_divideComplex, imaginary part

Percentage Accurate: 61.3% → 93.3%
Time: 10.8s
Alternatives: 9
Speedup: 1.8×

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

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

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

Alternative 1: 93.3% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{y.re}}, \frac{-x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}\right)\\ t_1 := \frac{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)} - \frac{x.re}{y.im}\\ \mathbf{if}\;y.im \leq -2.16 \cdot 10^{+161}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.im \leq -3.6 \cdot 10^{-134}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.im \leq 1.55 \cdot 10^{-167}:\\ \;\;\;\;\frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re}\\ \mathbf{elif}\;y.im \leq 5.8 \cdot 10^{+132}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0
         (fma
          (/ 1.0 (hypot y.re y.im))
          (/ x.im (/ (hypot y.re y.im) y.re))
          (/ (- x.re) (/ (pow (hypot y.re y.im) 2.0) y.im))))
        (t_1
         (-
          (/ (* y.re (/ x.im (hypot y.re y.im))) (hypot y.re y.im))
          (/ x.re y.im))))
   (if (<= y.im -2.16e+161)
     t_1
     (if (<= y.im -3.6e-134)
       t_0
       (if (<= y.im 1.55e-167)
         (/ (- x.im (/ (* y.im x.re) y.re)) y.re)
         (if (<= y.im 5.8e+132) t_0 t_1))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = fma((1.0 / hypot(y_46_re, y_46_im)), (x_46_im / (hypot(y_46_re, y_46_im) / y_46_re)), (-x_46_re / (pow(hypot(y_46_re, y_46_im), 2.0) / y_46_im)));
	double t_1 = ((y_46_re * (x_46_im / hypot(y_46_re, y_46_im))) / hypot(y_46_re, y_46_im)) - (x_46_re / y_46_im);
	double tmp;
	if (y_46_im <= -2.16e+161) {
		tmp = t_1;
	} else if (y_46_im <= -3.6e-134) {
		tmp = t_0;
	} else if (y_46_im <= 1.55e-167) {
		tmp = (x_46_im - ((y_46_im * x_46_re) / y_46_re)) / y_46_re;
	} else if (y_46_im <= 5.8e+132) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = fma(Float64(1.0 / hypot(y_46_re, y_46_im)), Float64(x_46_im / Float64(hypot(y_46_re, y_46_im) / y_46_re)), Float64(Float64(-x_46_re) / Float64((hypot(y_46_re, y_46_im) ^ 2.0) / y_46_im)))
	t_1 = Float64(Float64(Float64(y_46_re * Float64(x_46_im / hypot(y_46_re, y_46_im))) / hypot(y_46_re, y_46_im)) - Float64(x_46_re / y_46_im))
	tmp = 0.0
	if (y_46_im <= -2.16e+161)
		tmp = t_1;
	elseif (y_46_im <= -3.6e-134)
		tmp = t_0;
	elseif (y_46_im <= 1.55e-167)
		tmp = Float64(Float64(x_46_im - Float64(Float64(y_46_im * x_46_re) / y_46_re)) / y_46_re);
	elseif (y_46_im <= 5.8e+132)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(1.0 / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision] * N[(x$46$im / N[(N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] + N[((-x$46$re) / N[(N[Power[N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision], 2.0], $MachinePrecision] / y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(y$46$re * N[(x$46$im / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision] - N[(x$46$re / y$46$im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$im, -2.16e+161], t$95$1, If[LessEqual[y$46$im, -3.6e-134], t$95$0, If[LessEqual[y$46$im, 1.55e-167], N[(N[(x$46$im - N[(N[(y$46$im * x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 5.8e+132], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{y.re}}, \frac{-x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}\right)\\
t_1 := \frac{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)} - \frac{x.re}{y.im}\\
\mathbf{if}\;y.im \leq -2.16 \cdot 10^{+161}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y.im \leq -3.6 \cdot 10^{-134}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;y.im \leq 5.8 \cdot 10^{+132}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.im < -2.16e161 or 5.7999999999999997e132 < y.im

    1. Initial program 27.4%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Step-by-step derivation
      1. div-sub27.4%

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}} \]
      2. *-un-lft-identity27.4%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(x.im \cdot y.re\right)}}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      3. add-sqr-sqrt27.4%

        \[\leadsto \frac{1 \cdot \left(x.im \cdot y.re\right)}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      4. times-frac27.4%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{x.im \cdot y.re}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      5. fma-neg27.4%

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right)}}, -\frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\right) \]
      8. associate-/l*36.2%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\color{blue}{\frac{x.re}{\frac{y.re \cdot y.re + y.im \cdot y.im}{y.im}}}\right) \]
      9. add-sqr-sqrt36.2%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\frac{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}}{y.im}}\right) \]
      10. pow236.2%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\frac{\color{blue}{{\left(\sqrt{y.re \cdot y.re + y.im \cdot y.im}\right)}^{2}}}{y.im}}\right) \]
      11. hypot-def36.2%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\frac{{\color{blue}{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}}^{2}}{y.im}}\right) \]
    3. Applied egg-rr36.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}\right)} \]
    4. Step-by-step derivation
      1. associate-/l*49.9%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \color{blue}{\frac{x.im}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{y.re}}}, -\frac{x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}\right) \]
      2. distribute-neg-frac49.9%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{y.re}}, \frac{-x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}\right)} \]
    6. Step-by-step derivation
      1. fma-udef49.9%

        \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{x.im}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{y.re}} + \frac{-x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}} \]
      2. associate-/r/50.0%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \color{blue}{\left(\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot y.re\right)} + \frac{-x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}} \]
      3. associate-/r/50.0%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \left(\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot y.re\right) + \color{blue}{\frac{-x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}} \cdot y.im} \]
    7. Applied egg-rr50.0%

      \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \left(\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot y.re\right) + \frac{-x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}} \cdot y.im} \]
    8. Step-by-step derivation
      1. +-commutative50.0%

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

        \[\leadsto \color{blue}{y.im \cdot \frac{-x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}} + \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \left(\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot y.re\right) \]
      3. associate-*l/50.0%

        \[\leadsto y.im \cdot \frac{-x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}} + \color{blue}{\frac{1 \cdot \left(\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot y.re\right)}{\mathsf{hypot}\left(y.re, y.im\right)}} \]
      4. *-lft-identity50.0%

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

        \[\leadsto y.im \cdot \frac{-x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}} + \frac{\color{blue}{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}}}{\mathsf{hypot}\left(y.re, y.im\right)} \]
    9. Simplified50.0%

      \[\leadsto \color{blue}{y.im \cdot \frac{-x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}} + \frac{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)}} \]
    10. Taylor expanded in y.im around inf 97.5%

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im}} + \frac{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)} \]
    11. Step-by-step derivation
      1. associate-*r/97.5%

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

        \[\leadsto \frac{\color{blue}{-x.re}}{y.im} + \frac{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)} \]
    12. Simplified97.5%

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

    if -2.16e161 < y.im < -3.5999999999999999e-134 or 1.55e-167 < y.im < 5.7999999999999997e132

    1. Initial program 73.7%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Step-by-step derivation
      1. div-sub73.6%

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}} \]
      2. *-un-lft-identity73.6%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(x.im \cdot y.re\right)}}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      3. add-sqr-sqrt73.6%

        \[\leadsto \frac{1 \cdot \left(x.im \cdot y.re\right)}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      4. times-frac73.6%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{x.im \cdot y.re}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      5. fma-neg73.6%

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right)}}, -\frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\right) \]
      8. associate-/l*83.8%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\color{blue}{\frac{x.re}{\frac{y.re \cdot y.re + y.im \cdot y.im}{y.im}}}\right) \]
      9. add-sqr-sqrt83.7%

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\frac{\color{blue}{{\left(\sqrt{y.re \cdot y.re + y.im \cdot y.im}\right)}^{2}}}{y.im}}\right) \]
      11. hypot-def83.7%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\frac{{\color{blue}{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}}^{2}}{y.im}}\right) \]
    3. Applied egg-rr83.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}\right)} \]
    4. Step-by-step derivation
      1. associate-/l*96.9%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \color{blue}{\frac{x.im}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{y.re}}}, -\frac{x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}\right) \]
      2. distribute-neg-frac96.9%

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

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

    if -3.5999999999999999e-134 < y.im < 1.55e-167

    1. Initial program 75.3%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re} + -1 \cdot \frac{x.re \cdot y.im}{{y.re}^{2}}} \]
    3. Step-by-step derivation
      1. mul-1-neg80.6%

        \[\leadsto \frac{x.im}{y.re} + \color{blue}{\left(-\frac{x.re \cdot y.im}{{y.re}^{2}}\right)} \]
      2. unsub-neg80.6%

        \[\leadsto \color{blue}{\frac{x.im}{y.re} - \frac{x.re \cdot y.im}{{y.re}^{2}}} \]
      3. unpow280.6%

        \[\leadsto \frac{x.im}{y.re} - \frac{x.re \cdot y.im}{\color{blue}{y.re \cdot y.re}} \]
      4. times-frac84.5%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re} - \frac{x.re}{y.re} \cdot \frac{y.im}{y.re}} \]
    5. Step-by-step derivation
      1. associate-*l/92.0%

        \[\leadsto \frac{x.im}{y.re} - \color{blue}{\frac{x.re \cdot \frac{y.im}{y.re}}{y.re}} \]
    6. Applied egg-rr92.0%

      \[\leadsto \frac{x.im}{y.re} - \color{blue}{\frac{x.re \cdot \frac{y.im}{y.re}}{y.re}} \]
    7. Step-by-step derivation
      1. sub-div95.3%

        \[\leadsto \color{blue}{\frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}} \]
    8. Applied egg-rr95.3%

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

        \[\leadsto \frac{x.im - \color{blue}{\frac{x.re \cdot y.im}{y.re}}}{y.re} \]
      2. *-commutative95.3%

        \[\leadsto \frac{x.im - \frac{\color{blue}{y.im \cdot x.re}}{y.re}}{y.re} \]
    10. Applied egg-rr95.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -2.16 \cdot 10^{+161}:\\ \;\;\;\;\frac{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)} - \frac{x.re}{y.im}\\ \mathbf{elif}\;y.im \leq -3.6 \cdot 10^{-134}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{y.re}}, \frac{-x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}\right)\\ \mathbf{elif}\;y.im \leq 1.55 \cdot 10^{-167}:\\ \;\;\;\;\frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re}\\ \mathbf{elif}\;y.im \leq 5.8 \cdot 10^{+132}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{y.re}}, \frac{-x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)} - \frac{x.re}{y.im}\\ \end{array} \]

Alternative 2: 89.3% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y.re \cdot x.im - y.im \cdot x.re\\ \mathbf{if}\;\frac{t_0}{y.re \cdot y.re + y.im \cdot y.im} \leq 4 \cdot 10^{+288}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)} - \frac{x.re}{y.im}\\ \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))))
   (if (<= (/ t_0 (+ (* y.re y.re) (* y.im y.im))) 4e+288)
     (* (/ 1.0 (hypot y.re y.im)) (/ t_0 (hypot y.re y.im)))
     (-
      (/ (* y.re (/ x.im (hypot y.re y.im))) (hypot y.re 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 = (y_46_re * x_46_im) - (y_46_im * x_46_re);
	double tmp;
	if ((t_0 / ((y_46_re * y_46_re) + (y_46_im * y_46_im))) <= 4e+288) {
		tmp = (1.0 / hypot(y_46_re, y_46_im)) * (t_0 / hypot(y_46_re, y_46_im));
	} else {
		tmp = ((y_46_re * (x_46_im / hypot(y_46_re, y_46_im))) / hypot(y_46_re, y_46_im)) - (x_46_re / y_46_im);
	}
	return tmp;
}
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);
	double tmp;
	if ((t_0 / ((y_46_re * y_46_re) + (y_46_im * y_46_im))) <= 4e+288) {
		tmp = (1.0 / Math.hypot(y_46_re, y_46_im)) * (t_0 / Math.hypot(y_46_re, y_46_im));
	} else {
		tmp = ((y_46_re * (x_46_im / Math.hypot(y_46_re, y_46_im))) / Math.hypot(y_46_re, 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 = (y_46_re * x_46_im) - (y_46_im * x_46_re)
	tmp = 0
	if (t_0 / ((y_46_re * y_46_re) + (y_46_im * y_46_im))) <= 4e+288:
		tmp = (1.0 / math.hypot(y_46_re, y_46_im)) * (t_0 / math.hypot(y_46_re, y_46_im))
	else:
		tmp = ((y_46_re * (x_46_im / math.hypot(y_46_re, y_46_im))) / math.hypot(y_46_re, 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(Float64(y_46_re * x_46_im) - Float64(y_46_im * x_46_re))
	tmp = 0.0
	if (Float64(t_0 / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))) <= 4e+288)
		tmp = Float64(Float64(1.0 / hypot(y_46_re, y_46_im)) * Float64(t_0 / hypot(y_46_re, y_46_im)));
	else
		tmp = Float64(Float64(Float64(y_46_re * Float64(x_46_im / hypot(y_46_re, y_46_im))) / hypot(y_46_re, 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 = (y_46_re * x_46_im) - (y_46_im * x_46_re);
	tmp = 0.0;
	if ((t_0 / ((y_46_re * y_46_re) + (y_46_im * y_46_im))) <= 4e+288)
		tmp = (1.0 / hypot(y_46_re, y_46_im)) * (t_0 / hypot(y_46_re, y_46_im));
	else
		tmp = ((y_46_re * (x_46_im / hypot(y_46_re, y_46_im))) / hypot(y_46_re, 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[(N[(y$46$re * x$46$im), $MachinePrecision] - N[(y$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4e+288], N[(N[(1.0 / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y$46$re * N[(x$46$im / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision] - N[(x$46$re / y$46$im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 (*.f64 x.im y.re) (*.f64 x.re y.im)) (+.f64 (*.f64 y.re y.re) (*.f64 y.im y.im))) < 4e288

    1. Initial program 78.8%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Step-by-step derivation
      1. *-un-lft-identity78.8%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(x.im \cdot y.re - x.re \cdot y.im\right)}}{y.re \cdot y.re + y.im \cdot y.im} \]
      2. add-sqr-sqrt78.8%

        \[\leadsto \frac{1 \cdot \left(x.im \cdot y.re - x.re \cdot y.im\right)}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}} \]
      3. times-frac78.7%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}} \]
      4. hypot-def78.7%

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

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

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

    if 4e288 < (/.f64 (-.f64 (*.f64 x.im y.re) (*.f64 x.re y.im)) (+.f64 (*.f64 y.re y.re) (*.f64 y.im y.im)))

    1. Initial program 8.0%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Step-by-step derivation
      1. div-sub4.9%

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}} \]
      2. *-un-lft-identity4.9%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(x.im \cdot y.re\right)}}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      3. add-sqr-sqrt4.9%

        \[\leadsto \frac{1 \cdot \left(x.im \cdot y.re\right)}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      4. times-frac4.9%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{x.im \cdot y.re}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      5. fma-neg4.9%

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right)}}, -\frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\right) \]
      8. associate-/l*16.3%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\color{blue}{\frac{x.re}{\frac{y.re \cdot y.re + y.im \cdot y.im}{y.im}}}\right) \]
      9. add-sqr-sqrt16.3%

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\frac{{\color{blue}{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}}^{2}}{y.im}}\right) \]
    3. Applied egg-rr16.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}\right)} \]
    4. Step-by-step derivation
      1. associate-/l*61.8%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \color{blue}{\frac{x.im}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{y.re}}}, -\frac{x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}\right) \]
      2. distribute-neg-frac61.8%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{y.re}}, \frac{-x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}\right)} \]
    6. Step-by-step derivation
      1. fma-udef61.8%

        \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{x.im}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{y.re}} + \frac{-x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}} \]
      2. associate-/r/61.9%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \color{blue}{\left(\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot y.re\right)} + \frac{-x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}} \]
      3. associate-/r/61.9%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \left(\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot y.re\right) + \color{blue}{\frac{-x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}} \cdot y.im} \]
    7. Applied egg-rr61.9%

      \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \left(\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot y.re\right) + \frac{-x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}} \cdot y.im} \]
    8. Step-by-step derivation
      1. +-commutative61.9%

        \[\leadsto \color{blue}{\frac{-x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}} \cdot y.im + \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \left(\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot y.re\right)} \]
      2. *-commutative61.9%

        \[\leadsto \color{blue}{y.im \cdot \frac{-x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}} + \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \left(\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot y.re\right) \]
      3. associate-*l/62.0%

        \[\leadsto y.im \cdot \frac{-x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}} + \color{blue}{\frac{1 \cdot \left(\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot y.re\right)}{\mathsf{hypot}\left(y.re, y.im\right)}} \]
      4. *-lft-identity62.0%

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

        \[\leadsto y.im \cdot \frac{-x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}} + \frac{\color{blue}{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}}}{\mathsf{hypot}\left(y.re, y.im\right)} \]
    9. Simplified62.0%

      \[\leadsto \color{blue}{y.im \cdot \frac{-x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}} + \frac{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)}} \]
    10. Taylor expanded in y.im around inf 77.5%

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im}} + \frac{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)} \]
    11. Step-by-step derivation
      1. associate-*r/77.5%

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

        \[\leadsto \frac{\color{blue}{-x.re}}{y.im} + \frac{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)} \]
    12. Simplified77.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im} \leq 4 \cdot 10^{+288}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)} - \frac{x.re}{y.im}\\ \end{array} \]

Alternative 3: 81.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)} - \frac{x.re}{y.im}\\ \mathbf{if}\;y.im \leq -1.9 \cdot 10^{-33}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.im \leq -2.9 \cdot 10^{-134}:\\ \;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 1.92 \cdot 10^{+99}:\\ \;\;\;\;\frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0
         (-
          (/ (* y.re (/ x.im (hypot y.re y.im))) (hypot y.re y.im))
          (/ x.re y.im))))
   (if (<= y.im -1.9e-33)
     t_0
     (if (<= y.im -2.9e-134)
       (/ (- (* y.re x.im) (* y.im x.re)) (+ (* y.re y.re) (* y.im y.im)))
       (if (<= y.im 1.92e+99) (/ (- x.im (* x.re (/ y.im y.re))) y.re) t_0)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = ((y_46_re * (x_46_im / hypot(y_46_re, y_46_im))) / hypot(y_46_re, y_46_im)) - (x_46_re / y_46_im);
	double tmp;
	if (y_46_im <= -1.9e-33) {
		tmp = t_0;
	} else if (y_46_im <= -2.9e-134) {
		tmp = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	} else if (y_46_im <= 1.92e+99) {
		tmp = (x_46_im - (x_46_re * (y_46_im / y_46_re))) / y_46_re;
	} else {
		tmp = t_0;
	}
	return tmp;
}
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 / Math.hypot(y_46_re, y_46_im))) / Math.hypot(y_46_re, y_46_im)) - (x_46_re / y_46_im);
	double tmp;
	if (y_46_im <= -1.9e-33) {
		tmp = t_0;
	} else if (y_46_im <= -2.9e-134) {
		tmp = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	} else if (y_46_im <= 1.92e+99) {
		tmp = (x_46_im - (x_46_re * (y_46_im / y_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 = ((y_46_re * (x_46_im / math.hypot(y_46_re, y_46_im))) / math.hypot(y_46_re, y_46_im)) - (x_46_re / y_46_im)
	tmp = 0
	if y_46_im <= -1.9e-33:
		tmp = t_0
	elif y_46_im <= -2.9e-134:
		tmp = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
	elif y_46_im <= 1.92e+99:
		tmp = (x_46_im - (x_46_re * (y_46_im / y_46_re))) / y_46_re
	else:
		tmp = t_0
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(Float64(y_46_re * Float64(x_46_im / hypot(y_46_re, y_46_im))) / hypot(y_46_re, y_46_im)) - Float64(x_46_re / y_46_im))
	tmp = 0.0
	if (y_46_im <= -1.9e-33)
		tmp = t_0;
	elseif (y_46_im <= -2.9e-134)
		tmp = Float64(Float64(Float64(y_46_re * x_46_im) - Float64(y_46_im * x_46_re)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)));
	elseif (y_46_im <= 1.92e+99)
		tmp = Float64(Float64(x_46_im - Float64(x_46_re * Float64(y_46_im / y_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 = ((y_46_re * (x_46_im / hypot(y_46_re, y_46_im))) / hypot(y_46_re, y_46_im)) - (x_46_re / y_46_im);
	tmp = 0.0;
	if (y_46_im <= -1.9e-33)
		tmp = t_0;
	elseif (y_46_im <= -2.9e-134)
		tmp = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	elseif (y_46_im <= 1.92e+99)
		tmp = (x_46_im - (x_46_re * (y_46_im / y_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[(y$46$re * N[(x$46$im / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision] - N[(x$46$re / y$46$im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$im, -1.9e-33], t$95$0, If[LessEqual[y$46$im, -2.9e-134], N[(N[(N[(y$46$re * x$46$im), $MachinePrecision] - N[(y$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 1.92e+99], N[(N[(x$46$im - N[(x$46$re * N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

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

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

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.im < -1.89999999999999997e-33 or 1.9199999999999999e99 < y.im

    1. Initial program 45.3%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Step-by-step derivation
      1. div-sub45.3%

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}} \]
      2. *-un-lft-identity45.3%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(x.im \cdot y.re\right)}}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      3. add-sqr-sqrt45.3%

        \[\leadsto \frac{1 \cdot \left(x.im \cdot y.re\right)}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      4. times-frac45.3%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{x.im \cdot y.re}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      5. fma-neg45.3%

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right)}}, -\frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\right) \]
      8. associate-/l*57.0%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\color{blue}{\frac{x.re}{\frac{y.re \cdot y.re + y.im \cdot y.im}{y.im}}}\right) \]
      9. add-sqr-sqrt57.0%

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\frac{\color{blue}{{\left(\sqrt{y.re \cdot y.re + y.im \cdot y.im}\right)}^{2}}}{y.im}}\right) \]
      11. hypot-def57.0%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\frac{{\color{blue}{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}}^{2}}{y.im}}\right) \]
    3. Applied egg-rr57.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}\right)} \]
    4. Step-by-step derivation
      1. associate-/l*68.6%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \color{blue}{\frac{x.im}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{y.re}}}, -\frac{x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}\right) \]
      2. distribute-neg-frac68.6%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{y.re}}, \frac{-x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}\right)} \]
    6. Step-by-step derivation
      1. fma-udef68.6%

        \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{x.im}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{y.re}} + \frac{-x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}} \]
      2. associate-/r/68.7%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \color{blue}{\left(\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot y.re\right)} + \frac{-x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}} \]
      3. associate-/r/64.9%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \left(\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot y.re\right) + \color{blue}{\frac{-x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}} \cdot y.im} \]
    7. Applied egg-rr64.9%

      \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \left(\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot y.re\right) + \frac{-x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}} \cdot y.im} \]
    8. Step-by-step derivation
      1. +-commutative64.9%

        \[\leadsto \color{blue}{\frac{-x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}} \cdot y.im + \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \left(\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot y.re\right)} \]
      2. *-commutative64.9%

        \[\leadsto \color{blue}{y.im \cdot \frac{-x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}} + \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \left(\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot y.re\right) \]
      3. associate-*l/65.0%

        \[\leadsto y.im \cdot \frac{-x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}} + \color{blue}{\frac{1 \cdot \left(\frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot y.re\right)}{\mathsf{hypot}\left(y.re, y.im\right)}} \]
      4. *-lft-identity65.0%

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

        \[\leadsto y.im \cdot \frac{-x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}} + \frac{\color{blue}{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}}}{\mathsf{hypot}\left(y.re, y.im\right)} \]
    9. Simplified65.0%

      \[\leadsto \color{blue}{y.im \cdot \frac{-x.re}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}} + \frac{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)}} \]
    10. Taylor expanded in y.im around inf 93.0%

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im}} + \frac{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)} \]
    11. Step-by-step derivation
      1. associate-*r/93.0%

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

        \[\leadsto \frac{\color{blue}{-x.re}}{y.im} + \frac{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)} \]
    12. Simplified93.0%

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

    if -1.89999999999999997e-33 < y.im < -2.89999999999999993e-134

    1. Initial program 98.5%

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

    if -2.89999999999999993e-134 < y.im < 1.9199999999999999e99

    1. Initial program 67.9%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re} + -1 \cdot \frac{x.re \cdot y.im}{{y.re}^{2}}} \]
    3. Step-by-step derivation
      1. mul-1-neg75.7%

        \[\leadsto \frac{x.im}{y.re} + \color{blue}{\left(-\frac{x.re \cdot y.im}{{y.re}^{2}}\right)} \]
      2. unsub-neg75.7%

        \[\leadsto \color{blue}{\frac{x.im}{y.re} - \frac{x.re \cdot y.im}{{y.re}^{2}}} \]
      3. unpow275.7%

        \[\leadsto \frac{x.im}{y.re} - \frac{x.re \cdot y.im}{\color{blue}{y.re \cdot y.re}} \]
      4. times-frac79.2%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re} - \frac{x.re}{y.re} \cdot \frac{y.im}{y.re}} \]
    5. Step-by-step derivation
      1. associate-*l/83.6%

        \[\leadsto \frac{x.im}{y.re} - \color{blue}{\frac{x.re \cdot \frac{y.im}{y.re}}{y.re}} \]
    6. Applied egg-rr83.6%

      \[\leadsto \frac{x.im}{y.re} - \color{blue}{\frac{x.re \cdot \frac{y.im}{y.re}}{y.re}} \]
    7. Step-by-step derivation
      1. sub-div85.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -1.9 \cdot 10^{-33}:\\ \;\;\;\;\frac{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)} - \frac{x.re}{y.im}\\ \mathbf{elif}\;y.im \leq -2.9 \cdot 10^{-134}:\\ \;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 1.92 \cdot 10^{+99}:\\ \;\;\;\;\frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{y.re \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)} - \frac{x.re}{y.im}\\ \end{array} \]

Alternative 4: 79.1% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.im \leq -2.4 \cdot 10^{+42}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \left(x.re - y.re \cdot \frac{x.im}{y.im}\right)\\ \mathbf{elif}\;y.im \leq -9.2 \cdot 10^{-134}:\\ \;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 1.92 \cdot 10^{+99}:\\ \;\;\;\;\frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.im} \cdot \frac{y.re}{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.4e+42)
   (* (/ 1.0 (hypot y.re y.im)) (- x.re (* y.re (/ x.im y.im))))
   (if (<= y.im -9.2e-134)
     (/ (- (* y.re x.im) (* y.im x.re)) (+ (* y.re y.re) (* y.im y.im)))
     (if (<= y.im 1.92e+99)
       (/ (- x.im (* x.re (/ y.im y.re))) y.re)
       (- (* (/ x.im y.im) (/ y.re 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.4e+42) {
		tmp = (1.0 / hypot(y_46_re, y_46_im)) * (x_46_re - (y_46_re * (x_46_im / y_46_im)));
	} else if (y_46_im <= -9.2e-134) {
		tmp = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	} else if (y_46_im <= 1.92e+99) {
		tmp = (x_46_im - (x_46_re * (y_46_im / y_46_re))) / y_46_re;
	} else {
		tmp = ((x_46_im / y_46_im) * (y_46_re / y_46_im)) - (x_46_re / y_46_im);
	}
	return tmp;
}
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.4e+42) {
		tmp = (1.0 / Math.hypot(y_46_re, y_46_im)) * (x_46_re - (y_46_re * (x_46_im / y_46_im)));
	} else if (y_46_im <= -9.2e-134) {
		tmp = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	} else if (y_46_im <= 1.92e+99) {
		tmp = (x_46_im - (x_46_re * (y_46_im / y_46_re))) / y_46_re;
	} else {
		tmp = ((x_46_im / y_46_im) * (y_46_re / 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.4e+42:
		tmp = (1.0 / math.hypot(y_46_re, y_46_im)) * (x_46_re - (y_46_re * (x_46_im / y_46_im)))
	elif y_46_im <= -9.2e-134:
		tmp = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
	elif y_46_im <= 1.92e+99:
		tmp = (x_46_im - (x_46_re * (y_46_im / y_46_re))) / y_46_re
	else:
		tmp = ((x_46_im / y_46_im) * (y_46_re / 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.4e+42)
		tmp = Float64(Float64(1.0 / hypot(y_46_re, y_46_im)) * Float64(x_46_re - Float64(y_46_re * Float64(x_46_im / y_46_im))));
	elseif (y_46_im <= -9.2e-134)
		tmp = Float64(Float64(Float64(y_46_re * x_46_im) - Float64(y_46_im * x_46_re)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)));
	elseif (y_46_im <= 1.92e+99)
		tmp = Float64(Float64(x_46_im - Float64(x_46_re * Float64(y_46_im / y_46_re))) / y_46_re);
	else
		tmp = Float64(Float64(Float64(x_46_im / y_46_im) * Float64(y_46_re / 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.4e+42)
		tmp = (1.0 / hypot(y_46_re, y_46_im)) * (x_46_re - (y_46_re * (x_46_im / y_46_im)));
	elseif (y_46_im <= -9.2e-134)
		tmp = ((y_46_re * x_46_im) - (y_46_im * x_46_re)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	elseif (y_46_im <= 1.92e+99)
		tmp = (x_46_im - (x_46_re * (y_46_im / y_46_re))) / y_46_re;
	else
		tmp = ((x_46_im / y_46_im) * (y_46_re / 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.4e+42], N[(N[(1.0 / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision] * N[(x$46$re - N[(y$46$re * N[(x$46$im / y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, -9.2e-134], N[(N[(N[(y$46$re * x$46$im), $MachinePrecision] - N[(y$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 1.92e+99], N[(N[(x$46$im - N[(x$46$re * N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], N[(N[(N[(x$46$im / y$46$im), $MachinePrecision] * N[(y$46$re / y$46$im), $MachinePrecision]), $MachinePrecision] - N[(x$46$re / y$46$im), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -2.4 \cdot 10^{+42}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \left(x.re - y.re \cdot \frac{x.im}{y.im}\right)\\

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

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

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


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

    1. Initial program 47.6%

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Step-by-step derivation
      1. *-un-lft-identity47.6%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(x.im \cdot y.re - x.re \cdot y.im\right)}}{y.re \cdot y.re + y.im \cdot y.im} \]
      2. add-sqr-sqrt47.6%

        \[\leadsto \frac{1 \cdot \left(x.im \cdot y.re - x.re \cdot y.im\right)}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}} \]
      3. times-frac47.6%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}} \]
      4. hypot-def47.6%

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

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \color{blue}{\left(-1 \cdot \frac{y.re \cdot x.im}{y.im} + x.re\right)} \]
    5. Step-by-step derivation
      1. +-commutative84.2%

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

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \color{blue}{\left(x.re - \frac{y.re \cdot x.im}{y.im}\right)} \]
      4. associate-*r/89.6%

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

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

    if -2.3999999999999999e42 < y.im < -9.2000000000000001e-134

    1. Initial program 94.0%

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

    if -9.2000000000000001e-134 < y.im < 1.9199999999999999e99

    1. Initial program 67.9%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re} + -1 \cdot \frac{x.re \cdot y.im}{{y.re}^{2}}} \]
    3. Step-by-step derivation
      1. mul-1-neg75.7%

        \[\leadsto \frac{x.im}{y.re} + \color{blue}{\left(-\frac{x.re \cdot y.im}{{y.re}^{2}}\right)} \]
      2. unsub-neg75.7%

        \[\leadsto \color{blue}{\frac{x.im}{y.re} - \frac{x.re \cdot y.im}{{y.re}^{2}}} \]
      3. unpow275.7%

        \[\leadsto \frac{x.im}{y.re} - \frac{x.re \cdot y.im}{\color{blue}{y.re \cdot y.re}} \]
      4. times-frac79.2%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re} - \frac{x.re}{y.re} \cdot \frac{y.im}{y.re}} \]
    5. Step-by-step derivation
      1. associate-*l/83.6%

        \[\leadsto \frac{x.im}{y.re} - \color{blue}{\frac{x.re \cdot \frac{y.im}{y.re}}{y.re}} \]
    6. Applied egg-rr83.6%

      \[\leadsto \frac{x.im}{y.re} - \color{blue}{\frac{x.re \cdot \frac{y.im}{y.re}}{y.re}} \]
    7. Step-by-step derivation
      1. sub-div85.5%

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

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

    if 1.9199999999999999e99 < y.im

    1. Initial program 32.8%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im} + \frac{y.re \cdot x.im}{{y.im}^{2}}} \]
    3. Step-by-step derivation
      1. +-commutative71.9%

        \[\leadsto \color{blue}{\frac{y.re \cdot x.im}{{y.im}^{2}} + -1 \cdot \frac{x.re}{y.im}} \]
      2. mul-1-neg71.9%

        \[\leadsto \frac{y.re \cdot x.im}{{y.im}^{2}} + \color{blue}{\left(-\frac{x.re}{y.im}\right)} \]
      3. unsub-neg71.9%

        \[\leadsto \color{blue}{\frac{y.re \cdot x.im}{{y.im}^{2}} - \frac{x.re}{y.im}} \]
      4. unpow271.9%

        \[\leadsto \frac{y.re \cdot x.im}{\color{blue}{y.im \cdot y.im}} - \frac{x.re}{y.im} \]
      5. times-frac88.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -2.4 \cdot 10^{+42}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \left(x.re - y.re \cdot \frac{x.im}{y.im}\right)\\ \mathbf{elif}\;y.im \leq -9.2 \cdot 10^{-134}:\\ \;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 1.92 \cdot 10^{+99}:\\ \;\;\;\;\frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.im} \cdot \frac{y.re}{y.im} - \frac{x.re}{y.im}\\ \end{array} \]

Alternative 5: 79.0% accurate, 0.8× speedup?

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

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

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

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

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.im < -2.3500000000000001e63 or 1.9199999999999999e99 < y.im

    1. Initial program 39.5%

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

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

        \[\leadsto \color{blue}{\frac{y.re \cdot x.im}{{y.im}^{2}} + -1 \cdot \frac{x.re}{y.im}} \]
      2. mul-1-neg76.4%

        \[\leadsto \frac{y.re \cdot x.im}{{y.im}^{2}} + \color{blue}{\left(-\frac{x.re}{y.im}\right)} \]
      3. unsub-neg76.4%

        \[\leadsto \color{blue}{\frac{y.re \cdot x.im}{{y.im}^{2}} - \frac{x.re}{y.im}} \]
      4. unpow276.4%

        \[\leadsto \frac{y.re \cdot x.im}{\color{blue}{y.im \cdot y.im}} - \frac{x.re}{y.im} \]
      5. times-frac89.4%

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

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

    if -2.3500000000000001e63 < y.im < -1.40000000000000001e-132

    1. Initial program 92.1%

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

    if -1.40000000000000001e-132 < y.im < 1.9199999999999999e99

    1. Initial program 67.9%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re} + -1 \cdot \frac{x.re \cdot y.im}{{y.re}^{2}}} \]
    3. Step-by-step derivation
      1. mul-1-neg75.7%

        \[\leadsto \frac{x.im}{y.re} + \color{blue}{\left(-\frac{x.re \cdot y.im}{{y.re}^{2}}\right)} \]
      2. unsub-neg75.7%

        \[\leadsto \color{blue}{\frac{x.im}{y.re} - \frac{x.re \cdot y.im}{{y.re}^{2}}} \]
      3. unpow275.7%

        \[\leadsto \frac{x.im}{y.re} - \frac{x.re \cdot y.im}{\color{blue}{y.re \cdot y.re}} \]
      4. times-frac79.2%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re} - \frac{x.re}{y.re} \cdot \frac{y.im}{y.re}} \]
    5. Step-by-step derivation
      1. associate-*l/83.6%

        \[\leadsto \frac{x.im}{y.re} - \color{blue}{\frac{x.re \cdot \frac{y.im}{y.re}}{y.re}} \]
    6. Applied egg-rr83.6%

      \[\leadsto \frac{x.im}{y.re} - \color{blue}{\frac{x.re \cdot \frac{y.im}{y.re}}{y.re}} \]
    7. Step-by-step derivation
      1. sub-div85.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -2.35 \cdot 10^{+63}:\\ \;\;\;\;\frac{x.im}{y.im} \cdot \frac{y.re}{y.im} - \frac{x.re}{y.im}\\ \mathbf{elif}\;y.im \leq -1.4 \cdot 10^{-132}:\\ \;\;\;\;\frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 1.92 \cdot 10^{+99}:\\ \;\;\;\;\frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.im} \cdot \frac{y.re}{y.im} - \frac{x.re}{y.im}\\ \end{array} \]

Alternative 6: 76.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.im \leq -4.1 \cdot 10^{-26} \lor \neg \left(y.im \leq 1.92 \cdot 10^{+99}\right):\\ \;\;\;\;\frac{x.im}{y.im} \cdot \frac{y.re}{y.im} - \frac{x.re}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (or (<= y.im -4.1e-26) (not (<= y.im 1.92e+99)))
   (- (* (/ x.im y.im) (/ y.re y.im)) (/ x.re y.im))
   (/ (- x.im (* x.re (/ y.im y.re))) y.re)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if ((y_46_im <= -4.1e-26) || !(y_46_im <= 1.92e+99)) {
		tmp = ((x_46_im / y_46_im) * (y_46_re / y_46_im)) - (x_46_re / y_46_im);
	} else {
		tmp = (x_46_im - (x_46_re * (y_46_im / y_46_re))) / y_46_re;
	}
	return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: tmp
    if ((y_46im <= (-4.1d-26)) .or. (.not. (y_46im <= 1.92d+99))) then
        tmp = ((x_46im / y_46im) * (y_46re / y_46im)) - (x_46re / y_46im)
    else
        tmp = (x_46im - (x_46re * (y_46im / y_46re))) / y_46re
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if ((y_46_im <= -4.1e-26) || !(y_46_im <= 1.92e+99)) {
		tmp = ((x_46_im / y_46_im) * (y_46_re / y_46_im)) - (x_46_re / y_46_im);
	} else {
		tmp = (x_46_im - (x_46_re * (y_46_im / y_46_re))) / y_46_re;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	tmp = 0
	if (y_46_im <= -4.1e-26) or not (y_46_im <= 1.92e+99):
		tmp = ((x_46_im / y_46_im) * (y_46_re / y_46_im)) - (x_46_re / y_46_im)
	else:
		tmp = (x_46_im - (x_46_re * (y_46_im / y_46_re))) / y_46_re
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0
	if ((y_46_im <= -4.1e-26) || !(y_46_im <= 1.92e+99))
		tmp = Float64(Float64(Float64(x_46_im / y_46_im) * Float64(y_46_re / y_46_im)) - Float64(x_46_re / y_46_im));
	else
		tmp = Float64(Float64(x_46_im - Float64(x_46_re * Float64(y_46_im / y_46_re))) / y_46_re);
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0;
	if ((y_46_im <= -4.1e-26) || ~((y_46_im <= 1.92e+99)))
		tmp = ((x_46_im / y_46_im) * (y_46_re / y_46_im)) - (x_46_re / y_46_im);
	else
		tmp = (x_46_im - (x_46_re * (y_46_im / y_46_re))) / y_46_re;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$im, -4.1e-26], N[Not[LessEqual[y$46$im, 1.92e+99]], $MachinePrecision]], N[(N[(N[(x$46$im / y$46$im), $MachinePrecision] * N[(y$46$re / y$46$im), $MachinePrecision]), $MachinePrecision] - N[(x$46$re / y$46$im), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im - N[(x$46$re * N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -4.1 \cdot 10^{-26} \lor \neg \left(y.im \leq 1.92 \cdot 10^{+99}\right):\\
\;\;\;\;\frac{x.im}{y.im} \cdot \frac{y.re}{y.im} - \frac{x.re}{y.im}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < -4.0999999999999999e-26 or 1.9199999999999999e99 < y.im

    1. Initial program 45.7%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im} + \frac{y.re \cdot x.im}{{y.im}^{2}}} \]
    3. Step-by-step derivation
      1. +-commutative77.0%

        \[\leadsto \color{blue}{\frac{y.re \cdot x.im}{{y.im}^{2}} + -1 \cdot \frac{x.re}{y.im}} \]
      2. mul-1-neg77.0%

        \[\leadsto \frac{y.re \cdot x.im}{{y.im}^{2}} + \color{blue}{\left(-\frac{x.re}{y.im}\right)} \]
      3. unsub-neg77.0%

        \[\leadsto \color{blue}{\frac{y.re \cdot x.im}{{y.im}^{2}} - \frac{x.re}{y.im}} \]
      4. unpow277.0%

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

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

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

    if -4.0999999999999999e-26 < y.im < 1.9199999999999999e99

    1. Initial program 73.4%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re} + -1 \cdot \frac{x.re \cdot y.im}{{y.re}^{2}}} \]
    3. Step-by-step derivation
      1. mul-1-neg73.8%

        \[\leadsto \frac{x.im}{y.re} + \color{blue}{\left(-\frac{x.re \cdot y.im}{{y.re}^{2}}\right)} \]
      2. unsub-neg73.8%

        \[\leadsto \color{blue}{\frac{x.im}{y.re} - \frac{x.re \cdot y.im}{{y.re}^{2}}} \]
      3. unpow273.8%

        \[\leadsto \frac{x.im}{y.re} - \frac{x.re \cdot y.im}{\color{blue}{y.re \cdot y.re}} \]
      4. times-frac76.1%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re} - \frac{x.re}{y.re} \cdot \frac{y.im}{y.re}} \]
    5. Step-by-step derivation
      1. associate-*l/80.3%

        \[\leadsto \frac{x.im}{y.re} - \color{blue}{\frac{x.re \cdot \frac{y.im}{y.re}}{y.re}} \]
    6. Applied egg-rr80.3%

      \[\leadsto \frac{x.im}{y.re} - \color{blue}{\frac{x.re \cdot \frac{y.im}{y.re}}{y.re}} \]
    7. Step-by-step derivation
      1. sub-div81.8%

        \[\leadsto \color{blue}{\frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}} \]
    8. Applied egg-rr81.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -4.1 \cdot 10^{-26} \lor \neg \left(y.im \leq 1.92 \cdot 10^{+99}\right):\\ \;\;\;\;\frac{x.im}{y.im} \cdot \frac{y.re}{y.im} - \frac{x.re}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}\\ \end{array} \]

Alternative 7: 71.7% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.im \leq -1.9 \cdot 10^{-25} \lor \neg \left(y.im \leq 2.2 \cdot 10^{+99}\right):\\ \;\;\;\;\frac{-x.re}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (or (<= y.im -1.9e-25) (not (<= y.im 2.2e+99)))
   (/ (- x.re) y.im)
   (/ (- x.im (* x.re (/ y.im y.re))) y.re)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if ((y_46_im <= -1.9e-25) || !(y_46_im <= 2.2e+99)) {
		tmp = -x_46_re / y_46_im;
	} else {
		tmp = (x_46_im - (x_46_re * (y_46_im / y_46_re))) / y_46_re;
	}
	return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: tmp
    if ((y_46im <= (-1.9d-25)) .or. (.not. (y_46im <= 2.2d+99))) then
        tmp = -x_46re / y_46im
    else
        tmp = (x_46im - (x_46re * (y_46im / y_46re))) / y_46re
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if ((y_46_im <= -1.9e-25) || !(y_46_im <= 2.2e+99)) {
		tmp = -x_46_re / y_46_im;
	} else {
		tmp = (x_46_im - (x_46_re * (y_46_im / y_46_re))) / y_46_re;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	tmp = 0
	if (y_46_im <= -1.9e-25) or not (y_46_im <= 2.2e+99):
		tmp = -x_46_re / y_46_im
	else:
		tmp = (x_46_im - (x_46_re * (y_46_im / y_46_re))) / y_46_re
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0
	if ((y_46_im <= -1.9e-25) || !(y_46_im <= 2.2e+99))
		tmp = Float64(Float64(-x_46_re) / y_46_im);
	else
		tmp = Float64(Float64(x_46_im - Float64(x_46_re * Float64(y_46_im / y_46_re))) / y_46_re);
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0;
	if ((y_46_im <= -1.9e-25) || ~((y_46_im <= 2.2e+99)))
		tmp = -x_46_re / y_46_im;
	else
		tmp = (x_46_im - (x_46_re * (y_46_im / y_46_re))) / y_46_re;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$im, -1.9e-25], N[Not[LessEqual[y$46$im, 2.2e+99]], $MachinePrecision]], N[((-x$46$re) / y$46$im), $MachinePrecision], N[(N[(x$46$im - N[(x$46$re * N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -1.9 \cdot 10^{-25} \lor \neg \left(y.im \leq 2.2 \cdot 10^{+99}\right):\\
\;\;\;\;\frac{-x.re}{y.im}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < -1.8999999999999999e-25 or 2.19999999999999978e99 < y.im

    1. Initial program 45.7%

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot x.re}{y.im}} \]
      2. neg-mul-176.8%

        \[\leadsto \frac{\color{blue}{-x.re}}{y.im} \]
    4. Simplified76.8%

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

    if -1.8999999999999999e-25 < y.im < 2.19999999999999978e99

    1. Initial program 73.4%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re} + -1 \cdot \frac{x.re \cdot y.im}{{y.re}^{2}}} \]
    3. Step-by-step derivation
      1. mul-1-neg73.8%

        \[\leadsto \frac{x.im}{y.re} + \color{blue}{\left(-\frac{x.re \cdot y.im}{{y.re}^{2}}\right)} \]
      2. unsub-neg73.8%

        \[\leadsto \color{blue}{\frac{x.im}{y.re} - \frac{x.re \cdot y.im}{{y.re}^{2}}} \]
      3. unpow273.8%

        \[\leadsto \frac{x.im}{y.re} - \frac{x.re \cdot y.im}{\color{blue}{y.re \cdot y.re}} \]
      4. times-frac76.1%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re} - \frac{x.re}{y.re} \cdot \frac{y.im}{y.re}} \]
    5. Step-by-step derivation
      1. associate-*l/80.3%

        \[\leadsto \frac{x.im}{y.re} - \color{blue}{\frac{x.re \cdot \frac{y.im}{y.re}}{y.re}} \]
    6. Applied egg-rr80.3%

      \[\leadsto \frac{x.im}{y.re} - \color{blue}{\frac{x.re \cdot \frac{y.im}{y.re}}{y.re}} \]
    7. Step-by-step derivation
      1. sub-div81.8%

        \[\leadsto \color{blue}{\frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}} \]
    8. Applied egg-rr81.8%

      \[\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 simplification79.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -1.9 \cdot 10^{-25} \lor \neg \left(y.im \leq 2.2 \cdot 10^{+99}\right):\\ \;\;\;\;\frac{-x.re}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im - x.re \cdot \frac{y.im}{y.re}}{y.re}\\ \end{array} \]

Alternative 8: 62.0% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.im \leq -2.95 \cdot 10^{-64} \lor \neg \left(y.im \leq 1.92 \cdot 10^{+99}\right):\\ \;\;\;\;\frac{-x.re}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (or (<= y.im -2.95e-64) (not (<= y.im 1.92e+99)))
   (/ (- x.re) y.im)
   (/ x.im y.re)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if ((y_46_im <= -2.95e-64) || !(y_46_im <= 1.92e+99)) {
		tmp = -x_46_re / y_46_im;
	} else {
		tmp = x_46_im / y_46_re;
	}
	return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: tmp
    if ((y_46im <= (-2.95d-64)) .or. (.not. (y_46im <= 1.92d+99))) then
        tmp = -x_46re / y_46im
    else
        tmp = x_46im / y_46re
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if ((y_46_im <= -2.95e-64) || !(y_46_im <= 1.92e+99)) {
		tmp = -x_46_re / y_46_im;
	} else {
		tmp = x_46_im / y_46_re;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	tmp = 0
	if (y_46_im <= -2.95e-64) or not (y_46_im <= 1.92e+99):
		tmp = -x_46_re / y_46_im
	else:
		tmp = x_46_im / y_46_re
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0
	if ((y_46_im <= -2.95e-64) || !(y_46_im <= 1.92e+99))
		tmp = Float64(Float64(-x_46_re) / y_46_im);
	else
		tmp = Float64(x_46_im / y_46_re);
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0;
	if ((y_46_im <= -2.95e-64) || ~((y_46_im <= 1.92e+99)))
		tmp = -x_46_re / y_46_im;
	else
		tmp = x_46_im / y_46_re;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$im, -2.95e-64], N[Not[LessEqual[y$46$im, 1.92e+99]], $MachinePrecision]], N[((-x$46$re) / y$46$im), $MachinePrecision], N[(x$46$im / y$46$re), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -2.95 \cdot 10^{-64} \lor \neg \left(y.im \leq 1.92 \cdot 10^{+99}\right):\\
\;\;\;\;\frac{-x.re}{y.im}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < -2.94999999999999997e-64 or 1.9199999999999999e99 < y.im

    1. Initial program 46.6%

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot x.re}{y.im}} \]
      2. neg-mul-175.5%

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

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

    if -2.94999999999999997e-64 < y.im < 1.9199999999999999e99

    1. Initial program 73.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -2.95 \cdot 10^{-64} \lor \neg \left(y.im \leq 1.92 \cdot 10^{+99}\right):\\ \;\;\;\;\frac{-x.re}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \end{array} \]

Alternative 9: 41.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 60.0%

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

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

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

Reproduce

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