Average Error: 26.3 → 13.0
Time: 25.9s
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.re \le -1.2534913427767432 \cdot 10^{+147}:\\ \;\;\;\;\frac{-x.re}{\sqrt{y.re^2 + y.im^2}^*}\\ \mathbf{elif}\;y.re \le 2.135523821820183 \cdot 10^{+102}:\\ \;\;\;\;\frac{\frac{1}{\frac{\sqrt{y.re^2 + y.im^2}^*}{(y.im \cdot x.im + \left(x.re \cdot y.re\right))_*}}}{\sqrt{y.re^2 + y.im^2}^*}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{\sqrt{y.re^2 + y.im^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.re < -1.2534913427767432e+147

    1. Initial program 44.1

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\sqrt{y.re^2 + y.im^2}^*}} \cdot \frac{x.re \cdot y.re + x.im \cdot y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}\]
    7. Simplified27.9

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

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

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

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

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

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

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

    if -1.2534913427767432e+147 < y.re < 2.135523821820183e+102

    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. Using strategy rm
    3. Applied add-sqr-sqrt19.0

      \[\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-identity19.0

      \[\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-frac19.0

      \[\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. Simplified19.0

      \[\leadsto \color{blue}{\frac{1}{\sqrt{y.re^2 + y.im^2}^*}} \cdot \frac{x.re \cdot y.re + x.im \cdot y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}\]
    7. Simplified11.9

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

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

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

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

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

    if 2.135523821820183e+102 < y.re

    1. Initial program 39.8

      \[\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-sqrt39.8

      \[\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-identity39.8

      \[\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-frac39.8

      \[\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. Simplified39.8

      \[\leadsto \color{blue}{\frac{1}{\sqrt{y.re^2 + y.im^2}^*}} \cdot \frac{x.re \cdot y.re + x.im \cdot y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}\]
    7. Simplified26.0

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

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

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

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

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

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

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

Runtime

Time bar (total: 25.9s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes16.713.02.314.426.2%
herbie shell --seed 2018351 +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))))