_divideComplex, real part

Percentage Accurate: 61.8% → 80.6%
Time: 9.9s
Alternatives: 7
Speedup: 1.6×

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 7 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.8% 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: 80.6% accurate, 0.8× 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.re \leq -6.6 \cdot 10^{+111}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.re \leq -1.16 \cdot 10^{-102}:\\ \;\;\;\;\frac{y.re \cdot x.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.re \leq 6.8 \cdot 10^{+57}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.re, \frac{y.re}{y.im}, x.im\right)}{y.im}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (/ (fma x.im (/ y.im y.re) x.re) y.re)))
   (if (<= y.re -6.6e+111)
     t_0
     (if (<= y.re -1.16e-102)
       (/ (+ (* y.re x.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im)))
       (if (<= y.re 6.8e+57) (/ (fma x.re (/ y.re y.im) x.im) y.im) t_0)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
	double tmp;
	if (y_46_re <= -6.6e+111) {
		tmp = t_0;
	} else if (y_46_re <= -1.16e-102) {
		tmp = ((y_46_re * x_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	} else if (y_46_re <= 6.8e+57) {
		tmp = fma(x_46_re, (y_46_re / y_46_im), x_46_im) / y_46_im;
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re)
	tmp = 0.0
	if (y_46_re <= -6.6e+111)
		tmp = t_0;
	elseif (y_46_re <= -1.16e-102)
		tmp = Float64(Float64(Float64(y_46_re * x_46_re) + Float64(x_46_im * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)));
	elseif (y_46_re <= 6.8e+57)
		tmp = Float64(fma(x_46_re, Float64(y_46_re / y_46_im), x_46_im) / y_46_im);
	else
		tmp = t_0;
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -6.6e+111], t$95$0, If[LessEqual[y$46$re, -1.16e-102], N[(N[(N[(y$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 6.8e+57], N[(N[(x$46$re * N[(y$46$re / y$46$im), $MachinePrecision] + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], t$95$0]]]]
\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.re \leq -6.6 \cdot 10^{+111}:\\
\;\;\;\;t\_0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.re < -6.6000000000000002e111 or 6.79999999999999984e57 < y.re

    1. Initial program 45.6%

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

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

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

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

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

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

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

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

    if -6.6000000000000002e111 < y.re < -1.1599999999999999e-102

    1. Initial program 95.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

    if -1.1599999999999999e-102 < y.re < 6.79999999999999984e57

    1. Initial program 68.8%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -6.6 \cdot 10^{+111}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{elif}\;y.re \leq -1.16 \cdot 10^{-102}:\\ \;\;\;\;\frac{y.re \cdot x.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.re \leq 6.8 \cdot 10^{+57}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.re, \frac{y.re}{y.im}, x.im\right)}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 73.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.im \leq -2.5 \cdot 10^{+75}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{elif}\;y.im \leq 0.0112:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{elif}\;y.im \leq 3.1 \cdot 10^{+138}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{y.im \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (<= y.im -2.5e+75)
   (/ x.im y.im)
   (if (<= y.im 0.0112)
     (/ (fma x.im (/ y.im y.re) x.re) y.re)
     (if (<= y.im 3.1e+138)
       (/ (fma y.im x.im (* y.re x.re)) (* y.im y.im))
       (/ x.im y.im)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if (y_46_im <= -2.5e+75) {
		tmp = x_46_im / y_46_im;
	} else if (y_46_im <= 0.0112) {
		tmp = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
	} else if (y_46_im <= 3.1e+138) {
		tmp = fma(y_46_im, x_46_im, (y_46_re * x_46_re)) / (y_46_im * y_46_im);
	} else {
		tmp = x_46_im / y_46_im;
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0
	if (y_46_im <= -2.5e+75)
		tmp = Float64(x_46_im / y_46_im);
	elseif (y_46_im <= 0.0112)
		tmp = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re);
	elseif (y_46_im <= 3.1e+138)
		tmp = Float64(fma(y_46_im, x_46_im, Float64(y_46_re * x_46_re)) / Float64(y_46_im * y_46_im));
	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_] := If[LessEqual[y$46$im, -2.5e+75], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 0.0112], 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, 3.1e+138], N[(N[(y$46$im * x$46$im + N[(y$46$re * x$46$re), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision], N[(x$46$im / y$46$im), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -2.5 \cdot 10^{+75}:\\
\;\;\;\;\frac{x.im}{y.im}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.im < -2.5000000000000001e75 or 3.0999999999999998e138 < y.im

    1. Initial program 46.1%

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

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

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

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

    if -2.5000000000000001e75 < y.im < 0.0111999999999999999

    1. Initial program 72.3%

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

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

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

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

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

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

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

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

    if 0.0111999999999999999 < y.im < 3.0999999999999998e138

    1. Initial program 88.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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y.im \cdot x.im} + x.re \cdot y.re}{y.im \cdot y.im} \]
      6. lower-fma.f6479.4

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

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

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

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

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

Alternative 3: 78.0% accurate, 0.9× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < -1.24999999999999993e-21 or 0.00679999999999999962 < y.im

    1. Initial program 58.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.im around inf

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

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

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

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

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

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

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

    if -1.24999999999999993e-21 < y.im < 0.00679999999999999962

    1. Initial program 75.4%

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

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

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

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

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

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

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

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

Alternative 4: 63.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -8 \cdot 10^{+110}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq -1.85 \cdot 10^{-146}:\\ \;\;\;\;\frac{y.re \cdot x.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\ \mathbf{elif}\;y.re \leq 1.5 \cdot 10^{+93}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (<= y.re -8e+110)
   (/ x.re y.re)
   (if (<= y.re -1.85e-146)
     (/ (* y.re x.re) (fma y.im y.im (* y.re y.re)))
     (if (<= y.re 1.5e+93) (/ x.im y.im) (/ x.re y.re)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if (y_46_re <= -8e+110) {
		tmp = x_46_re / y_46_re;
	} else if (y_46_re <= -1.85e-146) {
		tmp = (y_46_re * x_46_re) / fma(y_46_im, y_46_im, (y_46_re * y_46_re));
	} else if (y_46_re <= 1.5e+93) {
		tmp = x_46_im / y_46_im;
	} else {
		tmp = x_46_re / y_46_re;
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0
	if (y_46_re <= -8e+110)
		tmp = Float64(x_46_re / y_46_re);
	elseif (y_46_re <= -1.85e-146)
		tmp = Float64(Float64(y_46_re * x_46_re) / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re)));
	elseif (y_46_re <= 1.5e+93)
		tmp = Float64(x_46_im / y_46_im);
	else
		tmp = Float64(x_46_re / y_46_re);
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -8e+110], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, -1.85e-146], N[(N[(y$46$re * x$46$re), $MachinePrecision] / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 1.5e+93], N[(x$46$im / y$46$im), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]]]
\begin{array}{l}

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.re < -8.0000000000000002e110 or 1.49999999999999989e93 < y.re

    1. Initial program 43.4%

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

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

        \[\leadsto \color{blue}{\frac{x.re}{y.re}} \]
    5. Simplified84.9%

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

    if -8.0000000000000002e110 < y.re < -1.84999999999999993e-146

    1. Initial program 92.8%

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

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

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

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

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

        \[\leadsto \frac{x.re \cdot y.re}{\color{blue}{\mathsf{fma}\left(y.im, y.im, {y.re}^{2}\right)}} \]
      5. unpow2N/A

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

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

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

    if -1.84999999999999993e-146 < y.re < 1.49999999999999989e93

    1. Initial program 69.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 0

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -8 \cdot 10^{+110}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq -1.85 \cdot 10^{-146}:\\ \;\;\;\;\frac{y.re \cdot x.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\ \mathbf{elif}\;y.re \leq 1.5 \cdot 10^{+93}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 63.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -7.2 \cdot 10^{+120}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq -1.45 \cdot 10^{-146}:\\ \;\;\;\;y.re \cdot \frac{x.re}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}\\ \mathbf{elif}\;y.re \leq 1.5 \cdot 10^{+93}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (<= y.re -7.2e+120)
   (/ x.re y.re)
   (if (<= y.re -1.45e-146)
     (* y.re (/ x.re (fma y.re y.re (* y.im y.im))))
     (if (<= y.re 1.5e+93) (/ x.im y.im) (/ x.re y.re)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if (y_46_re <= -7.2e+120) {
		tmp = x_46_re / y_46_re;
	} else if (y_46_re <= -1.45e-146) {
		tmp = y_46_re * (x_46_re / fma(y_46_re, y_46_re, (y_46_im * y_46_im)));
	} else if (y_46_re <= 1.5e+93) {
		tmp = x_46_im / y_46_im;
	} else {
		tmp = x_46_re / y_46_re;
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0
	if (y_46_re <= -7.2e+120)
		tmp = Float64(x_46_re / y_46_re);
	elseif (y_46_re <= -1.45e-146)
		tmp = Float64(y_46_re * Float64(x_46_re / fma(y_46_re, y_46_re, Float64(y_46_im * y_46_im))));
	elseif (y_46_re <= 1.5e+93)
		tmp = Float64(x_46_im / y_46_im);
	else
		tmp = Float64(x_46_re / y_46_re);
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -7.2e+120], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, -1.45e-146], N[(y$46$re * N[(x$46$re / N[(y$46$re * y$46$re + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 1.5e+93], N[(x$46$im / y$46$im), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]]]
\begin{array}{l}

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.re < -7.20000000000000031e120 or 1.49999999999999989e93 < y.re

    1. Initial program 42.3%

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

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

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

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

    if -7.20000000000000031e120 < y.re < -1.45000000000000005e-146

    1. Initial program 90.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 x.re around inf

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

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

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

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

        \[\leadsto \frac{x.re \cdot y.re}{\color{blue}{\mathsf{fma}\left(y.im, y.im, {y.re}^{2}\right)}} \]
      5. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.45000000000000005e-146 < y.re < 1.49999999999999989e93

    1. Initial program 69.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 0

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

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

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

Alternative 6: 63.4% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -4.05 \cdot 10^{+74}:\\
\;\;\;\;\frac{x.im}{y.im}\\

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

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


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

    1. Initial program 58.8%

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

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

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

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

    if -4.0500000000000002e74 < y.im < 1.85e-4

    1. Initial program 72.3%

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

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

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

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

Alternative 7: 43.3% accurate, 3.2× 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 66.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

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

      \[\leadsto \color{blue}{\frac{x.im}{y.im}} \]
  5. Simplified41.6%

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

Reproduce

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