Complex numbers


Literals

A complex number consists of a real component and an imaginary component. The real component is an ordinary real number, the imaginary component is a real number with the letter i appened. The two components are combined with the addition (+) operator. In most cases you will have to put the complex number in parenthesis to make it clear that the number forms a unit.

Some valid complexes: 45+2i, 4.67+34e-23i

Constants

Constant Definition
i The imaginary unit

 

Operators

Operator Description Examples
x + y Addition (1+2i)+(3+4i)
x - y Subtraction (1+2i)-(3+4i)
x * y Complex multiplication or scalar multiplication depending on the types of x and y. The * sign can be omitted as with real numbers. (1+2i)(3+4i), 3(1+2i)
x / y Division (1+2i)/(3+4i)
conj x Conjugation conj (1+2i)
re x Extracts the real component of x re (5+3i)
im x Extracts the imaginary component of x im (5+3i)