Complex Numbers
complex
The complex number a + bi. Exact when a and b are. Complex values take the ordinary operators + - * / and a whole-number power ^ (z * w, z^2, 1/z), == and !=, and abs(z) for the modulus; the name i, when bound to nothing, is the imaginary unit in an expression of numbers: (3 + 4*i)*(1 - 2*i) is 11 - 2i.
a (number) -- real part
b (number) -- imaginary part
polar
The complex number with modulus r and argument theta (radians).
r (number) --
theta (number) -- 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).
z (complex) --
w (complex) --
div
The quotient z / w of two complex numbers.
z (complex) --
w (complex) --
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), exact where its parts allow: csqrt(-3) is sqrt(3)i as NCERT writes it, csqrt(-4) is 2i, csqrt(complex(3, 4)) is 2 + i; otherwise a decimal.
conj
The complex conjugate: conj(3 + 4*i) is 3 - 4i. sqrt of a complex value gives its principal root, as csqrt.
z (complex) -- The complex number
cpow
z^n for a whole-number n, exact when z is.
z (complex) --
n (integer) --
croots
All n n-th roots of z, as a list.
z (complex) --
n (integer) --
cpolyRoots
All roots of a polynomial of any degree with real or complex coefficients, given as a list from the highest power down; a root of multiplicity m appears m times. Roots whose parts are fractions are exact, the others are decimals; sorted by real part, then a + bi before a - bi. (For rational coefficients, solve(..., "complex") also gives radicals exactly.)
coefficients (list of complex) -- highest power first
cis
cos(theta) + i sin(theta), theta in radians; exact at multiples of 30 and 45 degrees (cis(pi/3) is 1/2 + sqrt(3)/2 i).
theta (number) -- radians
crotate
The complex number z turned counter-clockwise by theta radians about the point c: c + (z - c) cis(theta). Exact at multiples of 30 and 45 degrees. (rotate is for points, shapes and vectors.)
z (complex) --
c (complex) -- the centre
theta (number) -- radians
ccollinear
True when three complex numbers (points of the Argand plane) lie on one line: im(conj(z2 - z1)(z3 - z1)) = 0. (collinear is for points.)
z1 (complex) --
z2 (complex) --
z3 (complex) --
careaTriangle
The area of the triangle whose corners are three complex numbers: |im(conj(z2 - z1)(z3 - z1))| / 2.
z1 (complex) --
z2 (complex) --
z3 (complex) --
cdistanceToLine
The distance from the complex number z to the line through a and b: |im(conj(b - a)(z - a))| / |b - a|.
z (complex) --
a (complex) --
b (complex) --
cisSum
The sum of cis(2 pi j k / n) for j = 0, ..., n - 1, exact: n when n divides k, otherwise 0 (the sum of the n-th roots of unity, each raised to the k).
k (integer) --
n (integer) -- at least 1