Average Error: 26.1 → 25.6
Time: 1.5m
Precision: 64
Internal Precision: 576
\[\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{y.re \cdot y.re + y.im \cdot y.im}{x.im \cdot y.re - x.re \cdot y.im} \le -1.636583666423324 \cdot 10^{-308}:\\ \;\;\;\;\frac{\frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}\\ \mathbf{if}\;\frac{y.re \cdot y.re + y.im \cdot y.im}{x.im \cdot y.re - x.re \cdot y.im} \le 0.0:\\ \;\;\;\;\frac{-x.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}{\sqrt{y.re \cdot y.re + y.im \cdot 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 (/ (+ (* y.re y.re) (* y.im y.im)) (- (* x.im y.re) (* x.re y.im))) < -1.636583666423324e-308 or 0.0 < (/ (+ (* y.re y.re) (* y.im y.im)) (- (* x.im y.re) (* x.re y.im)))

    1. Initial program 23.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-sqrt23.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 associate-/r*23.4

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

    if -1.636583666423324e-308 < (/ (+ (* y.re y.re) (* y.im y.im)) (- (* x.im y.re) (* x.re y.im))) < 0.0

    1. Initial program 60.5

      \[\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-sqrt60.5

      \[\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 associate-/r*60.5

      \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}\]
    5. Taylor expanded around -inf 53.9

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

      \[\leadsto \color{blue}{\frac{-x.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}\]
  3. Recombined 2 regimes into one program.

Runtime

Time bar (total: 1.5m)Debug logProfile

herbie shell --seed '#(1072840222 1305617769 1692503039 1353360431 4178980589 1488672652)' 
(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))))