(complex)
| 2103 | return this.times(...arguments) |
| 2104 | } |
| 2105 | times(complex) { |
| 2106 | if (!complex.isComplex) { |
| 2107 | throw "[TheoremJS]: Complex operation require complex numbers" |
| 2108 | } |
| 2109 | const a = this.a |
| 2110 | const b = this.b |
| 2111 | this.a = a.times(complex.a).minus(b.times(complex.b)) |
| 2112 | this.b = a |
| 2113 | .plus(b) |
| 2114 | .times(complex.a.plus(complex.b)) |
| 2115 | .minus(a.times(complex.a)) |
| 2116 | .minus(b.times(complex.b)) // (a+b)(c+d)-ac-bd. |
| 2117 | return this |
| 2118 | } |
| 2119 | toString() { |
| 2120 | return `${this.a.toString()} ${this.b.lt(0) ? "-" : "+"} ${this.b.abs().toString()}i` |
| 2121 | } |
no test coverage detected