Average Error: 26.7 → 0.6
Time: 7.7s
Precision: 64
\[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
\[\frac{x.im \cdot \frac{y.re}{\mathsf{hypot}\left(y.im, y.re\right)} - \frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)} \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{x.im \cdot \frac{y.re}{\mathsf{hypot}\left(y.im, y.re\right)} - \frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)} \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 r55054 = x_im;
        double r55055 = y_re;
        double r55056 = r55054 * r55055;
        double r55057 = x_re;
        double r55058 = y_im;
        double r55059 = r55057 * r55058;
        double r55060 = r55056 - r55059;
        double r55061 = r55055 * r55055;
        double r55062 = r55058 * r55058;
        double r55063 = r55061 + r55062;
        double r55064 = r55060 / r55063;
        return r55064;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r55065 = x_im;
        double r55066 = y_re;
        double r55067 = y_im;
        double r55068 = hypot(r55067, r55066);
        double r55069 = r55066 / r55068;
        double r55070 = r55065 * r55069;
        double r55071 = r55067 / r55068;
        double r55072 = x_re;
        double r55073 = r55071 * r55072;
        double r55074 = r55070 - r55073;
        double r55075 = r55074 / r55068;
        return r55075;
}

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(y.im, y.re\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.3

    \[\leadsto \frac{1}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \color{blue}{\frac{x.im \cdot y.re - x.re \cdot y.im}{\mathsf{hypot}\left(y.im, y.re\right)}}\]
  9. Using strategy rm
  10. Applied associate-*r/17.3

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

    \[\leadsto \frac{\color{blue}{\frac{x.im \cdot y.re - x.re \cdot y.im}{\mathsf{hypot}\left(y.im, y.re\right)}}}{\mathsf{hypot}\left(y.im, y.re\right)}\]
  12. Using strategy rm
  13. Applied div-sub17.2

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

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

    \[\leadsto \frac{\frac{x.im \cdot y.re}{\color{blue}{1 \cdot \mathsf{hypot}\left(y.im, y.re\right)}} - \frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot x.re}{\mathsf{hypot}\left(y.im, y.re\right)}\]
  17. Applied times-frac0.6

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

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

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

Reproduce

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