Average Error: 26.1 → 12.5
Time: 10.5s
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 -3.15237965316425658713861194838439775727 \cdot 10^{161}:\\ \;\;\;\;1 \cdot \frac{-1 \cdot x.im}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{elif}\;y.re \le 1.921207477017030655217671855912447948644 \cdot 10^{123}:\\ \;\;\;\;1 \cdot \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)}\\ \mathbf{else}:\\ \;\;\;\;1 \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 -3.15237965316425658713861194838439775727 \cdot 10^{161}:\\
\;\;\;\;1 \cdot \frac{-1 \cdot x.im}{\mathsf{hypot}\left(y.re, y.im\right)}\\

\mathbf{elif}\;y.re \le 1.921207477017030655217671855912447948644 \cdot 10^{123}:\\
\;\;\;\;1 \cdot \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)}\\

\mathbf{else}:\\
\;\;\;\;1 \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 r90528 = x_im;
        double r90529 = y_re;
        double r90530 = r90528 * r90529;
        double r90531 = x_re;
        double r90532 = y_im;
        double r90533 = r90531 * r90532;
        double r90534 = r90530 - r90533;
        double r90535 = r90529 * r90529;
        double r90536 = r90532 * r90532;
        double r90537 = r90535 + r90536;
        double r90538 = r90534 / r90537;
        return r90538;
}

double f(double x_re, double x_im, double y_re, double y_im) {
        double r90539 = y_re;
        double r90540 = -3.1523796531642566e+161;
        bool r90541 = r90539 <= r90540;
        double r90542 = 1.0;
        double r90543 = -1.0;
        double r90544 = x_im;
        double r90545 = r90543 * r90544;
        double r90546 = y_im;
        double r90547 = hypot(r90539, r90546);
        double r90548 = r90545 / r90547;
        double r90549 = r90542 * r90548;
        double r90550 = 1.9212074770170307e+123;
        bool r90551 = r90539 <= r90550;
        double r90552 = r90544 * r90539;
        double r90553 = x_re;
        double r90554 = r90553 * r90546;
        double r90555 = r90552 - r90554;
        double r90556 = r90555 / r90547;
        double r90557 = r90556 / r90547;
        double r90558 = r90542 * r90557;
        double r90559 = r90544 / r90547;
        double r90560 = r90542 * r90559;
        double r90561 = r90551 ? r90558 : r90560;
        double r90562 = r90541 ? r90549 : r90561;
        return r90562;
}

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 < -3.1523796531642566e+161

    1. Initial program 45.4

      \[\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-sqrt45.4

      \[\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-identity45.4

      \[\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-frac45.4

      \[\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. Simplified45.4

      \[\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. Simplified29.9

      \[\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 *-un-lft-identity29.9

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

      \[\leadsto \color{blue}{1 \cdot \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)}\]
    11. Simplified29.8

      \[\leadsto 1 \cdot \color{blue}{\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)}}\]
    12. Taylor expanded around -inf 12.9

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

    if -3.1523796531642566e+161 < y.re < 1.9212074770170307e+123

    1. Initial program 19.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 add-sqr-sqrt19.1

      \[\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.1

      \[\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.1

      \[\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.1

      \[\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. Simplified12.1

      \[\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 *-un-lft-identity12.1

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

      \[\leadsto \color{blue}{1 \cdot \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)}\]
    11. Simplified12.0

      \[\leadsto 1 \cdot \color{blue}{\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)}}\]

    if 1.9212074770170307e+123 < y.re

    1. Initial program 41.4

      \[\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.4

      \[\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.4

      \[\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.4

      \[\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.4

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

      \[\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 *-un-lft-identity26.6

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

      \[\leadsto \color{blue}{1 \cdot \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)}\]
    11. Simplified26.6

      \[\leadsto 1 \cdot \color{blue}{\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)}}\]
    12. Taylor expanded around inf 14.7

      \[\leadsto 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.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \le -3.15237965316425658713861194838439775727 \cdot 10^{161}:\\ \;\;\;\;1 \cdot \frac{-1 \cdot x.im}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{elif}\;y.re \le 1.921207477017030655217671855912447948644 \cdot 10^{123}:\\ \;\;\;\;1 \cdot \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)}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \end{array}\]

Reproduce

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