Average Error: 25.4 → 14.1
Time: 1.1m
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 3.637924346615467 \cdot 10^{+157}:\\ \;\;\;\;\frac{1}{\sqrt{y.im^2 + y.re^2}^*} \cdot \frac{(x.im \cdot y.im + \left(y.re \cdot x.re\right))_*}{\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 2 regimes
  2. if y.re < 3.637924346615467e+157

    1. Initial program 22.6

      \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Applied simplify22.6

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

      \[\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 *-un-lft-identity22.6

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

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

      \[\leadsto \color{blue}{\frac{1}{\sqrt{y.im^2 + y.re^2}^*}} \cdot \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))_*}}\]
    8. Applied simplify14.4

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

    if 3.637924346615467e+157 < y.re

    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. Applied simplify44.2

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

      \[\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 *-un-lft-identity44.2

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

      \[\leadsto \color{blue}{\frac{1}{\sqrt{y.im^2 + y.re^2}^*}} \cdot \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))_*}}\]
    8. Applied simplify28.9

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

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

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

Runtime

Time bar (total: 1.1m)Debug logProfile

herbie shell --seed '#(1071373924 2949776965 1885069702 3247780810 90874544 2263903749)' +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))))