Average Error: 26.2 → 1.2
Time: 17.1s
Precision: 64
\[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
\[\frac{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)} - y.im \cdot \frac{x.re}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)}\]
\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\frac{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)} - y.im \cdot \frac{x.re}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r63049 = x_im;
        double r63050 = y_re;
        double r63051 = r63049 * r63050;
        double r63052 = x_re;
        double r63053 = y_im;
        double r63054 = r63052 * r63053;
        double r63055 = r63051 - r63054;
        double r63056 = r63050 * r63050;
        double r63057 = r63053 * r63053;
        double r63058 = r63056 + r63057;
        double r63059 = r63055 / r63058;
        return r63059;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r63060 = y_re;
        double r63061 = x_im;
        double r63062 = y_im;
        double r63063 = hypot(r63060, r63062);
        double r63064 = r63061 / r63063;
        double r63065 = r63060 * r63064;
        double r63066 = x_re;
        double r63067 = r63066 / r63063;
        double r63068 = r63062 * r63067;
        double r63069 = r63065 - r63068;
        double r63070 = r63069 / r63063;
        return r63070;
}

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

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

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

    \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{\sqrt{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)} \cdot \sqrt{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}}}\]
  5. Applied *-un-lft-identity26.2

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(\frac{\sqrt{1}}{1} \cdot \frac{\sqrt{1}}{\mathsf{hypot}\left(y.re, y.im\right)}\right)} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\mathsf{hypot}\left(y.re, y.im\right)}\]
  13. Applied associate-*l*17.0

    \[\leadsto \color{blue}{\frac{\sqrt{1}}{1} \cdot \left(\frac{\sqrt{1}}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\mathsf{hypot}\left(y.re, y.im\right)}\right)}\]
  14. Simplified16.9

    \[\leadsto \frac{\sqrt{1}}{1} \cdot \color{blue}{\frac{\frac{x.im \cdot y.re - x.re \cdot y.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)}}\]
  15. Using strategy rm
  16. Applied div-sub16.9

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

    \[\leadsto \frac{\sqrt{1}}{1} \cdot \frac{\color{blue}{\frac{y.re \cdot x.im}{\mathsf{hypot}\left(y.re, y.im\right)}} - \frac{x.re \cdot y.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)}\]
  18. Simplified9.5

    \[\leadsto \frac{\sqrt{1}}{1} \cdot \frac{\frac{y.re \cdot x.im}{\mathsf{hypot}\left(y.re, y.im\right)} - \color{blue}{y.im \cdot \frac{x.re}{\mathsf{hypot}\left(y.re, y.im\right)}}}{\mathsf{hypot}\left(y.re, y.im\right)}\]
  19. Using strategy rm
  20. Applied *-un-lft-identity9.5

    \[\leadsto \frac{\sqrt{1}}{1} \cdot \frac{\frac{y.re \cdot x.im}{\color{blue}{1 \cdot \mathsf{hypot}\left(y.re, y.im\right)}} - y.im \cdot \frac{x.re}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)}\]
  21. Applied times-frac1.2

    \[\leadsto \frac{\sqrt{1}}{1} \cdot \frac{\color{blue}{\frac{y.re}{1} \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}} - y.im \cdot \frac{x.re}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)}\]
  22. Simplified1.2

    \[\leadsto \frac{\sqrt{1}}{1} \cdot \frac{\color{blue}{y.re} \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)} - y.im \cdot \frac{x.re}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)}\]
  23. Final simplification1.2

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

Reproduce

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