ApasScript.

Complex Numbers

complex

The complex number a + bi. Exact when a and b are.

polar

The complex number with modulus r and argument theta (radians).

re

The real part of a complex number (also z.re).

im

The imaginary part of a complex number (also z.im).

conjugate

The complex conjugate a - bi. Also the conjugate of a quaternion.

modulus

|z| = sqrt(a^2 + b^2), exact (a surd when irrational).

modulusSq

|z|^2 = a^2 + b^2, exact.

argument

The argument (angle) of z in radians, in (-pi, pi].

toPolar

The modulus r and argument theta of z, as a record (z.r, z.theta).

isReal

True if the imaginary part is zero.

isImaginary

True if the real part is zero.

mul

The product of two complex numbers (a plain number counts as complex). Also the product of two quaternions (not commutative: ij = k, ji = -k).

div

The quotient z / w of two complex numbers.

cexp

e^z for a complex z.

clog

The principal natural logarithm of a complex z.

csqrt

The principal square root of a complex z (also of a negative number).

cpow

z^n for a whole-number n, exact when z is.

croots

All n n-th roots of z, as a list.