Complex
Complex
A complex number z = x + yi, where i = √-1.
i : Complex
The imaginary unit.
zero : Complex
The complex number z = 0 + 0i.
from_real : Num * -> Complex
Convert a number x to a complex number z = x + 0i.
from_imag : Num * -> Complex
Convert a number y to a complex number z = 0 + yi.
from_tuple :
(
Num *,
Num *
)
-> Complex
Convert two numbers x and y to a complex number z = x + yi. The inverse of [toTuple].
to_tuple :
Complex
->
(
F64,
F64
)
Convert a complex number z = x + yi to a tuple (x, y)
. The inverse of [fromTuple].
add : Complex, Complex -> Complex
Add two complex numbers together.
sub : Complex, Complex -> Complex
Subtract one complex number from another.
mul : Complex, Complex -> Complex
Multiply two complex numbers together.
div : Complex, Complex -> Complex
Divide one complex number by another.
reciprocal : Complex -> Complex
The reciprocal of a non-zero complex number.
abs : Complex -> F64
The absolute value of a complex number, which is the distance from 0. Defined as |x + yi| = √x² + y².
arg : Complex -> F64
The argument of a complex number, the angle from the positive x-axis.
to_polar :
Complex
->
{
r : F64,
arg : F64
}
Convert a complex number to polar form.
is_approx_eq :
Complex,
Complex,
{
rtol ? F64,
atol ? F64
}
-> Bool
Check if two complex numbers are approximately equal.