Average Error: 26.5 → 4.8
Time: 4.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 -2.2616143508082277 \cdot 10^{79} \lor \neg \left(y.re \le 1.03827084215452011 \cdot 10^{-35}\right):\\ \;\;\;\;{\left(\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)}\right)}^{1}\\ \mathbf{else}:\\ \;\;\;\;{\left(\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)}}}\right)}^{1}\\ \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):\\
\;\;\;\;{\left(\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)}\right)}^{1}\\

\mathbf{else}:\\
\;\;\;\;{\left(\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)}}}\right)}^{1}\\

\end{array}
double f(double x_re, double x_im, double y_re, double y_im) {
        double r81551 = x_im;
        double r81552 = y_re;
        double r81553 = r81551 * r81552;
        double r81554 = x_re;
        double r81555 = y_im;
        double r81556 = r81554 * r81555;
        double r81557 = r81553 - r81556;
        double r81558 = r81552 * r81552;
        double r81559 = r81555 * r81555;
        double r81560 = r81558 + r81559;
        double r81561 = r81557 / r81560;
        return r81561;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r81562 = y_re;
        double r81563 = -2.2616143508082277e+79;
        bool r81564 = r81562 <= r81563;
        double r81565 = 1.0382708421545201e-35;
        bool r81566 = r81562 <= r81565;
        double r81567 = !r81566;
        bool r81568 = r81564 || r81567;
        double r81569 = x_im;
        double r81570 = y_im;
        double r81571 = hypot(r81562, r81570);
        double r81572 = r81571 / r81562;
        double r81573 = r81569 / r81572;
        double r81574 = r81573 / r81571;
        double r81575 = x_re;
        double r81576 = r81575 * r81570;
        double r81577 = r81576 / r81571;
        double r81578 = r81577 / r81571;
        double r81579 = r81574 - r81578;
        double r81580 = 1.0;
        double r81581 = pow(r81579, r81580);
        double r81582 = r81569 * r81562;
        double r81583 = r81582 / r81571;
        double r81584 = r81583 / r81571;
        double r81585 = r81575 / r81580;
        double r81586 = r81570 / r81571;
        double r81587 = r81571 / r81586;
        double r81588 = r81585 / r81587;
        double r81589 = r81584 - r81588;
        double r81590 = pow(r81589, r81580);
        double r81591 = r81568 ? r81581 : r81590;
        return r81591;
}

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

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

      \[\leadsto \color{blue}{{\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right) \cdot 1}\right)}^{1}} \cdot {\left(\frac{x.im \cdot y.re - x.re \cdot y.im}{\mathsf{hypot}\left(y.re, y.im\right)}\right)}^{1}\]
    11. Applied pow-prod-down23.3

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

      \[\leadsto {\color{blue}{\left(\frac{\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)}\right)}}^{1}\]
    13. Using strategy rm
    14. Applied div-sub23.2

      \[\leadsto {\left(\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)}\right)}^{1}\]
    15. Applied div-sub23.2

      \[\leadsto {\color{blue}{\left(\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)}\right)}}^{1}\]
    16. Using strategy rm
    17. Applied associate-/l*7.8

      \[\leadsto {\left(\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)}\right)}^{1}\]

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

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

      \[\leadsto \color{blue}{{\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right) \cdot 1}\right)}^{1}} \cdot {\left(\frac{x.im \cdot y.re - x.re \cdot y.im}{\mathsf{hypot}\left(y.re, y.im\right)}\right)}^{1}\]
    11. Applied pow-prod-down11.8

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

      \[\leadsto {\color{blue}{\left(\frac{\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)}\right)}}^{1}\]
    13. Using strategy rm
    14. Applied div-sub11.7

      \[\leadsto {\left(\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)}\right)}^{1}\]
    15. Applied div-sub11.7

      \[\leadsto {\color{blue}{\left(\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)}\right)}}^{1}\]
    16. Using strategy rm
    17. Applied *-un-lft-identity11.7

      \[\leadsto {\left(\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)}\right)}^{1}\]
    18. Applied times-frac1.7

      \[\leadsto {\left(\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)}\right)}^{1}\]
    19. Applied associate-/l*1.9

      \[\leadsto {\left(\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)}}}}\right)}^{1}\]
  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):\\ \;\;\;\;{\left(\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)}\right)}^{1}\\ \mathbf{else}:\\ \;\;\;\;{\left(\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)}}}\right)}^{1}\\ \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))))