Complex division, real part

Percentage Accurate: 61.3% → 81.2%
Time: 3.8s
Alternatives: 6
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}

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 6 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.3% 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.2% accurate, 0.6× speedup?

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

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

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{a + \frac{b \cdot d}{c}}{c}\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if c < -1.05e128

    1. Initial program 35.6%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{a \cdot c}{c \cdot c + d \cdot d} \cdot \frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d} \cdot \frac{b \cdot d}{c \cdot c + d \cdot d}}{\frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d}}} \]
    3. Applied rewrites7.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{a}{c}} \]
    7. Step-by-step derivation
      1. lower-/.f6477.7

        \[\leadsto \frac{a}{\color{blue}{c}} \]
    8. Applied rewrites77.7%

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

    if -1.05e128 < c < -1.4499999999999999e-26

    1. Initial program 73.0%

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

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

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

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

        \[\leadsto \frac{\color{blue}{a \cdot c}}{c \cdot c + d \cdot d} + \frac{b \cdot d}{c \cdot c + d \cdot d} \]
      5. associate-/l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.4499999999999999e-26 < c < 4.60000000000000014e-145

    1. Initial program 71.7%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{a \cdot c}{c \cdot c + d \cdot d} \cdot \frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d} \cdot \frac{b \cdot d}{c \cdot c + d \cdot d}}{\frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d}}} \]
    3. Applied rewrites28.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
    7. Step-by-step derivation
      1. lower-/.f64N/A

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

        \[\leadsto \frac{b + \frac{a \cdot c}{d}}{d} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{b + \frac{a \cdot c}{d}}{d} \]
      4. lift-*.f6486.9

        \[\leadsto \frac{b + \frac{a \cdot c}{d}}{d} \]
    8. Applied rewrites86.9%

      \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]

    if 4.60000000000000014e-145 < c < 2.3000000000000002e88

    1. Initial program 76.9%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. 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.f6476.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-*.f6476.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.f6476.9

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

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

    if 2.3000000000000002e88 < c

    1. Initial program 39.6%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{a \cdot c}{c \cdot c + d \cdot d} \cdot \frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d} \cdot \frac{b \cdot d}{c \cdot c + d \cdot d}}{\frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d}}} \]
    3. Applied rewrites15.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
    7. Step-by-step derivation
      1. lower-/.f64N/A

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

        \[\leadsto \frac{a + \frac{b \cdot d}{c}}{c} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{a + \frac{b \cdot d}{c}}{c} \]
      4. lower-*.f6478.1

        \[\leadsto \frac{a + \frac{b \cdot d}{c}}{c} \]
    8. Applied rewrites78.1%

      \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
  3. Recombined 5 regimes into one program.
  4. Add Preprocessing

Alternative 2: 80.3% 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)}\\ \mathbf{if}\;c \leq -1 \cdot 10^{+114}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq -1.45 \cdot 10^{-26}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 4.6 \cdot 10^{-145}:\\ \;\;\;\;\frac{b + \frac{a \cdot c}{d}}{d}\\ \mathbf{elif}\;c \leq 2.3 \cdot 10^{+88}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{a + \frac{b \cdot d}{c}}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (fma d b (* c a)) (fma d d (* c c)))))
   (if (<= c -1e+114)
     (/ a c)
     (if (<= c -1.45e-26)
       t_0
       (if (<= c 4.6e-145)
         (/ (+ b (/ (* a c) d)) d)
         (if (<= c 2.3e+88) t_0 (/ (+ a (/ (* b d) c)) c)))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(d, b, (c * a)) / fma(d, d, (c * c));
	double tmp;
	if (c <= -1e+114) {
		tmp = a / c;
	} else if (c <= -1.45e-26) {
		tmp = t_0;
	} else if (c <= 4.6e-145) {
		tmp = (b + ((a * c) / d)) / d;
	} else if (c <= 2.3e+88) {
		tmp = t_0;
	} else {
		tmp = (a + ((b * d) / c)) / c;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(fma(d, b, Float64(c * a)) / fma(d, d, Float64(c * c)))
	tmp = 0.0
	if (c <= -1e+114)
		tmp = Float64(a / c);
	elseif (c <= -1.45e-26)
		tmp = t_0;
	elseif (c <= 4.6e-145)
		tmp = Float64(Float64(b + Float64(Float64(a * c) / d)) / d);
	elseif (c <= 2.3e+88)
		tmp = t_0;
	else
		tmp = Float64(Float64(a + Float64(Float64(b * d) / c)) / c);
	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]}, If[LessEqual[c, -1e+114], N[(a / c), $MachinePrecision], If[LessEqual[c, -1.45e-26], t$95$0, If[LessEqual[c, 4.6e-145], N[(N[(b + N[(N[(a * c), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 2.3e+88], t$95$0, N[(N[(a + N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]]]
\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)}\\
\mathbf{if}\;c \leq -1 \cdot 10^{+114}:\\
\;\;\;\;\frac{a}{c}\\

\mathbf{elif}\;c \leq -1.45 \cdot 10^{-26}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 2.3 \cdot 10^{+88}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\frac{a + \frac{b \cdot d}{c}}{c}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -1e114

    1. Initial program 37.5%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{a \cdot c}{c \cdot c + d \cdot d} \cdot \frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d} \cdot \frac{b \cdot d}{c \cdot c + d \cdot d}}{\frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d}}} \]
    3. Applied rewrites10.5%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\left(c \cdot \frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \cdot \left(c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)} - \left(d \cdot \frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \cdot \frac{\color{blue}{b \cdot d}}{\mathsf{fma}\left(d, d, c \cdot c\right)}}{c \cdot \frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)} - d \cdot \frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    5. Applied rewrites6.6%

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

      \[\leadsto \color{blue}{\frac{a}{c}} \]
    7. Step-by-step derivation
      1. lower-/.f6476.7

        \[\leadsto \frac{a}{\color{blue}{c}} \]
    8. Applied rewrites76.7%

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

    if -1e114 < c < -1.4499999999999999e-26 or 4.60000000000000014e-145 < c < 2.3000000000000002e88

    1. Initial program 75.8%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. 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.f6475.8

        \[\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-*.f6475.8

        \[\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.f6475.8

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

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

    if -1.4499999999999999e-26 < c < 4.60000000000000014e-145

    1. Initial program 71.7%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{a \cdot c}{c \cdot c + d \cdot d} \cdot \frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d} \cdot \frac{b \cdot d}{c \cdot c + d \cdot d}}{\frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d}}} \]
    3. Applied rewrites28.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
    7. Step-by-step derivation
      1. lower-/.f64N/A

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

        \[\leadsto \frac{b + \frac{a \cdot c}{d}}{d} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{b + \frac{a \cdot c}{d}}{d} \]
      4. lift-*.f6486.9

        \[\leadsto \frac{b + \frac{a \cdot c}{d}}{d} \]
    8. Applied rewrites86.9%

      \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]

    if 2.3000000000000002e88 < c

    1. Initial program 39.6%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{a \cdot c}{c \cdot c + d \cdot d} \cdot \frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d} \cdot \frac{b \cdot d}{c \cdot c + d \cdot d}}{\frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d}}} \]
    3. Applied rewrites15.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
    7. Step-by-step derivation
      1. lower-/.f64N/A

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

        \[\leadsto \frac{a + \frac{b \cdot d}{c}}{c} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{a + \frac{b \cdot d}{c}}{c} \]
      4. lower-*.f6478.1

        \[\leadsto \frac{a + \frac{b \cdot d}{c}}{c} \]
    8. Applied rewrites78.1%

      \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 3: 76.1% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{a + \frac{b \cdot d}{c}}{c}\\ \mathbf{if}\;c \leq -4.7 \cdot 10^{+58}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 1.02 \cdot 10^{-8}:\\ \;\;\;\;\frac{b + \frac{a \cdot c}{d}}{d}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (+ a (/ (* b d) c)) c)))
   (if (<= c -4.7e+58) t_0 (if (<= c 1.02e-8) (/ (+ b (/ (* a c) d)) d) t_0))))
double code(double a, double b, double c, double d) {
	double t_0 = (a + ((b * d) / c)) / c;
	double tmp;
	if (c <= -4.7e+58) {
		tmp = t_0;
	} else if (c <= 1.02e-8) {
		tmp = (b + ((a * c) / d)) / d;
	} else {
		tmp = t_0;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(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) :: t_0
    real(8) :: tmp
    t_0 = (a + ((b * d) / c)) / c
    if (c <= (-4.7d+58)) then
        tmp = t_0
    else if (c <= 1.02d-8) then
        tmp = (b + ((a * c) / d)) / d
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = (a + ((b * d) / c)) / c;
	double tmp;
	if (c <= -4.7e+58) {
		tmp = t_0;
	} else if (c <= 1.02e-8) {
		tmp = (b + ((a * c) / d)) / d;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (a + ((b * d) / c)) / c
	tmp = 0
	if c <= -4.7e+58:
		tmp = t_0
	elif c <= 1.02e-8:
		tmp = (b + ((a * c) / d)) / d
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(a + Float64(Float64(b * d) / c)) / c)
	tmp = 0.0
	if (c <= -4.7e+58)
		tmp = t_0;
	elseif (c <= 1.02e-8)
		tmp = Float64(Float64(b + Float64(Float64(a * c) / d)) / d);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (a + ((b * d) / c)) / c;
	tmp = 0.0;
	if (c <= -4.7e+58)
		tmp = t_0;
	elseif (c <= 1.02e-8)
		tmp = (b + ((a * c) / d)) / d;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a + N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -4.7e+58], t$95$0, If[LessEqual[c, 1.02e-8], N[(N[(b + N[(N[(a * c), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{a + \frac{b \cdot d}{c}}{c}\\
\mathbf{if}\;c \leq -4.7 \cdot 10^{+58}:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -4.69999999999999972e58 or 1.02000000000000003e-8 < c

    1. Initial program 47.0%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{a \cdot c}{c \cdot c + d \cdot d} \cdot \frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d} \cdot \frac{b \cdot d}{c \cdot c + d \cdot d}}{\frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d}}} \]
    3. Applied rewrites21.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
    7. Step-by-step derivation
      1. lower-/.f64N/A

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

        \[\leadsto \frac{a + \frac{b \cdot d}{c}}{c} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{a + \frac{b \cdot d}{c}}{c} \]
      4. lower-*.f6473.6

        \[\leadsto \frac{a + \frac{b \cdot d}{c}}{c} \]
    8. Applied rewrites73.6%

      \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]

    if -4.69999999999999972e58 < c < 1.02000000000000003e-8

    1. Initial program 74.0%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{a \cdot c}{c \cdot c + d \cdot d} \cdot \frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d} \cdot \frac{b \cdot d}{c \cdot c + d \cdot d}}{\frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d}}} \]
    3. Applied rewrites32.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
    7. Step-by-step derivation
      1. lower-/.f64N/A

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

        \[\leadsto \frac{b + \frac{a \cdot c}{d}}{d} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{b + \frac{a \cdot c}{d}}{d} \]
      4. lift-*.f6478.4

        \[\leadsto \frac{b + \frac{a \cdot c}{d}}{d} \]
    8. Applied rewrites78.4%

      \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 73.1% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -0.013:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq 4.2 \cdot 10^{+25}:\\ \;\;\;\;\frac{a + \frac{b \cdot d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= d -0.013)
   (/ b d)
   (if (<= d 4.2e+25) (/ (+ a (/ (* b d) c)) c) (/ b d))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -0.013) {
		tmp = b / d;
	} else if (d <= 4.2e+25) {
		tmp = (a + ((b * d) / c)) / 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 (d <= (-0.013d0)) then
        tmp = b / d
    else if (d <= 4.2d+25) then
        tmp = (a + ((b * d) / c)) / 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 (d <= -0.013) {
		tmp = b / d;
	} else if (d <= 4.2e+25) {
		tmp = (a + ((b * d) / c)) / c;
	} else {
		tmp = b / d;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if d <= -0.013:
		tmp = b / d
	elif d <= 4.2e+25:
		tmp = (a + ((b * d) / c)) / c
	else:
		tmp = b / d
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (d <= -0.013)
		tmp = Float64(b / d);
	elseif (d <= 4.2e+25)
		tmp = Float64(Float64(a + Float64(Float64(b * d) / c)) / c);
	else
		tmp = Float64(b / d);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (d <= -0.013)
		tmp = b / d;
	elseif (d <= 4.2e+25)
		tmp = (a + ((b * d) / c)) / c;
	else
		tmp = b / d;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[d, -0.013], N[(b / d), $MachinePrecision], If[LessEqual[d, 4.2e+25], N[(N[(a + N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(b / d), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -0.013:\\
\;\;\;\;\frac{b}{d}\\

\mathbf{elif}\;d \leq 4.2 \cdot 10^{+25}:\\
\;\;\;\;\frac{a + \frac{b \cdot d}{c}}{c}\\

\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -0.0129999999999999994 or 4.1999999999999998e25 < d

    1. Initial program 48.0%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{a \cdot c}{c \cdot c + d \cdot d} \cdot \frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d} \cdot \frac{b \cdot d}{c \cdot c + d \cdot d}}{\frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d}}} \]
    3. Applied rewrites22.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{b}{d}} \]
    7. Step-by-step derivation
      1. lower-/.f6465.4

        \[\leadsto \frac{b}{\color{blue}{d}} \]
    8. Applied rewrites65.4%

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

    if -0.0129999999999999994 < d < 4.1999999999999998e25

    1. Initial program 73.3%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{a \cdot c}{c \cdot c + d \cdot d} \cdot \frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d} \cdot \frac{b \cdot d}{c \cdot c + d \cdot d}}{\frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d}}} \]
    3. Applied rewrites32.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
    7. Step-by-step derivation
      1. lower-/.f64N/A

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

        \[\leadsto \frac{a + \frac{b \cdot d}{c}}{c} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{a + \frac{b \cdot d}{c}}{c} \]
      4. lower-*.f6480.2

        \[\leadsto \frac{a + \frac{b \cdot d}{c}}{c} \]
    8. Applied rewrites80.2%

      \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 64.1% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -4.7 \cdot 10^{+58}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 22000:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= c -4.7e+58) (/ a c) (if (<= c 22000.0) (/ b d) (/ a c))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -4.7e+58) {
		tmp = a / c;
	} else if (c <= 22000.0) {
		tmp = b / d;
	} else {
		tmp = a / c;
	}
	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 <= (-4.7d+58)) then
        tmp = a / c
    else if (c <= 22000.0d0) then
        tmp = b / d
    else
        tmp = a / c
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -4.7e+58) {
		tmp = a / c;
	} else if (c <= 22000.0) {
		tmp = b / d;
	} else {
		tmp = a / c;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if c <= -4.7e+58:
		tmp = a / c
	elif c <= 22000.0:
		tmp = b / d
	else:
		tmp = a / c
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (c <= -4.7e+58)
		tmp = Float64(a / c);
	elseif (c <= 22000.0)
		tmp = Float64(b / d);
	else
		tmp = Float64(a / c);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (c <= -4.7e+58)
		tmp = a / c;
	elseif (c <= 22000.0)
		tmp = b / d;
	else
		tmp = a / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[c, -4.7e+58], N[(a / c), $MachinePrecision], If[LessEqual[c, 22000.0], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.7 \cdot 10^{+58}:\\
\;\;\;\;\frac{a}{c}\\

\mathbf{elif}\;c \leq 22000:\\
\;\;\;\;\frac{b}{d}\\

\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -4.69999999999999972e58 or 22000 < c

    1. Initial program 46.4%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{a \cdot c}{c \cdot c + d \cdot d} \cdot \frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d} \cdot \frac{b \cdot d}{c \cdot c + d \cdot d}}{\frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d}}} \]
    3. Applied rewrites21.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{a}{c}} \]
    7. Step-by-step derivation
      1. lower-/.f6467.6

        \[\leadsto \frac{a}{\color{blue}{c}} \]
    8. Applied rewrites67.6%

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

    if -4.69999999999999972e58 < c < 22000

    1. Initial program 74.0%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{a \cdot c}{c \cdot c + d \cdot d} \cdot \frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d} \cdot \frac{b \cdot d}{c \cdot c + d \cdot d}}{\frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d}}} \]
    3. Applied rewrites32.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{b}{d}} \]
    7. Step-by-step derivation
      1. lower-/.f6461.1

        \[\leadsto \frac{b}{\color{blue}{d}} \]
    8. Applied rewrites61.1%

      \[\leadsto \color{blue}{\frac{b}{d}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 43.7% 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 61.3%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{a \cdot c}{c \cdot c + d \cdot d} \cdot \frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d} \cdot \frac{b \cdot d}{c \cdot c + d \cdot d}}{\frac{a \cdot c}{c \cdot c + d \cdot d} - \frac{b \cdot d}{c \cdot c + d \cdot d}}} \]
  3. Applied rewrites27.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  7. Step-by-step derivation
    1. lower-/.f6443.7

      \[\leadsto \frac{a}{\color{blue}{c}} \]
  8. Applied rewrites43.7%

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  9. 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 2025107 
(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))))