_divideComplex, real part

Percentage Accurate: 61.9% → 86.4%
Time: 13.9s
Alternatives: 13
Speedup: 2.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

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

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

Alternative 1: 86.4% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 2 \cdot 10^{+270}\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0
         (/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im)))))
   (if (or (<= t_0 (- INFINITY)) (not (<= t_0 2e+270)))
     (/ (fma x.im (/ y.im y.re) x.re) y.re)
     (/
      (/ (fma x.im y.im (* x.re y.re)) (hypot y.re y.im))
      (hypot y.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_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	double tmp;
	if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 2e+270)) {
		tmp = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
	} else {
		tmp = (fma(x_46_im, y_46_im, (x_46_re * y_46_re)) / hypot(y_46_re, y_46_im)) / hypot(y_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(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)))
	tmp = 0.0
	if ((t_0 <= Float64(-Inf)) || !(t_0 <= 2e+270))
		tmp = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re);
	else
		tmp = Float64(Float64(fma(x_46_im, y_46_im, Float64(x_46_re * y_46_re)) / hypot(y_46_re, y_46_im)) / hypot(y_46_re, y_46_im));
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 2e+270]], $MachinePrecision]], N[(N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], N[(N[(N[(x$46$im * y$46$im + N[(x$46$re * y$46$re), $MachinePrecision]), $MachinePrecision] / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (*.f64 x.re y.re) (*.f64 x.im y.im)) (+.f64 (*.f64 y.re y.re) (*.f64 y.im y.im))) < -inf.0 or 2.0000000000000001e270 < (/.f64 (+.f64 (*.f64 x.re y.re) (*.f64 x.im y.im)) (+.f64 (*.f64 y.re y.re) (*.f64 y.im y.im)))

    1. Initial program 16.9%

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

      \[\leadsto \frac{x.re \cdot y.re + x.im \cdot y.im}{\color{blue}{{y.re}^{2}}} \]
    4. Step-by-step derivation
      1. *-un-lft-identity17.6%

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

        \[\leadsto \frac{1 \cdot \color{blue}{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)}}{{y.re}^{2}} \]
      3. pow217.6%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{y.re} \cdot \frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u12.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{y.re} \cdot \frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re}\right)\right)} \]
      2. expm1-udef12.4%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{1}{y.re} \cdot \frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re}\right)} - 1} \]
      3. *-commutative12.4%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re} \cdot \frac{1}{y.re}}\right)} - 1 \]
      4. div-inv12.4%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right) \cdot \frac{1}{y.re}\right)} \cdot \frac{1}{y.re}\right)} - 1 \]
      5. associate-*l*9.3%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right) \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)}\right)} - 1 \]
      6. fma-udef9.3%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(x.im \cdot y.im + x.re \cdot y.re\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      7. +-commutative9.3%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(x.re \cdot y.re + x.im \cdot y.im\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      8. fma-def9.3%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      9. inv-pow9.3%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \left(\color{blue}{{y.re}^{-1}} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      10. inv-pow9.3%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \left({y.re}^{-1} \cdot \color{blue}{{y.re}^{-1}}\right)\right)} - 1 \]
      11. pow-prod-up9.3%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \color{blue}{{y.re}^{\left(-1 + -1\right)}}\right)} - 1 \]
      12. metadata-eval9.3%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def9.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}\right)\right)} \]
      2. expm1-log1p17.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}} \]
      3. *-commutative17.7%

        \[\leadsto \color{blue}{{y.re}^{-2} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)} \]
      4. metadata-eval17.7%

        \[\leadsto {y.re}^{\color{blue}{\left(2 \cdot -1\right)}} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \]
      5. pow-sqr17.7%

        \[\leadsto \color{blue}{\left({y.re}^{-1} \cdot {y.re}^{-1}\right)} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \]
      6. unpow-117.7%

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

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

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

        \[\leadsto \frac{1}{y.re} \cdot \color{blue}{\frac{1 \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)}{y.re}} \]
      10. *-lft-identity22.4%

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

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

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

    if -inf.0 < (/.f64 (+.f64 (*.f64 x.re y.re) (*.f64 x.im y.im)) (+.f64 (*.f64 y.re y.re) (*.f64 y.im y.im))) < 2.0000000000000001e270

    1. Initial program 82.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{\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 simplification85.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \leq -\infty \lor \neg \left(\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \leq 2 \cdot 10^{+270}\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 86.1% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x.re \cdot y.re + x.im \cdot y.im\\ t_1 := \frac{t_0}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+294} \lor \neg \left(t_1 \leq 2 \cdot 10^{+270}\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (+ (* x.re y.re) (* x.im y.im)))
        (t_1 (/ t_0 (+ (* y.re y.re) (* y.im y.im)))))
   (if (or (<= t_1 -1e+294) (not (<= t_1 2e+270)))
     (/ (fma x.im (/ y.im y.re) x.re) y.re)
     (* (/ 1.0 (hypot y.re y.im)) (/ t_0 (hypot y.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_re * y_46_re) + (x_46_im * y_46_im);
	double t_1 = t_0 / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	double tmp;
	if ((t_1 <= -1e+294) || !(t_1 <= 2e+270)) {
		tmp = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
	} else {
		tmp = (1.0 / hypot(y_46_re, y_46_im)) * (t_0 / hypot(y_46_re, y_46_im));
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im))
	t_1 = Float64(t_0 / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)))
	tmp = 0.0
	if ((t_1 <= -1e+294) || !(t_1 <= 2e+270))
		tmp = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re);
	else
		tmp = Float64(Float64(1.0 / hypot(y_46_re, y_46_im)) * Float64(t_0 / hypot(y_46_re, y_46_im)));
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -1e+294], N[Not[LessEqual[t$95$1, 2e+270]], $MachinePrecision]], N[(N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], 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]]]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (*.f64 x.re y.re) (*.f64 x.im y.im)) (+.f64 (*.f64 y.re y.re) (*.f64 y.im y.im))) < -1.00000000000000007e294 or 2.0000000000000001e270 < (/.f64 (+.f64 (*.f64 x.re y.re) (*.f64 x.im y.im)) (+.f64 (*.f64 y.re y.re) (*.f64 y.im y.im)))

    1. Initial program 17.7%

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

      \[\leadsto \frac{x.re \cdot y.re + x.im \cdot y.im}{\color{blue}{{y.re}^{2}}} \]
    4. Step-by-step derivation
      1. *-un-lft-identity18.5%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(x.re \cdot y.re + x.im \cdot y.im\right)}}{{y.re}^{2}} \]
      2. fma-def18.5%

        \[\leadsto \frac{1 \cdot \color{blue}{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)}}{{y.re}^{2}} \]
      3. pow218.5%

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

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

        \[\leadsto \frac{1}{y.re} \cdot \frac{\color{blue}{x.re \cdot y.re + x.im \cdot y.im}}{y.re} \]
      6. +-commutative23.2%

        \[\leadsto \frac{1}{y.re} \cdot \frac{\color{blue}{x.im \cdot y.im + x.re \cdot y.re}}{y.re} \]
      7. fma-def23.2%

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

      \[\leadsto \color{blue}{\frac{1}{y.re} \cdot \frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u12.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{y.re} \cdot \frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re}\right)\right)} \]
      2. expm1-udef12.3%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{1}{y.re} \cdot \frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re}\right)} - 1} \]
      3. *-commutative12.3%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re} \cdot \frac{1}{y.re}}\right)} - 1 \]
      4. div-inv12.3%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right) \cdot \frac{1}{y.re}\right)} \cdot \frac{1}{y.re}\right)} - 1 \]
      5. associate-*l*9.2%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right) \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)}\right)} - 1 \]
      6. fma-udef9.2%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(x.im \cdot y.im + x.re \cdot y.re\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      7. +-commutative9.2%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(x.re \cdot y.re + x.im \cdot y.im\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      8. fma-def9.2%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      9. inv-pow9.2%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \left(\color{blue}{{y.re}^{-1}} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      10. inv-pow9.2%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \left({y.re}^{-1} \cdot \color{blue}{{y.re}^{-1}}\right)\right)} - 1 \]
      11. pow-prod-up9.2%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \color{blue}{{y.re}^{\left(-1 + -1\right)}}\right)} - 1 \]
      12. metadata-eval9.2%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def9.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}\right)\right)} \]
      2. expm1-log1p18.6%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}} \]
      3. *-commutative18.6%

        \[\leadsto \color{blue}{{y.re}^{-2} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)} \]
      4. metadata-eval18.6%

        \[\leadsto {y.re}^{\color{blue}{\left(2 \cdot -1\right)}} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \]
      5. pow-sqr18.5%

        \[\leadsto \color{blue}{\left({y.re}^{-1} \cdot {y.re}^{-1}\right)} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \]
      6. unpow-118.5%

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

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

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

        \[\leadsto \frac{1}{y.re} \cdot \color{blue}{\frac{1 \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)}{y.re}} \]
      10. *-lft-identity23.2%

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

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

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

    if -1.00000000000000007e294 < (/.f64 (+.f64 (*.f64 x.re y.re) (*.f64 x.im y.im)) (+.f64 (*.f64 y.re y.re) (*.f64 y.im y.im))) < 2.0000000000000001e270

    1. Initial program 82.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \leq -1 \cdot 10^{+294} \lor \neg \left(\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \leq 2 \cdot 10^{+270}\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{x.re \cdot y.re + x.im \cdot y.im}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 78.1% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{x.re}{\mathsf{hypot}\left(y.re, y.im\right)}\\ t_1 := \frac{x.re}{\frac{y.im}{y.re}}\\ \mathbf{if}\;y.im \leq -3.8 \cdot 10^{+92}:\\ \;\;\;\;\frac{\left(-x.im\right) - t_1}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{elif}\;y.im \leq -3.6 \cdot 10^{-69}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.im \leq 7.5 \cdot 10^{-87}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{elif}\;y.im \leq 1.62 \cdot 10^{-12}:\\ \;\;\;\;\frac{x.re \cdot y.re + x.im \cdot y.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\ \mathbf{elif}\;y.im \leq 3.4 \cdot 10^{+61}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im + t_1}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (* (/ y.re (hypot y.re y.im)) (/ x.re (hypot y.re y.im))))
        (t_1 (/ x.re (/ y.im y.re))))
   (if (<= y.im -3.8e+92)
     (/ (- (- x.im) t_1) (hypot y.re y.im))
     (if (<= y.im -3.6e-69)
       t_0
       (if (<= y.im 7.5e-87)
         (/ (fma x.im (/ y.im y.re) x.re) y.re)
         (if (<= y.im 1.62e-12)
           (/ (+ (* x.re y.re) (* x.im y.im)) (fma y.im y.im (* y.re y.re)))
           (if (<= y.im 3.4e+61) t_0 (/ (+ x.im t_1) (hypot y.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 / hypot(y_46_re, y_46_im)) * (x_46_re / hypot(y_46_re, y_46_im));
	double t_1 = x_46_re / (y_46_im / y_46_re);
	double tmp;
	if (y_46_im <= -3.8e+92) {
		tmp = (-x_46_im - t_1) / hypot(y_46_re, y_46_im);
	} else if (y_46_im <= -3.6e-69) {
		tmp = t_0;
	} else if (y_46_im <= 7.5e-87) {
		tmp = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
	} else if (y_46_im <= 1.62e-12) {
		tmp = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / fma(y_46_im, y_46_im, (y_46_re * y_46_re));
	} else if (y_46_im <= 3.4e+61) {
		tmp = t_0;
	} else {
		tmp = (x_46_im + t_1) / hypot(y_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 / hypot(y_46_re, y_46_im)) * Float64(x_46_re / hypot(y_46_re, y_46_im)))
	t_1 = Float64(x_46_re / Float64(y_46_im / y_46_re))
	tmp = 0.0
	if (y_46_im <= -3.8e+92)
		tmp = Float64(Float64(Float64(-x_46_im) - t_1) / hypot(y_46_re, y_46_im));
	elseif (y_46_im <= -3.6e-69)
		tmp = t_0;
	elseif (y_46_im <= 7.5e-87)
		tmp = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re);
	elseif (y_46_im <= 1.62e-12)
		tmp = Float64(Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re)));
	elseif (y_46_im <= 3.4e+61)
		tmp = t_0;
	else
		tmp = Float64(Float64(x_46_im + t_1) / hypot(y_46_re, y_46_im));
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(y$46$re / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision] * N[(x$46$re / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x$46$re / N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$im, -3.8e+92], N[(N[((-x$46$im) - t$95$1), $MachinePrecision] / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, -3.6e-69], t$95$0, If[LessEqual[y$46$im, 7.5e-87], N[(N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 1.62e-12], N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 3.4e+61], t$95$0, N[(N[(x$46$im + t$95$1), $MachinePrecision] / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if y.im < -3.8e92

    1. Initial program 37.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.8e92 < y.im < -3.60000000000000018e-69 or 1.62e-12 < y.im < 3.40000000000000026e61

    1. Initial program 66.5%

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

      \[\leadsto \frac{\color{blue}{x.re \cdot y.re}}{y.re \cdot y.re + y.im \cdot y.im} \]
    4. Step-by-step derivation
      1. *-commutative56.5%

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

      \[\leadsto \frac{\color{blue}{y.re \cdot x.re}}{y.re \cdot y.re + y.im \cdot y.im} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt56.5%

        \[\leadsto \frac{y.re \cdot x.re}{\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}}} \]
      2. hypot-udef56.5%

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

        \[\leadsto \frac{y.re \cdot x.re}{\mathsf{hypot}\left(y.re, y.im\right) \cdot \color{blue}{\mathsf{hypot}\left(y.re, y.im\right)}} \]
      4. times-frac83.7%

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

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

    if -3.60000000000000018e-69 < y.im < 7.5000000000000002e-87

    1. Initial program 68.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{y.re} \cdot \frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u48.3%

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{1}{y.re} \cdot \frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re}\right)} - 1} \]
      3. *-commutative28.7%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re} \cdot \frac{1}{y.re}}\right)} - 1 \]
      4. div-inv28.7%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right) \cdot \frac{1}{y.re}\right)} \cdot \frac{1}{y.re}\right)} - 1 \]
      5. associate-*l*25.5%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right) \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)}\right)} - 1 \]
      6. fma-udef25.5%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(x.im \cdot y.im + x.re \cdot y.re\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      7. +-commutative25.5%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(x.re \cdot y.re + x.im \cdot y.im\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      8. fma-def25.5%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      9. inv-pow25.5%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \left(\color{blue}{{y.re}^{-1}} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      10. inv-pow25.5%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \left({y.re}^{-1} \cdot \color{blue}{{y.re}^{-1}}\right)\right)} - 1 \]
      11. pow-prod-up25.5%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \color{blue}{{y.re}^{\left(-1 + -1\right)}}\right)} - 1 \]
      12. metadata-eval25.5%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{\color{blue}{-2}}\right)} - 1 \]
    7. Applied egg-rr25.5%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def41.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}\right)\right)} \]
      2. expm1-log1p60.1%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}} \]
      3. *-commutative60.1%

        \[\leadsto \color{blue}{{y.re}^{-2} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)} \]
      4. metadata-eval60.1%

        \[\leadsto {y.re}^{\color{blue}{\left(2 \cdot -1\right)}} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \]
      5. pow-sqr60.1%

        \[\leadsto \color{blue}{\left({y.re}^{-1} \cdot {y.re}^{-1}\right)} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \]
      6. unpow-160.1%

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

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

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

        \[\leadsto \frac{1}{y.re} \cdot \color{blue}{\frac{1 \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)}{y.re}} \]
      10. *-lft-identity68.5%

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

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

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

    if 7.5000000000000002e-87 < y.im < 1.62e-12

    1. Initial program 82.3%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-def82.3%

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

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

    if 3.40000000000000026e61 < y.im

    1. Initial program 46.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{x.im + \frac{x.re}{\frac{y.im}{y.re}}}}{\mathsf{hypot}\left(y.re, y.im\right)} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification84.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -3.8 \cdot 10^{+92}:\\ \;\;\;\;\frac{\left(-x.im\right) - \frac{x.re}{\frac{y.im}{y.re}}}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{elif}\;y.im \leq -3.6 \cdot 10^{-69}:\\ \;\;\;\;\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{x.re}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{elif}\;y.im \leq 7.5 \cdot 10^{-87}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{elif}\;y.im \leq 1.62 \cdot 10^{-12}:\\ \;\;\;\;\frac{x.re \cdot y.re + x.im \cdot y.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\ \mathbf{elif}\;y.im \leq 3.4 \cdot 10^{+61}:\\ \;\;\;\;\frac{y.re}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{x.re}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im + \frac{x.re}{\frac{y.im}{y.re}}}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 78.4% accurate, 0.1× speedup?

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

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

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

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

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

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


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

    1. Initial program 37.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.79999999999999966e91 < y.im < 2.0500000000000001e-88 or 9.4999999999999999e-14 < y.im < 3.4999999999999999e44

    1. Initial program 68.3%

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

      \[\leadsto \frac{x.re \cdot y.re + x.im \cdot y.im}{\color{blue}{{y.re}^{2}}} \]
    4. Step-by-step derivation
      1. *-un-lft-identity52.7%

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

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

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

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

        \[\leadsto \frac{1}{y.re} \cdot \frac{\color{blue}{x.re \cdot y.re + x.im \cdot y.im}}{y.re} \]
      6. +-commutative63.7%

        \[\leadsto \frac{1}{y.re} \cdot \frac{\color{blue}{x.im \cdot y.im + x.re \cdot y.re}}{y.re} \]
      7. fma-def63.7%

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

      \[\leadsto \color{blue}{\frac{1}{y.re} \cdot \frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u48.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{y.re} \cdot \frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re}\right)\right)} \]
      2. expm1-udef25.8%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{1}{y.re} \cdot \frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re}\right)} - 1} \]
      3. *-commutative25.8%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re} \cdot \frac{1}{y.re}}\right)} - 1 \]
      4. div-inv25.8%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right) \cdot \frac{1}{y.re}\right)} \cdot \frac{1}{y.re}\right)} - 1 \]
      5. associate-*l*23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right) \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)}\right)} - 1 \]
      6. fma-udef23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(x.im \cdot y.im + x.re \cdot y.re\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      7. +-commutative23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(x.re \cdot y.re + x.im \cdot y.im\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      8. fma-def23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      9. inv-pow23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \left(\color{blue}{{y.re}^{-1}} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      10. inv-pow23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \left({y.re}^{-1} \cdot \color{blue}{{y.re}^{-1}}\right)\right)} - 1 \]
      11. pow-prod-up23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \color{blue}{{y.re}^{\left(-1 + -1\right)}}\right)} - 1 \]
      12. metadata-eval23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{\color{blue}{-2}}\right)} - 1 \]
    7. Applied egg-rr23.6%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def39.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}\right)\right)} \]
      2. expm1-log1p53.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}} \]
      3. *-commutative53.4%

        \[\leadsto \color{blue}{{y.re}^{-2} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)} \]
      4. metadata-eval53.4%

        \[\leadsto {y.re}^{\color{blue}{\left(2 \cdot -1\right)}} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \]
      5. pow-sqr53.4%

        \[\leadsto \color{blue}{\left({y.re}^{-1} \cdot {y.re}^{-1}\right)} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \]
      6. unpow-153.4%

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

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

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

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

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

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

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

    if 2.0500000000000001e-88 < y.im < 9.4999999999999999e-14

    1. Initial program 82.3%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-def82.3%

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

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

    if 3.4999999999999999e44 < y.im

    1. Initial program 46.4%

      \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity46.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -4.8 \cdot 10^{+91}:\\ \;\;\;\;\frac{\left(-x.im\right) - \frac{x.re}{\frac{y.im}{y.re}}}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{elif}\;y.im \leq 2.05 \cdot 10^{-88}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{elif}\;y.im \leq 9.5 \cdot 10^{-14}:\\ \;\;\;\;\frac{x.re \cdot y.re + x.im \cdot y.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\ \mathbf{elif}\;y.im \leq 3.5 \cdot 10^{+44}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im + \frac{x.re}{\frac{y.im}{y.re}}}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 76.2% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ t_1 := \frac{x.im}{y.im} + y.re \cdot \frac{x.re}{{y.im}^{2}}\\ \mathbf{if}\;y.im \leq -4.8 \cdot 10^{+91}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.im \leq 6.5 \cdot 10^{-88}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.im \leq 2.55 \cdot 10^{-14}:\\ \;\;\;\;\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 7 \cdot 10^{+43}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (/ (fma x.im (/ y.im y.re) x.re) y.re))
        (t_1 (+ (/ x.im y.im) (* y.re (/ x.re (pow y.im 2.0))))))
   (if (<= y.im -4.8e+91)
     t_1
     (if (<= y.im 6.5e-88)
       t_0
       (if (<= y.im 2.55e-14)
         (/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im)))
         (if (<= y.im 7e+43) t_0 t_1))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
	double t_1 = (x_46_im / y_46_im) + (y_46_re * (x_46_re / pow(y_46_im, 2.0)));
	double tmp;
	if (y_46_im <= -4.8e+91) {
		tmp = t_1;
	} else if (y_46_im <= 6.5e-88) {
		tmp = t_0;
	} else if (y_46_im <= 2.55e-14) {
		tmp = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	} else if (y_46_im <= 7e+43) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re)
	t_1 = Float64(Float64(x_46_im / y_46_im) + Float64(y_46_re * Float64(x_46_re / (y_46_im ^ 2.0))))
	tmp = 0.0
	if (y_46_im <= -4.8e+91)
		tmp = t_1;
	elseif (y_46_im <= 6.5e-88)
		tmp = t_0;
	elseif (y_46_im <= 2.55e-14)
		tmp = Float64(Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)));
	elseif (y_46_im <= 7e+43)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x$46$im / y$46$im), $MachinePrecision] + N[(y$46$re * N[(x$46$re / N[Power[y$46$im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$im, -4.8e+91], t$95$1, If[LessEqual[y$46$im, 6.5e-88], t$95$0, If[LessEqual[y$46$im, 2.55e-14], N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 7e+43], t$95$0, t$95$1]]]]]]
\begin{array}{l}

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.im < -4.79999999999999966e91 or 7.0000000000000002e43 < y.im

    1. Initial program 42.0%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.im} + \frac{x.re \cdot y.re}{{y.im}^{2}}} \]
    4. Step-by-step derivation
      1. associate-/l*75.3%

        \[\leadsto \frac{x.im}{y.im} + \color{blue}{\frac{x.re}{\frac{{y.im}^{2}}{y.re}}} \]
      2. associate-/r/77.1%

        \[\leadsto \frac{x.im}{y.im} + \color{blue}{\frac{x.re}{{y.im}^{2}} \cdot y.re} \]
    5. Simplified77.1%

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

    if -4.79999999999999966e91 < y.im < 6.50000000000000006e-88 or 2.5499999999999999e-14 < y.im < 7.0000000000000002e43

    1. Initial program 68.3%

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

      \[\leadsto \frac{x.re \cdot y.re + x.im \cdot y.im}{\color{blue}{{y.re}^{2}}} \]
    4. Step-by-step derivation
      1. *-un-lft-identity52.7%

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

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

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

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

        \[\leadsto \frac{1}{y.re} \cdot \frac{\color{blue}{x.re \cdot y.re + x.im \cdot y.im}}{y.re} \]
      6. +-commutative63.7%

        \[\leadsto \frac{1}{y.re} \cdot \frac{\color{blue}{x.im \cdot y.im + x.re \cdot y.re}}{y.re} \]
      7. fma-def63.7%

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

      \[\leadsto \color{blue}{\frac{1}{y.re} \cdot \frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u48.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{y.re} \cdot \frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re}\right)\right)} \]
      2. expm1-udef25.8%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{1}{y.re} \cdot \frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re}\right)} - 1} \]
      3. *-commutative25.8%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re} \cdot \frac{1}{y.re}}\right)} - 1 \]
      4. div-inv25.8%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right) \cdot \frac{1}{y.re}\right)} \cdot \frac{1}{y.re}\right)} - 1 \]
      5. associate-*l*23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right) \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)}\right)} - 1 \]
      6. fma-udef23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(x.im \cdot y.im + x.re \cdot y.re\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      7. +-commutative23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(x.re \cdot y.re + x.im \cdot y.im\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      8. fma-def23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      9. inv-pow23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \left(\color{blue}{{y.re}^{-1}} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      10. inv-pow23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \left({y.re}^{-1} \cdot \color{blue}{{y.re}^{-1}}\right)\right)} - 1 \]
      11. pow-prod-up23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \color{blue}{{y.re}^{\left(-1 + -1\right)}}\right)} - 1 \]
      12. metadata-eval23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{\color{blue}{-2}}\right)} - 1 \]
    7. Applied egg-rr23.6%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def39.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}\right)\right)} \]
      2. expm1-log1p53.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}} \]
      3. *-commutative53.4%

        \[\leadsto \color{blue}{{y.re}^{-2} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)} \]
      4. metadata-eval53.4%

        \[\leadsto {y.re}^{\color{blue}{\left(2 \cdot -1\right)}} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \]
      5. pow-sqr53.4%

        \[\leadsto \color{blue}{\left({y.re}^{-1} \cdot {y.re}^{-1}\right)} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \]
      6. unpow-153.4%

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

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

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

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

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

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

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

    if 6.50000000000000006e-88 < y.im < 2.5499999999999999e-14

    1. Initial program 82.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -4.8 \cdot 10^{+91}:\\ \;\;\;\;\frac{x.im}{y.im} + y.re \cdot \frac{x.re}{{y.im}^{2}}\\ \mathbf{elif}\;y.im \leq 6.5 \cdot 10^{-88}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{elif}\;y.im \leq 2.55 \cdot 10^{-14}:\\ \;\;\;\;\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 7 \cdot 10^{+43}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.im} + y.re \cdot \frac{x.re}{{y.im}^{2}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 77.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{if}\;y.im \leq -5 \cdot 10^{+91}:\\ \;\;\;\;\frac{x.im}{y.im} + y.re \cdot \frac{x.re}{{y.im}^{2}}\\ \mathbf{elif}\;y.im \leq 6.5 \cdot 10^{-88}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.im \leq 5.2 \cdot 10^{-14}:\\ \;\;\;\;\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 2.5 \cdot 10^{+43}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im + \frac{x.re}{\frac{y.im}{y.re}}}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (/ (fma x.im (/ y.im y.re) x.re) y.re)))
   (if (<= y.im -5e+91)
     (+ (/ x.im y.im) (* y.re (/ x.re (pow y.im 2.0))))
     (if (<= y.im 6.5e-88)
       t_0
       (if (<= y.im 5.2e-14)
         (/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im)))
         (if (<= y.im 2.5e+43)
           t_0
           (/ (+ x.im (/ x.re (/ y.im y.re))) (hypot y.re y.im))))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
	double tmp;
	if (y_46_im <= -5e+91) {
		tmp = (x_46_im / y_46_im) + (y_46_re * (x_46_re / pow(y_46_im, 2.0)));
	} else if (y_46_im <= 6.5e-88) {
		tmp = t_0;
	} else if (y_46_im <= 5.2e-14) {
		tmp = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	} else if (y_46_im <= 2.5e+43) {
		tmp = t_0;
	} else {
		tmp = (x_46_im + (x_46_re / (y_46_im / y_46_re))) / hypot(y_46_re, y_46_im);
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re)
	tmp = 0.0
	if (y_46_im <= -5e+91)
		tmp = Float64(Float64(x_46_im / y_46_im) + Float64(y_46_re * Float64(x_46_re / (y_46_im ^ 2.0))));
	elseif (y_46_im <= 6.5e-88)
		tmp = t_0;
	elseif (y_46_im <= 5.2e-14)
		tmp = Float64(Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)));
	elseif (y_46_im <= 2.5e+43)
		tmp = t_0;
	else
		tmp = Float64(Float64(x_46_im + Float64(x_46_re / Float64(y_46_im / y_46_re))) / hypot(y_46_re, y_46_im));
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$im, -5e+91], N[(N[(x$46$im / y$46$im), $MachinePrecision] + N[(y$46$re * N[(x$46$re / N[Power[y$46$im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 6.5e-88], t$95$0, If[LessEqual[y$46$im, 5.2e-14], N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 2.5e+43], t$95$0, N[(N[(x$46$im + N[(x$46$re / N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

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

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

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

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


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

    1. Initial program 37.2%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.im} + \frac{x.re \cdot y.re}{{y.im}^{2}}} \]
    4. Step-by-step derivation
      1. associate-/l*70.3%

        \[\leadsto \frac{x.im}{y.im} + \color{blue}{\frac{x.re}{\frac{{y.im}^{2}}{y.re}}} \]
      2. associate-/r/72.7%

        \[\leadsto \frac{x.im}{y.im} + \color{blue}{\frac{x.re}{{y.im}^{2}} \cdot y.re} \]
    5. Simplified72.7%

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

    if -5.0000000000000002e91 < y.im < 6.50000000000000006e-88 or 5.19999999999999993e-14 < y.im < 2.5000000000000002e43

    1. Initial program 68.3%

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

      \[\leadsto \frac{x.re \cdot y.re + x.im \cdot y.im}{\color{blue}{{y.re}^{2}}} \]
    4. Step-by-step derivation
      1. *-un-lft-identity52.7%

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

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

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

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

        \[\leadsto \frac{1}{y.re} \cdot \frac{\color{blue}{x.re \cdot y.re + x.im \cdot y.im}}{y.re} \]
      6. +-commutative63.7%

        \[\leadsto \frac{1}{y.re} \cdot \frac{\color{blue}{x.im \cdot y.im + x.re \cdot y.re}}{y.re} \]
      7. fma-def63.7%

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

      \[\leadsto \color{blue}{\frac{1}{y.re} \cdot \frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u48.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{y.re} \cdot \frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re}\right)\right)} \]
      2. expm1-udef25.8%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{1}{y.re} \cdot \frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re}\right)} - 1} \]
      3. *-commutative25.8%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re} \cdot \frac{1}{y.re}}\right)} - 1 \]
      4. div-inv25.8%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right) \cdot \frac{1}{y.re}\right)} \cdot \frac{1}{y.re}\right)} - 1 \]
      5. associate-*l*23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right) \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)}\right)} - 1 \]
      6. fma-udef23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(x.im \cdot y.im + x.re \cdot y.re\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      7. +-commutative23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(x.re \cdot y.re + x.im \cdot y.im\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      8. fma-def23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      9. inv-pow23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \left(\color{blue}{{y.re}^{-1}} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      10. inv-pow23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \left({y.re}^{-1} \cdot \color{blue}{{y.re}^{-1}}\right)\right)} - 1 \]
      11. pow-prod-up23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \color{blue}{{y.re}^{\left(-1 + -1\right)}}\right)} - 1 \]
      12. metadata-eval23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{\color{blue}{-2}}\right)} - 1 \]
    7. Applied egg-rr23.6%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def39.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}\right)\right)} \]
      2. expm1-log1p53.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}} \]
      3. *-commutative53.4%

        \[\leadsto \color{blue}{{y.re}^{-2} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)} \]
      4. metadata-eval53.4%

        \[\leadsto {y.re}^{\color{blue}{\left(2 \cdot -1\right)}} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \]
      5. pow-sqr53.4%

        \[\leadsto \color{blue}{\left({y.re}^{-1} \cdot {y.re}^{-1}\right)} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \]
      6. unpow-153.4%

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

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

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

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

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

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

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

    if 6.50000000000000006e-88 < y.im < 5.19999999999999993e-14

    1. Initial program 82.3%

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

    if 2.5000000000000002e43 < y.im

    1. Initial program 46.4%

      \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity46.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -5 \cdot 10^{+91}:\\ \;\;\;\;\frac{x.im}{y.im} + y.re \cdot \frac{x.re}{{y.im}^{2}}\\ \mathbf{elif}\;y.im \leq 6.5 \cdot 10^{-88}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{elif}\;y.im \leq 5.2 \cdot 10^{-14}:\\ \;\;\;\;\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 2.5 \cdot 10^{+43}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im + \frac{x.re}{\frac{y.im}{y.re}}}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 78.5% accurate, 0.1× speedup?

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

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

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

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

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

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


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

    1. Initial program 37.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.02000000000000003e92 < y.im < 3.80000000000000011e-88 or 1.65e-12 < y.im < 9.50000000000000019e42

    1. Initial program 68.3%

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

      \[\leadsto \frac{x.re \cdot y.re + x.im \cdot y.im}{\color{blue}{{y.re}^{2}}} \]
    4. Step-by-step derivation
      1. *-un-lft-identity52.7%

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

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

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

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

        \[\leadsto \frac{1}{y.re} \cdot \frac{\color{blue}{x.re \cdot y.re + x.im \cdot y.im}}{y.re} \]
      6. +-commutative63.7%

        \[\leadsto \frac{1}{y.re} \cdot \frac{\color{blue}{x.im \cdot y.im + x.re \cdot y.re}}{y.re} \]
      7. fma-def63.7%

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

      \[\leadsto \color{blue}{\frac{1}{y.re} \cdot \frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u48.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{y.re} \cdot \frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re}\right)\right)} \]
      2. expm1-udef25.8%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{1}{y.re} \cdot \frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re}\right)} - 1} \]
      3. *-commutative25.8%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re} \cdot \frac{1}{y.re}}\right)} - 1 \]
      4. div-inv25.8%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right) \cdot \frac{1}{y.re}\right)} \cdot \frac{1}{y.re}\right)} - 1 \]
      5. associate-*l*23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right) \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)}\right)} - 1 \]
      6. fma-udef23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(x.im \cdot y.im + x.re \cdot y.re\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      7. +-commutative23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(x.re \cdot y.re + x.im \cdot y.im\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      8. fma-def23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      9. inv-pow23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \left(\color{blue}{{y.re}^{-1}} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      10. inv-pow23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \left({y.re}^{-1} \cdot \color{blue}{{y.re}^{-1}}\right)\right)} - 1 \]
      11. pow-prod-up23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \color{blue}{{y.re}^{\left(-1 + -1\right)}}\right)} - 1 \]
      12. metadata-eval23.6%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{\color{blue}{-2}}\right)} - 1 \]
    7. Applied egg-rr23.6%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def39.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}\right)\right)} \]
      2. expm1-log1p53.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}} \]
      3. *-commutative53.4%

        \[\leadsto \color{blue}{{y.re}^{-2} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)} \]
      4. metadata-eval53.4%

        \[\leadsto {y.re}^{\color{blue}{\left(2 \cdot -1\right)}} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \]
      5. pow-sqr53.4%

        \[\leadsto \color{blue}{\left({y.re}^{-1} \cdot {y.re}^{-1}\right)} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \]
      6. unpow-153.4%

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

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

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

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

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

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

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

    if 3.80000000000000011e-88 < y.im < 1.65e-12

    1. Initial program 82.3%

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

    if 9.50000000000000019e42 < y.im

    1. Initial program 46.4%

      \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity46.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -1.02 \cdot 10^{+92}:\\ \;\;\;\;\frac{\left(-x.im\right) - \frac{x.re}{\frac{y.im}{y.re}}}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{elif}\;y.im \leq 3.8 \cdot 10^{-88}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{elif}\;y.im \leq 1.65 \cdot 10^{-12}:\\ \;\;\;\;\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 9.5 \cdot 10^{+42}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im + \frac{x.re}{\frac{y.im}{y.re}}}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 79.7% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{if}\;y.im \leq -2 \cdot 10^{+116}:\\ \;\;\;\;\frac{-x.im}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{elif}\;y.im \leq -5.3 \cdot 10^{-81}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.im \leq 6.8 \cdot 10^{-87}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{elif}\;y.im \leq 1.15 \cdot 10^{+92}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0
         (/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im)))))
   (if (<= y.im -2e+116)
     (/ (- x.im) (hypot y.re y.im))
     (if (<= y.im -5.3e-81)
       t_0
       (if (<= y.im 6.8e-87)
         (/ (fma x.im (/ y.im y.re) x.re) y.re)
         (if (<= y.im 1.15e+92) t_0 (/ x.im 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_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	double tmp;
	if (y_46_im <= -2e+116) {
		tmp = -x_46_im / hypot(y_46_re, y_46_im);
	} else if (y_46_im <= -5.3e-81) {
		tmp = t_0;
	} else if (y_46_im <= 6.8e-87) {
		tmp = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
	} else if (y_46_im <= 1.15e+92) {
		tmp = t_0;
	} else {
		tmp = x_46_im / y_46_im;
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)))
	tmp = 0.0
	if (y_46_im <= -2e+116)
		tmp = Float64(Float64(-x_46_im) / hypot(y_46_re, y_46_im));
	elseif (y_46_im <= -5.3e-81)
		tmp = t_0;
	elseif (y_46_im <= 6.8e-87)
		tmp = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re);
	elseif (y_46_im <= 1.15e+92)
		tmp = t_0;
	else
		tmp = Float64(x_46_im / y_46_im);
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$im, -2e+116], N[((-x$46$im) / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, -5.3e-81], t$95$0, If[LessEqual[y$46$im, 6.8e-87], N[(N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 1.15e+92], t$95$0, N[(x$46$im / y$46$im), $MachinePrecision]]]]]]
\begin{array}{l}

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

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

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

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

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


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

    1. Initial program 30.4%

      \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity30.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.00000000000000003e116 < y.im < -5.3000000000000003e-81 or 6.7999999999999997e-87 < y.im < 1.14999999999999999e92

    1. Initial program 73.1%

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

    if -5.3000000000000003e-81 < y.im < 6.7999999999999997e-87

    1. Initial program 67.7%

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

      \[\leadsto \frac{x.re \cdot y.re + x.im \cdot y.im}{\color{blue}{{y.re}^{2}}} \]
    4. Step-by-step derivation
      1. *-un-lft-identity60.0%

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

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

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

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

        \[\leadsto \frac{1}{y.re} \cdot \frac{\color{blue}{x.re \cdot y.re + x.im \cdot y.im}}{y.re} \]
      6. +-commutative69.7%

        \[\leadsto \frac{1}{y.re} \cdot \frac{\color{blue}{x.im \cdot y.im + x.re \cdot y.re}}{y.re} \]
      7. fma-def69.7%

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

      \[\leadsto \color{blue}{\frac{1}{y.re} \cdot \frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u50.1%

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{1}{y.re} \cdot \frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re}\right)} - 1} \]
      3. *-commutative29.7%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right)}{y.re} \cdot \frac{1}{y.re}}\right)} - 1 \]
      4. div-inv29.7%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right) \cdot \frac{1}{y.re}\right)} \cdot \frac{1}{y.re}\right)} - 1 \]
      5. associate-*l*26.4%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(x.im, y.im, x.re \cdot y.re\right) \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)}\right)} - 1 \]
      6. fma-udef26.4%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(x.im \cdot y.im + x.re \cdot y.re\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      7. +-commutative26.4%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\left(x.re \cdot y.re + x.im \cdot y.im\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      8. fma-def26.4%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)} \cdot \left(\frac{1}{y.re} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      9. inv-pow26.4%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \left(\color{blue}{{y.re}^{-1}} \cdot \frac{1}{y.re}\right)\right)} - 1 \]
      10. inv-pow26.4%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \left({y.re}^{-1} \cdot \color{blue}{{y.re}^{-1}}\right)\right)} - 1 \]
      11. pow-prod-up26.4%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \color{blue}{{y.re}^{\left(-1 + -1\right)}}\right)} - 1 \]
      12. metadata-eval26.4%

        \[\leadsto e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{\color{blue}{-2}}\right)} - 1 \]
    7. Applied egg-rr26.4%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def43.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}\right)\right)} \]
      2. expm1-log1p61.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot {y.re}^{-2}} \]
      3. *-commutative61.0%

        \[\leadsto \color{blue}{{y.re}^{-2} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)} \]
      4. metadata-eval61.0%

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

        \[\leadsto \color{blue}{\left({y.re}^{-1} \cdot {y.re}^{-1}\right)} \cdot \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \]
      6. unpow-160.9%

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

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

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

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

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

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

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

    if 1.14999999999999999e92 < y.im

    1. Initial program 42.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -2 \cdot 10^{+116}:\\ \;\;\;\;\frac{-x.im}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{elif}\;y.im \leq -5.3 \cdot 10^{-81}:\\ \;\;\;\;\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 6.8 \cdot 10^{-87}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{elif}\;y.im \leq 1.15 \cdot 10^{+92}:\\ \;\;\;\;\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 75.2% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;y.re \leq -1.5 \cdot 10^{-224}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;y.re \leq 8 \cdot 10^{+94}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 37.6%

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

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

    if -1.1599999999999999e104 < y.re < -1.49999999999999991e-224 or 2.44999999999999989e-218 < y.re < 8.0000000000000002e94

    1. Initial program 73.1%

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

    if -1.49999999999999991e-224 < y.re < 2.44999999999999989e-218

    1. Initial program 65.4%

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

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

    if 8.0000000000000002e94 < y.re

    1. Initial program 33.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -1.16 \cdot 10^{+104}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq -1.5 \cdot 10^{-224}:\\ \;\;\;\;\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.re \leq 2.45 \cdot 10^{-218}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{elif}\;y.re \leq 8 \cdot 10^{+94}:\\ \;\;\;\;\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 75.3% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;y.re \leq -5.2 \cdot 10^{-228}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;y.re \leq 1.2 \cdot 10^{+94}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 37.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot x.re}}{\mathsf{hypot}\left(y.re, y.im\right)} \]
    8. Step-by-step derivation
      1. neg-mul-172.8%

        \[\leadsto \frac{\color{blue}{-x.re}}{\mathsf{hypot}\left(y.re, y.im\right)} \]
    9. Simplified72.8%

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

    if -5.2000000000000004e105 < y.re < -5.2e-228 or 1.3e-220 < y.re < 1.19999999999999991e94

    1. Initial program 73.1%

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

    if -5.2e-228 < y.re < 1.3e-220

    1. Initial program 65.4%

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

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

    if 1.19999999999999991e94 < y.re

    1. Initial program 33.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -5.2 \cdot 10^{+105}:\\ \;\;\;\;\frac{-x.re}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{elif}\;y.re \leq -5.2 \cdot 10^{-228}:\\ \;\;\;\;\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.re \leq 1.3 \cdot 10^{-220}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{elif}\;y.re \leq 1.2 \cdot 10^{+94}:\\ \;\;\;\;\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 75.2% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;y.re \leq -1.15 \cdot 10^{-225}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;y.re \leq 3.1 \cdot 10^{+127}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.re < -5.49999999999999979e105 or 3.1000000000000002e127 < y.re

    1. Initial program 30.5%

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

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

    if -5.49999999999999979e105 < y.re < -1.1499999999999999e-225 or 5.8000000000000004e-222 < y.re < 3.1000000000000002e127

    1. Initial program 74.0%

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

    if -1.1499999999999999e-225 < y.re < 5.8000000000000004e-222

    1. Initial program 65.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -5.5 \cdot 10^{+105}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq -1.15 \cdot 10^{-225}:\\ \;\;\;\;\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.re \leq 5.8 \cdot 10^{-222}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{elif}\;y.re \leq 3.1 \cdot 10^{+127}:\\ \;\;\;\;\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 63.0% accurate, 2.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -1.6 \cdot 10^{+92} \lor \neg \left(y.im \leq 3.7 \cdot 10^{+43}\right):\\
\;\;\;\;\frac{x.im}{y.im}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < -1.60000000000000013e92 or 3.7000000000000001e43 < y.im

    1. Initial program 42.0%

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

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

    if -1.60000000000000013e92 < y.im < 3.7000000000000001e43

    1. Initial program 70.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -1.6 \cdot 10^{+92} \lor \neg \left(y.im \leq 3.7 \cdot 10^{+43}\right):\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 42.6% accurate, 5.0× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{x.im}{y.im}} \]
  4. Final simplification42.5%

    \[\leadsto \frac{x.im}{y.im} \]
  5. Add Preprocessing

Reproduce

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