Average Error: 25.7 → 0.9
Time: 8.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{\frac{y.re}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot x.im - y.im \cdot \frac{x.re}{\mathsf{hypot}\left(y.im, y.re\right)}}{\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{\frac{y.re}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot x.im - y.im \cdot \frac{x.re}{\mathsf{hypot}\left(y.im, y.re\right)}}{\mathsf{hypot}\left(y.im, y.re\right)}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r125844 = x_im;
        double r125845 = y_re;
        double r125846 = r125844 * r125845;
        double r125847 = x_re;
        double r125848 = y_im;
        double r125849 = r125847 * r125848;
        double r125850 = r125846 - r125849;
        double r125851 = r125845 * r125845;
        double r125852 = r125848 * r125848;
        double r125853 = r125851 + r125852;
        double r125854 = r125850 / r125853;
        return r125854;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r125855 = y_re;
        double r125856 = y_im;
        double r125857 = hypot(r125856, r125855);
        double r125858 = r125855 / r125857;
        double r125859 = x_im;
        double r125860 = r125858 * r125859;
        double r125861 = x_re;
        double r125862 = r125861 / r125857;
        double r125863 = r125856 * r125862;
        double r125864 = r125860 - r125863;
        double r125865 = r125864 / r125857;
        return r125865;
}

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

    \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
  2. Simplified25.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-sqrt25.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-identity25.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-frac25.7

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

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

    \[\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 *-un-lft-identity16.6

    \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{\mathsf{hypot}\left(y.im, y.re\right)}\right)} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\mathsf{hypot}\left(y.im, y.re\right)}\]
  11. Applied associate-*l*16.6

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

    \[\leadsto 1 \cdot \color{blue}{\frac{\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)}}\]
  13. Using strategy rm
  14. Applied div-sub16.5

    \[\leadsto 1 \cdot \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)}\]
  15. Simplified9.7

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

    \[\leadsto 1 \cdot \frac{\frac{y.re}{\frac{\mathsf{hypot}\left(y.im, y.re\right)}{x.im}} - \color{blue}{y.im \cdot \frac{x.re}{\mathsf{hypot}\left(y.im, y.re\right)}}}{\mathsf{hypot}\left(y.im, y.re\right)}\]
  17. Using strategy rm
  18. Applied *-un-lft-identity1.5

    \[\leadsto 1 \cdot \frac{\frac{y.re}{\frac{\mathsf{hypot}\left(y.im, y.re\right)}{\color{blue}{1 \cdot x.im}}} - y.im \cdot \frac{x.re}{\mathsf{hypot}\left(y.im, y.re\right)}}{\mathsf{hypot}\left(y.im, y.re\right)}\]
  19. Applied *-un-lft-identity1.5

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

    \[\leadsto 1 \cdot \frac{\frac{y.re}{\color{blue}{\frac{1}{1} \cdot \frac{\mathsf{hypot}\left(y.im, y.re\right)}{x.im}}} - y.im \cdot \frac{x.re}{\mathsf{hypot}\left(y.im, y.re\right)}}{\mathsf{hypot}\left(y.im, y.re\right)}\]
  21. Applied *-un-lft-identity1.5

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

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

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

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

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

Reproduce

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