Average Error: 25.9 → 26.0
Time: 18.6s
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}\;y.im \le 1.4830868861678625 \cdot 10^{+72}:\\ \;\;\;\;\frac{\frac{x.re \cdot y.re + y.im \cdot x.im}{\sqrt{y.im \cdot y.im + y.re \cdot y.re}}}{\sqrt{y.im \cdot y.im + y.re \cdot y.re}}\\ \mathbf{elif}\;y.im \le 3.4978915880616634 \cdot 10^{+152}:\\ \;\;\;\;\frac{x.im}{\sqrt{y.im \cdot y.im + y.re \cdot y.re}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{y.im \cdot y.im + y.re \cdot y.re}} \cdot \frac{\frac{x.re \cdot y.re + y.im \cdot x.im}{\sqrt{\sqrt{y.im \cdot y.im + y.re \cdot y.re}}}}{\sqrt{\sqrt{y.im \cdot y.im + y.re \cdot y.re}}}\\ \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 3 regimes
  2. if y.im < 1.4830868861678625e+72

    1. Initial program 22.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-sqrt22.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*22.5

      \[\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}}}\]

    if 1.4830868861678625e+72 < y.im < 3.4978915880616634e+152

    1. Initial program 23.4

      \[\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-sqrt23.4

      \[\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*23.2

      \[\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. Taylor expanded around 0 25.2

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

    if 3.4978915880616634e+152 < y.im

    1. Initial program 46.7

      \[\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-sqrt46.7

      \[\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 *-un-lft-identity46.7

      \[\leadsto \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} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}\]
    5. Applied times-frac46.7

      \[\leadsto \color{blue}{\frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{x.re \cdot y.re + x.im \cdot y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}\]
    6. Using strategy rm
    7. Applied add-sqr-sqrt46.7

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

      \[\leadsto \frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{x.re \cdot y.re + x.im \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}}}}\]
    9. Applied associate-/r*46.7

      \[\leadsto \frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \color{blue}{\frac{\frac{x.re \cdot y.re + x.im \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}}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification26.0

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

Reproduce

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