Average Error: 26.4 → 17.0
Time: 15.4s
Precision: 64
\[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
\[\frac{1}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{hypot}\left(y.im, y.re\right)}\]
\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\frac{1}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{hypot}\left(y.im, y.re\right)}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r2695233 = x_im;
        double r2695234 = y_re;
        double r2695235 = r2695233 * r2695234;
        double r2695236 = x_re;
        double r2695237 = y_im;
        double r2695238 = r2695236 * r2695237;
        double r2695239 = r2695235 - r2695238;
        double r2695240 = r2695234 * r2695234;
        double r2695241 = r2695237 * r2695237;
        double r2695242 = r2695240 + r2695241;
        double r2695243 = r2695239 / r2695242;
        return r2695243;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r2695244 = 1.0;
        double r2695245 = y_im;
        double r2695246 = y_re;
        double r2695247 = hypot(r2695245, r2695246);
        double r2695248 = r2695244 / r2695247;
        double r2695249 = x_im;
        double r2695250 = r2695246 * r2695249;
        double r2695251 = x_re;
        double r2695252 = r2695245 * r2695251;
        double r2695253 = r2695250 - r2695252;
        double r2695254 = r2695253 / r2695247;
        double r2695255 = r2695248 * r2695254;
        return r2695255;
}

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. Initial program 26.4

    \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
  2. Simplified26.4

    \[\leadsto \color{blue}{\frac{x.im \cdot y.re - x.re \cdot y.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt26.4

    \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{\sqrt{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot \sqrt{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}}}\]
  5. Applied associate-/r*26.3

    \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}}}{\sqrt{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}}}\]
  6. Using strategy rm
  7. Applied clear-num26.5

    \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}}{\frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}}}}}\]
  8. Simplified26.6

    \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}{y.re \cdot x.im - y.im \cdot x.re}}}\]
  9. Using strategy rm
  10. Applied *-un-lft-identity26.6

    \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}{\color{blue}{1 \cdot \left(y.re \cdot x.im - y.im \cdot x.re\right)}}}\]
  11. Applied add-sqr-sqrt26.6

    \[\leadsto \frac{1}{\frac{\color{blue}{\sqrt{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot \sqrt{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}}}{1 \cdot \left(y.re \cdot x.im - y.im \cdot x.re\right)}}\]
  12. Applied times-frac26.6

    \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}}{1} \cdot \frac{\sqrt{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}}{y.re \cdot x.im - y.im \cdot x.re}}}\]
  13. Applied add-cube-cbrt26.6

    \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{\sqrt{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}}{1} \cdot \frac{\sqrt{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}}{y.re \cdot x.im - y.im \cdot x.re}}\]
  14. Applied times-frac26.5

    \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{\sqrt{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}}{1}} \cdot \frac{\sqrt[3]{1}}{\frac{\sqrt{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}}{y.re \cdot x.im - y.im \cdot x.re}}}\]
  15. Simplified26.5

    \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(y.im, y.re\right)}} \cdot \frac{\sqrt[3]{1}}{\frac{\sqrt{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}}{y.re \cdot x.im - y.im \cdot x.re}}\]
  16. Simplified17.0

    \[\leadsto \frac{1}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \color{blue}{\frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{hypot}\left(y.im, y.re\right)}}\]
  17. Final simplification17.0

    \[\leadsto \frac{1}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{hypot}\left(y.im, y.re\right)}\]

Reproduce

herbie shell --seed 2019174 +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))))