Average Error: 25.7 → 1.2
Time: 41.9s
Precision: 64
Internal Precision: 384
\[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
\[\begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{y.re^2 + y.im^2}^*} \cdot \left(\frac{y.re \cdot x.im}{\sqrt{y.re^2 + y.im^2}^*} - \frac{x.re}{\sqrt{\sqrt{y.re^2 + y.im^2}^*}} \cdot \frac{y.im}{\sqrt{\sqrt{y.re^2 + y.im^2}^*}}\right) \le -4.057114789023461 \cdot 10^{-127}:\\ \;\;\;\;\frac{\frac{y.re}{\sqrt{y.re^2 + y.im^2}^*}}{\frac{\sqrt{y.re^2 + y.im^2}^*}{x.im}} + \frac{\frac{-x.re}{\sqrt{y.re^2 + y.im^2}^*}}{\frac{\sqrt{y.re^2 + y.im^2}^*}{y.im}}\\ \mathbf{if}\;\frac{1}{\sqrt{y.re^2 + y.im^2}^*} \cdot \left(\frac{y.re \cdot x.im}{\sqrt{y.re^2 + y.im^2}^*} - \frac{x.re}{\sqrt{\sqrt{y.re^2 + y.im^2}^*}} \cdot \frac{y.im}{\sqrt{\sqrt{y.re^2 + y.im^2}^*}}\right) \le 1.3673325635416466 \cdot 10^{+297}:\\ \;\;\;\;\frac{1}{\sqrt{y.re^2 + y.im^2}^*} \cdot \left(\frac{y.re \cdot x.im}{\sqrt{y.re^2 + y.im^2}^*} - \frac{x.re}{\sqrt{\sqrt{y.re^2 + y.im^2}^*}} \cdot \frac{y.im}{\sqrt{\sqrt{y.re^2 + y.im^2}^*}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y.re}{\sqrt{y.re^2 + y.im^2}^*}}{\frac{\sqrt{y.re^2 + y.im^2}^*}{x.im}} + \frac{\frac{-x.re}{\sqrt{y.re^2 + y.im^2}^*}}{\frac{\sqrt{y.re^2 + y.im^2}^*}{y.im}}\\ \end{array}\]

Error

Bits error versus x.re

Bits error versus x.im

Bits error versus y.re

Bits error versus y.im

Derivation

  1. Split input into 2 regimes
  2. if (* (/ 1 (hypot y.re y.im)) (- (/ (* y.re x.im) (hypot y.re y.im)) (* (/ x.re (sqrt (hypot y.re y.im))) (/ y.im (sqrt (hypot y.re y.im)))))) < -4.057114789023461e-127 or 1.3673325635416466e+297 < (* (/ 1 (hypot y.re y.im)) (- (/ (* y.re x.im) (hypot y.re y.im)) (* (/ x.re (sqrt (hypot y.re y.im))) (/ y.im (sqrt (hypot y.re y.im))))))

    1. Initial program 34.6

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt34.6

      \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}}\]
    4. Applied *-un-lft-identity34.6

      \[\leadsto \frac{\color{blue}{1 \cdot \left(x.im \cdot y.re - x.re \cdot y.im\right)}}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}\]
    5. Applied times-frac34.6

      \[\leadsto \color{blue}{\frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}\]
    6. Applied simplify34.6

      \[\leadsto \color{blue}{\frac{1}{\sqrt{y.re^2 + y.im^2}^*}} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}\]
    7. Applied simplify31.0

      \[\leadsto \frac{1}{\sqrt{y.re^2 + y.im^2}^*} \cdot \color{blue}{\frac{y.re \cdot x.im - x.re \cdot y.im}{\sqrt{y.re^2 + y.im^2}^*}}\]
    8. Using strategy rm
    9. Applied div-sub31.0

      \[\leadsto \frac{1}{\sqrt{y.re^2 + y.im^2}^*} \cdot \color{blue}{\left(\frac{y.re \cdot x.im}{\sqrt{y.re^2 + y.im^2}^*} - \frac{x.re \cdot y.im}{\sqrt{y.re^2 + y.im^2}^*}\right)}\]
    10. Using strategy rm
    11. Applied sub-neg31.0

      \[\leadsto \frac{1}{\sqrt{y.re^2 + y.im^2}^*} \cdot \color{blue}{\left(\frac{y.re \cdot x.im}{\sqrt{y.re^2 + y.im^2}^*} + \left(-\frac{x.re \cdot y.im}{\sqrt{y.re^2 + y.im^2}^*}\right)\right)}\]
    12. Applied distribute-rgt-in31.0

      \[\leadsto \color{blue}{\frac{y.re \cdot x.im}{\sqrt{y.re^2 + y.im^2}^*} \cdot \frac{1}{\sqrt{y.re^2 + y.im^2}^*} + \left(-\frac{x.re \cdot y.im}{\sqrt{y.re^2 + y.im^2}^*}\right) \cdot \frac{1}{\sqrt{y.re^2 + y.im^2}^*}}\]
    13. Applied simplify11.6

      \[\leadsto \color{blue}{\frac{\frac{y.re}{\sqrt{y.re^2 + y.im^2}^*}}{\frac{\sqrt{y.re^2 + y.im^2}^*}{x.im}}} + \left(-\frac{x.re \cdot y.im}{\sqrt{y.re^2 + y.im^2}^*}\right) \cdot \frac{1}{\sqrt{y.re^2 + y.im^2}^*}\]
    14. Applied simplify1.7

      \[\leadsto \frac{\frac{y.re}{\sqrt{y.re^2 + y.im^2}^*}}{\frac{\sqrt{y.re^2 + y.im^2}^*}{x.im}} + \color{blue}{\frac{\frac{-x.re}{\sqrt{y.re^2 + y.im^2}^*}}{\frac{\sqrt{y.re^2 + y.im^2}^*}{y.im}}}\]

    if -4.057114789023461e-127 < (* (/ 1 (hypot y.re y.im)) (- (/ (* y.re x.im) (hypot y.re y.im)) (* (/ x.re (sqrt (hypot y.re y.im))) (/ y.im (sqrt (hypot y.re y.im)))))) < 1.3673325635416466e+297

    1. Initial program 20.4

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt20.4

      \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}}\]
    4. Applied *-un-lft-identity20.4

      \[\leadsto \frac{\color{blue}{1 \cdot \left(x.im \cdot y.re - x.re \cdot y.im\right)}}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}\]
    5. Applied times-frac20.4

      \[\leadsto \color{blue}{\frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}\]
    6. Applied simplify20.4

      \[\leadsto \color{blue}{\frac{1}{\sqrt{y.re^2 + y.im^2}^*}} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}\]
    7. Applied simplify8.0

      \[\leadsto \frac{1}{\sqrt{y.re^2 + y.im^2}^*} \cdot \color{blue}{\frac{y.re \cdot x.im - x.re \cdot y.im}{\sqrt{y.re^2 + y.im^2}^*}}\]
    8. Using strategy rm
    9. Applied div-sub8.0

      \[\leadsto \frac{1}{\sqrt{y.re^2 + y.im^2}^*} \cdot \color{blue}{\left(\frac{y.re \cdot x.im}{\sqrt{y.re^2 + y.im^2}^*} - \frac{x.re \cdot y.im}{\sqrt{y.re^2 + y.im^2}^*}\right)}\]
    10. Using strategy rm
    11. Applied add-sqr-sqrt8.1

      \[\leadsto \frac{1}{\sqrt{y.re^2 + y.im^2}^*} \cdot \left(\frac{y.re \cdot x.im}{\sqrt{y.re^2 + y.im^2}^*} - \frac{x.re \cdot y.im}{\color{blue}{\sqrt{\sqrt{y.re^2 + y.im^2}^*} \cdot \sqrt{\sqrt{y.re^2 + y.im^2}^*}}}\right)\]
    12. Applied times-frac0.9

      \[\leadsto \frac{1}{\sqrt{y.re^2 + y.im^2}^*} \cdot \left(\frac{y.re \cdot x.im}{\sqrt{y.re^2 + y.im^2}^*} - \color{blue}{\frac{x.re}{\sqrt{\sqrt{y.re^2 + y.im^2}^*}} \cdot \frac{y.im}{\sqrt{\sqrt{y.re^2 + y.im^2}^*}}}\right)\]
  3. Recombined 2 regimes into one program.

Runtime

Time bar (total: 41.9s)Debug logProfile

herbie shell --seed '#(1064173506 2580572819 2847706409 4129882574 1125180799 1845288547)' +o rules:numerics
(FPCore (x.re x.im y.re y.im)
  :name "_divideComplex, imaginary part"
  (/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))))