Average Error: 25.9 → 0.4
Time: 18.9s
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 r64084 = x_im;
        double r64085 = y_re;
        double r64086 = r64084 * r64085;
        double r64087 = x_re;
        double r64088 = y_im;
        double r64089 = r64087 * r64088;
        double r64090 = r64086 - r64089;
        double r64091 = r64085 * r64085;
        double r64092 = r64088 * r64088;
        double r64093 = r64091 + r64092;
        double r64094 = r64090 / r64093;
        return r64094;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r64095 = y_re;
        double r64096 = y_im;
        double r64097 = hypot(r64095, r64096);
        double r64098 = r64095 / r64097;
        double r64099 = x_im;
        double r64100 = r64098 * r64099;
        double r64101 = x_re;
        double r64102 = r64096 / r64097;
        double r64103 = r64101 * r64102;
        double r64104 = r64100 - r64103;
        double r64105 = r64104 / r64097;
        return r64105;
}

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{\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)}\]
  12. Using strategy rm
  13. Applied div-sub16.7

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

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

    \[\leadsto \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)}\]
  16. Using strategy rm
  17. Applied div-inv1.0

    \[\leadsto \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)}\]
  18. Applied associate-*l*0.5

    \[\leadsto \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)}\]
  19. Simplified0.4

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