_divideComplex, real part

Percentage Accurate: 61.5% → 79.0%
Time: 4.6s
Alternatives: 8
Speedup: 1.6×

Specification

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

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

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 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.5% accurate, 1.0× speedup?

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

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

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

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

Alternative 1: 79.0% accurate, 0.7× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y.re < -9.50000000000000069e68 or 1.7500000000000001e24 < y.re

    1. Initial program 46.0%

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

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

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

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

        if -9.50000000000000069e68 < y.re < -1.65000000000000008e-43

        1. Initial program 78.8%

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

          \[\leadsto \color{blue}{x.im \cdot \left(\frac{y.im}{{y.im}^{2} + {y.re}^{2}} + \frac{x.re \cdot y.re}{x.im \cdot \left({y.im}^{2} + {y.re}^{2}\right)}\right)} \]
        4. Step-by-step derivation
          1. Applied rewrites82.9%

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

          if -1.65000000000000008e-43 < y.re < 1.7500000000000001e24

          1. Initial program 70.3%

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

            \[\leadsto \color{blue}{\frac{x.im}{y.im} + \frac{x.re \cdot y.re}{{y.im}^{2}}} \]
          4. Applied rewrites85.8%

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

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

          Alternative 2: 61.2% accurate, 0.7× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -1.5 \cdot 10^{+194}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq -4.5 \cdot 10^{+67}:\\ \;\;\;\;\frac{\frac{x.im}{y.re} \cdot y.im}{y.re}\\ \mathbf{elif}\;y.re \leq 2 \cdot 10^{-23}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{elif}\;y.re \leq 6.3 \cdot 10^{+122}:\\ \;\;\;\;\frac{y.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot x.re\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \end{array} \end{array} \]
          (FPCore (x.re x.im y.re y.im)
           :precision binary64
           (if (<= y.re -1.5e+194)
             (/ x.re y.re)
             (if (<= y.re -4.5e+67)
               (/ (* (/ x.im y.re) y.im) y.re)
               (if (<= y.re 2e-23)
                 (/ x.im y.im)
                 (if (<= y.re 6.3e+122)
                   (* (/ y.re (fma y.im y.im (* y.re y.re))) x.re)
                   (/ x.re y.re))))))
          double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
          	double tmp;
          	if (y_46_re <= -1.5e+194) {
          		tmp = x_46_re / y_46_re;
          	} else if (y_46_re <= -4.5e+67) {
          		tmp = ((x_46_im / y_46_re) * y_46_im) / y_46_re;
          	} else if (y_46_re <= 2e-23) {
          		tmp = x_46_im / y_46_im;
          	} else if (y_46_re <= 6.3e+122) {
          		tmp = (y_46_re / fma(y_46_im, y_46_im, (y_46_re * y_46_re))) * x_46_re;
          	} else {
          		tmp = x_46_re / y_46_re;
          	}
          	return tmp;
          }
          
          function code(x_46_re, x_46_im, y_46_re, y_46_im)
          	tmp = 0.0
          	if (y_46_re <= -1.5e+194)
          		tmp = Float64(x_46_re / y_46_re);
          	elseif (y_46_re <= -4.5e+67)
          		tmp = Float64(Float64(Float64(x_46_im / y_46_re) * y_46_im) / y_46_re);
          	elseif (y_46_re <= 2e-23)
          		tmp = Float64(x_46_im / y_46_im);
          	elseif (y_46_re <= 6.3e+122)
          		tmp = Float64(Float64(y_46_re / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))) * x_46_re);
          	else
          		tmp = Float64(x_46_re / y_46_re);
          	end
          	return tmp
          end
          
          code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -1.5e+194], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, -4.5e+67], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 2e-23], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 6.3e+122], N[(N[(y$46$re / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x$46$re), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;y.re \leq -1.5 \cdot 10^{+194}:\\
          \;\;\;\;\frac{x.re}{y.re}\\
          
          \mathbf{elif}\;y.re \leq -4.5 \cdot 10^{+67}:\\
          \;\;\;\;\frac{\frac{x.im}{y.re} \cdot y.im}{y.re}\\
          
          \mathbf{elif}\;y.re \leq 2 \cdot 10^{-23}:\\
          \;\;\;\;\frac{x.im}{y.im}\\
          
          \mathbf{elif}\;y.re \leq 6.3 \cdot 10^{+122}:\\
          \;\;\;\;\frac{y.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot x.re\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{x.re}{y.re}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 4 regimes
          2. if y.re < -1.5000000000000002e194 or 6.3000000000000001e122 < y.re

            1. Initial program 33.3%

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

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

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

              if -1.5000000000000002e194 < y.re < -4.4999999999999998e67

              1. Initial program 49.5%

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

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

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

                    \[\leadsto \frac{\mathsf{fma}\left(y.im, \frac{x.im}{y.re}, x.re\right)}{y.re} \]
                  2. Taylor expanded in x.re around 0

                    \[\leadsto \frac{\frac{x.im \cdot y.im}{y.re}}{y.re} \]
                  3. Step-by-step derivation
                    1. Applied rewrites51.0%

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

                    if -4.4999999999999998e67 < y.re < 1.99999999999999992e-23

                    1. Initial program 70.8%

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

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

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

                      if 1.99999999999999992e-23 < y.re < 6.3000000000000001e122

                      1. Initial program 84.2%

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

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

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

                      Alternative 3: 61.3% accurate, 0.7× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -1.5 \cdot 10^{+194}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \mathbf{elif}\;y.re \leq -4.2 \cdot 10^{+67}:\\ \;\;\;\;\frac{\frac{x.im}{y.re}}{y.re} \cdot y.im\\ \mathbf{elif}\;y.re \leq 2 \cdot 10^{-23}:\\ \;\;\;\;\frac{x.im}{y.im}\\ \mathbf{elif}\;y.re \leq 6.3 \cdot 10^{+122}:\\ \;\;\;\;\frac{y.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot x.re\\ \mathbf{else}:\\ \;\;\;\;\frac{x.re}{y.re}\\ \end{array} \end{array} \]
                      (FPCore (x.re x.im y.re y.im)
                       :precision binary64
                       (if (<= y.re -1.5e+194)
                         (/ x.re y.re)
                         (if (<= y.re -4.2e+67)
                           (* (/ (/ x.im y.re) y.re) y.im)
                           (if (<= y.re 2e-23)
                             (/ x.im y.im)
                             (if (<= y.re 6.3e+122)
                               (* (/ y.re (fma y.im y.im (* y.re y.re))) x.re)
                               (/ x.re y.re))))))
                      double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
                      	double tmp;
                      	if (y_46_re <= -1.5e+194) {
                      		tmp = x_46_re / y_46_re;
                      	} else if (y_46_re <= -4.2e+67) {
                      		tmp = ((x_46_im / y_46_re) / y_46_re) * y_46_im;
                      	} else if (y_46_re <= 2e-23) {
                      		tmp = x_46_im / y_46_im;
                      	} else if (y_46_re <= 6.3e+122) {
                      		tmp = (y_46_re / fma(y_46_im, y_46_im, (y_46_re * y_46_re))) * x_46_re;
                      	} else {
                      		tmp = x_46_re / y_46_re;
                      	}
                      	return tmp;
                      }
                      
                      function code(x_46_re, x_46_im, y_46_re, y_46_im)
                      	tmp = 0.0
                      	if (y_46_re <= -1.5e+194)
                      		tmp = Float64(x_46_re / y_46_re);
                      	elseif (y_46_re <= -4.2e+67)
                      		tmp = Float64(Float64(Float64(x_46_im / y_46_re) / y_46_re) * y_46_im);
                      	elseif (y_46_re <= 2e-23)
                      		tmp = Float64(x_46_im / y_46_im);
                      	elseif (y_46_re <= 6.3e+122)
                      		tmp = Float64(Float64(y_46_re / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))) * x_46_re);
                      	else
                      		tmp = Float64(x_46_re / y_46_re);
                      	end
                      	return tmp
                      end
                      
                      code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -1.5e+194], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, -4.2e+67], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] / y$46$re), $MachinePrecision] * y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 2e-23], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 6.3e+122], N[(N[(y$46$re / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x$46$re), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]]]]
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      \mathbf{if}\;y.re \leq -1.5 \cdot 10^{+194}:\\
                      \;\;\;\;\frac{x.re}{y.re}\\
                      
                      \mathbf{elif}\;y.re \leq -4.2 \cdot 10^{+67}:\\
                      \;\;\;\;\frac{\frac{x.im}{y.re}}{y.re} \cdot y.im\\
                      
                      \mathbf{elif}\;y.re \leq 2 \cdot 10^{-23}:\\
                      \;\;\;\;\frac{x.im}{y.im}\\
                      
                      \mathbf{elif}\;y.re \leq 6.3 \cdot 10^{+122}:\\
                      \;\;\;\;\frac{y.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot x.re\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\frac{x.re}{y.re}\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 4 regimes
                      2. if y.re < -1.5000000000000002e194 or 6.3000000000000001e122 < y.re

                        1. Initial program 33.3%

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

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

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

                          if -1.5000000000000002e194 < y.re < -4.2000000000000003e67

                          1. Initial program 49.5%

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

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

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

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

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

                              if -4.2000000000000003e67 < y.re < 1.99999999999999992e-23

                              1. Initial program 70.8%

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

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

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

                                if 1.99999999999999992e-23 < y.re < 6.3000000000000001e122

                                1. Initial program 84.2%

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

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

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

                                Alternative 4: 77.2% accurate, 0.9× speedup?

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

                                  1. Initial program 48.0%

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

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

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

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

                                      if -3.40000000000000012e43 < y.re < 1.7500000000000001e24

                                      1. Initial program 71.4%

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

                                        \[\leadsto \color{blue}{\frac{x.im}{y.im} + \frac{x.re \cdot y.re}{{y.im}^{2}}} \]
                                      4. Applied rewrites83.0%

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

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

                                        \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -3.4 \cdot 10^{+43} \lor \neg \left(y.re \leq 1.75 \cdot 10^{+24}\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(y.im, \frac{x.im}{y.re}, x.re\right)}{y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y.re, \frac{x.re}{y.im}, x.im\right)}{y.im}\\ \end{array} \]
                                      8. Add Preprocessing

                                      Alternative 5: 68.9% accurate, 0.9× speedup?

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

                                        1. Initial program 50.5%

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

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

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

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

                                            if -2.00000000000000009e42 < y.re < 2.9000000000000001e-31

                                            1. Initial program 71.0%

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

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

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

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

                                            Alternative 6: 59.8% accurate, 0.9× speedup?

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

                                              1. Initial program 49.1%

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

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

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

                                                if -1.5000000000000002e194 < y.re < -4.2000000000000003e67

                                                1. Initial program 49.5%

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

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

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

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

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

                                                    if -4.2000000000000003e67 < y.re < 2.15000000000000001e-23

                                                    1. Initial program 70.8%

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

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

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

                                                    Alternative 7: 63.1% accurate, 1.6× speedup?

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

                                                      1. Initial program 50.4%

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

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

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

                                                        if -2.40000000000000023e43 < y.re < 2.15000000000000001e-23

                                                        1. Initial program 70.7%

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

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

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

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

                                                        Alternative 8: 43.4% accurate, 3.2× speedup?

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

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

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

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

                                                          Reproduce

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