Complex number functions
As a general rule, you can pass a complex number to nearly any of the built-in mathematical functions described elsewhere in this manual for which a complex variation of the function is meaningful. For example, you can evaluate Sqrt(3 + 2j), Exp(4 - 1j), Ln(-1 - 3j), ArcCos(1 - 2j), (3 + 2j)^(1 - 3j)
, and so on.
EnableComplexNumbers
There are several standard mathematical functions that produce a complex number when passed a real-valued parameter -- for example, Sqrt(-1)
or ArcCos(2)
. These will produce a warning and return NaN
unless you have enabled complex numbers. To enable complex numbers, make sure you are in edit mode with no object selected, then select Definition → System Variables → EnableComplexNumbers. Change the definition to 1. After it is changed, these functions return a complex result without a warning.
Degrees or radians?: Analytica’s trigonometric functions operate using degrees rather than radians, but exponential and logarithm functions, when applied to complex numbers, operate in radians so as to produce the conventional results. Hence, Euler’s identity becomes
Exp(1j*x) = Cos(Degrees(x)) + 1j * Sin(Degrees(x))
The scalar functions listed here are specific to complex numbers. For more details on using complex numbers, see Complex Numbers on the Analytica Wiki, and “Complex Numbers” in the User Guide.
Abs(x)
The magnitude of a complex number.
Abs(3 - 4j) → 5
ComplexDegrees(x)
The phase of a complex number in degrees, between -180 and 180.
ComplexDegrees(-1 + 1j) → 135
ComplexRadians(x)
The phase of a complex number in radians, between -π and π.
ComplexRadians(-1j) → -1.571
Conj(x)
The complex conjugate on a number.
Conj(4 + 8j) → 4 - 8j
ImPart(x)
The imaginary part of a complex number.
ImPart(3+4j) → 4
RealPart(x)
The real part of a complex number.
RealPart(3 + 4j) → 3
Enable comment auto-refresher