_divideComplex, imaginary part

Percentage Accurate: 61.8% → 84.6%
Time: 7.0s
Alternatives: 8
Speedup: 1.5×

Specification

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

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

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 61.8% accurate, 1.0× speedup?

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

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

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

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

Alternative 1: 84.6% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;y.im \leq -2.7 \cdot 10^{-42}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;y.im \leq 7.5 \cdot 10^{+147}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.im < -7.7999999999999997e120 or 7.50000000000000037e147 < y.im

    1. Initial program 30.1%

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

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

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

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

        if -7.7999999999999997e120 < y.im < -2.69999999999999999e-42 or 1.30000000000000007e-98 < y.im < 7.50000000000000037e147

        1. Initial program 78.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if -2.69999999999999999e-42 < y.im < 1.30000000000000007e-98

        1. Initial program 70.6%

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

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

            \[\leadsto \color{blue}{\frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
          2. Step-by-step derivation
            1. Applied rewrites93.6%

              \[\leadsto \frac{x.im - y.im \cdot \frac{x.re}{y.re}}{y.re} \]
          3. Recombined 3 regimes into one program.
          4. Final simplification87.6%

            \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -7.8 \cdot 10^{+120}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\ \mathbf{elif}\;y.im \leq -2.7 \cdot 10^{-42}:\\ \;\;\;\;x.im \cdot \frac{y.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} - x.re \cdot \frac{y.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\ \mathbf{elif}\;y.im \leq 1.3 \cdot 10^{-98}:\\ \;\;\;\;\frac{x.im - y.im \cdot \frac{x.re}{y.re}}{y.re}\\ \mathbf{elif}\;y.im \leq 7.5 \cdot 10^{+147}:\\ \;\;\;\;x.im \cdot \frac{y.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} - x.re \cdot \frac{y.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\ \end{array} \]
          5. Add Preprocessing

          Alternative 2: 80.9% accurate, 0.7× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\ \mathbf{if}\;y.im \leq -2 \cdot 10^{-16}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.im \leq 1.35 \cdot 10^{-109}:\\ \;\;\;\;\frac{x.im - y.im \cdot \frac{x.re}{y.re}}{y.re}\\ \mathbf{elif}\;y.im \leq 2 \cdot 10^{+147}:\\ \;\;\;\;\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
          (FPCore (x.re x.im y.re y.im)
           :precision binary64
           (let* ((t_0 (/ (fma y.re (/ x.im y.im) (- x.re)) y.im)))
             (if (<= y.im -2e-16)
               t_0
               (if (<= y.im 1.35e-109)
                 (/ (- x.im (* y.im (/ x.re y.re))) y.re)
                 (if (<= y.im 2e+147)
                   (/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im)))
                   t_0)))))
          double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
          	double t_0 = fma(y_46_re, (x_46_im / y_46_im), -x_46_re) / y_46_im;
          	double tmp;
          	if (y_46_im <= -2e-16) {
          		tmp = t_0;
          	} else if (y_46_im <= 1.35e-109) {
          		tmp = (x_46_im - (y_46_im * (x_46_re / y_46_re))) / y_46_re;
          	} else if (y_46_im <= 2e+147) {
          		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));
          	} else {
          		tmp = t_0;
          	}
          	return tmp;
          }
          
          function code(x_46_re, x_46_im, y_46_re, y_46_im)
          	t_0 = Float64(fma(y_46_re, Float64(x_46_im / y_46_im), Float64(-x_46_re)) / y_46_im)
          	tmp = 0.0
          	if (y_46_im <= -2e-16)
          		tmp = t_0;
          	elseif (y_46_im <= 1.35e-109)
          		tmp = Float64(Float64(x_46_im - Float64(y_46_im * Float64(x_46_re / y_46_re))) / y_46_re);
          	elseif (y_46_im <= 2e+147)
          		tmp = 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)));
          	else
          		tmp = t_0;
          	end
          	return tmp
          end
          
          code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(y$46$re * N[(x$46$im / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -2e-16], t$95$0, If[LessEqual[y$46$im, 1.35e-109], N[(N[(x$46$im - N[(y$46$im * N[(x$46$re / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 2e+147], 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], t$95$0]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\
          \mathbf{if}\;y.im \leq -2 \cdot 10^{-16}:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;y.im \leq 1.35 \cdot 10^{-109}:\\
          \;\;\;\;\frac{x.im - y.im \cdot \frac{x.re}{y.re}}{y.re}\\
          
          \mathbf{elif}\;y.im \leq 2 \cdot 10^{+147}:\\
          \;\;\;\;\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if y.im < -2e-16 or 2e147 < y.im

            1. Initial program 41.8%

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

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

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

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

                if -2e-16 < y.im < 1.35e-109

                1. Initial program 70.4%

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

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

                    \[\leadsto \color{blue}{\frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
                  2. Step-by-step derivation
                    1. Applied rewrites92.8%

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

                    if 1.35e-109 < y.im < 2e147

                    1. Initial program 79.7%

                      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
                    2. Add Preprocessing
                  3. Recombined 3 regimes into one program.
                  4. Final simplification84.8%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -2 \cdot 10^{-16}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\ \mathbf{elif}\;y.im \leq 1.35 \cdot 10^{-109}:\\ \;\;\;\;\frac{x.im - y.im \cdot \frac{x.re}{y.re}}{y.re}\\ \mathbf{elif}\;y.im \leq 2 \cdot 10^{+147}:\\ \;\;\;\;\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y.re, \frac{x.im}{y.im}, -x.re\right)}{y.im}\\ \end{array} \]
                  5. Add Preprocessing

                  Alternative 3: 66.7% accurate, 0.7× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-x.re}{y.im}\\ t_1 := \frac{x.im \cdot y.re - x.re \cdot y.im}{y.im \cdot y.im}\\ \mathbf{if}\;y.im \leq -1.68 \cdot 10^{+124}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y.im \leq -1.9 \cdot 10^{-16}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y.im \leq 2.9 \cdot 10^{-5}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{elif}\;y.im \leq 4.8 \cdot 10^{+118}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                  (FPCore (x.re x.im y.re y.im)
                   :precision binary64
                   (let* ((t_0 (/ (- x.re) y.im))
                          (t_1 (/ (- (* x.im y.re) (* x.re y.im)) (* y.im y.im))))
                     (if (<= y.im -1.68e+124)
                       t_0
                       (if (<= y.im -1.9e-16)
                         t_1
                         (if (<= y.im 2.9e-5) (/ x.im y.re) (if (<= y.im 4.8e+118) t_1 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 t_1 = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / (y_46_im * y_46_im);
                  	double tmp;
                  	if (y_46_im <= -1.68e+124) {
                  		tmp = t_0;
                  	} else if (y_46_im <= -1.9e-16) {
                  		tmp = t_1;
                  	} else if (y_46_im <= 2.9e-5) {
                  		tmp = x_46_im / y_46_re;
                  	} else if (y_46_im <= 4.8e+118) {
                  		tmp = t_1;
                  	} 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) :: t_1
                      real(8) :: tmp
                      t_0 = -x_46re / y_46im
                      t_1 = ((x_46im * y_46re) - (x_46re * y_46im)) / (y_46im * y_46im)
                      if (y_46im <= (-1.68d+124)) then
                          tmp = t_0
                      else if (y_46im <= (-1.9d-16)) then
                          tmp = t_1
                      else if (y_46im <= 2.9d-5) then
                          tmp = x_46im / y_46re
                      else if (y_46im <= 4.8d+118) then
                          tmp = t_1
                      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 t_1 = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / (y_46_im * y_46_im);
                  	double tmp;
                  	if (y_46_im <= -1.68e+124) {
                  		tmp = t_0;
                  	} else if (y_46_im <= -1.9e-16) {
                  		tmp = t_1;
                  	} else if (y_46_im <= 2.9e-5) {
                  		tmp = x_46_im / y_46_re;
                  	} else if (y_46_im <= 4.8e+118) {
                  		tmp = t_1;
                  	} 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
                  	t_1 = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / (y_46_im * y_46_im)
                  	tmp = 0
                  	if y_46_im <= -1.68e+124:
                  		tmp = t_0
                  	elif y_46_im <= -1.9e-16:
                  		tmp = t_1
                  	elif y_46_im <= 2.9e-5:
                  		tmp = x_46_im / y_46_re
                  	elif y_46_im <= 4.8e+118:
                  		tmp = t_1
                  	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)
                  	t_1 = Float64(Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im)) / Float64(y_46_im * y_46_im))
                  	tmp = 0.0
                  	if (y_46_im <= -1.68e+124)
                  		tmp = t_0;
                  	elseif (y_46_im <= -1.9e-16)
                  		tmp = t_1;
                  	elseif (y_46_im <= 2.9e-5)
                  		tmp = Float64(x_46_im / y_46_re);
                  	elseif (y_46_im <= 4.8e+118)
                  		tmp = t_1;
                  	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;
                  	t_1 = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / (y_46_im * y_46_im);
                  	tmp = 0.0;
                  	if (y_46_im <= -1.68e+124)
                  		tmp = t_0;
                  	elseif (y_46_im <= -1.9e-16)
                  		tmp = t_1;
                  	elseif (y_46_im <= 2.9e-5)
                  		tmp = x_46_im / y_46_re;
                  	elseif (y_46_im <= 4.8e+118)
                  		tmp = t_1;
                  	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]}, Block[{t$95$1 = N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$im, -1.68e+124], t$95$0, If[LessEqual[y$46$im, -1.9e-16], t$95$1, If[LessEqual[y$46$im, 2.9e-5], N[(x$46$im / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 4.8e+118], t$95$1, t$95$0]]]]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  t_0 := \frac{-x.re}{y.im}\\
                  t_1 := \frac{x.im \cdot y.re - x.re \cdot y.im}{y.im \cdot y.im}\\
                  \mathbf{if}\;y.im \leq -1.68 \cdot 10^{+124}:\\
                  \;\;\;\;t\_0\\
                  
                  \mathbf{elif}\;y.im \leq -1.9 \cdot 10^{-16}:\\
                  \;\;\;\;t\_1\\
                  
                  \mathbf{elif}\;y.im \leq 2.9 \cdot 10^{-5}:\\
                  \;\;\;\;\frac{x.im}{y.re}\\
                  
                  \mathbf{elif}\;y.im \leq 4.8 \cdot 10^{+118}:\\
                  \;\;\;\;t\_1\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;t\_0\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 3 regimes
                  2. if y.im < -1.67999999999999995e124 or 4.8e118 < y.im

                    1. Initial program 29.5%

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

                      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im}} \]
                    4. Step-by-step derivation
                      1. Applied rewrites69.3%

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

                      if -1.67999999999999995e124 < y.im < -1.90000000000000006e-16 or 2.9e-5 < y.im < 4.8e118

                      1. Initial program 81.9%

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

                        \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{{y.im}^{2}}} \]
                      4. Step-by-step derivation
                        1. Applied rewrites67.9%

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

                        if -1.90000000000000006e-16 < y.im < 2.9e-5

                        1. Initial program 72.3%

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

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

                            \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
                        5. Recombined 3 regimes into one program.
                        6. Final simplification70.5%

                          \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -1.68 \cdot 10^{+124}:\\ \;\;\;\;\frac{-x.re}{y.im}\\ \mathbf{elif}\;y.im \leq -1.9 \cdot 10^{-16}:\\ \;\;\;\;\frac{x.im \cdot y.re - x.re \cdot y.im}{y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 2.9 \cdot 10^{-5}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{elif}\;y.im \leq 4.8 \cdot 10^{+118}:\\ \;\;\;\;\frac{x.im \cdot y.re - x.re \cdot y.im}{y.im \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{-x.re}{y.im}\\ \end{array} \]
                        7. Add Preprocessing

                        Alternative 4: 73.2% accurate, 0.8× speedup?

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

                          1. Initial program 43.5%

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

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

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

                            if -1.8000000000000001e30 < y.re < 1.2599999999999999e-27

                            1. Initial program 71.3%

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

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

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

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

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

                              if 1.2599999999999999e-27 < y.re < 8.59999999999999947e88

                              1. Initial program 71.9%

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

                                \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{{y.re}^{2}}} \]
                              4. Step-by-step derivation
                                1. Applied rewrites59.1%

                                  \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{y.re \cdot y.re}} \]
                              5. Recombined 3 regimes into one program.
                              6. Final simplification74.5%

                                \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -1.8 \cdot 10^{+30}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{elif}\;y.re \leq 1.26 \cdot 10^{-27}:\\ \;\;\;\;\frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im}\\ \mathbf{elif}\;y.re \leq 8.6 \cdot 10^{+88}:\\ \;\;\;\;\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \end{array} \]
                              7. Add Preprocessing

                              Alternative 5: 79.0% accurate, 0.9× speedup?

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

                                1. Initial program 49.7%

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

                                  \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im} + \frac{x.im \cdot y.re}{{y.im}^{2}}} \]
                                4. Step-by-step derivation
                                  1. Applied rewrites76.5%

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

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

                                    if -2e-16 < y.im < 3.10000000000000014e-5

                                    1. Initial program 72.3%

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

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

                                        \[\leadsto \color{blue}{\frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
                                      2. Step-by-step derivation
                                        1. Applied rewrites86.9%

                                          \[\leadsto \frac{x.im - y.im \cdot \frac{x.re}{y.re}}{y.re} \]
                                      3. Recombined 2 regimes into one program.
                                      4. Final simplification81.9%

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

                                      Alternative 6: 78.4% accurate, 0.9× speedup?

                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -1.9 \cdot 10^{+29} \lor \neg \left(y.re \leq 1.26 \cdot 10^{-27}\right):\\ \;\;\;\;\frac{x.im - y.im \cdot \frac{x.re}{y.re}}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im}\\ \end{array} \end{array} \]
                                      (FPCore (x.re x.im y.re y.im)
                                       :precision binary64
                                       (if (or (<= y.re -1.9e+29) (not (<= y.re 1.26e-27)))
                                         (/ (- x.im (* y.im (/ x.re y.re))) y.re)
                                         (/ (- (/ (* y.re x.im) y.im) x.re) y.im)))
                                      double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
                                      	double tmp;
                                      	if ((y_46_re <= -1.9e+29) || !(y_46_re <= 1.26e-27)) {
                                      		tmp = (x_46_im - (y_46_im * (x_46_re / y_46_re))) / y_46_re;
                                      	} else {
                                      		tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im;
                                      	}
                                      	return tmp;
                                      }
                                      
                                      module fmin_fmax_functions
                                          implicit none
                                          private
                                          public fmax
                                          public fmin
                                      
                                          interface fmax
                                              module procedure fmax88
                                              module procedure fmax44
                                              module procedure fmax84
                                              module procedure fmax48
                                          end interface
                                          interface fmin
                                              module procedure fmin88
                                              module procedure fmin44
                                              module procedure fmin84
                                              module procedure fmin48
                                          end interface
                                      contains
                                          real(8) function fmax88(x, y) result (res)
                                              real(8), intent (in) :: x
                                              real(8), intent (in) :: y
                                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                          end function
                                          real(4) function fmax44(x, y) result (res)
                                              real(4), intent (in) :: x
                                              real(4), intent (in) :: y
                                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                          end function
                                          real(8) function fmax84(x, y) result(res)
                                              real(8), intent (in) :: x
                                              real(4), intent (in) :: y
                                              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                          end function
                                          real(8) function fmax48(x, y) result(res)
                                              real(4), intent (in) :: x
                                              real(8), intent (in) :: y
                                              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                          end function
                                          real(8) function fmin88(x, y) result (res)
                                              real(8), intent (in) :: x
                                              real(8), intent (in) :: y
                                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                          end function
                                          real(4) function fmin44(x, y) result (res)
                                              real(4), intent (in) :: x
                                              real(4), intent (in) :: y
                                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                          end function
                                          real(8) function fmin84(x, y) result(res)
                                              real(8), intent (in) :: x
                                              real(4), intent (in) :: y
                                              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                          end function
                                          real(8) function fmin48(x, y) result(res)
                                              real(4), intent (in) :: x
                                              real(8), intent (in) :: y
                                              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                          end function
                                      end module
                                      
                                      real(8) function code(x_46re, x_46im, y_46re, y_46im)
                                      use fmin_fmax_functions
                                          real(8), intent (in) :: x_46re
                                          real(8), intent (in) :: x_46im
                                          real(8), intent (in) :: y_46re
                                          real(8), intent (in) :: y_46im
                                          real(8) :: tmp
                                          if ((y_46re <= (-1.9d+29)) .or. (.not. (y_46re <= 1.26d-27))) then
                                              tmp = (x_46im - (y_46im * (x_46re / y_46re))) / y_46re
                                          else
                                              tmp = (((y_46re * x_46im) / y_46im) - x_46re) / y_46im
                                          end if
                                          code = tmp
                                      end function
                                      
                                      public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
                                      	double tmp;
                                      	if ((y_46_re <= -1.9e+29) || !(y_46_re <= 1.26e-27)) {
                                      		tmp = (x_46_im - (y_46_im * (x_46_re / y_46_re))) / y_46_re;
                                      	} else {
                                      		tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im;
                                      	}
                                      	return tmp;
                                      }
                                      
                                      def code(x_46_re, x_46_im, y_46_re, y_46_im):
                                      	tmp = 0
                                      	if (y_46_re <= -1.9e+29) or not (y_46_re <= 1.26e-27):
                                      		tmp = (x_46_im - (y_46_im * (x_46_re / y_46_re))) / y_46_re
                                      	else:
                                      		tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im
                                      	return tmp
                                      
                                      function code(x_46_re, x_46_im, y_46_re, y_46_im)
                                      	tmp = 0.0
                                      	if ((y_46_re <= -1.9e+29) || !(y_46_re <= 1.26e-27))
                                      		tmp = Float64(Float64(x_46_im - Float64(y_46_im * Float64(x_46_re / y_46_re))) / y_46_re);
                                      	else
                                      		tmp = Float64(Float64(Float64(Float64(y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im);
                                      	end
                                      	return tmp
                                      end
                                      
                                      function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
                                      	tmp = 0.0;
                                      	if ((y_46_re <= -1.9e+29) || ~((y_46_re <= 1.26e-27)))
                                      		tmp = (x_46_im - (y_46_im * (x_46_re / y_46_re))) / y_46_re;
                                      	else
                                      		tmp = (((y_46_re * x_46_im) / y_46_im) - x_46_re) / y_46_im;
                                      	end
                                      	tmp_2 = tmp;
                                      end
                                      
                                      code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -1.9e+29], N[Not[LessEqual[y$46$re, 1.26e-27]], $MachinePrecision]], N[(N[(x$46$im - N[(y$46$im * N[(x$46$re / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], N[(N[(N[(N[(y$46$re * x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision] - x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision]]
                                      
                                      \begin{array}{l}
                                      
                                      \\
                                      \begin{array}{l}
                                      \mathbf{if}\;y.re \leq -1.9 \cdot 10^{+29} \lor \neg \left(y.re \leq 1.26 \cdot 10^{-27}\right):\\
                                      \;\;\;\;\frac{x.im - y.im \cdot \frac{x.re}{y.re}}{y.re}\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;\frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im}\\
                                      
                                      
                                      \end{array}
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 2 regimes
                                      2. if y.re < -1.89999999999999985e29 or 1.2599999999999999e-27 < y.re

                                        1. Initial program 49.5%

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

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

                                            \[\leadsto \color{blue}{\frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re}} \]
                                          2. Step-by-step derivation
                                            1. Applied rewrites77.9%

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

                                            if -1.89999999999999985e29 < y.re < 1.2599999999999999e-27

                                            1. Initial program 71.3%

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

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

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

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

                                                \[\leadsto \frac{\frac{y.re \cdot x.im}{y.im} - x.re}{\color{blue}{y.im}} \]
                                            7. Recombined 2 regimes into one program.
                                            8. Final simplification78.7%

                                              \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -1.9 \cdot 10^{+29} \lor \neg \left(y.re \leq 1.26 \cdot 10^{-27}\right):\\ \;\;\;\;\frac{x.im - y.im \cdot \frac{x.re}{y.re}}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y.re \cdot x.im}{y.im} - x.re}{y.im}\\ \end{array} \]
                                            9. Add Preprocessing

                                            Alternative 7: 65.5% accurate, 1.5× speedup?

                                            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.im \leq -2.4 \cdot 10^{-16} \lor \neg \left(y.im \leq 3.4 \cdot 10^{-5}\right):\\ \;\;\;\;\frac{-x.re}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \end{array} \end{array} \]
                                            (FPCore (x.re x.im y.re y.im)
                                             :precision binary64
                                             (if (or (<= y.im -2.4e-16) (not (<= y.im 3.4e-5)))
                                               (/ (- x.re) y.im)
                                               (/ x.im y.re)))
                                            double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
                                            	double tmp;
                                            	if ((y_46_im <= -2.4e-16) || !(y_46_im <= 3.4e-5)) {
                                            		tmp = -x_46_re / y_46_im;
                                            	} else {
                                            		tmp = x_46_im / y_46_re;
                                            	}
                                            	return tmp;
                                            }
                                            
                                            module fmin_fmax_functions
                                                implicit none
                                                private
                                                public fmax
                                                public fmin
                                            
                                                interface fmax
                                                    module procedure fmax88
                                                    module procedure fmax44
                                                    module procedure fmax84
                                                    module procedure fmax48
                                                end interface
                                                interface fmin
                                                    module procedure fmin88
                                                    module procedure fmin44
                                                    module procedure fmin84
                                                    module procedure fmin48
                                                end interface
                                            contains
                                                real(8) function fmax88(x, y) result (res)
                                                    real(8), intent (in) :: x
                                                    real(8), intent (in) :: y
                                                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                end function
                                                real(4) function fmax44(x, y) result (res)
                                                    real(4), intent (in) :: x
                                                    real(4), intent (in) :: y
                                                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                end function
                                                real(8) function fmax84(x, y) result(res)
                                                    real(8), intent (in) :: x
                                                    real(4), intent (in) :: y
                                                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                end function
                                                real(8) function fmax48(x, y) result(res)
                                                    real(4), intent (in) :: x
                                                    real(8), intent (in) :: y
                                                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                end function
                                                real(8) function fmin88(x, y) result (res)
                                                    real(8), intent (in) :: x
                                                    real(8), intent (in) :: y
                                                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                end function
                                                real(4) function fmin44(x, y) result (res)
                                                    real(4), intent (in) :: x
                                                    real(4), intent (in) :: y
                                                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                end function
                                                real(8) function fmin84(x, y) result(res)
                                                    real(8), intent (in) :: x
                                                    real(4), intent (in) :: y
                                                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                end function
                                                real(8) function fmin48(x, y) result(res)
                                                    real(4), intent (in) :: x
                                                    real(8), intent (in) :: y
                                                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                end function
                                            end module
                                            
                                            real(8) function code(x_46re, x_46im, y_46re, y_46im)
                                            use fmin_fmax_functions
                                                real(8), intent (in) :: x_46re
                                                real(8), intent (in) :: x_46im
                                                real(8), intent (in) :: y_46re
                                                real(8), intent (in) :: y_46im
                                                real(8) :: tmp
                                                if ((y_46im <= (-2.4d-16)) .or. (.not. (y_46im <= 3.4d-5))) then
                                                    tmp = -x_46re / y_46im
                                                else
                                                    tmp = x_46im / y_46re
                                                end if
                                                code = tmp
                                            end function
                                            
                                            public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
                                            	double tmp;
                                            	if ((y_46_im <= -2.4e-16) || !(y_46_im <= 3.4e-5)) {
                                            		tmp = -x_46_re / y_46_im;
                                            	} else {
                                            		tmp = x_46_im / y_46_re;
                                            	}
                                            	return tmp;
                                            }
                                            
                                            def code(x_46_re, x_46_im, y_46_re, y_46_im):
                                            	tmp = 0
                                            	if (y_46_im <= -2.4e-16) or not (y_46_im <= 3.4e-5):
                                            		tmp = -x_46_re / y_46_im
                                            	else:
                                            		tmp = x_46_im / y_46_re
                                            	return tmp
                                            
                                            function code(x_46_re, x_46_im, y_46_re, y_46_im)
                                            	tmp = 0.0
                                            	if ((y_46_im <= -2.4e-16) || !(y_46_im <= 3.4e-5))
                                            		tmp = Float64(Float64(-x_46_re) / y_46_im);
                                            	else
                                            		tmp = Float64(x_46_im / y_46_re);
                                            	end
                                            	return tmp
                                            end
                                            
                                            function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
                                            	tmp = 0.0;
                                            	if ((y_46_im <= -2.4e-16) || ~((y_46_im <= 3.4e-5)))
                                            		tmp = -x_46_re / y_46_im;
                                            	else
                                            		tmp = x_46_im / y_46_re;
                                            	end
                                            	tmp_2 = tmp;
                                            end
                                            
                                            code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$im, -2.4e-16], N[Not[LessEqual[y$46$im, 3.4e-5]], $MachinePrecision]], N[((-x$46$re) / y$46$im), $MachinePrecision], N[(x$46$im / y$46$re), $MachinePrecision]]
                                            
                                            \begin{array}{l}
                                            
                                            \\
                                            \begin{array}{l}
                                            \mathbf{if}\;y.im \leq -2.4 \cdot 10^{-16} \lor \neg \left(y.im \leq 3.4 \cdot 10^{-5}\right):\\
                                            \;\;\;\;\frac{-x.re}{y.im}\\
                                            
                                            \mathbf{else}:\\
                                            \;\;\;\;\frac{x.im}{y.re}\\
                                            
                                            
                                            \end{array}
                                            \end{array}
                                            
                                            Derivation
                                            1. Split input into 2 regimes
                                            2. if y.im < -2.40000000000000005e-16 or 3.4e-5 < y.im

                                              1. Initial program 49.7%

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

                                                \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im}} \]
                                              4. Step-by-step derivation
                                                1. Applied rewrites60.9%

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

                                                if -2.40000000000000005e-16 < y.im < 3.4e-5

                                                1. Initial program 72.3%

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

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

                                                    \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
                                                5. Recombined 2 regimes into one program.
                                                6. Final simplification66.2%

                                                  \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -2.4 \cdot 10^{-16} \lor \neg \left(y.im \leq 3.4 \cdot 10^{-5}\right):\\ \;\;\;\;\frac{-x.re}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \end{array} \]
                                                7. Add Preprocessing

                                                Alternative 8: 43.2% accurate, 3.2× speedup?

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

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

                                                  \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
                                                4. Step-by-step derivation
                                                  1. Applied rewrites45.0%

                                                    \[\leadsto \color{blue}{\frac{x.im}{y.re}} \]
                                                  2. Final simplification45.0%

                                                    \[\leadsto \frac{x.im}{y.re} \]
                                                  3. Add Preprocessing

                                                  Reproduce

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