Average Error: 26.2 → 11.9
Time: 4.9s
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.0951350871904923 \cdot 10^{187}:\\ \;\;\;\;\frac{-1 \cdot x.im}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{elif}\;y.re \le -4.18745680298238259 \cdot 10^{61}:\\ \;\;\;\;\frac{1}{\sqrt{\mathsf{hypot}\left(y.re, y.im\right)}} \cdot \left(\frac{y.re}{\frac{{\left(\sqrt{\mathsf{hypot}\left(y.re, y.im\right)}\right)}^{3}}{x.im}} - \frac{y.im}{\frac{{\left(\sqrt{\mathsf{hypot}\left(y.re, y.im\right)}\right)}^{3}}{x.re}}\right)\\ \mathbf{elif}\;y.re \le 2.1380990366988849 \cdot 10^{168}:\\ \;\;\;\;\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}:\\ \;\;\;\;\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.0951350871904923 \cdot 10^{187}:\\
\;\;\;\;\frac{-1 \cdot x.im}{\mathsf{hypot}\left(y.re, y.im\right)}\\

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

\mathbf{elif}\;y.re \le 2.1380990366988849 \cdot 10^{168}:\\
\;\;\;\;\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}:\\
\;\;\;\;\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}\\

\end{array}
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return (((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im)));
}
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double temp;
	if ((y_46_re <= -2.0951350871904923e+187)) {
		temp = ((-1.0 * x_46_im) / hypot(y_46_re, y_46_im));
	} else {
		double temp_1;
		if ((y_46_re <= -4.1874568029823826e+61)) {
			temp_1 = ((1.0 / sqrt(hypot(y_46_re, y_46_im))) * ((y_46_re / (pow(sqrt(hypot(y_46_re, y_46_im)), 3.0) / x_46_im)) - (y_46_im / (pow(sqrt(hypot(y_46_re, y_46_im)), 3.0) / x_46_re))));
		} else {
			double temp_2;
			if ((y_46_re <= 2.138099036698885e+168)) {
				temp_2 = ((((x_46_im * y_46_re) - (x_46_re * y_46_im)) / hypot(y_46_re, y_46_im)) / hypot(y_46_re, y_46_im));
			} else {
				temp_2 = (x_46_im / hypot(y_46_re, y_46_im));
			}
			temp_1 = temp_2;
		}
		temp = temp_1;
	}
	return temp;
}

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 4 regimes
  2. if y.re < -2.0951350871904923e+187

    1. Initial program 43.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 add-sqr-sqrt43.3

      \[\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-identity43.3

      \[\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-frac43.3

      \[\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. Simplified43.3

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

      \[\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/30.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. Simplified30.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. Taylor expanded around -inf 11.1

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

    if -2.0951350871904923e+187 < y.re < -4.1874568029823826e+61

    1. Initial program 30.5

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{\sqrt{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \sqrt{\mathsf{hypot}\left(y.re, y.im\right)}}}}{1 \cdot \mathsf{hypot}\left(y.re, y.im\right)}\]
    14. Applied *-un-lft-identity19.8

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

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

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

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

      \[\leadsto \frac{1}{\sqrt{\mathsf{hypot}\left(y.re, y.im\right)}} \cdot \color{blue}{\frac{\frac{x.im \cdot y.re - x.re \cdot y.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\sqrt{\mathsf{hypot}\left(y.re, y.im\right)}}}\]
    19. Using strategy rm
    20. Applied div-sub19.8

      \[\leadsto \frac{1}{\sqrt{\mathsf{hypot}\left(y.re, y.im\right)}} \cdot \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)}}}{\sqrt{\mathsf{hypot}\left(y.re, y.im\right)}}\]
    21. Applied div-sub19.8

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

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

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

    if -4.1874568029823826e+61 < y.re < 2.138099036698885e+168

    1. Initial program 19.7

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

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

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

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

      \[\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 associate-*r/12.1

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

      \[\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)}\]

    if 2.138099036698885e+168 < y.re

    1. Initial program 44.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 add-sqr-sqrt44.3

      \[\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-identity44.3

      \[\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-frac44.3

      \[\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. Simplified44.3

      \[\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. Simplified30.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 associate-*r/30.6

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

      \[\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. Taylor expanded around inf 11.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \le -2.0951350871904923 \cdot 10^{187}:\\ \;\;\;\;\frac{-1 \cdot x.im}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{elif}\;y.re \le -4.18745680298238259 \cdot 10^{61}:\\ \;\;\;\;\frac{1}{\sqrt{\mathsf{hypot}\left(y.re, y.im\right)}} \cdot \left(\frac{y.re}{\frac{{\left(\sqrt{\mathsf{hypot}\left(y.re, y.im\right)}\right)}^{3}}{x.im}} - \frac{y.im}{\frac{{\left(\sqrt{\mathsf{hypot}\left(y.re, y.im\right)}\right)}^{3}}{x.re}}\right)\\ \mathbf{elif}\;y.re \le 2.1380990366988849 \cdot 10^{168}:\\ \;\;\;\;\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}:\\ \;\;\;\;\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \end{array}\]

Reproduce

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