Average Error: 25.2 → 16.1
Time: 15.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{1}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \frac{y.re \cdot x.im - y.im \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{1}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \frac{y.re \cdot x.im - y.im \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 r1919944 = x_im;
        double r1919945 = y_re;
        double r1919946 = r1919944 * r1919945;
        double r1919947 = x_re;
        double r1919948 = y_im;
        double r1919949 = r1919947 * r1919948;
        double r1919950 = r1919946 - r1919949;
        double r1919951 = r1919945 * r1919945;
        double r1919952 = r1919948 * r1919948;
        double r1919953 = r1919951 + r1919952;
        double r1919954 = r1919950 / r1919953;
        return r1919954;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r1919955 = 1.0;
        double r1919956 = y_im;
        double r1919957 = y_re;
        double r1919958 = hypot(r1919956, r1919957);
        double r1919959 = r1919955 / r1919958;
        double r1919960 = x_im;
        double r1919961 = r1919957 * r1919960;
        double r1919962 = x_re;
        double r1919963 = r1919956 * r1919962;
        double r1919964 = r1919961 - r1919963;
        double r1919965 = r1919964 / r1919958;
        double r1919966 = r1919959 * r1919965;
        return r1919966;
}

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

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

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

    \[\leadsto \frac{\color{blue}{1 \cdot \left(x.im \cdot y.re - x.re \cdot y.im\right)}}{\mathsf{fma}\left(y.im, y.im, \left(y.re \cdot y.re\right)\right)}\]
  5. Applied associate-/l*25.3

    \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(y.im, y.im, \left(y.re \cdot y.re\right)\right)}{x.im \cdot y.re - x.re \cdot y.im}}}\]
  6. Using strategy rm
  7. Applied *-un-lft-identity25.3

    \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(y.im, y.im, \left(y.re \cdot y.re\right)\right)}{\color{blue}{1 \cdot \left(x.im \cdot y.re - x.re \cdot y.im\right)}}}\]
  8. Applied add-sqr-sqrt25.3

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

    \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{\mathsf{fma}\left(y.im, y.im, \left(y.re \cdot y.re\right)\right)}}{1} \cdot \frac{\sqrt{\mathsf{fma}\left(y.im, y.im, \left(y.re \cdot y.re\right)\right)}}{x.im \cdot y.re - x.re \cdot y.im}}}\]
  10. Applied add-cube-cbrt25.3

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

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

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

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

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

Reproduce

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