_divideComplex, real part

Percentage Accurate: 61.7% → 80.9%
Time: 6.1s
Alternatives: 10
Speedup: 1.6×

Specification

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

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

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 61.7% accurate, 1.0× speedup?

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

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

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

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

Alternative 1: 80.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -6.6 \cdot 10^{-18}:\\ \;\;\;\;\frac{\frac{x.im}{y.re} \cdot y.im + x.re}{y.re}\\ \mathbf{elif}\;y.re \leq 1.35 \cdot 10^{-136}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\ \mathbf{elif}\;y.re \leq 3.8 \cdot 10^{+124}:\\ \;\;\;\;\frac{x.re \cdot y.re + x.im \cdot y.im}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (<= y.re -6.6e-18)
   (/ (+ (* (/ x.im y.re) y.im) x.re) y.re)
   (if (<= y.re 1.35e-136)
     (/ (fma (/ x.re y.im) y.re x.im) y.im)
     (if (<= y.re 3.8e+124)
       (/ (+ (* x.re y.re) (* x.im y.im)) (fma y.re y.re (* y.im y.im)))
       (/ (fma (/ x.im y.re) y.im x.re) y.re)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if (y_46_re <= -6.6e-18) {
		tmp = (((x_46_im / y_46_re) * y_46_im) + x_46_re) / y_46_re;
	} else if (y_46_re <= 1.35e-136) {
		tmp = fma((x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im;
	} else if (y_46_re <= 3.8e+124) {
		tmp = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / fma(y_46_re, y_46_re, (y_46_im * y_46_im));
	} else {
		tmp = fma((x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re;
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0
	if (y_46_re <= -6.6e-18)
		tmp = Float64(Float64(Float64(Float64(x_46_im / y_46_re) * y_46_im) + x_46_re) / y_46_re);
	elseif (y_46_re <= 1.35e-136)
		tmp = Float64(fma(Float64(x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im);
	elseif (y_46_re <= 3.8e+124)
		tmp = Float64(Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / fma(y_46_re, y_46_re, Float64(y_46_im * y_46_im)));
	else
		tmp = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re);
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -6.6e-18], N[(N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im), $MachinePrecision] + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 1.35e-136], N[(N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 3.8e+124], N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(y$46$re * y$46$re + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]]]]
\begin{array}{l}

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y.re < -6.6000000000000003e-18

    1. Initial program 43.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -6.6000000000000003e-18 < y.re < 1.3499999999999999e-136

      1. Initial program 68.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 1.3499999999999999e-136 < y.re < 3.7999999999999998e124

      1. Initial program 84.1%

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

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

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

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

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

      if 3.7999999999999998e124 < y.re

      1. Initial program 35.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 2: 65.0% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(y.re, x.re, y.im \cdot x.im\right)\\ \mathbf{if}\;y.re \leq -3.1 \cdot 10^{-22}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq 3.9 \cdot 10^{-252}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{elif}\;y.re \leq 1.1 \cdot 10^{-87}:\\ \;\;\;\;\frac{t\_0}{y.im \cdot y.im}\\ \mathbf{elif}\;y.re \leq 1.3 \cdot 10^{+122}:\\ \;\;\;\;\frac{t\_0}{y.re \cdot y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \end{array} \end{array} \]
    (FPCore (x.re x.im y.re y.im)
     :precision binary64
     (let* ((t_0 (fma y.re x.re (* y.im x.im))))
       (if (<= y.re -3.1e-22)
         (/ x.re y.re)
         (if (<= y.re 3.9e-252)
           (/ x.im y.im)
           (if (<= y.re 1.1e-87)
             (/ t_0 (* y.im y.im))
             (if (<= y.re 1.3e+122) (/ t_0 (* y.re y.re)) (/ x.re y.re)))))))
    double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
    	double t_0 = fma(y_46_re, x_46_re, (y_46_im * x_46_im));
    	double tmp;
    	if (y_46_re <= -3.1e-22) {
    		tmp = x_46_re / y_46_re;
    	} else if (y_46_re <= 3.9e-252) {
    		tmp = x_46_im / y_46_im;
    	} else if (y_46_re <= 1.1e-87) {
    		tmp = t_0 / (y_46_im * y_46_im);
    	} else if (y_46_re <= 1.3e+122) {
    		tmp = t_0 / (y_46_re * y_46_re);
    	} else {
    		tmp = x_46_re / y_46_re;
    	}
    	return tmp;
    }
    
    function code(x_46_re, x_46_im, y_46_re, y_46_im)
    	t_0 = fma(y_46_re, x_46_re, Float64(y_46_im * x_46_im))
    	tmp = 0.0
    	if (y_46_re <= -3.1e-22)
    		tmp = Float64(x_46_re / y_46_re);
    	elseif (y_46_re <= 3.9e-252)
    		tmp = Float64(x_46_im / y_46_im);
    	elseif (y_46_re <= 1.1e-87)
    		tmp = Float64(t_0 / Float64(y_46_im * y_46_im));
    	elseif (y_46_re <= 1.3e+122)
    		tmp = Float64(t_0 / Float64(y_46_re * y_46_re));
    	else
    		tmp = Float64(x_46_re / y_46_re);
    	end
    	return tmp
    end
    
    code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(y$46$re * x$46$re + N[(y$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -3.1e-22], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 3.9e-252], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 1.1e-87], N[(t$95$0 / N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 1.3e+122], N[(t$95$0 / N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \mathsf{fma}\left(y.re, x.re, y.im \cdot x.im\right)\\
    \mathbf{if}\;y.re \leq -3.1 \cdot 10^{-22}:\\
    \;\;\;\;\frac{x.re}{y.re}\\
    
    \mathbf{elif}\;y.re \leq 3.9 \cdot 10^{-252}:\\
    \;\;\;\;\frac{x.im}{y.im}\\
    
    \mathbf{elif}\;y.re \leq 1.1 \cdot 10^{-87}:\\
    \;\;\;\;\frac{t\_0}{y.im \cdot y.im}\\
    
    \mathbf{elif}\;y.re \leq 1.3 \cdot 10^{+122}:\\
    \;\;\;\;\frac{t\_0}{y.re \cdot y.re}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{x.re}{y.re}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 4 regimes
    2. if y.re < -3.10000000000000013e-22 or 1.30000000000000004e122 < y.re

      1. Initial program 40.6%

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

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

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

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

      if -3.10000000000000013e-22 < y.re < 3.8999999999999999e-252

      1. Initial program 62.0%

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

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

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

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

      if 3.8999999999999999e-252 < y.re < 1.09999999999999994e-87

      1. Initial program 88.6%

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

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

          \[\leadsto \frac{x.re \cdot y.re + x.im \cdot y.im}{\color{blue}{y.im \cdot y.im}} \]
        2. lower-*.f6477.3

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

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

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

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

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

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

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

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

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

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

      if 1.09999999999999994e-87 < y.re < 1.30000000000000004e122

      1. Initial program 84.0%

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

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

          \[\leadsto \frac{x.re \cdot y.re + x.im \cdot y.im}{\color{blue}{y.im \cdot y.im}} \]
        2. lower-*.f6429.4

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 3: 65.8% accurate, 0.7× speedup?

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

      1. Initial program 40.9%

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

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

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

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

      if -3.10000000000000013e-22 < y.re < 3.8999999999999999e-252

      1. Initial program 62.0%

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

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

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

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

      if 3.8999999999999999e-252 < y.re < 2.5e-53

      1. Initial program 87.6%

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

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

          \[\leadsto \frac{x.re \cdot y.re + x.im \cdot y.im}{\color{blue}{y.im \cdot y.im}} \]
        2. lower-*.f6470.8

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

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

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

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

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

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

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

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

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

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

      if 2.5e-53 < y.re < 1.35e132

      1. Initial program 82.4%

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

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

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

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

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

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

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

          \[\leadsto \frac{x.re}{{y.im}^{2} + \color{blue}{y.re \cdot y.re}} \cdot y.re \]
        7. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

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

          \[\leadsto \frac{x.re}{y.im \cdot y.im + 1 \cdot \color{blue}{{y.re}^{2}}} \cdot y.re \]
        15. *-lft-identityN/A

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

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

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

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

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

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

      Alternative 4: 80.9% accurate, 0.7× speedup?

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

        1. Initial program 43.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if -6.6000000000000003e-18 < y.re < 1.3499999999999999e-136

          1. Initial program 68.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

          if 1.3499999999999999e-136 < y.re < 3.7999999999999998e124

          1. Initial program 84.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if 3.7999999999999998e124 < y.re

          1. Initial program 35.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 5: 65.7% accurate, 0.8× speedup?

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

          1. Initial program 40.9%

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

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

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

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

          if -3.10000000000000013e-22 < y.re < 2.25e-128

          1. Initial program 69.0%

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

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

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

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

          if 2.25e-128 < y.re < 1.35e132

          1. Initial program 83.6%

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

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

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

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

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

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

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

              \[\leadsto \frac{x.re}{{y.im}^{2} + \color{blue}{y.re \cdot y.re}} \cdot y.re \]
            7. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

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

              \[\leadsto \frac{x.re}{y.im \cdot y.im + 1 \cdot \color{blue}{{y.re}^{2}}} \cdot y.re \]
            15. *-lft-identityN/A

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

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

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

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

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

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

          Alternative 6: 78.8% accurate, 0.9× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -6.6 \cdot 10^{-18} \lor \neg \left(y.re \leq 0.205\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\ \end{array} \end{array} \]
          (FPCore (x.re x.im y.re y.im)
           :precision binary64
           (if (or (<= y.re -6.6e-18) (not (<= y.re 0.205)))
             (/ (fma (/ x.im y.re) y.im x.re) y.re)
             (/ (fma (/ x.re y.im) y.re x.im) y.im)))
          double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
          	double tmp;
          	if ((y_46_re <= -6.6e-18) || !(y_46_re <= 0.205)) {
          		tmp = fma((x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re;
          	} else {
          		tmp = fma((x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im;
          	}
          	return tmp;
          }
          
          function code(x_46_re, x_46_im, y_46_re, y_46_im)
          	tmp = 0.0
          	if ((y_46_re <= -6.6e-18) || !(y_46_re <= 0.205))
          		tmp = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re);
          	else
          		tmp = Float64(fma(Float64(x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im);
          	end
          	return tmp
          end
          
          code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -6.6e-18], N[Not[LessEqual[y$46$re, 0.205]], $MachinePrecision]], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], N[(N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;y.re \leq -6.6 \cdot 10^{-18} \lor \neg \left(y.re \leq 0.205\right):\\
          \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if y.re < -6.6000000000000003e-18 or 0.204999999999999988 < y.re

            1. Initial program 50.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if -6.6000000000000003e-18 < y.re < 0.204999999999999988

            1. Initial program 72.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -6.6 \cdot 10^{-18} \lor \neg \left(y.re \leq 0.205\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\ \end{array} \]
          5. Add Preprocessing

          Alternative 7: 71.3% accurate, 0.9× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.im \leq -1 \cdot 10^{+135} \lor \neg \left(y.im \leq 2.65 \cdot 10^{-6}\right):\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\ \end{array} \end{array} \]
          (FPCore (x.re x.im y.re y.im)
           :precision binary64
           (if (or (<= y.im -1e+135) (not (<= y.im 2.65e-6)))
             (/ x.im y.im)
             (/ (fma (/ x.im y.re) y.im x.re) y.re)))
          double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
          	double tmp;
          	if ((y_46_im <= -1e+135) || !(y_46_im <= 2.65e-6)) {
          		tmp = x_46_im / y_46_im;
          	} else {
          		tmp = fma((x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re;
          	}
          	return tmp;
          }
          
          function code(x_46_re, x_46_im, y_46_re, y_46_im)
          	tmp = 0.0
          	if ((y_46_im <= -1e+135) || !(y_46_im <= 2.65e-6))
          		tmp = Float64(x_46_im / y_46_im);
          	else
          		tmp = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re);
          	end
          	return tmp
          end
          
          code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$im, -1e+135], N[Not[LessEqual[y$46$im, 2.65e-6]], $MachinePrecision]], N[(x$46$im / y$46$im), $MachinePrecision], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;y.im \leq -1 \cdot 10^{+135} \lor \neg \left(y.im \leq 2.65 \cdot 10^{-6}\right):\\
          \;\;\;\;\frac{x.im}{y.im}\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if y.im < -9.99999999999999962e134 or 2.65e-6 < y.im

            1. Initial program 45.0%

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

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

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

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

            if -9.99999999999999962e134 < y.im < 2.65e-6

            1. Initial program 69.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -1 \cdot 10^{+135} \lor \neg \left(y.im \leq 2.65 \cdot 10^{-6}\right):\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\ \end{array} \]
          5. Add Preprocessing

          Alternative 8: 78.8% accurate, 0.9× speedup?

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

            1. Initial program 43.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              if -6.6000000000000003e-18 < y.re < 0.204999999999999988

              1. Initial program 72.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

              if 0.204999999999999988 < y.re

              1. Initial program 55.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            Alternative 9: 62.6% accurate, 1.6× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.im \leq -3.6 \cdot 10^{+131} \lor \neg \left(y.im \leq 1.25 \cdot 10^{+36}\right):\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \end{array} \end{array} \]
            (FPCore (x.re x.im y.re y.im)
             :precision binary64
             (if (or (<= y.im -3.6e+131) (not (<= y.im 1.25e+36)))
               (/ x.im y.im)
               (/ x.re y.re)))
            double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
            	double tmp;
            	if ((y_46_im <= -3.6e+131) || !(y_46_im <= 1.25e+36)) {
            		tmp = x_46_im / y_46_im;
            	} else {
            		tmp = x_46_re / 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_46im <= (-3.6d+131)) .or. (.not. (y_46im <= 1.25d+36))) then
                    tmp = x_46im / y_46im
                else
                    tmp = x_46re / y_46re
                end if
                code = tmp
            end function
            
            public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
            	double tmp;
            	if ((y_46_im <= -3.6e+131) || !(y_46_im <= 1.25e+36)) {
            		tmp = x_46_im / y_46_im;
            	} else {
            		tmp = x_46_re / y_46_re;
            	}
            	return tmp;
            }
            
            def code(x_46_re, x_46_im, y_46_re, y_46_im):
            	tmp = 0
            	if (y_46_im <= -3.6e+131) or not (y_46_im <= 1.25e+36):
            		tmp = x_46_im / y_46_im
            	else:
            		tmp = x_46_re / y_46_re
            	return tmp
            
            function code(x_46_re, x_46_im, y_46_re, y_46_im)
            	tmp = 0.0
            	if ((y_46_im <= -3.6e+131) || !(y_46_im <= 1.25e+36))
            		tmp = Float64(x_46_im / y_46_im);
            	else
            		tmp = Float64(x_46_re / y_46_re);
            	end
            	return tmp
            end
            
            function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
            	tmp = 0.0;
            	if ((y_46_im <= -3.6e+131) || ~((y_46_im <= 1.25e+36)))
            		tmp = x_46_im / y_46_im;
            	else
            		tmp = x_46_re / y_46_re;
            	end
            	tmp_2 = tmp;
            end
            
            code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$im, -3.6e+131], N[Not[LessEqual[y$46$im, 1.25e+36]], $MachinePrecision]], N[(x$46$im / y$46$im), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;y.im \leq -3.6 \cdot 10^{+131} \lor \neg \left(y.im \leq 1.25 \cdot 10^{+36}\right):\\
            \;\;\;\;\frac{x.im}{y.im}\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{x.re}{y.re}\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if y.im < -3.60000000000000031e131 or 1.24999999999999994e36 < y.im

              1. Initial program 42.0%

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

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

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

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

              if -3.60000000000000031e131 < y.im < 1.24999999999999994e36

              1. Initial program 70.0%

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

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

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

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

              \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -3.6 \cdot 10^{+131} \lor \neg \left(y.im \leq 1.25 \cdot 10^{+36}\right):\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \end{array} \]
            5. Add Preprocessing

            Alternative 10: 42.8% accurate, 3.2× speedup?

            \[\begin{array}{l} \\ \frac{x.im}{y.im} \end{array} \]
            (FPCore (x.re x.im y.re y.im) :precision binary64 (/ x.im y.im))
            double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
            	return x_46_im / y_46_im;
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(8) function code(x_46re, x_46im, y_46re, y_46im)
            use fmin_fmax_functions
                real(8), intent (in) :: x_46re
                real(8), intent (in) :: x_46im
                real(8), intent (in) :: y_46re
                real(8), intent (in) :: y_46im
                code = x_46im / y_46im
            end function
            
            public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
            	return x_46_im / y_46_im;
            }
            
            def code(x_46_re, x_46_im, y_46_re, y_46_im):
            	return x_46_im / y_46_im
            
            function code(x_46_re, x_46_im, y_46_re, y_46_im)
            	return Float64(x_46_im / y_46_im)
            end
            
            function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im)
            	tmp = x_46_im / y_46_im;
            end
            
            code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(x$46$im / y$46$im), $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            \frac{x.im}{y.im}
            \end{array}
            
            Derivation
            1. Initial program 60.1%

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

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

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

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

            Reproduce

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