Average Error: 26.0 → 13.4
Time: 15.1s
Precision: 64
\[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
\[\begin{array}{l} \mathbf{if}\;y.re \le -9.293826114497670869139658346683561592978 \cdot 10^{210}:\\ \;\;\;\;\frac{-1}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot x.im\\ \mathbf{elif}\;y.re \le 1.15056779942975516580562280806905910555 \cdot 10^{182}:\\ \;\;\;\;\frac{\frac{x.im \cdot y.re - y.im \cdot x.re}{\mathsf{hypot}\left(y.im, y.re\right)}}{\mathsf{hypot}\left(y.im, y.re\right)}\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \frac{1}{\mathsf{hypot}\left(y.im, y.re\right)}\\ \end{array}\]
\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\begin{array}{l}
\mathbf{if}\;y.re \le -9.293826114497670869139658346683561592978 \cdot 10^{210}:\\
\;\;\;\;\frac{-1}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot x.im\\

\mathbf{elif}\;y.re \le 1.15056779942975516580562280806905910555 \cdot 10^{182}:\\
\;\;\;\;\frac{\frac{x.im \cdot y.re - y.im \cdot x.re}{\mathsf{hypot}\left(y.im, y.re\right)}}{\mathsf{hypot}\left(y.im, y.re\right)}\\

\mathbf{else}:\\
\;\;\;\;x.im \cdot \frac{1}{\mathsf{hypot}\left(y.im, y.re\right)}\\

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r2625755 = x_im;
        double r2625756 = y_re;
        double r2625757 = r2625755 * r2625756;
        double r2625758 = x_re;
        double r2625759 = y_im;
        double r2625760 = r2625758 * r2625759;
        double r2625761 = r2625757 - r2625760;
        double r2625762 = r2625756 * r2625756;
        double r2625763 = r2625759 * r2625759;
        double r2625764 = r2625762 + r2625763;
        double r2625765 = r2625761 / r2625764;
        return r2625765;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r2625766 = y_re;
        double r2625767 = -9.293826114497671e+210;
        bool r2625768 = r2625766 <= r2625767;
        double r2625769 = -1.0;
        double r2625770 = y_im;
        double r2625771 = hypot(r2625770, r2625766);
        double r2625772 = r2625769 / r2625771;
        double r2625773 = x_im;
        double r2625774 = r2625772 * r2625773;
        double r2625775 = 1.1505677994297552e+182;
        bool r2625776 = r2625766 <= r2625775;
        double r2625777 = r2625773 * r2625766;
        double r2625778 = x_re;
        double r2625779 = r2625770 * r2625778;
        double r2625780 = r2625777 - r2625779;
        double r2625781 = r2625780 / r2625771;
        double r2625782 = r2625781 / r2625771;
        double r2625783 = 1.0;
        double r2625784 = r2625783 / r2625771;
        double r2625785 = r2625773 * r2625784;
        double r2625786 = r2625776 ? r2625782 : r2625785;
        double r2625787 = r2625768 ? r2625774 : r2625786;
        return r2625787;
}

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. Split input into 3 regimes
  2. if y.re < -9.293826114497671e+210

    1. Initial program 41.6

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

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

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

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

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

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

      \[\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, y.re \cdot y.re\right)}}{1} \cdot \frac{\sqrt{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}}{x.im \cdot y.re - x.re \cdot y.im}}\]
    10. Applied times-frac41.6

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

      \[\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, y.re \cdot y.re\right)}}{x.im \cdot y.re - x.re \cdot y.im}}\]
    12. Simplified29.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.im, y.re\right)}}\]
    13. Taylor expanded around -inf 10.2

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

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

    if -9.293826114497671e+210 < y.re < 1.1505677994297552e+182

    1. Initial program 22.3

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

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

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

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

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

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

      \[\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, y.re \cdot y.re\right)}}{1} \cdot \frac{\sqrt{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}}{x.im \cdot y.re - x.re \cdot y.im}}\]
    10. Applied times-frac22.3

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

      \[\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, y.re \cdot y.re\right)}}{x.im \cdot y.re - x.re \cdot y.im}}\]
    12. Simplified14.0

      \[\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)}}\]
    13. Using strategy rm
    14. Applied associate-*r/14.0

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

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

    if 1.1505677994297552e+182 < y.re

    1. Initial program 42.1

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

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

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

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

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

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

      \[\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, y.re \cdot y.re\right)}}{1} \cdot \frac{\sqrt{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}}{x.im \cdot y.re - x.re \cdot y.im}}\]
    10. Applied times-frac42.1

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

      \[\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, y.re \cdot y.re\right)}}{x.im \cdot y.re - x.re \cdot y.im}}\]
    12. Simplified29.5

      \[\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)}}\]
    13. Taylor expanded around inf 12.1

      \[\leadsto \frac{1}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \color{blue}{x.im}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification13.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \le -9.293826114497670869139658346683561592978 \cdot 10^{210}:\\ \;\;\;\;\frac{-1}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot x.im\\ \mathbf{elif}\;y.re \le 1.15056779942975516580562280806905910555 \cdot 10^{182}:\\ \;\;\;\;\frac{\frac{x.im \cdot y.re - y.im \cdot x.re}{\mathsf{hypot}\left(y.im, y.re\right)}}{\mathsf{hypot}\left(y.im, y.re\right)}\\ \mathbf{else}:\\ \;\;\;\;x.im \cdot \frac{1}{\mathsf{hypot}\left(y.im, y.re\right)}\\ \end{array}\]

Reproduce

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