_divideComplex, imaginary part

Percentage Accurate: 62.3% → 80.5%
Time: 11.0s
Alternatives: 10
Speedup: 1.5×

Specification

?
\[\begin{array}{l} \\ \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \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))))
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));
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    code = ((x_46im * y_46re) - (x_46re * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
end function
public static 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));
}
def code(x_46_re, x_46_im, y_46_re, 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))
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	return Float64(Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)))
end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 10 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 62.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \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))))
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));
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    code = ((x_46im * y_46re) - (x_46re * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
end function
public static 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));
}
def code(x_46_re, x_46_im, y_46_re, 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))
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	return Float64(Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)))
end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\end{array}

Alternative 1: 80.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(x.re, -\frac{y.im}{y.re}, x.im\right)}{y.re}\\ \mathbf{if}\;y.im \leq -3.25 \cdot 10^{+74}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\ \mathbf{elif}\;y.im \leq -2.4 \cdot 10^{+54}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.im \leq -1.25 \cdot 10^{-153}:\\ \;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 0.0102:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y.re}{y.im}, \frac{x.im}{y.im}, \frac{-x.re}{y.im}\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (/ (fma x.re (- (/ y.im y.re)) x.im) y.re)))
   (if (<= y.im -3.25e+74)
     (/ (fma y.re (/ x.im y.im) (- x.re)) y.im)
     (if (<= y.im -2.4e+54)
       t_0
       (if (<= y.im -1.25e-153)
         (/ (- (* y.re x.im) (* y.im x.re)) (+ (* y.re y.re) (* y.im y.im)))
         (if (<= y.im 0.0102)
           t_0
           (fma (/ y.re y.im) (/ x.im y.im) (/ (- x.re) y.im))))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = fma(x_46_re, -(y_46_im / y_46_re), x_46_im) / y_46_re;
	double tmp;
	if (y_46_im <= -3.25e+74) {
		tmp = fma(y_46_re, (x_46_im / y_46_im), -x_46_re) / y_46_im;
	} else if (y_46_im <= -2.4e+54) {
		tmp = t_0;
	} else if (y_46_im <= -1.25e-153) {
		tmp = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	} else if (y_46_im <= 0.0102) {
		tmp = t_0;
	} else {
		tmp = fma((y_46_re / y_46_im), (x_46_im / y_46_im), (-x_46_re / y_46_im));
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(fma(x_46_re, Float64(-Float64(y_46_im / y_46_re)), x_46_im) / y_46_re)
	tmp = 0.0
	if (y_46_im <= -3.25e+74)
		tmp = Float64(fma(y_46_re, Float64(x_46_im / y_46_im), Float64(-x_46_re)) / y_46_im);
	elseif (y_46_im <= -2.4e+54)
		tmp = t_0;
	elseif (y_46_im <= -1.25e-153)
		tmp = Float64(Float64(Float64(y_46_re * x_46_im) - Float64(y_46_im * x_46_re)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)));
	elseif (y_46_im <= 0.0102)
		tmp = t_0;
	else
		tmp = fma(Float64(y_46_re / y_46_im), Float64(x_46_im / y_46_im), Float64(Float64(-x_46_re) / y_46_im));
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(x$46$re * (-N[(y$46$im / y$46$re), $MachinePrecision]) + x$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$im, -3.25e+74], N[(N[(y$46$re * N[(x$46$im / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, -2.4e+54], t$95$0, If[LessEqual[y$46$im, -1.25e-153], N[(N[(N[(y$46$re * x$46$im), $MachinePrecision] - N[(y$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 0.0102], t$95$0, N[(N[(y$46$re / y$46$im), $MachinePrecision] * N[(x$46$im / y$46$im), $MachinePrecision] + N[((-x$46$re) / y$46$im), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(x.re, -\frac{y.im}{y.re}, x.im\right)}{y.re}\\
\mathbf{if}\;y.im \leq -3.25 \cdot 10^{+74}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\

\mathbf{elif}\;y.im \leq -2.4 \cdot 10^{+54}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y.im \leq -1.25 \cdot 10^{-153}:\\
\;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\\

\mathbf{elif}\;y.im \leq 0.0102:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y.re}{y.im}, \frac{x.im}{y.im}, \frac{-x.re}{y.im}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y.im < -3.24999999999999981e74

    1. Initial program 53.1%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im} + \frac{x.im \cdot y.re}{{y.im}^{2}}} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{{y.im}^{2}} + -1 \cdot \frac{x.re}{y.im}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{x.im \cdot y.re}{{y.im}^{2}} + \color{blue}{\left(\mathsf{neg}\left(\frac{x.re}{y.im}\right)\right)} \]
      3. unsub-negN/A

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{{y.im}^{2}} - \frac{x.re}{y.im}} \]
      4. unpow2N/A

        \[\leadsto \frac{x.im \cdot y.re}{\color{blue}{y.im \cdot y.im}} - \frac{x.re}{y.im} \]
      5. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im}}{y.im}} - \frac{x.re}{y.im} \]
      6. div-subN/A

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}} \]
      7. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}} \]
      8. sub-negN/A

        \[\leadsto \frac{\color{blue}{\frac{x.im \cdot y.re}{y.im} + \left(\mathsf{neg}\left(x.re\right)\right)}}{y.im} \]
      9. *-commutativeN/A

        \[\leadsto \frac{\frac{\color{blue}{y.re \cdot x.im}}{y.im} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      10. associate-/l*N/A

        \[\leadsto \frac{\color{blue}{y.re \cdot \frac{x.im}{y.im}} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      11. mul-1-negN/A

        \[\leadsto \frac{y.re \cdot \frac{x.im}{y.im} + \color{blue}{-1 \cdot x.re}}{y.im} \]
      12. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -1 \cdot x.re\right)}}{y.im} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(y.re, \color{blue}{\frac{x.im}{y.im}}, -1 \cdot x.re\right)}{y.im} \]
      14. mul-1-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, \color{blue}{\mathsf{neg}\left(x.re\right)}\right)}{y.im} \]
      15. lower-neg.f6487.2

        \[\leadsto \frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, \color{blue}{-x.re}\right)}{y.im} \]
    5. Simplified87.2%

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

    if -3.24999999999999981e74 < y.im < -2.39999999999999998e54 or -1.25000000000000008e-153 < y.im < 0.010200000000000001

    1. Initial program 62.0%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{x.im \cdot y.re} - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{x.im \cdot y.re - \color{blue}{x.re \cdot y.im}}{y.re \cdot y.re + y.im \cdot y.im} \]
      3. sub-negN/A

        \[\leadsto \frac{\color{blue}{x.im \cdot y.re + \left(\mathsf{neg}\left(x.re \cdot y.im\right)\right)}}{y.re \cdot y.re + y.im \cdot y.im} \]
      4. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(x.re \cdot y.im\right)\right) + x.im \cdot y.re}}{y.re \cdot y.re + y.im \cdot y.im} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{x.re \cdot y.im}\right)\right) + x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{y.im \cdot x.re}\right)\right) + x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} \]
      7. distribute-lft-neg-inN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(y.im\right)\right) \cdot x.re} + x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} \]
      8. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(y.im\right), x.re, x.im \cdot y.re\right)}}{y.re \cdot y.re + y.im \cdot y.im} \]
      9. lower-neg.f6462.0

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{-y.im}, x.re, x.im \cdot y.re\right)}{y.re \cdot y.re + y.im \cdot y.im} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(y.im\right), x.re, \color{blue}{x.im \cdot y.re}\right)}{y.re \cdot y.re + y.im \cdot y.im} \]
      11. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(y.im\right), x.re, \color{blue}{y.re \cdot x.im}\right)}{y.re \cdot y.re + y.im \cdot y.im} \]
      12. lower-*.f6462.0

        \[\leadsto \frac{\mathsf{fma}\left(-y.im, x.re, \color{blue}{y.re \cdot x.im}\right)}{y.re \cdot y.re + y.im \cdot y.im} \]
    4. Applied egg-rr62.0%

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

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(y.im\right), x.re, y.re \cdot x.im\right)}{\color{blue}{{y.re}^{2}}} \]
    6. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(y.im\right), x.re, y.re \cdot x.im\right)}{\color{blue}{y.re \cdot y.re}} \]
      2. lower-*.f6460.1

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re \cdot y.im}{{y.re}^{2}} + \frac{x.im}{y.re}} \]
    9. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{x.re \cdot y.im}{{y.re}^{2}}\right)\right)} + \frac{x.im}{y.re} \]
      2. neg-sub0N/A

        \[\leadsto \color{blue}{\left(0 - \frac{x.re \cdot y.im}{{y.re}^{2}}\right)} + \frac{x.im}{y.re} \]
      3. associate-+l-N/A

        \[\leadsto \color{blue}{0 - \left(\frac{x.re \cdot y.im}{{y.re}^{2}} - \frac{x.im}{y.re}\right)} \]
      4. unpow2N/A

        \[\leadsto 0 - \left(\frac{x.re \cdot y.im}{\color{blue}{y.re \cdot y.re}} - \frac{x.im}{y.re}\right) \]
      5. associate-/r*N/A

        \[\leadsto 0 - \left(\color{blue}{\frac{\frac{x.re \cdot y.im}{y.re}}{y.re}} - \frac{x.im}{y.re}\right) \]
      6. div-subN/A

        \[\leadsto 0 - \color{blue}{\frac{\frac{x.re \cdot y.im}{y.re} - x.im}{y.re}} \]
      7. unsub-negN/A

        \[\leadsto 0 - \frac{\color{blue}{\frac{x.re \cdot y.im}{y.re} + \left(\mathsf{neg}\left(x.im\right)\right)}}{y.re} \]
      8. mul-1-negN/A

        \[\leadsto 0 - \frac{\frac{x.re \cdot y.im}{y.re} + \color{blue}{-1 \cdot x.im}}{y.re} \]
      9. +-commutativeN/A

        \[\leadsto 0 - \frac{\color{blue}{-1 \cdot x.im + \frac{x.re \cdot y.im}{y.re}}}{y.re} \]
      10. neg-sub0N/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{-1 \cdot x.im + \frac{x.re \cdot y.im}{y.re}}{y.re}\right)} \]
      11. mul-1-negN/A

        \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot x.im + \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
      12. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(-1 \cdot x.im + \frac{x.re \cdot y.im}{y.re}\right)}{y.re}} \]
      13. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(-1 \cdot x.im + \frac{x.re \cdot y.im}{y.re}\right)}{y.re}} \]
    10. Simplified93.1%

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

    if -2.39999999999999998e54 < y.im < -1.25000000000000008e-153

    1. Initial program 86.4%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing

    if 0.010200000000000001 < y.im

    1. Initial program 58.8%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im} + \frac{x.im \cdot y.re}{{y.im}^{2}}} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{{y.im}^{2}} + -1 \cdot \frac{x.re}{y.im}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{x.im \cdot y.re}{{y.im}^{2}} + \color{blue}{\left(\mathsf{neg}\left(\frac{x.re}{y.im}\right)\right)} \]
      3. unsub-negN/A

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{{y.im}^{2}} - \frac{x.re}{y.im}} \]
      4. unpow2N/A

        \[\leadsto \frac{x.im \cdot y.re}{\color{blue}{y.im \cdot y.im}} - \frac{x.re}{y.im} \]
      5. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im}}{y.im}} - \frac{x.re}{y.im} \]
      6. div-subN/A

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}} \]
      7. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}} \]
      8. sub-negN/A

        \[\leadsto \frac{\color{blue}{\frac{x.im \cdot y.re}{y.im} + \left(\mathsf{neg}\left(x.re\right)\right)}}{y.im} \]
      9. *-commutativeN/A

        \[\leadsto \frac{\frac{\color{blue}{y.re \cdot x.im}}{y.im} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      10. associate-/l*N/A

        \[\leadsto \frac{\color{blue}{y.re \cdot \frac{x.im}{y.im}} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      11. mul-1-negN/A

        \[\leadsto \frac{y.re \cdot \frac{x.im}{y.im} + \color{blue}{-1 \cdot x.re}}{y.im} \]
      12. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -1 \cdot x.re\right)}}{y.im} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(y.re, \color{blue}{\frac{x.im}{y.im}}, -1 \cdot x.re\right)}{y.im} \]
      14. mul-1-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, \color{blue}{\mathsf{neg}\left(x.re\right)}\right)}{y.im} \]
      15. lower-neg.f6487.5

        \[\leadsto \frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, \color{blue}{-x.re}\right)}{y.im} \]
    5. Simplified87.5%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}} \]
    6. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{y.re \cdot \color{blue}{\frac{x.im}{y.im}} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      2. +-rgt-identityN/A

        \[\leadsto \frac{\color{blue}{\left(y.re \cdot \frac{x.im}{y.im} + 0\right)} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      3. sub-negN/A

        \[\leadsto \frac{\color{blue}{\left(y.re \cdot \frac{x.im}{y.im} + 0\right) - x.re}}{y.im} \]
      4. div-subN/A

        \[\leadsto \color{blue}{\frac{y.re \cdot \frac{x.im}{y.im} + 0}{y.im} - \frac{x.re}{y.im}} \]
      5. +-rgt-identityN/A

        \[\leadsto \frac{\color{blue}{y.re \cdot \frac{x.im}{y.im}}}{y.im} - \frac{x.re}{y.im} \]
      6. lift-/.f64N/A

        \[\leadsto \frac{y.re \cdot \color{blue}{\frac{x.im}{y.im}}}{y.im} - \frac{x.re}{y.im} \]
      7. associate-*r/N/A

        \[\leadsto \frac{\color{blue}{\frac{y.re \cdot x.im}{y.im}}}{y.im} - \frac{x.re}{y.im} \]
      8. lift-*.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{y.re \cdot x.im}}{y.im}}{y.im} - \frac{x.re}{y.im} \]
      9. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{y.re \cdot x.im}{y.im \cdot y.im}} - \frac{x.re}{y.im} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{y.re \cdot x.im}}{y.im \cdot y.im} - \frac{x.re}{y.im} \]
      11. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{x.im \cdot y.re}}{y.im \cdot y.im} - \frac{x.re}{y.im} \]
      12. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{x.im \cdot y.re}}{y.im \cdot y.im} - \frac{x.re}{y.im} \]
      13. lift-*.f64N/A

        \[\leadsto \frac{x.im \cdot y.re}{\color{blue}{y.im \cdot y.im}} - \frac{x.re}{y.im} \]
      14. sub-negN/A

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{y.im \cdot y.im} + \left(\mathsf{neg}\left(\frac{x.re}{y.im}\right)\right)} \]
      15. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{x.im \cdot y.re}}{y.im \cdot y.im} + \left(\mathsf{neg}\left(\frac{x.re}{y.im}\right)\right) \]
      16. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{y.re \cdot x.im}}{y.im \cdot y.im} + \left(\mathsf{neg}\left(\frac{x.re}{y.im}\right)\right) \]
      17. lift-*.f64N/A

        \[\leadsto \frac{y.re \cdot x.im}{\color{blue}{y.im \cdot y.im}} + \left(\mathsf{neg}\left(\frac{x.re}{y.im}\right)\right) \]
      18. times-fracN/A

        \[\leadsto \color{blue}{\frac{y.re}{y.im} \cdot \frac{x.im}{y.im}} + \left(\mathsf{neg}\left(\frac{x.re}{y.im}\right)\right) \]
      19. lift-/.f64N/A

        \[\leadsto \frac{y.re}{y.im} \cdot \color{blue}{\frac{x.im}{y.im}} + \left(\mathsf{neg}\left(\frac{x.re}{y.im}\right)\right) \]
      20. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y.re}{y.im}, \frac{x.im}{y.im}, \mathsf{neg}\left(\frac{x.re}{y.im}\right)\right)} \]
      21. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{y.re}{y.im}}, \frac{x.im}{y.im}, \mathsf{neg}\left(\frac{x.re}{y.im}\right)\right) \]
    7. Applied egg-rr87.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -3.25 \cdot 10^{+74}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\ \mathbf{elif}\;y.im \leq -2.4 \cdot 10^{+54}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.re, -\frac{y.im}{y.re}, x.im\right)}{y.re}\\ \mathbf{elif}\;y.im \leq -1.25 \cdot 10^{-153}:\\ \;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 0.0102:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.re, -\frac{y.im}{y.re}, x.im\right)}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y.re}{y.im}, \frac{x.im}{y.im}, \frac{-x.re}{y.im}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 80.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(x.re, -\frac{y.im}{y.re}, x.im\right)}{y.re}\\ t_1 := \frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\ \mathbf{if}\;y.im \leq -6.2 \cdot 10^{+74}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y.im \leq -3.4 \cdot 10^{+54}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.im \leq -1.25 \cdot 10^{-153}:\\ \;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 0.00062:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (/ (fma x.re (- (/ y.im y.re)) x.im) y.re))
        (t_1 (/ (fma y.re (/ x.im y.im) (- x.re)) y.im)))
   (if (<= y.im -6.2e+74)
     t_1
     (if (<= y.im -3.4e+54)
       t_0
       (if (<= y.im -1.25e-153)
         (/ (- (* y.re x.im) (* y.im x.re)) (+ (* y.re y.re) (* y.im y.im)))
         (if (<= y.im 0.00062) t_0 t_1))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = fma(x_46_re, -(y_46_im / y_46_re), x_46_im) / y_46_re;
	double t_1 = fma(y_46_re, (x_46_im / y_46_im), -x_46_re) / y_46_im;
	double tmp;
	if (y_46_im <= -6.2e+74) {
		tmp = t_1;
	} else if (y_46_im <= -3.4e+54) {
		tmp = t_0;
	} else if (y_46_im <= -1.25e-153) {
		tmp = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	} else if (y_46_im <= 0.00062) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(fma(x_46_re, Float64(-Float64(y_46_im / y_46_re)), x_46_im) / y_46_re)
	t_1 = Float64(fma(y_46_re, Float64(x_46_im / y_46_im), Float64(-x_46_re)) / y_46_im)
	tmp = 0.0
	if (y_46_im <= -6.2e+74)
		tmp = t_1;
	elseif (y_46_im <= -3.4e+54)
		tmp = t_0;
	elseif (y_46_im <= -1.25e-153)
		tmp = Float64(Float64(Float64(y_46_re * x_46_im) - Float64(y_46_im * x_46_re)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)));
	elseif (y_46_im <= 0.00062)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(x$46$re * (-N[(y$46$im / y$46$re), $MachinePrecision]) + x$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]}, Block[{t$95$1 = N[(N[(y$46$re * N[(x$46$im / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -6.2e+74], t$95$1, If[LessEqual[y$46$im, -3.4e+54], t$95$0, If[LessEqual[y$46$im, -1.25e-153], N[(N[(N[(y$46$re * x$46$im), $MachinePrecision] - N[(y$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 0.00062], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(x.re, -\frac{y.im}{y.re}, x.im\right)}{y.re}\\
t_1 := \frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\
\mathbf{if}\;y.im \leq -6.2 \cdot 10^{+74}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y.im \leq -3.4 \cdot 10^{+54}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y.im \leq -1.25 \cdot 10^{-153}:\\
\;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\\

\mathbf{elif}\;y.im \leq 0.00062:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.im < -6.20000000000000043e74 or 6.2e-4 < y.im

    1. Initial program 56.7%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im} + \frac{x.im \cdot y.re}{{y.im}^{2}}} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{{y.im}^{2}} + -1 \cdot \frac{x.re}{y.im}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{x.im \cdot y.re}{{y.im}^{2}} + \color{blue}{\left(\mathsf{neg}\left(\frac{x.re}{y.im}\right)\right)} \]
      3. unsub-negN/A

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{{y.im}^{2}} - \frac{x.re}{y.im}} \]
      4. unpow2N/A

        \[\leadsto \frac{x.im \cdot y.re}{\color{blue}{y.im \cdot y.im}} - \frac{x.re}{y.im} \]
      5. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im}}{y.im}} - \frac{x.re}{y.im} \]
      6. div-subN/A

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}} \]
      7. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}} \]
      8. sub-negN/A

        \[\leadsto \frac{\color{blue}{\frac{x.im \cdot y.re}{y.im} + \left(\mathsf{neg}\left(x.re\right)\right)}}{y.im} \]
      9. *-commutativeN/A

        \[\leadsto \frac{\frac{\color{blue}{y.re \cdot x.im}}{y.im} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      10. associate-/l*N/A

        \[\leadsto \frac{\color{blue}{y.re \cdot \frac{x.im}{y.im}} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      11. mul-1-negN/A

        \[\leadsto \frac{y.re \cdot \frac{x.im}{y.im} + \color{blue}{-1 \cdot x.re}}{y.im} \]
      12. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -1 \cdot x.re\right)}}{y.im} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(y.re, \color{blue}{\frac{x.im}{y.im}}, -1 \cdot x.re\right)}{y.im} \]
      14. mul-1-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, \color{blue}{\mathsf{neg}\left(x.re\right)}\right)}{y.im} \]
      15. lower-neg.f6487.4

        \[\leadsto \frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, \color{blue}{-x.re}\right)}{y.im} \]
    5. Simplified87.4%

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

    if -6.20000000000000043e74 < y.im < -3.4000000000000001e54 or -1.25000000000000008e-153 < y.im < 6.2e-4

    1. Initial program 62.0%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{x.im \cdot y.re} - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{x.im \cdot y.re - \color{blue}{x.re \cdot y.im}}{y.re \cdot y.re + y.im \cdot y.im} \]
      3. sub-negN/A

        \[\leadsto \frac{\color{blue}{x.im \cdot y.re + \left(\mathsf{neg}\left(x.re \cdot y.im\right)\right)}}{y.re \cdot y.re + y.im \cdot y.im} \]
      4. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(x.re \cdot y.im\right)\right) + x.im \cdot y.re}}{y.re \cdot y.re + y.im \cdot y.im} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{x.re \cdot y.im}\right)\right) + x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{y.im \cdot x.re}\right)\right) + x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} \]
      7. distribute-lft-neg-inN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(y.im\right)\right) \cdot x.re} + x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} \]
      8. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(y.im\right), x.re, x.im \cdot y.re\right)}}{y.re \cdot y.re + y.im \cdot y.im} \]
      9. lower-neg.f6462.0

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{-y.im}, x.re, x.im \cdot y.re\right)}{y.re \cdot y.re + y.im \cdot y.im} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(y.im\right), x.re, \color{blue}{x.im \cdot y.re}\right)}{y.re \cdot y.re + y.im \cdot y.im} \]
      11. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(y.im\right), x.re, \color{blue}{y.re \cdot x.im}\right)}{y.re \cdot y.re + y.im \cdot y.im} \]
      12. lower-*.f6462.0

        \[\leadsto \frac{\mathsf{fma}\left(-y.im, x.re, \color{blue}{y.re \cdot x.im}\right)}{y.re \cdot y.re + y.im \cdot y.im} \]
    4. Applied egg-rr62.0%

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

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(y.im\right), x.re, y.re \cdot x.im\right)}{\color{blue}{{y.re}^{2}}} \]
    6. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(y.im\right), x.re, y.re \cdot x.im\right)}{\color{blue}{y.re \cdot y.re}} \]
      2. lower-*.f6460.1

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re \cdot y.im}{{y.re}^{2}} + \frac{x.im}{y.re}} \]
    9. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{x.re \cdot y.im}{{y.re}^{2}}\right)\right)} + \frac{x.im}{y.re} \]
      2. neg-sub0N/A

        \[\leadsto \color{blue}{\left(0 - \frac{x.re \cdot y.im}{{y.re}^{2}}\right)} + \frac{x.im}{y.re} \]
      3. associate-+l-N/A

        \[\leadsto \color{blue}{0 - \left(\frac{x.re \cdot y.im}{{y.re}^{2}} - \frac{x.im}{y.re}\right)} \]
      4. unpow2N/A

        \[\leadsto 0 - \left(\frac{x.re \cdot y.im}{\color{blue}{y.re \cdot y.re}} - \frac{x.im}{y.re}\right) \]
      5. associate-/r*N/A

        \[\leadsto 0 - \left(\color{blue}{\frac{\frac{x.re \cdot y.im}{y.re}}{y.re}} - \frac{x.im}{y.re}\right) \]
      6. div-subN/A

        \[\leadsto 0 - \color{blue}{\frac{\frac{x.re \cdot y.im}{y.re} - x.im}{y.re}} \]
      7. unsub-negN/A

        \[\leadsto 0 - \frac{\color{blue}{\frac{x.re \cdot y.im}{y.re} + \left(\mathsf{neg}\left(x.im\right)\right)}}{y.re} \]
      8. mul-1-negN/A

        \[\leadsto 0 - \frac{\frac{x.re \cdot y.im}{y.re} + \color{blue}{-1 \cdot x.im}}{y.re} \]
      9. +-commutativeN/A

        \[\leadsto 0 - \frac{\color{blue}{-1 \cdot x.im + \frac{x.re \cdot y.im}{y.re}}}{y.re} \]
      10. neg-sub0N/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{-1 \cdot x.im + \frac{x.re \cdot y.im}{y.re}}{y.re}\right)} \]
      11. mul-1-negN/A

        \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot x.im + \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
      12. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(-1 \cdot x.im + \frac{x.re \cdot y.im}{y.re}\right)}{y.re}} \]
      13. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(-1 \cdot x.im + \frac{x.re \cdot y.im}{y.re}\right)}{y.re}} \]
    10. Simplified93.1%

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

    if -3.4000000000000001e54 < y.im < -1.25000000000000008e-153

    1. Initial program 86.4%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
  3. Recombined 3 regimes into one program.
  4. Final simplification89.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -6.2 \cdot 10^{+74}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\ \mathbf{elif}\;y.im \leq -3.4 \cdot 10^{+54}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.re, -\frac{y.im}{y.re}, x.im\right)}{y.re}\\ \mathbf{elif}\;y.im \leq -1.25 \cdot 10^{-153}:\\ \;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 0.00062:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.re, -\frac{y.im}{y.re}, x.im\right)}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 73.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-x.re}{y.im}\\ \mathbf{if}\;y.im \leq -9.5 \cdot 10^{+28}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.im \leq 5.8 \cdot 10^{-5}:\\ \;\;\;\;\frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re}\\ \mathbf{elif}\;y.im \leq 9 \cdot 10^{+142}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-y.im, x.re, y.re \cdot x.im\right)}{y.im \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (/ (- x.re) y.im)))
   (if (<= y.im -9.5e+28)
     t_0
     (if (<= y.im 5.8e-5)
       (/ (- x.im (/ (* y.im x.re) y.re)) y.re)
       (if (<= y.im 9e+142)
         (/ (fma (- y.im) x.re (* y.re x.im)) (* y.im y.im))
         t_0)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = -x_46_re / y_46_im;
	double tmp;
	if (y_46_im <= -9.5e+28) {
		tmp = t_0;
	} else if (y_46_im <= 5.8e-5) {
		tmp = (x_46_im - ((y_46_im * x_46_re) / y_46_re)) / y_46_re;
	} else if (y_46_im <= 9e+142) {
		tmp = fma(-y_46_im, x_46_re, (y_46_re * x_46_im)) / (y_46_im * y_46_im);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(-x_46_re) / y_46_im)
	tmp = 0.0
	if (y_46_im <= -9.5e+28)
		tmp = t_0;
	elseif (y_46_im <= 5.8e-5)
		tmp = Float64(Float64(x_46_im - Float64(Float64(y_46_im * x_46_re) / y_46_re)) / y_46_re);
	elseif (y_46_im <= 9e+142)
		tmp = Float64(fma(Float64(-y_46_im), x_46_re, Float64(y_46_re * x_46_im)) / Float64(y_46_im * y_46_im));
	else
		tmp = t_0;
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[((-x$46$re) / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -9.5e+28], t$95$0, If[LessEqual[y$46$im, 5.8e-5], N[(N[(x$46$im - N[(N[(y$46$im * x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 9e+142], N[(N[((-y$46$im) * x$46$re + N[(y$46$re * x$46$im), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{-x.re}{y.im}\\
\mathbf{if}\;y.im \leq -9.5 \cdot 10^{+28}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;y.im \leq 9 \cdot 10^{+142}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-y.im, x.re, y.re \cdot x.im\right)}{y.im \cdot y.im}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.im < -9.49999999999999927e28 or 8.9999999999999998e142 < y.im

    1. Initial program 43.2%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im}} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{x.re}{y.im}\right)} \]
      2. distribute-neg-frac2N/A

        \[\leadsto \color{blue}{\frac{x.re}{\mathsf{neg}\left(y.im\right)}} \]
      3. mul-1-negN/A

        \[\leadsto \frac{x.re}{\color{blue}{-1 \cdot y.im}} \]
      4. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x.re}{-1 \cdot y.im}} \]
      5. mul-1-negN/A

        \[\leadsto \frac{x.re}{\color{blue}{\mathsf{neg}\left(y.im\right)}} \]
      6. lower-neg.f6475.1

        \[\leadsto \frac{x.re}{\color{blue}{-y.im}} \]
    5. Simplified75.1%

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

    if -9.49999999999999927e28 < y.im < 5.8e-5

    1. Initial program 72.2%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around inf

      \[\leadsto \color{blue}{\frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{x.im + \color{blue}{\left(\mathsf{neg}\left(\frac{x.re \cdot y.im}{y.re}\right)\right)}}{y.re} \]
      3. unsub-negN/A

        \[\leadsto \frac{\color{blue}{x.im - \frac{x.re \cdot y.im}{y.re}}}{y.re} \]
      4. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{x.im - \frac{x.re \cdot y.im}{y.re}}}{y.re} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{x.im - \color{blue}{\frac{x.re \cdot y.im}{y.re}}}{y.re} \]
      6. *-commutativeN/A

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

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

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

    if 5.8e-5 < y.im < 8.9999999999999998e142

    1. Initial program 91.1%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around 0

      \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{{y.im}^{2}}} \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{y.im \cdot y.im}} \]
      2. lower-*.f6479.8

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

      \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{y.im \cdot y.im}} \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{y.re \cdot x.im} - x.re \cdot y.im}{y.im \cdot y.im} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{y.re \cdot x.im} - x.re \cdot y.im}{y.im \cdot y.im} \]
      3. *-commutativeN/A

        \[\leadsto \frac{y.re \cdot x.im - \color{blue}{y.im \cdot x.re}}{y.im \cdot y.im} \]
      4. cancel-sign-sub-invN/A

        \[\leadsto \frac{\color{blue}{y.re \cdot x.im + \left(\mathsf{neg}\left(y.im\right)\right) \cdot x.re}}{y.im \cdot y.im} \]
      5. lift-neg.f64N/A

        \[\leadsto \frac{y.re \cdot x.im + \color{blue}{\left(\mathsf{neg}\left(y.im\right)\right)} \cdot x.re}{y.im \cdot y.im} \]
      6. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(y.im\right)\right) \cdot x.re + y.re \cdot x.im}}{y.im \cdot y.im} \]
      7. lift-fma.f6480.0

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(-y.im, x.re, y.re \cdot x.im\right)}}{y.im \cdot y.im} \]
    7. Applied egg-rr80.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -9.5 \cdot 10^{+28}:\\ \;\;\;\;\frac{-x.re}{y.im}\\ \mathbf{elif}\;y.im \leq 5.8 \cdot 10^{-5}:\\ \;\;\;\;\frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re}\\ \mathbf{elif}\;y.im \leq 9 \cdot 10^{+142}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-y.im, x.re, y.re \cdot x.im\right)}{y.im \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{-x.re}{y.im}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 64.6% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-x.re}{y.im}\\ \mathbf{if}\;y.im \leq -7.4 \cdot 10^{+22}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.im \leq 6.8 \cdot 10^{-6}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{elif}\;y.im \leq 1.4 \cdot 10^{+143}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-y.im, x.re, y.re \cdot x.im\right)}{y.im \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (/ (- x.re) y.im)))
   (if (<= y.im -7.4e+22)
     t_0
     (if (<= y.im 6.8e-6)
       (/ x.im y.re)
       (if (<= y.im 1.4e+143)
         (/ (fma (- y.im) x.re (* y.re x.im)) (* y.im y.im))
         t_0)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = -x_46_re / y_46_im;
	double tmp;
	if (y_46_im <= -7.4e+22) {
		tmp = t_0;
	} else if (y_46_im <= 6.8e-6) {
		tmp = x_46_im / y_46_re;
	} else if (y_46_im <= 1.4e+143) {
		tmp = fma(-y_46_im, x_46_re, (y_46_re * x_46_im)) / (y_46_im * y_46_im);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(-x_46_re) / y_46_im)
	tmp = 0.0
	if (y_46_im <= -7.4e+22)
		tmp = t_0;
	elseif (y_46_im <= 6.8e-6)
		tmp = Float64(x_46_im / y_46_re);
	elseif (y_46_im <= 1.4e+143)
		tmp = Float64(fma(Float64(-y_46_im), x_46_re, Float64(y_46_re * x_46_im)) / Float64(y_46_im * y_46_im));
	else
		tmp = t_0;
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[((-x$46$re) / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -7.4e+22], t$95$0, If[LessEqual[y$46$im, 6.8e-6], N[(x$46$im / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 1.4e+143], N[(N[((-y$46$im) * x$46$re + N[(y$46$re * x$46$im), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{-x.re}{y.im}\\
\mathbf{if}\;y.im \leq -7.4 \cdot 10^{+22}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;y.im \leq 1.4 \cdot 10^{+143}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-y.im, x.re, y.re \cdot x.im\right)}{y.im \cdot y.im}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.im < -7.3999999999999996e22 or 1.39999999999999999e143 < y.im

    1. Initial program 43.8%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im}} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{x.re}{y.im}\right)} \]
      2. distribute-neg-frac2N/A

        \[\leadsto \color{blue}{\frac{x.re}{\mathsf{neg}\left(y.im\right)}} \]
      3. mul-1-negN/A

        \[\leadsto \frac{x.re}{\color{blue}{-1 \cdot y.im}} \]
      4. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x.re}{-1 \cdot y.im}} \]
      5. mul-1-negN/A

        \[\leadsto \frac{x.re}{\color{blue}{\mathsf{neg}\left(y.im\right)}} \]
      6. lower-neg.f6474.3

        \[\leadsto \frac{x.re}{\color{blue}{-y.im}} \]
    5. Simplified74.3%

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

    if -7.3999999999999996e22 < y.im < 6.80000000000000012e-6

    1. Initial program 72.0%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around inf

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    4. Step-by-step derivation
      1. lower-/.f6463.3

        \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    5. Simplified63.3%

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

    if 6.80000000000000012e-6 < y.im < 1.39999999999999999e143

    1. Initial program 91.1%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around 0

      \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{{y.im}^{2}}} \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{y.im \cdot y.im}} \]
      2. lower-*.f6479.8

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

      \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{y.im \cdot y.im}} \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{y.re \cdot x.im} - x.re \cdot y.im}{y.im \cdot y.im} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{y.re \cdot x.im} - x.re \cdot y.im}{y.im \cdot y.im} \]
      3. *-commutativeN/A

        \[\leadsto \frac{y.re \cdot x.im - \color{blue}{y.im \cdot x.re}}{y.im \cdot y.im} \]
      4. cancel-sign-sub-invN/A

        \[\leadsto \frac{\color{blue}{y.re \cdot x.im + \left(\mathsf{neg}\left(y.im\right)\right) \cdot x.re}}{y.im \cdot y.im} \]
      5. lift-neg.f64N/A

        \[\leadsto \frac{y.re \cdot x.im + \color{blue}{\left(\mathsf{neg}\left(y.im\right)\right)} \cdot x.re}{y.im \cdot y.im} \]
      6. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(y.im\right)\right) \cdot x.re + y.re \cdot x.im}}{y.im \cdot y.im} \]
      7. lift-fma.f6480.0

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(-y.im, x.re, y.re \cdot x.im\right)}}{y.im \cdot y.im} \]
    7. Applied egg-rr80.0%

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(-y.im, x.re, y.re \cdot x.im\right)}}{y.im \cdot y.im} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification69.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -7.4 \cdot 10^{+22}:\\ \;\;\;\;\frac{-x.re}{y.im}\\ \mathbf{elif}\;y.im \leq 6.8 \cdot 10^{-6}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{elif}\;y.im \leq 1.4 \cdot 10^{+143}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-y.im, x.re, y.re \cdot x.im\right)}{y.im \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{-x.re}{y.im}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 64.6% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-x.re}{y.im}\\ \mathbf{if}\;y.im \leq -8 \cdot 10^{+22}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.im \leq 6.6 \cdot 10^{-6}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{elif}\;y.im \leq 5.2 \cdot 10^{+142}:\\ \;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (/ (- x.re) y.im)))
   (if (<= y.im -8e+22)
     t_0
     (if (<= y.im 6.6e-6)
       (/ x.im y.re)
       (if (<= y.im 5.2e+142)
         (/ (- (* y.re x.im) (* y.im x.re)) (* y.im y.im))
         t_0)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = -x_46_re / y_46_im;
	double tmp;
	if (y_46_im <= -8e+22) {
		tmp = t_0;
	} else if (y_46_im <= 6.6e-6) {
		tmp = x_46_im / y_46_re;
	} else if (y_46_im <= 5.2e+142) {
		tmp = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / (y_46_im * y_46_im);
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = -x_46re / y_46im
    if (y_46im <= (-8d+22)) then
        tmp = t_0
    else if (y_46im <= 6.6d-6) then
        tmp = x_46im / y_46re
    else if (y_46im <= 5.2d+142) then
        tmp = ((y_46re * x_46im) - (y_46im * x_46re)) / (y_46im * y_46im)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = -x_46_re / y_46_im;
	double tmp;
	if (y_46_im <= -8e+22) {
		tmp = t_0;
	} else if (y_46_im <= 6.6e-6) {
		tmp = x_46_im / y_46_re;
	} else if (y_46_im <= 5.2e+142) {
		tmp = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / (y_46_im * y_46_im);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = -x_46_re / y_46_im
	tmp = 0
	if y_46_im <= -8e+22:
		tmp = t_0
	elif y_46_im <= 6.6e-6:
		tmp = x_46_im / y_46_re
	elif y_46_im <= 5.2e+142:
		tmp = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / (y_46_im * y_46_im)
	else:
		tmp = t_0
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(-x_46_re) / y_46_im)
	tmp = 0.0
	if (y_46_im <= -8e+22)
		tmp = t_0;
	elseif (y_46_im <= 6.6e-6)
		tmp = Float64(x_46_im / y_46_re);
	elseif (y_46_im <= 5.2e+142)
		tmp = Float64(Float64(Float64(y_46_re * x_46_im) - Float64(y_46_im * x_46_re)) / Float64(y_46_im * y_46_im));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = -x_46_re / y_46_im;
	tmp = 0.0;
	if (y_46_im <= -8e+22)
		tmp = t_0;
	elseif (y_46_im <= 6.6e-6)
		tmp = x_46_im / y_46_re;
	elseif (y_46_im <= 5.2e+142)
		tmp = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / (y_46_im * y_46_im);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[((-x$46$re) / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -8e+22], t$95$0, If[LessEqual[y$46$im, 6.6e-6], N[(x$46$im / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 5.2e+142], N[(N[(N[(y$46$re * x$46$im), $MachinePrecision] - N[(y$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{-x.re}{y.im}\\
\mathbf{if}\;y.im \leq -8 \cdot 10^{+22}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;y.im \leq 5.2 \cdot 10^{+142}:\\
\;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.im < -8e22 or 5.20000000000000043e142 < y.im

    1. Initial program 43.8%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im}} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{x.re}{y.im}\right)} \]
      2. distribute-neg-frac2N/A

        \[\leadsto \color{blue}{\frac{x.re}{\mathsf{neg}\left(y.im\right)}} \]
      3. mul-1-negN/A

        \[\leadsto \frac{x.re}{\color{blue}{-1 \cdot y.im}} \]
      4. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x.re}{-1 \cdot y.im}} \]
      5. mul-1-negN/A

        \[\leadsto \frac{x.re}{\color{blue}{\mathsf{neg}\left(y.im\right)}} \]
      6. lower-neg.f6474.3

        \[\leadsto \frac{x.re}{\color{blue}{-y.im}} \]
    5. Simplified74.3%

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

    if -8e22 < y.im < 6.60000000000000034e-6

    1. Initial program 72.0%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around inf

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    4. Step-by-step derivation
      1. lower-/.f6463.3

        \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    5. Simplified63.3%

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

    if 6.60000000000000034e-6 < y.im < 5.20000000000000043e142

    1. Initial program 91.1%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around 0

      \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{{y.im}^{2}}} \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{y.im \cdot y.im}} \]
      2. lower-*.f6479.8

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

      \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{y.im \cdot y.im}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification69.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -8 \cdot 10^{+22}:\\ \;\;\;\;\frac{-x.re}{y.im}\\ \mathbf{elif}\;y.im \leq 6.6 \cdot 10^{-6}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{elif}\;y.im \leq 5.2 \cdot 10^{+142}:\\ \;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.im \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{-x.re}{y.im}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 78.5% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\ \mathbf{if}\;y.im \leq -2.05 \cdot 10^{-25}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.im \leq 0.00095:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.re, -\frac{y.im}{y.re}, x.im\right)}{y.re}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (/ (fma y.re (/ x.im y.im) (- x.re)) y.im)))
   (if (<= y.im -2.05e-25)
     t_0
     (if (<= y.im 0.00095) (/ (fma x.re (- (/ y.im y.re)) x.im) y.re) t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = fma(y_46_re, (x_46_im / y_46_im), -x_46_re) / y_46_im;
	double tmp;
	if (y_46_im <= -2.05e-25) {
		tmp = t_0;
	} else if (y_46_im <= 0.00095) {
		tmp = fma(x_46_re, -(y_46_im / y_46_re), x_46_im) / y_46_re;
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(fma(y_46_re, Float64(x_46_im / y_46_im), Float64(-x_46_re)) / y_46_im)
	tmp = 0.0
	if (y_46_im <= -2.05e-25)
		tmp = t_0;
	elseif (y_46_im <= 0.00095)
		tmp = Float64(fma(x_46_re, Float64(-Float64(y_46_im / y_46_re)), x_46_im) / y_46_re);
	else
		tmp = t_0;
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(y$46$re * N[(x$46$im / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -2.05e-25], t$95$0, If[LessEqual[y$46$im, 0.00095], N[(N[(x$46$re * (-N[(y$46$im / y$46$re), $MachinePrecision]) + x$46$im), $MachinePrecision] / y$46$re), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\
\mathbf{if}\;y.im \leq -2.05 \cdot 10^{-25}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y.im \leq 0.00095:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.re, -\frac{y.im}{y.re}, x.im\right)}{y.re}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < -2.04999999999999994e-25 or 9.49999999999999998e-4 < y.im

    1. Initial program 58.5%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im} + \frac{x.im \cdot y.re}{{y.im}^{2}}} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{{y.im}^{2}} + -1 \cdot \frac{x.re}{y.im}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{x.im \cdot y.re}{{y.im}^{2}} + \color{blue}{\left(\mathsf{neg}\left(\frac{x.re}{y.im}\right)\right)} \]
      3. unsub-negN/A

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{{y.im}^{2}} - \frac{x.re}{y.im}} \]
      4. unpow2N/A

        \[\leadsto \frac{x.im \cdot y.re}{\color{blue}{y.im \cdot y.im}} - \frac{x.re}{y.im} \]
      5. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im}}{y.im}} - \frac{x.re}{y.im} \]
      6. div-subN/A

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}} \]
      7. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}} \]
      8. sub-negN/A

        \[\leadsto \frac{\color{blue}{\frac{x.im \cdot y.re}{y.im} + \left(\mathsf{neg}\left(x.re\right)\right)}}{y.im} \]
      9. *-commutativeN/A

        \[\leadsto \frac{\frac{\color{blue}{y.re \cdot x.im}}{y.im} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      10. associate-/l*N/A

        \[\leadsto \frac{\color{blue}{y.re \cdot \frac{x.im}{y.im}} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      11. mul-1-negN/A

        \[\leadsto \frac{y.re \cdot \frac{x.im}{y.im} + \color{blue}{-1 \cdot x.re}}{y.im} \]
      12. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -1 \cdot x.re\right)}}{y.im} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(y.re, \color{blue}{\frac{x.im}{y.im}}, -1 \cdot x.re\right)}{y.im} \]
      14. mul-1-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, \color{blue}{\mathsf{neg}\left(x.re\right)}\right)}{y.im} \]
      15. lower-neg.f6481.3

        \[\leadsto \frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, \color{blue}{-x.re}\right)}{y.im} \]
    5. Simplified81.3%

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

    if -2.04999999999999994e-25 < y.im < 9.49999999999999998e-4

    1. Initial program 71.7%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{x.im \cdot y.re} - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{x.im \cdot y.re - \color{blue}{x.re \cdot y.im}}{y.re \cdot y.re + y.im \cdot y.im} \]
      3. sub-negN/A

        \[\leadsto \frac{\color{blue}{x.im \cdot y.re + \left(\mathsf{neg}\left(x.re \cdot y.im\right)\right)}}{y.re \cdot y.re + y.im \cdot y.im} \]
      4. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(x.re \cdot y.im\right)\right) + x.im \cdot y.re}}{y.re \cdot y.re + y.im \cdot y.im} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{x.re \cdot y.im}\right)\right) + x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{y.im \cdot x.re}\right)\right) + x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} \]
      7. distribute-lft-neg-inN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(y.im\right)\right) \cdot x.re} + x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} \]
      8. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(y.im\right), x.re, x.im \cdot y.re\right)}}{y.re \cdot y.re + y.im \cdot y.im} \]
      9. lower-neg.f6471.7

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{-y.im}, x.re, x.im \cdot y.re\right)}{y.re \cdot y.re + y.im \cdot y.im} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(y.im\right), x.re, \color{blue}{x.im \cdot y.re}\right)}{y.re \cdot y.re + y.im \cdot y.im} \]
      11. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(y.im\right), x.re, \color{blue}{y.re \cdot x.im}\right)}{y.re \cdot y.re + y.im \cdot y.im} \]
      12. lower-*.f6471.7

        \[\leadsto \frac{\mathsf{fma}\left(-y.im, x.re, \color{blue}{y.re \cdot x.im}\right)}{y.re \cdot y.re + y.im \cdot y.im} \]
    4. Applied egg-rr71.7%

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

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(y.im\right), x.re, y.re \cdot x.im\right)}{\color{blue}{{y.re}^{2}}} \]
    6. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(y.im\right), x.re, y.re \cdot x.im\right)}{\color{blue}{y.re \cdot y.re}} \]
      2. lower-*.f6460.9

        \[\leadsto \frac{\mathsf{fma}\left(-y.im, x.re, y.re \cdot x.im\right)}{\color{blue}{y.re \cdot y.re}} \]
    7. Simplified60.9%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re \cdot y.im}{{y.re}^{2}} + \frac{x.im}{y.re}} \]
    9. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{x.re \cdot y.im}{{y.re}^{2}}\right)\right)} + \frac{x.im}{y.re} \]
      2. neg-sub0N/A

        \[\leadsto \color{blue}{\left(0 - \frac{x.re \cdot y.im}{{y.re}^{2}}\right)} + \frac{x.im}{y.re} \]
      3. associate-+l-N/A

        \[\leadsto \color{blue}{0 - \left(\frac{x.re \cdot y.im}{{y.re}^{2}} - \frac{x.im}{y.re}\right)} \]
      4. unpow2N/A

        \[\leadsto 0 - \left(\frac{x.re \cdot y.im}{\color{blue}{y.re \cdot y.re}} - \frac{x.im}{y.re}\right) \]
      5. associate-/r*N/A

        \[\leadsto 0 - \left(\color{blue}{\frac{\frac{x.re \cdot y.im}{y.re}}{y.re}} - \frac{x.im}{y.re}\right) \]
      6. div-subN/A

        \[\leadsto 0 - \color{blue}{\frac{\frac{x.re \cdot y.im}{y.re} - x.im}{y.re}} \]
      7. unsub-negN/A

        \[\leadsto 0 - \frac{\color{blue}{\frac{x.re \cdot y.im}{y.re} + \left(\mathsf{neg}\left(x.im\right)\right)}}{y.re} \]
      8. mul-1-negN/A

        \[\leadsto 0 - \frac{\frac{x.re \cdot y.im}{y.re} + \color{blue}{-1 \cdot x.im}}{y.re} \]
      9. +-commutativeN/A

        \[\leadsto 0 - \frac{\color{blue}{-1 \cdot x.im + \frac{x.re \cdot y.im}{y.re}}}{y.re} \]
      10. neg-sub0N/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{-1 \cdot x.im + \frac{x.re \cdot y.im}{y.re}}{y.re}\right)} \]
      11. mul-1-negN/A

        \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot x.im + \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
      12. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(-1 \cdot x.im + \frac{x.re \cdot y.im}{y.re}\right)}{y.re}} \]
      13. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(-1 \cdot x.im + \frac{x.re \cdot y.im}{y.re}\right)}{y.re}} \]
    10. Simplified86.0%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x.re, \frac{y.im}{-y.re}, x.im\right)}{y.re}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification83.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -2.05 \cdot 10^{-25}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\ \mathbf{elif}\;y.im \leq 0.00095:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.re, -\frac{y.im}{y.re}, x.im\right)}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 78.1% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(x.im, \frac{y.re}{y.im}, -x.re\right)}{y.im}\\ \mathbf{if}\;y.im \leq -3 \cdot 10^{-17}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.im \leq 0.00047:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.re, -\frac{y.im}{y.re}, x.im\right)}{y.re}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (/ (fma x.im (/ y.re y.im) (- x.re)) y.im)))
   (if (<= y.im -3e-17)
     t_0
     (if (<= y.im 0.00047) (/ (fma x.re (- (/ y.im y.re)) x.im) y.re) t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = fma(x_46_im, (y_46_re / y_46_im), -x_46_re) / y_46_im;
	double tmp;
	if (y_46_im <= -3e-17) {
		tmp = t_0;
	} else if (y_46_im <= 0.00047) {
		tmp = fma(x_46_re, -(y_46_im / y_46_re), x_46_im) / y_46_re;
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(fma(x_46_im, Float64(y_46_re / y_46_im), Float64(-x_46_re)) / y_46_im)
	tmp = 0.0
	if (y_46_im <= -3e-17)
		tmp = t_0;
	elseif (y_46_im <= 0.00047)
		tmp = Float64(fma(x_46_re, Float64(-Float64(y_46_im / y_46_re)), x_46_im) / y_46_re);
	else
		tmp = t_0;
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(x$46$im * N[(y$46$re / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -3e-17], t$95$0, If[LessEqual[y$46$im, 0.00047], N[(N[(x$46$re * (-N[(y$46$im / y$46$re), $MachinePrecision]) + x$46$im), $MachinePrecision] / y$46$re), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(x.im, \frac{y.re}{y.im}, -x.re\right)}{y.im}\\
\mathbf{if}\;y.im \leq -3 \cdot 10^{-17}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y.im \leq 0.00047:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.re, -\frac{y.im}{y.re}, x.im\right)}{y.re}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < -3.00000000000000006e-17 or 4.69999999999999986e-4 < y.im

    1. Initial program 58.5%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im} + \frac{x.im \cdot y.re}{{y.im}^{2}}} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{{y.im}^{2}} + -1 \cdot \frac{x.re}{y.im}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{x.im \cdot y.re}{{y.im}^{2}} + \color{blue}{\left(\mathsf{neg}\left(\frac{x.re}{y.im}\right)\right)} \]
      3. unsub-negN/A

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{{y.im}^{2}} - \frac{x.re}{y.im}} \]
      4. unpow2N/A

        \[\leadsto \frac{x.im \cdot y.re}{\color{blue}{y.im \cdot y.im}} - \frac{x.re}{y.im} \]
      5. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im}}{y.im}} - \frac{x.re}{y.im} \]
      6. div-subN/A

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}} \]
      7. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}} \]
      8. sub-negN/A

        \[\leadsto \frac{\color{blue}{\frac{x.im \cdot y.re}{y.im} + \left(\mathsf{neg}\left(x.re\right)\right)}}{y.im} \]
      9. *-commutativeN/A

        \[\leadsto \frac{\frac{\color{blue}{y.re \cdot x.im}}{y.im} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      10. associate-/l*N/A

        \[\leadsto \frac{\color{blue}{y.re \cdot \frac{x.im}{y.im}} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      11. mul-1-negN/A

        \[\leadsto \frac{y.re \cdot \frac{x.im}{y.im} + \color{blue}{-1 \cdot x.re}}{y.im} \]
      12. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -1 \cdot x.re\right)}}{y.im} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(y.re, \color{blue}{\frac{x.im}{y.im}}, -1 \cdot x.re\right)}{y.im} \]
      14. mul-1-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, \color{blue}{\mathsf{neg}\left(x.re\right)}\right)}{y.im} \]
      15. lower-neg.f6481.3

        \[\leadsto \frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, \color{blue}{-x.re}\right)}{y.im} \]
    5. Simplified81.3%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}} \]
    6. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{\color{blue}{\frac{y.re \cdot x.im}{y.im}} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      2. *-commutativeN/A

        \[\leadsto \frac{\frac{\color{blue}{x.im \cdot y.re}}{y.im} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      3. associate-/l*N/A

        \[\leadsto \frac{\color{blue}{x.im \cdot \frac{y.re}{y.im}} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      4. lift-neg.f64N/A

        \[\leadsto \frac{x.im \cdot \frac{y.re}{y.im} + \color{blue}{\left(\mathsf{neg}\left(x.re\right)\right)}}{y.im} \]
      5. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x.im, \frac{y.re}{y.im}, \mathsf{neg}\left(x.re\right)\right)}}{y.im} \]
      6. lower-/.f6480.6

        \[\leadsto \frac{\mathsf{fma}\left(x.im, \color{blue}{\frac{y.re}{y.im}}, -x.re\right)}{y.im} \]
    7. Applied egg-rr80.6%

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

    if -3.00000000000000006e-17 < y.im < 4.69999999999999986e-4

    1. Initial program 71.7%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{x.im \cdot y.re} - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{x.im \cdot y.re - \color{blue}{x.re \cdot y.im}}{y.re \cdot y.re + y.im \cdot y.im} \]
      3. sub-negN/A

        \[\leadsto \frac{\color{blue}{x.im \cdot y.re + \left(\mathsf{neg}\left(x.re \cdot y.im\right)\right)}}{y.re \cdot y.re + y.im \cdot y.im} \]
      4. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(x.re \cdot y.im\right)\right) + x.im \cdot y.re}}{y.re \cdot y.re + y.im \cdot y.im} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{x.re \cdot y.im}\right)\right) + x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{y.im \cdot x.re}\right)\right) + x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} \]
      7. distribute-lft-neg-inN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(y.im\right)\right) \cdot x.re} + x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} \]
      8. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(y.im\right), x.re, x.im \cdot y.re\right)}}{y.re \cdot y.re + y.im \cdot y.im} \]
      9. lower-neg.f6471.7

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{-y.im}, x.re, x.im \cdot y.re\right)}{y.re \cdot y.re + y.im \cdot y.im} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(y.im\right), x.re, \color{blue}{x.im \cdot y.re}\right)}{y.re \cdot y.re + y.im \cdot y.im} \]
      11. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(y.im\right), x.re, \color{blue}{y.re \cdot x.im}\right)}{y.re \cdot y.re + y.im \cdot y.im} \]
      12. lower-*.f6471.7

        \[\leadsto \frac{\mathsf{fma}\left(-y.im, x.re, \color{blue}{y.re \cdot x.im}\right)}{y.re \cdot y.re + y.im \cdot y.im} \]
    4. Applied egg-rr71.7%

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

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(y.im\right), x.re, y.re \cdot x.im\right)}{\color{blue}{{y.re}^{2}}} \]
    6. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(y.im\right), x.re, y.re \cdot x.im\right)}{\color{blue}{y.re \cdot y.re}} \]
      2. lower-*.f6460.9

        \[\leadsto \frac{\mathsf{fma}\left(-y.im, x.re, y.re \cdot x.im\right)}{\color{blue}{y.re \cdot y.re}} \]
    7. Simplified60.9%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re \cdot y.im}{{y.re}^{2}} + \frac{x.im}{y.re}} \]
    9. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{x.re \cdot y.im}{{y.re}^{2}}\right)\right)} + \frac{x.im}{y.re} \]
      2. neg-sub0N/A

        \[\leadsto \color{blue}{\left(0 - \frac{x.re \cdot y.im}{{y.re}^{2}}\right)} + \frac{x.im}{y.re} \]
      3. associate-+l-N/A

        \[\leadsto \color{blue}{0 - \left(\frac{x.re \cdot y.im}{{y.re}^{2}} - \frac{x.im}{y.re}\right)} \]
      4. unpow2N/A

        \[\leadsto 0 - \left(\frac{x.re \cdot y.im}{\color{blue}{y.re \cdot y.re}} - \frac{x.im}{y.re}\right) \]
      5. associate-/r*N/A

        \[\leadsto 0 - \left(\color{blue}{\frac{\frac{x.re \cdot y.im}{y.re}}{y.re}} - \frac{x.im}{y.re}\right) \]
      6. div-subN/A

        \[\leadsto 0 - \color{blue}{\frac{\frac{x.re \cdot y.im}{y.re} - x.im}{y.re}} \]
      7. unsub-negN/A

        \[\leadsto 0 - \frac{\color{blue}{\frac{x.re \cdot y.im}{y.re} + \left(\mathsf{neg}\left(x.im\right)\right)}}{y.re} \]
      8. mul-1-negN/A

        \[\leadsto 0 - \frac{\frac{x.re \cdot y.im}{y.re} + \color{blue}{-1 \cdot x.im}}{y.re} \]
      9. +-commutativeN/A

        \[\leadsto 0 - \frac{\color{blue}{-1 \cdot x.im + \frac{x.re \cdot y.im}{y.re}}}{y.re} \]
      10. neg-sub0N/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{-1 \cdot x.im + \frac{x.re \cdot y.im}{y.re}}{y.re}\right)} \]
      11. mul-1-negN/A

        \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot x.im + \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
      12. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(-1 \cdot x.im + \frac{x.re \cdot y.im}{y.re}\right)}{y.re}} \]
      13. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(-1 \cdot x.im + \frac{x.re \cdot y.im}{y.re}\right)}{y.re}} \]
    10. Simplified86.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -3 \cdot 10^{-17}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.re}{y.im}, -x.re\right)}{y.im}\\ \mathbf{elif}\;y.im \leq 0.00047:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.re, -\frac{y.im}{y.re}, x.im\right)}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.re}{y.im}, -x.re\right)}{y.im}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 78.0% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(x.im, \frac{y.re}{y.im}, -x.re\right)}{y.im}\\ \mathbf{if}\;y.im \leq -1.2 \cdot 10^{-24}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.im \leq 0.000205:\\ \;\;\;\;\frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (/ (fma x.im (/ y.re y.im) (- x.re)) y.im)))
   (if (<= y.im -1.2e-24)
     t_0
     (if (<= y.im 0.000205) (/ (- x.im (/ (* y.im x.re) y.re)) y.re) t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = fma(x_46_im, (y_46_re / y_46_im), -x_46_re) / y_46_im;
	double tmp;
	if (y_46_im <= -1.2e-24) {
		tmp = t_0;
	} else if (y_46_im <= 0.000205) {
		tmp = (x_46_im - ((y_46_im * x_46_re) / y_46_re)) / y_46_re;
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(fma(x_46_im, Float64(y_46_re / y_46_im), Float64(-x_46_re)) / y_46_im)
	tmp = 0.0
	if (y_46_im <= -1.2e-24)
		tmp = t_0;
	elseif (y_46_im <= 0.000205)
		tmp = Float64(Float64(x_46_im - Float64(Float64(y_46_im * x_46_re) / y_46_re)) / y_46_re);
	else
		tmp = t_0;
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(x$46$im * N[(y$46$re / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -1.2e-24], t$95$0, If[LessEqual[y$46$im, 0.000205], N[(N[(x$46$im - N[(N[(y$46$im * x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(x.im, \frac{y.re}{y.im}, -x.re\right)}{y.im}\\
\mathbf{if}\;y.im \leq -1.2 \cdot 10^{-24}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y.im \leq 0.000205:\\
\;\;\;\;\frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < -1.1999999999999999e-24 or 2.05e-4 < y.im

    1. Initial program 58.5%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im} + \frac{x.im \cdot y.re}{{y.im}^{2}}} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{{y.im}^{2}} + -1 \cdot \frac{x.re}{y.im}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{x.im \cdot y.re}{{y.im}^{2}} + \color{blue}{\left(\mathsf{neg}\left(\frac{x.re}{y.im}\right)\right)} \]
      3. unsub-negN/A

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{{y.im}^{2}} - \frac{x.re}{y.im}} \]
      4. unpow2N/A

        \[\leadsto \frac{x.im \cdot y.re}{\color{blue}{y.im \cdot y.im}} - \frac{x.re}{y.im} \]
      5. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im}}{y.im}} - \frac{x.re}{y.im} \]
      6. div-subN/A

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}} \]
      7. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}} \]
      8. sub-negN/A

        \[\leadsto \frac{\color{blue}{\frac{x.im \cdot y.re}{y.im} + \left(\mathsf{neg}\left(x.re\right)\right)}}{y.im} \]
      9. *-commutativeN/A

        \[\leadsto \frac{\frac{\color{blue}{y.re \cdot x.im}}{y.im} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      10. associate-/l*N/A

        \[\leadsto \frac{\color{blue}{y.re \cdot \frac{x.im}{y.im}} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      11. mul-1-negN/A

        \[\leadsto \frac{y.re \cdot \frac{x.im}{y.im} + \color{blue}{-1 \cdot x.re}}{y.im} \]
      12. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -1 \cdot x.re\right)}}{y.im} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(y.re, \color{blue}{\frac{x.im}{y.im}}, -1 \cdot x.re\right)}{y.im} \]
      14. mul-1-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, \color{blue}{\mathsf{neg}\left(x.re\right)}\right)}{y.im} \]
      15. lower-neg.f6481.3

        \[\leadsto \frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, \color{blue}{-x.re}\right)}{y.im} \]
    5. Simplified81.3%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}} \]
    6. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{\color{blue}{\frac{y.re \cdot x.im}{y.im}} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      2. *-commutativeN/A

        \[\leadsto \frac{\frac{\color{blue}{x.im \cdot y.re}}{y.im} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      3. associate-/l*N/A

        \[\leadsto \frac{\color{blue}{x.im \cdot \frac{y.re}{y.im}} + \left(\mathsf{neg}\left(x.re\right)\right)}{y.im} \]
      4. lift-neg.f64N/A

        \[\leadsto \frac{x.im \cdot \frac{y.re}{y.im} + \color{blue}{\left(\mathsf{neg}\left(x.re\right)\right)}}{y.im} \]
      5. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x.im, \frac{y.re}{y.im}, \mathsf{neg}\left(x.re\right)\right)}}{y.im} \]
      6. lower-/.f6480.6

        \[\leadsto \frac{\mathsf{fma}\left(x.im, \color{blue}{\frac{y.re}{y.im}}, -x.re\right)}{y.im} \]
    7. Applied egg-rr80.6%

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

    if -1.1999999999999999e-24 < y.im < 2.05e-4

    1. Initial program 71.7%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around inf

      \[\leadsto \color{blue}{\frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{x.im + \color{blue}{\left(\mathsf{neg}\left(\frac{x.re \cdot y.im}{y.re}\right)\right)}}{y.re} \]
      3. unsub-negN/A

        \[\leadsto \frac{\color{blue}{x.im - \frac{x.re \cdot y.im}{y.re}}}{y.re} \]
      4. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{x.im - \frac{x.re \cdot y.im}{y.re}}}{y.re} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{x.im - \color{blue}{\frac{x.re \cdot y.im}{y.re}}}{y.re} \]
      6. *-commutativeN/A

        \[\leadsto \frac{x.im - \frac{\color{blue}{y.im \cdot x.re}}{y.re}}{y.re} \]
      7. lower-*.f6485.2

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

      \[\leadsto \color{blue}{\frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 63.8% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-x.re}{y.im}\\ \mathbf{if}\;y.im \leq -3.5 \cdot 10^{+24}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.im \leq 2.6 \cdot 10^{-5}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (/ (- x.re) y.im)))
   (if (<= y.im -3.5e+24) t_0 (if (<= y.im 2.6e-5) (/ x.im y.re) t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = -x_46_re / y_46_im;
	double tmp;
	if (y_46_im <= -3.5e+24) {
		tmp = t_0;
	} else if (y_46_im <= 2.6e-5) {
		tmp = x_46_im / y_46_re;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = -x_46re / y_46im
    if (y_46im <= (-3.5d+24)) then
        tmp = t_0
    else if (y_46im <= 2.6d-5) then
        tmp = x_46im / y_46re
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = -x_46_re / y_46_im;
	double tmp;
	if (y_46_im <= -3.5e+24) {
		tmp = t_0;
	} else if (y_46_im <= 2.6e-5) {
		tmp = x_46_im / y_46_re;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = -x_46_re / y_46_im
	tmp = 0
	if y_46_im <= -3.5e+24:
		tmp = t_0
	elif y_46_im <= 2.6e-5:
		tmp = x_46_im / y_46_re
	else:
		tmp = t_0
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(-x_46_re) / y_46_im)
	tmp = 0.0
	if (y_46_im <= -3.5e+24)
		tmp = t_0;
	elseif (y_46_im <= 2.6e-5)
		tmp = Float64(x_46_im / y_46_re);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = -x_46_re / y_46_im;
	tmp = 0.0;
	if (y_46_im <= -3.5e+24)
		tmp = t_0;
	elseif (y_46_im <= 2.6e-5)
		tmp = x_46_im / y_46_re;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[((-x$46$re) / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -3.5e+24], t$95$0, If[LessEqual[y$46$im, 2.6e-5], N[(x$46$im / y$46$re), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{-x.re}{y.im}\\
\mathbf{if}\;y.im \leq -3.5 \cdot 10^{+24}:\\
\;\;\;\;t\_0\\

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < -3.5000000000000002e24 or 2.59999999999999984e-5 < y.im

    1. Initial program 56.9%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im}} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{x.re}{y.im}\right)} \]
      2. distribute-neg-frac2N/A

        \[\leadsto \color{blue}{\frac{x.re}{\mathsf{neg}\left(y.im\right)}} \]
      3. mul-1-negN/A

        \[\leadsto \frac{x.re}{\color{blue}{-1 \cdot y.im}} \]
      4. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x.re}{-1 \cdot y.im}} \]
      5. mul-1-negN/A

        \[\leadsto \frac{x.re}{\color{blue}{\mathsf{neg}\left(y.im\right)}} \]
      6. lower-neg.f6472.2

        \[\leadsto \frac{x.re}{\color{blue}{-y.im}} \]
    5. Simplified72.2%

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

    if -3.5000000000000002e24 < y.im < 2.59999999999999984e-5

    1. Initial program 72.0%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Taylor expanded in y.re around inf

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    4. Step-by-step derivation
      1. lower-/.f6463.3

        \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    5. Simplified63.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -3.5 \cdot 10^{+24}:\\ \;\;\;\;\frac{-x.re}{y.im}\\ \mathbf{elif}\;y.im \leq 2.6 \cdot 10^{-5}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{-x.re}{y.im}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 42.0% accurate, 3.2× speedup?

\[\begin{array}{l} \\ \frac{x.im}{y.re} \end{array} \]
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ 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;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    code = x_46im / y_46re
end function
public static 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;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	return x_46_im / y_46_re
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	return Float64(x_46_im / y_46_re)
end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = x_46_im / y_46_re;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(x$46$im / y$46$re), $MachinePrecision]
\begin{array}{l}

\\
\frac{x.im}{y.re}
\end{array}
Derivation
  1. Initial program 64.7%

    \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
  2. Add Preprocessing
  3. Taylor expanded in y.re around inf

    \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
  4. Step-by-step derivation
    1. lower-/.f6440.0

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
  5. Simplified40.0%

    \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
  6. Add Preprocessing

Reproduce

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