Average Error: 25.8 → 16.2
Time: 55.6s
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 x.im - y.im \cdot x.re}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{1}{\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{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{1}{\mathsf{hypot}\left(y.im, y.re\right)}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r2500793 = x_im;
        double r2500794 = y_re;
        double r2500795 = r2500793 * r2500794;
        double r2500796 = x_re;
        double r2500797 = y_im;
        double r2500798 = r2500796 * r2500797;
        double r2500799 = r2500795 - r2500798;
        double r2500800 = r2500794 * r2500794;
        double r2500801 = r2500797 * r2500797;
        double r2500802 = r2500800 + r2500801;
        double r2500803 = r2500799 / r2500802;
        return r2500803;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r2500804 = y_re;
        double r2500805 = x_im;
        double r2500806 = r2500804 * r2500805;
        double r2500807 = y_im;
        double r2500808 = x_re;
        double r2500809 = r2500807 * r2500808;
        double r2500810 = r2500806 - r2500809;
        double r2500811 = hypot(r2500804, r2500807);
        double r2500812 = r2500810 / r2500811;
        double r2500813 = 1.0;
        double r2500814 = hypot(r2500807, r2500804);
        double r2500815 = r2500813 / r2500814;
        double r2500816 = r2500812 * r2500815;
        return r2500816;
}

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.im, y.im, \left(y.re \cdot y.re\right)\right)}}\]
  3. Using strategy rm
  4. Applied clear-num25.9

    \[\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}}}\]
  5. Using strategy rm
  6. Applied *-un-lft-identity25.9

    \[\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)}}}\]
  7. Applied add-sqr-sqrt25.9

    \[\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)}}\]
  8. Applied times-frac25.9

    \[\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}}}\]
  9. Applied add-cube-cbrt25.9

    \[\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}}\]
  10. Applied times-frac25.8

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

    \[\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}}\]
  12. Simplified16.2

    \[\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.re, y.im\right)}}\]
  13. Final simplification16.2

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

Reproduce

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