Complex numbers are represented by a dictionary of real and imaginary attributes:
complex( x, y ) — returns a complex number as { re: x, im: y }
complex( x ) — returns a complex number as { re: x, im: 0 }
complex( x, y ).re = x complex( x, y ).im = y
or with convenience functions:
re( x ) — real part of a real or complex number
real( x ) — real part of a real or complex number
im( x ) — imaginary part of a real or complex number
imag( x ) — imaginary part of a real or complex number
add( x, y ) — add two real or complex numbers of x+y
add( x, y, z, … ) — add an arbitrary number of real or complex numbers of x+y+z
sub( x, y ) — subtract two real or complex numbers of x-y
mul( x, y ) — multiply two real or complex numbers of x*y
mul( x, y, z, … ) — multiply an arbitrary number of real or complex numbers of x*y*z
div( x, y ) — divide two real or complex numbers of x/y
neg( x ) — negate a real or complex number of -x
inv( x ) — invert a real or complex number of 1/z
pow( x, y ) — power two real or complex numbers of x^y
root( x, y ) — root two real or complex numbers of x^(1/y)