Average Error: 25.4 → 22.7
Time: 19.9s
Precision: 64
Internal Precision: 128
\[\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{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} = -\infty:\\ \;\;\;\;\frac{y.re}{y.re \cdot y.re + y.im \cdot y.im} \cdot x.im - \frac{x.re}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}\\ \mathbf{elif}\;\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \le 1.2978434507798444 \cdot 10^{+268}:\\ \;\;\;\;\frac{\frac{\frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}}{\sqrt{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y.re}{y.re \cdot y.re + y.im \cdot y.im} \cdot x.im - \frac{x.re}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{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 (/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))) < -inf.0 or 1.2978434507798444e+268 < (/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im)))

    1. Initial program 60.0

      \[\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 div-sub60.1

      \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt60.1

      \[\leadsto \frac{x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} - \frac{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}}}\]
    6. Applied times-frac54.8

      \[\leadsto \frac{x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} - \color{blue}{\frac{x.re}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity54.8

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

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

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

    if -inf.0 < (/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))) < 1.2978434507798444e+268

    1. Initial program 11.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-sqrt11.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 associate-/r*11.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. Using strategy rm
    6. Applied add-sqr-sqrt11.5

      \[\leadsto \frac{\frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{\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}}}}}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}\]
    7. Applied sqrt-prod11.8

      \[\leadsto \frac{\frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{\sqrt{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \sqrt{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}}}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}\]
    8. Applied associate-/r*11.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} = -\infty:\\ \;\;\;\;\frac{y.re}{y.re \cdot y.re + y.im \cdot y.im} \cdot x.im - \frac{x.re}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}\\ \mathbf{elif}\;\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \le 1.2978434507798444 \cdot 10^{+268}:\\ \;\;\;\;\frac{\frac{\frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}}{\sqrt{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y.re}{y.re \cdot y.re + y.im \cdot y.im} \cdot x.im - \frac{x.re}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019068 
(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))))