Average Error: 26.1 → 4.9
Time: 13.6s
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}\;x.im \le 4.898100458132601400927039599397440378071 \cdot 10^{76}:\\ \;\;\;\;\frac{x.im}{y.re + \frac{y.im \cdot y.im}{y.re}} - \frac{x.re}{y.re \cdot \frac{y.re}{y.im} + y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.re + \frac{y.im}{\frac{y.re}{y.im}}} - \frac{x.re}{y.im + \frac{y.re \cdot y.re}{y.im}}\\ \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}\;x.im \le 4.898100458132601400927039599397440378071 \cdot 10^{76}:\\
\;\;\;\;\frac{x.im}{y.re + \frac{y.im \cdot y.im}{y.re}} - \frac{x.re}{y.re \cdot \frac{y.re}{y.im} + y.im}\\

\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.re + \frac{y.im}{\frac{y.re}{y.im}}} - \frac{x.re}{y.im + \frac{y.re \cdot y.re}{y.im}}\\

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r61779 = x_im;
        double r61780 = y_re;
        double r61781 = r61779 * r61780;
        double r61782 = x_re;
        double r61783 = y_im;
        double r61784 = r61782 * r61783;
        double r61785 = r61781 - r61784;
        double r61786 = r61780 * r61780;
        double r61787 = r61783 * r61783;
        double r61788 = r61786 + r61787;
        double r61789 = r61785 / r61788;
        return r61789;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r61790 = x_im;
        double r61791 = 4.8981004581326014e+76;
        bool r61792 = r61790 <= r61791;
        double r61793 = y_re;
        double r61794 = y_im;
        double r61795 = r61794 * r61794;
        double r61796 = r61795 / r61793;
        double r61797 = r61793 + r61796;
        double r61798 = r61790 / r61797;
        double r61799 = x_re;
        double r61800 = r61793 / r61794;
        double r61801 = r61793 * r61800;
        double r61802 = r61801 + r61794;
        double r61803 = r61799 / r61802;
        double r61804 = r61798 - r61803;
        double r61805 = r61794 / r61800;
        double r61806 = r61793 + r61805;
        double r61807 = r61790 / r61806;
        double r61808 = r61793 * r61793;
        double r61809 = r61808 / r61794;
        double r61810 = r61794 + r61809;
        double r61811 = r61799 / r61810;
        double r61812 = r61807 - r61811;
        double r61813 = r61792 ? r61804 : r61812;
        return r61813;
}

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 2 regimes
  2. if x.im < 4.8981004581326014e+76

    1. Initial program 24.1

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Using strategy rm
    3. Applied div-sub24.1

      \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}}\]
    4. Simplified23.0

      \[\leadsto \color{blue}{\frac{x.im}{\frac{y.im \cdot y.im + y.re \cdot y.re}{y.re}}} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    5. Simplified21.6

      \[\leadsto \frac{x.im}{\frac{y.im \cdot y.im + y.re \cdot y.re}{y.re}} - \color{blue}{\frac{x.re}{\frac{y.im \cdot y.im + y.re \cdot y.re}{y.im}}}\]
    6. Taylor expanded around 0 15.6

      \[\leadsto \frac{x.im}{\color{blue}{y.re + \frac{{y.im}^{2}}{y.re}}} - \frac{x.re}{\frac{y.im \cdot y.im + y.re \cdot y.re}{y.im}}\]
    7. Simplified15.6

      \[\leadsto \frac{x.im}{\color{blue}{y.re + \frac{y.im \cdot y.im}{y.re}}} - \frac{x.re}{\frac{y.im \cdot y.im + y.re \cdot y.re}{y.im}}\]
    8. Taylor expanded around 0 7.5

      \[\leadsto \frac{x.im}{y.re + \frac{y.im \cdot y.im}{y.re}} - \frac{x.re}{\color{blue}{y.im + \frac{{y.re}^{2}}{y.im}}}\]
    9. Simplified7.5

      \[\leadsto \frac{x.im}{y.re + \frac{y.im \cdot y.im}{y.re}} - \frac{x.re}{\color{blue}{\frac{y.re \cdot y.re}{y.im} + y.im}}\]
    10. Using strategy rm
    11. Applied *-un-lft-identity7.5

      \[\leadsto \frac{x.im}{y.re + \frac{y.im \cdot y.im}{y.re}} - \frac{x.re}{\color{blue}{1 \cdot \left(\frac{y.re \cdot y.re}{y.im} + y.im\right)}}\]
    12. Applied *-un-lft-identity7.5

      \[\leadsto \frac{x.im}{y.re + \frac{y.im \cdot y.im}{y.re}} - \frac{\color{blue}{1 \cdot x.re}}{1 \cdot \left(\frac{y.re \cdot y.re}{y.im} + y.im\right)}\]
    13. Applied times-frac7.5

      \[\leadsto \frac{x.im}{y.re + \frac{y.im \cdot y.im}{y.re}} - \color{blue}{\frac{1}{1} \cdot \frac{x.re}{\frac{y.re \cdot y.re}{y.im} + y.im}}\]
    14. Simplified7.5

      \[\leadsto \frac{x.im}{y.re + \frac{y.im \cdot y.im}{y.re}} - \color{blue}{1} \cdot \frac{x.re}{\frac{y.re \cdot y.re}{y.im} + y.im}\]
    15. Simplified4.8

      \[\leadsto \frac{x.im}{y.re + \frac{y.im \cdot y.im}{y.re}} - 1 \cdot \color{blue}{\frac{x.re}{\frac{y.re}{y.im} \cdot y.re + y.im}}\]

    if 4.8981004581326014e+76 < x.im

    1. Initial program 35.3

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Using strategy rm
    3. Applied div-sub35.3

      \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}}\]
    4. Simplified30.7

      \[\leadsto \color{blue}{\frac{x.im}{\frac{y.im \cdot y.im + y.re \cdot y.re}{y.re}}} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    5. Simplified29.0

      \[\leadsto \frac{x.im}{\frac{y.im \cdot y.im + y.re \cdot y.re}{y.re}} - \color{blue}{\frac{x.re}{\frac{y.im \cdot y.im + y.re \cdot y.re}{y.im}}}\]
    6. Taylor expanded around 0 16.4

      \[\leadsto \frac{x.im}{\color{blue}{y.re + \frac{{y.im}^{2}}{y.re}}} - \frac{x.re}{\frac{y.im \cdot y.im + y.re \cdot y.re}{y.im}}\]
    7. Simplified16.4

      \[\leadsto \frac{x.im}{\color{blue}{y.re + \frac{y.im \cdot y.im}{y.re}}} - \frac{x.re}{\frac{y.im \cdot y.im + y.re \cdot y.re}{y.im}}\]
    8. Taylor expanded around 0 9.6

      \[\leadsto \frac{x.im}{y.re + \frac{y.im \cdot y.im}{y.re}} - \frac{x.re}{\color{blue}{y.im + \frac{{y.re}^{2}}{y.im}}}\]
    9. Simplified9.6

      \[\leadsto \frac{x.im}{y.re + \frac{y.im \cdot y.im}{y.re}} - \frac{x.re}{\color{blue}{\frac{y.re \cdot y.re}{y.im} + y.im}}\]
    10. Using strategy rm
    11. Applied *-un-lft-identity9.6

      \[\leadsto \frac{x.im}{\color{blue}{1 \cdot \left(y.re + \frac{y.im \cdot y.im}{y.re}\right)}} - \frac{x.re}{\frac{y.re \cdot y.re}{y.im} + y.im}\]
    12. Applied *-un-lft-identity9.6

      \[\leadsto \frac{\color{blue}{1 \cdot x.im}}{1 \cdot \left(y.re + \frac{y.im \cdot y.im}{y.re}\right)} - \frac{x.re}{\frac{y.re \cdot y.re}{y.im} + y.im}\]
    13. Applied times-frac9.6

      \[\leadsto \color{blue}{\frac{1}{1} \cdot \frac{x.im}{y.re + \frac{y.im \cdot y.im}{y.re}}} - \frac{x.re}{\frac{y.re \cdot y.re}{y.im} + y.im}\]
    14. Simplified9.6

      \[\leadsto \color{blue}{1} \cdot \frac{x.im}{y.re + \frac{y.im \cdot y.im}{y.re}} - \frac{x.re}{\frac{y.re \cdot y.re}{y.im} + y.im}\]
    15. Simplified5.7

      \[\leadsto 1 \cdot \color{blue}{\frac{x.im}{y.re + \frac{y.im}{\frac{y.re}{y.im}}}} - \frac{x.re}{\frac{y.re \cdot y.re}{y.im} + y.im}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification4.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \le 4.898100458132601400927039599397440378071 \cdot 10^{76}:\\ \;\;\;\;\frac{x.im}{y.re + \frac{y.im \cdot y.im}{y.re}} - \frac{x.re}{y.re \cdot \frac{y.re}{y.im} + y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.re + \frac{y.im}{\frac{y.re}{y.im}}} - \frac{x.re}{y.im + \frac{y.re \cdot y.re}{y.im}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019179 
(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))))