Average Error: 26.3 → 12.6
Time: 10.8s
Precision: binary64
\[\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 \leq -6.768602245328106 \cdot 10^{+178}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \frac{1}{\frac{-1}{x.im}}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_0 := y.re \cdot x.im - y.im \cdot x.re\\ \mathbf{if}\;y.re \leq -7.25891010860212 \cdot 10^{-279}:\\ \;\;\;\;\frac{\frac{t_0}{\mathsf{hypot}\left(y.im, y.re\right)}}{\mathsf{hypot}\left(y.im, y.re\right)}\\ \mathbf{elif}\;y.re \leq 6.614960636702775 \cdot 10^{-88}:\\ \;\;\;\;\frac{y.re \cdot x.im}{y.im \cdot y.im} - \frac{x.re}{y.im}\\ \mathbf{elif}\;y.re \leq 1.846500094027842 \cdot 10^{+129}:\\ \;\;\;\;\frac{\frac{1}{\frac{\mathsf{hypot}\left(y.im, y.re\right)}{t_0}}}{\mathsf{hypot}\left(y.im, y.re\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \end{array}\\ \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 \leq -6.768602245328106 \cdot 10^{+178}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \frac{1}{\frac{-1}{x.im}}\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := y.re \cdot x.im - y.im \cdot x.re\\
\mathbf{if}\;y.re \leq -7.25891010860212 \cdot 10^{-279}:\\
\;\;\;\;\frac{\frac{t_0}{\mathsf{hypot}\left(y.im, y.re\right)}}{\mathsf{hypot}\left(y.im, y.re\right)}\\

\mathbf{elif}\;y.re \leq 6.614960636702775 \cdot 10^{-88}:\\
\;\;\;\;\frac{y.re \cdot x.im}{y.im \cdot y.im} - \frac{x.re}{y.im}\\

\mathbf{elif}\;y.re \leq 1.846500094027842 \cdot 10^{+129}:\\
\;\;\;\;\frac{\frac{1}{\frac{\mathsf{hypot}\left(y.im, y.re\right)}{t_0}}}{\mathsf{hypot}\left(y.im, y.re\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.re}\\


\end{array}\\


\end{array}
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))))
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (<= y.re -6.768602245328106e+178)
   (* (/ 1.0 (hypot y.im y.re)) (/ 1.0 (/ -1.0 x.im)))
   (let* ((t_0 (- (* y.re x.im) (* y.im x.re))))
     (if (<= y.re -7.25891010860212e-279)
       (/ (/ t_0 (hypot y.im y.re)) (hypot y.im y.re))
       (if (<= y.re 6.614960636702775e-88)
         (- (/ (* y.re x.im) (* y.im y.im)) (/ x.re y.im))
         (if (<= y.re 1.846500094027842e+129)
           (/ (/ 1.0 (/ (hypot y.im y.re) t_0)) (hypot y.im y.re))
           (/ x.im y.re)))))))
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 tmp;
	if (y_46_re <= -6.768602245328106e+178) {
		tmp = (1.0 / hypot(y_46_im, y_46_re)) * (1.0 / (-1.0 / x_46_im));
	} else {
		double t_0 = (y_46_re * x_46_im) - (y_46_im * x_46_re);
		double tmp_1;
		if (y_46_re <= -7.25891010860212e-279) {
			tmp_1 = (t_0 / hypot(y_46_im, y_46_re)) / hypot(y_46_im, y_46_re);
		} else if (y_46_re <= 6.614960636702775e-88) {
			tmp_1 = ((y_46_re * x_46_im) / (y_46_im * y_46_im)) - (x_46_re / y_46_im);
		} else if (y_46_re <= 1.846500094027842e+129) {
			tmp_1 = (1.0 / (hypot(y_46_im, y_46_re) / t_0)) / hypot(y_46_im, y_46_re);
		} else {
			tmp_1 = x_46_im / y_46_re;
		}
		tmp = tmp_1;
	}
	return tmp;
}

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 5 regimes
  2. if y.re < -6.76860224532810612e178

    1. Initial program 44.4

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Simplified44.4

      \[\leadsto \color{blue}{\frac{x.im \cdot y.re - x.re \cdot y.im}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}} \]
    3. Applied add-sqr-sqrt_binary6444.4

      \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{\sqrt{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)} \cdot \sqrt{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}}} \]
    4. Applied *-un-lft-identity_binary6444.4

      \[\leadsto \frac{\color{blue}{1 \cdot \left(x.im \cdot y.re - x.re \cdot y.im\right)}}{\sqrt{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)} \cdot \sqrt{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}} \]
    5. Applied times-frac_binary6444.4

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

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \color{blue}{\frac{1}{\frac{\mathsf{hypot}\left(y.im, y.re\right)}{y.re \cdot x.im - x.re \cdot y.im}}} \]
    9. Taylor expanded in y.re around -inf 12.9

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

    if -6.76860224532810612e178 < y.re < -7.2589101086021204e-279

    1. Initial program 20.8

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Simplified20.8

      \[\leadsto \color{blue}{\frac{x.im \cdot y.re - x.re \cdot y.im}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}} \]
    3. Applied add-sqr-sqrt_binary6420.8

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

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

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

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

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

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

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

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

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

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

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

    if -7.2589101086021204e-279 < y.re < 6.6149606367027748e-88

    1. Initial program 21.9

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Simplified21.9

      \[\leadsto \color{blue}{\frac{x.im \cdot y.re - x.re \cdot y.im}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}} \]
    3. Applied add-sqr-sqrt_binary6421.9

      \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{\sqrt{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)} \cdot \sqrt{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}}} \]
    4. Applied *-un-lft-identity_binary6421.9

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \color{blue}{\frac{1}{\frac{\mathsf{hypot}\left(y.im, y.re\right)}{y.re \cdot x.im - x.re \cdot y.im}}} \]
    9. Taylor expanded in y.im around inf 10.8

      \[\leadsto \color{blue}{\frac{y.re \cdot x.im}{{y.im}^{2}} - \frac{x.re}{y.im}} \]
    10. Simplified10.8

      \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{y.im \cdot y.im} - \frac{x.re}{y.im}} \]

    if 6.6149606367027748e-88 < y.re < 1.8465000940278421e129

    1. Initial program 16.3

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Simplified16.3

      \[\leadsto \color{blue}{\frac{x.im \cdot y.re - x.re \cdot y.im}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}} \]
    3. Applied add-sqr-sqrt_binary6416.3

      \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{\sqrt{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)} \cdot \sqrt{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}}} \]
    4. Applied *-un-lft-identity_binary6416.3

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

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

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

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

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

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

    if 1.8465000940278421e129 < y.re

    1. Initial program 43.1

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Simplified43.1

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification12.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -6.768602245328106 \cdot 10^{+178}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \frac{1}{\frac{-1}{x.im}}\\ \mathbf{elif}\;y.re \leq -7.25891010860212 \cdot 10^{-279}:\\ \;\;\;\;\frac{\frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{hypot}\left(y.im, y.re\right)}}{\mathsf{hypot}\left(y.im, y.re\right)}\\ \mathbf{elif}\;y.re \leq 6.614960636702775 \cdot 10^{-88}:\\ \;\;\;\;\frac{y.re \cdot x.im}{y.im \cdot y.im} - \frac{x.re}{y.im}\\ \mathbf{elif}\;y.re \leq 1.846500094027842 \cdot 10^{+129}:\\ \;\;\;\;\frac{\frac{1}{\frac{\mathsf{hypot}\left(y.im, y.re\right)}{y.re \cdot x.im - y.im \cdot x.re}}}{\mathsf{hypot}\left(y.im, y.re\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \end{array} \]

Reproduce

herbie shell --seed 2021273 
(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))))