Complex division, real part

Percentage Accurate: 60.7% → 81.9%
Time: 5.1s
Alternatives: 9
Speedup: 1.6×

Specification

?
\[\begin{array}{l} \\ \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
	return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
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(a, b, c, d)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    code = ((a * c) + (b * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
	return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d):
	return ((a * c) + (b * d)) / ((c * c) + (d * d))
function code(a, b, c, d)
	return Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d)))
end
function tmp = code(a, b, c, d)
	tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
end
code[a_, b_, c_, d_] := N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\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 9 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: 60.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
	return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
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(a, b, c, d)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    code = ((a * c) + (b * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
	return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d):
	return ((a * c) + (b * d)) / ((c * c) + (d * d))
function code(a, b, c, d)
	return Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d)))
end
function tmp = code(a, b, c, d)
	tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
end
code[a_, b_, c_, d_] := N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\end{array}

Alternative 1: 81.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\ \mathbf{if}\;c \leq -2.4 \cdot 10^{+91}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq -2.2 \cdot 10^{-83}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 7 \cdot 10^{-118}:\\ \;\;\;\;\frac{b - \frac{\mathsf{fma}\left(-a, c, \frac{\left(b \cdot c\right) \cdot c}{d}\right)}{d}}{d}\\ \mathbf{elif}\;c \leq 2.25 \cdot 10^{+77}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (fma (/ d c) b a) c)))
   (if (<= c -2.4e+91)
     t_0
     (if (<= c -2.2e-83)
       (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
       (if (<= c 7e-118)
         (/ (- b (/ (fma (- a) c (/ (* (* b c) c) d)) d)) d)
         (if (<= c 2.25e+77) (/ (fma d b (* c a)) (fma d d (* c c))) t_0))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma((d / c), b, a) / c;
	double tmp;
	if (c <= -2.4e+91) {
		tmp = t_0;
	} else if (c <= -2.2e-83) {
		tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
	} else if (c <= 7e-118) {
		tmp = (b - (fma(-a, c, (((b * c) * c) / d)) / d)) / d;
	} else if (c <= 2.25e+77) {
		tmp = fma(d, b, (c * a)) / fma(d, d, (c * c));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(fma(Float64(d / c), b, a) / c)
	tmp = 0.0
	if (c <= -2.4e+91)
		tmp = t_0;
	elseif (c <= -2.2e-83)
		tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d)));
	elseif (c <= 7e-118)
		tmp = Float64(Float64(b - Float64(fma(Float64(-a), c, Float64(Float64(Float64(b * c) * c) / d)) / d)) / d);
	elseif (c <= 2.25e+77)
		tmp = Float64(fma(d, b, Float64(c * a)) / fma(d, d, Float64(c * c)));
	else
		tmp = t_0;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(d / c), $MachinePrecision] * b + a), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -2.4e+91], t$95$0, If[LessEqual[c, -2.2e-83], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 7e-118], N[(N[(b - N[(N[((-a) * c + N[(N[(N[(b * c), $MachinePrecision] * c), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 2.25e+77], N[(N[(d * b + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\
\mathbf{if}\;c \leq -2.4 \cdot 10^{+91}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;c \leq -2.2 \cdot 10^{-83}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\

\mathbf{elif}\;c \leq 7 \cdot 10^{-118}:\\
\;\;\;\;\frac{b - \frac{\mathsf{fma}\left(-a, c, \frac{\left(b \cdot c\right) \cdot c}{d}\right)}{d}}{d}\\

\mathbf{elif}\;c \leq 2.25 \cdot 10^{+77}:\\
\;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -2.39999999999999983e91 or 2.25000000000000012e77 < c

    1. Initial program 39.7%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around inf

      \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. Applied rewrites86.8%

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}} \]

      if -2.39999999999999983e91 < c < -2.20000000000000008e-83

      1. Initial program 81.7%

        \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
      2. Add Preprocessing

      if -2.20000000000000008e-83 < c < 7e-118

      1. Initial program 67.2%

        \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
      2. Add Preprocessing
      3. Taylor expanded in c around 0

        \[\leadsto \color{blue}{c \cdot \left(-1 \cdot \frac{b \cdot c}{{d}^{3}} + \frac{a}{{d}^{2}}\right) + \frac{b}{d}} \]
      4. Applied rewrites89.3%

        \[\leadsto \color{blue}{\frac{b - \frac{\mathsf{fma}\left(-a, c, \frac{\left(b \cdot c\right) \cdot c}{d}\right)}{d}}{d}} \]

      if 7e-118 < c < 2.25000000000000012e77

      1. Initial program 84.1%

        \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift-+.f64N/A

          \[\leadsto \frac{\color{blue}{a \cdot c + b \cdot d}}{c \cdot c + d \cdot d} \]
        2. +-commutativeN/A

          \[\leadsto \frac{\color{blue}{b \cdot d + a \cdot c}}{c \cdot c + d \cdot d} \]
        3. lift-*.f64N/A

          \[\leadsto \frac{\color{blue}{b \cdot d} + a \cdot c}{c \cdot c + d \cdot d} \]
        4. *-commutativeN/A

          \[\leadsto \frac{\color{blue}{d \cdot b} + a \cdot c}{c \cdot c + d \cdot d} \]
        5. lower-fma.f6484.1

          \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(d, b, a \cdot c\right)}}{c \cdot c + d \cdot d} \]
        6. lift-*.f64N/A

          \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{a \cdot c}\right)}{c \cdot c + d \cdot d} \]
        7. *-commutativeN/A

          \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{c \cdot a}\right)}{c \cdot c + d \cdot d} \]
        8. lower-*.f6484.1

          \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{c \cdot a}\right)}{c \cdot c + d \cdot d} \]
        9. lift-+.f64N/A

          \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{c \cdot c + d \cdot d}} \]
        10. +-commutativeN/A

          \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{d \cdot d + c \cdot c}} \]
        11. lift-*.f64N/A

          \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{d \cdot d} + c \cdot c} \]
        12. lower-fma.f6484.1

          \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
      4. Applied rewrites84.1%

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    5. Recombined 4 regimes into one program.
    6. Add Preprocessing

    Alternative 2: 82.6% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\ \mathbf{if}\;c \leq -2.4 \cdot 10^{+91}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq -2.2 \cdot 10^{-83}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 2.3 \cdot 10^{-117}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\ \mathbf{elif}\;c \leq 2.25 \cdot 10^{+77}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (a b c d)
     :precision binary64
     (let* ((t_0 (/ (fma (/ d c) b a) c)))
       (if (<= c -2.4e+91)
         t_0
         (if (<= c -2.2e-83)
           (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
           (if (<= c 2.3e-117)
             (/ (fma (/ c d) a b) d)
             (if (<= c 2.25e+77) (/ (fma d b (* c a)) (fma d d (* c c))) t_0))))))
    double code(double a, double b, double c, double d) {
    	double t_0 = fma((d / c), b, a) / c;
    	double tmp;
    	if (c <= -2.4e+91) {
    		tmp = t_0;
    	} else if (c <= -2.2e-83) {
    		tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
    	} else if (c <= 2.3e-117) {
    		tmp = fma((c / d), a, b) / d;
    	} else if (c <= 2.25e+77) {
    		tmp = fma(d, b, (c * a)) / fma(d, d, (c * c));
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    function code(a, b, c, d)
    	t_0 = Float64(fma(Float64(d / c), b, a) / c)
    	tmp = 0.0
    	if (c <= -2.4e+91)
    		tmp = t_0;
    	elseif (c <= -2.2e-83)
    		tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d)));
    	elseif (c <= 2.3e-117)
    		tmp = Float64(fma(Float64(c / d), a, b) / d);
    	elseif (c <= 2.25e+77)
    		tmp = Float64(fma(d, b, Float64(c * a)) / fma(d, d, Float64(c * c)));
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(d / c), $MachinePrecision] * b + a), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -2.4e+91], t$95$0, If[LessEqual[c, -2.2e-83], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.3e-117], N[(N[(N[(c / d), $MachinePrecision] * a + b), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 2.25e+77], N[(N[(d * b + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\
    \mathbf{if}\;c \leq -2.4 \cdot 10^{+91}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;c \leq -2.2 \cdot 10^{-83}:\\
    \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
    
    \mathbf{elif}\;c \leq 2.3 \cdot 10^{-117}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\
    
    \mathbf{elif}\;c \leq 2.25 \cdot 10^{+77}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 4 regimes
    2. if c < -2.39999999999999983e91 or 2.25000000000000012e77 < c

      1. Initial program 39.7%

        \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
      2. Add Preprocessing
      3. Taylor expanded in c around inf

        \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
      4. Step-by-step derivation
        1. Applied rewrites86.8%

          \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}} \]

        if -2.39999999999999983e91 < c < -2.20000000000000008e-83

        1. Initial program 81.7%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Add Preprocessing

        if -2.20000000000000008e-83 < c < 2.29999999999999994e-117

        1. Initial program 67.2%

          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
        2. Add Preprocessing
        3. Taylor expanded in c around 0

          \[\leadsto \color{blue}{\frac{b}{d} + \frac{a \cdot c}{{d}^{2}}} \]
        4. Step-by-step derivation
          1. Applied rewrites87.4%

            \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}} \]

          if 2.29999999999999994e-117 < c < 2.25000000000000012e77

          1. Initial program 84.1%

            \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
          2. Add Preprocessing
          3. Step-by-step derivation
            1. lift-+.f64N/A

              \[\leadsto \frac{\color{blue}{a \cdot c + b \cdot d}}{c \cdot c + d \cdot d} \]
            2. +-commutativeN/A

              \[\leadsto \frac{\color{blue}{b \cdot d + a \cdot c}}{c \cdot c + d \cdot d} \]
            3. lift-*.f64N/A

              \[\leadsto \frac{\color{blue}{b \cdot d} + a \cdot c}{c \cdot c + d \cdot d} \]
            4. *-commutativeN/A

              \[\leadsto \frac{\color{blue}{d \cdot b} + a \cdot c}{c \cdot c + d \cdot d} \]
            5. lower-fma.f6484.1

              \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(d, b, a \cdot c\right)}}{c \cdot c + d \cdot d} \]
            6. lift-*.f64N/A

              \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{a \cdot c}\right)}{c \cdot c + d \cdot d} \]
            7. *-commutativeN/A

              \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{c \cdot a}\right)}{c \cdot c + d \cdot d} \]
            8. lower-*.f6484.1

              \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{c \cdot a}\right)}{c \cdot c + d \cdot d} \]
            9. lift-+.f64N/A

              \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{c \cdot c + d \cdot d}} \]
            10. +-commutativeN/A

              \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{d \cdot d + c \cdot c}} \]
            11. lift-*.f64N/A

              \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{d \cdot d} + c \cdot c} \]
            12. lower-fma.f6484.1

              \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
          4. Applied rewrites84.1%

            \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
        5. Recombined 4 regimes into one program.
        6. Add Preprocessing

        Alternative 3: 82.6% accurate, 0.7× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ t_1 := \frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\ \mathbf{if}\;c \leq -2.4 \cdot 10^{+91}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;c \leq -2.2 \cdot 10^{-83}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 2.3 \cdot 10^{-117}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\ \mathbf{elif}\;c \leq 2.25 \cdot 10^{+77}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
        (FPCore (a b c d)
         :precision binary64
         (let* ((t_0 (/ (fma d b (* c a)) (fma d d (* c c))))
                (t_1 (/ (fma (/ d c) b a) c)))
           (if (<= c -2.4e+91)
             t_1
             (if (<= c -2.2e-83)
               t_0
               (if (<= c 2.3e-117)
                 (/ (fma (/ c d) a b) d)
                 (if (<= c 2.25e+77) t_0 t_1))))))
        double code(double a, double b, double c, double d) {
        	double t_0 = fma(d, b, (c * a)) / fma(d, d, (c * c));
        	double t_1 = fma((d / c), b, a) / c;
        	double tmp;
        	if (c <= -2.4e+91) {
        		tmp = t_1;
        	} else if (c <= -2.2e-83) {
        		tmp = t_0;
        	} else if (c <= 2.3e-117) {
        		tmp = fma((c / d), a, b) / d;
        	} else if (c <= 2.25e+77) {
        		tmp = t_0;
        	} else {
        		tmp = t_1;
        	}
        	return tmp;
        }
        
        function code(a, b, c, d)
        	t_0 = Float64(fma(d, b, Float64(c * a)) / fma(d, d, Float64(c * c)))
        	t_1 = Float64(fma(Float64(d / c), b, a) / c)
        	tmp = 0.0
        	if (c <= -2.4e+91)
        		tmp = t_1;
        	elseif (c <= -2.2e-83)
        		tmp = t_0;
        	elseif (c <= 2.3e-117)
        		tmp = Float64(fma(Float64(c / d), a, b) / d);
        	elseif (c <= 2.25e+77)
        		tmp = t_0;
        	else
        		tmp = t_1;
        	end
        	return tmp
        end
        
        code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(d * b + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(d / c), $MachinePrecision] * b + a), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -2.4e+91], t$95$1, If[LessEqual[c, -2.2e-83], t$95$0, If[LessEqual[c, 2.3e-117], N[(N[(N[(c / d), $MachinePrecision] * a + b), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 2.25e+77], t$95$0, t$95$1]]]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
        t_1 := \frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\
        \mathbf{if}\;c \leq -2.4 \cdot 10^{+91}:\\
        \;\;\;\;t\_1\\
        
        \mathbf{elif}\;c \leq -2.2 \cdot 10^{-83}:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;c \leq 2.3 \cdot 10^{-117}:\\
        \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\
        
        \mathbf{elif}\;c \leq 2.25 \cdot 10^{+77}:\\
        \;\;\;\;t\_0\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_1\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if c < -2.39999999999999983e91 or 2.25000000000000012e77 < c

          1. Initial program 39.7%

            \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
          2. Add Preprocessing
          3. Taylor expanded in c around inf

            \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
          4. Step-by-step derivation
            1. Applied rewrites86.8%

              \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}} \]

            if -2.39999999999999983e91 < c < -2.20000000000000008e-83 or 2.29999999999999994e-117 < c < 2.25000000000000012e77

            1. Initial program 83.0%

              \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
            2. Add Preprocessing
            3. Step-by-step derivation
              1. lift-+.f64N/A

                \[\leadsto \frac{\color{blue}{a \cdot c + b \cdot d}}{c \cdot c + d \cdot d} \]
              2. +-commutativeN/A

                \[\leadsto \frac{\color{blue}{b \cdot d + a \cdot c}}{c \cdot c + d \cdot d} \]
              3. lift-*.f64N/A

                \[\leadsto \frac{\color{blue}{b \cdot d} + a \cdot c}{c \cdot c + d \cdot d} \]
              4. *-commutativeN/A

                \[\leadsto \frac{\color{blue}{d \cdot b} + a \cdot c}{c \cdot c + d \cdot d} \]
              5. lower-fma.f6483.0

                \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(d, b, a \cdot c\right)}}{c \cdot c + d \cdot d} \]
              6. lift-*.f64N/A

                \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{a \cdot c}\right)}{c \cdot c + d \cdot d} \]
              7. *-commutativeN/A

                \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{c \cdot a}\right)}{c \cdot c + d \cdot d} \]
              8. lower-*.f6483.0

                \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{c \cdot a}\right)}{c \cdot c + d \cdot d} \]
              9. lift-+.f64N/A

                \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{c \cdot c + d \cdot d}} \]
              10. +-commutativeN/A

                \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{d \cdot d + c \cdot c}} \]
              11. lift-*.f64N/A

                \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{d \cdot d} + c \cdot c} \]
              12. lower-fma.f6483.0

                \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
            4. Applied rewrites83.0%

              \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]

            if -2.20000000000000008e-83 < c < 2.29999999999999994e-117

            1. Initial program 67.2%

              \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
            2. Add Preprocessing
            3. Taylor expanded in c around 0

              \[\leadsto \color{blue}{\frac{b}{d} + \frac{a \cdot c}{{d}^{2}}} \]
            4. Step-by-step derivation
              1. Applied rewrites87.4%

                \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}} \]
            5. Recombined 3 regimes into one program.
            6. Add Preprocessing

            Alternative 4: 72.9% accurate, 0.7× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -9.5 \cdot 10^{+64}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 1.6 \cdot 10^{-17}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\ \mathbf{elif}\;c \leq 3.8 \cdot 10^{+79}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot a\\ \mathbf{elif}\;c \leq 2.65 \cdot 10^{+132}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, a, b \cdot d\right)}{c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \end{array} \]
            (FPCore (a b c d)
             :precision binary64
             (if (<= c -9.5e+64)
               (/ a c)
               (if (<= c 1.6e-17)
                 (/ (fma (/ c d) a b) d)
                 (if (<= c 3.8e+79)
                   (* (/ c (fma d d (* c c))) a)
                   (if (<= c 2.65e+132) (/ (fma c a (* b d)) (* c c)) (/ a c))))))
            double code(double a, double b, double c, double d) {
            	double tmp;
            	if (c <= -9.5e+64) {
            		tmp = a / c;
            	} else if (c <= 1.6e-17) {
            		tmp = fma((c / d), a, b) / d;
            	} else if (c <= 3.8e+79) {
            		tmp = (c / fma(d, d, (c * c))) * a;
            	} else if (c <= 2.65e+132) {
            		tmp = fma(c, a, (b * d)) / (c * c);
            	} else {
            		tmp = a / c;
            	}
            	return tmp;
            }
            
            function code(a, b, c, d)
            	tmp = 0.0
            	if (c <= -9.5e+64)
            		tmp = Float64(a / c);
            	elseif (c <= 1.6e-17)
            		tmp = Float64(fma(Float64(c / d), a, b) / d);
            	elseif (c <= 3.8e+79)
            		tmp = Float64(Float64(c / fma(d, d, Float64(c * c))) * a);
            	elseif (c <= 2.65e+132)
            		tmp = Float64(fma(c, a, Float64(b * d)) / Float64(c * c));
            	else
            		tmp = Float64(a / c);
            	end
            	return tmp
            end
            
            code[a_, b_, c_, d_] := If[LessEqual[c, -9.5e+64], N[(a / c), $MachinePrecision], If[LessEqual[c, 1.6e-17], N[(N[(N[(c / d), $MachinePrecision] * a + b), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 3.8e+79], N[(N[(c / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[c, 2.65e+132], N[(N[(c * a + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], N[(a / c), $MachinePrecision]]]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;c \leq -9.5 \cdot 10^{+64}:\\
            \;\;\;\;\frac{a}{c}\\
            
            \mathbf{elif}\;c \leq 1.6 \cdot 10^{-17}:\\
            \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\
            
            \mathbf{elif}\;c \leq 3.8 \cdot 10^{+79}:\\
            \;\;\;\;\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot a\\
            
            \mathbf{elif}\;c \leq 2.65 \cdot 10^{+132}:\\
            \;\;\;\;\frac{\mathsf{fma}\left(c, a, b \cdot d\right)}{c \cdot c}\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{a}{c}\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 4 regimes
            2. if c < -9.50000000000000028e64 or 2.65e132 < c

              1. Initial program 37.9%

                \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
              2. Add Preprocessing
              3. Taylor expanded in c around inf

                \[\leadsto \color{blue}{\frac{a}{c}} \]
              4. Step-by-step derivation
                1. Applied rewrites76.0%

                  \[\leadsto \color{blue}{\frac{a}{c}} \]

                if -9.50000000000000028e64 < c < 1.6000000000000001e-17

                1. Initial program 71.8%

                  \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
                2. Add Preprocessing
                3. Taylor expanded in c around 0

                  \[\leadsto \color{blue}{\frac{b}{d} + \frac{a \cdot c}{{d}^{2}}} \]
                4. Step-by-step derivation
                  1. Applied rewrites80.0%

                    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}} \]

                  if 1.6000000000000001e-17 < c < 3.8000000000000002e79

                  1. Initial program 80.4%

                    \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
                  2. Add Preprocessing
                  3. Taylor expanded in a around inf

                    \[\leadsto \color{blue}{\frac{a \cdot c}{{c}^{2} + {d}^{2}}} \]
                  4. Step-by-step derivation
                    1. Applied rewrites76.0%

                      \[\leadsto \color{blue}{\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot a} \]

                    if 3.8000000000000002e79 < c < 2.65e132

                    1. Initial program 84.9%

                      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
                    2. Add Preprocessing
                    3. Step-by-step derivation
                      1. lift-+.f64N/A

                        \[\leadsto \frac{\color{blue}{a \cdot c + b \cdot d}}{c \cdot c + d \cdot d} \]
                      2. +-commutativeN/A

                        \[\leadsto \frac{\color{blue}{b \cdot d + a \cdot c}}{c \cdot c + d \cdot d} \]
                      3. lift-*.f64N/A

                        \[\leadsto \frac{\color{blue}{b \cdot d} + a \cdot c}{c \cdot c + d \cdot d} \]
                      4. *-commutativeN/A

                        \[\leadsto \frac{\color{blue}{d \cdot b} + a \cdot c}{c \cdot c + d \cdot d} \]
                      5. lower-fma.f6484.9

                        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(d, b, a \cdot c\right)}}{c \cdot c + d \cdot d} \]
                      6. lift-*.f64N/A

                        \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{a \cdot c}\right)}{c \cdot c + d \cdot d} \]
                      7. *-commutativeN/A

                        \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{c \cdot a}\right)}{c \cdot c + d \cdot d} \]
                      8. lower-*.f6484.9

                        \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{c \cdot a}\right)}{c \cdot c + d \cdot d} \]
                      9. lift-+.f64N/A

                        \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{c \cdot c + d \cdot d}} \]
                      10. +-commutativeN/A

                        \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{d \cdot d + c \cdot c}} \]
                      11. lift-*.f64N/A

                        \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{d \cdot d} + c \cdot c} \]
                      12. lower-fma.f6484.9

                        \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
                    4. Applied rewrites84.9%

                      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
                    5. Taylor expanded in c around inf

                      \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{{c}^{2}}} \]
                    6. Step-by-step derivation
                      1. Applied rewrites84.6%

                        \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{c \cdot c}} \]
                      2. Step-by-step derivation
                        1. lift-fma.f64N/A

                          \[\leadsto \frac{\color{blue}{d \cdot b + c \cdot a}}{c \cdot c} \]
                        2. +-commutativeN/A

                          \[\leadsto \frac{\color{blue}{c \cdot a + d \cdot b}}{c \cdot c} \]
                        3. lift-*.f64N/A

                          \[\leadsto \frac{\color{blue}{c \cdot a} + d \cdot b}{c \cdot c} \]
                        4. lower-fma.f64N/A

                          \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, a, d \cdot b\right)}}{c \cdot c} \]
                        5. *-commutativeN/A

                          \[\leadsto \frac{\mathsf{fma}\left(c, a, \color{blue}{b \cdot d}\right)}{c \cdot c} \]
                        6. lower-*.f6484.8

                          \[\leadsto \frac{\mathsf{fma}\left(c, a, \color{blue}{b \cdot d}\right)}{c \cdot c} \]
                      3. Applied rewrites84.8%

                        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, a, b \cdot d\right)}}{c \cdot c} \]
                    7. Recombined 4 regimes into one program.
                    8. Add Preprocessing

                    Alternative 5: 64.6% accurate, 0.7× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -3.5 \cdot 10^{-14}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 7 \cdot 10^{-117}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 3.8 \cdot 10^{+79}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot a\\ \mathbf{elif}\;c \leq 2.65 \cdot 10^{+132}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, a, b \cdot d\right)}{c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \end{array} \]
                    (FPCore (a b c d)
                     :precision binary64
                     (if (<= c -3.5e-14)
                       (/ a c)
                       (if (<= c 7e-117)
                         (/ b d)
                         (if (<= c 3.8e+79)
                           (* (/ c (fma d d (* c c))) a)
                           (if (<= c 2.65e+132) (/ (fma c a (* b d)) (* c c)) (/ a c))))))
                    double code(double a, double b, double c, double d) {
                    	double tmp;
                    	if (c <= -3.5e-14) {
                    		tmp = a / c;
                    	} else if (c <= 7e-117) {
                    		tmp = b / d;
                    	} else if (c <= 3.8e+79) {
                    		tmp = (c / fma(d, d, (c * c))) * a;
                    	} else if (c <= 2.65e+132) {
                    		tmp = fma(c, a, (b * d)) / (c * c);
                    	} else {
                    		tmp = a / c;
                    	}
                    	return tmp;
                    }
                    
                    function code(a, b, c, d)
                    	tmp = 0.0
                    	if (c <= -3.5e-14)
                    		tmp = Float64(a / c);
                    	elseif (c <= 7e-117)
                    		tmp = Float64(b / d);
                    	elseif (c <= 3.8e+79)
                    		tmp = Float64(Float64(c / fma(d, d, Float64(c * c))) * a);
                    	elseif (c <= 2.65e+132)
                    		tmp = Float64(fma(c, a, Float64(b * d)) / Float64(c * c));
                    	else
                    		tmp = Float64(a / c);
                    	end
                    	return tmp
                    end
                    
                    code[a_, b_, c_, d_] := If[LessEqual[c, -3.5e-14], N[(a / c), $MachinePrecision], If[LessEqual[c, 7e-117], N[(b / d), $MachinePrecision], If[LessEqual[c, 3.8e+79], N[(N[(c / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[c, 2.65e+132], N[(N[(c * a + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], N[(a / c), $MachinePrecision]]]]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;c \leq -3.5 \cdot 10^{-14}:\\
                    \;\;\;\;\frac{a}{c}\\
                    
                    \mathbf{elif}\;c \leq 7 \cdot 10^{-117}:\\
                    \;\;\;\;\frac{b}{d}\\
                    
                    \mathbf{elif}\;c \leq 3.8 \cdot 10^{+79}:\\
                    \;\;\;\;\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot a\\
                    
                    \mathbf{elif}\;c \leq 2.65 \cdot 10^{+132}:\\
                    \;\;\;\;\frac{\mathsf{fma}\left(c, a, b \cdot d\right)}{c \cdot c}\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;\frac{a}{c}\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 4 regimes
                    2. if c < -3.5000000000000002e-14 or 2.65e132 < c

                      1. Initial program 41.8%

                        \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
                      2. Add Preprocessing
                      3. Taylor expanded in c around inf

                        \[\leadsto \color{blue}{\frac{a}{c}} \]
                      4. Step-by-step derivation
                        1. Applied rewrites71.3%

                          \[\leadsto \color{blue}{\frac{a}{c}} \]

                        if -3.5000000000000002e-14 < c < 6.9999999999999997e-117

                        1. Initial program 69.9%

                          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
                        2. Add Preprocessing
                        3. Taylor expanded in c around 0

                          \[\leadsto \color{blue}{\frac{b}{d}} \]
                        4. Step-by-step derivation
                          1. Applied rewrites74.0%

                            \[\leadsto \color{blue}{\frac{b}{d}} \]

                          if 6.9999999999999997e-117 < c < 3.8000000000000002e79

                          1. Initial program 82.0%

                            \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
                          2. Add Preprocessing
                          3. Taylor expanded in a around inf

                            \[\leadsto \color{blue}{\frac{a \cdot c}{{c}^{2} + {d}^{2}}} \]
                          4. Step-by-step derivation
                            1. Applied rewrites71.1%

                              \[\leadsto \color{blue}{\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot a} \]

                            if 3.8000000000000002e79 < c < 2.65e132

                            1. Initial program 84.9%

                              \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
                            2. Add Preprocessing
                            3. Step-by-step derivation
                              1. lift-+.f64N/A

                                \[\leadsto \frac{\color{blue}{a \cdot c + b \cdot d}}{c \cdot c + d \cdot d} \]
                              2. +-commutativeN/A

                                \[\leadsto \frac{\color{blue}{b \cdot d + a \cdot c}}{c \cdot c + d \cdot d} \]
                              3. lift-*.f64N/A

                                \[\leadsto \frac{\color{blue}{b \cdot d} + a \cdot c}{c \cdot c + d \cdot d} \]
                              4. *-commutativeN/A

                                \[\leadsto \frac{\color{blue}{d \cdot b} + a \cdot c}{c \cdot c + d \cdot d} \]
                              5. lower-fma.f6484.9

                                \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(d, b, a \cdot c\right)}}{c \cdot c + d \cdot d} \]
                              6. lift-*.f64N/A

                                \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{a \cdot c}\right)}{c \cdot c + d \cdot d} \]
                              7. *-commutativeN/A

                                \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{c \cdot a}\right)}{c \cdot c + d \cdot d} \]
                              8. lower-*.f6484.9

                                \[\leadsto \frac{\mathsf{fma}\left(d, b, \color{blue}{c \cdot a}\right)}{c \cdot c + d \cdot d} \]
                              9. lift-+.f64N/A

                                \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{c \cdot c + d \cdot d}} \]
                              10. +-commutativeN/A

                                \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{d \cdot d + c \cdot c}} \]
                              11. lift-*.f64N/A

                                \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{d \cdot d} + c \cdot c} \]
                              12. lower-fma.f6484.9

                                \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
                            4. Applied rewrites84.9%

                              \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
                            5. Taylor expanded in c around inf

                              \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{{c}^{2}}} \]
                            6. Step-by-step derivation
                              1. Applied rewrites84.6%

                                \[\leadsto \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\color{blue}{c \cdot c}} \]
                              2. Step-by-step derivation
                                1. lift-fma.f64N/A

                                  \[\leadsto \frac{\color{blue}{d \cdot b + c \cdot a}}{c \cdot c} \]
                                2. +-commutativeN/A

                                  \[\leadsto \frac{\color{blue}{c \cdot a + d \cdot b}}{c \cdot c} \]
                                3. lift-*.f64N/A

                                  \[\leadsto \frac{\color{blue}{c \cdot a} + d \cdot b}{c \cdot c} \]
                                4. lower-fma.f64N/A

                                  \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, a, d \cdot b\right)}}{c \cdot c} \]
                                5. *-commutativeN/A

                                  \[\leadsto \frac{\mathsf{fma}\left(c, a, \color{blue}{b \cdot d}\right)}{c \cdot c} \]
                                6. lower-*.f6484.8

                                  \[\leadsto \frac{\mathsf{fma}\left(c, a, \color{blue}{b \cdot d}\right)}{c \cdot c} \]
                              3. Applied rewrites84.8%

                                \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, a, b \cdot d\right)}}{c \cdot c} \]
                            7. Recombined 4 regimes into one program.
                            8. Add Preprocessing

                            Alternative 6: 64.6% accurate, 0.8× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -3.5 \cdot 10^{-14}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 7 \cdot 10^{-117}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 7.5 \cdot 10^{+79}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot a\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \end{array} \]
                            (FPCore (a b c d)
                             :precision binary64
                             (if (<= c -3.5e-14)
                               (/ a c)
                               (if (<= c 7e-117)
                                 (/ b d)
                                 (if (<= c 7.5e+79) (* (/ c (fma d d (* c c))) a) (/ a c)))))
                            double code(double a, double b, double c, double d) {
                            	double tmp;
                            	if (c <= -3.5e-14) {
                            		tmp = a / c;
                            	} else if (c <= 7e-117) {
                            		tmp = b / d;
                            	} else if (c <= 7.5e+79) {
                            		tmp = (c / fma(d, d, (c * c))) * a;
                            	} else {
                            		tmp = a / c;
                            	}
                            	return tmp;
                            }
                            
                            function code(a, b, c, d)
                            	tmp = 0.0
                            	if (c <= -3.5e-14)
                            		tmp = Float64(a / c);
                            	elseif (c <= 7e-117)
                            		tmp = Float64(b / d);
                            	elseif (c <= 7.5e+79)
                            		tmp = Float64(Float64(c / fma(d, d, Float64(c * c))) * a);
                            	else
                            		tmp = Float64(a / c);
                            	end
                            	return tmp
                            end
                            
                            code[a_, b_, c_, d_] := If[LessEqual[c, -3.5e-14], N[(a / c), $MachinePrecision], If[LessEqual[c, 7e-117], N[(b / d), $MachinePrecision], If[LessEqual[c, 7.5e+79], N[(N[(c / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], N[(a / c), $MachinePrecision]]]]
                            
                            \begin{array}{l}
                            
                            \\
                            \begin{array}{l}
                            \mathbf{if}\;c \leq -3.5 \cdot 10^{-14}:\\
                            \;\;\;\;\frac{a}{c}\\
                            
                            \mathbf{elif}\;c \leq 7 \cdot 10^{-117}:\\
                            \;\;\;\;\frac{b}{d}\\
                            
                            \mathbf{elif}\;c \leq 7.5 \cdot 10^{+79}:\\
                            \;\;\;\;\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot a\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;\frac{a}{c}\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 3 regimes
                            2. if c < -3.5000000000000002e-14 or 7.49999999999999967e79 < c

                              1. Initial program 46.6%

                                \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
                              2. Add Preprocessing
                              3. Taylor expanded in c around inf

                                \[\leadsto \color{blue}{\frac{a}{c}} \]
                              4. Step-by-step derivation
                                1. Applied rewrites69.4%

                                  \[\leadsto \color{blue}{\frac{a}{c}} \]

                                if -3.5000000000000002e-14 < c < 6.9999999999999997e-117

                                1. Initial program 69.9%

                                  \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
                                2. Add Preprocessing
                                3. Taylor expanded in c around 0

                                  \[\leadsto \color{blue}{\frac{b}{d}} \]
                                4. Step-by-step derivation
                                  1. Applied rewrites74.0%

                                    \[\leadsto \color{blue}{\frac{b}{d}} \]

                                  if 6.9999999999999997e-117 < c < 7.49999999999999967e79

                                  1. Initial program 82.0%

                                    \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
                                  2. Add Preprocessing
                                  3. Taylor expanded in a around inf

                                    \[\leadsto \color{blue}{\frac{a \cdot c}{{c}^{2} + {d}^{2}}} \]
                                  4. Step-by-step derivation
                                    1. Applied rewrites71.1%

                                      \[\leadsto \color{blue}{\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot a} \]
                                  5. Recombined 3 regimes into one program.
                                  6. Add Preprocessing

                                  Alternative 7: 78.5% accurate, 0.9× speedup?

                                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -3 \cdot 10^{+39} \lor \neg \left(d \leq 4.9 \cdot 10^{-9}\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\ \end{array} \end{array} \]
                                  (FPCore (a b c d)
                                   :precision binary64
                                   (if (or (<= d -3e+39) (not (<= d 4.9e-9)))
                                     (/ (fma (/ c d) a b) d)
                                     (/ (fma (/ d c) b a) c)))
                                  double code(double a, double b, double c, double d) {
                                  	double tmp;
                                  	if ((d <= -3e+39) || !(d <= 4.9e-9)) {
                                  		tmp = fma((c / d), a, b) / d;
                                  	} else {
                                  		tmp = fma((d / c), b, a) / c;
                                  	}
                                  	return tmp;
                                  }
                                  
                                  function code(a, b, c, d)
                                  	tmp = 0.0
                                  	if ((d <= -3e+39) || !(d <= 4.9e-9))
                                  		tmp = Float64(fma(Float64(c / d), a, b) / d);
                                  	else
                                  		tmp = Float64(fma(Float64(d / c), b, a) / c);
                                  	end
                                  	return tmp
                                  end
                                  
                                  code[a_, b_, c_, d_] := If[Or[LessEqual[d, -3e+39], N[Not[LessEqual[d, 4.9e-9]], $MachinePrecision]], N[(N[(N[(c / d), $MachinePrecision] * a + b), $MachinePrecision] / d), $MachinePrecision], N[(N[(N[(d / c), $MachinePrecision] * b + a), $MachinePrecision] / c), $MachinePrecision]]
                                  
                                  \begin{array}{l}
                                  
                                  \\
                                  \begin{array}{l}
                                  \mathbf{if}\;d \leq -3 \cdot 10^{+39} \lor \neg \left(d \leq 4.9 \cdot 10^{-9}\right):\\
                                  \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\
                                  
                                  \mathbf{else}:\\
                                  \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\
                                  
                                  
                                  \end{array}
                                  \end{array}
                                  
                                  Derivation
                                  1. Split input into 2 regimes
                                  2. if d < -3e39 or 4.90000000000000004e-9 < d

                                    1. Initial program 48.6%

                                      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
                                    2. Add Preprocessing
                                    3. Taylor expanded in c around 0

                                      \[\leadsto \color{blue}{\frac{b}{d} + \frac{a \cdot c}{{d}^{2}}} \]
                                    4. Step-by-step derivation
                                      1. Applied rewrites76.1%

                                        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}} \]

                                      if -3e39 < d < 4.90000000000000004e-9

                                      1. Initial program 73.6%

                                        \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
                                      2. Add Preprocessing
                                      3. Taylor expanded in c around inf

                                        \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
                                      4. Step-by-step derivation
                                        1. Applied rewrites87.2%

                                          \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}} \]
                                      5. Recombined 2 regimes into one program.
                                      6. Final simplification81.5%

                                        \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3 \cdot 10^{+39} \lor \neg \left(d \leq 4.9 \cdot 10^{-9}\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\ \end{array} \]
                                      7. Add Preprocessing

                                      Alternative 8: 61.9% accurate, 1.6× speedup?

                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -3.5 \cdot 10^{-14} \lor \neg \left(c \leq 8.5 \cdot 10^{-117}\right):\\ \;\;\;\;\frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \end{array} \]
                                      (FPCore (a b c d)
                                       :precision binary64
                                       (if (or (<= c -3.5e-14) (not (<= c 8.5e-117))) (/ a c) (/ b d)))
                                      double code(double a, double b, double c, double d) {
                                      	double tmp;
                                      	if ((c <= -3.5e-14) || !(c <= 8.5e-117)) {
                                      		tmp = a / c;
                                      	} else {
                                      		tmp = b / d;
                                      	}
                                      	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(a, b, c, d)
                                      use fmin_fmax_functions
                                          real(8), intent (in) :: a
                                          real(8), intent (in) :: b
                                          real(8), intent (in) :: c
                                          real(8), intent (in) :: d
                                          real(8) :: tmp
                                          if ((c <= (-3.5d-14)) .or. (.not. (c <= 8.5d-117))) then
                                              tmp = a / c
                                          else
                                              tmp = b / d
                                          end if
                                          code = tmp
                                      end function
                                      
                                      public static double code(double a, double b, double c, double d) {
                                      	double tmp;
                                      	if ((c <= -3.5e-14) || !(c <= 8.5e-117)) {
                                      		tmp = a / c;
                                      	} else {
                                      		tmp = b / d;
                                      	}
                                      	return tmp;
                                      }
                                      
                                      def code(a, b, c, d):
                                      	tmp = 0
                                      	if (c <= -3.5e-14) or not (c <= 8.5e-117):
                                      		tmp = a / c
                                      	else:
                                      		tmp = b / d
                                      	return tmp
                                      
                                      function code(a, b, c, d)
                                      	tmp = 0.0
                                      	if ((c <= -3.5e-14) || !(c <= 8.5e-117))
                                      		tmp = Float64(a / c);
                                      	else
                                      		tmp = Float64(b / d);
                                      	end
                                      	return tmp
                                      end
                                      
                                      function tmp_2 = code(a, b, c, d)
                                      	tmp = 0.0;
                                      	if ((c <= -3.5e-14) || ~((c <= 8.5e-117)))
                                      		tmp = a / c;
                                      	else
                                      		tmp = b / d;
                                      	end
                                      	tmp_2 = tmp;
                                      end
                                      
                                      code[a_, b_, c_, d_] := If[Or[LessEqual[c, -3.5e-14], N[Not[LessEqual[c, 8.5e-117]], $MachinePrecision]], N[(a / c), $MachinePrecision], N[(b / d), $MachinePrecision]]
                                      
                                      \begin{array}{l}
                                      
                                      \\
                                      \begin{array}{l}
                                      \mathbf{if}\;c \leq -3.5 \cdot 10^{-14} \lor \neg \left(c \leq 8.5 \cdot 10^{-117}\right):\\
                                      \;\;\;\;\frac{a}{c}\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;\frac{b}{d}\\
                                      
                                      
                                      \end{array}
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 2 regimes
                                      2. if c < -3.5000000000000002e-14 or 8.49999999999999981e-117 < c

                                        1. Initial program 55.2%

                                          \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
                                        2. Add Preprocessing
                                        3. Taylor expanded in c around inf

                                          \[\leadsto \color{blue}{\frac{a}{c}} \]
                                        4. Step-by-step derivation
                                          1. Applied rewrites63.4%

                                            \[\leadsto \color{blue}{\frac{a}{c}} \]

                                          if -3.5000000000000002e-14 < c < 8.49999999999999981e-117

                                          1. Initial program 69.9%

                                            \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
                                          2. Add Preprocessing
                                          3. Taylor expanded in c around 0

                                            \[\leadsto \color{blue}{\frac{b}{d}} \]
                                          4. Step-by-step derivation
                                            1. Applied rewrites74.0%

                                              \[\leadsto \color{blue}{\frac{b}{d}} \]
                                          5. Recombined 2 regimes into one program.
                                          6. Final simplification67.5%

                                            \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.5 \cdot 10^{-14} \lor \neg \left(c \leq 8.5 \cdot 10^{-117}\right):\\ \;\;\;\;\frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \]
                                          7. Add Preprocessing

                                          Alternative 9: 42.6% accurate, 3.2× speedup?

                                          \[\begin{array}{l} \\ \frac{a}{c} \end{array} \]
                                          (FPCore (a b c d) :precision binary64 (/ a c))
                                          double code(double a, double b, double c, double d) {
                                          	return a / c;
                                          }
                                          
                                          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(a, b, c, d)
                                          use fmin_fmax_functions
                                              real(8), intent (in) :: a
                                              real(8), intent (in) :: b
                                              real(8), intent (in) :: c
                                              real(8), intent (in) :: d
                                              code = a / c
                                          end function
                                          
                                          public static double code(double a, double b, double c, double d) {
                                          	return a / c;
                                          }
                                          
                                          def code(a, b, c, d):
                                          	return a / c
                                          
                                          function code(a, b, c, d)
                                          	return Float64(a / c)
                                          end
                                          
                                          function tmp = code(a, b, c, d)
                                          	tmp = a / c;
                                          end
                                          
                                          code[a_, b_, c_, d_] := N[(a / c), $MachinePrecision]
                                          
                                          \begin{array}{l}
                                          
                                          \\
                                          \frac{a}{c}
                                          \end{array}
                                          
                                          Derivation
                                          1. Initial program 60.9%

                                            \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
                                          2. Add Preprocessing
                                          3. Taylor expanded in c around inf

                                            \[\leadsto \color{blue}{\frac{a}{c}} \]
                                          4. Step-by-step derivation
                                            1. Applied rewrites44.2%

                                              \[\leadsto \color{blue}{\frac{a}{c}} \]
                                            2. Add Preprocessing

                                            Developer Target 1: 99.3% accurate, 0.6× speedup?

                                            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|d\right| < \left|c\right|:\\ \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\ \end{array} \end{array} \]
                                            (FPCore (a b c d)
                                             :precision binary64
                                             (if (< (fabs d) (fabs c))
                                               (/ (+ a (* b (/ d c))) (+ c (* d (/ d c))))
                                               (/ (+ b (* a (/ c d))) (+ d (* c (/ c d))))))
                                            double code(double a, double b, double c, double d) {
                                            	double tmp;
                                            	if (fabs(d) < fabs(c)) {
                                            		tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
                                            	} else {
                                            		tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
                                            	}
                                            	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(a, b, c, d)
                                            use fmin_fmax_functions
                                                real(8), intent (in) :: a
                                                real(8), intent (in) :: b
                                                real(8), intent (in) :: c
                                                real(8), intent (in) :: d
                                                real(8) :: tmp
                                                if (abs(d) < abs(c)) then
                                                    tmp = (a + (b * (d / c))) / (c + (d * (d / c)))
                                                else
                                                    tmp = (b + (a * (c / d))) / (d + (c * (c / d)))
                                                end if
                                                code = tmp
                                            end function
                                            
                                            public static double code(double a, double b, double c, double d) {
                                            	double tmp;
                                            	if (Math.abs(d) < Math.abs(c)) {
                                            		tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
                                            	} else {
                                            		tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
                                            	}
                                            	return tmp;
                                            }
                                            
                                            def code(a, b, c, d):
                                            	tmp = 0
                                            	if math.fabs(d) < math.fabs(c):
                                            		tmp = (a + (b * (d / c))) / (c + (d * (d / c)))
                                            	else:
                                            		tmp = (b + (a * (c / d))) / (d + (c * (c / d)))
                                            	return tmp
                                            
                                            function code(a, b, c, d)
                                            	tmp = 0.0
                                            	if (abs(d) < abs(c))
                                            		tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c))));
                                            	else
                                            		tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d))));
                                            	end
                                            	return tmp
                                            end
                                            
                                            function tmp_2 = code(a, b, c, d)
                                            	tmp = 0.0;
                                            	if (abs(d) < abs(c))
                                            		tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
                                            	else
                                            		tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
                                            	end
                                            	tmp_2 = tmp;
                                            end
                                            
                                            code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                            
                                            \begin{array}{l}
                                            
                                            \\
                                            \begin{array}{l}
                                            \mathbf{if}\;\left|d\right| < \left|c\right|:\\
                                            \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
                                            
                                            \mathbf{else}:\\
                                            \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
                                            
                                            
                                            \end{array}
                                            \end{array}
                                            

                                            Reproduce

                                            ?
                                            herbie shell --seed 2025056 
                                            (FPCore (a b c d)
                                              :name "Complex division, real part"
                                              :precision binary64
                                            
                                              :alt
                                              (! :herbie-platform default (if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d))))))
                                            
                                              (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))