| 485 | * `(−1)^0.5` gave `6.1·10⁻¹⁷ + i`) and loses digits for an integer exponent |
| 486 | * (`(−2)³` gave `−7.999999999999998`). Here: |
| 487 | * - an integer exponent of a real base is `Math.pow`, and a small integer |
| 488 | * exponent (`|n| ≤ 64`) of a complex base is computed by repeated |
| 489 | * squaring, so a Gaussian integer has an exact power. For a larger `|n|` |
| 490 | * the rounding error of each product grows with the number of products |
| 491 | * that follow it: `(1 + 10⁻⁹i)^(10⁹)` had a relative error of 10⁻⁹ by |
| 492 | * squaring, and the polar form below is used instead; |
| 493 | * - a real exponent of a base on an axis or a diagonal, whose angle is a |
| 494 | * multiple of `π/4`, takes the angle from `cosSinPi()`, which is exact at |
| 495 | * the multiples of `π/2` and gives `√2/2` at the odd multiples of `π/4` |
| 496 | * (a part is then the modulus divided by `√2`: `(2i)^{0.5}` is `1 + i`); |
| 497 | * - otherwise the polar form is used, with `ln|z|` computed without forming |
| 498 | * `|z|`, so a small part that is the value is kept |
| 499 | * (`2^(10⁻¹⁰⁰·i)` is `1 + 6.93·10⁻¹⁰¹i`). |
| 500 | * A zero base, or a value with an infinite or NaN part, uses the |
| 501 | * `complex.js` method. |
| 502 | */ |
| 503 | export function complexPow(z: Complex, w: Complex): Complex { |