_divideComplex, imaginary part

Percentage Accurate: 61.5% → 83.2%
Time: 1.8s
Alternatives: 10
Speedup: 1.5×

Specification

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

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

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

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 61.5% accurate, 1.0× speedup?

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

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

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

Alternative 1: 83.2% accurate, 0.6× speedup?

\[\begin{array}{l} t_0 := \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ t_1 := \frac{\left(-x.re\right) - \left(-y.re\right) \cdot \frac{x.im}{y.im}}{y.im}\\ \mathbf{if}\;y.im \leq -1549999999999999942316721355256651167768960321267789649373183178612670464:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y.im \leq \frac{-8593944123082061}{226156424291633194186662080095093570025917938800079226639565593765455331328}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.im \leq \frac{3630826122770869}{1037378892220248239628101965922790287753111558060609224998914332422663202853227036599926762236775948572049471652825197295598787768852943826971718708528490921765295450850377380921344}:\\ \;\;\;\;\frac{x.im - \frac{x.re}{\frac{y.re}{y.im}}}{y.re}\\ \mathbf{elif}\;y.im \leq 339999999999999980010654200175664637847404227877287010028207688682110504545216375346111184896:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
(FPCore (x.re x.im y.re y.im)
  :precision binary64
  (let* ((t_0
        (/
         (- (* x.im y.re) (* x.re y.im))
         (+ (* y.re y.re) (* y.im y.im))))
       (t_1 (/ (- (- x.re) (* (- y.re) (/ x.im y.im))) y.im)))
  (if (<=
       y.im
       -1549999999999999942316721355256651167768960321267789649373183178612670464)
    t_1
    (if (<=
         y.im
         -8593944123082061/226156424291633194186662080095093570025917938800079226639565593765455331328)
      t_0
      (if (<=
           y.im
           3630826122770869/1037378892220248239628101965922790287753111558060609224998914332422663202853227036599926762236775948572049471652825197295598787768852943826971718708528490921765295450850377380921344)
        (/ (- x.im (/ x.re (/ y.re y.im))) y.re)
        (if (<=
             y.im
             339999999999999980010654200175664637847404227877287010028207688682110504545216375346111184896)
          t_0
          t_1))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	double t_1 = (-x_46_re - (-y_46_re * (x_46_im / y_46_im))) / y_46_im;
	double tmp;
	if (y_46_im <= -1.55e+72) {
		tmp = t_1;
	} else if (y_46_im <= -3.8e-59) {
		tmp = t_0;
	} else if (y_46_im <= 3.5e-165) {
		tmp = (x_46_im - (x_46_re / (y_46_re / y_46_im))) / y_46_re;
	} else if (y_46_im <= 3.4e+92) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = ((x_46im * y_46re) - (x_46re * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
    t_1 = (-x_46re - (-y_46re * (x_46im / y_46im))) / y_46im
    if (y_46im <= (-1.55d+72)) then
        tmp = t_1
    else if (y_46im <= (-3.8d-59)) then
        tmp = t_0
    else if (y_46im <= 3.5d-165) then
        tmp = (x_46im - (x_46re / (y_46re / y_46im))) / y_46re
    else if (y_46im <= 3.4d+92) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	double t_1 = (-x_46_re - (-y_46_re * (x_46_im / y_46_im))) / y_46_im;
	double tmp;
	if (y_46_im <= -1.55e+72) {
		tmp = t_1;
	} else if (y_46_im <= -3.8e-59) {
		tmp = t_0;
	} else if (y_46_im <= 3.5e-165) {
		tmp = (x_46_im - (x_46_re / (y_46_re / y_46_im))) / y_46_re;
	} else if (y_46_im <= 3.4e+92) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
	t_1 = (-x_46_re - (-y_46_re * (x_46_im / y_46_im))) / y_46_im
	tmp = 0
	if y_46_im <= -1.55e+72:
		tmp = t_1
	elif y_46_im <= -3.8e-59:
		tmp = t_0
	elif y_46_im <= 3.5e-165:
		tmp = (x_46_im - (x_46_re / (y_46_re / y_46_im))) / y_46_re
	elif y_46_im <= 3.4e+92:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)))
	t_1 = Float64(Float64(Float64(-x_46_re) - Float64(Float64(-y_46_re) * Float64(x_46_im / y_46_im))) / y_46_im)
	tmp = 0.0
	if (y_46_im <= -1.55e+72)
		tmp = t_1;
	elseif (y_46_im <= -3.8e-59)
		tmp = t_0;
	elseif (y_46_im <= 3.5e-165)
		tmp = Float64(Float64(x_46_im - Float64(x_46_re / Float64(y_46_re / y_46_im))) / y_46_re);
	elseif (y_46_im <= 3.4e+92)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	t_1 = (-x_46_re - (-y_46_re * (x_46_im / y_46_im))) / y_46_im;
	tmp = 0.0;
	if (y_46_im <= -1.55e+72)
		tmp = t_1;
	elseif (y_46_im <= -3.8e-59)
		tmp = t_0;
	elseif (y_46_im <= 3.5e-165)
		tmp = (x_46_im - (x_46_re / (y_46_re / y_46_im))) / y_46_re;
	elseif (y_46_im <= 3.4e+92)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[((-x$46$re) - N[((-y$46$re) * N[(x$46$im / y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -1549999999999999942316721355256651167768960321267789649373183178612670464], t$95$1, If[LessEqual[y$46$im, -8593944123082061/226156424291633194186662080095093570025917938800079226639565593765455331328], t$95$0, If[LessEqual[y$46$im, 3630826122770869/1037378892220248239628101965922790287753111558060609224998914332422663202853227036599926762236775948572049471652825197295598787768852943826971718708528490921765295450850377380921344], N[(N[(x$46$im - N[(x$46$re / N[(y$46$re / y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 339999999999999980010654200175664637847404227877287010028207688682110504545216375346111184896], t$95$0, t$95$1]]]]]]
\begin{array}{l}
t_0 := \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\
t_1 := \frac{\left(-x.re\right) - \left(-y.re\right) \cdot \frac{x.im}{y.im}}{y.im}\\
\mathbf{if}\;y.im \leq -1549999999999999942316721355256651167768960321267789649373183178612670464:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y.im \leq \frac{-8593944123082061}{226156424291633194186662080095093570025917938800079226639565593765455331328}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y.im \leq \frac{3630826122770869}{1037378892220248239628101965922790287753111558060609224998914332422663202853227036599926762236775948572049471652825197295598787768852943826971718708528490921765295450850377380921344}:\\
\;\;\;\;\frac{x.im - \frac{x.re}{\frac{y.re}{y.im}}}{y.re}\\

\mathbf{elif}\;y.im \leq 339999999999999980010654200175664637847404227877287010028207688682110504545216375346111184896:\\
\;\;\;\;t\_0\\

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


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.im < -1.5499999999999999e72 or 3.3999999999999998e92 < y.im

    1. Initial program 61.5%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f6443.0%

        \[\leadsto \frac{x.im}{\color{blue}{y.re}} \]
    4. Applied rewrites43.0%

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    5. Taylor expanded in y.im around inf

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-1 \cdot x.re + y.re \cdot \frac{x.im}{y.im}}{y.im} \]
      6. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

        \[\leadsto \frac{\left(-x.re\right) - \left(-y.re\right) \cdot \frac{x.im}{y.im}}{y.im} \]
      13. lower-/.f6453.6%

        \[\leadsto \frac{\left(-x.re\right) - \left(-y.re\right) \cdot \frac{x.im}{y.im}}{y.im} \]
    9. Applied rewrites53.6%

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

    if -1.5499999999999999e72 < y.im < -3.7999999999999998e-59 or 3.5000000000000002e-165 < y.im < 3.3999999999999998e92

    1. Initial program 61.5%

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

    if -3.7999999999999998e-59 < y.im < 3.5000000000000002e-165

    1. Initial program 61.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re} \]
      13. lift-*.f6452.8%

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re} \]
      5. lower-*.f6454.5%

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

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

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

        \[\leadsto \frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re} \]
      3. div-flip-revN/A

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

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

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

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

        \[\leadsto \frac{x.im - x.re \cdot \frac{1}{\frac{y.re}{y.im}}}{y.re} \]
      8. mult-flip-revN/A

        \[\leadsto \frac{x.im - \frac{x.re}{\frac{y.re}{y.im}}}{y.re} \]
      9. lower-/.f6454.5%

        \[\leadsto \frac{x.im - \frac{x.re}{\frac{y.re}{y.im}}}{y.re} \]
    10. Applied rewrites54.5%

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

Alternative 2: 78.6% accurate, 0.7× speedup?

\[\begin{array}{l} t_0 := \frac{\left(-x.re\right) - \left(-y.re\right) \cdot \frac{x.im}{y.im}}{y.im}\\ \mathbf{if}\;y.im \leq -2100000000000000136991060992552505181349115988754604270400850104669962240:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.im \leq \frac{-498150793720287}{3213876088517980551083924184682325205044405987565585670602752}:\\ \;\;\;\;\frac{-1 \cdot \left(x.re \cdot y.im\right)}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 7999999999999999517673330972825428688896:\\ \;\;\;\;\frac{x.im - \frac{x.re}{\frac{y.re}{y.im}}}{y.re}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (x.re x.im y.re y.im)
  :precision binary64
  (let* ((t_0 (/ (- (- x.re) (* (- y.re) (/ x.im y.im))) y.im)))
  (if (<=
       y.im
       -2100000000000000136991060992552505181349115988754604270400850104669962240)
    t_0
    (if (<=
         y.im
         -498150793720287/3213876088517980551083924184682325205044405987565585670602752)
      (/ (* -1 (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im)))
      (if (<= y.im 7999999999999999517673330972825428688896)
        (/ (- x.im (/ x.re (/ y.re y.im))) y.re)
        t_0)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = (-x_46_re - (-y_46_re * (x_46_im / y_46_im))) / y_46_im;
	double tmp;
	if (y_46_im <= -2.1e+72) {
		tmp = t_0;
	} else if (y_46_im <= -1.55e-46) {
		tmp = (-1.0 * (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	} else if (y_46_im <= 8e+39) {
		tmp = (x_46_im - (x_46_re / (y_46_re / y_46_im))) / y_46_re;
	} else {
		tmp = t_0;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (-x_46re - (-y_46re * (x_46im / y_46im))) / y_46im
    if (y_46im <= (-2.1d+72)) then
        tmp = t_0
    else if (y_46im <= (-1.55d-46)) then
        tmp = ((-1.0d0) * (x_46re * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
    else if (y_46im <= 8d+39) then
        tmp = (x_46im - (x_46re / (y_46re / y_46im))) / y_46re
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = (-x_46_re - (-y_46_re * (x_46_im / y_46_im))) / y_46_im;
	double tmp;
	if (y_46_im <= -2.1e+72) {
		tmp = t_0;
	} else if (y_46_im <= -1.55e-46) {
		tmp = (-1.0 * (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	} else if (y_46_im <= 8e+39) {
		tmp = (x_46_im - (x_46_re / (y_46_re / y_46_im))) / y_46_re;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = (-x_46_re - (-y_46_re * (x_46_im / y_46_im))) / y_46_im
	tmp = 0
	if y_46_im <= -2.1e+72:
		tmp = t_0
	elif y_46_im <= -1.55e-46:
		tmp = (-1.0 * (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
	elif y_46_im <= 8e+39:
		tmp = (x_46_im - (x_46_re / (y_46_re / y_46_im))) / y_46_re
	else:
		tmp = t_0
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(Float64(-x_46_re) - Float64(Float64(-y_46_re) * Float64(x_46_im / y_46_im))) / y_46_im)
	tmp = 0.0
	if (y_46_im <= -2.1e+72)
		tmp = t_0;
	elseif (y_46_im <= -1.55e-46)
		tmp = Float64(Float64(-1.0 * Float64(x_46_re * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)));
	elseif (y_46_im <= 8e+39)
		tmp = Float64(Float64(x_46_im - Float64(x_46_re / Float64(y_46_re / y_46_im))) / y_46_re);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = (-x_46_re - (-y_46_re * (x_46_im / y_46_im))) / y_46_im;
	tmp = 0.0;
	if (y_46_im <= -2.1e+72)
		tmp = t_0;
	elseif (y_46_im <= -1.55e-46)
		tmp = (-1.0 * (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	elseif (y_46_im <= 8e+39)
		tmp = (x_46_im - (x_46_re / (y_46_re / y_46_im))) / y_46_re;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[((-x$46$re) - N[((-y$46$re) * N[(x$46$im / y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -2100000000000000136991060992552505181349115988754604270400850104669962240], t$95$0, If[LessEqual[y$46$im, -498150793720287/3213876088517980551083924184682325205044405987565585670602752], N[(N[(-1 * N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 7999999999999999517673330972825428688896], N[(N[(x$46$im - N[(x$46$re / N[(y$46$re / y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
t_0 := \frac{\left(-x.re\right) - \left(-y.re\right) \cdot \frac{x.im}{y.im}}{y.im}\\
\mathbf{if}\;y.im \leq -2100000000000000136991060992552505181349115988754604270400850104669962240:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y.im \leq \frac{-498150793720287}{3213876088517980551083924184682325205044405987565585670602752}:\\
\;\;\;\;\frac{-1 \cdot \left(x.re \cdot y.im\right)}{y.re \cdot y.re + y.im \cdot y.im}\\

\mathbf{elif}\;y.im \leq 7999999999999999517673330972825428688896:\\
\;\;\;\;\frac{x.im - \frac{x.re}{\frac{y.re}{y.im}}}{y.re}\\

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


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.im < -2.1000000000000001e72 or 7.9999999999999995e39 < y.im

    1. Initial program 61.5%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f6443.0%

        \[\leadsto \frac{x.im}{\color{blue}{y.re}} \]
    4. Applied rewrites43.0%

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    5. Taylor expanded in y.im around inf

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-1 \cdot x.re + y.re \cdot \frac{x.im}{y.im}}{y.im} \]
      6. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

        \[\leadsto \frac{\left(-x.re\right) - \left(-y.re\right) \cdot \frac{x.im}{y.im}}{y.im} \]
      13. lower-/.f6453.6%

        \[\leadsto \frac{\left(-x.re\right) - \left(-y.re\right) \cdot \frac{x.im}{y.im}}{y.im} \]
    9. Applied rewrites53.6%

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

    if -2.1000000000000001e72 < y.im < -1.55e-46

    1. Initial program 61.5%

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

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

        \[\leadsto \frac{-1 \cdot \color{blue}{\left(x.re \cdot y.im\right)}}{y.re \cdot y.re + y.im \cdot y.im} \]
      2. lower-*.f6439.6%

        \[\leadsto \frac{-1 \cdot \left(x.re \cdot \color{blue}{y.im}\right)}{y.re \cdot y.re + y.im \cdot y.im} \]
    4. Applied rewrites39.6%

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

    if -1.55e-46 < y.im < 7.9999999999999995e39

    1. Initial program 61.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re} \]
      13. lift-*.f6452.8%

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re} \]
      5. lower-*.f6454.5%

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

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

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

        \[\leadsto \frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re} \]
      3. div-flip-revN/A

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

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

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

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

        \[\leadsto \frac{x.im - x.re \cdot \frac{1}{\frac{y.re}{y.im}}}{y.re} \]
      8. mult-flip-revN/A

        \[\leadsto \frac{x.im - \frac{x.re}{\frac{y.re}{y.im}}}{y.re} \]
      9. lower-/.f6454.5%

        \[\leadsto \frac{x.im - \frac{x.re}{\frac{y.re}{y.im}}}{y.re} \]
    10. Applied rewrites54.5%

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

Alternative 3: 78.5% accurate, 0.7× speedup?

\[\begin{array}{l} t_0 := \frac{\left(-x.re\right) - \left(-y.re\right) \cdot \frac{x.im}{y.im}}{y.im}\\ \mathbf{if}\;y.im \leq -2100000000000000136991060992552505181349115988754604270400850104669962240:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.im \leq \frac{-498150793720287}{3213876088517980551083924184682325205044405987565585670602752}:\\ \;\;\;\;\frac{-1 \cdot \left(x.re \cdot y.im\right)}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 7999999999999999517673330972825428688896:\\ \;\;\;\;\frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (x.re x.im y.re y.im)
  :precision binary64
  (let* ((t_0 (/ (- (- x.re) (* (- y.re) (/ x.im y.im))) y.im)))
  (if (<=
       y.im
       -2100000000000000136991060992552505181349115988754604270400850104669962240)
    t_0
    (if (<=
         y.im
         -498150793720287/3213876088517980551083924184682325205044405987565585670602752)
      (/ (* -1 (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im)))
      (if (<= y.im 7999999999999999517673330972825428688896)
        (/ (- x.im (* (/ y.im y.re) x.re)) y.re)
        t_0)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = (-x_46_re - (-y_46_re * (x_46_im / y_46_im))) / y_46_im;
	double tmp;
	if (y_46_im <= -2.1e+72) {
		tmp = t_0;
	} else if (y_46_im <= -1.55e-46) {
		tmp = (-1.0 * (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	} else if (y_46_im <= 8e+39) {
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re;
	} else {
		tmp = t_0;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (-x_46re - (-y_46re * (x_46im / y_46im))) / y_46im
    if (y_46im <= (-2.1d+72)) then
        tmp = t_0
    else if (y_46im <= (-1.55d-46)) then
        tmp = ((-1.0d0) * (x_46re * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
    else if (y_46im <= 8d+39) then
        tmp = (x_46im - ((y_46im / y_46re) * x_46re)) / y_46re
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = (-x_46_re - (-y_46_re * (x_46_im / y_46_im))) / y_46_im;
	double tmp;
	if (y_46_im <= -2.1e+72) {
		tmp = t_0;
	} else if (y_46_im <= -1.55e-46) {
		tmp = (-1.0 * (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	} else if (y_46_im <= 8e+39) {
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = (-x_46_re - (-y_46_re * (x_46_im / y_46_im))) / y_46_im
	tmp = 0
	if y_46_im <= -2.1e+72:
		tmp = t_0
	elif y_46_im <= -1.55e-46:
		tmp = (-1.0 * (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
	elif y_46_im <= 8e+39:
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re
	else:
		tmp = t_0
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(Float64(-x_46_re) - Float64(Float64(-y_46_re) * Float64(x_46_im / y_46_im))) / y_46_im)
	tmp = 0.0
	if (y_46_im <= -2.1e+72)
		tmp = t_0;
	elseif (y_46_im <= -1.55e-46)
		tmp = Float64(Float64(-1.0 * Float64(x_46_re * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)));
	elseif (y_46_im <= 8e+39)
		tmp = Float64(Float64(x_46_im - Float64(Float64(y_46_im / y_46_re) * x_46_re)) / y_46_re);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = (-x_46_re - (-y_46_re * (x_46_im / y_46_im))) / y_46_im;
	tmp = 0.0;
	if (y_46_im <= -2.1e+72)
		tmp = t_0;
	elseif (y_46_im <= -1.55e-46)
		tmp = (-1.0 * (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	elseif (y_46_im <= 8e+39)
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[((-x$46$re) - N[((-y$46$re) * N[(x$46$im / y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -2100000000000000136991060992552505181349115988754604270400850104669962240], t$95$0, If[LessEqual[y$46$im, -498150793720287/3213876088517980551083924184682325205044405987565585670602752], N[(N[(-1 * N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 7999999999999999517673330972825428688896], N[(N[(x$46$im - N[(N[(y$46$im / y$46$re), $MachinePrecision] * x$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
t_0 := \frac{\left(-x.re\right) - \left(-y.re\right) \cdot \frac{x.im}{y.im}}{y.im}\\
\mathbf{if}\;y.im \leq -2100000000000000136991060992552505181349115988754604270400850104669962240:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y.im \leq \frac{-498150793720287}{3213876088517980551083924184682325205044405987565585670602752}:\\
\;\;\;\;\frac{-1 \cdot \left(x.re \cdot y.im\right)}{y.re \cdot y.re + y.im \cdot y.im}\\

\mathbf{elif}\;y.im \leq 7999999999999999517673330972825428688896:\\
\;\;\;\;\frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re}\\

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


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.im < -2.1000000000000001e72 or 7.9999999999999995e39 < y.im

    1. Initial program 61.5%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f6443.0%

        \[\leadsto \frac{x.im}{\color{blue}{y.re}} \]
    4. Applied rewrites43.0%

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    5. Taylor expanded in y.im around inf

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-1 \cdot x.re + y.re \cdot \frac{x.im}{y.im}}{y.im} \]
      6. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

        \[\leadsto \frac{\left(-x.re\right) - \left(-y.re\right) \cdot \frac{x.im}{y.im}}{y.im} \]
      13. lower-/.f6453.6%

        \[\leadsto \frac{\left(-x.re\right) - \left(-y.re\right) \cdot \frac{x.im}{y.im}}{y.im} \]
    9. Applied rewrites53.6%

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

    if -2.1000000000000001e72 < y.im < -1.55e-46

    1. Initial program 61.5%

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

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

        \[\leadsto \frac{-1 \cdot \color{blue}{\left(x.re \cdot y.im\right)}}{y.re \cdot y.re + y.im \cdot y.im} \]
      2. lower-*.f6439.6%

        \[\leadsto \frac{-1 \cdot \left(x.re \cdot \color{blue}{y.im}\right)}{y.re \cdot y.re + y.im \cdot y.im} \]
    4. Applied rewrites39.6%

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

    if -1.55e-46 < y.im < 7.9999999999999995e39

    1. Initial program 61.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re} \]
      13. lift-*.f6452.8%

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re} \]
      5. lower-*.f6454.5%

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

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

Alternative 4: 78.5% accurate, 0.8× speedup?

\[\begin{array}{l} t_0 := \frac{\left(-x.re\right) - \left(-y.re\right) \cdot \frac{x.im}{y.im}}{y.im}\\ \mathbf{if}\;y.im \leq -195000000000000005714904619635812128629974360554371271422985808308600832:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.im \leq 7999999999999999517673330972825428688896:\\ \;\;\;\;\frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (x.re x.im y.re y.im)
  :precision binary64
  (let* ((t_0 (/ (- (- x.re) (* (- y.re) (/ x.im y.im))) y.im)))
  (if (<=
       y.im
       -195000000000000005714904619635812128629974360554371271422985808308600832)
    t_0
    (if (<= y.im 7999999999999999517673330972825428688896)
      (/ (- x.im (* (/ y.im y.re) x.re)) y.re)
      t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = (-x_46_re - (-y_46_re * (x_46_im / y_46_im))) / y_46_im;
	double tmp;
	if (y_46_im <= -1.95e+71) {
		tmp = t_0;
	} else if (y_46_im <= 8e+39) {
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re;
	} else {
		tmp = t_0;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (-x_46re - (-y_46re * (x_46im / y_46im))) / y_46im
    if (y_46im <= (-1.95d+71)) then
        tmp = t_0
    else if (y_46im <= 8d+39) then
        tmp = (x_46im - ((y_46im / y_46re) * x_46re)) / y_46re
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = (-x_46_re - (-y_46_re * (x_46_im / y_46_im))) / y_46_im;
	double tmp;
	if (y_46_im <= -1.95e+71) {
		tmp = t_0;
	} else if (y_46_im <= 8e+39) {
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = (-x_46_re - (-y_46_re * (x_46_im / y_46_im))) / y_46_im
	tmp = 0
	if y_46_im <= -1.95e+71:
		tmp = t_0
	elif y_46_im <= 8e+39:
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re
	else:
		tmp = t_0
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(Float64(-x_46_re) - Float64(Float64(-y_46_re) * Float64(x_46_im / y_46_im))) / y_46_im)
	tmp = 0.0
	if (y_46_im <= -1.95e+71)
		tmp = t_0;
	elseif (y_46_im <= 8e+39)
		tmp = Float64(Float64(x_46_im - Float64(Float64(y_46_im / y_46_re) * x_46_re)) / y_46_re);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = (-x_46_re - (-y_46_re * (x_46_im / y_46_im))) / y_46_im;
	tmp = 0.0;
	if (y_46_im <= -1.95e+71)
		tmp = t_0;
	elseif (y_46_im <= 8e+39)
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[((-x$46$re) - N[((-y$46$re) * N[(x$46$im / y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -195000000000000005714904619635812128629974360554371271422985808308600832], t$95$0, If[LessEqual[y$46$im, 7999999999999999517673330972825428688896], N[(N[(x$46$im - N[(N[(y$46$im / y$46$re), $MachinePrecision] * x$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{\left(-x.re\right) - \left(-y.re\right) \cdot \frac{x.im}{y.im}}{y.im}\\
\mathbf{if}\;y.im \leq -195000000000000005714904619635812128629974360554371271422985808308600832:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y.im \leq 7999999999999999517673330972825428688896:\\
\;\;\;\;\frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < -1.9500000000000001e71 or 7.9999999999999995e39 < y.im

    1. Initial program 61.5%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f6443.0%

        \[\leadsto \frac{x.im}{\color{blue}{y.re}} \]
    4. Applied rewrites43.0%

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    5. Taylor expanded in y.im around inf

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-1 \cdot x.re + y.re \cdot \frac{x.im}{y.im}}{y.im} \]
      6. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

        \[\leadsto \frac{\left(-x.re\right) - \left(-y.re\right) \cdot \frac{x.im}{y.im}}{y.im} \]
      13. lower-/.f6453.6%

        \[\leadsto \frac{\left(-x.re\right) - \left(-y.re\right) \cdot \frac{x.im}{y.im}}{y.im} \]
    9. Applied rewrites53.6%

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

    if -1.9500000000000001e71 < y.im < 7.9999999999999995e39

    1. Initial program 61.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re} \]
      13. lift-*.f6452.8%

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re} \]
      5. lower-*.f6454.5%

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

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

Alternative 5: 78.5% accurate, 0.9× speedup?

\[\begin{array}{l} t_0 := \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re}\\ \mathbf{if}\;y.re \leq \frac{-6941760285187145}{2722258935367507707706996859454145691648}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.re \leq 1900000000000000011885089336066048:\\ \;\;\;\;\frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (x.re x.im y.re y.im)
  :precision binary64
  (let* ((t_0 (/ (- x.im (* (/ x.re y.re) y.im)) y.re)))
  (if (<=
       y.re
       -6941760285187145/2722258935367507707706996859454145691648)
    t_0
    (if (<= y.re 1900000000000000011885089336066048)
      (/ (- (/ (* y.re x.im) y.im) x.re) y.im)
      t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = (x_46_im - ((x_46_re / y_46_re) * y_46_im)) / y_46_re;
	double tmp;
	if (y_46_re <= -2.55e-24) {
		tmp = t_0;
	} else if (y_46_re <= 1.9e+33) {
		tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im;
	} else {
		tmp = t_0;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x_46im - ((x_46re / y_46re) * y_46im)) / y_46re
    if (y_46re <= (-2.55d-24)) then
        tmp = t_0
    else if (y_46re <= 1.9d+33) then
        tmp = (((y_46re * x_46im) / y_46im) - x_46re) / y_46im
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = (x_46_im - ((x_46_re / y_46_re) * y_46_im)) / y_46_re;
	double tmp;
	if (y_46_re <= -2.55e-24) {
		tmp = t_0;
	} else if (y_46_re <= 1.9e+33) {
		tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = (x_46_im - ((x_46_re / y_46_re) * y_46_im)) / y_46_re
	tmp = 0
	if y_46_re <= -2.55e-24:
		tmp = t_0
	elif y_46_re <= 1.9e+33:
		tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im
	else:
		tmp = t_0
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(x_46_im - Float64(Float64(x_46_re / y_46_re) * y_46_im)) / y_46_re)
	tmp = 0.0
	if (y_46_re <= -2.55e-24)
		tmp = t_0;
	elseif (y_46_re <= 1.9e+33)
		tmp = Float64(Float64(Float64(Float64(y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = (x_46_im - ((x_46_re / y_46_re) * y_46_im)) / y_46_re;
	tmp = 0.0;
	if (y_46_re <= -2.55e-24)
		tmp = t_0;
	elseif (y_46_re <= 1.9e+33)
		tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(x$46$im - N[(N[(x$46$re / y$46$re), $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -6941760285187145/2722258935367507707706996859454145691648], t$95$0, If[LessEqual[y$46$re, 1900000000000000011885089336066048], N[(N[(N[(N[(y$46$re * x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re}\\
\mathbf{if}\;y.re \leq \frac{-6941760285187145}{2722258935367507707706996859454145691648}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y.re \leq 1900000000000000011885089336066048:\\
\;\;\;\;\frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.re < -2.5500000000000001e-24 or 1.9e33 < y.re

    1. Initial program 61.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re} \]
      13. lift-*.f6452.8%

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

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
      6. lower-*.f6454.0%

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

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

    if -2.5500000000000001e-24 < y.re < 1.9e33

    1. Initial program 61.5%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f6443.0%

        \[\leadsto \frac{x.im}{\color{blue}{y.re}} \]
    4. Applied rewrites43.0%

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    5. Taylor expanded in y.im around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 73.7% accurate, 0.9× speedup?

\[\begin{array}{l} t_0 := \frac{-x.re}{y.im}\\ \mathbf{if}\;y.im \leq -195000000000000005714904619635812128629974360554371271422985808308600832:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.im \leq 39999999999999998543585179860992:\\ \;\;\;\;\frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (x.re x.im y.re y.im)
  :precision binary64
  (let* ((t_0 (/ (- x.re) y.im)))
  (if (<=
       y.im
       -195000000000000005714904619635812128629974360554371271422985808308600832)
    t_0
    (if (<= y.im 39999999999999998543585179860992)
      (/ (- x.im (* (/ y.im y.re) x.re)) y.re)
      t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = -x_46_re / y_46_im;
	double tmp;
	if (y_46_im <= -1.95e+71) {
		tmp = t_0;
	} else if (y_46_im <= 4e+31) {
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re;
	} else {
		tmp = t_0;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = -x_46re / y_46im
    if (y_46im <= (-1.95d+71)) then
        tmp = t_0
    else if (y_46im <= 4d+31) then
        tmp = (x_46im - ((y_46im / y_46re) * x_46re)) / y_46re
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = -x_46_re / y_46_im;
	double tmp;
	if (y_46_im <= -1.95e+71) {
		tmp = t_0;
	} else if (y_46_im <= 4e+31) {
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = -x_46_re / y_46_im
	tmp = 0
	if y_46_im <= -1.95e+71:
		tmp = t_0
	elif y_46_im <= 4e+31:
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re
	else:
		tmp = t_0
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(-x_46_re) / y_46_im)
	tmp = 0.0
	if (y_46_im <= -1.95e+71)
		tmp = t_0;
	elseif (y_46_im <= 4e+31)
		tmp = Float64(Float64(x_46_im - Float64(Float64(y_46_im / y_46_re) * x_46_re)) / y_46_re);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = -x_46_re / y_46_im;
	tmp = 0.0;
	if (y_46_im <= -1.95e+71)
		tmp = t_0;
	elseif (y_46_im <= 4e+31)
		tmp = (x_46_im - ((y_46_im / y_46_re) * x_46_re)) / y_46_re;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[((-x$46$re) / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -195000000000000005714904619635812128629974360554371271422985808308600832], t$95$0, If[LessEqual[y$46$im, 39999999999999998543585179860992], N[(N[(x$46$im - N[(N[(y$46$im / y$46$re), $MachinePrecision] * x$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{-x.re}{y.im}\\
\mathbf{if}\;y.im \leq -195000000000000005714904619635812128629974360554371271422985808308600832:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y.im \leq 39999999999999998543585179860992:\\
\;\;\;\;\frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < -1.9500000000000001e71 or 3.9999999999999999e31 < y.im

    1. Initial program 61.5%

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

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

        \[\leadsto -1 \cdot \color{blue}{\frac{x.re}{y.im}} \]
      2. lower-/.f6442.7%

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

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

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

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

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

        \[\leadsto \frac{-1 \cdot x.re}{y.im} \]
      5. lower-/.f6442.7%

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

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

        \[\leadsto \frac{\mathsf{neg}\left(x.re\right)}{y.im} \]
      8. lift-neg.f6442.7%

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

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

    if -1.9500000000000001e71 < y.im < 3.9999999999999999e31

    1. Initial program 61.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re} \]
      13. lift-*.f6452.8%

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{y.im}{y.re} \cdot x.re}{y.re} \]
      5. lower-*.f6454.5%

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

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

Alternative 7: 73.1% accurate, 0.9× speedup?

\[\begin{array}{l} t_0 := \frac{-x.re}{y.im}\\ \mathbf{if}\;y.im \leq -195000000000000005714904619635812128629974360554371271422985808308600832:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.im \leq 39999999999999998543585179860992:\\ \;\;\;\;\frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (x.re x.im y.re y.im)
  :precision binary64
  (let* ((t_0 (/ (- x.re) y.im)))
  (if (<=
       y.im
       -195000000000000005714904619635812128629974360554371271422985808308600832)
    t_0
    (if (<= y.im 39999999999999998543585179860992)
      (/ (- x.im (* (/ x.re y.re) y.im)) y.re)
      t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = -x_46_re / y_46_im;
	double tmp;
	if (y_46_im <= -1.95e+71) {
		tmp = t_0;
	} else if (y_46_im <= 4e+31) {
		tmp = (x_46_im - ((x_46_re / y_46_re) * y_46_im)) / y_46_re;
	} else {
		tmp = t_0;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = -x_46re / y_46im
    if (y_46im <= (-1.95d+71)) then
        tmp = t_0
    else if (y_46im <= 4d+31) then
        tmp = (x_46im - ((x_46re / y_46re) * y_46im)) / y_46re
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = -x_46_re / y_46_im;
	double tmp;
	if (y_46_im <= -1.95e+71) {
		tmp = t_0;
	} else if (y_46_im <= 4e+31) {
		tmp = (x_46_im - ((x_46_re / y_46_re) * y_46_im)) / y_46_re;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = -x_46_re / y_46_im
	tmp = 0
	if y_46_im <= -1.95e+71:
		tmp = t_0
	elif y_46_im <= 4e+31:
		tmp = (x_46_im - ((x_46_re / y_46_re) * y_46_im)) / y_46_re
	else:
		tmp = t_0
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(-x_46_re) / y_46_im)
	tmp = 0.0
	if (y_46_im <= -1.95e+71)
		tmp = t_0;
	elseif (y_46_im <= 4e+31)
		tmp = Float64(Float64(x_46_im - Float64(Float64(x_46_re / y_46_re) * y_46_im)) / y_46_re);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = -x_46_re / y_46_im;
	tmp = 0.0;
	if (y_46_im <= -1.95e+71)
		tmp = t_0;
	elseif (y_46_im <= 4e+31)
		tmp = (x_46_im - ((x_46_re / y_46_re) * y_46_im)) / y_46_re;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[((-x$46$re) / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -195000000000000005714904619635812128629974360554371271422985808308600832], t$95$0, If[LessEqual[y$46$im, 39999999999999998543585179860992], N[(N[(x$46$im - N[(N[(x$46$re / y$46$re), $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{-x.re}{y.im}\\
\mathbf{if}\;y.im \leq -195000000000000005714904619635812128629974360554371271422985808308600832:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y.im \leq 39999999999999998543585179860992:\\
\;\;\;\;\frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < -1.9500000000000001e71 or 3.9999999999999999e31 < y.im

    1. Initial program 61.5%

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

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

        \[\leadsto -1 \cdot \color{blue}{\frac{x.re}{y.im}} \]
      2. lower-/.f6442.7%

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

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

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

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

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

        \[\leadsto \frac{-1 \cdot x.re}{y.im} \]
      5. lower-/.f6442.7%

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

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

        \[\leadsto \frac{\mathsf{neg}\left(x.re\right)}{y.im} \]
      8. lift-neg.f6442.7%

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

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

    if -1.9500000000000001e71 < y.im < 3.9999999999999999e31

    1. Initial program 61.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{y.im \cdot x.re}{y.re}}{y.re} \]
      13. lift-*.f6452.8%

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

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

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

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

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

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

        \[\leadsto \frac{x.im - \frac{x.re}{y.re} \cdot y.im}{y.re} \]
      6. lower-*.f6454.0%

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

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

Alternative 8: 64.1% accurate, 1.5× speedup?

\[\begin{array}{l} t_0 := \frac{-x.re}{y.im}\\ \mathbf{if}\;y.im \leq \frac{-1156995391866473}{6427752177035961102167848369364650410088811975131171341205504}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.im \leq 39999999999999998543585179860992:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (x.re x.im y.re y.im)
  :precision binary64
  (let* ((t_0 (/ (- x.re) y.im)))
  (if (<=
       y.im
       -1156995391866473/6427752177035961102167848369364650410088811975131171341205504)
    t_0
    (if (<= y.im 39999999999999998543585179860992)
      (/ x.im y.re)
      t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = -x_46_re / y_46_im;
	double tmp;
	if (y_46_im <= -1.8e-46) {
		tmp = t_0;
	} else if (y_46_im <= 4e+31) {
		tmp = x_46_im / y_46_re;
	} else {
		tmp = t_0;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = -x_46re / y_46im
    if (y_46im <= (-1.8d-46)) then
        tmp = t_0
    else if (y_46im <= 4d+31) then
        tmp = x_46im / y_46re
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = -x_46_re / y_46_im;
	double tmp;
	if (y_46_im <= -1.8e-46) {
		tmp = t_0;
	} else if (y_46_im <= 4e+31) {
		tmp = x_46_im / y_46_re;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = -x_46_re / y_46_im
	tmp = 0
	if y_46_im <= -1.8e-46:
		tmp = t_0
	elif y_46_im <= 4e+31:
		tmp = x_46_im / y_46_re
	else:
		tmp = t_0
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(Float64(-x_46_re) / y_46_im)
	tmp = 0.0
	if (y_46_im <= -1.8e-46)
		tmp = t_0;
	elseif (y_46_im <= 4e+31)
		tmp = Float64(x_46_im / y_46_re);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = -x_46_re / y_46_im;
	tmp = 0.0;
	if (y_46_im <= -1.8e-46)
		tmp = t_0;
	elseif (y_46_im <= 4e+31)
		tmp = x_46_im / y_46_re;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[((-x$46$re) / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -1156995391866473/6427752177035961102167848369364650410088811975131171341205504], t$95$0, If[LessEqual[y$46$im, 39999999999999998543585179860992], N[(x$46$im / y$46$re), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{-x.re}{y.im}\\
\mathbf{if}\;y.im \leq \frac{-1156995391866473}{6427752177035961102167848369364650410088811975131171341205504}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y.im \leq 39999999999999998543585179860992:\\
\;\;\;\;\frac{x.im}{y.re}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < -1.8e-46 or 3.9999999999999999e31 < y.im

    1. Initial program 61.5%

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

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

        \[\leadsto -1 \cdot \color{blue}{\frac{x.re}{y.im}} \]
      2. lower-/.f6442.7%

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

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

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

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

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

        \[\leadsto \frac{-1 \cdot x.re}{y.im} \]
      5. lower-/.f6442.7%

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

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

        \[\leadsto \frac{\mathsf{neg}\left(x.re\right)}{y.im} \]
      8. lift-neg.f6442.7%

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

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

    if -1.8e-46 < y.im < 3.9999999999999999e31

    1. Initial program 61.5%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f6443.0%

        \[\leadsto \frac{x.im}{\color{blue}{y.re}} \]
    4. Applied rewrites43.0%

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

Alternative 9: 44.9% accurate, 2.1× speedup?

\[\begin{array}{l} \mathbf{if}\;y.im \leq 800000000000000011524758069796219084664894897942650104109698519483991416553009053014906061005811648644043497466369868300288:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{y.re}\\ \end{array} \]
(FPCore (x.re x.im y.re y.im)
  :precision binary64
  (if (<=
     y.im
     800000000000000011524758069796219084664894897942650104109698519483991416553009053014906061005811648644043497466369868300288)
  (/ x.im y.re)
  (/ 0 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 <= 8e+122) {
		tmp = x_46_im / y_46_re;
	} else {
		tmp = 0.0 / 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 <= 8d+122) then
        tmp = x_46im / y_46re
    else
        tmp = 0.0d0 / 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 <= 8e+122) {
		tmp = x_46_im / y_46_re;
	} else {
		tmp = 0.0 / 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 <= 8e+122:
		tmp = x_46_im / y_46_re
	else:
		tmp = 0.0 / 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 <= 8e+122)
		tmp = Float64(x_46_im / y_46_re);
	else
		tmp = Float64(0.0 / 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 <= 8e+122)
		tmp = x_46_im / y_46_re;
	else
		tmp = 0.0 / y_46_re;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$im, 800000000000000011524758069796219084664894897942650104109698519483991416553009053014906061005811648644043497466369868300288], N[(x$46$im / y$46$re), $MachinePrecision], N[(0 / y$46$re), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;y.im \leq 800000000000000011524758069796219084664894897942650104109698519483991416553009053014906061005811648644043497466369868300288:\\
\;\;\;\;\frac{x.im}{y.re}\\

\mathbf{else}:\\
\;\;\;\;\frac{0}{y.re}\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.im < 8.0000000000000001e122

    1. Initial program 61.5%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f6443.0%

        \[\leadsto \frac{x.im}{\color{blue}{y.re}} \]
    4. Applied rewrites43.0%

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

    if 8.0000000000000001e122 < y.im

    1. Initial program 61.5%

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f6443.0%

        \[\leadsto \frac{x.im}{\color{blue}{y.re}} \]
    4. Applied rewrites43.0%

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    5. Taylor expanded in undef-var around zero

      \[\leadsto \frac{0}{y.re} \]
    6. Step-by-step derivation
      1. Applied rewrites17.5%

        \[\leadsto \frac{0}{y.re} \]
    7. Recombined 2 regimes into one program.
    8. Add Preprocessing

    Alternative 10: 43.0% accurate, 3.2× speedup?

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

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

      \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
    3. Step-by-step derivation
      1. lower-/.f6443.0%

        \[\leadsto \frac{x.im}{\color{blue}{y.re}} \]
    4. Applied rewrites43.0%

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

    Reproduce

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