* Divide two complex numbers * @param other - The 2nd complex number operand * @returns The result of the division x / other
(other: complex)
| 72 | * @returns The result of the division x / other |
| 73 | */ |
| 74 | public div(other: complex): complex |
| 75 | { |
| 76 | /* Complex division: |
| 77 | ac + bd bc - ad |
| 78 | -------- + -------- i |
| 79 | c^2 + d^2 c^2 + d^2 |
| 80 | */ |
| 81 | let ac = this._real * other.real; |
| 82 | let bd = this._img * other.img; |
| 83 | let bc = this._img * other.real; |
| 84 | let ad = this._real * other.img; |
| 85 | let cc = other.real * other.real; |
| 86 | let dd = other.img * other.img; |
| 87 | return new complex ((ac + bd) / (cc + dd), (bc - ad) / (cc + dd)); |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Scalar multiply a complex number, by a real number lambda |