Average Error: 25.6 → 13.4
Time: 1.4m
Precision: 64
Internal Precision: 320
\[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
\[\begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{y.re^2 + y.im^2}^*} \cdot \frac{\frac{y.re \cdot x.im - x.re \cdot y.im}{\sqrt{\sqrt{y.re^2 + y.im^2}^*}}}{\sqrt{\sqrt{y.re^2 + y.im^2}^*}} \le -1.7787867425133029 \cdot 10^{+308}:\\ \;\;\;\;\frac{x.im}{\sqrt{y.re^2 + y.im^2}^*}\\ \mathbf{if}\;\frac{1}{\sqrt{y.re^2 + y.im^2}^*} \cdot \frac{\frac{y.re \cdot x.im - x.re \cdot y.im}{\sqrt{\sqrt{y.re^2 + y.im^2}^*}}}{\sqrt{\sqrt{y.re^2 + y.im^2}^*}} \le 1.7733770411415807 \cdot 10^{+308}:\\ \;\;\;\;\frac{1}{\sqrt{y.re^2 + y.im^2}^*} \cdot \frac{(y.re \cdot x.im + \left(-x.re \cdot y.im\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 (* (/ 1 (hypot y.re y.im)) (/ (/ (- (* y.re x.im) (* x.re y.im)) (sqrt (hypot y.re y.im))) (sqrt (hypot y.re y.im)))) < -1.7787867425133029e+308

    1. Initial program 62.9

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt62.9

      \[\leadsto \frac{x.im \cdot y.re - x.re \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-identity62.9

      \[\leadsto \frac{\color{blue}{1 \cdot \left(x.im \cdot y.re - x.re \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-frac62.9

      \[\leadsto \color{blue}{\frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}\]
    6. Applied simplify62.9

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

      \[\leadsto \frac{1}{\sqrt{y.re^2 + y.im^2}^*} \cdot \color{blue}{\frac{y.re \cdot x.im - x.re \cdot y.im}{\sqrt{y.re^2 + y.im^2}^*}}\]
    8. Taylor expanded around inf 48.8

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

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

    if -1.7787867425133029e+308 < (* (/ 1 (hypot y.re y.im)) (/ (/ (- (* y.re x.im) (* x.re y.im)) (sqrt (hypot y.re y.im))) (sqrt (hypot y.re y.im)))) < 1.7733770411415807e+308

    1. Initial program 13.2

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt13.2

      \[\leadsto \frac{x.im \cdot y.re - x.re \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-identity13.2

      \[\leadsto \frac{\color{blue}{1 \cdot \left(x.im \cdot y.re - x.re \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-frac13.2

      \[\leadsto \color{blue}{\frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}\]
    6. Applied simplify13.2

      \[\leadsto \color{blue}{\frac{1}{\sqrt{y.re^2 + y.im^2}^*}} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}\]
    7. Applied simplify1.6

      \[\leadsto \frac{1}{\sqrt{y.re^2 + y.im^2}^*} \cdot \color{blue}{\frac{y.re \cdot x.im - x.re \cdot y.im}{\sqrt{y.re^2 + y.im^2}^*}}\]
    8. Using strategy rm
    9. Applied fma-neg1.6

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

    if 1.7733770411415807e+308 < (* (/ 1 (hypot y.re y.im)) (/ (/ (- (* y.re x.im) (* x.re y.im)) (sqrt (hypot y.re y.im))) (sqrt (hypot y.re y.im))))

    1. Initial program 62.0

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt62.0

      \[\leadsto \frac{x.im \cdot y.re - x.re \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-identity62.0

      \[\leadsto \frac{\color{blue}{1 \cdot \left(x.im \cdot y.re - x.re \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-frac62.0

      \[\leadsto \color{blue}{\frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}\]
    6. Applied simplify62.0

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

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

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

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

Runtime

Time bar (total: 1.4m)Debug logProfile

herbie shell --seed 2018206 +o rules:numerics
(FPCore (x.re x.im y.re y.im)
  :name "_divideComplex, imaginary part"
  (/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))))