Average Error: 25.7 → 16.8
Time: 25.1s
Precision: 64
\[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
\[\frac{\frac{1}{\frac{\mathsf{hypot}\left(y.im, y.re\right)}{\mathsf{fma}\left(x.re, y.re, \left(x.im \cdot y.im\right)\right)}}}{\mathsf{hypot}\left(y.im, y.re\right)}\]
\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\frac{\frac{1}{\frac{\mathsf{hypot}\left(y.im, y.re\right)}{\mathsf{fma}\left(x.re, y.re, \left(x.im \cdot y.im\right)\right)}}}{\mathsf{hypot}\left(y.im, y.re\right)}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r2732206 = x_re;
        double r2732207 = y_re;
        double r2732208 = r2732206 * r2732207;
        double r2732209 = x_im;
        double r2732210 = y_im;
        double r2732211 = r2732209 * r2732210;
        double r2732212 = r2732208 + r2732211;
        double r2732213 = r2732207 * r2732207;
        double r2732214 = r2732210 * r2732210;
        double r2732215 = r2732213 + r2732214;
        double r2732216 = r2732212 / r2732215;
        return r2732216;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r2732217 = 1.0;
        double r2732218 = y_im;
        double r2732219 = y_re;
        double r2732220 = hypot(r2732218, r2732219);
        double r2732221 = x_re;
        double r2732222 = x_im;
        double r2732223 = r2732222 * r2732218;
        double r2732224 = fma(r2732221, r2732219, r2732223);
        double r2732225 = r2732220 / r2732224;
        double r2732226 = r2732217 / r2732225;
        double r2732227 = r2732226 / r2732220;
        return r2732227;
}

Error

Bits error versus x.re

Bits error versus x.im

Bits error versus y.re

Bits error versus y.im

Derivation

  1. Initial program 25.7

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

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

    \[\leadsto \frac{\mathsf{fma}\left(x.re, y.re, \left(x.im \cdot y.im\right)\right)}{\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)}}}\]
  5. Applied associate-/r*25.7

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

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

    \[\leadsto \frac{\color{blue}{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(y.im, y.im, \left(y.re \cdot y.re\right)\right)}}{\mathsf{fma}\left(x.re, y.re, \left(x.im \cdot y.im\right)\right)}}}}{\sqrt{\mathsf{fma}\left(y.im, y.im, \left(y.re \cdot y.re\right)\right)}}\]
  9. Using strategy rm
  10. Applied fma-udef25.7

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

    \[\leadsto \frac{\frac{1}{\frac{\color{blue}{\mathsf{hypot}\left(y.im, y.re\right)}}{\mathsf{fma}\left(x.re, y.re, \left(x.im \cdot y.im\right)\right)}}}{\sqrt{\mathsf{fma}\left(y.im, y.im, \left(y.re \cdot y.re\right)\right)}}\]
  12. Using strategy rm
  13. Applied fma-udef25.7

    \[\leadsto \frac{\frac{1}{\frac{\mathsf{hypot}\left(y.im, y.re\right)}{\mathsf{fma}\left(x.re, y.re, \left(x.im \cdot y.im\right)\right)}}}{\sqrt{\color{blue}{y.im \cdot y.im + y.re \cdot y.re}}}\]
  14. Applied hypot-def16.8

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

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

Reproduce

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