_divideComplex, real part

Percentage Accurate: 61.2% → 77.8%
Time: 11.2s
Alternatives: 9
Speedup: 1.2×

Specification

?
\[\begin{array}{l} \\ \frac{x.re \cdot y.re + x.im \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.re y.re) (* x.im 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_re * y_46_re) + (x_46_im * 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_46re * y_46re) + (x_46im * 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_re * y_46_re) + (x_46_im * 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_re * y_46_re) + (x_46_im * 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_re * y_46_re) + Float64(x_46_im * 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_re * y_46_re) + (x_46_im * 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$re * y$46$re), $MachinePrecision] + N[(x$46$im * 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.re \cdot y.re + x.im \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 9 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: 61.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x.re \cdot y.re + x.im \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.re y.re) (* x.im 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_re * y_46_re) + (x_46_im * 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_46re * y_46re) + (x_46im * 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_re * y_46_re) + (x_46_im * 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_re * y_46_re) + (x_46_im * 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_re * y_46_re) + Float64(x_46_im * 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_re * y_46_re) + (x_46_im * 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$re * y$46$re), $MachinePrecision] + N[(x$46$im * 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.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\end{array}

Alternative 1: 77.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x.im + \frac{y.re \cdot x.re}{y.im}}{y.im}\\ t_1 := \frac{y.re \cdot x.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{if}\;y.re \leq -3.6 \cdot 10^{+131}:\\ \;\;\;\;\left(x.im \cdot \left(\frac{x.re}{x.im} + \frac{y.im}{y.re}\right)\right) \cdot \frac{1}{y.re}\\ \mathbf{elif}\;y.re \leq -9 \cdot 10^{+80}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.re \leq -1.75 \cdot 10^{-65}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y.re \leq 1.8 \cdot 10^{-80}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.re \leq 2.15 \cdot 10^{+151}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y.re} \cdot \left(y.im \cdot \left(\frac{x.im}{y.re} + \frac{x.re}{y.im}\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (/ (+ x.im (/ (* y.re x.re) y.im)) y.im))
        (t_1
         (/ (+ (* y.re x.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im)))))
   (if (<= y.re -3.6e+131)
     (* (* x.im (+ (/ x.re x.im) (/ y.im y.re))) (/ 1.0 y.re))
     (if (<= y.re -9e+80)
       t_0
       (if (<= y.re -1.75e-65)
         t_1
         (if (<= y.re 1.8e-80)
           t_0
           (if (<= y.re 2.15e+151)
             t_1
             (* (/ 1.0 y.re) (* y.im (+ (/ x.im y.re) (/ 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 = (x_46_im + ((y_46_re * x_46_re) / y_46_im)) / y_46_im;
	double t_1 = ((y_46_re * x_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	double tmp;
	if (y_46_re <= -3.6e+131) {
		tmp = (x_46_im * ((x_46_re / x_46_im) + (y_46_im / y_46_re))) * (1.0 / y_46_re);
	} else if (y_46_re <= -9e+80) {
		tmp = t_0;
	} else if (y_46_re <= -1.75e-65) {
		tmp = t_1;
	} else if (y_46_re <= 1.8e-80) {
		tmp = t_0;
	} else if (y_46_re <= 2.15e+151) {
		tmp = t_1;
	} else {
		tmp = (1.0 / y_46_re) * (y_46_im * ((x_46_im / y_46_re) + (x_46_re / y_46_im)));
	}
	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) :: t_1
    real(8) :: tmp
    t_0 = (x_46im + ((y_46re * x_46re) / y_46im)) / y_46im
    t_1 = ((y_46re * x_46re) + (x_46im * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
    if (y_46re <= (-3.6d+131)) then
        tmp = (x_46im * ((x_46re / x_46im) + (y_46im / y_46re))) * (1.0d0 / y_46re)
    else if (y_46re <= (-9d+80)) then
        tmp = t_0
    else if (y_46re <= (-1.75d-65)) then
        tmp = t_1
    else if (y_46re <= 1.8d-80) then
        tmp = t_0
    else if (y_46re <= 2.15d+151) then
        tmp = t_1
    else
        tmp = (1.0d0 / y_46re) * (y_46im * ((x_46im / y_46re) + (x_46re / y_46im)))
    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_im + ((y_46_re * x_46_re) / y_46_im)) / y_46_im;
	double t_1 = ((y_46_re * x_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	double tmp;
	if (y_46_re <= -3.6e+131) {
		tmp = (x_46_im * ((x_46_re / x_46_im) + (y_46_im / y_46_re))) * (1.0 / y_46_re);
	} else if (y_46_re <= -9e+80) {
		tmp = t_0;
	} else if (y_46_re <= -1.75e-65) {
		tmp = t_1;
	} else if (y_46_re <= 1.8e-80) {
		tmp = t_0;
	} else if (y_46_re <= 2.15e+151) {
		tmp = t_1;
	} else {
		tmp = (1.0 / y_46_re) * (y_46_im * ((x_46_im / y_46_re) + (x_46_re / y_46_im)));
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = (x_46_im + ((y_46_re * x_46_re) / y_46_im)) / y_46_im
	t_1 = ((y_46_re * x_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
	tmp = 0
	if y_46_re <= -3.6e+131:
		tmp = (x_46_im * ((x_46_re / x_46_im) + (y_46_im / y_46_re))) * (1.0 / y_46_re)
	elif y_46_re <= -9e+80:
		tmp = t_0
	elif y_46_re <= -1.75e-65:
		tmp = t_1
	elif y_46_re <= 1.8e-80:
		tmp = t_0
	elif y_46_re <= 2.15e+151:
		tmp = t_1
	else:
		tmp = (1.0 / y_46_re) * (y_46_im * ((x_46_im / y_46_re) + (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(Float64(x_46_im + Float64(Float64(y_46_re * x_46_re) / y_46_im)) / y_46_im)
	t_1 = Float64(Float64(Float64(y_46_re * x_46_re) + Float64(x_46_im * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)))
	tmp = 0.0
	if (y_46_re <= -3.6e+131)
		tmp = Float64(Float64(x_46_im * Float64(Float64(x_46_re / x_46_im) + Float64(y_46_im / y_46_re))) * Float64(1.0 / y_46_re));
	elseif (y_46_re <= -9e+80)
		tmp = t_0;
	elseif (y_46_re <= -1.75e-65)
		tmp = t_1;
	elseif (y_46_re <= 1.8e-80)
		tmp = t_0;
	elseif (y_46_re <= 2.15e+151)
		tmp = t_1;
	else
		tmp = Float64(Float64(1.0 / y_46_re) * Float64(y_46_im * Float64(Float64(x_46_im / y_46_re) + Float64(x_46_re / y_46_im))));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = (x_46_im + ((y_46_re * x_46_re) / y_46_im)) / y_46_im;
	t_1 = ((y_46_re * x_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	tmp = 0.0;
	if (y_46_re <= -3.6e+131)
		tmp = (x_46_im * ((x_46_re / x_46_im) + (y_46_im / y_46_re))) * (1.0 / y_46_re);
	elseif (y_46_re <= -9e+80)
		tmp = t_0;
	elseif (y_46_re <= -1.75e-65)
		tmp = t_1;
	elseif (y_46_re <= 1.8e-80)
		tmp = t_0;
	elseif (y_46_re <= 2.15e+151)
		tmp = t_1;
	else
		tmp = (1.0 / y_46_re) * (y_46_im * ((x_46_im / y_46_re) + (x_46_re / y_46_im)));
	end
	tmp_2 = 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[(N[(y$46$re * x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(y$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $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$re, -3.6e+131], N[(N[(x$46$im * N[(N[(x$46$re / x$46$im), $MachinePrecision] + N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / y$46$re), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, -9e+80], t$95$0, If[LessEqual[y$46$re, -1.75e-65], t$95$1, If[LessEqual[y$46$re, 1.8e-80], t$95$0, If[LessEqual[y$46$re, 2.15e+151], t$95$1, N[(N[(1.0 / y$46$re), $MachinePrecision] * N[(y$46$im * N[(N[(x$46$im / y$46$re), $MachinePrecision] + N[(x$46$re / y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x.im + \frac{y.re \cdot x.re}{y.im}}{y.im}\\
t_1 := \frac{y.re \cdot x.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\
\mathbf{if}\;y.re \leq -3.6 \cdot 10^{+131}:\\
\;\;\;\;\left(x.im \cdot \left(\frac{x.re}{x.im} + \frac{y.im}{y.re}\right)\right) \cdot \frac{1}{y.re}\\

\mathbf{elif}\;y.re \leq -9 \cdot 10^{+80}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y.re \leq -1.75 \cdot 10^{-65}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y.re \leq 1.8 \cdot 10^{-80}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y.re \leq 2.15 \cdot 10^{+151}:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{y.re} \cdot \left(y.im \cdot \left(\frac{x.im}{y.re} + \frac{x.re}{y.im}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y.re < -3.60000000000000031e131

    1. Initial program 29.3%

      \[\frac{x.re \cdot y.re + x.im \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 \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, y.im\right)\right), \color{blue}{\left({y.re}^{2}\right)}\right) \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, y.im\right)\right), \left(y.re \cdot \color{blue}{y.re}\right)\right) \]
      2. *-lowering-*.f6429.3%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, y.im\right)\right), \mathsf{*.f64}\left(y.re, \color{blue}{y.re}\right)\right) \]
    5. Simplified29.3%

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re}\right), \color{blue}{\left(\frac{1}{y.re}\right)}\right) \]
      4. /-lowering-/.f64N/A

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(x.im \cdot y.im + y.re \cdot x.re\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(x.im \cdot y.im\right), \left(y.re \cdot x.re\right)\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      8. *-lowering-*.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), \left(x.re \cdot y.re\right)\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), \mathsf{*.f64}\left(x.re, y.re\right)\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      11. /-lowering-/.f6440.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), \mathsf{*.f64}\left(x.re, y.re\right)\right), y.re\right), \mathsf{/.f64}\left(1, \color{blue}{y.re}\right)\right) \]
    7. Applied egg-rr40.4%

      \[\leadsto \color{blue}{\frac{x.im \cdot y.im + x.re \cdot y.re}{y.re} \cdot \frac{1}{y.re}} \]
    8. Taylor expanded in x.im around inf

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(x.im \cdot \left(\frac{x.re}{x.im} + \frac{y.im}{y.re}\right)\right)}, \mathsf{/.f64}\left(1, y.re\right)\right) \]
    9. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x.im, \left(\frac{x.re}{x.im} + \frac{y.im}{y.re}\right)\right), \mathsf{/.f64}\left(\color{blue}{1}, y.re\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x.im, \mathsf{+.f64}\left(\left(\frac{x.re}{x.im}\right), \left(\frac{y.im}{y.re}\right)\right)\right), \mathsf{/.f64}\left(1, y.re\right)\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x.im, \mathsf{+.f64}\left(\mathsf{/.f64}\left(x.re, x.im\right), \left(\frac{y.im}{y.re}\right)\right)\right), \mathsf{/.f64}\left(1, y.re\right)\right) \]
      4. /-lowering-/.f6484.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x.im, \mathsf{+.f64}\left(\mathsf{/.f64}\left(x.re, x.im\right), \mathsf{/.f64}\left(y.im, y.re\right)\right)\right), \mathsf{/.f64}\left(1, y.re\right)\right) \]
    10. Simplified84.8%

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

    if -3.60000000000000031e131 < y.re < -9.00000000000000013e80 or -1.75000000000000002e-65 < y.re < 1.8e-80

    1. Initial program 65.9%

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(x.im + \frac{x.re \cdot y.re}{y.im}\right), \color{blue}{y.im}\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \left(\frac{x.re \cdot y.re}{y.im}\right)\right), y.im\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(\left(x.re \cdot y.re\right), y.im\right)\right), y.im\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(\left(y.re \cdot x.re\right), y.im\right)\right), y.im\right) \]
      5. *-lowering-*.f6495.2%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(\mathsf{*.f64}\left(y.re, x.re\right), y.im\right)\right), y.im\right) \]
    5. Simplified95.2%

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

    if -9.00000000000000013e80 < y.re < -1.75000000000000002e-65 or 1.8e-80 < y.re < 2.14999999999999991e151

    1. Initial program 87.9%

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

    if 2.14999999999999991e151 < y.re

    1. Initial program 21.3%

      \[\frac{x.re \cdot y.re + x.im \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 \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, y.im\right)\right), \color{blue}{\left({y.re}^{2}\right)}\right) \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, y.im\right)\right), \left(y.re \cdot \color{blue}{y.re}\right)\right) \]
      2. *-lowering-*.f6421.3%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, y.im\right)\right), \mathsf{*.f64}\left(y.re, \color{blue}{y.re}\right)\right) \]
    5. Simplified21.3%

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re}\right), \color{blue}{\left(\frac{1}{y.re}\right)}\right) \]
      4. /-lowering-/.f64N/A

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(x.im \cdot y.im + y.re \cdot x.re\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(x.im \cdot y.im\right), \left(y.re \cdot x.re\right)\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      8. *-lowering-*.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), \left(x.re \cdot y.re\right)\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), \mathsf{*.f64}\left(x.re, y.re\right)\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      11. /-lowering-/.f6451.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), \mathsf{*.f64}\left(x.re, y.re\right)\right), y.re\right), \mathsf{/.f64}\left(1, \color{blue}{y.re}\right)\right) \]
    7. Applied egg-rr51.2%

      \[\leadsto \color{blue}{\frac{x.im \cdot y.im + x.re \cdot y.re}{y.re} \cdot \frac{1}{y.re}} \]
    8. Taylor expanded in y.im around inf

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(y.im \cdot \left(\frac{x.im}{y.re} + \frac{x.re}{y.im}\right)\right)}, \mathsf{/.f64}\left(1, y.re\right)\right) \]
    9. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(y.im, \left(\frac{x.im}{y.re} + \frac{x.re}{y.im}\right)\right), \mathsf{/.f64}\left(\color{blue}{1}, y.re\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(y.im, \mathsf{+.f64}\left(\left(\frac{x.im}{y.re}\right), \left(\frac{x.re}{y.im}\right)\right)\right), \mathsf{/.f64}\left(1, y.re\right)\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(y.im, \mathsf{+.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \left(\frac{x.re}{y.im}\right)\right)\right), \mathsf{/.f64}\left(1, y.re\right)\right) \]
      4. /-lowering-/.f6488.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(y.im, \mathsf{+.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \mathsf{/.f64}\left(x.re, y.im\right)\right)\right), \mathsf{/.f64}\left(1, y.re\right)\right) \]
    10. Simplified88.4%

      \[\leadsto \color{blue}{\left(y.im \cdot \left(\frac{x.im}{y.re} + \frac{x.re}{y.im}\right)\right)} \cdot \frac{1}{y.re} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification90.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -3.6 \cdot 10^{+131}:\\ \;\;\;\;\left(x.im \cdot \left(\frac{x.re}{x.im} + \frac{y.im}{y.re}\right)\right) \cdot \frac{1}{y.re}\\ \mathbf{elif}\;y.re \leq -9 \cdot 10^{+80}:\\ \;\;\;\;\frac{x.im + \frac{y.re \cdot x.re}{y.im}}{y.im}\\ \mathbf{elif}\;y.re \leq -1.75 \cdot 10^{-65}:\\ \;\;\;\;\frac{y.re \cdot x.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.re \leq 1.8 \cdot 10^{-80}:\\ \;\;\;\;\frac{x.im + \frac{y.re \cdot x.re}{y.im}}{y.im}\\ \mathbf{elif}\;y.re \leq 2.15 \cdot 10^{+151}:\\ \;\;\;\;\frac{y.re \cdot x.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y.re} \cdot \left(y.im \cdot \left(\frac{x.im}{y.re} + \frac{x.re}{y.im}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 79.2% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y.re \cdot y.re + y.im \cdot y.im\\ \mathbf{if}\;y.re \leq -4.4 \cdot 10^{+126}:\\ \;\;\;\;\left(x.im \cdot \left(\frac{x.re}{x.im} + \frac{y.im}{y.re}\right)\right) \cdot \frac{1}{y.re}\\ \mathbf{elif}\;y.re \leq -1.25 \cdot 10^{-54}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x.im}{t\_0}, y.im, \frac{y.re \cdot x.re}{t\_0}\right)\\ \mathbf{elif}\;y.re \leq 3.6 \cdot 10^{-85}:\\ \;\;\;\;\frac{x.im + \frac{y.re \cdot x.re}{y.im}}{y.im}\\ \mathbf{elif}\;y.re \leq 1.85 \cdot 10^{+151}:\\ \;\;\;\;\frac{1}{\frac{t\_0}{y.re \cdot x.re + x.im \cdot y.im}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y.re} \cdot \left(y.im \cdot \left(\frac{x.im}{y.re} + \frac{x.re}{y.im}\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (+ (* y.re y.re) (* y.im y.im))))
   (if (<= y.re -4.4e+126)
     (* (* x.im (+ (/ x.re x.im) (/ y.im y.re))) (/ 1.0 y.re))
     (if (<= y.re -1.25e-54)
       (fma (/ x.im t_0) y.im (/ (* y.re x.re) t_0))
       (if (<= y.re 3.6e-85)
         (/ (+ x.im (/ (* y.re x.re) y.im)) y.im)
         (if (<= y.re 1.85e+151)
           (/ 1.0 (/ t_0 (+ (* y.re x.re) (* x.im y.im))))
           (* (/ 1.0 y.re) (* y.im (+ (/ x.im y.re) (/ 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 = (y_46_re * y_46_re) + (y_46_im * y_46_im);
	double tmp;
	if (y_46_re <= -4.4e+126) {
		tmp = (x_46_im * ((x_46_re / x_46_im) + (y_46_im / y_46_re))) * (1.0 / y_46_re);
	} else if (y_46_re <= -1.25e-54) {
		tmp = fma((x_46_im / t_0), y_46_im, ((y_46_re * x_46_re) / t_0));
	} else if (y_46_re <= 3.6e-85) {
		tmp = (x_46_im + ((y_46_re * x_46_re) / y_46_im)) / y_46_im;
	} else if (y_46_re <= 1.85e+151) {
		tmp = 1.0 / (t_0 / ((y_46_re * x_46_re) + (x_46_im * y_46_im)));
	} else {
		tmp = (1.0 / y_46_re) * (y_46_im * ((x_46_im / y_46_re) + (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(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))
	tmp = 0.0
	if (y_46_re <= -4.4e+126)
		tmp = Float64(Float64(x_46_im * Float64(Float64(x_46_re / x_46_im) + Float64(y_46_im / y_46_re))) * Float64(1.0 / y_46_re));
	elseif (y_46_re <= -1.25e-54)
		tmp = fma(Float64(x_46_im / t_0), y_46_im, Float64(Float64(y_46_re * x_46_re) / t_0));
	elseif (y_46_re <= 3.6e-85)
		tmp = Float64(Float64(x_46_im + Float64(Float64(y_46_re * x_46_re) / y_46_im)) / y_46_im);
	elseif (y_46_re <= 1.85e+151)
		tmp = Float64(1.0 / Float64(t_0 / Float64(Float64(y_46_re * x_46_re) + Float64(x_46_im * y_46_im))));
	else
		tmp = Float64(Float64(1.0 / y_46_re) * Float64(y_46_im * Float64(Float64(x_46_im / y_46_re) + 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[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -4.4e+126], N[(N[(x$46$im * N[(N[(x$46$re / x$46$im), $MachinePrecision] + N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / y$46$re), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, -1.25e-54], N[(N[(x$46$im / t$95$0), $MachinePrecision] * y$46$im + N[(N[(y$46$re * x$46$re), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 3.6e-85], N[(N[(x$46$im + N[(N[(y$46$re * x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 1.85e+151], N[(1.0 / N[(t$95$0 / N[(N[(y$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y$46$re), $MachinePrecision] * N[(y$46$im * N[(N[(x$46$im / y$46$re), $MachinePrecision] + N[(x$46$re / y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y.re \cdot y.re + y.im \cdot y.im\\
\mathbf{if}\;y.re \leq -4.4 \cdot 10^{+126}:\\
\;\;\;\;\left(x.im \cdot \left(\frac{x.re}{x.im} + \frac{y.im}{y.re}\right)\right) \cdot \frac{1}{y.re}\\

\mathbf{elif}\;y.re \leq -1.25 \cdot 10^{-54}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x.im}{t\_0}, y.im, \frac{y.re \cdot x.re}{t\_0}\right)\\

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

\mathbf{elif}\;y.re \leq 1.85 \cdot 10^{+151}:\\
\;\;\;\;\frac{1}{\frac{t\_0}{y.re \cdot x.re + x.im \cdot y.im}}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{y.re} \cdot \left(y.im \cdot \left(\frac{x.im}{y.re} + \frac{x.re}{y.im}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if y.re < -4.39999999999999997e126

    1. Initial program 27.6%

      \[\frac{x.re \cdot y.re + x.im \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 \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, y.im\right)\right), \color{blue}{\left({y.re}^{2}\right)}\right) \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, y.im\right)\right), \left(y.re \cdot \color{blue}{y.re}\right)\right) \]
      2. *-lowering-*.f6427.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, y.im\right)\right), \mathsf{*.f64}\left(y.re, \color{blue}{y.re}\right)\right) \]
    5. Simplified27.6%

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re}\right), \color{blue}{\left(\frac{1}{y.re}\right)}\right) \]
      4. /-lowering-/.f64N/A

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(x.im \cdot y.im + y.re \cdot x.re\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(x.im \cdot y.im\right), \left(y.re \cdot x.re\right)\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      8. *-lowering-*.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), \left(x.re \cdot y.re\right)\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), \mathsf{*.f64}\left(x.re, y.re\right)\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      11. /-lowering-/.f6437.9%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), \mathsf{*.f64}\left(x.re, y.re\right)\right), y.re\right), \mathsf{/.f64}\left(1, \color{blue}{y.re}\right)\right) \]
    7. Applied egg-rr37.9%

      \[\leadsto \color{blue}{\frac{x.im \cdot y.im + x.re \cdot y.re}{y.re} \cdot \frac{1}{y.re}} \]
    8. Taylor expanded in x.im around inf

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(x.im \cdot \left(\frac{x.re}{x.im} + \frac{y.im}{y.re}\right)\right)}, \mathsf{/.f64}\left(1, y.re\right)\right) \]
    9. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x.im, \left(\frac{x.re}{x.im} + \frac{y.im}{y.re}\right)\right), \mathsf{/.f64}\left(\color{blue}{1}, y.re\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x.im, \mathsf{+.f64}\left(\left(\frac{x.re}{x.im}\right), \left(\frac{y.im}{y.re}\right)\right)\right), \mathsf{/.f64}\left(1, y.re\right)\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x.im, \mathsf{+.f64}\left(\mathsf{/.f64}\left(x.re, x.im\right), \left(\frac{y.im}{y.re}\right)\right)\right), \mathsf{/.f64}\left(1, y.re\right)\right) \]
      4. /-lowering-/.f6481.5%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x.im, \mathsf{+.f64}\left(\mathsf{/.f64}\left(x.re, x.im\right), \mathsf{/.f64}\left(y.im, y.re\right)\right)\right), \mathsf{/.f64}\left(1, y.re\right)\right) \]
    10. Simplified81.5%

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

    if -4.39999999999999997e126 < y.re < -1.25000000000000004e-54

    1. Initial program 75.7%

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

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

        \[\leadsto \frac{1}{y.re \cdot y.re + y.im \cdot y.im} \cdot \color{blue}{\left(x.re \cdot y.re + x.im \cdot y.im\right)} \]
      3. distribute-rgt-inN/A

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y.im, \color{blue}{x.im \cdot \frac{1}{y.re \cdot y.re + y.im \cdot y.im}}, \left(x.re \cdot y.re\right) \cdot \frac{1}{y.re \cdot y.re + y.im \cdot y.im}\right) \]
      8. un-div-invN/A

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

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

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

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

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

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

    if -1.25000000000000004e-54 < y.re < 3.5999999999999998e-85

    1. Initial program 71.1%

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(x.im + \frac{x.re \cdot y.re}{y.im}\right), \color{blue}{y.im}\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \left(\frac{x.re \cdot y.re}{y.im}\right)\right), y.im\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(\left(x.re \cdot y.re\right), y.im\right)\right), y.im\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(\left(y.re \cdot x.re\right), y.im\right)\right), y.im\right) \]
      5. *-lowering-*.f6496.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(\mathsf{*.f64}\left(y.re, x.re\right), y.im\right)\right), y.im\right) \]
    5. Simplified96.8%

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

    if 3.5999999999999998e-85 < y.re < 1.8499999999999999e151

    1. Initial program 92.8%

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

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

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{y.re \cdot y.re + y.im \cdot y.im}{x.re \cdot y.re + x.im \cdot y.im}\right)}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\left(y.re \cdot y.re + y.im \cdot y.im\right), \color{blue}{\left(x.re \cdot y.re + x.im \cdot y.im\right)}\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(y.re \cdot y.re\right), \left(y.im \cdot y.im\right)\right), \left(\color{blue}{x.re \cdot y.re} + x.im \cdot y.im\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(y.re, y.re\right), \left(y.im \cdot y.im\right)\right), \left(\color{blue}{x.re} \cdot y.re + x.im \cdot y.im\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(y.re, y.re\right), \mathsf{*.f64}\left(y.im, y.im\right)\right), \left(x.re \cdot \color{blue}{y.re} + x.im \cdot y.im\right)\right)\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(y.re, y.re\right), \mathsf{*.f64}\left(y.im, y.im\right)\right), \mathsf{+.f64}\left(\left(x.re \cdot y.re\right), \color{blue}{\left(x.im \cdot y.im\right)}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(y.re, y.re\right), \mathsf{*.f64}\left(y.im, y.im\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \left(\color{blue}{x.im} \cdot y.im\right)\right)\right)\right) \]
      9. *-lowering-*.f6492.8%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(y.re, y.re\right), \mathsf{*.f64}\left(y.im, y.im\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, \color{blue}{y.im}\right)\right)\right)\right) \]
    4. Applied egg-rr92.8%

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

    if 1.8499999999999999e151 < y.re

    1. Initial program 21.3%

      \[\frac{x.re \cdot y.re + x.im \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 \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, y.im\right)\right), \color{blue}{\left({y.re}^{2}\right)}\right) \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, y.im\right)\right), \left(y.re \cdot \color{blue}{y.re}\right)\right) \]
      2. *-lowering-*.f6421.3%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, y.im\right)\right), \mathsf{*.f64}\left(y.re, \color{blue}{y.re}\right)\right) \]
    5. Simplified21.3%

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re}\right), \color{blue}{\left(\frac{1}{y.re}\right)}\right) \]
      4. /-lowering-/.f64N/A

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(x.im \cdot y.im + y.re \cdot x.re\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(x.im \cdot y.im\right), \left(y.re \cdot x.re\right)\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      8. *-lowering-*.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), \left(x.re \cdot y.re\right)\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), \mathsf{*.f64}\left(x.re, y.re\right)\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      11. /-lowering-/.f6451.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), \mathsf{*.f64}\left(x.re, y.re\right)\right), y.re\right), \mathsf{/.f64}\left(1, \color{blue}{y.re}\right)\right) \]
    7. Applied egg-rr51.2%

      \[\leadsto \color{blue}{\frac{x.im \cdot y.im + x.re \cdot y.re}{y.re} \cdot \frac{1}{y.re}} \]
    8. Taylor expanded in y.im around inf

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(y.im \cdot \left(\frac{x.im}{y.re} + \frac{x.re}{y.im}\right)\right)}, \mathsf{/.f64}\left(1, y.re\right)\right) \]
    9. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(y.im, \left(\frac{x.im}{y.re} + \frac{x.re}{y.im}\right)\right), \mathsf{/.f64}\left(\color{blue}{1}, y.re\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(y.im, \mathsf{+.f64}\left(\left(\frac{x.im}{y.re}\right), \left(\frac{x.re}{y.im}\right)\right)\right), \mathsf{/.f64}\left(1, y.re\right)\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(y.im, \mathsf{+.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \left(\frac{x.re}{y.im}\right)\right)\right), \mathsf{/.f64}\left(1, y.re\right)\right) \]
      4. /-lowering-/.f6488.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(y.im, \mathsf{+.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \mathsf{/.f64}\left(x.re, y.im\right)\right)\right), \mathsf{/.f64}\left(1, y.re\right)\right) \]
    10. Simplified88.4%

      \[\leadsto \color{blue}{\left(y.im \cdot \left(\frac{x.im}{y.re} + \frac{x.re}{y.im}\right)\right)} \cdot \frac{1}{y.re} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification89.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -4.4 \cdot 10^{+126}:\\ \;\;\;\;\left(x.im \cdot \left(\frac{x.re}{x.im} + \frac{y.im}{y.re}\right)\right) \cdot \frac{1}{y.re}\\ \mathbf{elif}\;y.re \leq -1.25 \cdot 10^{-54}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x.im}{y.re \cdot y.re + y.im \cdot y.im}, y.im, \frac{y.re \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\right)\\ \mathbf{elif}\;y.re \leq 3.6 \cdot 10^{-85}:\\ \;\;\;\;\frac{x.im + \frac{y.re \cdot x.re}{y.im}}{y.im}\\ \mathbf{elif}\;y.re \leq 1.85 \cdot 10^{+151}:\\ \;\;\;\;\frac{1}{\frac{y.re \cdot y.re + y.im \cdot y.im}{y.re \cdot x.re + x.im \cdot y.im}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y.re} \cdot \left(y.im \cdot \left(\frac{x.im}{y.re} + \frac{x.re}{y.im}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 79.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{\frac{y.re \cdot y.re + y.im \cdot y.im}{y.re \cdot x.re + x.im \cdot y.im}}\\ \mathbf{if}\;y.re \leq -3.2 \cdot 10^{+123}:\\ \;\;\;\;\left(x.im \cdot \left(\frac{x.re}{x.im} + \frac{y.im}{y.re}\right)\right) \cdot \frac{1}{y.re}\\ \mathbf{elif}\;y.re \leq -6.8 \cdot 10^{-65}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.re \leq 6 \cdot 10^{-85}:\\ \;\;\;\;\frac{x.im + \frac{y.re \cdot x.re}{y.im}}{y.im}\\ \mathbf{elif}\;y.re \leq 5.1 \cdot 10^{+152}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y.re} \cdot \left(y.im \cdot \left(\frac{x.im}{y.re} + \frac{x.re}{y.im}\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0
         (/
          1.0
          (/
           (+ (* y.re y.re) (* y.im y.im))
           (+ (* y.re x.re) (* x.im y.im))))))
   (if (<= y.re -3.2e+123)
     (* (* x.im (+ (/ x.re x.im) (/ y.im y.re))) (/ 1.0 y.re))
     (if (<= y.re -6.8e-65)
       t_0
       (if (<= y.re 6e-85)
         (/ (+ x.im (/ (* y.re x.re) y.im)) y.im)
         (if (<= y.re 5.1e+152)
           t_0
           (* (/ 1.0 y.re) (* y.im (+ (/ x.im y.re) (/ 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 = 1.0 / (((y_46_re * y_46_re) + (y_46_im * y_46_im)) / ((y_46_re * x_46_re) + (x_46_im * y_46_im)));
	double tmp;
	if (y_46_re <= -3.2e+123) {
		tmp = (x_46_im * ((x_46_re / x_46_im) + (y_46_im / y_46_re))) * (1.0 / y_46_re);
	} else if (y_46_re <= -6.8e-65) {
		tmp = t_0;
	} else if (y_46_re <= 6e-85) {
		tmp = (x_46_im + ((y_46_re * x_46_re) / y_46_im)) / y_46_im;
	} else if (y_46_re <= 5.1e+152) {
		tmp = t_0;
	} else {
		tmp = (1.0 / y_46_re) * (y_46_im * ((x_46_im / y_46_re) + (x_46_re / y_46_im)));
	}
	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 = 1.0d0 / (((y_46re * y_46re) + (y_46im * y_46im)) / ((y_46re * x_46re) + (x_46im * y_46im)))
    if (y_46re <= (-3.2d+123)) then
        tmp = (x_46im * ((x_46re / x_46im) + (y_46im / y_46re))) * (1.0d0 / y_46re)
    else if (y_46re <= (-6.8d-65)) then
        tmp = t_0
    else if (y_46re <= 6d-85) then
        tmp = (x_46im + ((y_46re * x_46re) / y_46im)) / y_46im
    else if (y_46re <= 5.1d+152) then
        tmp = t_0
    else
        tmp = (1.0d0 / y_46re) * (y_46im * ((x_46im / y_46re) + (x_46re / y_46im)))
    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 = 1.0 / (((y_46_re * y_46_re) + (y_46_im * y_46_im)) / ((y_46_re * x_46_re) + (x_46_im * y_46_im)));
	double tmp;
	if (y_46_re <= -3.2e+123) {
		tmp = (x_46_im * ((x_46_re / x_46_im) + (y_46_im / y_46_re))) * (1.0 / y_46_re);
	} else if (y_46_re <= -6.8e-65) {
		tmp = t_0;
	} else if (y_46_re <= 6e-85) {
		tmp = (x_46_im + ((y_46_re * x_46_re) / y_46_im)) / y_46_im;
	} else if (y_46_re <= 5.1e+152) {
		tmp = t_0;
	} else {
		tmp = (1.0 / y_46_re) * (y_46_im * ((x_46_im / y_46_re) + (x_46_re / y_46_im)));
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = 1.0 / (((y_46_re * y_46_re) + (y_46_im * y_46_im)) / ((y_46_re * x_46_re) + (x_46_im * y_46_im)))
	tmp = 0
	if y_46_re <= -3.2e+123:
		tmp = (x_46_im * ((x_46_re / x_46_im) + (y_46_im / y_46_re))) * (1.0 / y_46_re)
	elif y_46_re <= -6.8e-65:
		tmp = t_0
	elif y_46_re <= 6e-85:
		tmp = (x_46_im + ((y_46_re * x_46_re) / y_46_im)) / y_46_im
	elif y_46_re <= 5.1e+152:
		tmp = t_0
	else:
		tmp = (1.0 / y_46_re) * (y_46_im * ((x_46_im / y_46_re) + (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(1.0 / Float64(Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)) / Float64(Float64(y_46_re * x_46_re) + Float64(x_46_im * y_46_im))))
	tmp = 0.0
	if (y_46_re <= -3.2e+123)
		tmp = Float64(Float64(x_46_im * Float64(Float64(x_46_re / x_46_im) + Float64(y_46_im / y_46_re))) * Float64(1.0 / y_46_re));
	elseif (y_46_re <= -6.8e-65)
		tmp = t_0;
	elseif (y_46_re <= 6e-85)
		tmp = Float64(Float64(x_46_im + Float64(Float64(y_46_re * x_46_re) / y_46_im)) / y_46_im);
	elseif (y_46_re <= 5.1e+152)
		tmp = t_0;
	else
		tmp = Float64(Float64(1.0 / y_46_re) * Float64(y_46_im * Float64(Float64(x_46_im / y_46_re) + Float64(x_46_re / y_46_im))));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = 1.0 / (((y_46_re * y_46_re) + (y_46_im * y_46_im)) / ((y_46_re * x_46_re) + (x_46_im * y_46_im)));
	tmp = 0.0;
	if (y_46_re <= -3.2e+123)
		tmp = (x_46_im * ((x_46_re / x_46_im) + (y_46_im / y_46_re))) * (1.0 / y_46_re);
	elseif (y_46_re <= -6.8e-65)
		tmp = t_0;
	elseif (y_46_re <= 6e-85)
		tmp = (x_46_im + ((y_46_re * x_46_re) / y_46_im)) / y_46_im;
	elseif (y_46_re <= 5.1e+152)
		tmp = t_0;
	else
		tmp = (1.0 / y_46_re) * (y_46_im * ((x_46_im / y_46_re) + (x_46_re / y_46_im)));
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(1.0 / N[(N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -3.2e+123], N[(N[(x$46$im * N[(N[(x$46$re / x$46$im), $MachinePrecision] + N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / y$46$re), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, -6.8e-65], t$95$0, If[LessEqual[y$46$re, 6e-85], N[(N[(x$46$im + N[(N[(y$46$re * x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 5.1e+152], t$95$0, N[(N[(1.0 / y$46$re), $MachinePrecision] * N[(y$46$im * N[(N[(x$46$im / y$46$re), $MachinePrecision] + N[(x$46$re / y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{\frac{y.re \cdot y.re + y.im \cdot y.im}{y.re \cdot x.re + x.im \cdot y.im}}\\
\mathbf{if}\;y.re \leq -3.2 \cdot 10^{+123}:\\
\;\;\;\;\left(x.im \cdot \left(\frac{x.re}{x.im} + \frac{y.im}{y.re}\right)\right) \cdot \frac{1}{y.re}\\

\mathbf{elif}\;y.re \leq -6.8 \cdot 10^{-65}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;y.re \leq 5.1 \cdot 10^{+152}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{y.re} \cdot \left(y.im \cdot \left(\frac{x.im}{y.re} + \frac{x.re}{y.im}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y.re < -3.20000000000000005e123

    1. Initial program 27.6%

      \[\frac{x.re \cdot y.re + x.im \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 \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, y.im\right)\right), \color{blue}{\left({y.re}^{2}\right)}\right) \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, y.im\right)\right), \left(y.re \cdot \color{blue}{y.re}\right)\right) \]
      2. *-lowering-*.f6427.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, y.im\right)\right), \mathsf{*.f64}\left(y.re, \color{blue}{y.re}\right)\right) \]
    5. Simplified27.6%

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re}\right), \color{blue}{\left(\frac{1}{y.re}\right)}\right) \]
      4. /-lowering-/.f64N/A

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(x.im \cdot y.im + y.re \cdot x.re\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(x.im \cdot y.im\right), \left(y.re \cdot x.re\right)\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      8. *-lowering-*.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), \left(x.re \cdot y.re\right)\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), \mathsf{*.f64}\left(x.re, y.re\right)\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      11. /-lowering-/.f6437.9%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), \mathsf{*.f64}\left(x.re, y.re\right)\right), y.re\right), \mathsf{/.f64}\left(1, \color{blue}{y.re}\right)\right) \]
    7. Applied egg-rr37.9%

      \[\leadsto \color{blue}{\frac{x.im \cdot y.im + x.re \cdot y.re}{y.re} \cdot \frac{1}{y.re}} \]
    8. Taylor expanded in x.im around inf

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(x.im \cdot \left(\frac{x.re}{x.im} + \frac{y.im}{y.re}\right)\right)}, \mathsf{/.f64}\left(1, y.re\right)\right) \]
    9. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x.im, \left(\frac{x.re}{x.im} + \frac{y.im}{y.re}\right)\right), \mathsf{/.f64}\left(\color{blue}{1}, y.re\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x.im, \mathsf{+.f64}\left(\left(\frac{x.re}{x.im}\right), \left(\frac{y.im}{y.re}\right)\right)\right), \mathsf{/.f64}\left(1, y.re\right)\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x.im, \mathsf{+.f64}\left(\mathsf{/.f64}\left(x.re, x.im\right), \left(\frac{y.im}{y.re}\right)\right)\right), \mathsf{/.f64}\left(1, y.re\right)\right) \]
      4. /-lowering-/.f6481.5%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x.im, \mathsf{+.f64}\left(\mathsf{/.f64}\left(x.re, x.im\right), \mathsf{/.f64}\left(y.im, y.re\right)\right)\right), \mathsf{/.f64}\left(1, y.re\right)\right) \]
    10. Simplified81.5%

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

    if -3.20000000000000005e123 < y.re < -6.79999999999999973e-65 or 6.00000000000000044e-85 < y.re < 5.0999999999999996e152

    1. Initial program 83.1%

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

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

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{y.re \cdot y.re + y.im \cdot y.im}{x.re \cdot y.re + x.im \cdot y.im}\right)}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\left(y.re \cdot y.re + y.im \cdot y.im\right), \color{blue}{\left(x.re \cdot y.re + x.im \cdot y.im\right)}\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(y.re \cdot y.re\right), \left(y.im \cdot y.im\right)\right), \left(\color{blue}{x.re \cdot y.re} + x.im \cdot y.im\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(y.re, y.re\right), \left(y.im \cdot y.im\right)\right), \left(\color{blue}{x.re} \cdot y.re + x.im \cdot y.im\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(y.re, y.re\right), \mathsf{*.f64}\left(y.im, y.im\right)\right), \left(x.re \cdot \color{blue}{y.re} + x.im \cdot y.im\right)\right)\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(y.re, y.re\right), \mathsf{*.f64}\left(y.im, y.im\right)\right), \mathsf{+.f64}\left(\left(x.re \cdot y.re\right), \color{blue}{\left(x.im \cdot y.im\right)}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(y.re, y.re\right), \mathsf{*.f64}\left(y.im, y.im\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \left(\color{blue}{x.im} \cdot y.im\right)\right)\right)\right) \]
      9. *-lowering-*.f6483.2%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(y.re, y.re\right), \mathsf{*.f64}\left(y.im, y.im\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, \color{blue}{y.im}\right)\right)\right)\right) \]
    4. Applied egg-rr83.2%

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

    if -6.79999999999999973e-65 < y.re < 6.00000000000000044e-85

    1. Initial program 70.8%

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(x.im + \frac{x.re \cdot y.re}{y.im}\right), \color{blue}{y.im}\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \left(\frac{x.re \cdot y.re}{y.im}\right)\right), y.im\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(\left(x.re \cdot y.re\right), y.im\right)\right), y.im\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(\left(y.re \cdot x.re\right), y.im\right)\right), y.im\right) \]
      5. *-lowering-*.f6497.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(\mathsf{*.f64}\left(y.re, x.re\right), y.im\right)\right), y.im\right) \]
    5. Simplified97.8%

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

    if 5.0999999999999996e152 < y.re

    1. Initial program 21.3%

      \[\frac{x.re \cdot y.re + x.im \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 \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, y.im\right)\right), \color{blue}{\left({y.re}^{2}\right)}\right) \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, y.im\right)\right), \left(y.re \cdot \color{blue}{y.re}\right)\right) \]
      2. *-lowering-*.f6421.3%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, y.im\right)\right), \mathsf{*.f64}\left(y.re, \color{blue}{y.re}\right)\right) \]
    5. Simplified21.3%

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re}\right), \color{blue}{\left(\frac{1}{y.re}\right)}\right) \]
      4. /-lowering-/.f64N/A

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(x.im \cdot y.im + y.re \cdot x.re\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(x.im \cdot y.im\right), \left(y.re \cdot x.re\right)\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      8. *-lowering-*.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), \left(x.re \cdot y.re\right)\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), \mathsf{*.f64}\left(x.re, y.re\right)\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      11. /-lowering-/.f6451.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), \mathsf{*.f64}\left(x.re, y.re\right)\right), y.re\right), \mathsf{/.f64}\left(1, \color{blue}{y.re}\right)\right) \]
    7. Applied egg-rr51.2%

      \[\leadsto \color{blue}{\frac{x.im \cdot y.im + x.re \cdot y.re}{y.re} \cdot \frac{1}{y.re}} \]
    8. Taylor expanded in y.im around inf

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(y.im \cdot \left(\frac{x.im}{y.re} + \frac{x.re}{y.im}\right)\right)}, \mathsf{/.f64}\left(1, y.re\right)\right) \]
    9. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(y.im, \left(\frac{x.im}{y.re} + \frac{x.re}{y.im}\right)\right), \mathsf{/.f64}\left(\color{blue}{1}, y.re\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(y.im, \mathsf{+.f64}\left(\left(\frac{x.im}{y.re}\right), \left(\frac{x.re}{y.im}\right)\right)\right), \mathsf{/.f64}\left(1, y.re\right)\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(y.im, \mathsf{+.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \left(\frac{x.re}{y.im}\right)\right)\right), \mathsf{/.f64}\left(1, y.re\right)\right) \]
      4. /-lowering-/.f6488.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(y.im, \mathsf{+.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \mathsf{/.f64}\left(x.re, y.im\right)\right)\right), \mathsf{/.f64}\left(1, y.re\right)\right) \]
    10. Simplified88.4%

      \[\leadsto \color{blue}{\left(y.im \cdot \left(\frac{x.im}{y.re} + \frac{x.re}{y.im}\right)\right)} \cdot \frac{1}{y.re} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification88.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -3.2 \cdot 10^{+123}:\\ \;\;\;\;\left(x.im \cdot \left(\frac{x.re}{x.im} + \frac{y.im}{y.re}\right)\right) \cdot \frac{1}{y.re}\\ \mathbf{elif}\;y.re \leq -6.8 \cdot 10^{-65}:\\ \;\;\;\;\frac{1}{\frac{y.re \cdot y.re + y.im \cdot y.im}{y.re \cdot x.re + x.im \cdot y.im}}\\ \mathbf{elif}\;y.re \leq 6 \cdot 10^{-85}:\\ \;\;\;\;\frac{x.im + \frac{y.re \cdot x.re}{y.im}}{y.im}\\ \mathbf{elif}\;y.re \leq 5.1 \cdot 10^{+152}:\\ \;\;\;\;\frac{1}{\frac{y.re \cdot y.re + y.im \cdot y.im}{y.re \cdot x.re + x.im \cdot y.im}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y.re} \cdot \left(y.im \cdot \left(\frac{x.im}{y.re} + \frac{x.re}{y.im}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 75.7% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}\\ \mathbf{if}\;y.re \leq -1.05 \cdot 10^{+176}:\\ \;\;\;\;\left(x.im \cdot \left(\frac{x.re}{x.im} + \frac{y.im}{y.re}\right)\right) \cdot \frac{1}{y.re}\\ \mathbf{elif}\;y.re \leq -1.5 \cdot 10^{-62}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.re \leq 2.7 \cdot 10^{-18}:\\ \;\;\;\;\frac{x.im + \frac{y.re \cdot x.re}{y.im}}{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 (/ (* x.im y.im) y.re)) y.re)))
   (if (<= y.re -1.05e+176)
     (* (* x.im (+ (/ x.re x.im) (/ y.im y.re))) (/ 1.0 y.re))
     (if (<= y.re -1.5e-62)
       t_0
       (if (<= y.re 2.7e-18) (/ (+ x.im (/ (* y.re 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 + ((x_46_im * y_46_im) / y_46_re)) / y_46_re;
	double tmp;
	if (y_46_re <= -1.05e+176) {
		tmp = (x_46_im * ((x_46_re / x_46_im) + (y_46_im / y_46_re))) * (1.0 / y_46_re);
	} else if (y_46_re <= -1.5e-62) {
		tmp = t_0;
	} else if (y_46_re <= 2.7e-18) {
		tmp = (x_46_im + ((y_46_re * 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 + ((x_46im * y_46im) / y_46re)) / y_46re
    if (y_46re <= (-1.05d+176)) then
        tmp = (x_46im * ((x_46re / x_46im) + (y_46im / y_46re))) * (1.0d0 / y_46re)
    else if (y_46re <= (-1.5d-62)) then
        tmp = t_0
    else if (y_46re <= 2.7d-18) then
        tmp = (x_46im + ((y_46re * 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 + ((x_46_im * y_46_im) / y_46_re)) / y_46_re;
	double tmp;
	if (y_46_re <= -1.05e+176) {
		tmp = (x_46_im * ((x_46_re / x_46_im) + (y_46_im / y_46_re))) * (1.0 / y_46_re);
	} else if (y_46_re <= -1.5e-62) {
		tmp = t_0;
	} else if (y_46_re <= 2.7e-18) {
		tmp = (x_46_im + ((y_46_re * 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 + ((x_46_im * y_46_im) / y_46_re)) / y_46_re
	tmp = 0
	if y_46_re <= -1.05e+176:
		tmp = (x_46_im * ((x_46_re / x_46_im) + (y_46_im / y_46_re))) * (1.0 / y_46_re)
	elif y_46_re <= -1.5e-62:
		tmp = t_0
	elif y_46_re <= 2.7e-18:
		tmp = (x_46_im + ((y_46_re * 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 + Float64(Float64(x_46_im * y_46_im) / y_46_re)) / y_46_re)
	tmp = 0.0
	if (y_46_re <= -1.05e+176)
		tmp = Float64(Float64(x_46_im * Float64(Float64(x_46_re / x_46_im) + Float64(y_46_im / y_46_re))) * Float64(1.0 / y_46_re));
	elseif (y_46_re <= -1.5e-62)
		tmp = t_0;
	elseif (y_46_re <= 2.7e-18)
		tmp = Float64(Float64(x_46_im + Float64(Float64(y_46_re * x_46_re) / 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 + ((x_46_im * y_46_im) / y_46_re)) / y_46_re;
	tmp = 0.0;
	if (y_46_re <= -1.05e+176)
		tmp = (x_46_im * ((x_46_re / x_46_im) + (y_46_im / y_46_re))) * (1.0 / y_46_re);
	elseif (y_46_re <= -1.5e-62)
		tmp = t_0;
	elseif (y_46_re <= 2.7e-18)
		tmp = (x_46_im + ((y_46_re * 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[(N[(x$46$re + N[(N[(x$46$im * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -1.05e+176], N[(N[(x$46$im * N[(N[(x$46$re / x$46$im), $MachinePrecision] + N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / y$46$re), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, -1.5e-62], t$95$0, If[LessEqual[y$46$re, 2.7e-18], N[(N[(x$46$im + N[(N[(y$46$re * x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}\\
\mathbf{if}\;y.re \leq -1.05 \cdot 10^{+176}:\\
\;\;\;\;\left(x.im \cdot \left(\frac{x.re}{x.im} + \frac{y.im}{y.re}\right)\right) \cdot \frac{1}{y.re}\\

\mathbf{elif}\;y.re \leq -1.5 \cdot 10^{-62}:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.re < -1.05e176

    1. Initial program 21.7%

      \[\frac{x.re \cdot y.re + x.im \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 \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, y.im\right)\right), \color{blue}{\left({y.re}^{2}\right)}\right) \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, y.im\right)\right), \left(y.re \cdot \color{blue}{y.re}\right)\right) \]
      2. *-lowering-*.f6421.7%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.re, y.re\right), \mathsf{*.f64}\left(x.im, y.im\right)\right), \mathsf{*.f64}\left(y.re, \color{blue}{y.re}\right)\right) \]
    5. Simplified21.7%

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re}\right), \color{blue}{\left(\frac{1}{y.re}\right)}\right) \]
      4. /-lowering-/.f64N/A

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(x.im \cdot y.im + y.re \cdot x.re\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(x.im \cdot y.im\right), \left(y.re \cdot x.re\right)\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      8. *-lowering-*.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), \left(x.re \cdot y.re\right)\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), \mathsf{*.f64}\left(x.re, y.re\right)\right), y.re\right), \left(\frac{1}{y.re}\right)\right) \]
      11. /-lowering-/.f6429.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), \mathsf{*.f64}\left(x.re, y.re\right)\right), y.re\right), \mathsf{/.f64}\left(1, \color{blue}{y.re}\right)\right) \]
    7. Applied egg-rr29.8%

      \[\leadsto \color{blue}{\frac{x.im \cdot y.im + x.re \cdot y.re}{y.re} \cdot \frac{1}{y.re}} \]
    8. Taylor expanded in x.im around inf

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(x.im \cdot \left(\frac{x.re}{x.im} + \frac{y.im}{y.re}\right)\right)}, \mathsf{/.f64}\left(1, y.re\right)\right) \]
    9. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x.im, \left(\frac{x.re}{x.im} + \frac{y.im}{y.re}\right)\right), \mathsf{/.f64}\left(\color{blue}{1}, y.re\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x.im, \mathsf{+.f64}\left(\left(\frac{x.re}{x.im}\right), \left(\frac{y.im}{y.re}\right)\right)\right), \mathsf{/.f64}\left(1, y.re\right)\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x.im, \mathsf{+.f64}\left(\mathsf{/.f64}\left(x.re, x.im\right), \left(\frac{y.im}{y.re}\right)\right)\right), \mathsf{/.f64}\left(1, y.re\right)\right) \]
      4. /-lowering-/.f6483.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x.im, \mathsf{+.f64}\left(\mathsf{/.f64}\left(x.re, x.im\right), \mathsf{/.f64}\left(y.im, y.re\right)\right)\right), \mathsf{/.f64}\left(1, y.re\right)\right) \]
    10. Simplified83.7%

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

    if -1.05e176 < y.re < -1.5000000000000001e-62 or 2.69999999999999989e-18 < y.re

    1. Initial program 61.4%

      \[\frac{x.re \cdot y.re + x.im \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.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x.re + \frac{x.im \cdot y.im}{y.re}\right), \color{blue}{y.re}\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.re, \left(\frac{x.im \cdot y.im}{y.re}\right)\right), y.re\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.re, \mathsf{/.f64}\left(\left(x.im \cdot y.im\right), y.re\right)\right), y.re\right) \]
      4. *-lowering-*.f6472.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.re, \mathsf{/.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), y.re\right)\right), y.re\right) \]
    5. Simplified72.6%

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

    if -1.5000000000000001e-62 < y.re < 2.69999999999999989e-18

    1. Initial program 72.8%

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(x.im + \frac{x.re \cdot y.re}{y.im}\right), \color{blue}{y.im}\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \left(\frac{x.re \cdot y.re}{y.im}\right)\right), y.im\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(\left(x.re \cdot y.re\right), y.im\right)\right), y.im\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(\left(y.re \cdot x.re\right), y.im\right)\right), y.im\right) \]
      5. *-lowering-*.f6495.2%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(\mathsf{*.f64}\left(y.re, x.re\right), y.im\right)\right), y.im\right) \]
    5. Simplified95.2%

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

Alternative 5: 76.0% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}\\ \mathbf{if}\;y.re \leq -1.5 \cdot 10^{-62}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.re \leq 1.3 \cdot 10^{-25}:\\ \;\;\;\;\frac{x.im + \frac{y.re \cdot x.re}{y.im}}{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 (/ (* x.im y.im) y.re)) y.re)))
   (if (<= y.re -1.5e-62)
     t_0
     (if (<= y.re 1.3e-25) (/ (+ x.im (/ (* y.re 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 + ((x_46_im * y_46_im) / y_46_re)) / y_46_re;
	double tmp;
	if (y_46_re <= -1.5e-62) {
		tmp = t_0;
	} else if (y_46_re <= 1.3e-25) {
		tmp = (x_46_im + ((y_46_re * 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 + ((x_46im * y_46im) / y_46re)) / y_46re
    if (y_46re <= (-1.5d-62)) then
        tmp = t_0
    else if (y_46re <= 1.3d-25) then
        tmp = (x_46im + ((y_46re * 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 + ((x_46_im * y_46_im) / y_46_re)) / y_46_re;
	double tmp;
	if (y_46_re <= -1.5e-62) {
		tmp = t_0;
	} else if (y_46_re <= 1.3e-25) {
		tmp = (x_46_im + ((y_46_re * 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 + ((x_46_im * y_46_im) / y_46_re)) / y_46_re
	tmp = 0
	if y_46_re <= -1.5e-62:
		tmp = t_0
	elif y_46_re <= 1.3e-25:
		tmp = (x_46_im + ((y_46_re * 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 + Float64(Float64(x_46_im * y_46_im) / y_46_re)) / y_46_re)
	tmp = 0.0
	if (y_46_re <= -1.5e-62)
		tmp = t_0;
	elseif (y_46_re <= 1.3e-25)
		tmp = Float64(Float64(x_46_im + Float64(Float64(y_46_re * x_46_re) / 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 + ((x_46_im * y_46_im) / y_46_re)) / y_46_re;
	tmp = 0.0;
	if (y_46_re <= -1.5e-62)
		tmp = t_0;
	elseif (y_46_re <= 1.3e-25)
		tmp = (x_46_im + ((y_46_re * 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[(N[(x$46$re + N[(N[(x$46$im * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -1.5e-62], t$95$0, If[LessEqual[y$46$re, 1.3e-25], N[(N[(x$46$im + N[(N[(y$46$re * x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.re < -1.5000000000000001e-62 or 1.3e-25 < y.re

    1. Initial program 53.2%

      \[\frac{x.re \cdot y.re + x.im \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.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x.re + \frac{x.im \cdot y.im}{y.re}\right), \color{blue}{y.re}\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.re, \left(\frac{x.im \cdot y.im}{y.re}\right)\right), y.re\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.re, \mathsf{/.f64}\left(\left(x.im \cdot y.im\right), y.re\right)\right), y.re\right) \]
      4. *-lowering-*.f6471.4%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.re, \mathsf{/.f64}\left(\mathsf{*.f64}\left(x.im, y.im\right), y.re\right)\right), y.re\right) \]
    5. Simplified71.4%

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

    if -1.5000000000000001e-62 < y.re < 1.3e-25

    1. Initial program 72.8%

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(x.im + \frac{x.re \cdot y.re}{y.im}\right), \color{blue}{y.im}\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \left(\frac{x.re \cdot y.re}{y.im}\right)\right), y.im\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(\left(x.re \cdot y.re\right), y.im\right)\right), y.im\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(\left(y.re \cdot x.re\right), y.im\right)\right), y.im\right) \]
      5. *-lowering-*.f6495.2%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(\mathsf{*.f64}\left(y.re, x.re\right), y.im\right)\right), y.im\right) \]
    5. Simplified95.2%

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

Alternative 6: 72.2% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -5 \cdot 10^{+110}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq 1.15 \cdot 10^{-25}:\\ \;\;\;\;\frac{x.im + \frac{y.re \cdot x.re}{y.im}}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (<= y.re -5e+110)
   (/ x.re y.re)
   (if (<= y.re 1.15e-25)
     (/ (+ x.im (/ (* y.re x.re) y.im)) y.im)
     (/ x.re y.re))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if (y_46_re <= -5e+110) {
		tmp = x_46_re / y_46_re;
	} else if (y_46_re <= 1.15e-25) {
		tmp = (x_46_im + ((y_46_re * x_46_re) / y_46_im)) / y_46_im;
	} else {
		tmp = x_46_re / y_46_re;
	}
	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) :: tmp
    if (y_46re <= (-5d+110)) then
        tmp = x_46re / y_46re
    else if (y_46re <= 1.15d-25) then
        tmp = (x_46im + ((y_46re * x_46re) / y_46im)) / y_46im
    else
        tmp = x_46re / y_46re
    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 tmp;
	if (y_46_re <= -5e+110) {
		tmp = x_46_re / y_46_re;
	} else if (y_46_re <= 1.15e-25) {
		tmp = (x_46_im + ((y_46_re * x_46_re) / y_46_im)) / y_46_im;
	} else {
		tmp = x_46_re / y_46_re;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	tmp = 0
	if y_46_re <= -5e+110:
		tmp = x_46_re / y_46_re
	elif y_46_re <= 1.15e-25:
		tmp = (x_46_im + ((y_46_re * x_46_re) / y_46_im)) / y_46_im
	else:
		tmp = x_46_re / y_46_re
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0
	if (y_46_re <= -5e+110)
		tmp = Float64(x_46_re / y_46_re);
	elseif (y_46_re <= 1.15e-25)
		tmp = Float64(Float64(x_46_im + Float64(Float64(y_46_re * x_46_re) / y_46_im)) / y_46_im);
	else
		tmp = Float64(x_46_re / y_46_re);
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0;
	if (y_46_re <= -5e+110)
		tmp = x_46_re / y_46_re;
	elseif (y_46_re <= 1.15e-25)
		tmp = (x_46_im + ((y_46_re * x_46_re) / y_46_im)) / y_46_im;
	else
		tmp = x_46_re / y_46_re;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -5e+110], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 1.15e-25], N[(N[(x$46$im + N[(N[(y$46$re * x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -5 \cdot 10^{+110}:\\
\;\;\;\;\frac{x.re}{y.re}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.re < -4.99999999999999978e110 or 1.15e-25 < y.re

    1. Initial program 43.3%

      \[\frac{x.re \cdot y.re + x.im \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.re}{y.re}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f6470.0%

        \[\leadsto \mathsf{/.f64}\left(x.re, \color{blue}{y.re}\right) \]
    5. Simplified70.0%

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

    if -4.99999999999999978e110 < y.re < 1.15e-25

    1. Initial program 73.6%

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(x.im + \frac{x.re \cdot y.re}{y.im}\right), \color{blue}{y.im}\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \left(\frac{x.re \cdot y.re}{y.im}\right)\right), y.im\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(\left(x.re \cdot y.re\right), y.im\right)\right), y.im\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(\left(y.re \cdot x.re\right), y.im\right)\right), y.im\right) \]
      5. *-lowering-*.f6478.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(\mathsf{*.f64}\left(y.re, x.re\right), y.im\right)\right), y.im\right) \]
    5. Simplified78.8%

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

Alternative 7: 72.5% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -2.4 \cdot 10^{+112}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq 3.25 \cdot 10^{-18}:\\ \;\;\;\;\frac{x.im + \frac{x.re}{\frac{y.im}{y.re}}}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (<= y.re -2.4e+112)
   (/ x.re y.re)
   (if (<= y.re 3.25e-18)
     (/ (+ x.im (/ x.re (/ y.im y.re))) y.im)
     (/ x.re y.re))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if (y_46_re <= -2.4e+112) {
		tmp = x_46_re / y_46_re;
	} else if (y_46_re <= 3.25e-18) {
		tmp = (x_46_im + (x_46_re / (y_46_im / y_46_re))) / y_46_im;
	} else {
		tmp = x_46_re / y_46_re;
	}
	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) :: tmp
    if (y_46re <= (-2.4d+112)) then
        tmp = x_46re / y_46re
    else if (y_46re <= 3.25d-18) then
        tmp = (x_46im + (x_46re / (y_46im / y_46re))) / y_46im
    else
        tmp = x_46re / y_46re
    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 tmp;
	if (y_46_re <= -2.4e+112) {
		tmp = x_46_re / y_46_re;
	} else if (y_46_re <= 3.25e-18) {
		tmp = (x_46_im + (x_46_re / (y_46_im / y_46_re))) / y_46_im;
	} else {
		tmp = x_46_re / y_46_re;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	tmp = 0
	if y_46_re <= -2.4e+112:
		tmp = x_46_re / y_46_re
	elif y_46_re <= 3.25e-18:
		tmp = (x_46_im + (x_46_re / (y_46_im / y_46_re))) / y_46_im
	else:
		tmp = x_46_re / y_46_re
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0
	if (y_46_re <= -2.4e+112)
		tmp = Float64(x_46_re / y_46_re);
	elseif (y_46_re <= 3.25e-18)
		tmp = Float64(Float64(x_46_im + Float64(x_46_re / Float64(y_46_im / y_46_re))) / y_46_im);
	else
		tmp = Float64(x_46_re / y_46_re);
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0;
	if (y_46_re <= -2.4e+112)
		tmp = x_46_re / y_46_re;
	elseif (y_46_re <= 3.25e-18)
		tmp = (x_46_im + (x_46_re / (y_46_im / y_46_re))) / y_46_im;
	else
		tmp = x_46_re / y_46_re;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -2.4e+112], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 3.25e-18], N[(N[(x$46$im + N[(x$46$re / N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -2.4 \cdot 10^{+112}:\\
\;\;\;\;\frac{x.re}{y.re}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.re < -2.4e112 or 3.25000000000000004e-18 < y.re

    1. Initial program 43.3%

      \[\frac{x.re \cdot y.re + x.im \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.re}{y.re}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f6470.0%

        \[\leadsto \mathsf{/.f64}\left(x.re, \color{blue}{y.re}\right) \]
    5. Simplified70.0%

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

    if -2.4e112 < y.re < 3.25000000000000004e-18

    1. Initial program 73.6%

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(x.im + \frac{x.re \cdot y.re}{y.im}\right), \color{blue}{y.im}\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \left(\frac{x.re \cdot y.re}{y.im}\right)\right), y.im\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(\left(x.re \cdot y.re\right), y.im\right)\right), y.im\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(\left(y.re \cdot x.re\right), y.im\right)\right), y.im\right) \]
      5. *-lowering-*.f6478.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(\mathsf{*.f64}\left(y.re, x.re\right), y.im\right)\right), y.im\right) \]
    5. Simplified78.8%

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \left(\frac{1}{\frac{y.im}{y.re \cdot x.re}}\right)\right), y.im\right) \]
      2. associate-/r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \left(\frac{1}{\frac{\frac{y.im}{y.re}}{x.re}}\right)\right), y.im\right) \]
      3. clear-numN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \left(\frac{x.re}{\frac{y.im}{y.re}}\right)\right), y.im\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(x.re, \left(\frac{y.im}{y.re}\right)\right)\right), y.im\right) \]
      5. /-lowering-/.f6477.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x.im, \mathsf{/.f64}\left(x.re, \mathsf{/.f64}\left(y.im, y.re\right)\right)\right), y.im\right) \]
    7. Applied egg-rr77.6%

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

Alternative 8: 63.2% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -9.5 \cdot 10^{-42}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq 4.7 \cdot 10^{-33}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (<= y.re -9.5e-42)
   (/ x.re y.re)
   (if (<= y.re 4.7e-33) (/ x.im y.im) (/ x.re y.re))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if (y_46_re <= -9.5e-42) {
		tmp = x_46_re / y_46_re;
	} else if (y_46_re <= 4.7e-33) {
		tmp = x_46_im / y_46_im;
	} else {
		tmp = x_46_re / y_46_re;
	}
	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) :: tmp
    if (y_46re <= (-9.5d-42)) then
        tmp = x_46re / y_46re
    else if (y_46re <= 4.7d-33) then
        tmp = x_46im / y_46im
    else
        tmp = x_46re / y_46re
    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 tmp;
	if (y_46_re <= -9.5e-42) {
		tmp = x_46_re / y_46_re;
	} else if (y_46_re <= 4.7e-33) {
		tmp = x_46_im / y_46_im;
	} else {
		tmp = x_46_re / y_46_re;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	tmp = 0
	if y_46_re <= -9.5e-42:
		tmp = x_46_re / y_46_re
	elif y_46_re <= 4.7e-33:
		tmp = x_46_im / y_46_im
	else:
		tmp = x_46_re / y_46_re
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0
	if (y_46_re <= -9.5e-42)
		tmp = Float64(x_46_re / y_46_re);
	elseif (y_46_re <= 4.7e-33)
		tmp = Float64(x_46_im / y_46_im);
	else
		tmp = Float64(x_46_re / y_46_re);
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0;
	if (y_46_re <= -9.5e-42)
		tmp = x_46_re / y_46_re;
	elseif (y_46_re <= 4.7e-33)
		tmp = x_46_im / y_46_im;
	else
		tmp = x_46_re / y_46_re;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -9.5e-42], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 4.7e-33], N[(x$46$im / y$46$im), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -9.5 \cdot 10^{-42}:\\
\;\;\;\;\frac{x.re}{y.re}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.re < -9.49999999999999948e-42 or 4.7000000000000002e-33 < y.re

    1. Initial program 52.6%

      \[\frac{x.re \cdot y.re + x.im \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.re}{y.re}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f6461.8%

        \[\leadsto \mathsf{/.f64}\left(x.re, \color{blue}{y.re}\right) \]
    5. Simplified61.8%

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

    if -9.49999999999999948e-42 < y.re < 4.7000000000000002e-33

    1. Initial program 72.9%

      \[\frac{x.re \cdot y.re + x.im \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}{\frac{x.im}{y.im}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f6471.9%

        \[\leadsto \mathsf{/.f64}\left(x.im, \color{blue}{y.im}\right) \]
    5. Simplified71.9%

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

Alternative 9: 42.8% accurate, 5.0× speedup?

\[\begin{array}{l} \\ \frac{x.im}{y.im} \end{array} \]
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ x.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_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_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_im;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	return x_46_im / y_46_im
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	return Float64(x_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_im;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(x$46$im / y$46$im), $MachinePrecision]
\begin{array}{l}

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

    \[\frac{x.re \cdot y.re + x.im \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}{\frac{x.im}{y.im}} \]
  4. Step-by-step derivation
    1. /-lowering-/.f6440.5%

      \[\leadsto \mathsf{/.f64}\left(x.im, \color{blue}{y.im}\right) \]
  5. Simplified40.5%

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

Reproduce

?
herbie shell --seed 2024159 
(FPCore (x.re x.im y.re y.im)
  :name "_divideComplex, real part"
  :precision binary64
  (/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im))))