Average Error: 26.5 → 12.8
Time: 20.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.im \le -2.865517408624961 \cdot 10^{+166}:\\ \;\;\;\;x.im \cdot \frac{-1}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{elif}\;y.im \le 1.3321223559131863 \cdot 10^{+171}:\\ \;\;\;\;\frac{\frac{y.re \cdot x.re + x.im \cdot y.im}{\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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if y.im < -2.865517408624961e+166

    1. Initial program 44.3

      \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Initial simplification44.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-sqrt44.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-identity44.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-frac44.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. Simplified44.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. Simplified29.5

      \[\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. Taylor expanded around -inf 12.7

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

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

    if -2.865517408624961e+166 < y.im < 1.3321223559131863e+171

    1. Initial program 20.9

      \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Initial simplification20.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-sqrt20.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-identity20.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-frac20.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. Simplified20.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. Simplified13.0

      \[\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-*l/12.9

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

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

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

    if 1.3321223559131863e+171 < y.im

    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. Initial simplification44.1

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

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

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

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

      \[\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. Simplified29.5

      \[\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-*l/29.5

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

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

      \[\leadsto \frac{\frac{\color{blue}{y.re \cdot x.re + x.im \cdot y.im}}{\sqrt{y.im^2 + y.re^2}^*}}{\sqrt{y.im^2 + y.re^2}^*}\]
    14. Taylor expanded around 0 12.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \le -2.865517408624961 \cdot 10^{+166}:\\ \;\;\;\;x.im \cdot \frac{-1}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{elif}\;y.im \le 1.3321223559131863 \cdot 10^{+171}:\\ \;\;\;\;\frac{\frac{y.re \cdot x.re + x.im \cdot y.im}{\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}\]

Runtime

Time bar (total: 20.9s)Debug logProfile

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