This is the Complex class version 1.0.
Represents a complex number.
Ferret has native support for complex numbers, including syntax for the
normal mathematic notation in rectangular form a + bi
, where a
and b
are real numbers and i
is the
imaginary unit.
a
and b
are commonly called the "real part" and "imaginary part"
respectively, despite both being real numbers.
Complex numbers can also be constructed from polar representations
r(cosθ + isinθ)
or re^(iθ)
with Complex.polar()
.
$z = Complex($a: Num, $b: Num)
Creates a complex number with the given real and imaginary parts. This is
only useful to create a complex number from variable parts, since Ferret
has native support for inline a + bi
notation.
If the given imaginary part is zero, the constructor returns the real part as a real number.
$z = Complex($r: Num, $θ: Num)
Create a complex number in polar form given radius r
and angle θ
.
z = r(cosθ + isinθ)
.
-
r: Num - Distance from the origin in the complex plane.
-
θ: Num - Angle between the positive real axis and the.
$z.abs
Computed property. Absolute value (or modulus) of the complex number. This is distance from the origin on the complex plane.
In polar form, this is r
.
$z.arg
Computed property. Argument of
the complex number. On the
complex plane, this is the
angle θ
between the positive real axis and the position vector.
In polar form, this is θ
.
$z.conj
Computed property. Conjugate of the complex number.
$z.sqrt
Computed property. Square root of the complex number.
$z.root($n: Num)
Nth root of the complex number.
- n: Num
$z + ($rhs: Complex)
Addition of complex numbers.
$z + ($ehs: Num)
Addition of complex and real numbers.
$z - ($rhs: Complex)
Subtraction of complex numbers.
$z - ($rhs: Num)
Subtraction of real number from complex number.
$z - ($lhs: Num)
Subtraction of complex number from real number.
$z * ($rhs: Complex)
Multiplication of complex numbers.
$z * ($ehs: Num)
Multiplication of real and complex numbers.
$z / ($rhs: Complex)
Division of complex numbers.
$z / ($rhs: Num)
Division of complex number by real number.
$z ^ ($rhs: Num)
Complex number to real power.
This can get expensive for large powers.
For a quicker but less precise alternative, use .pow()
.
$z ^ ($lhs: Num)
Real number to a complex power.
$z == ($ehs: Complex)
Equality of complex numbers.
$z == ($ehs: Num)
Equality of complex number and real number.
$z.pow($rhs: Num)
Complex number to real power. This is an alternative implementation to the power operator which is faster but less precise.
- rhs: Num
Complex.polar($r: Num, $θ: Num)
Create a complex number in polar form given radius r
and angle θ
.
z = r(cosθ + isinθ)
.
-
r: Num - Distance from the origin in the complex plane.
-
θ: Num - Angle between the positive real axis and the.
End of the Complex class.
This file was generated automatically by the Ferret compiler from Complex.frt.