Average Error: 26.0 → 0.4
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{\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot x.im - x.re \cdot \frac{y.im}{\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{\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot x.im - x.re \cdot \frac{y.im}{\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 r45715 = x_im;
        double r45716 = y_re;
        double r45717 = r45715 * r45716;
        double r45718 = x_re;
        double r45719 = y_im;
        double r45720 = r45718 * r45719;
        double r45721 = r45717 - r45720;
        double r45722 = r45716 * r45716;
        double r45723 = r45719 * r45719;
        double r45724 = r45722 + r45723;
        double r45725 = r45721 / r45724;
        return r45725;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r45726 = y_re;
        double r45727 = y_im;
        double r45728 = hypot(r45726, r45727);
        double r45729 = r45726 / r45728;
        double r45730 = x_im;
        double r45731 = r45729 * r45730;
        double r45732 = x_re;
        double r45733 = r45727 / r45728;
        double r45734 = r45732 * r45733;
        double r45735 = r45731 - r45734;
        double r45736 = r45735 / r45728;
        return r45736;
}

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

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

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

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

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

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

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

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

    \[\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*16.8

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

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

    \[\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. Simplified9.0

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

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

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

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

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

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

Reproduce

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