Average Error: 25.2 → 12.5
Time: 20.9s
Precision: 64
Internal Precision: 384
\[\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 -2.36398613215644 \cdot 10^{+156}:\\ \;\;\;\;\frac{-x.im}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{if}\;y.im \le 2.4347391390427925 \cdot 10^{+164}:\\ \;\;\;\;\frac{\frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{\sqrt{y.im^2 + y.re^2}^*}}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{\sqrt{y.im^2 + y.re^2}^*}\\ \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 < -2.36398613215644e+156

    1. Initial program 43.7

      \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Applied simplify43.7

      \[\leadsto \color{blue}{\frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt43.7

      \[\leadsto \frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{\color{blue}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*} \cdot \sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}}\]
    5. Applied associate-/r*43.7

      \[\leadsto \color{blue}{\frac{\frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}}\]
    6. Using strategy rm
    7. Applied fma-udef43.7

      \[\leadsto \frac{\frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{\sqrt{\color{blue}{y.im \cdot y.im + y.re \cdot y.re}}}}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}\]
    8. Applied hypot-def43.7

      \[\leadsto \frac{\frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{\color{blue}{\sqrt{y.im^2 + y.re^2}^*}}}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}\]
    9. Using strategy rm
    10. Applied fma-udef43.7

      \[\leadsto \frac{\frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{\sqrt{y.im^2 + y.re^2}^*}}{\sqrt{\color{blue}{y.im \cdot y.im + y.re \cdot y.re}}}\]
    11. Applied hypot-def28.1

      \[\leadsto \frac{\frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{\sqrt{y.im^2 + y.re^2}^*}}{\color{blue}{\sqrt{y.im^2 + y.re^2}^*}}\]
    12. Taylor expanded around -inf 11.3

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

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

    if -2.36398613215644e+156 < y.im < 2.4347391390427925e+164

    1. Initial program 19.0

      \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Applied simplify19.0

      \[\leadsto \color{blue}{\frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt19.0

      \[\leadsto \frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{\color{blue}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*} \cdot \sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}}\]
    5. Applied associate-/r*18.9

      \[\leadsto \color{blue}{\frac{\frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}}\]
    6. Using strategy rm
    7. Applied fma-udef18.9

      \[\leadsto \frac{\frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{\sqrt{\color{blue}{y.im \cdot y.im + y.re \cdot y.re}}}}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}\]
    8. Applied hypot-def18.9

      \[\leadsto \frac{\frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{\color{blue}{\sqrt{y.im^2 + y.re^2}^*}}}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}\]
    9. Using strategy rm
    10. Applied fma-udef18.9

      \[\leadsto \frac{\frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{\sqrt{y.im^2 + y.re^2}^*}}{\sqrt{\color{blue}{y.im \cdot y.im + y.re \cdot y.re}}}\]
    11. Applied hypot-def12.6

      \[\leadsto \frac{\frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{\sqrt{y.im^2 + y.re^2}^*}}{\color{blue}{\sqrt{y.im^2 + y.re^2}^*}}\]

    if 2.4347391390427925e+164 < y.im

    1. Initial program 43.7

      \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Applied simplify43.7

      \[\leadsto \color{blue}{\frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt43.7

      \[\leadsto \frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{\color{blue}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*} \cdot \sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}}\]
    5. Applied associate-/r*43.7

      \[\leadsto \color{blue}{\frac{\frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}}\]
    6. Using strategy rm
    7. Applied fma-udef43.7

      \[\leadsto \frac{\frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{\sqrt{\color{blue}{y.im \cdot y.im + y.re \cdot y.re}}}}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}\]
    8. Applied hypot-def43.7

      \[\leadsto \frac{\frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{\color{blue}{\sqrt{y.im^2 + y.re^2}^*}}}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}\]
    9. Using strategy rm
    10. Applied fma-udef43.7

      \[\leadsto \frac{\frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{\sqrt{y.im^2 + y.re^2}^*}}{\sqrt{\color{blue}{y.im \cdot y.im + y.re \cdot y.re}}}\]
    11. Applied hypot-def29.0

      \[\leadsto \frac{\frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{\sqrt{y.im^2 + y.re^2}^*}}{\color{blue}{\sqrt{y.im^2 + y.re^2}^*}}\]
    12. Taylor expanded around inf 12.8

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

Runtime

Time bar (total: 20.9s)Debug logProfile

herbie shell --seed '#(1070131407 1246090267 3027482374 2150728003 2026520792 2347815650)' +o rules:numerics
(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))))