_divideComplex, real part

Percentage Accurate: 62.4% → 83.5%
Time: 4.4s
Alternatives: 8
Speedup: 1.1×

Specification

?
\[\begin{array}{l} \\ \frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
    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}

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: 62.4% 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));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
    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: 83.5% 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(\frac{y.re}{t\_0}, x.re, \frac{x.im}{t\_0} \cdot y.im\right)\\ \mathbf{if}\;y.re \leq -2 \cdot 10^{+122}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\ \mathbf{elif}\;y.re \leq -3.6 \cdot 10^{-39}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y.re \leq 2.75 \cdot 10^{-105}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.re, x.im\right)}{y.im}\\ \mathbf{elif}\;y.re \leq 1.14 \cdot 10^{+108}:\\ \;\;\;\;t\_1\\ \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
 (let* ((t_0 (fma y.im y.im (* y.re y.re)))
        (t_1 (fma (/ y.re t_0) x.re (* (/ x.im t_0) y.im))))
   (if (<= y.re -2e+122)
     (/ (fma (/ y.im y.re) x.im x.re) y.re)
     (if (<= y.re -3.6e-39)
       t_1
       (if (<= y.re 2.75e-105)
         (/ (fma (/ y.re y.im) x.re x.im) y.im)
         (if (<= y.re 1.14e+108)
           t_1
           (/ (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 t_0 = fma(y_46_im, y_46_im, (y_46_re * y_46_re));
	double t_1 = fma((y_46_re / t_0), x_46_re, ((x_46_im / t_0) * y_46_im));
	double tmp;
	if (y_46_re <= -2e+122) {
		tmp = fma((y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re;
	} else if (y_46_re <= -3.6e-39) {
		tmp = t_1;
	} else if (y_46_re <= 2.75e-105) {
		tmp = fma((y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im;
	} else if (y_46_re <= 1.14e+108) {
		tmp = t_1;
	} 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)
	t_0 = fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))
	t_1 = fma(Float64(y_46_re / t_0), x_46_re, Float64(Float64(x_46_im / t_0) * y_46_im))
	tmp = 0.0
	if (y_46_re <= -2e+122)
		tmp = Float64(fma(Float64(y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re);
	elseif (y_46_re <= -3.6e-39)
		tmp = t_1;
	elseif (y_46_re <= 2.75e-105)
		tmp = Float64(fma(Float64(y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im);
	elseif (y_46_re <= 1.14e+108)
		tmp = t_1;
	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_] := 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 / t$95$0), $MachinePrecision] * x$46$re + N[(N[(x$46$im / t$95$0), $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -2e+122], N[(N[(N[(y$46$im / y$46$re), $MachinePrecision] * x$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, -3.6e-39], t$95$1, If[LessEqual[y$46$re, 2.75e-105], N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 1.14e+108], t$95$1, 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}
t_0 := \mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)\\
t_1 := \mathsf{fma}\left(\frac{y.re}{t\_0}, x.re, \frac{x.im}{t\_0} \cdot y.im\right)\\
\mathbf{if}\;y.re \leq -2 \cdot 10^{+122}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\

\mathbf{elif}\;y.re \leq -3.6 \cdot 10^{-39}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;y.re \leq 1.14 \cdot 10^{+108}:\\
\;\;\;\;t\_1\\

\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 4 regimes
  2. if y.re < -2.00000000000000003e122

    1. Initial program 62.4%

      \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Step-by-step derivation
      1. *-lft-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left|y.re\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      20. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{\color{blue}{y.im \cdot y.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      21. fp-cancel-sub-sign-invN/A

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{y.im \cdot y.im + \color{blue}{\left|y.re\right| \cdot \left|y.re\right|}} \]
      27. sqr-abs-revN/A

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

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

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

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

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

        \[\leadsto \frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re} \]
      4. lower-*.f6452.6

        \[\leadsto \frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re} \]
    6. Applied rewrites52.6%

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

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

        \[\leadsto \frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re} \]
      3. add-to-fractionN/A

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

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

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

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

        \[\leadsto \frac{\frac{x.im \cdot y.im + x.re \cdot y.re}{y.re}}{y.re} \]
      8. div-addN/A

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

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

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

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

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

        \[\leadsto \frac{\frac{y.im}{y.re} \cdot x.im + \frac{x.re}{y.re} \cdot y.re}{y.re} \]
      14. mult-flipN/A

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

        \[\leadsto \frac{\frac{y.im}{y.re} \cdot x.im + \left(x.re \cdot \frac{1}{y.re}\right) \cdot y.re}{y.re} \]
      16. associate-*l*N/A

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

        \[\leadsto \frac{\frac{y.im}{y.re} \cdot x.im + x.re \cdot \left(\frac{1}{y.re} \cdot y.re\right)}{y.re} \]
      18. inv-powN/A

        \[\leadsto \frac{\frac{y.im}{y.re} \cdot x.im + x.re \cdot \left({y.re}^{-1} \cdot y.re\right)}{y.re} \]
      19. pow-plusN/A

        \[\leadsto \frac{\frac{y.im}{y.re} \cdot x.im + x.re \cdot {y.re}^{\left(-1 + 1\right)}}{y.re} \]
      20. metadata-evalN/A

        \[\leadsto \frac{\frac{y.im}{y.re} \cdot x.im + x.re \cdot {y.re}^{0}}{y.re} \]
      21. metadata-evalN/A

        \[\leadsto \frac{\frac{y.im}{y.re} \cdot x.im + x.re \cdot 1}{y.re} \]
      22. *-rgt-identityN/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re} \]
      24. lower-/.f6454.5

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

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

    if -2.00000000000000003e122 < y.re < -3.6000000000000001e-39 or 2.75000000000000015e-105 < y.re < 1.13999999999999994e108

    1. Initial program 62.4%

      \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Applied rewrites62.0%

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

    if -3.6000000000000001e-39 < y.re < 2.75000000000000015e-105

    1. Initial program 62.4%

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

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

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

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

        \[\leadsto \frac{x.im + \frac{x.re \cdot y.re}{y.im}}{y.im} \]
      4. lower-*.f6452.1

        \[\leadsto \frac{x.im + \frac{x.re \cdot y.re}{y.im}}{y.im} \]
    4. Applied rewrites52.1%

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

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

    if 1.13999999999999994e108 < y.re

    1. Initial program 62.4%

      \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Step-by-step derivation
      1. *-lft-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left|y.re\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      20. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{\color{blue}{y.im \cdot y.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
      21. fp-cancel-sub-sign-invN/A

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{y.im \cdot y.im + \color{blue}{\left|y.re\right| \cdot \left|y.re\right|}} \]
      27. sqr-abs-revN/A

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

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

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

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

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

        \[\leadsto \frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re} \]
      4. lower-*.f6452.6

        \[\leadsto \frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re} \]
    6. Applied rewrites52.6%

      \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
    7. Step-by-step derivation
      1. Applied rewrites53.7%

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

    Alternative 2: 82.6% accurate, 0.6× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\ \mathbf{if}\;y.re \leq -1.6 \cdot 10^{+103}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\ \mathbf{elif}\;y.re \leq -3.6 \cdot 10^{-39}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.re \leq 4.5 \cdot 10^{-109}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.re, x.im\right)}{y.im}\\ \mathbf{elif}\;y.re \leq 2.2 \cdot 10^{+88}:\\ \;\;\;\;t\_0\\ \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
     (let* ((t_0 (/ (fma y.im x.im (* y.re x.re)) (fma y.im y.im (* y.re y.re)))))
       (if (<= y.re -1.6e+103)
         (/ (fma (/ y.im y.re) x.im x.re) y.re)
         (if (<= y.re -3.6e-39)
           t_0
           (if (<= y.re 4.5e-109)
             (/ (fma (/ y.re y.im) x.re x.im) y.im)
             (if (<= y.re 2.2e+88) t_0 (/ (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 t_0 = fma(y_46_im, x_46_im, (y_46_re * x_46_re)) / fma(y_46_im, y_46_im, (y_46_re * y_46_re));
    	double tmp;
    	if (y_46_re <= -1.6e+103) {
    		tmp = fma((y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re;
    	} else if (y_46_re <= -3.6e-39) {
    		tmp = t_0;
    	} else if (y_46_re <= 4.5e-109) {
    		tmp = fma((y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im;
    	} else if (y_46_re <= 2.2e+88) {
    		tmp = t_0;
    	} 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)
    	t_0 = Float64(fma(y_46_im, x_46_im, Float64(y_46_re * x_46_re)) / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re)))
    	tmp = 0.0
    	if (y_46_re <= -1.6e+103)
    		tmp = Float64(fma(Float64(y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re);
    	elseif (y_46_re <= -3.6e-39)
    		tmp = t_0;
    	elseif (y_46_re <= 4.5e-109)
    		tmp = Float64(fma(Float64(y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im);
    	elseif (y_46_re <= 2.2e+88)
    		tmp = t_0;
    	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_] := Block[{t$95$0 = N[(N[(y$46$im * x$46$im + N[(y$46$re * x$46$re), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -1.6e+103], N[(N[(N[(y$46$im / y$46$re), $MachinePrecision] * x$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, -3.6e-39], t$95$0, If[LessEqual[y$46$re, 4.5e-109], N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 2.2e+88], t$95$0, 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}
    t_0 := \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\
    \mathbf{if}\;y.re \leq -1.6 \cdot 10^{+103}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\
    
    \mathbf{elif}\;y.re \leq -3.6 \cdot 10^{-39}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;y.re \leq 4.5 \cdot 10^{-109}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.re, x.im\right)}{y.im}\\
    
    \mathbf{elif}\;y.re \leq 2.2 \cdot 10^{+88}:\\
    \;\;\;\;t\_0\\
    
    \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 4 regimes
    2. if y.re < -1.59999999999999996e103

      1. Initial program 62.4%

        \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      2. Step-by-step derivation
        1. *-lft-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left|y.re\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
        20. fp-cancel-sign-sub-invN/A

          \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{\color{blue}{y.im \cdot y.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
        21. fp-cancel-sub-sign-invN/A

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

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

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

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

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

          \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{y.im \cdot y.im + \color{blue}{\left|y.re\right| \cdot \left|y.re\right|}} \]
        27. sqr-abs-revN/A

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

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

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

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

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

          \[\leadsto \frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re} \]
        4. lower-*.f6452.6

          \[\leadsto \frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re} \]
      6. Applied rewrites52.6%

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

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

          \[\leadsto \frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re} \]
        3. add-to-fractionN/A

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

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

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

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

          \[\leadsto \frac{\frac{x.im \cdot y.im + x.re \cdot y.re}{y.re}}{y.re} \]
        8. div-addN/A

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

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

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

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

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

          \[\leadsto \frac{\frac{y.im}{y.re} \cdot x.im + \frac{x.re}{y.re} \cdot y.re}{y.re} \]
        14. mult-flipN/A

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

          \[\leadsto \frac{\frac{y.im}{y.re} \cdot x.im + \left(x.re \cdot \frac{1}{y.re}\right) \cdot y.re}{y.re} \]
        16. associate-*l*N/A

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

          \[\leadsto \frac{\frac{y.im}{y.re} \cdot x.im + x.re \cdot \left(\frac{1}{y.re} \cdot y.re\right)}{y.re} \]
        18. inv-powN/A

          \[\leadsto \frac{\frac{y.im}{y.re} \cdot x.im + x.re \cdot \left({y.re}^{-1} \cdot y.re\right)}{y.re} \]
        19. pow-plusN/A

          \[\leadsto \frac{\frac{y.im}{y.re} \cdot x.im + x.re \cdot {y.re}^{\left(-1 + 1\right)}}{y.re} \]
        20. metadata-evalN/A

          \[\leadsto \frac{\frac{y.im}{y.re} \cdot x.im + x.re \cdot {y.re}^{0}}{y.re} \]
        21. metadata-evalN/A

          \[\leadsto \frac{\frac{y.im}{y.re} \cdot x.im + x.re \cdot 1}{y.re} \]
        22. *-rgt-identityN/A

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

          \[\leadsto \frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re} \]
        24. lower-/.f6454.5

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

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

      if -1.59999999999999996e103 < y.re < -3.6000000000000001e-39 or 4.5000000000000001e-109 < y.re < 2.20000000000000009e88

      1. Initial program 62.4%

        \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      2. Step-by-step derivation
        1. *-lft-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left|y.re\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
        20. fp-cancel-sign-sub-invN/A

          \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{\color{blue}{y.im \cdot y.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
        21. fp-cancel-sub-sign-invN/A

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

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

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

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

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

          \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{y.im \cdot y.im + \color{blue}{\left|y.re\right| \cdot \left|y.re\right|}} \]
        27. sqr-abs-revN/A

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

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

      if -3.6000000000000001e-39 < y.re < 4.5000000000000001e-109

      1. Initial program 62.4%

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

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

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

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

          \[\leadsto \frac{x.im + \frac{x.re \cdot y.re}{y.im}}{y.im} \]
        4. lower-*.f6452.1

          \[\leadsto \frac{x.im + \frac{x.re \cdot y.re}{y.im}}{y.im} \]
      4. Applied rewrites52.1%

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

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

      if 2.20000000000000009e88 < y.re

      1. Initial program 62.4%

        \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
      2. Step-by-step derivation
        1. *-lft-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left|y.re\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
        20. fp-cancel-sign-sub-invN/A

          \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{\color{blue}{y.im \cdot y.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
        21. fp-cancel-sub-sign-invN/A

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

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

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

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

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

          \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{y.im \cdot y.im + \color{blue}{\left|y.re\right| \cdot \left|y.re\right|}} \]
        27. sqr-abs-revN/A

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

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

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

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

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

          \[\leadsto \frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re} \]
        4. lower-*.f6452.6

          \[\leadsto \frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re} \]
      6. Applied rewrites52.6%

        \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
      7. Step-by-step derivation
        1. Applied rewrites53.7%

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

      Alternative 3: 78.0% accurate, 1.1× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -1.72 \cdot 10^{-38}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\ \mathbf{elif}\;y.re \leq 1.75 \cdot 10^{+22}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.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.72e-38)
         (/ (fma (/ y.im y.re) x.im x.re) y.re)
         (if (<= y.re 1.75e+22)
           (/ (fma (/ y.re y.im) x.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.72e-38) {
      		tmp = fma((y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re;
      	} else if (y_46_re <= 1.75e+22) {
      		tmp = fma((y_46_re / y_46_im), x_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.72e-38)
      		tmp = Float64(fma(Float64(y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re);
      	elseif (y_46_re <= 1.75e+22)
      		tmp = Float64(fma(Float64(y_46_re / y_46_im), x_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.72e-38], N[(N[(N[(y$46$im / y$46$re), $MachinePrecision] * x$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 1.75e+22], N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$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.72 \cdot 10^{-38}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\
      
      \mathbf{elif}\;y.re \leq 1.75 \cdot 10^{+22}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.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.72e-38

        1. Initial program 62.4%

          \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
        2. Step-by-step derivation
          1. *-lft-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left|y.re\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
          20. fp-cancel-sign-sub-invN/A

            \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{\color{blue}{y.im \cdot y.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
          21. fp-cancel-sub-sign-invN/A

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

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

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

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

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

            \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{y.im \cdot y.im + \color{blue}{\left|y.re\right| \cdot \left|y.re\right|}} \]
          27. sqr-abs-revN/A

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

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

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

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

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

            \[\leadsto \frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re} \]
          4. lower-*.f6452.6

            \[\leadsto \frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re} \]
        6. Applied rewrites52.6%

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

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

            \[\leadsto \frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re} \]
          3. add-to-fractionN/A

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

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

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

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

            \[\leadsto \frac{\frac{x.im \cdot y.im + x.re \cdot y.re}{y.re}}{y.re} \]
          8. div-addN/A

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

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

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

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

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

            \[\leadsto \frac{\frac{y.im}{y.re} \cdot x.im + \frac{x.re}{y.re} \cdot y.re}{y.re} \]
          14. mult-flipN/A

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

            \[\leadsto \frac{\frac{y.im}{y.re} \cdot x.im + \left(x.re \cdot \frac{1}{y.re}\right) \cdot y.re}{y.re} \]
          16. associate-*l*N/A

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

            \[\leadsto \frac{\frac{y.im}{y.re} \cdot x.im + x.re \cdot \left(\frac{1}{y.re} \cdot y.re\right)}{y.re} \]
          18. inv-powN/A

            \[\leadsto \frac{\frac{y.im}{y.re} \cdot x.im + x.re \cdot \left({y.re}^{-1} \cdot y.re\right)}{y.re} \]
          19. pow-plusN/A

            \[\leadsto \frac{\frac{y.im}{y.re} \cdot x.im + x.re \cdot {y.re}^{\left(-1 + 1\right)}}{y.re} \]
          20. metadata-evalN/A

            \[\leadsto \frac{\frac{y.im}{y.re} \cdot x.im + x.re \cdot {y.re}^{0}}{y.re} \]
          21. metadata-evalN/A

            \[\leadsto \frac{\frac{y.im}{y.re} \cdot x.im + x.re \cdot 1}{y.re} \]
          22. *-rgt-identityN/A

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

            \[\leadsto \frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re} \]
          24. lower-/.f6454.5

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

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

        if -1.72e-38 < y.re < 1.75e22

        1. Initial program 62.4%

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

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

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

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

            \[\leadsto \frac{x.im + \frac{x.re \cdot y.re}{y.im}}{y.im} \]
          4. lower-*.f6452.1

            \[\leadsto \frac{x.im + \frac{x.re \cdot y.re}{y.im}}{y.im} \]
        4. Applied rewrites52.1%

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

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

        if 1.75e22 < y.re

        1. Initial program 62.4%

          \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
        2. Step-by-step derivation
          1. *-lft-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left|y.re\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
          20. fp-cancel-sign-sub-invN/A

            \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{\color{blue}{y.im \cdot y.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
          21. fp-cancel-sub-sign-invN/A

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

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

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

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

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

            \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{y.im \cdot y.im + \color{blue}{\left|y.re\right| \cdot \left|y.re\right|}} \]
          27. sqr-abs-revN/A

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

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

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

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

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

            \[\leadsto \frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re} \]
          4. lower-*.f6452.6

            \[\leadsto \frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re} \]
        6. Applied rewrites52.6%

          \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
        7. Step-by-step derivation
          1. Applied rewrites53.7%

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

        Alternative 4: 77.9% accurate, 1.1× 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.72 \cdot 10^{-38}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.re \leq 1.75 \cdot 10^{+22}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.re, x.im\right)}{y.im}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
        (FPCore (x.re x.im y.re y.im)
         :precision binary64
         (let* ((t_0 (/ (fma (/ x.im y.re) y.im x.re) y.re)))
           (if (<= y.re -1.72e-38)
             t_0
             (if (<= y.re 1.75e+22) (/ (fma (/ y.re y.im) x.re x.im) y.im) t_0))))
        double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
        	double t_0 = fma((x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re;
        	double tmp;
        	if (y_46_re <= -1.72e-38) {
        		tmp = t_0;
        	} else if (y_46_re <= 1.75e+22) {
        		tmp = fma((y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im;
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        function code(x_46_re, x_46_im, y_46_re, y_46_im)
        	t_0 = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re)
        	tmp = 0.0
        	if (y_46_re <= -1.72e-38)
        		tmp = t_0;
        	elseif (y_46_re <= 1.75e+22)
        		tmp = Float64(fma(Float64(y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im);
        	else
        		tmp = t_0;
        	end
        	return tmp
        end
        
        code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(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.72e-38], t$95$0, If[LessEqual[y$46$re, 1.75e+22], N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$re + x$46$im), $MachinePrecision] / y$46$im), $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.72 \cdot 10^{-38}:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;y.re \leq 1.75 \cdot 10^{+22}:\\
        \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.re, x.im\right)}{y.im}\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if y.re < -1.72e-38 or 1.75e22 < y.re

          1. Initial program 62.4%

            \[\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
          2. Step-by-step derivation
            1. *-lft-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{y.im \cdot y.im + \color{blue}{\left(\mathsf{neg}\left(\left|y.re\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
            20. fp-cancel-sign-sub-invN/A

              \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{\color{blue}{y.im \cdot y.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|y.re\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|y.re\right|\right)\right)}} \]
            21. fp-cancel-sub-sign-invN/A

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

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

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

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

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

              \[\leadsto \frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{y.im \cdot y.im + \color{blue}{\left|y.re\right| \cdot \left|y.re\right|}} \]
            27. sqr-abs-revN/A

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

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

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

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

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

              \[\leadsto \frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re} \]
            4. lower-*.f6452.6

              \[\leadsto \frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re} \]
          6. Applied rewrites52.6%

            \[\leadsto \color{blue}{\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}} \]
          7. Step-by-step derivation
            1. Applied rewrites53.7%

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

            if -1.72e-38 < y.re < 1.75e22

            1. Initial program 62.4%

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

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

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

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

                \[\leadsto \frac{x.im + \frac{x.re \cdot y.re}{y.im}}{y.im} \]
              4. lower-*.f6452.1

                \[\leadsto \frac{x.im + \frac{x.re \cdot y.re}{y.im}}{y.im} \]
            4. Applied rewrites52.1%

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

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

          Alternative 5: 70.8% accurate, 1.1× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -1.72 \cdot 10^{-38}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq 1.7 \cdot 10^{+113}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.re, x.im\right)}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \end{array} \end{array} \]
          (FPCore (x.re x.im y.re y.im)
           :precision binary64
           (if (<= y.re -1.72e-38)
             (/ x.re y.re)
             (if (<= y.re 1.7e+113)
               (/ (fma (/ y.re y.im) x.re x.im) y.im)
               (/ x.re y.re))))
          double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
          	double tmp;
          	if (y_46_re <= -1.72e-38) {
          		tmp = x_46_re / y_46_re;
          	} else if (y_46_re <= 1.7e+113) {
          		tmp = fma((y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im;
          	} else {
          		tmp = x_46_re / y_46_re;
          	}
          	return tmp;
          }
          
          function code(x_46_re, x_46_im, y_46_re, y_46_im)
          	tmp = 0.0
          	if (y_46_re <= -1.72e-38)
          		tmp = Float64(x_46_re / y_46_re);
          	elseif (y_46_re <= 1.7e+113)
          		tmp = Float64(fma(Float64(y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im);
          	else
          		tmp = Float64(x_46_re / y_46_re);
          	end
          	return tmp
          end
          
          code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -1.72e-38], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 1.7e+113], N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;y.re \leq -1.72 \cdot 10^{-38}:\\
          \;\;\;\;\frac{x.re}{y.re}\\
          
          \mathbf{elif}\;y.re \leq 1.7 \cdot 10^{+113}:\\
          \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.re, x.im\right)}{y.im}\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{x.re}{y.re}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if y.re < -1.72e-38 or 1.70000000000000009e113 < y.re

            1. Initial program 62.4%

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

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

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

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

            if -1.72e-38 < y.re < 1.70000000000000009e113

            1. Initial program 62.4%

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

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

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

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

                \[\leadsto \frac{x.im + \frac{x.re \cdot y.re}{y.im}}{y.im} \]
              4. lower-*.f6452.1

                \[\leadsto \frac{x.im + \frac{x.re \cdot y.re}{y.im}}{y.im} \]
            4. Applied rewrites52.1%

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

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

          Alternative 6: 70.0% accurate, 1.1× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -1.72 \cdot 10^{-38}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq 1.7 \cdot 10^{+113}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \end{array} \end{array} \]
          (FPCore (x.re x.im y.re y.im)
           :precision binary64
           (if (<= y.re -1.72e-38)
             (/ x.re y.re)
             (if (<= y.re 1.7e+113)
               (/ (fma (/ x.re y.im) y.re x.im) y.im)
               (/ x.re y.re))))
          double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
          	double tmp;
          	if (y_46_re <= -1.72e-38) {
          		tmp = x_46_re / y_46_re;
          	} else if (y_46_re <= 1.7e+113) {
          		tmp = fma((x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im;
          	} else {
          		tmp = x_46_re / y_46_re;
          	}
          	return tmp;
          }
          
          function code(x_46_re, x_46_im, y_46_re, y_46_im)
          	tmp = 0.0
          	if (y_46_re <= -1.72e-38)
          		tmp = Float64(x_46_re / y_46_re);
          	elseif (y_46_re <= 1.7e+113)
          		tmp = Float64(fma(Float64(x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im);
          	else
          		tmp = Float64(x_46_re / y_46_re);
          	end
          	return tmp
          end
          
          code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -1.72e-38], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 1.7e+113], N[(N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;y.re \leq -1.72 \cdot 10^{-38}:\\
          \;\;\;\;\frac{x.re}{y.re}\\
          
          \mathbf{elif}\;y.re \leq 1.7 \cdot 10^{+113}:\\
          \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{x.re}{y.re}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if y.re < -1.72e-38 or 1.70000000000000009e113 < y.re

            1. Initial program 62.4%

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

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

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

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

            if -1.72e-38 < y.re < 1.70000000000000009e113

            1. Initial program 62.4%

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

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

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

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

                \[\leadsto \frac{x.im + \frac{x.re \cdot y.re}{y.im}}{y.im} \]
              4. lower-*.f6452.1

                \[\leadsto \frac{x.im + \frac{x.re \cdot y.re}{y.im}}{y.im} \]
            4. Applied rewrites52.1%

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

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

          Alternative 7: 62.1% accurate, 1.8× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.im \leq -7.5 \cdot 10^{+44}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{elif}\;y.im \leq 2.8 \cdot 10^{+100}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \end{array} \end{array} \]
          (FPCore (x.re x.im y.re y.im)
           :precision binary64
           (if (<= y.im -7.5e+44)
             (/ x.im y.im)
             (if (<= y.im 2.8e+100) (/ x.re y.re) (/ x.im y.im))))
          double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
          	double tmp;
          	if (y_46_im <= -7.5e+44) {
          		tmp = x_46_im / y_46_im;
          	} else if (y_46_im <= 2.8e+100) {
          		tmp = x_46_re / y_46_re;
          	} else {
          		tmp = x_46_im / y_46_im;
          	}
          	return tmp;
          }
          
          module fmin_fmax_functions
              implicit none
              private
              public fmax
              public fmin
          
              interface fmax
                  module procedure fmax88
                  module procedure fmax44
                  module procedure fmax84
                  module procedure fmax48
              end interface
              interface fmin
                  module procedure fmin88
                  module procedure fmin44
                  module procedure fmin84
                  module procedure fmin48
              end interface
          contains
              real(8) function fmax88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(4) function fmax44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(8) function fmax84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmax48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
              end function
              real(8) function fmin88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(4) function fmin44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(8) function fmin84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmin48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
              end function
          end module
          
          real(8) function code(x_46re, x_46im, y_46re, y_46im)
          use fmin_fmax_functions
              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 <= (-7.5d+44)) then
                  tmp = x_46im / y_46im
              else if (y_46im <= 2.8d+100) then
                  tmp = x_46re / y_46re
              else
                  tmp = x_46im / y_46im
              end if
              code = tmp
          end function
          
          public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
          	double tmp;
          	if (y_46_im <= -7.5e+44) {
          		tmp = x_46_im / y_46_im;
          	} else if (y_46_im <= 2.8e+100) {
          		tmp = x_46_re / y_46_re;
          	} else {
          		tmp = x_46_im / y_46_im;
          	}
          	return tmp;
          }
          
          def code(x_46_re, x_46_im, y_46_re, y_46_im):
          	tmp = 0
          	if y_46_im <= -7.5e+44:
          		tmp = x_46_im / y_46_im
          	elif y_46_im <= 2.8e+100:
          		tmp = x_46_re / y_46_re
          	else:
          		tmp = x_46_im / y_46_im
          	return tmp
          
          function code(x_46_re, x_46_im, y_46_re, y_46_im)
          	tmp = 0.0
          	if (y_46_im <= -7.5e+44)
          		tmp = Float64(x_46_im / y_46_im);
          	elseif (y_46_im <= 2.8e+100)
          		tmp = Float64(x_46_re / y_46_re);
          	else
          		tmp = Float64(x_46_im / y_46_im);
          	end
          	return tmp
          end
          
          function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
          	tmp = 0.0;
          	if (y_46_im <= -7.5e+44)
          		tmp = x_46_im / y_46_im;
          	elseif (y_46_im <= 2.8e+100)
          		tmp = x_46_re / y_46_re;
          	else
          		tmp = x_46_im / y_46_im;
          	end
          	tmp_2 = tmp;
          end
          
          code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$im, -7.5e+44], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 2.8e+100], N[(x$46$re / y$46$re), $MachinePrecision], N[(x$46$im / y$46$im), $MachinePrecision]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;y.im \leq -7.5 \cdot 10^{+44}:\\
          \;\;\;\;\frac{x.im}{y.im}\\
          
          \mathbf{elif}\;y.im \leq 2.8 \cdot 10^{+100}:\\
          \;\;\;\;\frac{x.re}{y.re}\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{x.im}{y.im}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if y.im < -7.50000000000000027e44 or 2.7999999999999998e100 < y.im

            1. Initial program 62.4%

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

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

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

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

            if -7.50000000000000027e44 < y.im < 2.7999999999999998e100

            1. Initial program 62.4%

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

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

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

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

          Alternative 8: 42.8% accurate, 5.0× speedup?

          \[\begin{array}{l} \\ \frac{x.im}{y.im} \end{array} \]
          (FPCore (x.re x.im y.re y.im) :precision binary64 (/ x.im y.im))
          double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
          	return x_46_im / y_46_im;
          }
          
          module fmin_fmax_functions
              implicit none
              private
              public fmax
              public fmin
          
              interface fmax
                  module procedure fmax88
                  module procedure fmax44
                  module procedure fmax84
                  module procedure fmax48
              end interface
              interface fmin
                  module procedure fmin88
                  module procedure fmin44
                  module procedure fmin84
                  module procedure fmin48
              end interface
          contains
              real(8) function fmax88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(4) function fmax44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(8) function fmax84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmax48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
              end function
              real(8) function fmin88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(4) function fmin44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(8) function fmin84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmin48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
              end function
          end module
          
          real(8) function code(x_46re, x_46im, y_46re, y_46im)
          use fmin_fmax_functions
              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 62.4%

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

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

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

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

          Reproduce

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