PackageDescription: SYSEXT-Complex


SYSEXT - Complex

Last published: April 24, 2022 by 'nice'

Defines 1 Classes
Extends 5 Classes


This package brings complex numbers (formed from imaginary square root of -1)

(3 + 2 i) is the complex number with real part 3, and imaginary part 2.
(3 i: 2) is another notation of same Complex, which is preferred for efficiency: it generates less dispatching.

Complex are capable of arithmetic, and mixed arithmetic with other ArithmeticValue, by using double dispatching
They also respond to the main mathematical functions (exponentiation, exponential, logarithm, trigonometry, hyperbolic,...).

Note that the message i: itself uses double dispatching so as to enable extensions
(typically with imaginary parts of alternate kind of ArithmeticValue).
Default behavior is only implemented for Numbers.

This package also bring complex extensions for some functions (like sqrt ln arcCos arcSin arCosh arTanh).
This means that the domain of those function is extended, but the resulting value on domain extension is complex.

The package provides two different strategies to do so, at the choice of user:
1) default strategy: no automatic complex extension
Complex implementComplexExtensions: false.
In this case, user has to explicitely use asComplex to perform a complex extension of a function:
-2 asComplex ln
The result of such evaluation is always a Complex result rather than a DomainError
-2 ln
will still raise a DomainError
2) alternative strategy: always use complex extensions
Complex implementComplexExtensions: true.
In this case,
-2 ln
will answer a Complex once the package is installed, instead of raising an error
-2 asComplex
will return -2 in this case, since real numbers will now behave asComplex by themselves without requiring conversion
this is implemented by a modification of DomainError behavior so as to intercept the well known complex extensions