Average Error: 25.8 → 1.2
Time: 16.2s
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 r62301 = x_im;
        double r62302 = y_re;
        double r62303 = r62301 * r62302;
        double r62304 = x_re;
        double r62305 = y_im;
        double r62306 = r62304 * r62305;
        double r62307 = r62303 - r62306;
        double r62308 = r62302 * r62302;
        double r62309 = r62305 * r62305;
        double r62310 = r62308 + r62309;
        double r62311 = r62307 / r62310;
        return r62311;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r62312 = y_re;
        double r62313 = x_im;
        double r62314 = y_im;
        double r62315 = hypot(r62312, r62314);
        double r62316 = r62313 / r62315;
        double r62317 = r62312 * r62316;
        double r62318 = x_re;
        double r62319 = r62318 / r62315;
        double r62320 = r62314 * r62319;
        double r62321 = r62317 - r62320;
        double r62322 = r62321 / r62315;
        return r62322;
}

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 25.8

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

    \[\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-sqrt25.8

    \[\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-identity25.8

    \[\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-frac25.8

    \[\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. Simplified25.8

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

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

    \[\leadsto \color{blue}{\left(1 \cdot \frac{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)}\]
  11. Applied associate-*l*17.2

    \[\leadsto \color{blue}{1 \cdot \left(\frac{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)}\]
  12. Simplified17.1

    \[\leadsto 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)}}\]
  13. Using strategy rm
  14. Applied div-sub17.1

    \[\leadsto 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)}\]
  15. Simplified17.1

    \[\leadsto 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)}\]
  16. Simplified9.9

    \[\leadsto 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)}\]
  17. Using strategy rm
  18. Applied *-un-lft-identity9.9

    \[\leadsto 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)}\]
  19. Applied times-frac1.2

    \[\leadsto 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)}\]
  20. Simplified1.2

    \[\leadsto 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)}\]
  21. 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 2019303 +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))))