Average Error: 26.5 → 4.8
Time: 3.8s
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.2616143508082277 \cdot 10^{79} \lor \neg \left(y.re \le 1.03827084215452011 \cdot 10^{-35}\right):\\ \;\;\;\;\frac{\frac{x.im}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{y.re}}}{\mathsf{hypot}\left(y.re, y.im\right)} - \frac{\frac{x.re \cdot y.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)} - \frac{\frac{x.re}{1}}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{\frac{y.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.2616143508082277 \cdot 10^{79} \lor \neg \left(y.re \le 1.03827084215452011 \cdot 10^{-35}\right):\\
\;\;\;\;\frac{\frac{x.im}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{y.re}}}{\mathsf{hypot}\left(y.re, y.im\right)} - \frac{\frac{x.re \cdot y.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)} - \frac{\frac{x.re}{1}}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{\frac{y.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 r76231 = x_im;
        double r76232 = y_re;
        double r76233 = r76231 * r76232;
        double r76234 = x_re;
        double r76235 = y_im;
        double r76236 = r76234 * r76235;
        double r76237 = r76233 - r76236;
        double r76238 = r76232 * r76232;
        double r76239 = r76235 * r76235;
        double r76240 = r76238 + r76239;
        double r76241 = r76237 / r76240;
        return r76241;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r76242 = y_re;
        double r76243 = -2.2616143508082277e+79;
        bool r76244 = r76242 <= r76243;
        double r76245 = 1.0382708421545201e-35;
        bool r76246 = r76242 <= r76245;
        double r76247 = !r76246;
        bool r76248 = r76244 || r76247;
        double r76249 = x_im;
        double r76250 = y_im;
        double r76251 = hypot(r76242, r76250);
        double r76252 = r76251 / r76242;
        double r76253 = r76249 / r76252;
        double r76254 = r76253 / r76251;
        double r76255 = x_re;
        double r76256 = r76255 * r76250;
        double r76257 = r76256 / r76251;
        double r76258 = r76257 / r76251;
        double r76259 = r76254 - r76258;
        double r76260 = r76249 * r76242;
        double r76261 = r76260 / r76251;
        double r76262 = r76261 / r76251;
        double r76263 = 1.0;
        double r76264 = r76255 / r76263;
        double r76265 = r76250 / r76251;
        double r76266 = r76251 / r76265;
        double r76267 = r76264 / r76266;
        double r76268 = r76262 - r76267;
        double r76269 = r76248 ? r76259 : r76268;
        return r76269;
}

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 y.re < -2.2616143508082277e+79 or 1.0382708421545201e-35 < y.re

    1. Initial program 33.6

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{x.im \cdot y.re - x.re \cdot y.im}{\mathsf{hypot}\left(y.re, y.im\right)}}}{\mathsf{hypot}\left(y.re, y.im\right)}\]
    11. Using strategy rm
    12. Applied div-sub23.2

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

      \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)} - \frac{\frac{x.re \cdot y.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)}}\]
    14. Using strategy rm
    15. Applied associate-/l*7.8

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

    if -2.2616143508082277e+79 < y.re < 1.0382708421545201e-35

    1. Initial program 19.6

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(y.re, y.im\right) \cdot 1}} \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.8

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

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

      \[\leadsto \frac{\color{blue}{\frac{x.im \cdot y.re - x.re \cdot y.im}{\mathsf{hypot}\left(y.re, y.im\right)}}}{\mathsf{hypot}\left(y.re, y.im\right)}\]
    11. Using strategy rm
    12. Applied div-sub11.7

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \le -2.2616143508082277 \cdot 10^{79} \lor \neg \left(y.re \le 1.03827084215452011 \cdot 10^{-35}\right):\\ \;\;\;\;\frac{\frac{x.im}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{y.re}}}{\mathsf{hypot}\left(y.re, y.im\right)} - \frac{\frac{x.re \cdot y.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)} - \frac{\frac{x.re}{1}}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{\frac{y.im}{\mathsf{hypot}\left(y.re, y.im\right)}}}\\ \end{array}\]

Reproduce

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