_divideComplex, imaginary part

Percentage Accurate: 61.2% → 84.4%
Time: 3.7s
Alternatives: 13
Speedup: 1.7×

Specification

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

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

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 13 alternatives:

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

Initial Program: 61.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
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_46re) - (x_46re * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	return ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	return Float64(Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)))
end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 84.4% 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(y.re, y.re, y.im \cdot y.im\right)\\ t_2 := \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re}\\ \mathbf{if}\;y.re \leq -2.7 \cdot 10^{+84}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;y.re \leq -7.2 \cdot 10^{-99}:\\ \;\;\;\;\mathsf{fma}\left(\frac{-y.im}{t\_0}, x.re, \frac{x.im}{t\_0} \cdot y.re\right)\\ \mathbf{elif}\;y.re \leq 5.2 \cdot 10^{-155}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -x.re\right)}{y.im}\\ \mathbf{elif}\;y.re \leq 4.5 \cdot 10^{+83}:\\ \;\;\;\;\frac{y.re}{t\_1} \cdot x.im - \frac{y.im}{t\_1} \cdot x.re\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (fma y.im y.im (* y.re y.re)))
        (t_1 (fma y.re y.re (* y.im y.im)))
        (t_2 (/ (- x.im (* (/ x.re y.re) y.im)) y.re)))
   (if (<= y.re -2.7e+84)
     t_2
     (if (<= y.re -7.2e-99)
       (fma (/ (- y.im) t_0) x.re (* (/ x.im t_0) y.re))
       (if (<= y.re 5.2e-155)
         (/ (fma (/ y.re y.im) x.im (- x.re)) y.im)
         (if (<= y.re 4.5e+83)
           (- (* (/ y.re t_1) x.im) (* (/ y.im t_1) x.re))
           t_2))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = fma(y_46_im, y_46_im, (y_46_re * y_46_re));
	double t_1 = fma(y_46_re, y_46_re, (y_46_im * y_46_im));
	double t_2 = (x_46_im - ((x_46_re / y_46_re) * y_46_im)) / y_46_re;
	double tmp;
	if (y_46_re <= -2.7e+84) {
		tmp = t_2;
	} else if (y_46_re <= -7.2e-99) {
		tmp = fma((-y_46_im / t_0), x_46_re, ((x_46_im / t_0) * y_46_re));
	} else if (y_46_re <= 5.2e-155) {
		tmp = fma((y_46_re / y_46_im), x_46_im, -x_46_re) / y_46_im;
	} else if (y_46_re <= 4.5e+83) {
		tmp = ((y_46_re / t_1) * x_46_im) - ((y_46_im / t_1) * x_46_re);
	} else {
		tmp = t_2;
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))
	t_1 = fma(y_46_re, y_46_re, Float64(y_46_im * y_46_im))
	t_2 = Float64(Float64(x_46_im - Float64(Float64(x_46_re / y_46_re) * y_46_im)) / y_46_re)
	tmp = 0.0
	if (y_46_re <= -2.7e+84)
		tmp = t_2;
	elseif (y_46_re <= -7.2e-99)
		tmp = fma(Float64(Float64(-y_46_im) / t_0), x_46_re, Float64(Float64(x_46_im / t_0) * y_46_re));
	elseif (y_46_re <= 5.2e-155)
		tmp = Float64(fma(Float64(y_46_re / y_46_im), x_46_im, Float64(-x_46_re)) / y_46_im);
	elseif (y_46_re <= 4.5e+83)
		tmp = Float64(Float64(Float64(y_46_re / t_1) * x_46_im) - Float64(Float64(y_46_im / t_1) * x_46_re));
	else
		tmp = t_2;
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y$46$re * y$46$re + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x$46$im - N[(N[(x$46$re / y$46$re), $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -2.7e+84], t$95$2, If[LessEqual[y$46$re, -7.2e-99], N[(N[((-y$46$im) / t$95$0), $MachinePrecision] * x$46$re + N[(N[(x$46$im / t$95$0), $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 5.2e-155], N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$im + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 4.5e+83], N[(N[(N[(y$46$re / t$95$1), $MachinePrecision] * x$46$im), $MachinePrecision] - N[(N[(y$46$im / t$95$1), $MachinePrecision] * x$46$re), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]]
\begin{array}{l}

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

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

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

\mathbf{elif}\;y.re \leq 4.5 \cdot 10^{+83}:\\
\;\;\;\;\frac{y.re}{t\_1} \cdot x.im - \frac{y.im}{t\_1} \cdot x.re\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y.re < -2.7e84 or 4.4999999999999999e83 < y.re

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      5. lower-*.f6451.8

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      2. add-flipN/A

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

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

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

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

        \[\leadsto \frac{x.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{x.re \cdot y.im}{y.re}\right)\right)\right)\right)}{y.re} \]
      7. distribute-neg-fracN/A

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

        \[\leadsto \frac{x.im - \frac{\mathsf{neg}\left(x.re \cdot y.im\right)}{\mathsf{neg}\left(y.re\right)}}{y.re} \]
      9. frac-2negN/A

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      10. lift-/.f6451.8

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
    6. Applied rewrites51.8%

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

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
      7. lower-/.f6453.0

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
    8. Applied rewrites53.0%

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

    if -2.7e84 < y.re < -7.2000000000000001e-99

    1. Initial program 61.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-y.im}{\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.re\right)} \]

    if -7.2000000000000001e-99 < y.re < 5.20000000000000016e-155

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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{-1 \cdot x.re + \frac{x.im \cdot y.re}{y.im}}{y.im}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, \left(\mathsf{neg}\left(1\right)\right) \cdot x.re\right)}{y.im} \]
      10. distribute-lft-neg-outN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, \mathsf{neg}\left(1 \cdot x.re\right)\right)}{y.im} \]
      11. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, \mathsf{neg}\left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x.re\right)\right)}{y.im} \]
      12. distribute-lft-neg-outN/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -\left(\mathsf{neg}\left(-1 \cdot x.re\right)\right)\right)}{y.im} \]
      14. distribute-lft-neg-outN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -\left(\mathsf{neg}\left(-1\right)\right) \cdot x.re\right)}{y.im} \]
      15. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -1 \cdot x.re\right)}{y.im} \]
      16. *-lft-identity54.5

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

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

    if 5.20000000000000016e-155 < y.re < 4.4999999999999999e83

    1. Initial program 61.2%

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{y.re \cdot y.re + y.im \cdot y.im}{x.im \cdot y.re - x.re \cdot y.im}}} \]
      4. lower-unsound-/.f6461.0

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

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

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

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      8. sqr-abs-revN/A

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{\left|y.re\right| \cdot \left|y.re\right|}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      9. sqr-neg-revN/A

        \[\leadsto \frac{1}{\frac{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)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      10. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{1}{\frac{\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)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      11. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{1}{\frac{\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)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      12. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\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)}{x.im \cdot y.re - x.re \cdot y.im}} \]
      13. distribute-lft-neg-inN/A

        \[\leadsto \frac{1}{\frac{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)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      14. distribute-lft-neg-inN/A

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

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

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

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

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      19. lower-fma.f6461.0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 84.0% accurate, 0.5× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.re < -1.29999999999999999e87 or 4.4999999999999999e83 < y.re

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      5. lower-*.f6451.8

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      2. add-flipN/A

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

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

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

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

        \[\leadsto \frac{x.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{x.re \cdot y.im}{y.re}\right)\right)\right)\right)}{y.re} \]
      7. distribute-neg-fracN/A

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

        \[\leadsto \frac{x.im - \frac{\mathsf{neg}\left(x.re \cdot y.im\right)}{\mathsf{neg}\left(y.re\right)}}{y.re} \]
      9. frac-2negN/A

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      10. lift-/.f6451.8

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
    6. Applied rewrites51.8%

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

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
      7. lower-/.f6453.0

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
    8. Applied rewrites53.0%

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

    if -1.29999999999999999e87 < y.re < -7.2000000000000001e-99 or 5.20000000000000016e-155 < y.re < 4.4999999999999999e83

    1. Initial program 61.2%

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{y.re \cdot y.re + y.im \cdot y.im}{x.im \cdot y.re - x.re \cdot y.im}}} \]
      4. lower-unsound-/.f6461.0

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

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

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

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      8. sqr-abs-revN/A

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{\left|y.re\right| \cdot \left|y.re\right|}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      9. sqr-neg-revN/A

        \[\leadsto \frac{1}{\frac{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)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      10. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{1}{\frac{\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)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      11. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{1}{\frac{\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)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      12. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\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)}{x.im \cdot y.re - x.re \cdot y.im}} \]
      13. distribute-lft-neg-inN/A

        \[\leadsto \frac{1}{\frac{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)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      14. distribute-lft-neg-inN/A

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

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

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

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

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      19. lower-fma.f6461.0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.2000000000000001e-99 < y.re < 5.20000000000000016e-155

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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{-1 \cdot x.re + \frac{x.im \cdot y.re}{y.im}}{y.im}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, \left(\mathsf{neg}\left(1\right)\right) \cdot x.re\right)}{y.im} \]
      10. distribute-lft-neg-outN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, \mathsf{neg}\left(1 \cdot x.re\right)\right)}{y.im} \]
      11. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, \mathsf{neg}\left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x.re\right)\right)}{y.im} \]
      12. distribute-lft-neg-outN/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -\left(\mathsf{neg}\left(-1 \cdot x.re\right)\right)\right)}{y.im} \]
      14. distribute-lft-neg-outN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -\left(\mathsf{neg}\left(-1\right)\right) \cdot x.re\right)}{y.im} \]
      15. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -1 \cdot x.re\right)}{y.im} \]
      16. *-lft-identity54.5

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

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

Alternative 3: 83.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)\\ t_1 := \frac{x.re}{-y.im}\\ \mathbf{if}\;y.im \leq -1.15 \cdot 10^{+111}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y.re}{y.im}, \frac{1}{\frac{y.im}{x.im}}, t\_1\right)\\ \mathbf{elif}\;y.im \leq -2.3 \cdot 10^{-151}:\\ \;\;\;\;\frac{x.im \cdot y.re - x.re \cdot y.im}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}\\ \mathbf{elif}\;y.im \leq 2.15 \cdot 10^{-29}:\\ \;\;\;\;\frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re}\\ \mathbf{elif}\;y.im \leq 2.35 \cdot 10^{+101}:\\ \;\;\;\;\frac{x.im}{t\_0} \cdot y.re - \frac{x.re}{t\_0} \cdot y.im\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y.re}{y.im}, \frac{x.im}{y.im}, t\_1\right)\\ \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 (/ x.re (- y.im))))
   (if (<= y.im -1.15e+111)
     (fma (/ y.re y.im) (/ 1.0 (/ y.im x.im)) t_1)
     (if (<= y.im -2.3e-151)
       (/ (- (* x.im y.re) (* x.re y.im)) (fma y.re y.re (* y.im y.im)))
       (if (<= y.im 2.15e-29)
         (/ (- x.im (/ (* x.re y.im) y.re)) y.re)
         (if (<= y.im 2.35e+101)
           (- (* (/ x.im t_0) y.re) (* (/ x.re t_0) y.im))
           (fma (/ y.re y.im) (/ x.im y.im) t_1)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = fma(y_46_im, y_46_im, (y_46_re * y_46_re));
	double t_1 = x_46_re / -y_46_im;
	double tmp;
	if (y_46_im <= -1.15e+111) {
		tmp = fma((y_46_re / y_46_im), (1.0 / (y_46_im / x_46_im)), t_1);
	} else if (y_46_im <= -2.3e-151) {
		tmp = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / fma(y_46_re, y_46_re, (y_46_im * y_46_im));
	} else if (y_46_im <= 2.15e-29) {
		tmp = (x_46_im - ((x_46_re * y_46_im) / y_46_re)) / y_46_re;
	} else if (y_46_im <= 2.35e+101) {
		tmp = ((x_46_im / t_0) * y_46_re) - ((x_46_re / t_0) * y_46_im);
	} else {
		tmp = fma((y_46_re / y_46_im), (x_46_im / y_46_im), t_1);
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))
	t_1 = Float64(x_46_re / Float64(-y_46_im))
	tmp = 0.0
	if (y_46_im <= -1.15e+111)
		tmp = fma(Float64(y_46_re / y_46_im), Float64(1.0 / Float64(y_46_im / x_46_im)), t_1);
	elseif (y_46_im <= -2.3e-151)
		tmp = Float64(Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im)) / fma(y_46_re, y_46_re, Float64(y_46_im * y_46_im)));
	elseif (y_46_im <= 2.15e-29)
		tmp = Float64(Float64(x_46_im - Float64(Float64(x_46_re * y_46_im) / y_46_re)) / y_46_re);
	elseif (y_46_im <= 2.35e+101)
		tmp = Float64(Float64(Float64(x_46_im / t_0) * y_46_re) - Float64(Float64(x_46_re / t_0) * y_46_im));
	else
		tmp = fma(Float64(y_46_re / y_46_im), Float64(x_46_im / y_46_im), t_1);
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x$46$re / (-y$46$im)), $MachinePrecision]}, If[LessEqual[y$46$im, -1.15e+111], N[(N[(y$46$re / y$46$im), $MachinePrecision] * N[(1.0 / N[(y$46$im / x$46$im), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], If[LessEqual[y$46$im, -2.3e-151], N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(y$46$re * y$46$re + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 2.15e-29], N[(N[(x$46$im - N[(N[(x$46$re * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 2.35e+101], N[(N[(N[(x$46$im / t$95$0), $MachinePrecision] * y$46$re), $MachinePrecision] - N[(N[(x$46$re / t$95$0), $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision], N[(N[(y$46$re / y$46$im), $MachinePrecision] * N[(x$46$im / y$46$im), $MachinePrecision] + t$95$1), $MachinePrecision]]]]]]]
\begin{array}{l}

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

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

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

\mathbf{elif}\;y.im \leq 2.35 \cdot 10^{+101}:\\
\;\;\;\;\frac{x.im}{t\_0} \cdot y.re - \frac{x.re}{t\_0} \cdot y.im\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y.re}{y.im}, \frac{x.im}{y.im}, t\_1\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if y.im < -1.15000000000000001e111

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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{-1 \cdot x.re + \frac{x.im \cdot y.re}{y.im}}{y.im}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{y.re}{y.im}, \frac{x.im}{y.im}, \frac{\mathsf{neg}\left(-1 \cdot x.re\right)}{-y.im}\right) \]
      16. distribute-lft-neg-outN/A

        \[\leadsto \mathsf{fma}\left(\frac{y.re}{y.im}, \frac{x.im}{y.im}, \frac{\left(\mathsf{neg}\left(-1\right)\right) \cdot x.re}{-y.im}\right) \]
      17. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\frac{y.re}{y.im}, \frac{x.im}{y.im}, \frac{1 \cdot x.re}{-y.im}\right) \]
      18. *-lft-identity52.9

        \[\leadsto \mathsf{fma}\left(\frac{y.re}{y.im}, \frac{x.im}{y.im}, \frac{x.re}{-y.im}\right) \]
    6. Applied rewrites52.9%

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

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

        \[\leadsto \mathsf{fma}\left(\frac{y.re}{y.im}, \frac{1}{\color{blue}{\frac{y.im}{x.im}}}, \frac{x.re}{-y.im}\right) \]
      3. metadata-evalN/A

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

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

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

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

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

    if -1.15000000000000001e111 < y.im < -2.29999999999999996e-151

    1. Initial program 61.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + \color{blue}{y.im \cdot y.im}} \]
      17. lower-fma.f6461.2

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

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

    if -2.29999999999999996e-151 < y.im < 2.1499999999999999e-29

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      5. lower-*.f6451.8

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      2. add-flipN/A

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

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

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

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

        \[\leadsto \frac{x.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{x.re \cdot y.im}{y.re}\right)\right)\right)\right)}{y.re} \]
      7. distribute-neg-fracN/A

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

        \[\leadsto \frac{x.im - \frac{\mathsf{neg}\left(x.re \cdot y.im\right)}{\mathsf{neg}\left(y.re\right)}}{y.re} \]
      9. frac-2negN/A

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      10. lift-/.f6451.8

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
    6. Applied rewrites51.8%

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

    if 2.1499999999999999e-29 < y.im < 2.34999999999999985e101

    1. Initial program 61.2%

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

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

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

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

        \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}} \]
    3. Applied rewrites58.4%

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

    if 2.34999999999999985e101 < y.im

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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{-1 \cdot x.re + \frac{x.im \cdot y.re}{y.im}}{y.im}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{y.re}{y.im}, \frac{x.im}{y.im}, \frac{\mathsf{neg}\left(-1 \cdot x.re\right)}{-y.im}\right) \]
      16. distribute-lft-neg-outN/A

        \[\leadsto \mathsf{fma}\left(\frac{y.re}{y.im}, \frac{x.im}{y.im}, \frac{\left(\mathsf{neg}\left(-1\right)\right) \cdot x.re}{-y.im}\right) \]
      17. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\frac{y.re}{y.im}, \frac{x.im}{y.im}, \frac{1 \cdot x.re}{-y.im}\right) \]
      18. *-lft-identity52.9

        \[\leadsto \mathsf{fma}\left(\frac{y.re}{y.im}, \frac{x.im}{y.im}, \frac{x.re}{-y.im}\right) \]
    6. Applied rewrites52.9%

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

Alternative 4: 82.4% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re}\\
\mathbf{if}\;y.re \leq -3.4 \cdot 10^{+86}:\\
\;\;\;\;t\_0\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y.re < -3.3999999999999998e86 or 1.85e50 < y.re

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      5. lower-*.f6451.8

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      2. add-flipN/A

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

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

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

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

        \[\leadsto \frac{x.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{x.re \cdot y.im}{y.re}\right)\right)\right)\right)}{y.re} \]
      7. distribute-neg-fracN/A

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

        \[\leadsto \frac{x.im - \frac{\mathsf{neg}\left(x.re \cdot y.im\right)}{\mathsf{neg}\left(y.re\right)}}{y.re} \]
      9. frac-2negN/A

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      10. lift-/.f6451.8

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
    6. Applied rewrites51.8%

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

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
      7. lower-/.f6453.0

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
    8. Applied rewrites53.0%

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

    if -3.3999999999999998e86 < y.re < -7.2000000000000001e-99

    1. Initial program 61.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + \color{blue}{y.im \cdot y.im}} \]
      17. lower-fma.f6461.2

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

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

    if -7.2000000000000001e-99 < y.re < 2.44999999999999994e-115

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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{-1 \cdot x.re + \frac{x.im \cdot y.re}{y.im}}{y.im}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, \left(\mathsf{neg}\left(1\right)\right) \cdot x.re\right)}{y.im} \]
      10. distribute-lft-neg-outN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, \mathsf{neg}\left(1 \cdot x.re\right)\right)}{y.im} \]
      11. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, \mathsf{neg}\left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x.re\right)\right)}{y.im} \]
      12. distribute-lft-neg-outN/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -\left(\mathsf{neg}\left(-1 \cdot x.re\right)\right)\right)}{y.im} \]
      14. distribute-lft-neg-outN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -\left(\mathsf{neg}\left(-1\right)\right) \cdot x.re\right)}{y.im} \]
      15. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -1 \cdot x.re\right)}{y.im} \]
      16. *-lft-identity54.5

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

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

    if 2.44999999999999994e-115 < y.re < 1.85e50

    1. Initial program 61.2%

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{y.re \cdot y.re + y.im \cdot y.im}{x.im \cdot y.re - x.re \cdot y.im}}} \]
      4. lower-unsound-/.f6461.0

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

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

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

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      8. sqr-abs-revN/A

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{\left|y.re\right| \cdot \left|y.re\right|}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      9. sqr-neg-revN/A

        \[\leadsto \frac{1}{\frac{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)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      10. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{1}{\frac{\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)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      11. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{1}{\frac{\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)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      12. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{\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)}{x.im \cdot y.re - x.re \cdot y.im}} \]
      13. distribute-lft-neg-inN/A

        \[\leadsto \frac{1}{\frac{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)}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      14. distribute-lft-neg-inN/A

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

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

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

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

        \[\leadsto \frac{1}{\frac{y.im \cdot y.im + \color{blue}{y.re \cdot y.re}}{x.im \cdot y.re - x.re \cdot y.im}} \]
      19. lower-fma.f6461.0

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

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

Alternative 5: 82.4% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;y.re \leq -7.2 \cdot 10^{-99}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;y.re \leq 1.85 \cdot 10^{+50}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.re < -3.3999999999999998e86 or 1.85e50 < y.re

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      5. lower-*.f6451.8

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      2. add-flipN/A

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

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

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

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

        \[\leadsto \frac{x.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{x.re \cdot y.im}{y.re}\right)\right)\right)\right)}{y.re} \]
      7. distribute-neg-fracN/A

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

        \[\leadsto \frac{x.im - \frac{\mathsf{neg}\left(x.re \cdot y.im\right)}{\mathsf{neg}\left(y.re\right)}}{y.re} \]
      9. frac-2negN/A

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      10. lift-/.f6451.8

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
    6. Applied rewrites51.8%

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

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
      7. lower-/.f6453.0

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
    8. Applied rewrites53.0%

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

    if -3.3999999999999998e86 < y.re < -7.2000000000000001e-99 or 5.9000000000000003e-117 < y.re < 1.85e50

    1. Initial program 61.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + \color{blue}{y.im \cdot y.im}} \]
      17. lower-fma.f6461.2

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

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

    if -7.2000000000000001e-99 < y.re < 5.9000000000000003e-117

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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{-1 \cdot x.re + \frac{x.im \cdot y.re}{y.im}}{y.im}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, \left(\mathsf{neg}\left(1\right)\right) \cdot x.re\right)}{y.im} \]
      10. distribute-lft-neg-outN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, \mathsf{neg}\left(1 \cdot x.re\right)\right)}{y.im} \]
      11. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, \mathsf{neg}\left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x.re\right)\right)}{y.im} \]
      12. distribute-lft-neg-outN/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -\left(\mathsf{neg}\left(-1 \cdot x.re\right)\right)\right)}{y.im} \]
      14. distribute-lft-neg-outN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -\left(\mathsf{neg}\left(-1\right)\right) \cdot x.re\right)}{y.im} \]
      15. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -1 \cdot x.re\right)}{y.im} \]
      16. *-lft-identity54.5

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

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

Alternative 6: 77.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -14500:\\ \;\;\;\;\frac{x.im - \frac{1}{\frac{y.re}{x.re}} \cdot y.im}{y.re}\\ \mathbf{elif}\;y.re \leq 7.5 \cdot 10^{-8}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -x.re\right)}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (<= y.re -14500.0)
   (/ (- x.im (* (/ 1.0 (/ y.re x.re)) y.im)) y.re)
   (if (<= y.re 7.5e-8)
     (/ (fma (/ y.re y.im) x.im (- x.re)) y.im)
     (/ (- x.im (* (/ x.re y.re) y.im)) 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 <= -14500.0) {
		tmp = (x_46_im - ((1.0 / (y_46_re / x_46_re)) * y_46_im)) / y_46_re;
	} else if (y_46_re <= 7.5e-8) {
		tmp = fma((y_46_re / y_46_im), x_46_im, -x_46_re) / y_46_im;
	} else {
		tmp = (x_46_im - ((x_46_re / y_46_re) * y_46_im)) / 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 <= -14500.0)
		tmp = Float64(Float64(x_46_im - Float64(Float64(1.0 / Float64(y_46_re / x_46_re)) * y_46_im)) / y_46_re);
	elseif (y_46_re <= 7.5e-8)
		tmp = Float64(fma(Float64(y_46_re / y_46_im), x_46_im, Float64(-x_46_re)) / y_46_im);
	else
		tmp = Float64(Float64(x_46_im - Float64(Float64(x_46_re / y_46_re) * y_46_im)) / 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, -14500.0], N[(N[(x$46$im - N[(N[(1.0 / N[(y$46$re / x$46$re), $MachinePrecision]), $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 7.5e-8], N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$im + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision], N[(N[(x$46$im - N[(N[(x$46$re / y$46$re), $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -14500:\\
\;\;\;\;\frac{x.im - \frac{1}{\frac{y.re}{x.re}} \cdot y.im}{y.re}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.re < -14500

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      5. lower-*.f6451.8

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      2. add-flipN/A

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

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

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

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

        \[\leadsto \frac{x.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{x.re \cdot y.im}{y.re}\right)\right)\right)\right)}{y.re} \]
      7. distribute-neg-fracN/A

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

        \[\leadsto \frac{x.im - \frac{\mathsf{neg}\left(x.re \cdot y.im\right)}{\mathsf{neg}\left(y.re\right)}}{y.re} \]
      9. frac-2negN/A

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      10. lift-/.f6451.8

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
    6. Applied rewrites51.8%

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

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
      7. lower-/.f6453.0

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
    8. Applied rewrites53.0%

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

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
      2. div-flipN/A

        \[\leadsto \frac{x.im - \frac{1}{\frac{y.re}{x.re}} \cdot y.im}{y.re} \]
      3. metadata-evalN/A

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

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

        \[\leadsto \frac{x.im - \frac{1}{\frac{y.re}{x.re}} \cdot y.im}{y.re} \]
      6. lower-unsound-/.f6453.0

        \[\leadsto \frac{x.im - \frac{1}{\frac{y.re}{x.re}} \cdot y.im}{y.re} \]
    10. Applied rewrites53.0%

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

    if -14500 < y.re < 7.4999999999999997e-8

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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{-1 \cdot x.re + \frac{x.im \cdot y.re}{y.im}}{y.im}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, \left(\mathsf{neg}\left(1\right)\right) \cdot x.re\right)}{y.im} \]
      10. distribute-lft-neg-outN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, \mathsf{neg}\left(1 \cdot x.re\right)\right)}{y.im} \]
      11. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, \mathsf{neg}\left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x.re\right)\right)}{y.im} \]
      12. distribute-lft-neg-outN/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -\left(\mathsf{neg}\left(-1 \cdot x.re\right)\right)\right)}{y.im} \]
      14. distribute-lft-neg-outN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -\left(\mathsf{neg}\left(-1\right)\right) \cdot x.re\right)}{y.im} \]
      15. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -1 \cdot x.re\right)}{y.im} \]
      16. *-lft-identity54.5

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

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

    if 7.4999999999999997e-8 < y.re

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      5. lower-*.f6451.8

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      2. add-flipN/A

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

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

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

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

        \[\leadsto \frac{x.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{x.re \cdot y.im}{y.re}\right)\right)\right)\right)}{y.re} \]
      7. distribute-neg-fracN/A

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

        \[\leadsto \frac{x.im - \frac{\mathsf{neg}\left(x.re \cdot y.im\right)}{\mathsf{neg}\left(y.re\right)}}{y.re} \]
      9. frac-2negN/A

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      10. lift-/.f6451.8

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
    6. Applied rewrites51.8%

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

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
      7. lower-/.f6453.0

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
    8. Applied rewrites53.0%

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

Alternative 7: 77.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -14500:\\ \;\;\;\;\frac{\mathsf{fma}\left(y.im, x.re \cdot \frac{-1}{y.re}, x.im\right)}{y.re}\\ \mathbf{elif}\;y.re \leq 7.5 \cdot 10^{-8}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -x.re\right)}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (<= y.re -14500.0)
   (/ (fma y.im (* x.re (/ -1.0 y.re)) x.im) y.re)
   (if (<= y.re 7.5e-8)
     (/ (fma (/ y.re y.im) x.im (- x.re)) y.im)
     (/ (- x.im (* (/ x.re y.re) y.im)) 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 <= -14500.0) {
		tmp = fma(y_46_im, (x_46_re * (-1.0 / y_46_re)), x_46_im) / y_46_re;
	} else if (y_46_re <= 7.5e-8) {
		tmp = fma((y_46_re / y_46_im), x_46_im, -x_46_re) / y_46_im;
	} else {
		tmp = (x_46_im - ((x_46_re / y_46_re) * y_46_im)) / 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 <= -14500.0)
		tmp = Float64(fma(y_46_im, Float64(x_46_re * Float64(-1.0 / y_46_re)), x_46_im) / y_46_re);
	elseif (y_46_re <= 7.5e-8)
		tmp = Float64(fma(Float64(y_46_re / y_46_im), x_46_im, Float64(-x_46_re)) / y_46_im);
	else
		tmp = Float64(Float64(x_46_im - Float64(Float64(x_46_re / y_46_re) * y_46_im)) / 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, -14500.0], N[(N[(y$46$im * N[(x$46$re * N[(-1.0 / y$46$re), $MachinePrecision]), $MachinePrecision] + x$46$im), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 7.5e-8], N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$im + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision], N[(N[(x$46$im - N[(N[(x$46$re / y$46$re), $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -14500:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.im, x.re \cdot \frac{-1}{y.re}, x.im\right)}{y.re}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.re < -14500

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      5. lower-*.f6451.8

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y.im, \left(\mathsf{neg}\left(-1 \cdot x.re\right)\right) \cdot \frac{1}{\mathsf{neg}\left(y.re\right)}, x.im\right)}{y.re} \]
      17. distribute-lft-neg-outN/A

        \[\leadsto \frac{\mathsf{fma}\left(y.im, \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x.re\right) \cdot \frac{1}{\mathsf{neg}\left(y.re\right)}, x.im\right)}{y.re} \]
      18. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(y.im, \left(1 \cdot x.re\right) \cdot \frac{1}{\mathsf{neg}\left(y.re\right)}, x.im\right)}{y.re} \]
      19. *-lft-identityN/A

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

        \[\leadsto \frac{\mathsf{fma}\left(y.im, x.re \cdot \frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(y.re\right)}, x.im\right)}{y.re} \]
      21. frac-2neg-revN/A

        \[\leadsto \frac{\mathsf{fma}\left(y.im, x.re \cdot \frac{-1}{y.re}, x.im\right)}{y.re} \]
      22. lower-/.f6453.0

        \[\leadsto \frac{\mathsf{fma}\left(y.im, x.re \cdot \frac{-1}{y.re}, x.im\right)}{y.re} \]
    6. Applied rewrites53.0%

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

    if -14500 < y.re < 7.4999999999999997e-8

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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{-1 \cdot x.re + \frac{x.im \cdot y.re}{y.im}}{y.im}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, \left(\mathsf{neg}\left(1\right)\right) \cdot x.re\right)}{y.im} \]
      10. distribute-lft-neg-outN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, \mathsf{neg}\left(1 \cdot x.re\right)\right)}{y.im} \]
      11. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, \mathsf{neg}\left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x.re\right)\right)}{y.im} \]
      12. distribute-lft-neg-outN/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -\left(\mathsf{neg}\left(-1 \cdot x.re\right)\right)\right)}{y.im} \]
      14. distribute-lft-neg-outN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -\left(\mathsf{neg}\left(-1\right)\right) \cdot x.re\right)}{y.im} \]
      15. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -1 \cdot x.re\right)}{y.im} \]
      16. *-lft-identity54.5

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

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

    if 7.4999999999999997e-8 < y.re

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      5. lower-*.f6451.8

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      2. add-flipN/A

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

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

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

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

        \[\leadsto \frac{x.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{x.re \cdot y.im}{y.re}\right)\right)\right)\right)}{y.re} \]
      7. distribute-neg-fracN/A

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

        \[\leadsto \frac{x.im - \frac{\mathsf{neg}\left(x.re \cdot y.im\right)}{\mathsf{neg}\left(y.re\right)}}{y.re} \]
      9. frac-2negN/A

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      10. lift-/.f6451.8

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
    6. Applied rewrites51.8%

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

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
      7. lower-/.f6453.0

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
    8. Applied rewrites53.0%

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

Alternative 8: 77.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re}\\ \mathbf{if}\;y.re \leq -14500:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.re \leq 7.5 \cdot 10^{-8}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -x.re\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 (/ (- x.im (* (/ x.re y.re) y.im)) y.re)))
   (if (<= y.re -14500.0)
     t_0
     (if (<= y.re 7.5e-8) (/ (fma (/ y.re y.im) x.im (- x.re)) 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 = (x_46_im - ((x_46_re / y_46_re) * y_46_im)) / y_46_re;
	double tmp;
	if (y_46_re <= -14500.0) {
		tmp = t_0;
	} else if (y_46_re <= 7.5e-8) {
		tmp = fma((y_46_re / y_46_im), x_46_im, -x_46_re) / 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(Float64(x_46_im - Float64(Float64(x_46_re / y_46_re) * y_46_im)) / y_46_re)
	tmp = 0.0
	if (y_46_re <= -14500.0)
		tmp = t_0;
	elseif (y_46_re <= 7.5e-8)
		tmp = Float64(fma(Float64(y_46_re / y_46_im), x_46_im, Float64(-x_46_re)) / y_46_im);
	else
		tmp = t_0;
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(x$46$im - N[(N[(x$46$re / y$46$re), $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -14500.0], t$95$0, If[LessEqual[y$46$re, 7.5e-8], N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$im + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re}\\
\mathbf{if}\;y.re \leq -14500:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.re < -14500 or 7.4999999999999997e-8 < y.re

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      5. lower-*.f6451.8

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      2. add-flipN/A

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

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

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

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

        \[\leadsto \frac{x.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{x.re \cdot y.im}{y.re}\right)\right)\right)\right)}{y.re} \]
      7. distribute-neg-fracN/A

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

        \[\leadsto \frac{x.im - \frac{\mathsf{neg}\left(x.re \cdot y.im\right)}{\mathsf{neg}\left(y.re\right)}}{y.re} \]
      9. frac-2negN/A

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      10. lift-/.f6451.8

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
    6. Applied rewrites51.8%

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

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
      7. lower-/.f6453.0

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
    8. Applied rewrites53.0%

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

    if -14500 < y.re < 7.4999999999999997e-8

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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{-1 \cdot x.re + \frac{x.im \cdot y.re}{y.im}}{y.im}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, \left(\mathsf{neg}\left(1\right)\right) \cdot x.re\right)}{y.im} \]
      10. distribute-lft-neg-outN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, \mathsf{neg}\left(1 \cdot x.re\right)\right)}{y.im} \]
      11. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, \mathsf{neg}\left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x.re\right)\right)}{y.im} \]
      12. distribute-lft-neg-outN/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -\left(\mathsf{neg}\left(-1 \cdot x.re\right)\right)\right)}{y.im} \]
      14. distribute-lft-neg-outN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -\left(\mathsf{neg}\left(-1\right)\right) \cdot x.re\right)}{y.im} \]
      15. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.im, -1 \cdot x.re\right)}{y.im} \]
      16. *-lft-identity54.5

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

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

Alternative 9: 77.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re}\\ \mathbf{if}\;y.re \leq -14500:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.re \leq 7.5 \cdot 10^{-8}:\\ \;\;\;\;\frac{\frac{x.im \cdot y.re}{y.im} - x.re}{y.im}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (/ (- x.im (* (/ x.re y.re) y.im)) y.re)))
   (if (<= y.re -14500.0)
     t_0
     (if (<= y.re 7.5e-8) (/ (- (/ (* x.im y.re) y.im) x.re) 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 = (x_46_im - ((x_46_re / y_46_re) * y_46_im)) / y_46_re;
	double tmp;
	if (y_46_re <= -14500.0) {
		tmp = t_0;
	} else if (y_46_re <= 7.5e-8) {
		tmp = (((x_46_im * y_46_re) / y_46_im) - x_46_re) / y_46_im;
	} else {
		tmp = t_0;
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = (x_46im - ((x_46re / y_46re) * y_46im)) / y_46re
    if (y_46re <= (-14500.0d0)) then
        tmp = t_0
    else if (y_46re <= 7.5d-8) then
        tmp = (((x_46im * y_46re) / y_46im) - x_46re) / y_46im
    else
        tmp = t_0
    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 t_0 = (x_46_im - ((x_46_re / y_46_re) * y_46_im)) / y_46_re;
	double tmp;
	if (y_46_re <= -14500.0) {
		tmp = t_0;
	} else if (y_46_re <= 7.5e-8) {
		tmp = (((x_46_im * y_46_re) / y_46_im) - x_46_re) / y_46_im;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = (x_46_im - ((x_46_re / y_46_re) * y_46_im)) / y_46_re
	tmp = 0
	if y_46_re <= -14500.0:
		tmp = t_0
	elif y_46_re <= 7.5e-8:
		tmp = (((x_46_im * y_46_re) / y_46_im) - x_46_re) / 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(Float64(x_46_im - Float64(Float64(x_46_re / y_46_re) * y_46_im)) / y_46_re)
	tmp = 0.0
	if (y_46_re <= -14500.0)
		tmp = t_0;
	elseif (y_46_re <= 7.5e-8)
		tmp = Float64(Float64(Float64(Float64(x_46_im * y_46_re) / y_46_im) - x_46_re) / y_46_im);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = (x_46_im - ((x_46_re / y_46_re) * y_46_im)) / y_46_re;
	tmp = 0.0;
	if (y_46_re <= -14500.0)
		tmp = t_0;
	elseif (y_46_re <= 7.5e-8)
		tmp = (((x_46_im * y_46_re) / y_46_im) - x_46_re) / y_46_im;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(x$46$im - N[(N[(x$46$re / y$46$re), $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -14500.0], t$95$0, If[LessEqual[y$46$re, 7.5e-8], N[(N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] / y$46$im), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re}\\
\mathbf{if}\;y.re \leq -14500:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.re < -14500 or 7.4999999999999997e-8 < y.re

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      5. lower-*.f6451.8

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      2. add-flipN/A

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

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

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

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

        \[\leadsto \frac{x.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{x.re \cdot y.im}{y.re}\right)\right)\right)\right)}{y.re} \]
      7. distribute-neg-fracN/A

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

        \[\leadsto \frac{x.im - \frac{\mathsf{neg}\left(x.re \cdot y.im\right)}{\mathsf{neg}\left(y.re\right)}}{y.re} \]
      9. frac-2negN/A

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      10. lift-/.f6451.8

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
    6. Applied rewrites51.8%

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

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
      7. lower-/.f6453.0

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
    8. Applied rewrites53.0%

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

    if -14500 < y.re < 7.4999999999999997e-8

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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{-1 \cdot x.re + \frac{x.im \cdot y.re}{y.im}}{y.im}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} - \left(\mathsf{neg}\left(-1 \cdot x.re\right)\right)}{y.im} \]
      5. distribute-lft-neg-outN/A

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

        \[\leadsto \frac{\frac{x.im \cdot y.re}{y.im} - 1 \cdot x.re}{y.im} \]
      7. *-lft-identity52.6

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

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

Alternative 10: 73.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-x.re}{y.im}\\ \mathbf{if}\;y.im \leq -3 \cdot 10^{+44}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.im \leq 2.75 \cdot 10^{+52}:\\ \;\;\;\;\frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (/ (- x.re) y.im)))
   (if (<= y.im -3e+44)
     t_0
     (if (<= y.im 2.75e+52) (/ (- x.im (/ (* x.re y.im) y.re)) y.re) t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = -x_46_re / y_46_im;
	double tmp;
	if (y_46_im <= -3e+44) {
		tmp = t_0;
	} else if (y_46_im <= 2.75e+52) {
		tmp = (x_46_im - ((x_46_re * y_46_im) / y_46_re)) / y_46_re;
	} else {
		tmp = t_0;
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = -x_46re / y_46im
    if (y_46im <= (-3d+44)) then
        tmp = t_0
    else if (y_46im <= 2.75d+52) then
        tmp = (x_46im - ((x_46re * y_46im) / y_46re)) / y_46re
    else
        tmp = t_0
    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 t_0 = -x_46_re / y_46_im;
	double tmp;
	if (y_46_im <= -3e+44) {
		tmp = t_0;
	} else if (y_46_im <= 2.75e+52) {
		tmp = (x_46_im - ((x_46_re * y_46_im) / y_46_re)) / y_46_re;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = -x_46_re / y_46_im
	tmp = 0
	if y_46_im <= -3e+44:
		tmp = t_0
	elif y_46_im <= 2.75e+52:
		tmp = (x_46_im - ((x_46_re * y_46_im) / y_46_re)) / y_46_re
	else:
		tmp = t_0
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(-x_46_re) / y_46_im)
	tmp = 0.0
	if (y_46_im <= -3e+44)
		tmp = t_0;
	elseif (y_46_im <= 2.75e+52)
		tmp = Float64(Float64(x_46_im - Float64(Float64(x_46_re * y_46_im) / y_46_re)) / y_46_re);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = -x_46_re / y_46_im;
	tmp = 0.0;
	if (y_46_im <= -3e+44)
		tmp = t_0;
	elseif (y_46_im <= 2.75e+52)
		tmp = (x_46_im - ((x_46_re * y_46_im) / y_46_re)) / y_46_re;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[((-x$46$re) / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -3e+44], t$95$0, If[LessEqual[y$46$im, 2.75e+52], N[(N[(x$46$im - N[(N[(x$46$re * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{-x.re}{y.im}\\
\mathbf{if}\;y.im \leq -3 \cdot 10^{+44}:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < -2.99999999999999987e44 or 2.74999999999999998e52 < y.im

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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{-1 \cdot x.re + \frac{x.im \cdot y.re}{y.im}}{y.im}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

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

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

      \[\leadsto \frac{-1 \cdot x.re}{y.im} \]
    6. Step-by-step derivation
      1. lower-*.f6442.6

        \[\leadsto \frac{-1 \cdot x.re}{y.im} \]
    7. Applied rewrites42.6%

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

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

        \[\leadsto \frac{\mathsf{neg}\left(x.re\right)}{y.im} \]
      3. lower-neg.f6442.6

        \[\leadsto \frac{-x.re}{y.im} \]
    9. Applied rewrites42.6%

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

    if -2.99999999999999987e44 < y.im < 2.74999999999999998e52

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      5. lower-*.f6451.8

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      2. add-flipN/A

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

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

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

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

        \[\leadsto \frac{x.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{x.re \cdot y.im}{y.re}\right)\right)\right)\right)}{y.re} \]
      7. distribute-neg-fracN/A

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

        \[\leadsto \frac{x.im - \frac{\mathsf{neg}\left(x.re \cdot y.im\right)}{\mathsf{neg}\left(y.re\right)}}{y.re} \]
      9. frac-2negN/A

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      10. lift-/.f6451.8

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
    6. Applied rewrites51.8%

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

Alternative 11: 72.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-x.re}{y.im}\\ \mathbf{if}\;y.im \leq -3 \cdot 10^{+44}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.im \leq 8 \cdot 10^{+89}:\\ \;\;\;\;\frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (/ (- x.re) y.im)))
   (if (<= y.im -3e+44)
     t_0
     (if (<= y.im 8e+89) (/ (- x.im (* (/ x.re y.re) y.im)) y.re) t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = -x_46_re / y_46_im;
	double tmp;
	if (y_46_im <= -3e+44) {
		tmp = t_0;
	} else if (y_46_im <= 8e+89) {
		tmp = (x_46_im - ((x_46_re / y_46_re) * y_46_im)) / y_46_re;
	} else {
		tmp = t_0;
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = -x_46re / y_46im
    if (y_46im <= (-3d+44)) then
        tmp = t_0
    else if (y_46im <= 8d+89) then
        tmp = (x_46im - ((x_46re / y_46re) * y_46im)) / y_46re
    else
        tmp = t_0
    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 t_0 = -x_46_re / y_46_im;
	double tmp;
	if (y_46_im <= -3e+44) {
		tmp = t_0;
	} else if (y_46_im <= 8e+89) {
		tmp = (x_46_im - ((x_46_re / y_46_re) * y_46_im)) / y_46_re;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = -x_46_re / y_46_im
	tmp = 0
	if y_46_im <= -3e+44:
		tmp = t_0
	elif y_46_im <= 8e+89:
		tmp = (x_46_im - ((x_46_re / y_46_re) * y_46_im)) / y_46_re
	else:
		tmp = t_0
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(-x_46_re) / y_46_im)
	tmp = 0.0
	if (y_46_im <= -3e+44)
		tmp = t_0;
	elseif (y_46_im <= 8e+89)
		tmp = Float64(Float64(x_46_im - Float64(Float64(x_46_re / y_46_re) * y_46_im)) / y_46_re);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = -x_46_re / y_46_im;
	tmp = 0.0;
	if (y_46_im <= -3e+44)
		tmp = t_0;
	elseif (y_46_im <= 8e+89)
		tmp = (x_46_im - ((x_46_re / y_46_re) * y_46_im)) / y_46_re;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[((-x$46$re) / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -3e+44], t$95$0, If[LessEqual[y$46$im, 8e+89], N[(N[(x$46$im - N[(N[(x$46$re / y$46$re), $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{-x.re}{y.im}\\
\mathbf{if}\;y.im \leq -3 \cdot 10^{+44}:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < -2.99999999999999987e44 or 7.99999999999999996e89 < y.im

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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{-1 \cdot x.re + \frac{x.im \cdot y.re}{y.im}}{y.im}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

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

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

      \[\leadsto \frac{-1 \cdot x.re}{y.im} \]
    6. Step-by-step derivation
      1. lower-*.f6442.6

        \[\leadsto \frac{-1 \cdot x.re}{y.im} \]
    7. Applied rewrites42.6%

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

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

        \[\leadsto \frac{\mathsf{neg}\left(x.re\right)}{y.im} \]
      3. lower-neg.f6442.6

        \[\leadsto \frac{-x.re}{y.im} \]
    9. Applied rewrites42.6%

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

    if -2.99999999999999987e44 < y.im < 7.99999999999999996e89

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      5. lower-*.f6451.8

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

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

        \[\leadsto \frac{x.im + -1 \cdot \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      2. add-flipN/A

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

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

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

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

        \[\leadsto \frac{x.im - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{x.re \cdot y.im}{y.re}\right)\right)\right)\right)}{y.re} \]
      7. distribute-neg-fracN/A

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

        \[\leadsto \frac{x.im - \frac{\mathsf{neg}\left(x.re \cdot y.im\right)}{\mathsf{neg}\left(y.re\right)}}{y.re} \]
      9. frac-2negN/A

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
      10. lift-/.f6451.8

        \[\leadsto \frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re} \]
    6. Applied rewrites51.8%

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

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
      7. lower-/.f6453.0

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
    8. Applied rewrites53.0%

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

Alternative 12: 62.9% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -4.8 \cdot 10^{+60}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{elif}\;y.re \leq 1.25 \cdot 10^{+19}:\\ \;\;\;\;\frac{-x.re}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (<= y.re -4.8e+60)
   (/ x.im y.re)
   (if (<= y.re 1.25e+19) (/ (- x.re) y.im) (/ x.im 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 <= -4.8e+60) {
		tmp = x_46_im / y_46_re;
	} else if (y_46_re <= 1.25e+19) {
		tmp = -x_46_re / y_46_im;
	} else {
		tmp = x_46_im / y_46_re;
	}
	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_46re <= (-4.8d+60)) then
        tmp = x_46im / y_46re
    else if (y_46re <= 1.25d+19) then
        tmp = -x_46re / y_46im
    else
        tmp = x_46im / y_46re
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if (y_46_re <= -4.8e+60) {
		tmp = x_46_im / y_46_re;
	} else if (y_46_re <= 1.25e+19) {
		tmp = -x_46_re / y_46_im;
	} else {
		tmp = x_46_im / y_46_re;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	tmp = 0
	if y_46_re <= -4.8e+60:
		tmp = x_46_im / y_46_re
	elif y_46_re <= 1.25e+19:
		tmp = -x_46_re / y_46_im
	else:
		tmp = x_46_im / 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 <= -4.8e+60)
		tmp = Float64(x_46_im / y_46_re);
	elseif (y_46_re <= 1.25e+19)
		tmp = Float64(Float64(-x_46_re) / y_46_im);
	else
		tmp = Float64(x_46_im / y_46_re);
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0;
	if (y_46_re <= -4.8e+60)
		tmp = x_46_im / y_46_re;
	elseif (y_46_re <= 1.25e+19)
		tmp = -x_46_re / y_46_im;
	else
		tmp = x_46_im / y_46_re;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -4.8e+60], N[(x$46$im / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 1.25e+19], N[((-x$46$re) / y$46$im), $MachinePrecision], N[(x$46$im / y$46$re), $MachinePrecision]]]
\begin{array}{l}

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.re < -4.8e60 or 1.25e19 < y.re

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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.im}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f6442.0

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

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

    if -4.8e60 < y.re < 1.25e19

    1. Initial program 61.2%

      \[\frac{x.im \cdot y.re - x.re \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{-1 \cdot x.re + \frac{x.im \cdot y.re}{y.im}}{y.im}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

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

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

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

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

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

      \[\leadsto \frac{-1 \cdot x.re}{y.im} \]
    6. Step-by-step derivation
      1. lower-*.f6442.6

        \[\leadsto \frac{-1 \cdot x.re}{y.im} \]
    7. Applied rewrites42.6%

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

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

        \[\leadsto \frac{\mathsf{neg}\left(x.re\right)}{y.im} \]
      3. lower-neg.f6442.6

        \[\leadsto \frac{-x.re}{y.im} \]
    9. Applied rewrites42.6%

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

Alternative 13: 42.0% accurate, 4.9× speedup?

\[\begin{array}{l} \\ \frac{x.im}{y.re} \end{array} \]
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ x.im y.re))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return x_46_im / y_46_re;
}
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_46re
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return x_46_im / y_46_re;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	return x_46_im / y_46_re
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	return Float64(x_46_im / y_46_re)
end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = x_46_im / y_46_re;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(x$46$im / y$46$re), $MachinePrecision]
\begin{array}{l}

\\
\frac{x.im}{y.re}
\end{array}
Derivation
  1. Initial program 61.2%

    \[\frac{x.im \cdot y.re - x.re \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.im}{y.re}} \]
  3. Step-by-step derivation
    1. lower-/.f6442.0

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

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

Reproduce

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