_divideComplex, imaginary part

Percentage Accurate: 61.5% → 83.9%
Time: 11.7s
Alternatives: 10
Speedup: 1.5×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 61.5% accurate, 1.0× speedup?

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

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

Alternative 1: 83.9% accurate, 0.5× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y.im < -2.29999999999999998e128 or 1.07999999999999997e104 < y.im

    1. Initial program 31.7%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}} \]
      8. sub-negN/A

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

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

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

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

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

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

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

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

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

    if -2.29999999999999998e128 < y.im < -5.5e-147

    1. Initial program 74.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.5e-147 < y.im < 3.59999999999999966e-86

    1. Initial program 59.7%

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

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

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{\color{blue}{y.im \cdot x.re}}{y.re}}{y.re} \]
      7. lower-*.f6491.2

        \[\leadsto \frac{x.im - \frac{\color{blue}{y.im \cdot x.re}}{y.re}}{y.re} \]
    5. Applied rewrites91.2%

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

    if 3.59999999999999966e-86 < y.im < 1.07999999999999997e104

    1. Initial program 73.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -2.3 \cdot 10^{+128}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\ \mathbf{elif}\;y.im \leq -5.5 \cdot 10^{-147}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}, x.im, \frac{y.im \cdot \left(-x.re\right)}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\right)\\ \mathbf{elif}\;y.im \leq 3.6 \cdot 10^{-86}:\\ \;\;\;\;\frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re}\\ \mathbf{elif}\;y.im \leq 1.08 \cdot 10^{+104}:\\ \;\;\;\;\mathsf{fma}\left(-x.re, \frac{y.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}, \frac{x.im \cdot y.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 83.8% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;y.im \leq -3.8 \cdot 10^{-96}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;y.im \leq 1.08 \cdot 10^{+104}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.im < -2.7999999999999999e132 or 1.07999999999999997e104 < y.im

    1. Initial program 36.3%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}} \]
      8. sub-negN/A

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

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

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

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

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

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

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

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

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

    if -2.7999999999999999e132 < y.im < -3.8000000000000001e-96 or 3.59999999999999966e-86 < y.im < 1.07999999999999997e104

    1. Initial program 73.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.8000000000000001e-96 < y.im < 3.59999999999999966e-86

    1. Initial program 71.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{\color{blue}{y.im \cdot x.re}}{y.re}}{y.re} \]
      7. lower-*.f6488.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -2.8 \cdot 10^{+132}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\ \mathbf{elif}\;y.im \leq -3.8 \cdot 10^{-96}:\\ \;\;\;\;\mathsf{fma}\left(-x.re, \frac{y.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}, \frac{x.im \cdot y.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\right)\\ \mathbf{elif}\;y.im \leq 3.6 \cdot 10^{-86}:\\ \;\;\;\;\frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re}\\ \mathbf{elif}\;y.im \leq 1.08 \cdot 10^{+104}:\\ \;\;\;\;\mathsf{fma}\left(-x.re, \frac{y.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}, \frac{x.im \cdot y.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\ \end{array} \]
  5. Add Preprocessing

Reproduce

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