Complex

Complex is an object that represents complex numbers.

To create a complex number, call Complex(re, im) where re is the real part and im is the imaginary part.

Complex numbers can also be created by multiplying an expression with I, for example, 3*I or 3+2.5*I. I is the predefined global Complex representing the imaginary unit.

Complex supports all the usual arithmetic operators, such as addition (+), subtraction (-), multiplication (*), division (/), and exponentiation (**).

The equality operator == compares the real and imaginary parts.

Syntax

Complex

Properties

prototype

Prototype Properties

Examples

Complex(1, 2)
1+2*I
Complex(1,2) == 1+2*I
true
sqrt(-1)
I
3-2.5*I
3-2.5*I
3-2.5*I / 2
3-1.25*I
print(Complex(1, 2) == Complex(1, 2))
print(Complex(1, 2) === Complex(1, 2))
true
false