_divideComplex, real part

Percentage Accurate: 61.7% → 81.6%
Time: 8.7s
Alternatives: 8
Speedup: 0.9×

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 8 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.7% 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: 81.6% 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.im \leq -1.15 \cdot 10^{+71}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\ \mathbf{elif}\;y.im \leq -2.3 \cdot 10^{-157}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.im \leq 6.5 \cdot 10^{-104}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{elif}\;y.im \leq 3.3 \cdot 10^{+155}:\\ \;\;\;\;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 -1.15e+71)
     (/ (fma (/ x.re y.im) y.re x.im) y.im)
     (if (<= y.im -2.3e-157)
       t_0
       (if (<= y.im 6.5e-104)
         (/ (fma x.im (/ y.im y.re) x.re) y.re)
         (if (<= y.im 3.3e+155) 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 <= -1.15e+71) {
		tmp = fma((x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im;
	} else if (y_46_im <= -2.3e-157) {
		tmp = t_0;
	} else if (y_46_im <= 6.5e-104) {
		tmp = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
	} else if (y_46_im <= 3.3e+155) {
		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 <= -1.15e+71)
		tmp = Float64(fma(Float64(x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im);
	elseif (y_46_im <= -2.3e-157)
		tmp = t_0;
	elseif (y_46_im <= 6.5e-104)
		tmp = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re);
	elseif (y_46_im <= 3.3e+155)
		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, -1.15e+71], N[(N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, -2.3e-157], t$95$0, If[LessEqual[y$46$im, 6.5e-104], 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.3e+155], 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 -1.15 \cdot 10^{+71}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\

\mathbf{elif}\;y.im \leq -2.3 \cdot 10^{-157}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;y.im \leq 3.3 \cdot 10^{+155}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 36.6%

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

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

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

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

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

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

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

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

    if -1.1500000000000001e71 < y.im < -2.29999999999999989e-157 or 6.49999999999999991e-104 < y.im < 3.2999999999999999e155

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

    if -2.29999999999999989e-157 < y.im < 6.49999999999999991e-104

    1. Initial program 76.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. Step-by-step derivation
      1. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-1}{\frac{x.re \cdot y.re - x.im \cdot y.im}{\left(x.re \cdot y.re\right) \cdot \left(x.re \cdot y.re\right) - \left(x.im \cdot y.im\right) \cdot \left(x.im \cdot y.im\right)} \cdot \left(\mathsf{neg}\left(\left(y.re \cdot y.re + y.im \cdot y.im\right)\right)\right)}} \]
      11. lower-*.f64N/A

        \[\leadsto \frac{-1}{\color{blue}{\frac{x.re \cdot y.re - x.im \cdot y.im}{\left(x.re \cdot y.re\right) \cdot \left(x.re \cdot y.re\right) - \left(x.im \cdot y.im\right) \cdot \left(x.im \cdot y.im\right)} \cdot \left(\mathsf{neg}\left(\left(y.re \cdot y.re + y.im \cdot y.im\right)\right)\right)}} \]
    4. Applied rewrites75.9%

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

      \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
    6. 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-/.f6497.1

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

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

    if 3.2999999999999999e155 < y.im

    1. Initial program 39.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-/.f6478.2

        \[\leadsto \color{blue}{\frac{x.im}{y.im}} \]
    5. Applied rewrites78.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -1.15 \cdot 10^{+71}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\ \mathbf{elif}\;y.im \leq -2.3 \cdot 10^{-157}:\\ \;\;\;\;\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.5 \cdot 10^{-104}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{elif}\;y.im \leq 3.3 \cdot 10^{+155}:\\ \;\;\;\;\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 2: 71.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.im \leq -4.5 \cdot 10^{+131}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{elif}\;y.im \leq -2.7 \cdot 10^{-120}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)}{y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 6.3 \cdot 10^{-38}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{elif}\;y.im \leq 3.3 \cdot 10^{+155}:\\ \;\;\;\;x.im \cdot \frac{y.im}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}\\ \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.5e+131)
   (/ x.im y.im)
   (if (<= y.im -2.7e-120)
     (/ (fma x.re y.re (* x.im y.im)) (* y.im y.im))
     (if (<= y.im 6.3e-38)
       (/ (fma x.im (/ y.im y.re) x.re) y.re)
       (if (<= y.im 3.3e+155)
         (* x.im (/ y.im (fma y.re y.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 <= -4.5e+131) {
		tmp = x_46_im / y_46_im;
	} else if (y_46_im <= -2.7e-120) {
		tmp = fma(x_46_re, y_46_re, (x_46_im * y_46_im)) / (y_46_im * y_46_im);
	} else if (y_46_im <= 6.3e-38) {
		tmp = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
	} else if (y_46_im <= 3.3e+155) {
		tmp = x_46_im * (y_46_im / fma(y_46_re, y_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 <= -4.5e+131)
		tmp = Float64(x_46_im / y_46_im);
	elseif (y_46_im <= -2.7e-120)
		tmp = Float64(fma(x_46_re, y_46_re, Float64(x_46_im * y_46_im)) / Float64(y_46_im * y_46_im));
	elseif (y_46_im <= 6.3e-38)
		tmp = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re);
	elseif (y_46_im <= 3.3e+155)
		tmp = Float64(x_46_im * Float64(y_46_im / fma(y_46_re, y_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, -4.5e+131], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, -2.7e-120], N[(N[(x$46$re * y$46$re + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 6.3e-38], 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.3e+155], N[(x$46$im * N[(y$46$im / N[(y$46$re * y$46$re + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im / y$46$im), $MachinePrecision]]]]]
\begin{array}{l}

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y.im < -4.5000000000000002e131 or 3.2999999999999999e155 < y.im

    1. Initial program 31.9%

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

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

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

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

    if -4.5000000000000002e131 < y.im < -2.6999999999999999e-120

    1. Initial program 83.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-*.f6464.6

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

      \[\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{\color{blue}{x.re \cdot y.re} + x.im \cdot y.im}{y.im \cdot y.im} \]
      3. lower-fma.f6464.6

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

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

    if -2.6999999999999999e-120 < y.im < 6.2999999999999996e-38

    1. Initial program 78.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. Step-by-step derivation
      1. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-1}{\frac{x.re \cdot y.re - x.im \cdot y.im}{\left(x.re \cdot y.re\right) \cdot \left(x.re \cdot y.re\right) - \left(x.im \cdot y.im\right) \cdot \left(x.im \cdot y.im\right)} \cdot \left(\mathsf{neg}\left(\left(y.re \cdot y.re + y.im \cdot y.im\right)\right)\right)}} \]
      11. lower-*.f64N/A

        \[\leadsto \frac{-1}{\color{blue}{\frac{x.re \cdot y.re - x.im \cdot y.im}{\left(x.re \cdot y.re\right) \cdot \left(x.re \cdot y.re\right) - \left(x.im \cdot y.im\right) \cdot \left(x.im \cdot y.im\right)} \cdot \left(\mathsf{neg}\left(\left(y.re \cdot y.re + y.im \cdot y.im\right)\right)\right)}} \]
    4. Applied rewrites78.5%

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

      \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
    6. 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-/.f6490.5

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

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

    if 6.2999999999999996e-38 < y.im < 3.2999999999999999e155

    1. Initial program 80.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-1}{\frac{x.re \cdot y.re - x.im \cdot y.im}{\left(x.re \cdot y.re\right) \cdot \left(x.re \cdot y.re\right) - \left(x.im \cdot y.im\right) \cdot \left(x.im \cdot y.im\right)} \cdot \left(\mathsf{neg}\left(\left(y.re \cdot y.re + y.im \cdot y.im\right)\right)\right)}} \]
      11. lower-*.f64N/A

        \[\leadsto \frac{-1}{\color{blue}{\frac{x.re \cdot y.re - x.im \cdot y.im}{\left(x.re \cdot y.re\right) \cdot \left(x.re \cdot y.re\right) - \left(x.im \cdot y.im\right) \cdot \left(x.im \cdot y.im\right)} \cdot \left(\mathsf{neg}\left(\left(y.re \cdot y.re + y.im \cdot y.im\right)\right)\right)}} \]
    4. Applied rewrites80.5%

      \[\leadsto \color{blue}{\frac{-1}{{\left(\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)\right)}^{-1} \cdot \left(-\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)\right)}} \]
    5. Taylor expanded in x.re around 0

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -4.5 \cdot 10^{+131}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{elif}\;y.im \leq -2.7 \cdot 10^{-120}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)}{y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 6.3 \cdot 10^{-38}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{elif}\;y.im \leq 3.3 \cdot 10^{+155}:\\ \;\;\;\;x.im \cdot \frac{y.im}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 65.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.im \leq -4.5 \cdot 10^{+131}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{elif}\;y.im \leq -1.9 \cdot 10^{-120}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)}{y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 3.9 \cdot 10^{-103}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.im \leq 3.3 \cdot 10^{+155}:\\ \;\;\;\;x.im \cdot \frac{y.im}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}\\ \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.5e+131)
   (/ x.im y.im)
   (if (<= y.im -1.9e-120)
     (/ (fma x.re y.re (* x.im y.im)) (* y.im y.im))
     (if (<= y.im 3.9e-103)
       (/ x.re y.re)
       (if (<= y.im 3.3e+155)
         (* x.im (/ y.im (fma y.re y.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 <= -4.5e+131) {
		tmp = x_46_im / y_46_im;
	} else if (y_46_im <= -1.9e-120) {
		tmp = fma(x_46_re, y_46_re, (x_46_im * y_46_im)) / (y_46_im * y_46_im);
	} else if (y_46_im <= 3.9e-103) {
		tmp = x_46_re / y_46_re;
	} else if (y_46_im <= 3.3e+155) {
		tmp = x_46_im * (y_46_im / fma(y_46_re, y_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 <= -4.5e+131)
		tmp = Float64(x_46_im / y_46_im);
	elseif (y_46_im <= -1.9e-120)
		tmp = Float64(fma(x_46_re, y_46_re, Float64(x_46_im * y_46_im)) / Float64(y_46_im * y_46_im));
	elseif (y_46_im <= 3.9e-103)
		tmp = Float64(x_46_re / y_46_re);
	elseif (y_46_im <= 3.3e+155)
		tmp = Float64(x_46_im * Float64(y_46_im / fma(y_46_re, y_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, -4.5e+131], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, -1.9e-120], N[(N[(x$46$re * y$46$re + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 3.9e-103], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 3.3e+155], N[(x$46$im * N[(y$46$im / N[(y$46$re * y$46$re + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im / y$46$im), $MachinePrecision]]]]]
\begin{array}{l}

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y.im < -4.5000000000000002e131 or 3.2999999999999999e155 < y.im

    1. Initial program 31.9%

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

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

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

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

    if -4.5000000000000002e131 < y.im < -1.8999999999999999e-120

    1. Initial program 83.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-*.f6464.6

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

      \[\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{\color{blue}{x.re \cdot y.re} + x.im \cdot y.im}{y.im \cdot y.im} \]
      3. lower-fma.f6464.6

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

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

    if -1.8999999999999999e-120 < y.im < 3.9000000000000002e-103

    1. Initial program 78.2%

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

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

        \[\leadsto \color{blue}{\frac{x.re}{y.re}} \]
    5. Applied rewrites76.4%

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

    if 3.9000000000000002e-103 < y.im < 3.2999999999999999e155

    1. Initial program 81.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. Step-by-step derivation
      1. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-1}{\frac{x.re \cdot y.re - x.im \cdot y.im}{\left(x.re \cdot y.re\right) \cdot \left(x.re \cdot y.re\right) - \left(x.im \cdot y.im\right) \cdot \left(x.im \cdot y.im\right)} \cdot \left(\mathsf{neg}\left(\left(y.re \cdot y.re + y.im \cdot y.im\right)\right)\right)}} \]
      11. lower-*.f64N/A

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

      \[\leadsto \color{blue}{\frac{-1}{{\left(\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)\right)}^{-1} \cdot \left(-\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)\right)}} \]
    5. Taylor expanded in x.re around 0

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -4.5 \cdot 10^{+131}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{elif}\;y.im \leq -1.9 \cdot 10^{-120}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)}{y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 3.9 \cdot 10^{-103}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.im \leq 3.3 \cdot 10^{+155}:\\ \;\;\;\;x.im \cdot \frac{y.im}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 66.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.im \leq -1.15 \cdot 10^{+71}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{elif}\;y.im \leq -1.36 \cdot 10^{-120}:\\ \;\;\;\;\frac{y.im \cdot x.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\ \mathbf{elif}\;y.im \leq 3.9 \cdot 10^{-103}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.im \leq 3.3 \cdot 10^{+155}:\\ \;\;\;\;x.im \cdot \frac{y.im}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}\\ \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 -1.15e+71)
   (/ x.im y.im)
   (if (<= y.im -1.36e-120)
     (/ (* y.im x.im) (fma y.im y.im (* y.re y.re)))
     (if (<= y.im 3.9e-103)
       (/ x.re y.re)
       (if (<= y.im 3.3e+155)
         (* x.im (/ y.im (fma y.re y.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 <= -1.15e+71) {
		tmp = x_46_im / y_46_im;
	} else if (y_46_im <= -1.36e-120) {
		tmp = (y_46_im * x_46_im) / fma(y_46_im, y_46_im, (y_46_re * y_46_re));
	} else if (y_46_im <= 3.9e-103) {
		tmp = x_46_re / y_46_re;
	} else if (y_46_im <= 3.3e+155) {
		tmp = x_46_im * (y_46_im / fma(y_46_re, y_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 <= -1.15e+71)
		tmp = Float64(x_46_im / y_46_im);
	elseif (y_46_im <= -1.36e-120)
		tmp = Float64(Float64(y_46_im * x_46_im) / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re)));
	elseif (y_46_im <= 3.9e-103)
		tmp = Float64(x_46_re / y_46_re);
	elseif (y_46_im <= 3.3e+155)
		tmp = Float64(x_46_im * Float64(y_46_im / fma(y_46_re, y_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, -1.15e+71], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, -1.36e-120], N[(N[(y$46$im * x$46$im), $MachinePrecision] / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 3.9e-103], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 3.3e+155], N[(x$46$im * N[(y$46$im / N[(y$46$re * y$46$re + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im / y$46$im), $MachinePrecision]]]]]
\begin{array}{l}

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y.im < -1.1500000000000001e71 or 3.2999999999999999e155 < y.im

    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 0

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

        \[\leadsto \color{blue}{\frac{x.im}{y.im}} \]
    5. Applied rewrites77.2%

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

    if -1.1500000000000001e71 < y.im < -1.36000000000000001e-120

    1. Initial program 82.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. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-1}{\frac{x.re \cdot y.re - x.im \cdot y.im}{\left(x.re \cdot y.re\right) \cdot \left(x.re \cdot y.re\right) - \left(x.im \cdot y.im\right) \cdot \left(x.im \cdot y.im\right)} \cdot \left(\mathsf{neg}\left(\left(y.re \cdot y.re + y.im \cdot y.im\right)\right)\right)}} \]
      11. lower-*.f64N/A

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

      \[\leadsto \color{blue}{\frac{-1}{{\left(\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)\right)}^{-1} \cdot \left(-\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)\right)}} \]
    5. Taylor expanded in x.re around 0

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

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

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

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

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

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

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

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

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

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

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

      if -1.36000000000000001e-120 < y.im < 3.9000000000000002e-103

      1. Initial program 78.2%

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

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

          \[\leadsto \color{blue}{\frac{x.re}{y.re}} \]
      5. Applied rewrites76.4%

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

      if 3.9000000000000002e-103 < y.im < 3.2999999999999999e155

      1. Initial program 81.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. Step-by-step derivation
        1. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\frac{-1}{\frac{x.re \cdot y.re - x.im \cdot y.im}{\left(x.re \cdot y.re\right) \cdot \left(x.re \cdot y.re\right) - \left(x.im \cdot y.im\right) \cdot \left(x.im \cdot y.im\right)} \cdot \left(\mathsf{neg}\left(\left(y.re \cdot y.re + y.im \cdot y.im\right)\right)\right)}} \]
        11. lower-*.f64N/A

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

        \[\leadsto \color{blue}{\frac{-1}{{\left(\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)\right)}^{-1} \cdot \left(-\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)\right)}} \]
      5. Taylor expanded in x.re around 0

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -1.15 \cdot 10^{+71}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{elif}\;y.im \leq -1.36 \cdot 10^{-120}:\\ \;\;\;\;\frac{y.im \cdot x.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\ \mathbf{elif}\;y.im \leq 3.9 \cdot 10^{-103}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.im \leq 3.3 \cdot 10^{+155}:\\ \;\;\;\;x.im \cdot \frac{y.im}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \end{array} \]
    11. Add Preprocessing

    Alternative 5: 66.2% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := x.im \cdot \frac{y.im}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}\\ \mathbf{if}\;y.im \leq -7.3 \cdot 10^{+68}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{elif}\;y.im \leq -1.36 \cdot 10^{-120}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.im \leq 3.9 \cdot 10^{-103}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.im \leq 3.3 \cdot 10^{+155}:\\ \;\;\;\;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.im (/ y.im (fma y.re y.re (* y.im y.im))))))
       (if (<= y.im -7.3e+68)
         (/ x.im y.im)
         (if (<= y.im -1.36e-120)
           t_0
           (if (<= y.im 3.9e-103)
             (/ x.re y.re)
             (if (<= y.im 3.3e+155) 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_im * (y_46_im / fma(y_46_re, y_46_re, (y_46_im * y_46_im)));
    	double tmp;
    	if (y_46_im <= -7.3e+68) {
    		tmp = x_46_im / y_46_im;
    	} else if (y_46_im <= -1.36e-120) {
    		tmp = t_0;
    	} else if (y_46_im <= 3.9e-103) {
    		tmp = x_46_re / y_46_re;
    	} else if (y_46_im <= 3.3e+155) {
    		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(x_46_im * Float64(y_46_im / fma(y_46_re, y_46_re, Float64(y_46_im * y_46_im))))
    	tmp = 0.0
    	if (y_46_im <= -7.3e+68)
    		tmp = Float64(x_46_im / y_46_im);
    	elseif (y_46_im <= -1.36e-120)
    		tmp = t_0;
    	elseif (y_46_im <= 3.9e-103)
    		tmp = Float64(x_46_re / y_46_re);
    	elseif (y_46_im <= 3.3e+155)
    		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[(x$46$im * N[(y$46$im / N[(y$46$re * y$46$re + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$im, -7.3e+68], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, -1.36e-120], t$95$0, If[LessEqual[y$46$im, 3.9e-103], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 3.3e+155], t$95$0, N[(x$46$im / y$46$im), $MachinePrecision]]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := x.im \cdot \frac{y.im}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}\\
    \mathbf{if}\;y.im \leq -7.3 \cdot 10^{+68}:\\
    \;\;\;\;\frac{x.im}{y.im}\\
    
    \mathbf{elif}\;y.im \leq -1.36 \cdot 10^{-120}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;y.im \leq 3.9 \cdot 10^{-103}:\\
    \;\;\;\;\frac{x.re}{y.re}\\
    
    \mathbf{elif}\;y.im \leq 3.3 \cdot 10^{+155}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{x.im}{y.im}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if y.im < -7.30000000000000034e68 or 3.2999999999999999e155 < y.im

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

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

          \[\leadsto \color{blue}{\frac{x.im}{y.im}} \]
      5. Applied rewrites77.5%

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

      if -7.30000000000000034e68 < y.im < -1.36000000000000001e-120 or 3.9000000000000002e-103 < y.im < 3.2999999999999999e155

      1. Initial program 81.8%

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\frac{-1}{\frac{x.re \cdot y.re - x.im \cdot y.im}{\left(x.re \cdot y.re\right) \cdot \left(x.re \cdot y.re\right) - \left(x.im \cdot y.im\right) \cdot \left(x.im \cdot y.im\right)} \cdot \left(\mathsf{neg}\left(\left(y.re \cdot y.re + y.im \cdot y.im\right)\right)\right)}} \]
        11. lower-*.f64N/A

          \[\leadsto \frac{-1}{\color{blue}{\frac{x.re \cdot y.re - x.im \cdot y.im}{\left(x.re \cdot y.re\right) \cdot \left(x.re \cdot y.re\right) - \left(x.im \cdot y.im\right) \cdot \left(x.im \cdot y.im\right)} \cdot \left(\mathsf{neg}\left(\left(y.re \cdot y.re + y.im \cdot y.im\right)\right)\right)}} \]
      4. Applied rewrites81.5%

        \[\leadsto \color{blue}{\frac{-1}{{\left(\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)\right)}^{-1} \cdot \left(-\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)\right)}} \]
      5. Taylor expanded in x.re around 0

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

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

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

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

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

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

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

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

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

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

      if -1.36000000000000001e-120 < y.im < 3.9000000000000002e-103

      1. Initial program 78.2%

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

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

          \[\leadsto \color{blue}{\frac{x.re}{y.re}} \]
      5. Applied rewrites76.4%

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -7.3 \cdot 10^{+68}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{elif}\;y.im \leq -1.36 \cdot 10^{-120}:\\ \;\;\;\;x.im \cdot \frac{y.im}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}\\ \mathbf{elif}\;y.im \leq 3.9 \cdot 10^{-103}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.im \leq 3.3 \cdot 10^{+155}:\\ \;\;\;\;x.im \cdot \frac{y.im}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 6: 77.4% accurate, 0.9× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -1.15 \cdot 10^{+31}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{elif}\;y.re \leq 0.038:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\ \end{array} \end{array} \]
    (FPCore (x.re x.im y.re y.im)
     :precision binary64
     (if (<= y.re -1.15e+31)
       (/ (fma x.im (/ y.im y.re) x.re) y.re)
       (if (<= y.re 0.038)
         (/ (fma (/ x.re y.im) y.re x.im) y.im)
         (/ (fma (/ x.im y.re) y.im x.re) y.re))))
    double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
    	double tmp;
    	if (y_46_re <= -1.15e+31) {
    		tmp = fma(x_46_im, (y_46_im / y_46_re), x_46_re) / y_46_re;
    	} else if (y_46_re <= 0.038) {
    		tmp = fma((x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im;
    	} else {
    		tmp = fma((x_46_im / y_46_re), y_46_im, 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 <= -1.15e+31)
    		tmp = Float64(fma(x_46_im, Float64(y_46_im / y_46_re), x_46_re) / y_46_re);
    	elseif (y_46_re <= 0.038)
    		tmp = Float64(fma(Float64(x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im);
    	else
    		tmp = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, 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, -1.15e+31], 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, 0.038], N[(N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;y.re \leq -1.15 \cdot 10^{+31}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.im}{y.re}, x.re\right)}{y.re}\\
    
    \mathbf{elif}\;y.re \leq 0.038:\\
    \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if y.re < -1.15e31

      1. Initial program 51.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. Step-by-step derivation
        1. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\frac{-1}{\frac{x.re \cdot y.re - x.im \cdot y.im}{\left(x.re \cdot y.re\right) \cdot \left(x.re \cdot y.re\right) - \left(x.im \cdot y.im\right) \cdot \left(x.im \cdot y.im\right)} \cdot \left(\mathsf{neg}\left(\left(y.re \cdot y.re + y.im \cdot y.im\right)\right)\right)}} \]
        11. lower-*.f64N/A

          \[\leadsto \frac{-1}{\color{blue}{\frac{x.re \cdot y.re - x.im \cdot y.im}{\left(x.re \cdot y.re\right) \cdot \left(x.re \cdot y.re\right) - \left(x.im \cdot y.im\right) \cdot \left(x.im \cdot y.im\right)} \cdot \left(\mathsf{neg}\left(\left(y.re \cdot y.re + y.im \cdot y.im\right)\right)\right)}} \]
      4. Applied rewrites51.5%

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

        \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
      6. 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-/.f6482.8

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

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

      if -1.15e31 < y.re < 0.0379999999999999991

      1. Initial program 79.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.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. *-commutativeN/A

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

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

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

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

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

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

      if 0.0379999999999999991 < y.re

      1. Initial program 53.7%

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

        \[\leadsto \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. *-commutativeN/A

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

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

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

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

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

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

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

    Alternative 7: 61.5% accurate, 1.6× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.im \leq -1.9 \cdot 10^{-120} \lor \neg \left(y.im \leq 7.5 \cdot 10^{-35}\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.9e-120) (not (<= y.im 7.5e-35)))
       (/ 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.9e-120) || !(y_46_im <= 7.5e-35)) {
    		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.9d-120)) .or. (.not. (y_46im <= 7.5d-35))) 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.9e-120) || !(y_46_im <= 7.5e-35)) {
    		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.9e-120) or not (y_46_im <= 7.5e-35):
    		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.9e-120) || !(y_46_im <= 7.5e-35))
    		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.9e-120) || ~((y_46_im <= 7.5e-35)))
    		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.9e-120], N[Not[LessEqual[y$46$im, 7.5e-35]], $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.9 \cdot 10^{-120} \lor \neg \left(y.im \leq 7.5 \cdot 10^{-35}\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.8999999999999999e-120 or 7.5e-35 < y.im

      1. Initial program 61.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-/.f6461.4

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

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

      if -1.8999999999999999e-120 < y.im < 7.5e-35

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

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

          \[\leadsto \color{blue}{\frac{x.re}{y.re}} \]
      5. Applied rewrites72.7%

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -1.9 \cdot 10^{-120} \lor \neg \left(y.im \leq 7.5 \cdot 10^{-35}\right):\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 8: 43.9% 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 67.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 0

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

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

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

    Reproduce

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