_divideComplex, real part

Percentage Accurate: 61.6% → 79.8%
Time: 10.6s
Alternatives: 10
Speedup: 1.6×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 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.6% 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: 79.8% accurate, 0.6× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.re < -3.69999999999999997e59 or 6.20000000000000011e48 < y.re

    1. Initial program 44.6%

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

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

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

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

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

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

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

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

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

      if -3.69999999999999997e59 < y.re < 1.85e-125

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

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

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

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

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

          \[\leadsto \frac{x.im + \left(\frac{x.re \cdot y.re}{y.im} - \frac{x.im \cdot {y.re}^{2}}{\color{blue}{y.im \cdot y.im}}\right)}{y.im} \]
        5. associate-/r*N/A

          \[\leadsto \frac{x.im + \left(\frac{x.re \cdot y.re}{y.im} - \color{blue}{\frac{\frac{x.im \cdot {y.re}^{2}}{y.im}}{y.im}}\right)}{y.im} \]
        6. div-subN/A

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

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

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

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

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

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

      if 1.85e-125 < y.re < 6.20000000000000011e48

      1. Initial program 84.3%

        \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. 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 \left(x.re \cdot y.re + x.im \cdot y.im\right) \cdot \frac{1}{\color{blue}{y.re \cdot y.re + y.im \cdot y.im}} \]
        4. flip-+N/A

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \frac{1}{\color{blue}{y.re \cdot y.re} + y.im \cdot y.im} \]
        16. lower-fma.f6484.4

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -3.7 \cdot 10^{+59}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\ \mathbf{elif}\;y.re \leq 1.85 \cdot 10^{-125}:\\ \;\;\;\;\frac{x.im + \frac{\mathsf{fma}\left(x.im, -\frac{y.re \cdot y.re}{y.im}, y.re \cdot x.re\right)}{y.im}}{y.im}\\ \mathbf{elif}\;y.re \leq 6.2 \cdot 10^{+48}:\\ \;\;\;\;\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \frac{1}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\ \end{array} \]
    9. Add Preprocessing

    Alternative 2: 80.4% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\ \mathbf{if}\;y.re \leq -1.25 \cdot 10^{+60}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.re \leq 1.85 \cdot 10^{-125}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x.re, \frac{y.re}{y.im}, x.im\right)}{y.im}\\ \mathbf{elif}\;y.re \leq 6.2 \cdot 10^{+48}:\\ \;\;\;\;\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \frac{1}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (x.re x.im y.re y.im)
     :precision binary64
     (let* ((t_0 (/ (fma (/ x.im y.re) y.im x.re) y.re)))
       (if (<= y.re -1.25e+60)
         t_0
         (if (<= y.re 1.85e-125)
           (/ (fma x.re (/ y.re y.im) x.im) y.im)
           (if (<= y.re 6.2e+48)
             (*
              (fma x.re y.re (* x.im y.im))
              (/ 1.0 (fma y.re y.re (* y.im y.im))))
             t_0)))))
    double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
    	double t_0 = fma((x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re;
    	double tmp;
    	if (y_46_re <= -1.25e+60) {
    		tmp = t_0;
    	} else if (y_46_re <= 1.85e-125) {
    		tmp = fma(x_46_re, (y_46_re / y_46_im), x_46_im) / y_46_im;
    	} else if (y_46_re <= 6.2e+48) {
    		tmp = fma(x_46_re, y_46_re, (x_46_im * y_46_im)) * (1.0 / fma(y_46_re, y_46_re, (y_46_im * y_46_im)));
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    function code(x_46_re, x_46_im, y_46_re, y_46_im)
    	t_0 = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re)
    	tmp = 0.0
    	if (y_46_re <= -1.25e+60)
    		tmp = t_0;
    	elseif (y_46_re <= 1.85e-125)
    		tmp = Float64(fma(x_46_re, Float64(y_46_re / y_46_im), x_46_im) / y_46_im);
    	elseif (y_46_re <= 6.2e+48)
    		tmp = Float64(fma(x_46_re, y_46_re, Float64(x_46_im * y_46_im)) * Float64(1.0 / fma(y_46_re, y_46_re, Float64(y_46_im * y_46_im))));
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -1.25e+60], t$95$0, If[LessEqual[y$46$re, 1.85e-125], N[(N[(x$46$re * N[(y$46$re / y$46$im), $MachinePrecision] + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 6.2e+48], N[(N[(x$46$re * y$46$re + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(y$46$re * y$46$re + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\
    \mathbf{if}\;y.re \leq -1.25 \cdot 10^{+60}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;y.re \leq 1.85 \cdot 10^{-125}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(x.re, \frac{y.re}{y.im}, x.im\right)}{y.im}\\
    
    \mathbf{elif}\;y.re \leq 6.2 \cdot 10^{+48}:\\
    \;\;\;\;\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right) \cdot \frac{1}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if y.re < -1.24999999999999994e60 or 6.20000000000000011e48 < y.re

      1. Initial program 43.4%

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

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

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

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

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

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

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

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

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

        if -1.24999999999999994e60 < y.re < 1.85e-125

        1. Initial program 73.3%

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

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

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

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

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

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

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

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

        if 1.85e-125 < y.re < 6.20000000000000011e48

        1. Initial program 76.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 \left(x.re \cdot y.re + x.im \cdot y.im\right) \cdot \frac{1}{\color{blue}{y.re \cdot y.re + y.im \cdot y.im}} \]
          4. flip-+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Reproduce

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