Complex division, real part

Percentage Accurate: 62.8% → 84.5%
Time: 4.5s
Alternatives: 10
Speedup: 1.8×

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 10 alternatives:

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

Initial Program: 62.8% 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: 84.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\ t_1 := \frac{d}{t\_0}\\ \mathbf{if}\;d \leq -3.3 \cdot 10^{+153}:\\ \;\;\;\;\frac{b + \frac{a \cdot c}{d}}{d}\\ \mathbf{elif}\;d \leq -6.2 \cdot 10^{-10}:\\ \;\;\;\;\mathsf{fma}\left(b, t\_1, c \cdot \frac{a}{t\_0}\right)\\ \mathbf{elif}\;d \leq 1.95 \cdot 10^{-135}:\\ \;\;\;\;\frac{a + \frac{b \cdot d}{c}}{c}\\ \mathbf{elif}\;d \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;\mathsf{fma}\left(b, t\_1, a \cdot \frac{c}{t\_0}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (fma d d (* c c))) (t_1 (/ d t_0)))
   (if (<= d -3.3e+153)
     (/ (+ b (/ (* a c) d)) d)
     (if (<= d -6.2e-10)
       (fma b t_1 (* c (/ a t_0)))
       (if (<= d 1.95e-135)
         (/ (+ a (/ (* b d) c)) c)
         (if (<= d 1.35e+154) (fma b t_1 (* a (/ c t_0))) (/ b d)))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(d, d, (c * c));
	double t_1 = d / t_0;
	double tmp;
	if (d <= -3.3e+153) {
		tmp = (b + ((a * c) / d)) / d;
	} else if (d <= -6.2e-10) {
		tmp = fma(b, t_1, (c * (a / t_0)));
	} else if (d <= 1.95e-135) {
		tmp = (a + ((b * d) / c)) / c;
	} else if (d <= 1.35e+154) {
		tmp = fma(b, t_1, (a * (c / t_0)));
	} else {
		tmp = b / d;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = fma(d, d, Float64(c * c))
	t_1 = Float64(d / t_0)
	tmp = 0.0
	if (d <= -3.3e+153)
		tmp = Float64(Float64(b + Float64(Float64(a * c) / d)) / d);
	elseif (d <= -6.2e-10)
		tmp = fma(b, t_1, Float64(c * Float64(a / t_0)));
	elseif (d <= 1.95e-135)
		tmp = Float64(Float64(a + Float64(Float64(b * d) / c)) / c);
	elseif (d <= 1.35e+154)
		tmp = fma(b, t_1, Float64(a * Float64(c / t_0)));
	else
		tmp = Float64(b / d);
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d / t$95$0), $MachinePrecision]}, If[LessEqual[d, -3.3e+153], N[(N[(b + N[(N[(a * c), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -6.2e-10], N[(b * t$95$1 + N[(c * N[(a / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.95e-135], N[(N[(a + N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.35e+154], N[(b * t$95$1 + N[(a * N[(c / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b / d), $MachinePrecision]]]]]]]
\begin{array}{l}

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -3.29999999999999994e153

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
    9. 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-*.f6452.8

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

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

    if -3.29999999999999994e153 < d < -6.2000000000000003e-10

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.2000000000000003e-10 < d < 1.95000000000000011e-135

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
    9. 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. lift-*.f6451.9

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

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

    if 1.95000000000000011e-135 < d < 1.35000000000000003e154

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.35000000000000003e154 < d

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{\color{blue}{d}} \]
    10. Applied rewrites43.1%

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

Alternative 2: 82.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\ t_1 := \mathsf{fma}\left(b, \frac{d}{t\_0}, a \cdot \frac{c}{t\_0}\right)\\ \mathbf{if}\;d \leq -8.5 \cdot 10^{+151}:\\ \;\;\;\;\frac{b + \frac{a \cdot c}{d}}{d}\\ \mathbf{elif}\;d \leq -1.3 \cdot 10^{-107}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;d \leq 1.95 \cdot 10^{-135}:\\ \;\;\;\;\frac{a + \frac{b \cdot d}{c}}{c}\\ \mathbf{elif}\;d \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (fma d d (* c c))) (t_1 (fma b (/ d t_0) (* a (/ c t_0)))))
   (if (<= d -8.5e+151)
     (/ (+ b (/ (* a c) d)) d)
     (if (<= d -1.3e-107)
       t_1
       (if (<= d 1.95e-135)
         (/ (+ a (/ (* b d) c)) c)
         (if (<= d 1.35e+154) t_1 (/ b d)))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(d, d, (c * c));
	double t_1 = fma(b, (d / t_0), (a * (c / t_0)));
	double tmp;
	if (d <= -8.5e+151) {
		tmp = (b + ((a * c) / d)) / d;
	} else if (d <= -1.3e-107) {
		tmp = t_1;
	} else if (d <= 1.95e-135) {
		tmp = (a + ((b * d) / c)) / c;
	} else if (d <= 1.35e+154) {
		tmp = t_1;
	} else {
		tmp = b / d;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = fma(d, d, Float64(c * c))
	t_1 = fma(b, Float64(d / t_0), Float64(a * Float64(c / t_0)))
	tmp = 0.0
	if (d <= -8.5e+151)
		tmp = Float64(Float64(b + Float64(Float64(a * c) / d)) / d);
	elseif (d <= -1.3e-107)
		tmp = t_1;
	elseif (d <= 1.95e-135)
		tmp = Float64(Float64(a + Float64(Float64(b * d) / c)) / c);
	elseif (d <= 1.35e+154)
		tmp = t_1;
	else
		tmp = Float64(b / d);
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b * N[(d / t$95$0), $MachinePrecision] + N[(a * N[(c / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -8.5e+151], N[(N[(b + N[(N[(a * c), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -1.3e-107], t$95$1, If[LessEqual[d, 1.95e-135], N[(N[(a + N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.35e+154], t$95$1, N[(b / d), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -1.3 \cdot 10^{-107}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;d \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -8.50000000000000051e151

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
    9. 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-*.f6452.8

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

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

    if -8.50000000000000051e151 < d < -1.3e-107 or 1.95000000000000011e-135 < d < 1.35000000000000003e154

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.3e-107 < d < 1.95000000000000011e-135

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
    9. 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. lift-*.f6451.9

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

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

    if 1.35000000000000003e154 < d

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{\color{blue}{d}} \]
    10. Applied rewrites43.1%

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

Alternative 3: 81.6% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(d, b, c \cdot a\right)\\ t_1 := \mathsf{fma}\left(d, d, c \cdot c\right)\\ \mathbf{if}\;d \leq -2.7 \cdot 10^{+144}:\\ \;\;\;\;\frac{b + \frac{a \cdot c}{d}}{d}\\ \mathbf{elif}\;d \leq -3.7 \cdot 10^{-75}:\\ \;\;\;\;\frac{t\_0}{t\_1}\\ \mathbf{elif}\;d \leq 3.8 \cdot 10^{-129}:\\ \;\;\;\;\frac{a + \frac{b \cdot d}{c}}{c}\\ \mathbf{elif}\;d \leq 8 \cdot 10^{+46}:\\ \;\;\;\;t\_0 \cdot \frac{1}{t\_1}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, \frac{1}{d}, a \cdot \frac{c}{t\_1}\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (fma d b (* c a))) (t_1 (fma d d (* c c))))
   (if (<= d -2.7e+144)
     (/ (+ b (/ (* a c) d)) d)
     (if (<= d -3.7e-75)
       (/ t_0 t_1)
       (if (<= d 3.8e-129)
         (/ (+ a (/ (* b d) c)) c)
         (if (<= d 8e+46)
           (* t_0 (/ 1.0 t_1))
           (fma b (/ 1.0 d) (* a (/ c t_1)))))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(d, b, (c * a));
	double t_1 = fma(d, d, (c * c));
	double tmp;
	if (d <= -2.7e+144) {
		tmp = (b + ((a * c) / d)) / d;
	} else if (d <= -3.7e-75) {
		tmp = t_0 / t_1;
	} else if (d <= 3.8e-129) {
		tmp = (a + ((b * d) / c)) / c;
	} else if (d <= 8e+46) {
		tmp = t_0 * (1.0 / t_1);
	} else {
		tmp = fma(b, (1.0 / d), (a * (c / t_1)));
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = fma(d, b, Float64(c * a))
	t_1 = fma(d, d, Float64(c * c))
	tmp = 0.0
	if (d <= -2.7e+144)
		tmp = Float64(Float64(b + Float64(Float64(a * c) / d)) / d);
	elseif (d <= -3.7e-75)
		tmp = Float64(t_0 / t_1);
	elseif (d <= 3.8e-129)
		tmp = Float64(Float64(a + Float64(Float64(b * d) / c)) / c);
	elseif (d <= 8e+46)
		tmp = Float64(t_0 * Float64(1.0 / t_1));
	else
		tmp = fma(b, Float64(1.0 / d), Float64(a * Float64(c / t_1)));
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * b + N[(c * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.7e+144], N[(N[(b + N[(N[(a * c), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -3.7e-75], N[(t$95$0 / t$95$1), $MachinePrecision], If[LessEqual[d, 3.8e-129], N[(N[(a + N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 8e+46], N[(t$95$0 * N[(1.0 / t$95$1), $MachinePrecision]), $MachinePrecision], N[(b * N[(1.0 / d), $MachinePrecision] + N[(a * N[(c / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -3.7 \cdot 10^{-75}:\\
\;\;\;\;\frac{t\_0}{t\_1}\\

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

\mathbf{elif}\;d \leq 8 \cdot 10^{+46}:\\
\;\;\;\;t\_0 \cdot \frac{1}{t\_1}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, \frac{1}{d}, a \cdot \frac{c}{t\_1}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -2.70000000000000015e144

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
    9. 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-*.f6452.8

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

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

    if -2.70000000000000015e144 < d < -3.70000000000000024e-75

    1. Initial program 62.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.f6462.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-*.f6462.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.f6462.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 rewrites62.8%

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

    if -3.70000000000000024e-75 < d < 3.79999999999999985e-129

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
    9. 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. lift-*.f6451.9

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

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

    if 3.79999999999999985e-129 < d < 7.9999999999999999e46

    1. Initial program 62.8%

      \[\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. mult-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.9999999999999999e46 < d

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{1}{d}}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
    9. Step-by-step derivation
      1. lower-/.f6456.3

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

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

Alternative 4: 80.7% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(d, b, c \cdot a\right)\\ t_1 := \mathsf{fma}\left(d, d, c \cdot c\right)\\ t_2 := \frac{a + \frac{b \cdot d}{c}}{c}\\ \mathbf{if}\;c \leq -2.9 \cdot 10^{+110}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;c \leq -4.4 \cdot 10^{-155}:\\ \;\;\;\;\frac{t\_0}{t\_1}\\ \mathbf{elif}\;c \leq 1.45 \cdot 10^{-25}:\\ \;\;\;\;\frac{b + \frac{a \cdot c}{d}}{d}\\ \mathbf{elif}\;c \leq 2.6 \cdot 10^{+94}:\\ \;\;\;\;t\_0 \cdot \frac{1}{t\_1}\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (fma d b (* c a)))
        (t_1 (fma d d (* c c)))
        (t_2 (/ (+ a (/ (* b d) c)) c)))
   (if (<= c -2.9e+110)
     t_2
     (if (<= c -4.4e-155)
       (/ t_0 t_1)
       (if (<= c 1.45e-25)
         (/ (+ b (/ (* a c) d)) d)
         (if (<= c 2.6e+94) (* t_0 (/ 1.0 t_1)) t_2))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(d, b, (c * a));
	double t_1 = fma(d, d, (c * c));
	double t_2 = (a + ((b * d) / c)) / c;
	double tmp;
	if (c <= -2.9e+110) {
		tmp = t_2;
	} else if (c <= -4.4e-155) {
		tmp = t_0 / t_1;
	} else if (c <= 1.45e-25) {
		tmp = (b + ((a * c) / d)) / d;
	} else if (c <= 2.6e+94) {
		tmp = t_0 * (1.0 / t_1);
	} else {
		tmp = t_2;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = fma(d, b, Float64(c * a))
	t_1 = fma(d, d, Float64(c * c))
	t_2 = Float64(Float64(a + Float64(Float64(b * d) / c)) / c)
	tmp = 0.0
	if (c <= -2.9e+110)
		tmp = t_2;
	elseif (c <= -4.4e-155)
		tmp = Float64(t_0 / t_1);
	elseif (c <= 1.45e-25)
		tmp = Float64(Float64(b + Float64(Float64(a * c) / d)) / d);
	elseif (c <= 2.6e+94)
		tmp = Float64(t_0 * Float64(1.0 / t_1));
	else
		tmp = t_2;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * b + N[(c * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(a + N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -2.9e+110], t$95$2, If[LessEqual[c, -4.4e-155], N[(t$95$0 / t$95$1), $MachinePrecision], If[LessEqual[c, 1.45e-25], N[(N[(b + N[(N[(a * c), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 2.6e+94], N[(t$95$0 * N[(1.0 / t$95$1), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, b, c \cdot a\right)\\
t_1 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
t_2 := \frac{a + \frac{b \cdot d}{c}}{c}\\
\mathbf{if}\;c \leq -2.9 \cdot 10^{+110}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;c \leq -4.4 \cdot 10^{-155}:\\
\;\;\;\;\frac{t\_0}{t\_1}\\

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

\mathbf{elif}\;c \leq 2.6 \cdot 10^{+94}:\\
\;\;\;\;t\_0 \cdot \frac{1}{t\_1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -2.9e110 or 2.5999999999999999e94 < c

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
    9. 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. lift-*.f6451.9

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

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

    if -2.9e110 < c < -4.3999999999999998e-155

    1. Initial program 62.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.f6462.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-*.f6462.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.f6462.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 rewrites62.8%

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

    if -4.3999999999999998e-155 < c < 1.45e-25

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
    9. 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-*.f6452.8

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

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

    if 1.45e-25 < c < 2.5999999999999999e94

    1. Initial program 62.8%

      \[\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. mult-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 80.6% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ t_1 := \frac{a + \frac{b \cdot d}{c}}{c}\\ \mathbf{if}\;c \leq -2.9 \cdot 10^{+110}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;c \leq -4.4 \cdot 10^{-155}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 1.45 \cdot 10^{-25}:\\ \;\;\;\;\frac{b + \frac{a \cdot c}{d}}{d}\\ \mathbf{elif}\;c \leq 2.6 \cdot 10^{+94}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (fma d b (* c a)) (fma d d (* c c))))
        (t_1 (/ (+ a (/ (* b d) c)) c)))
   (if (<= c -2.9e+110)
     t_1
     (if (<= c -4.4e-155)
       t_0
       (if (<= c 1.45e-25)
         (/ (+ b (/ (* a c) d)) d)
         (if (<= c 2.6e+94) t_0 t_1))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(d, b, (c * a)) / fma(d, d, (c * c));
	double t_1 = (a + ((b * d) / c)) / c;
	double tmp;
	if (c <= -2.9e+110) {
		tmp = t_1;
	} else if (c <= -4.4e-155) {
		tmp = t_0;
	} else if (c <= 1.45e-25) {
		tmp = (b + ((a * c) / d)) / d;
	} else if (c <= 2.6e+94) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(fma(d, b, Float64(c * a)) / fma(d, d, Float64(c * c)))
	t_1 = Float64(Float64(a + Float64(Float64(b * d) / c)) / c)
	tmp = 0.0
	if (c <= -2.9e+110)
		tmp = t_1;
	elseif (c <= -4.4e-155)
		tmp = t_0;
	elseif (c <= 1.45e-25)
		tmp = Float64(Float64(b + Float64(Float64(a * c) / d)) / d);
	elseif (c <= 2.6e+94)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(d * b + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a + N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -2.9e+110], t$95$1, If[LessEqual[c, -4.4e-155], t$95$0, If[LessEqual[c, 1.45e-25], N[(N[(b + N[(N[(a * c), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 2.6e+94], t$95$0, t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -4.4 \cdot 10^{-155}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 2.6 \cdot 10^{+94}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -2.9e110 or 2.5999999999999999e94 < c

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
    9. 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. lift-*.f6451.9

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

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

    if -2.9e110 < c < -4.3999999999999998e-155 or 1.45e-25 < c < 2.5999999999999999e94

    1. Initial program 62.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.f6462.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-*.f6462.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.f6462.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 rewrites62.8%

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

    if -4.3999999999999998e-155 < c < 1.45e-25

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
    9. 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-*.f6452.8

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

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

Alternative 6: 79.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 -2.9 \cdot 10^{+110}:\\ \;\;\;\;\frac{a + \frac{b \cdot d}{c}}{c}\\ \mathbf{elif}\;c \leq -4.4 \cdot 10^{-155}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{t\_0}\\ \mathbf{elif}\;c \leq 5.4 \cdot 10^{+28}:\\ \;\;\;\;\frac{b + \frac{a \cdot c}{d}}{d}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, \frac{1}{t\_0} \cdot d, a \cdot \frac{1}{c}\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (fma d d (* c c))))
   (if (<= c -2.9e+110)
     (/ (+ a (/ (* b d) c)) c)
     (if (<= c -4.4e-155)
       (/ (fma d b (* c a)) t_0)
       (if (<= c 5.4e+28)
         (/ (+ b (/ (* a c) d)) d)
         (fma b (* (/ 1.0 t_0) d) (* a (/ 1.0 c))))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(d, d, (c * c));
	double tmp;
	if (c <= -2.9e+110) {
		tmp = (a + ((b * d) / c)) / c;
	} else if (c <= -4.4e-155) {
		tmp = fma(d, b, (c * a)) / t_0;
	} else if (c <= 5.4e+28) {
		tmp = (b + ((a * c) / d)) / d;
	} else {
		tmp = fma(b, ((1.0 / t_0) * d), (a * (1.0 / c)));
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = fma(d, d, Float64(c * c))
	tmp = 0.0
	if (c <= -2.9e+110)
		tmp = Float64(Float64(a + Float64(Float64(b * d) / c)) / c);
	elseif (c <= -4.4e-155)
		tmp = Float64(fma(d, b, Float64(c * a)) / t_0);
	elseif (c <= 5.4e+28)
		tmp = Float64(Float64(b + Float64(Float64(a * c) / d)) / d);
	else
		tmp = fma(b, Float64(Float64(1.0 / t_0) * d), Float64(a * Float64(1.0 / 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, -2.9e+110], N[(N[(a + N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -4.4e-155], N[(N[(d * b + N[(c * a), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[c, 5.4e+28], N[(N[(b + N[(N[(a * c), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], N[(b * N[(N[(1.0 / t$95$0), $MachinePrecision] * d), $MachinePrecision] + N[(a * N[(1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, \frac{1}{t\_0} \cdot d, a \cdot \frac{1}{c}\right)\\


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

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
    9. 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. lift-*.f6451.9

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

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

    if -2.9e110 < c < -4.3999999999999998e-155

    1. Initial program 62.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.f6462.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-*.f6462.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.f6462.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 rewrites62.8%

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

    if -4.3999999999999998e-155 < c < 5.4000000000000003e28

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
    9. 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-*.f6452.8

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

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

    if 5.4000000000000003e28 < c

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(b, \frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d, a \cdot \color{blue}{\frac{1}{c}}\right) \]
    9. Step-by-step derivation
      1. lower-/.f6454.6

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

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

Alternative 7: 76.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{a + \frac{b \cdot d}{c}}{c}\\ \mathbf{if}\;c \leq -8.8 \cdot 10^{-23}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 5.5 \cdot 10^{+26}:\\ \;\;\;\;\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 -8.8e-23) t_0 (if (<= c 5.5e+26) (/ (+ 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 <= -8.8e-23) {
		tmp = t_0;
	} else if (c <= 5.5e+26) {
		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 <= (-8.8d-23)) then
        tmp = t_0
    else if (c <= 5.5d+26) 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 <= -8.8e-23) {
		tmp = t_0;
	} else if (c <= 5.5e+26) {
		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 <= -8.8e-23:
		tmp = t_0
	elif c <= 5.5e+26:
		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 <= -8.8e-23)
		tmp = t_0;
	elseif (c <= 5.5e+26)
		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 <= -8.8e-23)
		tmp = t_0;
	elseif (c <= 5.5e+26)
		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, -8.8e-23], t$95$0, If[LessEqual[c, 5.5e+26], 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 -8.8 \cdot 10^{-23}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;c \leq 5.5 \cdot 10^{+26}:\\
\;\;\;\;\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 < -8.7999999999999998e-23 or 5.4999999999999997e26 < c

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
    9. 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. lift-*.f6451.9

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

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

    if -8.7999999999999998e-23 < c < 5.4999999999999997e26

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
    9. 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-*.f6452.8

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

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

Alternative 8: 72.8% accurate, 1.0× speedup?

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

\mathbf{elif}\;d \leq 6.1 \cdot 10^{+47}:\\
\;\;\;\;\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.050000000000000003 or 6.10000000000000019e47 < d

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right)} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{c \cdot \frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
      2. lift-/.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \color{blue}{\frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
      3. associate-*r/N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{\frac{c \cdot a}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{\color{blue}{a \cdot c}}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
      5. associate-/l*N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
      6. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
      7. lower-/.f6465.7

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, a \cdot \color{blue}{\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
    5. Applied rewrites65.7%

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
    6. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
      2. mult-flipN/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{d \cdot \frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)}}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
      4. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
      5. lower-/.f6465.4

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \cdot d, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
    7. Applied rewrites65.4%

      \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
    8. Taylor expanded in c around 0

      \[\leadsto \color{blue}{\frac{b}{d}} \]
    9. Step-by-step derivation
      1. lower-/.f6443.1

        \[\leadsto \frac{b}{\color{blue}{d}} \]
    10. Applied rewrites43.1%

      \[\leadsto \color{blue}{\frac{b}{d}} \]

    if -0.050000000000000003 < d < 6.10000000000000019e47

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{b \cdot d + a \cdot c}}{c \cdot c + d \cdot d} \]
      4. div-addN/A

        \[\leadsto \color{blue}{\frac{b \cdot d}{c \cdot c + d \cdot d} + \frac{a \cdot c}{c \cdot c + d \cdot d}} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{b \cdot d}}{c \cdot c + d \cdot d} + \frac{a \cdot c}{c \cdot c + d \cdot d} \]
      6. associate-/l*N/A

        \[\leadsto \color{blue}{b \cdot \frac{d}{c \cdot c + d \cdot d}} + \frac{a \cdot c}{c \cdot c + d \cdot d} \]
      7. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(b, \frac{d}{c \cdot c + d \cdot d}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right)} \]
      8. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{d}{c \cdot c + d \cdot d}}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right) \]
      9. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\color{blue}{c \cdot c + d \cdot d}}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right) \]
      10. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\color{blue}{d \cdot d + c \cdot c}}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right) \]
      11. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\color{blue}{d \cdot d} + c \cdot c}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right) \]
      12. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right) \]
      13. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{\color{blue}{a \cdot c}}{c \cdot c + d \cdot d}\right) \]
      14. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{\color{blue}{c \cdot a}}{c \cdot c + d \cdot d}\right) \]
      15. associate-/l*N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{c \cdot \frac{a}{c \cdot c + d \cdot d}}\right) \]
      16. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{c \cdot \frac{a}{c \cdot c + d \cdot d}}\right) \]
      17. lower-/.f6462.6

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \color{blue}{\frac{a}{c \cdot c + d \cdot d}}\right) \]
      18. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \frac{a}{\color{blue}{c \cdot c + d \cdot d}}\right) \]
      19. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \frac{a}{\color{blue}{d \cdot d + c \cdot c}}\right) \]
      20. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \frac{a}{\color{blue}{d \cdot d} + c \cdot c}\right) \]
      21. lower-fma.f6462.6

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \frac{a}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
    3. Applied rewrites62.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right)} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{c \cdot \frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
      2. lift-/.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \color{blue}{\frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
      3. associate-*r/N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{\frac{c \cdot a}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{\color{blue}{a \cdot c}}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
      5. associate-/l*N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
      6. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
      7. lower-/.f6465.7

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, a \cdot \color{blue}{\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
    5. Applied rewrites65.7%

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
    6. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
      2. mult-flipN/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{d \cdot \frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)}}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
      4. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
      5. lower-/.f6465.4

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \cdot d, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
    7. Applied rewrites65.4%

      \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
    8. Taylor expanded in c around inf

      \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
    9. 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. lift-*.f6451.9

        \[\leadsto \frac{a + \frac{b \cdot d}{c}}{c} \]
    10. Applied rewrites51.9%

      \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 64.2% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -0.042:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq 3.1 \cdot 10^{+47}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= d -0.042) (/ b d) (if (<= d 3.1e+47) (/ a c) (/ b d))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -0.042) {
		tmp = b / d;
	} else if (d <= 3.1e+47) {
		tmp = a / c;
	} else {
		tmp = b / d;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b, c, d)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: tmp
    if (d <= (-0.042d0)) then
        tmp = b / d
    else if (d <= 3.1d+47) then
        tmp = a / c
    else
        tmp = b / d
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -0.042) {
		tmp = b / d;
	} else if (d <= 3.1e+47) {
		tmp = a / c;
	} else {
		tmp = b / d;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if d <= -0.042:
		tmp = b / d
	elif d <= 3.1e+47:
		tmp = a / c
	else:
		tmp = b / d
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (d <= -0.042)
		tmp = Float64(b / d);
	elseif (d <= 3.1e+47)
		tmp = Float64(a / c);
	else
		tmp = Float64(b / d);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (d <= -0.042)
		tmp = b / d;
	elseif (d <= 3.1e+47)
		tmp = a / c;
	else
		tmp = b / d;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[d, -0.042], N[(b / d), $MachinePrecision], If[LessEqual[d, 3.1e+47], N[(a / c), $MachinePrecision], N[(b / d), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -0.042:\\
\;\;\;\;\frac{b}{d}\\

\mathbf{elif}\;d \leq 3.1 \cdot 10^{+47}:\\
\;\;\;\;\frac{a}{c}\\

\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -0.0420000000000000026 or 3.1000000000000001e47 < d

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{b \cdot d + a \cdot c}}{c \cdot c + d \cdot d} \]
      4. div-addN/A

        \[\leadsto \color{blue}{\frac{b \cdot d}{c \cdot c + d \cdot d} + \frac{a \cdot c}{c \cdot c + d \cdot d}} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{b \cdot d}}{c \cdot c + d \cdot d} + \frac{a \cdot c}{c \cdot c + d \cdot d} \]
      6. associate-/l*N/A

        \[\leadsto \color{blue}{b \cdot \frac{d}{c \cdot c + d \cdot d}} + \frac{a \cdot c}{c \cdot c + d \cdot d} \]
      7. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(b, \frac{d}{c \cdot c + d \cdot d}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right)} \]
      8. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{d}{c \cdot c + d \cdot d}}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right) \]
      9. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\color{blue}{c \cdot c + d \cdot d}}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right) \]
      10. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\color{blue}{d \cdot d + c \cdot c}}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right) \]
      11. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\color{blue}{d \cdot d} + c \cdot c}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right) \]
      12. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right) \]
      13. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{\color{blue}{a \cdot c}}{c \cdot c + d \cdot d}\right) \]
      14. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{\color{blue}{c \cdot a}}{c \cdot c + d \cdot d}\right) \]
      15. associate-/l*N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{c \cdot \frac{a}{c \cdot c + d \cdot d}}\right) \]
      16. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{c \cdot \frac{a}{c \cdot c + d \cdot d}}\right) \]
      17. lower-/.f6462.6

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \color{blue}{\frac{a}{c \cdot c + d \cdot d}}\right) \]
      18. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \frac{a}{\color{blue}{c \cdot c + d \cdot d}}\right) \]
      19. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \frac{a}{\color{blue}{d \cdot d + c \cdot c}}\right) \]
      20. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \frac{a}{\color{blue}{d \cdot d} + c \cdot c}\right) \]
      21. lower-fma.f6462.6

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \frac{a}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
    3. Applied rewrites62.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right)} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{c \cdot \frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
      2. lift-/.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \color{blue}{\frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
      3. associate-*r/N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{\frac{c \cdot a}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{\color{blue}{a \cdot c}}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
      5. associate-/l*N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
      6. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
      7. lower-/.f6465.7

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, a \cdot \color{blue}{\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
    5. Applied rewrites65.7%

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
    6. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
      2. mult-flipN/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{d \cdot \frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)}}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
      4. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
      5. lower-/.f6465.4

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \cdot d, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
    7. Applied rewrites65.4%

      \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
    8. Taylor expanded in c around 0

      \[\leadsto \color{blue}{\frac{b}{d}} \]
    9. Step-by-step derivation
      1. lower-/.f6443.1

        \[\leadsto \frac{b}{\color{blue}{d}} \]
    10. Applied rewrites43.1%

      \[\leadsto \color{blue}{\frac{b}{d}} \]

    if -0.0420000000000000026 < d < 3.1000000000000001e47

    1. Initial program 62.8%

      \[\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. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{b \cdot d + a \cdot c}}{c \cdot c + d \cdot d} \]
      4. div-addN/A

        \[\leadsto \color{blue}{\frac{b \cdot d}{c \cdot c + d \cdot d} + \frac{a \cdot c}{c \cdot c + d \cdot d}} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{b \cdot d}}{c \cdot c + d \cdot d} + \frac{a \cdot c}{c \cdot c + d \cdot d} \]
      6. associate-/l*N/A

        \[\leadsto \color{blue}{b \cdot \frac{d}{c \cdot c + d \cdot d}} + \frac{a \cdot c}{c \cdot c + d \cdot d} \]
      7. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(b, \frac{d}{c \cdot c + d \cdot d}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right)} \]
      8. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{d}{c \cdot c + d \cdot d}}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right) \]
      9. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\color{blue}{c \cdot c + d \cdot d}}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right) \]
      10. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\color{blue}{d \cdot d + c \cdot c}}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right) \]
      11. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\color{blue}{d \cdot d} + c \cdot c}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right) \]
      12. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right) \]
      13. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{\color{blue}{a \cdot c}}{c \cdot c + d \cdot d}\right) \]
      14. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{\color{blue}{c \cdot a}}{c \cdot c + d \cdot d}\right) \]
      15. associate-/l*N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{c \cdot \frac{a}{c \cdot c + d \cdot d}}\right) \]
      16. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{c \cdot \frac{a}{c \cdot c + d \cdot d}}\right) \]
      17. lower-/.f6462.6

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \color{blue}{\frac{a}{c \cdot c + d \cdot d}}\right) \]
      18. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \frac{a}{\color{blue}{c \cdot c + d \cdot d}}\right) \]
      19. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \frac{a}{\color{blue}{d \cdot d + c \cdot c}}\right) \]
      20. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \frac{a}{\color{blue}{d \cdot d} + c \cdot c}\right) \]
      21. lower-fma.f6462.6

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \frac{a}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
    3. Applied rewrites62.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right)} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{c \cdot \frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
      2. lift-/.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \color{blue}{\frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
      3. associate-*r/N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{\frac{c \cdot a}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{\color{blue}{a \cdot c}}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
      5. associate-/l*N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
      6. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
      7. lower-/.f6465.7

        \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, a \cdot \color{blue}{\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
    5. Applied rewrites65.7%

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
    6. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
      2. mult-flipN/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{d \cdot \frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)}}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
      4. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
      5. lower-/.f6465.4

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \cdot d, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
    7. Applied rewrites65.4%

      \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
    8. Taylor expanded in c around inf

      \[\leadsto \color{blue}{\frac{a}{c}} \]
    9. Step-by-step derivation
      1. lower-/.f6442.7

        \[\leadsto \frac{a}{\color{blue}{c}} \]
    10. Applied rewrites42.7%

      \[\leadsto \color{blue}{\frac{a}{c}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 42.7% accurate, 5.0× 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 62.8%

    \[\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. +-commutativeN/A

      \[\leadsto \frac{\color{blue}{b \cdot d + a \cdot c}}{c \cdot c + d \cdot d} \]
    4. div-addN/A

      \[\leadsto \color{blue}{\frac{b \cdot d}{c \cdot c + d \cdot d} + \frac{a \cdot c}{c \cdot c + d \cdot d}} \]
    5. lift-*.f64N/A

      \[\leadsto \frac{\color{blue}{b \cdot d}}{c \cdot c + d \cdot d} + \frac{a \cdot c}{c \cdot c + d \cdot d} \]
    6. associate-/l*N/A

      \[\leadsto \color{blue}{b \cdot \frac{d}{c \cdot c + d \cdot d}} + \frac{a \cdot c}{c \cdot c + d \cdot d} \]
    7. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(b, \frac{d}{c \cdot c + d \cdot d}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right)} \]
    8. lower-/.f64N/A

      \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{d}{c \cdot c + d \cdot d}}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right) \]
    9. lift-+.f64N/A

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\color{blue}{c \cdot c + d \cdot d}}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right) \]
    10. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\color{blue}{d \cdot d + c \cdot c}}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right) \]
    11. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\color{blue}{d \cdot d} + c \cdot c}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right) \]
    12. lower-fma.f64N/A

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}}, \frac{a \cdot c}{c \cdot c + d \cdot d}\right) \]
    13. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{\color{blue}{a \cdot c}}{c \cdot c + d \cdot d}\right) \]
    14. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{\color{blue}{c \cdot a}}{c \cdot c + d \cdot d}\right) \]
    15. associate-/l*N/A

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{c \cdot \frac{a}{c \cdot c + d \cdot d}}\right) \]
    16. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{c \cdot \frac{a}{c \cdot c + d \cdot d}}\right) \]
    17. lower-/.f6462.6

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \color{blue}{\frac{a}{c \cdot c + d \cdot d}}\right) \]
    18. lift-+.f64N/A

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \frac{a}{\color{blue}{c \cdot c + d \cdot d}}\right) \]
    19. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \frac{a}{\color{blue}{d \cdot d + c \cdot c}}\right) \]
    20. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \frac{a}{\color{blue}{d \cdot d} + c \cdot c}\right) \]
    21. lower-fma.f6462.6

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \frac{a}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
  3. Applied rewrites62.6%

    \[\leadsto \color{blue}{\mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right)} \]
  4. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{c \cdot \frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
    2. lift-/.f64N/A

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, c \cdot \color{blue}{\frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
    3. associate-*r/N/A

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{\frac{c \cdot a}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
    4. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{\color{blue}{a \cdot c}}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
    5. associate-/l*N/A

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
    6. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
    7. lower-/.f6465.7

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, a \cdot \color{blue}{\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
  5. Applied rewrites65.7%

    \[\leadsto \mathsf{fma}\left(b, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
  6. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
    2. mult-flipN/A

      \[\leadsto \mathsf{fma}\left(b, \color{blue}{d \cdot \frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)}}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
    3. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
    4. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
    5. lower-/.f6465.4

      \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \cdot d, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
  7. Applied rewrites65.4%

    \[\leadsto \mathsf{fma}\left(b, \color{blue}{\frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d}, a \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
  8. Taylor expanded in c around inf

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  9. Step-by-step derivation
    1. lower-/.f6442.7

      \[\leadsto \frac{a}{\color{blue}{c}} \]
  10. Applied rewrites42.7%

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  11. Add Preprocessing

Developer Target 1: 99.4% accurate, 0.8× 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 2025136 
(FPCore (a b c d)
  :name "Complex division, real part"
  :precision binary64

  :alt
  (! :herbie-platform c (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))))