| 1895 | return this.times(...arguments) |
| 1896 | } |
| 1897 | div(complex) { |
| 1898 | if (!complex.isComplex) { |
| 1899 | throw "[TheoremJS]: Complex operation require complex numbers" |
| 1900 | } |
| 1901 | |
| 1902 | const a = this.a |
| 1903 | const b = this.b |
| 1904 | const c = complex.a |
| 1905 | const d = complex.b |
| 1906 | |
| 1907 | const c2d2 = c.times(c).plus(d.times(d)) // c^2 + d^2 |
| 1908 | |
| 1909 | const acbd = a.times(c).plus(b.times(d)) // a*c + b*d |
| 1910 | const bcad = b.times(c).minus(a.times(d)) // b*c - a*d |
| 1911 | |
| 1912 | const re = acbd.div(c2d2) |
| 1913 | const im = bcad.div(c2d2) |
| 1914 | |
| 1915 | this.a = re |
| 1916 | this.b = im |
| 1917 | |
| 1918 | return this |
| 1919 | } |
| 1920 | equal() { |
| 1921 | return this.eq(...arguments) |
| 1922 | } |