math-php
|
Class: Complex Complex Numbers. More...
Public Member Functions | |
__construct ($r, $i) | |
Constructor: __construct. More... | |
__toString () | |
Function: __toString String representation of a complex number a + bi, a - bi, etc. More... | |
__get (string $part) | |
Function: __get Get r or i. More... | |
complexConjugate () | |
The conjugate of a complex number. More... | |
abs () | |
The absolute value (magnitude) of a complex number (modulus) https://en.wikipedia.org/wiki/Complex_number#Absolute_value_and_argument. More... | |
arg () | |
The argument (phase) of a complex number The argument of z is the angle of the radius OP with the positive real axis, and is written as arg(z). More... | |
sqrt () | |
The square root of a complex number https://en.wikipedia.org/wiki/Complex_number#Square_root. More... | |
roots () | |
The roots of a complex number https://en.wikipedia.org/wiki/Complex_number#Square_root. More... | |
inverse () | |
The inverse of a complex number (reciprocal) More... | |
negate () | |
Negate the complex number Switches the signs of both the real and imaginary parts. More... | |
polarForm () | |
Polar form https://en.wikipedia.org/wiki/Complex_number#Polar_form. More... | |
add ($c) | |
Complex addition https://en.wikipedia.org/wiki/Complex_number#Addition_and_subtraction. More... | |
subtract ($c) | |
Complex subtraction https://en.wikipedia.org/wiki/Complex_number#Addition_and_subtraction. More... | |
multiply ($c) | |
Complex multiplication https://en.wikipedia.org/wiki/Complex_number#Multiplication_and_division. More... | |
divide ($c) | |
Complex division Dividing two complex numbers is accomplished by multiplying the first by the inverse of the second https://en.wikipedia.org/wiki/Complex_number#Multiplication_and_division. More... | |
equals (Complex $c) | |
Test for equality Two complex numbers are equal if and only if both their real and imaginary parts are equal. More... | |
Public Attributes | |
const | EPSILON = 1e-6 |
Floating-point range near zero to consider insignificant. | |
Protected Attributes | |
$r | |
$i | |
Class: Complex Complex Numbers.
A complex number is a number that can be expressed in the form a + bi, where a and b are real numbers and i is the imaginary unit, satisfying the equation i² = −1. In this expression, a is the real part and b is the imaginary part of the complex number. https://en.wikipedia.org/wiki/Complex_number
MathPHP\Number\Complex::__construct | ( | $r, | |
$i | |||
) |
Constructor: __construct.
number | $r | Real part |
number | $i | Imaginary part |
MathPHP\Number\Complex::__get | ( | string | $part | ) |
Function: __get Get r or i.
string | $part |
Exception |
MathPHP\Number\Complex::__toString | ( | ) |
Function: __toString String representation of a complex number a + bi, a - bi, etc.
MathPHP\Number\Complex::abs | ( | ) |
The absolute value (magnitude) of a complex number (modulus) https://en.wikipedia.org/wiki/Complex_number#Absolute_value_and_argument.
If z = a + bi
|z| = √a² + b²
MathPHP\Number\Complex::add | ( | $c | ) |
Complex addition https://en.wikipedia.org/wiki/Complex_number#Addition_and_subtraction.
(a + bi) + (c + di) = (a + c) + (b + d)i
mixed | $c |
Exception |
Implements MathPHP\Number\ObjectArithmetic.
MathPHP\Number\Complex::arg | ( | ) |
The argument (phase) of a complex number The argument of z is the angle of the radius OP with the positive real axis, and is written as arg(z).
https://en.wikipedia.org/wiki/Complex_number#Absolute_value_and_argument
If z = a + bi arg(z) = atan(b, a)
MathPHP\Number\Complex::complexConjugate | ( | ) |
The conjugate of a complex number.
https://en.wikipedia.org/wiki/Complex_number#Conjugate
MathPHP\Number\Complex::divide | ( | $c | ) |
Complex division Dividing two complex numbers is accomplished by multiplying the first by the inverse of the second https://en.wikipedia.org/wiki/Complex_number#Multiplication_and_division.
mixed | $c |
Exception |
MathPHP\Number\Complex::equals | ( | Complex | $c | ) |
Test for equality Two complex numbers are equal if and only if both their real and imaginary parts are equal.
https://en.wikipedia.org/wiki/Complex_number#Equality
Complex | $c |
MathPHP\Number\Complex::inverse | ( | ) |
The inverse of a complex number (reciprocal)
https://en.wikipedia.org/wiki/Complex_number#Reciprocal
Exception |
MathPHP\Number\Complex::multiply | ( | $c | ) |
Complex multiplication https://en.wikipedia.org/wiki/Complex_number#Multiplication_and_division.
(a + bi)(c + di) = (ac - bd) + (bc + ad)i
mixed | $c |
Exception |
Implements MathPHP\Number\ObjectArithmetic.
MathPHP\Number\Complex::negate | ( | ) |
Negate the complex number Switches the signs of both the real and imaginary parts.
MathPHP\Number\Complex::polarForm | ( | ) |
Polar form https://en.wikipedia.org/wiki/Complex_number#Polar_form.
z = a + bi = r(cos(θ) + i sin(θ)) Where r = |z| θ = arg(z) (in radians)
MathPHP\Number\Complex::roots | ( | ) |
The roots of a complex number https://en.wikipedia.org/wiki/Complex_number#Square_root.
The roots of a + bi (with b ≠ 0) are ±(γ + δi), where
____________ / _______ / a + √a² + b²
γ = / ---------— √ 2
____________ / _______ / -a + √a² + b²
δ = sgn(b) / ----------— √ 2
MathPHP\Number\Complex::sqrt | ( | ) |
The square root of a complex number https://en.wikipedia.org/wiki/Complex_number#Square_root.
The roots of a + bi (with b ≠ 0) are ±(γ + δi), where
____________ / _______ / a + √a² + b²
γ = / ---------— √ 2
____________ / _______ / -a + √a² + b²
δ = sgn(b) / ----------— √ 2
The square root returns the positive root.
MathPHP\Number\Complex::subtract | ( | $c | ) |
Complex subtraction https://en.wikipedia.org/wiki/Complex_number#Addition_and_subtraction.
(a + bi) - (c + di) = (a - c) + (b - d)i
mixed | $c |
Exception |
Implements MathPHP\Number\ObjectArithmetic.