Complex division, real part

Percentage Accurate: 62.3% → 82.2%
Time: 6.9s
Alternatives: 9
Speedup: 1.6×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 62.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
	return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
    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: 82.2% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -1.66 \cdot 10^{+97}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}{d}\\ \mathbf{elif}\;d \leq -3.5 \cdot 10^{-57}:\\ \;\;\;\;\frac{b \cdot d + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{elif}\;d \leq 1.25 \cdot 10^{-159}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\ \mathbf{elif}\;d \leq 7.5 \cdot 10^{+146}:\\ \;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{\mathsf{fma}\left(d, b, c \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= d -1.66e+97)
   (/ (fma (/ a d) c b) d)
   (if (<= d -3.5e-57)
     (/ (+ (* b d) (* c a)) (+ (* d d) (* c c)))
     (if (<= d 1.25e-159)
       (/ (fma (/ b c) d a) c)
       (if (<= d 7.5e+146)
         (/ 1.0 (/ (fma d d (* c c)) (fma d b (* c a))))
         (/ (fma a (/ c d) b) d))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -1.66e+97) {
		tmp = fma((a / d), c, b) / d;
	} else if (d <= -3.5e-57) {
		tmp = ((b * d) + (c * a)) / ((d * d) + (c * c));
	} else if (d <= 1.25e-159) {
		tmp = fma((b / c), d, a) / c;
	} else if (d <= 7.5e+146) {
		tmp = 1.0 / (fma(d, d, (c * c)) / fma(d, b, (c * a)));
	} else {
		tmp = fma(a, (c / d), b) / d;
	}
	return tmp;
}
function code(a, b, c, d)
	tmp = 0.0
	if (d <= -1.66e+97)
		tmp = Float64(fma(Float64(a / d), c, b) / d);
	elseif (d <= -3.5e-57)
		tmp = Float64(Float64(Float64(b * d) + Float64(c * a)) / Float64(Float64(d * d) + Float64(c * c)));
	elseif (d <= 1.25e-159)
		tmp = Float64(fma(Float64(b / c), d, a) / c);
	elseif (d <= 7.5e+146)
		tmp = Float64(1.0 / Float64(fma(d, d, Float64(c * c)) / fma(d, b, Float64(c * a))));
	else
		tmp = Float64(fma(a, Float64(c / d), b) / d);
	end
	return tmp
end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.66e+97], N[(N[(N[(a / d), $MachinePrecision] * c + b), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -3.5e-57], N[(N[(N[(b * d), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.25e-159], N[(N[(N[(b / c), $MachinePrecision] * d + a), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 7.5e+146], N[(1.0 / N[(N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision] / N[(d * b + N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a * N[(c / d), $MachinePrecision] + b), $MachinePrecision] / d), $MachinePrecision]]]]]
\begin{array}{l}

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

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

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

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

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


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

    1. Initial program 38.7%

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

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

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

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

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

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

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

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

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

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

    if -1.6599999999999999e97 < d < -3.49999999999999991e-57

    1. Initial program 77.5%

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

    if -3.49999999999999991e-57 < d < 1.25000000000000008e-159

    1. Initial program 66.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. +-commutativeN/A

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

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

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

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

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

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

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

    if 1.25000000000000008e-159 < d < 7.49999999999999983e146

    1. Initial program 84.8%

      \[\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. clear-numN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.49999999999999983e146 < d

    1. Initial program 29.7%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d} \]
    7. Recombined 5 regimes into one program.
    8. Final simplification89.0%

      \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.66 \cdot 10^{+97}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}{d}\\ \mathbf{elif}\;d \leq -3.5 \cdot 10^{-57}:\\ \;\;\;\;\frac{b \cdot d + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{elif}\;d \leq 1.25 \cdot 10^{-159}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\ \mathbf{elif}\;d \leq 7.5 \cdot 10^{+146}:\\ \;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{\mathsf{fma}\left(d, b, c \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\ \end{array} \]
    9. Add Preprocessing

    Alternative 2: 82.4% accurate, 0.6× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b \cdot d + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{if}\;d \leq -1.66 \cdot 10^{+97}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}{d}\\ \mathbf{elif}\;d \leq -3.5 \cdot 10^{-57}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 1.25 \cdot 10^{-159}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\ \mathbf{elif}\;d \leq 7.5 \cdot 10^{+146}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\ \end{array} \end{array} \]
    (FPCore (a b c d)
     :precision binary64
     (let* ((t_0 (/ (+ (* b d) (* c a)) (+ (* d d) (* c c)))))
       (if (<= d -1.66e+97)
         (/ (fma (/ a d) c b) d)
         (if (<= d -3.5e-57)
           t_0
           (if (<= d 1.25e-159)
             (/ (fma (/ b c) d a) c)
             (if (<= d 7.5e+146) t_0 (/ (fma a (/ c d) b) d)))))))
    double code(double a, double b, double c, double d) {
    	double t_0 = ((b * d) + (c * a)) / ((d * d) + (c * c));
    	double tmp;
    	if (d <= -1.66e+97) {
    		tmp = fma((a / d), c, b) / d;
    	} else if (d <= -3.5e-57) {
    		tmp = t_0;
    	} else if (d <= 1.25e-159) {
    		tmp = fma((b / c), d, a) / c;
    	} else if (d <= 7.5e+146) {
    		tmp = t_0;
    	} else {
    		tmp = fma(a, (c / d), b) / d;
    	}
    	return tmp;
    }
    
    function code(a, b, c, d)
    	t_0 = Float64(Float64(Float64(b * d) + Float64(c * a)) / Float64(Float64(d * d) + Float64(c * c)))
    	tmp = 0.0
    	if (d <= -1.66e+97)
    		tmp = Float64(fma(Float64(a / d), c, b) / d);
    	elseif (d <= -3.5e-57)
    		tmp = t_0;
    	elseif (d <= 1.25e-159)
    		tmp = Float64(fma(Float64(b / c), d, a) / c);
    	elseif (d <= 7.5e+146)
    		tmp = t_0;
    	else
    		tmp = Float64(fma(a, Float64(c / d), b) / d);
    	end
    	return tmp
    end
    
    code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * d), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.66e+97], N[(N[(N[(a / d), $MachinePrecision] * c + b), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -3.5e-57], t$95$0, If[LessEqual[d, 1.25e-159], N[(N[(N[(b / c), $MachinePrecision] * d + a), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 7.5e+146], t$95$0, N[(N[(a * N[(c / d), $MachinePrecision] + b), $MachinePrecision] / d), $MachinePrecision]]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{b \cdot d + c \cdot a}{d \cdot d + c \cdot c}\\
    \mathbf{if}\;d \leq -1.66 \cdot 10^{+97}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}{d}\\
    
    \mathbf{elif}\;d \leq -3.5 \cdot 10^{-57}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;d \leq 1.25 \cdot 10^{-159}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\
    
    \mathbf{elif}\;d \leq 7.5 \cdot 10^{+146}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 4 regimes
    2. if d < -1.6599999999999999e97

      1. Initial program 38.7%

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

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

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

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

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

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

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

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

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

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

      if -1.6599999999999999e97 < d < -3.49999999999999991e-57 or 1.25000000000000008e-159 < d < 7.49999999999999983e146

      1. Initial program 82.3%

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

      if -3.49999999999999991e-57 < d < 1.25000000000000008e-159

      1. Initial program 66.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. +-commutativeN/A

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

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

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

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

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

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

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

      if 7.49999999999999983e146 < d

      1. Initial program 29.7%

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d} \]
      7. Recombined 4 regimes into one program.
      8. Final simplification89.0%

        \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.66 \cdot 10^{+97}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}{d}\\ \mathbf{elif}\;d \leq -3.5 \cdot 10^{-57}:\\ \;\;\;\;\frac{b \cdot d + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{elif}\;d \leq 1.25 \cdot 10^{-159}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\ \mathbf{elif}\;d \leq 7.5 \cdot 10^{+146}:\\ \;\;\;\;\frac{b \cdot d + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\ \end{array} \]
      9. Add Preprocessing

      Alternative 3: 64.5% accurate, 0.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -2.3 \cdot 10^{+188}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq -5.2 \cdot 10^{+102}:\\ \;\;\;\;\frac{\frac{a}{d} \cdot c}{d}\\ \mathbf{elif}\;d \leq -3.5 \cdot 10^{-56}:\\ \;\;\;\;\frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d\\ \mathbf{elif}\;d \leq 6.5 \cdot 10^{-52}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;d \leq 1.35 \cdot 10^{+100}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \end{array} \]
      (FPCore (a b c d)
       :precision binary64
       (if (<= d -2.3e+188)
         (/ b d)
         (if (<= d -5.2e+102)
           (/ (* (/ a d) c) d)
           (if (<= d -3.5e-56)
             (* (/ b (fma d d (* c c))) d)
             (if (<= d 6.5e-52)
               (/ a c)
               (if (<= d 1.35e+100) (/ (fma d b (* c a)) (* d d)) (/ b d)))))))
      double code(double a, double b, double c, double d) {
      	double tmp;
      	if (d <= -2.3e+188) {
      		tmp = b / d;
      	} else if (d <= -5.2e+102) {
      		tmp = ((a / d) * c) / d;
      	} else if (d <= -3.5e-56) {
      		tmp = (b / fma(d, d, (c * c))) * d;
      	} else if (d <= 6.5e-52) {
      		tmp = a / c;
      	} else if (d <= 1.35e+100) {
      		tmp = fma(d, b, (c * a)) / (d * d);
      	} else {
      		tmp = b / d;
      	}
      	return tmp;
      }
      
      function code(a, b, c, d)
      	tmp = 0.0
      	if (d <= -2.3e+188)
      		tmp = Float64(b / d);
      	elseif (d <= -5.2e+102)
      		tmp = Float64(Float64(Float64(a / d) * c) / d);
      	elseif (d <= -3.5e-56)
      		tmp = Float64(Float64(b / fma(d, d, Float64(c * c))) * d);
      	elseif (d <= 6.5e-52)
      		tmp = Float64(a / c);
      	elseif (d <= 1.35e+100)
      		tmp = Float64(fma(d, b, Float64(c * a)) / Float64(d * d));
      	else
      		tmp = Float64(b / d);
      	end
      	return tmp
      end
      
      code[a_, b_, c_, d_] := If[LessEqual[d, -2.3e+188], N[(b / d), $MachinePrecision], If[LessEqual[d, -5.2e+102], N[(N[(N[(a / d), $MachinePrecision] * c), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -3.5e-56], N[(N[(b / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision], If[LessEqual[d, 6.5e-52], N[(a / c), $MachinePrecision], If[LessEqual[d, 1.35e+100], N[(N[(d * b + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision], N[(b / d), $MachinePrecision]]]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;d \leq -2.3 \cdot 10^{+188}:\\
      \;\;\;\;\frac{b}{d}\\
      
      \mathbf{elif}\;d \leq -5.2 \cdot 10^{+102}:\\
      \;\;\;\;\frac{\frac{a}{d} \cdot c}{d}\\
      
      \mathbf{elif}\;d \leq -3.5 \cdot 10^{-56}:\\
      \;\;\;\;\frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d\\
      
      \mathbf{elif}\;d \leq 6.5 \cdot 10^{-52}:\\
      \;\;\;\;\frac{a}{c}\\
      
      \mathbf{elif}\;d \leq 1.35 \cdot 10^{+100}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{d \cdot d}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{b}{d}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 5 regimes
      2. if d < -2.30000000000000011e188 or 1.34999999999999999e100 < d

        1. Initial program 36.8%

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

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

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

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

        if -2.30000000000000011e188 < d < -5.20000000000000013e102

        1. Initial program 58.3%

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\frac{a \cdot c}{d}}{d} \]
        7. Step-by-step derivation
          1. Applied rewrites78.8%

            \[\leadsto \frac{\frac{a \cdot c}{d}}{d} \]
          2. Step-by-step derivation
            1. Applied rewrites79.1%

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

            if -5.20000000000000013e102 < d < -3.4999999999999998e-56

            1. Initial program 76.1%

              \[\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}{\color{blue}{d \cdot d} + {c}^{2}} \cdot d \]
              8. lower-fma.f64N/A

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

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

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

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

            if -3.4999999999999998e-56 < d < 6.5e-52

            1. Initial program 68.2%

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

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

                \[\leadsto \color{blue}{\frac{a}{c}} \]
            5. Applied rewrites76.4%

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

            if 6.5e-52 < d < 1.34999999999999999e100

            1. Initial program 91.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 \frac{a \cdot c + b \cdot d}{\color{blue}{{c}^{2}}} \]
            4. Step-by-step derivation
              1. unpow2N/A

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

                \[\leadsto \frac{a \cdot c + b \cdot d}{\color{blue}{c \cdot c}} \]
            5. Applied rewrites31.4%

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.3 \cdot 10^{+188}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq -5.2 \cdot 10^{+102}:\\ \;\;\;\;\frac{\frac{a}{d} \cdot c}{d}\\ \mathbf{elif}\;d \leq -3.5 \cdot 10^{-56}:\\ \;\;\;\;\frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d\\ \mathbf{elif}\;d \leq 6.5 \cdot 10^{-52}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;d \leq 1.35 \cdot 10^{+100}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \]
          5. Add Preprocessing

          Alternative 4: 64.7% accurate, 0.7× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d\\ \mathbf{if}\;d \leq -2.3 \cdot 10^{+188}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq -5.2 \cdot 10^{+102}:\\ \;\;\;\;\frac{\frac{a}{d} \cdot c}{d}\\ \mathbf{elif}\;d \leq -3.5 \cdot 10^{-56}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{-48}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;d \leq 5 \cdot 10^{+104}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \end{array} \]
          (FPCore (a b c d)
           :precision binary64
           (let* ((t_0 (* (/ b (fma d d (* c c))) d)))
             (if (<= d -2.3e+188)
               (/ b d)
               (if (<= d -5.2e+102)
                 (/ (* (/ a d) c) d)
                 (if (<= d -3.5e-56)
                   t_0
                   (if (<= d 1.7e-48) (/ a c) (if (<= d 5e+104) t_0 (/ b d))))))))
          double code(double a, double b, double c, double d) {
          	double t_0 = (b / fma(d, d, (c * c))) * d;
          	double tmp;
          	if (d <= -2.3e+188) {
          		tmp = b / d;
          	} else if (d <= -5.2e+102) {
          		tmp = ((a / d) * c) / d;
          	} else if (d <= -3.5e-56) {
          		tmp = t_0;
          	} else if (d <= 1.7e-48) {
          		tmp = a / c;
          	} else if (d <= 5e+104) {
          		tmp = t_0;
          	} else {
          		tmp = b / d;
          	}
          	return tmp;
          }
          
          function code(a, b, c, d)
          	t_0 = Float64(Float64(b / fma(d, d, Float64(c * c))) * d)
          	tmp = 0.0
          	if (d <= -2.3e+188)
          		tmp = Float64(b / d);
          	elseif (d <= -5.2e+102)
          		tmp = Float64(Float64(Float64(a / d) * c) / d);
          	elseif (d <= -3.5e-56)
          		tmp = t_0;
          	elseif (d <= 1.7e-48)
          		tmp = Float64(a / c);
          	elseif (d <= 5e+104)
          		tmp = t_0;
          	else
          		tmp = Float64(b / d);
          	end
          	return tmp
          end
          
          code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]}, If[LessEqual[d, -2.3e+188], N[(b / d), $MachinePrecision], If[LessEqual[d, -5.2e+102], N[(N[(N[(a / d), $MachinePrecision] * c), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -3.5e-56], t$95$0, If[LessEqual[d, 1.7e-48], N[(a / c), $MachinePrecision], If[LessEqual[d, 5e+104], t$95$0, N[(b / d), $MachinePrecision]]]]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d\\
          \mathbf{if}\;d \leq -2.3 \cdot 10^{+188}:\\
          \;\;\;\;\frac{b}{d}\\
          
          \mathbf{elif}\;d \leq -5.2 \cdot 10^{+102}:\\
          \;\;\;\;\frac{\frac{a}{d} \cdot c}{d}\\
          
          \mathbf{elif}\;d \leq -3.5 \cdot 10^{-56}:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;d \leq 1.7 \cdot 10^{-48}:\\
          \;\;\;\;\frac{a}{c}\\
          
          \mathbf{elif}\;d \leq 5 \cdot 10^{+104}:\\
          \;\;\;\;t\_0\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{b}{d}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 4 regimes
          2. if d < -2.30000000000000011e188 or 4.9999999999999997e104 < d

            1. Initial program 37.3%

              \[\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-/.f6482.6

                \[\leadsto \color{blue}{\frac{b}{d}} \]
            5. Applied rewrites82.6%

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

            if -2.30000000000000011e188 < d < -5.20000000000000013e102

            1. Initial program 58.3%

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{\frac{a \cdot c}{d}}{d} \]
            7. Step-by-step derivation
              1. Applied rewrites78.8%

                \[\leadsto \frac{\frac{a \cdot c}{d}}{d} \]
              2. Step-by-step derivation
                1. Applied rewrites79.1%

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

                if -5.20000000000000013e102 < d < -3.4999999999999998e-56 or 1.70000000000000014e-48 < d < 4.9999999999999997e104

                1. Initial program 82.5%

                  \[\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}{\color{blue}{d \cdot d} + {c}^{2}} \cdot d \]
                  8. lower-fma.f64N/A

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

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

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

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

                if -3.4999999999999998e-56 < d < 1.70000000000000014e-48

                1. Initial program 68.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-/.f6475.8

                    \[\leadsto \color{blue}{\frac{a}{c}} \]
                5. Applied rewrites75.8%

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

              Alternative 5: 64.8% accurate, 0.7× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d\\ \mathbf{if}\;d \leq -2.3 \cdot 10^{+188}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq -5.2 \cdot 10^{+102}:\\ \;\;\;\;\frac{\frac{a}{d}}{d} \cdot c\\ \mathbf{elif}\;d \leq -3.5 \cdot 10^{-56}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{-48}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;d \leq 5 \cdot 10^{+104}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \end{array} \]
              (FPCore (a b c d)
               :precision binary64
               (let* ((t_0 (* (/ b (fma d d (* c c))) d)))
                 (if (<= d -2.3e+188)
                   (/ b d)
                   (if (<= d -5.2e+102)
                     (* (/ (/ a d) d) c)
                     (if (<= d -3.5e-56)
                       t_0
                       (if (<= d 1.7e-48) (/ a c) (if (<= d 5e+104) t_0 (/ b d))))))))
              double code(double a, double b, double c, double d) {
              	double t_0 = (b / fma(d, d, (c * c))) * d;
              	double tmp;
              	if (d <= -2.3e+188) {
              		tmp = b / d;
              	} else if (d <= -5.2e+102) {
              		tmp = ((a / d) / d) * c;
              	} else if (d <= -3.5e-56) {
              		tmp = t_0;
              	} else if (d <= 1.7e-48) {
              		tmp = a / c;
              	} else if (d <= 5e+104) {
              		tmp = t_0;
              	} else {
              		tmp = b / d;
              	}
              	return tmp;
              }
              
              function code(a, b, c, d)
              	t_0 = Float64(Float64(b / fma(d, d, Float64(c * c))) * d)
              	tmp = 0.0
              	if (d <= -2.3e+188)
              		tmp = Float64(b / d);
              	elseif (d <= -5.2e+102)
              		tmp = Float64(Float64(Float64(a / d) / d) * c);
              	elseif (d <= -3.5e-56)
              		tmp = t_0;
              	elseif (d <= 1.7e-48)
              		tmp = Float64(a / c);
              	elseif (d <= 5e+104)
              		tmp = t_0;
              	else
              		tmp = Float64(b / d);
              	end
              	return tmp
              end
              
              code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]}, If[LessEqual[d, -2.3e+188], N[(b / d), $MachinePrecision], If[LessEqual[d, -5.2e+102], N[(N[(N[(a / d), $MachinePrecision] / d), $MachinePrecision] * c), $MachinePrecision], If[LessEqual[d, -3.5e-56], t$95$0, If[LessEqual[d, 1.7e-48], N[(a / c), $MachinePrecision], If[LessEqual[d, 5e+104], t$95$0, N[(b / d), $MachinePrecision]]]]]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              t_0 := \frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot d\\
              \mathbf{if}\;d \leq -2.3 \cdot 10^{+188}:\\
              \;\;\;\;\frac{b}{d}\\
              
              \mathbf{elif}\;d \leq -5.2 \cdot 10^{+102}:\\
              \;\;\;\;\frac{\frac{a}{d}}{d} \cdot c\\
              
              \mathbf{elif}\;d \leq -3.5 \cdot 10^{-56}:\\
              \;\;\;\;t\_0\\
              
              \mathbf{elif}\;d \leq 1.7 \cdot 10^{-48}:\\
              \;\;\;\;\frac{a}{c}\\
              
              \mathbf{elif}\;d \leq 5 \cdot 10^{+104}:\\
              \;\;\;\;t\_0\\
              
              \mathbf{else}:\\
              \;\;\;\;\frac{b}{d}\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 4 regimes
              2. if d < -2.30000000000000011e188 or 4.9999999999999997e104 < d

                1. Initial program 37.3%

                  \[\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-/.f6482.6

                    \[\leadsto \color{blue}{\frac{b}{d}} \]
                5. Applied rewrites82.6%

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

                if -2.30000000000000011e188 < d < -5.20000000000000013e102

                1. Initial program 58.3%

                  \[\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}{\color{blue}{d \cdot d} + {c}^{2}} \cdot c \]
                  8. lower-fma.f64N/A

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

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

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

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

                  \[\leadsto \frac{a}{{d}^{2}} \cdot c \]
                7. Step-by-step derivation
                  1. Applied rewrites66.0%

                    \[\leadsto \frac{\frac{a}{d}}{d} \cdot c \]

                  if -5.20000000000000013e102 < d < -3.4999999999999998e-56 or 1.70000000000000014e-48 < d < 4.9999999999999997e104

                  1. Initial program 82.5%

                    \[\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}{\color{blue}{d \cdot d} + {c}^{2}} \cdot d \]
                    8. lower-fma.f64N/A

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

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

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

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

                  if -3.4999999999999998e-56 < d < 1.70000000000000014e-48

                  1. Initial program 68.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-/.f6475.8

                      \[\leadsto \color{blue}{\frac{a}{c}} \]
                  5. Applied rewrites75.8%

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

                Alternative 6: 73.3% accurate, 0.8× speedup?

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

                  1. Initial program 42.4%

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

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

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

                  if -1.8e93 < c < -2.60000000000000017e-21

                  1. Initial program 80.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}{\color{blue}{d \cdot d} + {c}^{2}} \cdot c \]
                    8. lower-fma.f64N/A

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

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

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

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

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

                    if -2.60000000000000017e-21 < c < 1.08e83

                    1. Initial program 75.7%

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.8 \cdot 10^{+93}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq -2.6 \cdot 10^{-21}:\\ \;\;\;\;\frac{c \cdot a}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;c \leq 1.08 \cdot 10^{+83}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
                    9. Add Preprocessing

                    Alternative 7: 77.0% accurate, 0.9× speedup?

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

                      1. Initial program 56.3%

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

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

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

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

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

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

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

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

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

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

                      if -3.5999999999999999e-53 < d < 7.19999999999999976e-52

                      1. Initial program 68.2%

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

                        \[\leadsto \color{blue}{\frac{a + \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. +-commutativeN/A

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

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

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

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

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

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

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

                      if 7.19999999999999976e-52 < d

                      1. Initial program 65.4%

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

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

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

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

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

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

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

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

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

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

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

                      Alternative 8: 63.8% accurate, 1.6× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -2 \cdot 10^{-53}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq 1.15 \cdot 10^{-43}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \end{array} \]
                      (FPCore (a b c d)
                       :precision binary64
                       (if (<= d -2e-53) (/ b d) (if (<= d 1.15e-43) (/ a c) (/ b d))))
                      double code(double a, double b, double c, double d) {
                      	double tmp;
                      	if (d <= -2e-53) {
                      		tmp = b / d;
                      	} else if (d <= 1.15e-43) {
                      		tmp = a / c;
                      	} else {
                      		tmp = b / d;
                      	}
                      	return tmp;
                      }
                      
                      real(8) function code(a, b, c, d)
                          real(8), intent (in) :: a
                          real(8), intent (in) :: b
                          real(8), intent (in) :: c
                          real(8), intent (in) :: d
                          real(8) :: tmp
                          if (d <= (-2d-53)) then
                              tmp = b / d
                          else if (d <= 1.15d-43) then
                              tmp = a / c
                          else
                              tmp = b / d
                          end if
                          code = tmp
                      end function
                      
                      public static double code(double a, double b, double c, double d) {
                      	double tmp;
                      	if (d <= -2e-53) {
                      		tmp = b / d;
                      	} else if (d <= 1.15e-43) {
                      		tmp = a / c;
                      	} else {
                      		tmp = b / d;
                      	}
                      	return tmp;
                      }
                      
                      def code(a, b, c, d):
                      	tmp = 0
                      	if d <= -2e-53:
                      		tmp = b / d
                      	elif d <= 1.15e-43:
                      		tmp = a / c
                      	else:
                      		tmp = b / d
                      	return tmp
                      
                      function code(a, b, c, d)
                      	tmp = 0.0
                      	if (d <= -2e-53)
                      		tmp = Float64(b / d);
                      	elseif (d <= 1.15e-43)
                      		tmp = Float64(a / c);
                      	else
                      		tmp = Float64(b / d);
                      	end
                      	return tmp
                      end
                      
                      function tmp_2 = code(a, b, c, d)
                      	tmp = 0.0;
                      	if (d <= -2e-53)
                      		tmp = b / d;
                      	elseif (d <= 1.15e-43)
                      		tmp = a / c;
                      	else
                      		tmp = b / d;
                      	end
                      	tmp_2 = tmp;
                      end
                      
                      code[a_, b_, c_, d_] := If[LessEqual[d, -2e-53], N[(b / d), $MachinePrecision], If[LessEqual[d, 1.15e-43], N[(a / c), $MachinePrecision], N[(b / d), $MachinePrecision]]]
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      \mathbf{if}\;d \leq -2 \cdot 10^{-53}:\\
                      \;\;\;\;\frac{b}{d}\\
                      
                      \mathbf{elif}\;d \leq 1.15 \cdot 10^{-43}:\\
                      \;\;\;\;\frac{a}{c}\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\frac{b}{d}\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if d < -2.00000000000000006e-53 or 1.1499999999999999e-43 < d

                        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 0

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

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

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

                        if -2.00000000000000006e-53 < d < 1.1499999999999999e-43

                        1. Initial program 68.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-/.f6475.8

                            \[\leadsto \color{blue}{\frac{a}{c}} \]
                        5. Applied rewrites75.8%

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

                      Alternative 9: 42.9% 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;
                      }
                      
                      real(8) function code(a, b, c, d)
                          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 63.9%

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

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

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

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

                      Developer Target 1: 99.4% 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;
                      }
                      
                      real(8) function code(a, b, c, d)
                          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 2024288 
                      (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))))