Average Error: 26.2 → 16.9
Time: 36.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{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 r3507215 = x_im;
        double r3507216 = y_re;
        double r3507217 = r3507215 * r3507216;
        double r3507218 = x_re;
        double r3507219 = y_im;
        double r3507220 = r3507218 * r3507219;
        double r3507221 = r3507217 - r3507220;
        double r3507222 = r3507216 * r3507216;
        double r3507223 = r3507219 * r3507219;
        double r3507224 = r3507222 + r3507223;
        double r3507225 = r3507221 / r3507224;
        return r3507225;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r3507226 = y_re;
        double r3507227 = x_im;
        double r3507228 = r3507226 * r3507227;
        double r3507229 = y_im;
        double r3507230 = x_re;
        double r3507231 = r3507229 * r3507230;
        double r3507232 = r3507228 - r3507231;
        double r3507233 = hypot(r3507226, r3507229);
        double r3507234 = r3507232 / r3507233;
        double r3507235 = 1.0;
        double r3507236 = hypot(r3507229, r3507226);
        double r3507237 = r3507235 / r3507236;
        double r3507238 = r3507234 * r3507237;
        return r3507238;
}

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

    \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
  2. Simplified26.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-identity26.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*26.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-identity26.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-sqrt26.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-frac26.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-cbrt26.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-frac26.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. Simplified26.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.9

    \[\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)}}\]
  14. Final simplification16.9

    \[\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 2019124 +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))))