Complex division, real part

Percentage Accurate: 61.5% → 84.1%
Time: 5.4s
Alternatives: 11
Speedup: 1.6×

Specification

?
\[\begin{array}{l} \\ \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
	return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(a, b, c, d)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    code = ((a * c) + (b * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
	return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d):
	return ((a * c) + (b * d)) / ((c * c) + (d * d))
function code(a, b, c, d)
	return Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d)))
end
function tmp = code(a, b, c, d)
	tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
end
code[a_, b_, c_, d_] := N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 61.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{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.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\ \mathbf{if}\;c \leq -3.6 \cdot 10^{+151}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{\mathsf{fma}\left(\frac{d}{c}, -a, b\right)}{c}, d, a\right)}{c}\\ \mathbf{elif}\;c \leq -1.35 \cdot 10^{-125}:\\ \;\;\;\;\mathsf{fma}\left(b, \frac{d}{t\_0}, c \cdot \frac{a}{t\_0}\right)\\ \mathbf{elif}\;c \leq 1.65 \cdot 10^{-52}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\ \mathbf{elif}\;c \leq 10^{+142}:\\ \;\;\;\;\mathsf{fma}\left(a, \frac{c}{t\_0}, d \cdot \frac{b}{t\_0}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (fma d d (* c c))))
   (if (<= c -3.6e+151)
     (/ (fma (/ (fma (/ d c) (- a) b) c) d a) c)
     (if (<= c -1.35e-125)
       (fma b (/ d t_0) (* c (/ a t_0)))
       (if (<= c 1.65e-52)
         (/ (fma (/ c d) a b) d)
         (if (<= c 1e+142)
           (fma a (/ c t_0) (* d (/ b t_0)))
           (/ (fma (/ d c) b a) c)))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(d, d, (c * c));
	double tmp;
	if (c <= -3.6e+151) {
		tmp = fma((fma((d / c), -a, b) / c), d, a) / c;
	} else if (c <= -1.35e-125) {
		tmp = fma(b, (d / t_0), (c * (a / t_0)));
	} else if (c <= 1.65e-52) {
		tmp = fma((c / d), a, b) / d;
	} else if (c <= 1e+142) {
		tmp = fma(a, (c / t_0), (d * (b / t_0)));
	} else {
		tmp = fma((d / c), b, a) / c;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = fma(d, d, Float64(c * c))
	tmp = 0.0
	if (c <= -3.6e+151)
		tmp = Float64(fma(Float64(fma(Float64(d / c), Float64(-a), b) / c), d, a) / c);
	elseif (c <= -1.35e-125)
		tmp = fma(b, Float64(d / t_0), Float64(c * Float64(a / t_0)));
	elseif (c <= 1.65e-52)
		tmp = Float64(fma(Float64(c / d), a, b) / d);
	elseif (c <= 1e+142)
		tmp = fma(a, Float64(c / t_0), Float64(d * Float64(b / t_0)));
	else
		tmp = Float64(fma(Float64(d / c), b, a) / 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, -3.6e+151], N[(N[(N[(N[(N[(d / c), $MachinePrecision] * (-a) + b), $MachinePrecision] / c), $MachinePrecision] * d + a), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -1.35e-125], N[(b * N[(d / t$95$0), $MachinePrecision] + N[(c * N[(a / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.65e-52], N[(N[(N[(c / d), $MachinePrecision] * a + b), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1e+142], N[(a * N[(c / t$95$0), $MachinePrecision] + N[(d * N[(b / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(d / c), $MachinePrecision] * b + a), $MachinePrecision] / c), $MachinePrecision]]]]]]
\begin{array}{l}

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

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

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

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

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


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

    1. Initial program 28.8%

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

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

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

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

      if -3.6e151 < c < -1.3499999999999999e-125

      1. Initial program 72.4%

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

          \[\leadsto \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-/.f6478.3

          \[\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.f6478.3

          \[\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) \]
      4. Applied rewrites78.3%

        \[\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 -1.3499999999999999e-125 < c < 1.64999999999999998e-52

      1. Initial program 68.4%

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

          \[\leadsto \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-/.f6466.8

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

          \[\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) \]
      4. Applied rewrites66.8%

        \[\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)} \]
      5. Taylor expanded in c around 0

        \[\leadsto \color{blue}{\frac{b}{d} + \frac{a \cdot c}{{d}^{2}}} \]
      6. Step-by-step derivation
        1. unpow2N/A

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

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

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

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

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

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

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

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

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

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

      if 1.64999999999999998e-52 < c < 1.00000000000000005e142

      1. Initial program 77.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 1.00000000000000005e142 < c

      1. Initial program 45.3%

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

          \[\leadsto \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-/.f6446.5

          \[\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.f6446.5

          \[\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) \]
      4. Applied rewrites46.5%

        \[\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)} \]
      5. Taylor expanded in c around inf

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

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

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.6 \cdot 10^{+151}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{\mathsf{fma}\left(\frac{d}{c}, -a, b\right)}{c}, d, a\right)}{c}\\ \mathbf{elif}\;c \leq -1.35 \cdot 10^{-125}:\\ \;\;\;\;\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)\\ \mathbf{elif}\;c \leq 1.65 \cdot 10^{-52}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\ \mathbf{elif}\;c \leq 10^{+142}:\\ \;\;\;\;\mathsf{fma}\left(a, \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}, d \cdot \frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\ \end{array} \]
    8. Add Preprocessing

    Alternative 2: 83.6% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ t_1 := \frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\ \mathbf{if}\;c \leq -6.6 \cdot 10^{+88}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;c \leq -1.35 \cdot 10^{-125}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 6.3 \cdot 10^{-105}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\ \mathbf{elif}\;c \leq 9.5 \cdot 10^{+122}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
    (FPCore (a b c d)
     :precision binary64
     (let* ((t_0 (/ (fma d b (* c a)) (fma d d (* c c))))
            (t_1 (/ (fma (/ b c) d a) c)))
       (if (<= c -6.6e+88)
         t_1
         (if (<= c -1.35e-125)
           t_0
           (if (<= c 6.3e-105)
             (/ (fma (/ c d) a b) d)
             (if (<= c 9.5e+122) t_0 t_1))))))
    double code(double a, double b, double c, double d) {
    	double t_0 = fma(d, b, (c * a)) / fma(d, d, (c * c));
    	double t_1 = fma((b / c), d, a) / c;
    	double tmp;
    	if (c <= -6.6e+88) {
    		tmp = t_1;
    	} else if (c <= -1.35e-125) {
    		tmp = t_0;
    	} else if (c <= 6.3e-105) {
    		tmp = fma((c / d), a, b) / d;
    	} else if (c <= 9.5e+122) {
    		tmp = t_0;
    	} else {
    		tmp = t_1;
    	}
    	return tmp;
    }
    
    function code(a, b, c, d)
    	t_0 = Float64(fma(d, b, Float64(c * a)) / fma(d, d, Float64(c * c)))
    	t_1 = Float64(fma(Float64(b / c), d, a) / c)
    	tmp = 0.0
    	if (c <= -6.6e+88)
    		tmp = t_1;
    	elseif (c <= -1.35e-125)
    		tmp = t_0;
    	elseif (c <= 6.3e-105)
    		tmp = Float64(fma(Float64(c / d), a, b) / d);
    	elseif (c <= 9.5e+122)
    		tmp = t_0;
    	else
    		tmp = t_1;
    	end
    	return tmp
    end
    
    code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(d * b + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(b / c), $MachinePrecision] * d + a), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -6.6e+88], t$95$1, If[LessEqual[c, -1.35e-125], t$95$0, If[LessEqual[c, 6.3e-105], N[(N[(N[(c / d), $MachinePrecision] * a + b), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 9.5e+122], t$95$0, t$95$1]]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
    t_1 := \frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\
    \mathbf{if}\;c \leq -6.6 \cdot 10^{+88}:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;c \leq -1.35 \cdot 10^{-125}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;c \leq 6.3 \cdot 10^{-105}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\
    
    \mathbf{elif}\;c \leq 9.5 \cdot 10^{+122}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if c < -6.6000000000000006e88 or 9.49999999999999986e122 < c

      1. Initial program 40.8%

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(-1 \cdot \frac{b \cdot d}{c}\right)\right)} + \left(-1 \cdot a\right) \cdot -1}{c} \]
        10. mul-1-negN/A

          \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{b \cdot d}{c}\right)\right)}\right)\right) + \left(-1 \cdot a\right) \cdot -1}{c} \]
        11. remove-double-negN/A

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

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

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

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

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

          \[\leadsto \frac{\frac{b}{c} \cdot d + \color{blue}{\left(\mathsf{neg}\left(-1 \cdot a\right)\right)}}{c} \]
        17. mul-1-negN/A

          \[\leadsto \frac{\frac{b}{c} \cdot d + \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(a\right)\right)}\right)\right)}{c} \]
        18. remove-double-negN/A

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

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

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

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

      if -6.6000000000000006e88 < c < -1.3499999999999999e-125 or 6.3e-105 < c < 9.49999999999999986e122

      1. Initial program 77.7%

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

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

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

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

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

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

          \[\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.f6477.7

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

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

      if -1.3499999999999999e-125 < c < 6.3e-105

      1. Initial program 66.9%

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

          \[\leadsto \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-/.f6468.7

          \[\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.f6468.7

          \[\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) \]
      4. Applied rewrites68.7%

        \[\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)} \]
      5. Taylor expanded in c around 0

        \[\leadsto \color{blue}{\frac{b}{d} + \frac{a \cdot c}{{d}^{2}}} \]
      6. Step-by-step derivation
        1. unpow2N/A

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -6.6 \cdot 10^{+88}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\ \mathbf{elif}\;c \leq -1.35 \cdot 10^{-125}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;c \leq 6.3 \cdot 10^{-105}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\ \mathbf{elif}\;c \leq 9.5 \cdot 10^{+122}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 3: 78.5% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\frac{a}{d}, \frac{c}{d}, \frac{b}{d}\right)\\ \mathbf{if}\;d \leq -6.8 \cdot 10^{+76}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq -2.2 \cdot 10^{-161}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{a}, d, c\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot a\\ \mathbf{elif}\;d \leq 7 \cdot 10^{+31}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (a b c d)
     :precision binary64
     (let* ((t_0 (fma (/ a d) (/ c d) (/ b d))))
       (if (<= d -6.8e+76)
         t_0
         (if (<= d -2.2e-161)
           (* (/ (fma (/ b a) d c) (fma c c (* d d))) a)
           (if (<= d 7e+31) (/ (fma (/ d c) b a) c) t_0)))))
    double code(double a, double b, double c, double d) {
    	double t_0 = fma((a / d), (c / d), (b / d));
    	double tmp;
    	if (d <= -6.8e+76) {
    		tmp = t_0;
    	} else if (d <= -2.2e-161) {
    		tmp = (fma((b / a), d, c) / fma(c, c, (d * d))) * a;
    	} else if (d <= 7e+31) {
    		tmp = fma((d / c), b, a) / c;
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    function code(a, b, c, d)
    	t_0 = fma(Float64(a / d), Float64(c / d), Float64(b / d))
    	tmp = 0.0
    	if (d <= -6.8e+76)
    		tmp = t_0;
    	elseif (d <= -2.2e-161)
    		tmp = Float64(Float64(fma(Float64(b / a), d, c) / fma(c, c, Float64(d * d))) * a);
    	elseif (d <= 7e+31)
    		tmp = Float64(fma(Float64(d / c), b, a) / c);
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a / d), $MachinePrecision] * N[(c / d), $MachinePrecision] + N[(b / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -6.8e+76], t$95$0, If[LessEqual[d, -2.2e-161], N[(N[(N[(N[(b / a), $MachinePrecision] * d + c), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[d, 7e+31], N[(N[(N[(d / c), $MachinePrecision] * b + a), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \mathsf{fma}\left(\frac{a}{d}, \frac{c}{d}, \frac{b}{d}\right)\\
    \mathbf{if}\;d \leq -6.8 \cdot 10^{+76}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;d \leq -2.2 \cdot 10^{-161}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{a}, d, c\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot a\\
    
    \mathbf{elif}\;d \leq 7 \cdot 10^{+31}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if d < -6.7999999999999994e76 or 7e31 < d

      1. Initial program 38.2%

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

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

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

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

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

          \[\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-*.f6438.2

          \[\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.f6438.2

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

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

        \[\leadsto \color{blue}{\frac{b}{d} + \frac{a \cdot c}{{d}^{2}}} \]
      6. Step-by-step derivation
        1. +-commutativeN/A

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

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

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

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

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

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

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

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

      if -6.7999999999999994e76 < d < -2.20000000000000002e-161

      1. Initial program 80.9%

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

          \[\leadsto \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-/.f6478.5

          \[\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.f6478.5

          \[\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) \]
      4. Applied rewrites78.5%

        \[\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)} \]
      5. Taylor expanded in a around inf

        \[\leadsto \color{blue}{a \cdot \left(\frac{c}{{c}^{2} + {d}^{2}} + \frac{b \cdot d}{a \cdot \left({c}^{2} + {d}^{2}\right)}\right)} \]
      6. Step-by-step derivation
        1. *-commutativeN/A

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

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

          \[\leadsto \color{blue}{\left(\frac{b \cdot d}{a \cdot \left({c}^{2} + {d}^{2}\right)} + \frac{c}{{c}^{2} + {d}^{2}}\right)} \cdot a \]
        4. times-fracN/A

          \[\leadsto \left(\color{blue}{\frac{b}{a} \cdot \frac{d}{{c}^{2} + {d}^{2}}} + \frac{c}{{c}^{2} + {d}^{2}}\right) \cdot a \]
        5. associate-*r/N/A

          \[\leadsto \left(\color{blue}{\frac{\frac{b}{a} \cdot d}{{c}^{2} + {d}^{2}}} + \frac{c}{{c}^{2} + {d}^{2}}\right) \cdot a \]
        6. div-add-revN/A

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

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

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

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

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

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

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

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

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

      if -2.20000000000000002e-161 < d < 7e31

      1. Initial program 70.7%

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

          \[\leadsto \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-/.f6465.4

          \[\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.f6465.4

          \[\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) \]
      4. Applied rewrites65.4%

        \[\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)} \]
      5. Taylor expanded in c around inf

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

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

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6.8 \cdot 10^{+76}:\\ \;\;\;\;\mathsf{fma}\left(\frac{a}{d}, \frac{c}{d}, \frac{b}{d}\right)\\ \mathbf{elif}\;d \leq -2.2 \cdot 10^{-161}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{a}, d, c\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot a\\ \mathbf{elif}\;d \leq 7 \cdot 10^{+31}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{a}{d}, \frac{c}{d}, \frac{b}{d}\right)\\ \end{array} \]
    5. Add Preprocessing

    Alternative 4: 65.5% accurate, 0.8× speedup?

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

      1. Initial program 47.5%

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

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

          \[\leadsto \color{blue}{\frac{a}{c}} \]
      5. Applied rewrites72.0%

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

      if -3e-15 < c < 1.64999999999999998e-52

      1. Initial program 69.7%

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

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

          \[\leadsto \color{blue}{\frac{b}{d}} \]
      5. Applied rewrites69.2%

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

      if 1.64999999999999998e-52 < c < 1.4e125

      1. Initial program 78.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{a \cdot c}{{c}^{2} + {d}^{2}}} \]
      6. Step-by-step derivation
        1. associate-/l*N/A

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

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

          \[\leadsto a \cdot \color{blue}{\frac{c}{{c}^{2} + {d}^{2}}} \]
        4. unpow2N/A

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

          \[\leadsto a \cdot \frac{c}{\color{blue}{\mathsf{fma}\left(c, c, {d}^{2}\right)}} \]
        6. unpow2N/A

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3 \cdot 10^{-15}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 1.65 \cdot 10^{-52}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 1.4 \cdot 10^{+125}:\\ \;\;\;\;a \cdot \frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 5: 65.0% accurate, 0.8× speedup?

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

      1. Initial program 47.5%

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

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

          \[\leadsto \color{blue}{\frac{a}{c}} \]
      5. Applied rewrites72.0%

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

      if -3e-15 < c < 2.8e-51

      1. Initial program 69.7%

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

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

          \[\leadsto \color{blue}{\frac{b}{d}} \]
      5. Applied rewrites69.2%

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

      if 2.8e-51 < c < 7.3999999999999993e122

      1. Initial program 78.0%

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

        \[\leadsto \color{blue}{\frac{a \cdot c}{{c}^{2} + {d}^{2}}} \]
      4. Step-by-step derivation
        1. *-commutativeN/A

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

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

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

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

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

          \[\leadsto \frac{a}{\color{blue}{{d}^{2} + {c}^{2}}} \cdot c \]
        7. unpow2N/A

          \[\leadsto \frac{a}{{d}^{2} + \color{blue}{c \cdot c}} \cdot c \]
        8. fp-cancel-sign-sub-invN/A

          \[\leadsto \frac{a}{\color{blue}{{d}^{2} - \left(\mathsf{neg}\left(c\right)\right) \cdot c}} \cdot c \]
        9. mul-1-negN/A

          \[\leadsto \frac{a}{{d}^{2} - \color{blue}{\left(-1 \cdot c\right)} \cdot c} \cdot c \]
        10. fp-cancel-sub-sign-invN/A

          \[\leadsto \frac{a}{\color{blue}{{d}^{2} + \left(\mathsf{neg}\left(-1 \cdot c\right)\right) \cdot c}} \cdot c \]
        11. unpow2N/A

          \[\leadsto \frac{a}{\color{blue}{d \cdot d} + \left(\mathsf{neg}\left(-1 \cdot c\right)\right) \cdot c} \cdot c \]
        12. distribute-lft-neg-outN/A

          \[\leadsto \frac{a}{d \cdot d + \color{blue}{\left(\left(\mathsf{neg}\left(-1\right)\right) \cdot c\right)} \cdot c} \cdot c \]
        13. metadata-evalN/A

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

          \[\leadsto \frac{a}{d \cdot d + \color{blue}{c} \cdot c} \cdot c \]
        15. unpow2N/A

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

          \[\leadsto \frac{a}{\color{blue}{\mathsf{fma}\left(d, d, {c}^{2}\right)}} \cdot c \]
        17. unpow2N/A

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

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

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

    Alternative 6: 78.5% accurate, 0.9× speedup?

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

      1. Initial program 51.0%

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(-1 \cdot \frac{b \cdot d}{c}\right)\right)} + \left(-1 \cdot a\right) \cdot -1}{c} \]
        10. mul-1-negN/A

          \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{b \cdot d}{c}\right)\right)}\right)\right) + \left(-1 \cdot a\right) \cdot -1}{c} \]
        11. remove-double-negN/A

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

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

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

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

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

          \[\leadsto \frac{\frac{b}{c} \cdot d + \color{blue}{\left(\mathsf{neg}\left(-1 \cdot a\right)\right)}}{c} \]
        17. mul-1-negN/A

          \[\leadsto \frac{\frac{b}{c} \cdot d + \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(a\right)\right)}\right)\right)}{c} \]
        18. remove-double-negN/A

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

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

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

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

      if -1.42e24 < c < 4.5e-13

      1. Initial program 71.9%

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

          \[\leadsto \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-/.f6470.1

          \[\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.f6470.1

          \[\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) \]
      4. Applied rewrites70.1%

        \[\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)} \]
      5. Taylor expanded in c around 0

        \[\leadsto \color{blue}{\frac{b}{d} + \frac{a \cdot c}{{d}^{2}}} \]
      6. Step-by-step derivation
        1. unpow2N/A

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.42 \cdot 10^{+24} \lor \neg \left(c \leq 4.5 \cdot 10^{-13}\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 7: 77.6% accurate, 0.9× speedup?

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

      1. Initial program 48.7%

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

          \[\leadsto \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-/.f6452.9

          \[\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.f6452.9

          \[\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) \]
      4. Applied rewrites52.9%

        \[\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)} \]
      5. Taylor expanded in c around inf

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

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

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

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

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

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

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

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

      if -1.49999999999999997e24 < c < 2.60000000000000007e45

      1. Initial program 72.5%

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

          \[\leadsto \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-/.f6471.0

          \[\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.f6471.0

          \[\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) \]
      4. Applied rewrites71.0%

        \[\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)} \]
      5. Taylor expanded in c around 0

        \[\leadsto \color{blue}{\frac{b}{d} + \frac{a \cdot c}{{d}^{2}}} \]
      6. Step-by-step derivation
        1. unpow2N/A

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.5 \cdot 10^{+24} \lor \neg \left(c \leq 2.6 \cdot 10^{+45}\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 8: 72.4% accurate, 0.9× speedup?

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

      1. Initial program 50.6%

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

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

          \[\leadsto \color{blue}{\frac{a}{c}} \]
      5. Applied rewrites69.6%

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

      if -7.7999999999999996e-14 < c < 1.24e82

      1. Initial program 71.1%

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

          \[\leadsto \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-/.f6470.3

          \[\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.f6470.3

          \[\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) \]
      4. Applied rewrites70.3%

        \[\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)} \]
      5. Taylor expanded in c around 0

        \[\leadsto \color{blue}{\frac{b}{d} + \frac{a \cdot c}{{d}^{2}}} \]
      6. Step-by-step derivation
        1. unpow2N/A

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -7.8 \cdot 10^{-14} \lor \neg \left(c \leq 1.24 \cdot 10^{+82}\right):\\ \;\;\;\;\frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 9: 64.7% accurate, 0.9× speedup?

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

      1. Initial program 31.2%

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

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

          \[\leadsto \color{blue}{\frac{b}{d}} \]
      5. Applied rewrites71.4%

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

      if -1.25000000000000001e154 < d < -2.39999999999999989e-129

      1. Initial program 74.9%

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

        \[\leadsto \color{blue}{\frac{b \cdot d}{{c}^{2} + {d}^{2}}} \]
      4. Step-by-step derivation
        1. *-commutativeN/A

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

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

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

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

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

          \[\leadsto \frac{b}{\color{blue}{{d}^{2} + {c}^{2}}} \cdot d \]
        7. unpow2N/A

          \[\leadsto \frac{b}{{d}^{2} + \color{blue}{c \cdot c}} \cdot d \]
        8. fp-cancel-sign-sub-invN/A

          \[\leadsto \frac{b}{\color{blue}{{d}^{2} - \left(\mathsf{neg}\left(c\right)\right) \cdot c}} \cdot d \]
        9. mul-1-negN/A

          \[\leadsto \frac{b}{{d}^{2} - \color{blue}{\left(-1 \cdot c\right)} \cdot c} \cdot d \]
        10. fp-cancel-sub-sign-invN/A

          \[\leadsto \frac{b}{\color{blue}{{d}^{2} + \left(\mathsf{neg}\left(-1 \cdot c\right)\right) \cdot c}} \cdot d \]
        11. unpow2N/A

          \[\leadsto \frac{b}{\color{blue}{d \cdot d} + \left(\mathsf{neg}\left(-1 \cdot c\right)\right) \cdot c} \cdot d \]
        12. distribute-lft-neg-outN/A

          \[\leadsto \frac{b}{d \cdot d + \color{blue}{\left(\left(\mathsf{neg}\left(-1\right)\right) \cdot c\right)} \cdot c} \cdot d \]
        13. metadata-evalN/A

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

          \[\leadsto \frac{b}{d \cdot d + \color{blue}{c} \cdot c} \cdot d \]
        15. unpow2N/A

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

          \[\leadsto \frac{b}{\color{blue}{\mathsf{fma}\left(d, d, {c}^{2}\right)}} \cdot d \]
        17. unpow2N/A

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

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

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

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

        if -2.39999999999999989e-129 < d < 7.50000000000000042e54

        1. Initial program 72.5%

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

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

            \[\leadsto \color{blue}{\frac{a}{c}} \]
        5. Applied rewrites69.3%

          \[\leadsto \color{blue}{\frac{a}{c}} \]
      7. Recombined 3 regimes into one program.
      8. Add Preprocessing

      Alternative 10: 63.6% accurate, 1.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -3 \cdot 10^{-15} \lor \neg \left(c \leq 2.8 \cdot 10^{-51}\right):\\ \;\;\;\;\frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \end{array} \]
      (FPCore (a b c d)
       :precision binary64
       (if (or (<= c -3e-15) (not (<= c 2.8e-51))) (/ a c) (/ b d)))
      double code(double a, double b, double c, double d) {
      	double tmp;
      	if ((c <= -3e-15) || !(c <= 2.8e-51)) {
      		tmp = a / c;
      	} else {
      		tmp = b / d;
      	}
      	return tmp;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(a, b, c, d)
      use fmin_fmax_functions
          real(8), intent (in) :: a
          real(8), intent (in) :: b
          real(8), intent (in) :: c
          real(8), intent (in) :: d
          real(8) :: tmp
          if ((c <= (-3d-15)) .or. (.not. (c <= 2.8d-51))) then
              tmp = a / c
          else
              tmp = b / d
          end if
          code = tmp
      end function
      
      public static double code(double a, double b, double c, double d) {
      	double tmp;
      	if ((c <= -3e-15) || !(c <= 2.8e-51)) {
      		tmp = a / c;
      	} else {
      		tmp = b / d;
      	}
      	return tmp;
      }
      
      def code(a, b, c, d):
      	tmp = 0
      	if (c <= -3e-15) or not (c <= 2.8e-51):
      		tmp = a / c
      	else:
      		tmp = b / d
      	return tmp
      
      function code(a, b, c, d)
      	tmp = 0.0
      	if ((c <= -3e-15) || !(c <= 2.8e-51))
      		tmp = Float64(a / c);
      	else
      		tmp = Float64(b / d);
      	end
      	return tmp
      end
      
      function tmp_2 = code(a, b, c, d)
      	tmp = 0.0;
      	if ((c <= -3e-15) || ~((c <= 2.8e-51)))
      		tmp = a / c;
      	else
      		tmp = b / d;
      	end
      	tmp_2 = tmp;
      end
      
      code[a_, b_, c_, d_] := If[Or[LessEqual[c, -3e-15], N[Not[LessEqual[c, 2.8e-51]], $MachinePrecision]], N[(a / c), $MachinePrecision], N[(b / d), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;c \leq -3 \cdot 10^{-15} \lor \neg \left(c \leq 2.8 \cdot 10^{-51}\right):\\
      \;\;\;\;\frac{a}{c}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{b}{d}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if c < -3e-15 or 2.8e-51 < c

        1. Initial program 54.6%

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

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

            \[\leadsto \color{blue}{\frac{a}{c}} \]
        5. Applied rewrites65.3%

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

        if -3e-15 < c < 2.8e-51

        1. Initial program 69.7%

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

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

            \[\leadsto \color{blue}{\frac{b}{d}} \]
        5. Applied rewrites69.2%

          \[\leadsto \color{blue}{\frac{b}{d}} \]
      3. Recombined 2 regimes into one program.
      4. Final simplification66.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3 \cdot 10^{-15} \lor \neg \left(c \leq 2.8 \cdot 10^{-51}\right):\\ \;\;\;\;\frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \]
      5. Add Preprocessing

      Alternative 11: 43.0% accurate, 3.2× speedup?

      \[\begin{array}{l} \\ \frac{a}{c} \end{array} \]
      (FPCore (a b c d) :precision binary64 (/ a c))
      double code(double a, double b, double c, double d) {
      	return a / c;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(a, b, c, d)
      use fmin_fmax_functions
          real(8), intent (in) :: a
          real(8), intent (in) :: b
          real(8), intent (in) :: c
          real(8), intent (in) :: d
          code = a / c
      end function
      
      public static double code(double a, double b, double c, double d) {
      	return a / c;
      }
      
      def code(a, b, c, d):
      	return a / c
      
      function code(a, b, c, d)
      	return Float64(a / c)
      end
      
      function tmp = code(a, b, c, d)
      	tmp = a / c;
      end
      
      code[a_, b_, c_, d_] := N[(a / c), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      \frac{a}{c}
      \end{array}
      
      Derivation
      1. Initial program 60.7%

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

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

          \[\leadsto \color{blue}{\frac{a}{c}} \]
      5. Applied rewrites44.9%

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

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

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|d\right| < \left|c\right|:\\ \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\ \end{array} \end{array} \]
      (FPCore (a b c d)
       :precision binary64
       (if (< (fabs d) (fabs c))
         (/ (+ a (* b (/ d c))) (+ c (* d (/ d c))))
         (/ (+ b (* a (/ c d))) (+ d (* c (/ c d))))))
      double code(double a, double b, double c, double d) {
      	double tmp;
      	if (fabs(d) < fabs(c)) {
      		tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
      	} else {
      		tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
      	}
      	return tmp;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(a, b, c, d)
      use fmin_fmax_functions
          real(8), intent (in) :: a
          real(8), intent (in) :: b
          real(8), intent (in) :: c
          real(8), intent (in) :: d
          real(8) :: tmp
          if (abs(d) < abs(c)) then
              tmp = (a + (b * (d / c))) / (c + (d * (d / c)))
          else
              tmp = (b + (a * (c / d))) / (d + (c * (c / d)))
          end if
          code = tmp
      end function
      
      public static double code(double a, double b, double c, double d) {
      	double tmp;
      	if (Math.abs(d) < Math.abs(c)) {
      		tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
      	} else {
      		tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
      	}
      	return tmp;
      }
      
      def code(a, b, c, d):
      	tmp = 0
      	if math.fabs(d) < math.fabs(c):
      		tmp = (a + (b * (d / c))) / (c + (d * (d / c)))
      	else:
      		tmp = (b + (a * (c / d))) / (d + (c * (c / d)))
      	return tmp
      
      function code(a, b, c, d)
      	tmp = 0.0
      	if (abs(d) < abs(c))
      		tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c))));
      	else
      		tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d))));
      	end
      	return tmp
      end
      
      function tmp_2 = code(a, b, c, d)
      	tmp = 0.0;
      	if (abs(d) < abs(c))
      		tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
      	else
      		tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
      	end
      	tmp_2 = tmp;
      end
      
      code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;\left|d\right| < \left|c\right|:\\
      \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
      
      
      \end{array}
      \end{array}
      

      Reproduce

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