_divideComplex, imaginary part

Percentage Accurate: 61.5% → 83.3%
Time: 10.1s
Alternatives: 9
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 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.5% accurate, 1.0× speedup?

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

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

Alternative 1: 83.3% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y.re \cdot y.re + y.im \cdot y.im\\ t_1 := \frac{x.re}{y.re \cdot \left(0 - y.re\right) - y.im \cdot y.im}\\ \mathbf{if}\;y.re \leq -9 \cdot 10^{+81}:\\ \;\;\;\;\frac{x.im}{y.re} - \frac{y.im}{y.re} \cdot \frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq -1.65 \cdot 10^{-161}:\\ \;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{t\_0}\\ \mathbf{elif}\;y.re \leq 3.8 \cdot 10^{-99}:\\ \;\;\;\;\frac{x.im \cdot \frac{y.re}{y.im} - x.re}{y.im}\\ \mathbf{elif}\;y.re \leq 1.02 \cdot 10^{+99}:\\ \;\;\;\;\mathsf{fma}\left(y.re, \frac{x.im}{t\_0}, y.im \cdot t\_1\right) + \mathsf{fma}\left(t\_1, y.im, y.im \cdot \frac{x.re}{t\_0}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re}\\ \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)))
        (t_1 (/ x.re (- (* y.re (- 0.0 y.re)) (* y.im y.im)))))
   (if (<= y.re -9e+81)
     (- (/ x.im y.re) (* (/ y.im y.re) (/ x.re y.re)))
     (if (<= y.re -1.65e-161)
       (/ (- (* y.re x.im) (* y.im x.re)) t_0)
       (if (<= y.re 3.8e-99)
         (/ (- (* x.im (/ y.re y.im)) x.re) y.im)
         (if (<= y.re 1.02e+99)
           (+
            (fma y.re (/ x.im t_0) (* y.im t_1))
            (fma t_1 y.im (* y.im (/ x.re t_0))))
           (/ (- x.im (* (/ y.im y.re) x.re)) y.re)))))))
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 t_1 = x_46_re / ((y_46_re * (0.0 - y_46_re)) - (y_46_im * y_46_im));
	double tmp;
	if (y_46_re <= -9e+81) {
		tmp = (x_46_im / y_46_re) - ((y_46_im / y_46_re) * (x_46_re / y_46_re));
	} else if (y_46_re <= -1.65e-161) {
		tmp = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / t_0;
	} else if (y_46_re <= 3.8e-99) {
		tmp = ((x_46_im * (y_46_re / y_46_im)) - x_46_re) / y_46_im;
	} else if (y_46_re <= 1.02e+99) {
		tmp = fma(y_46_re, (x_46_im / t_0), (y_46_im * t_1)) + fma(t_1, y_46_im, (y_46_im * (x_46_re / t_0)));
	} else {
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re;
	}
	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))
	t_1 = Float64(x_46_re / Float64(Float64(y_46_re * Float64(0.0 - y_46_re)) - Float64(y_46_im * y_46_im)))
	tmp = 0.0
	if (y_46_re <= -9e+81)
		tmp = Float64(Float64(x_46_im / y_46_re) - Float64(Float64(y_46_im / y_46_re) * Float64(x_46_re / y_46_re)));
	elseif (y_46_re <= -1.65e-161)
		tmp = Float64(Float64(Float64(y_46_re * x_46_im) - Float64(y_46_im * x_46_re)) / t_0);
	elseif (y_46_re <= 3.8e-99)
		tmp = Float64(Float64(Float64(x_46_im * Float64(y_46_re / y_46_im)) - x_46_re) / y_46_im);
	elseif (y_46_re <= 1.02e+99)
		tmp = Float64(fma(y_46_re, Float64(x_46_im / t_0), Float64(y_46_im * t_1)) + fma(t_1, y_46_im, Float64(y_46_im * Float64(x_46_re / t_0))));
	else
		tmp = Float64(Float64(x_46_im - Float64(Float64(y_46_im / y_46_re) * x_46_re)) / y_46_re);
	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]}, Block[{t$95$1 = N[(x$46$re / N[(N[(y$46$re * N[(0.0 - y$46$re), $MachinePrecision]), $MachinePrecision] - N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -9e+81], N[(N[(x$46$im / y$46$re), $MachinePrecision] - N[(N[(y$46$im / y$46$re), $MachinePrecision] * N[(x$46$re / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, -1.65e-161], N[(N[(N[(y$46$re * x$46$im), $MachinePrecision] - N[(y$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[y$46$re, 3.8e-99], N[(N[(N[(x$46$im * N[(y$46$re / y$46$im), $MachinePrecision]), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 1.02e+99], N[(N[(y$46$re * N[(x$46$im / t$95$0), $MachinePrecision] + N[(y$46$im * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * y$46$im + N[(y$46$im * N[(x$46$re / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im - N[(N[(y$46$im / y$46$re), $MachinePrecision] * x$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y.re \leq -1.65 \cdot 10^{-161}:\\
\;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{t\_0}\\

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

\mathbf{elif}\;y.re \leq 1.02 \cdot 10^{+99}:\\
\;\;\;\;\mathsf{fma}\left(y.re, \frac{x.im}{t\_0}, y.im \cdot t\_1\right) + \mathsf{fma}\left(t\_1, y.im, y.im \cdot \frac{x.re}{t\_0}\right)\\

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


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

    1. Initial program 36.5%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. 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.im \cdot y.re - x.re \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.im \cdot y.re - x.re \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.im \cdot y.re - x.re \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.im \cdot y.re} - x.re \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.im} \cdot y.re - x.re \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.im \cdot \color{blue}{y.re} - x.re \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.im \cdot y.re\right), \color{blue}{\left(x.re \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.im, y.re\right), \left(\color{blue}{x.re} \cdot y.im\right)\right)\right)\right) \]
      9. *-lowering-*.f6436.5%

        \[\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.im, y.re\right), \mathsf{*.f64}\left(x.re, \color{blue}{y.im}\right)\right)\right)\right) \]
    4. Applied egg-rr36.5%

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

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

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

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

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

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

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \left(\frac{\color{blue}{x.re \cdot y.im}}{{y.re}^{2}}\right)\right) \]
      6. associate-/l*N/A

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

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

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \mathsf{*.f64}\left(x.re, \mathsf{/.f64}\left(y.im, \color{blue}{\left({y.re}^{2}\right)}\right)\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \mathsf{*.f64}\left(x.re, \mathsf{/.f64}\left(y.im, \left(y.re \cdot \color{blue}{y.re}\right)\right)\right)\right) \]
      10. *-lowering-*.f6471.9%

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

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

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

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \left(\frac{y.im \cdot x.re}{\color{blue}{y.re} \cdot y.re}\right)\right) \]
      3. times-fracN/A

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

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

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \mathsf{*.f64}\left(\mathsf{/.f64}\left(y.im, y.re\right), \left(\frac{\color{blue}{x.re}}{y.re}\right)\right)\right) \]
      6. /-lowering-/.f6479.6%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \mathsf{*.f64}\left(\mathsf{/.f64}\left(y.im, y.re\right), \mathsf{/.f64}\left(x.re, \color{blue}{y.re}\right)\right)\right) \]
    9. Applied egg-rr79.6%

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

    if -9.00000000000000034e81 < y.re < -1.6499999999999999e-161

    1. Initial program 81.2%

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

    if -1.6499999999999999e-161 < y.re < 3.7999999999999997e-99

    1. Initial program 79.6%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{x.im \cdot y.re}{y.im}\right), x.re\right), y.im\right) \]
      9. associate-/l*N/A

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(x.im, \left(\frac{y.re}{y.im}\right)\right), x.re\right), y.im\right) \]
      11. /-lowering-/.f6496.3%

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

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

    if 3.7999999999999997e-99 < y.re < 1.01999999999999998e99

    1. Initial program 85.4%

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

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

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

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

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

        \[\leadsto y.re \cdot \frac{x.im}{y.re \cdot y.re + y.im \cdot y.im} - y.im \cdot \color{blue}{\frac{x.re}{y.re \cdot y.re + y.im \cdot y.im}} \]
      6. prod-diffN/A

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

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

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

    if 1.01999999999999998e99 < y.re

    1. Initial program 45.0%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{y.re \cdot y.re + y.im \cdot y.im}{x.im \cdot y.re - x.re \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.im \cdot y.re - x.re \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.im \cdot y.re - x.re \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.im \cdot y.re} - x.re \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.im} \cdot y.re - x.re \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.im \cdot \color{blue}{y.re} - x.re \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.im \cdot y.re\right), \color{blue}{\left(x.re \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.im, y.re\right), \left(\color{blue}{x.re} \cdot y.im\right)\right)\right)\right) \]
      9. *-lowering-*.f6443.6%

        \[\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.im, y.re\right), \mathsf{*.f64}\left(x.re, \color{blue}{y.im}\right)\right)\right)\right) \]
    4. Applied egg-rr43.6%

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x.im, \left(\frac{x.re \cdot y.im}{y.re}\right)\right), y.re\right) \]
      5. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x.im, \left(x.re \cdot \frac{y.im}{y.re}\right)\right), y.re\right) \]
      6. *-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.re\right) \]
      7. /-lowering-/.f6486.2%

        \[\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.re\right) \]
    7. Simplified86.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -9 \cdot 10^{+81}:\\ \;\;\;\;\frac{x.im}{y.re} - \frac{y.im}{y.re} \cdot \frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq -1.65 \cdot 10^{-161}:\\ \;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.re \leq 3.8 \cdot 10^{-99}:\\ \;\;\;\;\frac{x.im \cdot \frac{y.re}{y.im} - x.re}{y.im}\\ \mathbf{elif}\;y.re \leq 1.02 \cdot 10^{+99}:\\ \;\;\;\;\mathsf{fma}\left(y.re, \frac{x.im}{y.re \cdot y.re + y.im \cdot y.im}, y.im \cdot \frac{x.re}{y.re \cdot \left(0 - y.re\right) - y.im \cdot y.im}\right) + \mathsf{fma}\left(\frac{x.re}{y.re \cdot \left(0 - y.re\right) - y.im \cdot y.im}, y.im, y.im \cdot \frac{x.re}{y.re \cdot y.re + y.im \cdot y.im}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 82.6% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y.re \cdot y.re + y.im \cdot y.im\\ \mathbf{if}\;y.re \leq -8.5 \cdot 10^{+82}:\\ \;\;\;\;\frac{x.im}{y.re} - \frac{y.im}{y.re} \cdot \frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq -1.95 \cdot 10^{-162}:\\ \;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{t\_0}\\ \mathbf{elif}\;y.re \leq 1.5 \cdot 10^{-99}:\\ \;\;\;\;\frac{x.im \cdot \frac{y.re}{y.im} - x.re}{y.im}\\ \mathbf{elif}\;y.re \leq 7 \cdot 10^{+120}:\\ \;\;\;\;x.im \cdot \left(\frac{y.re}{t\_0} - \frac{\frac{y.im \cdot x.re}{x.im}}{t\_0}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re}\\ \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 -8.5e+82)
     (- (/ x.im y.re) (* (/ y.im y.re) (/ x.re y.re)))
     (if (<= y.re -1.95e-162)
       (/ (- (* y.re x.im) (* y.im x.re)) t_0)
       (if (<= y.re 1.5e-99)
         (/ (- (* x.im (/ y.re y.im)) x.re) y.im)
         (if (<= y.re 7e+120)
           (* x.im (- (/ y.re t_0) (/ (/ (* y.im x.re) x.im) t_0)))
           (/ (- x.im (* (/ y.im y.re) x.re)) y.re)))))))
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 <= -8.5e+82) {
		tmp = (x_46_im / y_46_re) - ((y_46_im / y_46_re) * (x_46_re / y_46_re));
	} else if (y_46_re <= -1.95e-162) {
		tmp = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / t_0;
	} else if (y_46_re <= 1.5e-99) {
		tmp = ((x_46_im * (y_46_re / y_46_im)) - x_46_re) / y_46_im;
	} else if (y_46_re <= 7e+120) {
		tmp = x_46_im * ((y_46_re / t_0) - (((y_46_im * x_46_re) / x_46_im) / t_0));
	} else {
		tmp = (x_46_im - ((y_46_im / y_46_re) * 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) :: t_0
    real(8) :: tmp
    t_0 = (y_46re * y_46re) + (y_46im * y_46im)
    if (y_46re <= (-8.5d+82)) then
        tmp = (x_46im / y_46re) - ((y_46im / y_46re) * (x_46re / y_46re))
    else if (y_46re <= (-1.95d-162)) then
        tmp = ((y_46re * x_46im) - (y_46im * x_46re)) / t_0
    else if (y_46re <= 1.5d-99) then
        tmp = ((x_46im * (y_46re / y_46im)) - x_46re) / y_46im
    else if (y_46re <= 7d+120) then
        tmp = x_46im * ((y_46re / t_0) - (((y_46im * x_46re) / x_46im) / t_0))
    else
        tmp = (x_46im - ((y_46im / y_46re) * 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 t_0 = (y_46_re * y_46_re) + (y_46_im * y_46_im);
	double tmp;
	if (y_46_re <= -8.5e+82) {
		tmp = (x_46_im / y_46_re) - ((y_46_im / y_46_re) * (x_46_re / y_46_re));
	} else if (y_46_re <= -1.95e-162) {
		tmp = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / t_0;
	} else if (y_46_re <= 1.5e-99) {
		tmp = ((x_46_im * (y_46_re / y_46_im)) - x_46_re) / y_46_im;
	} else if (y_46_re <= 7e+120) {
		tmp = x_46_im * ((y_46_re / t_0) - (((y_46_im * x_46_re) / x_46_im) / t_0));
	} else {
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = (y_46_re * y_46_re) + (y_46_im * y_46_im)
	tmp = 0
	if y_46_re <= -8.5e+82:
		tmp = (x_46_im / y_46_re) - ((y_46_im / y_46_re) * (x_46_re / y_46_re))
	elif y_46_re <= -1.95e-162:
		tmp = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / t_0
	elif y_46_re <= 1.5e-99:
		tmp = ((x_46_im * (y_46_re / y_46_im)) - x_46_re) / y_46_im
	elif y_46_re <= 7e+120:
		tmp = x_46_im * ((y_46_re / t_0) - (((y_46_im * x_46_re) / x_46_im) / t_0))
	else:
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re
	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 <= -8.5e+82)
		tmp = Float64(Float64(x_46_im / y_46_re) - Float64(Float64(y_46_im / y_46_re) * Float64(x_46_re / y_46_re)));
	elseif (y_46_re <= -1.95e-162)
		tmp = Float64(Float64(Float64(y_46_re * x_46_im) - Float64(y_46_im * x_46_re)) / t_0);
	elseif (y_46_re <= 1.5e-99)
		tmp = Float64(Float64(Float64(x_46_im * Float64(y_46_re / y_46_im)) - x_46_re) / y_46_im);
	elseif (y_46_re <= 7e+120)
		tmp = Float64(x_46_im * Float64(Float64(y_46_re / t_0) - Float64(Float64(Float64(y_46_im * x_46_re) / x_46_im) / t_0)));
	else
		tmp = Float64(Float64(x_46_im - Float64(Float64(y_46_im / y_46_re) * 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)
	t_0 = (y_46_re * y_46_re) + (y_46_im * y_46_im);
	tmp = 0.0;
	if (y_46_re <= -8.5e+82)
		tmp = (x_46_im / y_46_re) - ((y_46_im / y_46_re) * (x_46_re / y_46_re));
	elseif (y_46_re <= -1.95e-162)
		tmp = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / t_0;
	elseif (y_46_re <= 1.5e-99)
		tmp = ((x_46_im * (y_46_re / y_46_im)) - x_46_re) / y_46_im;
	elseif (y_46_re <= 7e+120)
		tmp = x_46_im * ((y_46_re / t_0) - (((y_46_im * x_46_re) / x_46_im) / t_0));
	else
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re;
	end
	tmp_2 = 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, -8.5e+82], N[(N[(x$46$im / y$46$re), $MachinePrecision] - N[(N[(y$46$im / y$46$re), $MachinePrecision] * N[(x$46$re / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, -1.95e-162], N[(N[(N[(y$46$re * x$46$im), $MachinePrecision] - N[(y$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[y$46$re, 1.5e-99], N[(N[(N[(x$46$im * N[(y$46$re / y$46$im), $MachinePrecision]), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 7e+120], N[(x$46$im * N[(N[(y$46$re / t$95$0), $MachinePrecision] - N[(N[(N[(y$46$im * x$46$re), $MachinePrecision] / x$46$im), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im - N[(N[(y$46$im / y$46$re), $MachinePrecision] * x$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y.re \leq -1.95 \cdot 10^{-162}:\\
\;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{t\_0}\\

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

\mathbf{elif}\;y.re \leq 7 \cdot 10^{+120}:\\
\;\;\;\;x.im \cdot \left(\frac{y.re}{t\_0} - \frac{\frac{y.im \cdot x.re}{x.im}}{t\_0}\right)\\

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


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

    1. Initial program 36.5%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. 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.im \cdot y.re - x.re \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.im \cdot y.re - x.re \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.im \cdot y.re - x.re \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.im \cdot y.re} - x.re \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.im} \cdot y.re - x.re \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.im \cdot \color{blue}{y.re} - x.re \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.im \cdot y.re\right), \color{blue}{\left(x.re \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.im, y.re\right), \left(\color{blue}{x.re} \cdot y.im\right)\right)\right)\right) \]
      9. *-lowering-*.f6436.5%

        \[\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.im, y.re\right), \mathsf{*.f64}\left(x.re, \color{blue}{y.im}\right)\right)\right)\right) \]
    4. Applied egg-rr36.5%

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

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

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

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

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

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

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \left(\frac{\color{blue}{x.re \cdot y.im}}{{y.re}^{2}}\right)\right) \]
      6. associate-/l*N/A

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

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

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \mathsf{*.f64}\left(x.re, \mathsf{/.f64}\left(y.im, \color{blue}{\left({y.re}^{2}\right)}\right)\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \mathsf{*.f64}\left(x.re, \mathsf{/.f64}\left(y.im, \left(y.re \cdot \color{blue}{y.re}\right)\right)\right)\right) \]
      10. *-lowering-*.f6471.9%

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

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

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

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \left(\frac{y.im \cdot x.re}{\color{blue}{y.re} \cdot y.re}\right)\right) \]
      3. times-fracN/A

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

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

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \mathsf{*.f64}\left(\mathsf{/.f64}\left(y.im, y.re\right), \left(\frac{\color{blue}{x.re}}{y.re}\right)\right)\right) \]
      6. /-lowering-/.f6479.6%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \mathsf{*.f64}\left(\mathsf{/.f64}\left(y.im, y.re\right), \mathsf{/.f64}\left(x.re, \color{blue}{y.re}\right)\right)\right) \]
    9. Applied egg-rr79.6%

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

    if -8.4999999999999995e82 < y.re < -1.95e-162

    1. Initial program 81.2%

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

    if -1.95e-162 < y.re < 1.50000000000000003e-99

    1. Initial program 79.6%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{x.im \cdot y.re}{y.im}\right), x.re\right), y.im\right) \]
      9. associate-/l*N/A

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(x.im, \left(\frac{y.re}{y.im}\right)\right), x.re\right), y.im\right) \]
      11. /-lowering-/.f6496.3%

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

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

    if 1.50000000000000003e-99 < y.re < 7.00000000000000015e120

    1. Initial program 83.6%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(x.im, \left(0 - \color{blue}{\left(-1 \cdot \frac{y.re}{{y.im}^{2} + {y.re}^{2}} + \frac{x.re \cdot y.im}{x.im \cdot \left({y.im}^{2} + {y.re}^{2}\right)}\right)}\right)\right) \]
    5. Simplified85.8%

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

    if 7.00000000000000015e120 < y.re

    1. Initial program 42.4%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. 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.im \cdot y.re - x.re \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.im \cdot y.re - x.re \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.im \cdot y.re - x.re \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.im \cdot y.re} - x.re \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.im} \cdot y.re - x.re \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.im \cdot \color{blue}{y.re} - x.re \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.im \cdot y.re\right), \color{blue}{\left(x.re \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.im, y.re\right), \left(\color{blue}{x.re} \cdot y.im\right)\right)\right)\right) \]
      9. *-lowering-*.f6440.9%

        \[\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.im, y.re\right), \mathsf{*.f64}\left(x.re, \color{blue}{y.im}\right)\right)\right)\right) \]
    4. Applied egg-rr40.9%

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x.im, \left(\frac{x.re \cdot y.im}{y.re}\right)\right), y.re\right) \]
      5. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x.im, \left(x.re \cdot \frac{y.im}{y.re}\right)\right), y.re\right) \]
      6. *-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.re\right) \]
      7. /-lowering-/.f6488.9%

        \[\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.re\right) \]
    7. Simplified88.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -8.5 \cdot 10^{+82}:\\ \;\;\;\;\frac{x.im}{y.re} - \frac{y.im}{y.re} \cdot \frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq -1.95 \cdot 10^{-162}:\\ \;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.re \leq 1.5 \cdot 10^{-99}:\\ \;\;\;\;\frac{x.im \cdot \frac{y.re}{y.im} - x.re}{y.im}\\ \mathbf{elif}\;y.re \leq 7 \cdot 10^{+120}:\\ \;\;\;\;x.im \cdot \left(\frac{y.re}{y.re \cdot y.re + y.im \cdot y.im} - \frac{\frac{y.im \cdot x.re}{x.im}}{y.re \cdot y.re + y.im \cdot y.im}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 83.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{if}\;y.re \leq -8.8 \cdot 10^{+80}:\\ \;\;\;\;\frac{x.im}{y.re} - \frac{y.im}{y.re} \cdot \frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq -1.65 \cdot 10^{-161}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.re \leq 1.3 \cdot 10^{-99}:\\ \;\;\;\;\frac{x.im \cdot \frac{y.re}{y.im} - x.re}{y.im}\\ \mathbf{elif}\;y.re \leq 9.2 \cdot 10^{+129}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0
         (/ (- (* y.re x.im) (* y.im x.re)) (+ (* y.re y.re) (* y.im y.im)))))
   (if (<= y.re -8.8e+80)
     (- (/ x.im y.re) (* (/ y.im y.re) (/ x.re y.re)))
     (if (<= y.re -1.65e-161)
       t_0
       (if (<= y.re 1.3e-99)
         (/ (- (* x.im (/ y.re y.im)) x.re) y.im)
         (if (<= y.re 9.2e+129)
           t_0
           (/ (- x.im (* (/ y.im y.re) x.re)) y.re)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	double tmp;
	if (y_46_re <= -8.8e+80) {
		tmp = (x_46_im / y_46_re) - ((y_46_im / y_46_re) * (x_46_re / y_46_re));
	} else if (y_46_re <= -1.65e-161) {
		tmp = t_0;
	} else if (y_46_re <= 1.3e-99) {
		tmp = ((x_46_im * (y_46_re / y_46_im)) - x_46_re) / y_46_im;
	} else if (y_46_re <= 9.2e+129) {
		tmp = t_0;
	} else {
		tmp = (x_46_im - ((y_46_im / y_46_re) * 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) :: t_0
    real(8) :: tmp
    t_0 = ((y_46re * x_46im) - (y_46im * x_46re)) / ((y_46re * y_46re) + (y_46im * y_46im))
    if (y_46re <= (-8.8d+80)) then
        tmp = (x_46im / y_46re) - ((y_46im / y_46re) * (x_46re / y_46re))
    else if (y_46re <= (-1.65d-161)) then
        tmp = t_0
    else if (y_46re <= 1.3d-99) then
        tmp = ((x_46im * (y_46re / y_46im)) - x_46re) / y_46im
    else if (y_46re <= 9.2d+129) then
        tmp = t_0
    else
        tmp = (x_46im - ((y_46im / y_46re) * 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 t_0 = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	double tmp;
	if (y_46_re <= -8.8e+80) {
		tmp = (x_46_im / y_46_re) - ((y_46_im / y_46_re) * (x_46_re / y_46_re));
	} else if (y_46_re <= -1.65e-161) {
		tmp = t_0;
	} else if (y_46_re <= 1.3e-99) {
		tmp = ((x_46_im * (y_46_re / y_46_im)) - x_46_re) / y_46_im;
	} else if (y_46_re <= 9.2e+129) {
		tmp = t_0;
	} else {
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
	tmp = 0
	if y_46_re <= -8.8e+80:
		tmp = (x_46_im / y_46_re) - ((y_46_im / y_46_re) * (x_46_re / y_46_re))
	elif y_46_re <= -1.65e-161:
		tmp = t_0
	elif y_46_re <= 1.3e-99:
		tmp = ((x_46_im * (y_46_re / y_46_im)) - x_46_re) / y_46_im
	elif y_46_re <= 9.2e+129:
		tmp = t_0
	else:
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(Float64(y_46_re * x_46_im) - Float64(y_46_im * x_46_re)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)))
	tmp = 0.0
	if (y_46_re <= -8.8e+80)
		tmp = Float64(Float64(x_46_im / y_46_re) - Float64(Float64(y_46_im / y_46_re) * Float64(x_46_re / y_46_re)));
	elseif (y_46_re <= -1.65e-161)
		tmp = t_0;
	elseif (y_46_re <= 1.3e-99)
		tmp = Float64(Float64(Float64(x_46_im * Float64(y_46_re / y_46_im)) - x_46_re) / y_46_im);
	elseif (y_46_re <= 9.2e+129)
		tmp = t_0;
	else
		tmp = Float64(Float64(x_46_im - Float64(Float64(y_46_im / y_46_re) * 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)
	t_0 = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	tmp = 0.0;
	if (y_46_re <= -8.8e+80)
		tmp = (x_46_im / y_46_re) - ((y_46_im / y_46_re) * (x_46_re / y_46_re));
	elseif (y_46_re <= -1.65e-161)
		tmp = t_0;
	elseif (y_46_re <= 1.3e-99)
		tmp = ((x_46_im * (y_46_re / y_46_im)) - x_46_re) / y_46_im;
	elseif (y_46_re <= 9.2e+129)
		tmp = t_0;
	else
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(N[(y$46$re * x$46$im), $MachinePrecision] - N[(y$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -8.8e+80], N[(N[(x$46$im / y$46$re), $MachinePrecision] - N[(N[(y$46$im / y$46$re), $MachinePrecision] * N[(x$46$re / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, -1.65e-161], t$95$0, If[LessEqual[y$46$re, 1.3e-99], N[(N[(N[(x$46$im * N[(y$46$re / y$46$im), $MachinePrecision]), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 9.2e+129], t$95$0, N[(N[(x$46$im - N[(N[(y$46$im / y$46$re), $MachinePrecision] * x$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]]]]]]
\begin{array}{l}

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

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

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

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

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


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

    1. Initial program 36.5%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. 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.im \cdot y.re - x.re \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.im \cdot y.re - x.re \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.im \cdot y.re - x.re \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.im \cdot y.re} - x.re \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.im} \cdot y.re - x.re \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.im \cdot \color{blue}{y.re} - x.re \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.im \cdot y.re\right), \color{blue}{\left(x.re \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.im, y.re\right), \left(\color{blue}{x.re} \cdot y.im\right)\right)\right)\right) \]
      9. *-lowering-*.f6436.5%

        \[\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.im, y.re\right), \mathsf{*.f64}\left(x.re, \color{blue}{y.im}\right)\right)\right)\right) \]
    4. Applied egg-rr36.5%

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

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

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

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

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

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

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \left(\frac{\color{blue}{x.re \cdot y.im}}{{y.re}^{2}}\right)\right) \]
      6. associate-/l*N/A

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

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

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \mathsf{*.f64}\left(x.re, \mathsf{/.f64}\left(y.im, \color{blue}{\left({y.re}^{2}\right)}\right)\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \mathsf{*.f64}\left(x.re, \mathsf{/.f64}\left(y.im, \left(y.re \cdot \color{blue}{y.re}\right)\right)\right)\right) \]
      10. *-lowering-*.f6471.9%

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

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

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

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \left(\frac{y.im \cdot x.re}{\color{blue}{y.re} \cdot y.re}\right)\right) \]
      3. times-fracN/A

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

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

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \mathsf{*.f64}\left(\mathsf{/.f64}\left(y.im, y.re\right), \left(\frac{\color{blue}{x.re}}{y.re}\right)\right)\right) \]
      6. /-lowering-/.f6479.6%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(x.im, y.re\right), \mathsf{*.f64}\left(\mathsf{/.f64}\left(y.im, y.re\right), \mathsf{/.f64}\left(x.re, \color{blue}{y.re}\right)\right)\right) \]
    9. Applied egg-rr79.6%

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

    if -8.80000000000000011e80 < y.re < -1.6499999999999999e-161 or 1.30000000000000003e-99 < y.re < 9.19999999999999961e129

    1. Initial program 82.1%

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

    if -1.6499999999999999e-161 < y.re < 1.30000000000000003e-99

    1. Initial program 79.6%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{x.im \cdot y.re}{y.im}\right), x.re\right), y.im\right) \]
      9. associate-/l*N/A

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(x.im, \left(\frac{y.re}{y.im}\right)\right), x.re\right), y.im\right) \]
      11. /-lowering-/.f6496.3%

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

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

    if 9.19999999999999961e129 < y.re

    1. Initial program 39.2%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. 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.im \cdot y.re - x.re \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.im \cdot y.re - x.re \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.im \cdot y.re - x.re \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.im \cdot y.re} - x.re \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.im} \cdot y.re - x.re \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.im \cdot \color{blue}{y.re} - x.re \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.im \cdot y.re\right), \color{blue}{\left(x.re \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.im, y.re\right), \left(\color{blue}{x.re} \cdot y.im\right)\right)\right)\right) \]
      9. *-lowering-*.f6439.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.im, y.re\right), \mathsf{*.f64}\left(x.re, \color{blue}{y.im}\right)\right)\right)\right) \]
    4. Applied egg-rr39.2%

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x.im, \left(\frac{x.re \cdot y.im}{y.re}\right)\right), y.re\right) \]
      5. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x.im, \left(x.re \cdot \frac{y.im}{y.re}\right)\right), y.re\right) \]
      6. *-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.re\right) \]
      7. /-lowering-/.f6490.2%

        \[\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.re\right) \]
    7. Simplified90.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -8.8 \cdot 10^{+80}:\\ \;\;\;\;\frac{x.im}{y.re} - \frac{y.im}{y.re} \cdot \frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq -1.65 \cdot 10^{-161}:\\ \;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.re \leq 1.3 \cdot 10^{-99}:\\ \;\;\;\;\frac{x.im \cdot \frac{y.re}{y.im} - x.re}{y.im}\\ \mathbf{elif}\;y.re \leq 9.2 \cdot 10^{+129}:\\ \;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 78.3% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -2.1 \cdot 10^{-26}:\\
\;\;\;\;\frac{x.im \cdot \left(y.re \cdot \frac{1}{y.im}\right) - x.re}{y.im}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.im < -2.10000000000000008e-26

    1. Initial program 66.6%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{x.im \cdot y.re}{y.im}\right), x.re\right), y.im\right) \]
      9. associate-/l*N/A

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(x.im, \left(\frac{y.re}{y.im}\right)\right), x.re\right), y.im\right) \]
      11. /-lowering-/.f6478.3%

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(x.im, \mathsf{*.f64}\left(\left(\frac{1}{y.im}\right), y.re\right)\right), x.re\right), y.im\right) \]
      4. metadata-evalN/A

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(x.im, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\mathsf{neg}\left(-1\right)\right), y.im\right), y.re\right)\right), x.re\right), y.im\right) \]
      6. metadata-eval78.3%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(x.im, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, y.im\right), y.re\right)\right), x.re\right), y.im\right) \]
    7. Applied egg-rr78.3%

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

    if -2.10000000000000008e-26 < y.im < 3.3000000000000002e-7

    1. Initial program 73.8%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. 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.im \cdot y.re - x.re \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.im \cdot y.re - x.re \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.im \cdot y.re - x.re \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.im \cdot y.re} - x.re \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.im} \cdot y.re - x.re \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.im \cdot \color{blue}{y.re} - x.re \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.im \cdot y.re\right), \color{blue}{\left(x.re \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.im, y.re\right), \left(\color{blue}{x.re} \cdot y.im\right)\right)\right)\right) \]
      9. *-lowering-*.f6473.1%

        \[\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.im, y.re\right), \mathsf{*.f64}\left(x.re, \color{blue}{y.im}\right)\right)\right)\right) \]
    4. Applied egg-rr73.1%

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x.im, \left(\frac{x.re \cdot y.im}{y.re}\right)\right), y.re\right) \]
      5. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x.im, \left(x.re \cdot \frac{y.im}{y.re}\right)\right), y.re\right) \]
      6. *-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.re\right) \]
      7. /-lowering-/.f6484.4%

        \[\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.re\right) \]
    7. Simplified84.4%

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

    if 3.3000000000000002e-7 < y.im

    1. Initial program 57.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{x.im \cdot y.re}{y.im}\right), x.re\right), y.im\right) \]
      9. associate-/l*N/A

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -2.1 \cdot 10^{-26}:\\ \;\;\;\;\frac{x.im \cdot \left(y.re \cdot \frac{1}{y.im}\right) - x.re}{y.im}\\ \mathbf{elif}\;y.im \leq 3.3 \cdot 10^{-7}:\\ \;\;\;\;\frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im \cdot \frac{y.re}{y.im}}{y.im} - \frac{x.re}{y.im}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 78.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.im \cdot \frac{y.re}{y.im}\\ \mathbf{if}\;y.im \leq -1.45 \cdot 10^{-26}:\\ \;\;\;\;\frac{t\_0 - x.re}{y.im}\\ \mathbf{elif}\;y.im \leq 3.1 \cdot 10^{-8}:\\ \;\;\;\;\frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_0}{y.im} - \frac{x.re}{y.im}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (* x.im (/ y.re y.im))))
   (if (<= y.im -1.45e-26)
     (/ (- t_0 x.re) y.im)
     (if (<= y.im 3.1e-8)
       (/ (- x.im (* (/ y.im y.re) x.re)) y.re)
       (- (/ t_0 y.im) (/ x.re y.im))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = x_46_im * (y_46_re / y_46_im);
	double tmp;
	if (y_46_im <= -1.45e-26) {
		tmp = (t_0 - x_46_re) / y_46_im;
	} else if (y_46_im <= 3.1e-8) {
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re;
	} else {
		tmp = (t_0 / y_46_im) - (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 = x_46im * (y_46re / y_46im)
    if (y_46im <= (-1.45d-26)) then
        tmp = (t_0 - x_46re) / y_46im
    else if (y_46im <= 3.1d-8) then
        tmp = (x_46im - ((y_46im / y_46re) * x_46re)) / y_46re
    else
        tmp = (t_0 / y_46im) - (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 / y_46_im);
	double tmp;
	if (y_46_im <= -1.45e-26) {
		tmp = (t_0 - x_46_re) / y_46_im;
	} else if (y_46_im <= 3.1e-8) {
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re;
	} else {
		tmp = (t_0 / y_46_im) - (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 / y_46_im)
	tmp = 0
	if y_46_im <= -1.45e-26:
		tmp = (t_0 - x_46_re) / y_46_im
	elif y_46_im <= 3.1e-8:
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re
	else:
		tmp = (t_0 / y_46_im) - (x_46_re / y_46_im)
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(x_46_im * Float64(y_46_re / y_46_im))
	tmp = 0.0
	if (y_46_im <= -1.45e-26)
		tmp = Float64(Float64(t_0 - x_46_re) / y_46_im);
	elseif (y_46_im <= 3.1e-8)
		tmp = Float64(Float64(x_46_im - Float64(Float64(y_46_im / y_46_re) * x_46_re)) / y_46_re);
	else
		tmp = Float64(Float64(t_0 / y_46_im) - 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 / y_46_im);
	tmp = 0.0;
	if (y_46_im <= -1.45e-26)
		tmp = (t_0 - x_46_re) / y_46_im;
	elseif (y_46_im <= 3.1e-8)
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re;
	else
		tmp = (t_0 / y_46_im) - (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[(x$46$im * N[(y$46$re / y$46$im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$im, -1.45e-26], N[(N[(t$95$0 - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 3.1e-8], N[(N[(x$46$im - N[(N[(y$46$im / y$46$re), $MachinePrecision] * x$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], N[(N[(t$95$0 / y$46$im), $MachinePrecision] - N[(x$46$re / y$46$im), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.im < -1.4499999999999999e-26

    1. Initial program 66.6%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{x.im \cdot y.re}{y.im}\right), x.re\right), y.im\right) \]
      9. associate-/l*N/A

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(x.im, \left(\frac{y.re}{y.im}\right)\right), x.re\right), y.im\right) \]
      11. /-lowering-/.f6478.3%

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

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

    if -1.4499999999999999e-26 < y.im < 3.1e-8

    1. Initial program 73.8%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. 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.im \cdot y.re - x.re \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.im \cdot y.re - x.re \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.im \cdot y.re - x.re \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.im \cdot y.re} - x.re \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.im} \cdot y.re - x.re \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.im \cdot \color{blue}{y.re} - x.re \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.im \cdot y.re\right), \color{blue}{\left(x.re \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.im, y.re\right), \left(\color{blue}{x.re} \cdot y.im\right)\right)\right)\right) \]
      9. *-lowering-*.f6473.1%

        \[\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.im, y.re\right), \mathsf{*.f64}\left(x.re, \color{blue}{y.im}\right)\right)\right)\right) \]
    4. Applied egg-rr73.1%

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x.im, \left(\frac{x.re \cdot y.im}{y.re}\right)\right), y.re\right) \]
      5. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x.im, \left(x.re \cdot \frac{y.im}{y.re}\right)\right), y.re\right) \]
      6. *-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.re\right) \]
      7. /-lowering-/.f6484.4%

        \[\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.re\right) \]
    7. Simplified84.4%

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

    if 3.1e-8 < y.im

    1. Initial program 57.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{x.im \cdot y.re}{y.im}\right), x.re\right), y.im\right) \]
      9. associate-/l*N/A

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -1.45 \cdot 10^{-26}:\\ \;\;\;\;\frac{x.im \cdot \frac{y.re}{y.im} - x.re}{y.im}\\ \mathbf{elif}\;y.im \leq 3.1 \cdot 10^{-8}:\\ \;\;\;\;\frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im \cdot \frac{y.re}{y.im}}{y.im} - \frac{x.re}{y.im}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 78.3% accurate, 0.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < -9.50000000000000037e-27 or 4.00000000000000033e-5 < y.im

    1. Initial program 62.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{x.im \cdot y.re}{y.im}\right), x.re\right), y.im\right) \]
      9. associate-/l*N/A

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(x.im, \left(\frac{y.re}{y.im}\right)\right), x.re\right), y.im\right) \]
      11. /-lowering-/.f6479.5%

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

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

    if -9.50000000000000037e-27 < y.im < 4.00000000000000033e-5

    1. Initial program 73.8%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. 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.im \cdot y.re - x.re \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.im \cdot y.re - x.re \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.im \cdot y.re - x.re \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.im \cdot y.re} - x.re \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.im} \cdot y.re - x.re \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.im \cdot \color{blue}{y.re} - x.re \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.im \cdot y.re\right), \color{blue}{\left(x.re \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.im, y.re\right), \left(\color{blue}{x.re} \cdot y.im\right)\right)\right)\right) \]
      9. *-lowering-*.f6473.1%

        \[\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.im, y.re\right), \mathsf{*.f64}\left(x.re, \color{blue}{y.im}\right)\right)\right)\right) \]
    4. Applied egg-rr73.1%

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x.im, \left(\frac{x.re \cdot y.im}{y.re}\right)\right), y.re\right) \]
      5. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x.im, \left(x.re \cdot \frac{y.im}{y.re}\right)\right), y.re\right) \]
      6. *-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.re\right) \]
      7. /-lowering-/.f6484.4%

        \[\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.re\right) \]
    7. Simplified84.4%

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

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

Alternative 7: 72.1% accurate, 0.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < -1.5499999999999999e-34 or 6.4000000000000004 < y.im

    1. Initial program 62.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(x.re, \left(0 - \color{blue}{\left(-1 \cdot \frac{x.im \cdot y.re}{x.re \cdot \left({y.im}^{2} + {y.re}^{2}\right)} + \frac{y.im}{{y.im}^{2} + {y.re}^{2}}\right)}\right)\right) \]
    5. Simplified60.6%

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

      \[\leadsto \mathsf{*.f64}\left(x.re, \color{blue}{\left(\frac{-1}{y.im}\right)}\right) \]
    7. Step-by-step derivation
      1. /-lowering-/.f6468.7%

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

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

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

        \[\leadsto \frac{x.re}{\color{blue}{\frac{y.im}{-1}}} \]
      3. clear-numN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{y.im}{-1}}{x.re}}} \]
      4. metadata-evalN/A

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

        \[\leadsto \mathsf{/.f64}\left(\left(\mathsf{neg}\left(-1\right)\right), \color{blue}{\left(\frac{\frac{y.im}{-1}}{x.re}\right)}\right) \]
      6. metadata-evalN/A

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

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

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{/.f64}\left(y.im, -1\right), x.re\right)\right) \]
    10. Applied egg-rr67.4%

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

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

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

        \[\leadsto \frac{x.re}{\frac{\mathsf{neg}\left(y.im\right)}{1}} \]
      4. /-rgt-identityN/A

        \[\leadsto \frac{x.re}{\mathsf{neg}\left(y.im\right)} \]
      5. distribute-frac-neg2N/A

        \[\leadsto \mathsf{neg}\left(\frac{x.re}{y.im}\right) \]
      6. neg-lowering-neg.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\left(\frac{x.re}{y.im}\right)\right) \]
      7. /-lowering-/.f6468.8%

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(x.re, y.im\right)\right) \]
    12. Applied egg-rr68.8%

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

    if -1.5499999999999999e-34 < y.im < 6.4000000000000004

    1. Initial program 74.5%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. 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.im \cdot y.re - x.re \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.im \cdot y.re - x.re \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.im \cdot y.re - x.re \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.im \cdot y.re} - x.re \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.im} \cdot y.re - x.re \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.im \cdot \color{blue}{y.re} - x.re \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.im \cdot y.re\right), \color{blue}{\left(x.re \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.im, y.re\right), \left(\color{blue}{x.re} \cdot y.im\right)\right)\right)\right) \]
      9. *-lowering-*.f6473.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.im, y.re\right), \mathsf{*.f64}\left(x.re, \color{blue}{y.im}\right)\right)\right)\right) \]
    4. Applied egg-rr73.8%

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x.im, \left(\frac{x.re \cdot y.im}{y.re}\right)\right), y.re\right) \]
      5. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x.im, \left(x.re \cdot \frac{y.im}{y.re}\right)\right), y.re\right) \]
      6. *-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.re\right) \]
      7. /-lowering-/.f6484.3%

        \[\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.re\right) \]
    7. Simplified84.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -1.55 \cdot 10^{-34}:\\ \;\;\;\;0 - \frac{x.re}{y.im}\\ \mathbf{elif}\;y.im \leq 6.4:\\ \;\;\;\;\frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re}\\ \mathbf{else}:\\ \;\;\;\;0 - \frac{x.re}{y.im}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 64.3% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;y.im \leq 42:\\
\;\;\;\;\frac{x.im}{y.re}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < -2.8000000000000002e-29 or 42 < y.im

    1. Initial program 62.4%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(x.re, \left(0 - \color{blue}{\left(-1 \cdot \frac{x.im \cdot y.re}{x.re \cdot \left({y.im}^{2} + {y.re}^{2}\right)} + \frac{y.im}{{y.im}^{2} + {y.re}^{2}}\right)}\right)\right) \]
    5. Simplified60.8%

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

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

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

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

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

        \[\leadsto \frac{x.re}{\color{blue}{\frac{y.im}{-1}}} \]
      3. clear-numN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{y.im}{-1}}{x.re}}} \]
      4. metadata-evalN/A

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

        \[\leadsto \mathsf{/.f64}\left(\left(\mathsf{neg}\left(-1\right)\right), \color{blue}{\left(\frac{\frac{y.im}{-1}}{x.re}\right)}\right) \]
      6. metadata-evalN/A

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

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\left(\frac{y.im}{-1}\right), \color{blue}{x.re}\right)\right) \]
      8. /-lowering-/.f6467.7%

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

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

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

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

        \[\leadsto \frac{x.re}{\frac{\mathsf{neg}\left(y.im\right)}{1}} \]
      4. /-rgt-identityN/A

        \[\leadsto \frac{x.re}{\mathsf{neg}\left(y.im\right)} \]
      5. distribute-frac-neg2N/A

        \[\leadsto \mathsf{neg}\left(\frac{x.re}{y.im}\right) \]
      6. neg-lowering-neg.f64N/A

        \[\leadsto \mathsf{neg.f64}\left(\left(\frac{x.re}{y.im}\right)\right) \]
      7. /-lowering-/.f6469.1%

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{/.f64}\left(x.re, y.im\right)\right) \]
    12. Applied egg-rr69.1%

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

    if -2.8000000000000002e-29 < y.im < 42

    1. Initial program 74.1%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f6467.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -2.8 \cdot 10^{-29}:\\ \;\;\;\;0 - \frac{x.re}{y.im}\\ \mathbf{elif}\;y.im \leq 42:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{else}:\\ \;\;\;\;0 - \frac{x.re}{y.im}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 42.7% accurate, 5.0× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
  4. Step-by-step derivation
    1. /-lowering-/.f6441.1%

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

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

Reproduce

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