Average Error: 26.0 → 12.6
Time: 11.7s
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 -2.7774429101464625 \cdot 10^{124}:\\ \;\;\;\;\frac{-x.im}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right)\\ \mathbf{elif}\;y.re \le 5.3202544266061094 \cdot 10^{154}:\\ \;\;\;\;\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \frac{\frac{1}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{\mathsf{fma}\left(y.re, x.im, -x.re \cdot y.im\right)}}}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\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 -2.7774429101464625 \cdot 10^{124}:\\
\;\;\;\;\frac{-x.im}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right)\\

\mathbf{elif}\;y.re \le 5.3202544266061094 \cdot 10^{154}:\\
\;\;\;\;\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \frac{\frac{1}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{\mathsf{fma}\left(y.re, x.im, -x.re \cdot y.im\right)}}}{\mathsf{hypot}\left(y.re, y.im\right)}\\

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

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r89695 = x_im;
        double r89696 = y_re;
        double r89697 = r89695 * r89696;
        double r89698 = x_re;
        double r89699 = y_im;
        double r89700 = r89698 * r89699;
        double r89701 = r89697 - r89700;
        double r89702 = r89696 * r89696;
        double r89703 = r89699 * r89699;
        double r89704 = r89702 + r89703;
        double r89705 = r89701 / r89704;
        return r89705;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r89706 = y_re;
        double r89707 = -2.7774429101464625e+124;
        bool r89708 = r89706 <= r89707;
        double r89709 = x_im;
        double r89710 = -r89709;
        double r89711 = y_im;
        double r89712 = hypot(r89706, r89711);
        double r89713 = r89710 / r89712;
        double r89714 = 1.0;
        double r89715 = cbrt(r89714);
        double r89716 = r89715 * r89715;
        double r89717 = r89713 * r89716;
        double r89718 = 5.3202544266061094e+154;
        bool r89719 = r89706 <= r89718;
        double r89720 = x_re;
        double r89721 = r89720 * r89711;
        double r89722 = -r89721;
        double r89723 = fma(r89706, r89709, r89722);
        double r89724 = r89712 / r89723;
        double r89725 = r89714 / r89724;
        double r89726 = r89725 / r89712;
        double r89727 = r89716 * r89726;
        double r89728 = r89709 / r89712;
        double r89729 = r89716 * r89728;
        double r89730 = r89719 ? r89727 : r89729;
        double r89731 = r89708 ? r89717 : r89730;
        return r89731;
}

Error

Bits error versus x.re

Bits error versus x.im

Bits error versus y.re

Bits error versus y.im

Derivation

  1. Split input into 3 regimes
  2. if y.re < -2.7774429101464625e+124

    1. Initial program 41.0

      \[\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 add-sqr-sqrt41.0

      \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}}\]
    4. Applied *-un-lft-identity41.0

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{1} \cdot \color{blue}{\frac{\frac{\mathsf{fma}\left(y.re, x.im, -x.re \cdot y.im\right)}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)}}\]
    14. Taylor expanded around -inf 15.6

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

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

    if -2.7774429101464625e+124 < y.re < 5.3202544266061094e+154

    1. Initial program 18.9

      \[\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 add-sqr-sqrt18.9

      \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}}\]
    4. Applied *-un-lft-identity18.9

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{1 \cdot \mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{hypot}\left(y.re, y.im\right)}\]
    11. Applied times-frac11.9

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

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

      \[\leadsto \frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{1} \cdot \color{blue}{\frac{\frac{\mathsf{fma}\left(y.re, x.im, -x.re \cdot y.im\right)}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)}}\]
    14. Using strategy rm
    15. Applied clear-num11.8

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

    if 5.3202544266061094e+154 < y.re

    1. Initial program 46.2

      \[\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 add-sqr-sqrt46.2

      \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}}\]
    4. Applied *-un-lft-identity46.2

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

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \color{blue}{\frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{hypot}\left(y.re, y.im\right)}}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity28.4

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

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{1 \cdot \mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{hypot}\left(y.re, y.im\right)}\]
    11. Applied times-frac28.4

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

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

      \[\leadsto \frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{1} \cdot \color{blue}{\frac{\frac{\mathsf{fma}\left(y.re, x.im, -x.re \cdot y.im\right)}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)}}\]
    14. Taylor expanded around inf 13.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \le -2.7774429101464625 \cdot 10^{124}:\\ \;\;\;\;\frac{-x.im}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right)\\ \mathbf{elif}\;y.re \le 5.3202544266061094 \cdot 10^{154}:\\ \;\;\;\;\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \frac{\frac{1}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{\mathsf{fma}\left(y.re, x.im, -x.re \cdot y.im\right)}}}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \end{array}\]

Reproduce

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