Average Error: 26.1 → 12.5
Time: 1.4m
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.re \le -6.944581811349617 \cdot 10^{+152}:\\ \;\;\;\;\frac{-x.re}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{elif}\;y.re \le 1.9226615919915936 \cdot 10^{+117}:\\ \;\;\;\;\frac{\frac{(y.re \cdot x.re + \left(y.im \cdot x.im\right))_*}{\sqrt{y.im^2 + y.re^2}^*}}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{\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.re < -6.944581811349617e+152

    1. Initial program 44.2

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

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

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

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

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

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

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

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

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

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

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

    if -6.944581811349617e+152 < y.re < 1.9226615919915936e+117

    1. Initial program 18.7

      \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Initial simplification18.7

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

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

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

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

      \[\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. Simplified11.6

      \[\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/11.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. Simplified11.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}^*}\]

    if 1.9226615919915936e+117 < y.re

    1. Initial program 41.7

      \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Initial simplification41.7

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

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

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

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

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

      \[\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/27.1

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

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

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

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

Runtime

Time bar (total: 1.4m)Debug logProfile

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