Average Error: 25.7 → 25.1
Time: 18.2s
Precision: 64
Internal Precision: 128
\[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x.im \cdot y.im + x.re \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} \le 3.4957913056678415 \cdot 10^{+302}:\\ \;\;\;\;\frac{\frac{1}{\frac{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}{x.im \cdot y.im + x.re \cdot y.re}}}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.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.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im))) < 3.4957913056678415e+302

    1. Initial program 13.6

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

      \[\leadsto \frac{x.re \cdot y.re + x.im \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*13.6

      \[\leadsto \color{blue}{\frac{\frac{x.re \cdot y.re + x.im \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 *-un-lft-identity13.6

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot \left(x.re \cdot y.re + x.im \cdot y.im\right)}}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}\]
    7. Applied associate-/l*13.6

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

    if 3.4957913056678415e+302 < (/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im)))

    1. Initial program 62.3

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

      \[\leadsto \frac{x.re \cdot y.re + x.im \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*62.3

      \[\leadsto \color{blue}{\frac{\frac{x.re \cdot y.re + x.im \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 div-inv62.3

      \[\leadsto \frac{\color{blue}{\left(x.re \cdot y.re + x.im \cdot y.im\right) \cdot \frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}\]
    7. Taylor expanded around 0 60.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x.im \cdot y.im + x.re \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} \le 3.4957913056678415 \cdot 10^{+302}:\\ \;\;\;\;\frac{\frac{1}{\frac{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}{x.im \cdot y.im + x.re \cdot y.re}}}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019050 
(FPCore (x.re x.im y.re y.im)
  :name "_divideComplex, real part"
  (/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im))))