Average Error: 26.0 → 5.4
Time: 18.2s
Precision: 64
Internal Precision: 576
\[\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.248615783269193 \cdot 10^{+47}:\\ \;\;\;\;\frac{\frac{y.re \cdot x.re}{\sqrt{y.im^2 + y.re^2}^*} + y.im \cdot \left(x.im \cdot \frac{1}{\sqrt{y.im^2 + y.re^2}^*}\right)}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{elif}\;y.im \le 2.2036828621787964 \cdot 10^{+182}:\\ \;\;\;\;\frac{(\left(\frac{y.re}{\sqrt{y.im^2 + y.re^2}^*}\right) \cdot x.re + \left(\frac{x.im \cdot y.im}{\sqrt{y.im^2 + y.re^2}^*}\right))_*}{\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.248615783269193e+47

    1. Initial program 35.3

      \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Initial simplification35.3

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

      \[\leadsto \frac{(x.re \cdot y.re + \left(x.im \cdot y.im\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 *-un-lft-identity35.3

      \[\leadsto \frac{\color{blue}{1 \cdot (x.re \cdot y.re + \left(x.im \cdot y.im\right))_*}}{\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))_*}}\]
    6. Applied times-frac35.3

      \[\leadsto \color{blue}{\frac{1}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}} \cdot \frac{(x.re \cdot y.re + \left(x.im \cdot y.im\right))_*}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}}\]
    7. Simplified35.3

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

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

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

      \[\leadsto \frac{\frac{1}{\sqrt{y.im^2 + y.re^2}^*} \cdot \color{blue}{\left(y.im \cdot x.im + x.re \cdot y.re\right)}}{\sqrt{y.im^2 + y.re^2}^*}\]
    13. Applied distribute-rgt-in23.9

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

      \[\leadsto \frac{\left(y.im \cdot x.im\right) \cdot \frac{1}{\sqrt{y.im^2 + y.re^2}^*} + \color{blue}{\frac{x.re \cdot y.re}{\sqrt{y.im^2 + y.re^2}^*}}}{\sqrt{y.im^2 + y.re^2}^*}\]
    15. Using strategy rm
    16. Applied associate-*l*8.3

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

    if -2.248615783269193e+47 < y.im < 2.2036828621787964e+182

    1. Initial program 20.3

      \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Initial simplification20.3

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

      \[\leadsto \frac{(x.re \cdot y.re + \left(x.im \cdot y.im\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 *-un-lft-identity20.3

      \[\leadsto \frac{\color{blue}{1 \cdot (x.re \cdot y.re + \left(x.im \cdot y.im\right))_*}}{\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))_*}}\]
    6. Applied times-frac20.3

      \[\leadsto \color{blue}{\frac{1}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}} \cdot \frac{(x.re \cdot y.re + \left(x.im \cdot y.im\right))_*}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}}\]
    7. Simplified20.3

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

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

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

      \[\leadsto \frac{\frac{1}{\sqrt{y.im^2 + y.re^2}^*} \cdot \color{blue}{\left(y.im \cdot x.im + x.re \cdot y.re\right)}}{\sqrt{y.im^2 + y.re^2}^*}\]
    13. Applied distribute-rgt-in12.9

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

      \[\leadsto \frac{\left(y.im \cdot x.im\right) \cdot \frac{1}{\sqrt{y.im^2 + y.re^2}^*} + \color{blue}{\frac{x.re \cdot y.re}{\sqrt{y.im^2 + y.re^2}^*}}}{\sqrt{y.im^2 + y.re^2}^*}\]
    15. Using strategy rm
    16. Applied *-un-lft-identity12.8

      \[\leadsto \frac{\left(y.im \cdot x.im\right) \cdot \frac{1}{\sqrt{y.im^2 + y.re^2}^*} + \frac{x.re \cdot y.re}{\sqrt{y.im^2 + y.re^2}^*}}{\color{blue}{1 \cdot \sqrt{y.im^2 + y.re^2}^*}}\]
    17. Applied *-un-lft-identity12.8

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(y.im \cdot x.im\right) \cdot \frac{1}{\sqrt{y.im^2 + y.re^2}^*} + \frac{x.re \cdot y.re}{\sqrt{y.im^2 + y.re^2}^*}\right)}}{1 \cdot \sqrt{y.im^2 + y.re^2}^*}\]
    18. Applied times-frac12.8

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

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

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

    if 2.2036828621787964e+182 < y.im

    1. Initial program 42.9

      \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Initial simplification42.9

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

      \[\leadsto \frac{(x.re \cdot y.re + \left(x.im \cdot y.im\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 *-un-lft-identity42.9

      \[\leadsto \frac{\color{blue}{1 \cdot (x.re \cdot y.re + \left(x.im \cdot y.im\right))_*}}{\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))_*}}\]
    6. Applied times-frac42.9

      \[\leadsto \color{blue}{\frac{1}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}} \cdot \frac{(x.re \cdot y.re + \left(x.im \cdot y.im\right))_*}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}}\]
    7. Simplified42.9

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \le -2.248615783269193 \cdot 10^{+47}:\\ \;\;\;\;\frac{\frac{y.re \cdot x.re}{\sqrt{y.im^2 + y.re^2}^*} + y.im \cdot \left(x.im \cdot \frac{1}{\sqrt{y.im^2 + y.re^2}^*}\right)}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{elif}\;y.im \le 2.2036828621787964 \cdot 10^{+182}:\\ \;\;\;\;\frac{(\left(\frac{y.re}{\sqrt{y.im^2 + y.re^2}^*}\right) \cdot x.re + \left(\frac{x.im \cdot y.im}{\sqrt{y.im^2 + y.re^2}^*}\right))_*}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{\sqrt{y.im^2 + y.re^2}^*}\\ \end{array}\]

Runtime

Time bar (total: 18.2s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes9.95.40.69.348.3%
herbie shell --seed 2018297 +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))))