Complex division, real part

Percentage Accurate: 61.6% → 78.9%
Time: 8.3s
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));
}
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 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.6% 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: 78.9% accurate, 0.6× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -3.69999999999999997e59 or 6.20000000000000011e48 < c

    1. Initial program 44.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-/.f6475.4

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

      \[\leadsto \color{blue}{\frac{a}{c}} \]
    6. Taylor expanded in c around inf

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

        \[\leadsto \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. lower-fma.f64N/A

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

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

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

    if -3.69999999999999997e59 < c < 1.85e-125

    1. Initial program 65.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}{c}} \]
    4. Step-by-step derivation
      1. lower-/.f6418.9

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

      \[\leadsto \color{blue}{\frac{a}{c}} \]
    6. Taylor expanded in c around inf

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

        \[\leadsto \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. lower-fma.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 1.85e-125 < c < 6.20000000000000011e48

      1. Initial program 84.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. div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.7 \cdot 10^{+59}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{c}\\ \mathbf{elif}\;c \leq 1.85 \cdot 10^{-125}:\\ \;\;\;\;\frac{b + \frac{\mathsf{fma}\left(a, c, \frac{c \cdot \left(c \cdot b\right)}{-d}\right)}{d}}{d}\\ \mathbf{elif}\;c \leq 6.2 \cdot 10^{+48}:\\ \;\;\;\;\mathsf{fma}\left(a, c, b \cdot d\right) \cdot \frac{1}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{c}\\ \end{array} \]
    12. Add Preprocessing

    Alternative 2: 80.4% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{c}\\ \mathbf{if}\;c \leq -1.25 \cdot 10^{+60}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 1.85 \cdot 10^{-125}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\ \mathbf{elif}\;c \leq 6.2 \cdot 10^{+48}:\\ \;\;\;\;\mathsf{fma}\left(a, c, b \cdot d\right) \cdot \frac{1}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (a b c d)
     :precision binary64
     (let* ((t_0 (/ (fma d (/ b c) a) c)))
       (if (<= c -1.25e+60)
         t_0
         (if (<= c 1.85e-125)
           (/ (fma a (/ c d) b) d)
           (if (<= c 6.2e+48)
             (* (fma a c (* b d)) (/ 1.0 (fma c c (* d d))))
             t_0)))))
    double code(double a, double b, double c, double d) {
    	double t_0 = fma(d, (b / c), a) / c;
    	double tmp;
    	if (c <= -1.25e+60) {
    		tmp = t_0;
    	} else if (c <= 1.85e-125) {
    		tmp = fma(a, (c / d), b) / d;
    	} else if (c <= 6.2e+48) {
    		tmp = fma(a, c, (b * d)) * (1.0 / fma(c, c, (d * d)));
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    function code(a, b, c, d)
    	t_0 = Float64(fma(d, Float64(b / c), a) / c)
    	tmp = 0.0
    	if (c <= -1.25e+60)
    		tmp = t_0;
    	elseif (c <= 1.85e-125)
    		tmp = Float64(fma(a, Float64(c / d), b) / d);
    	elseif (c <= 6.2e+48)
    		tmp = Float64(fma(a, c, Float64(b * d)) * Float64(1.0 / fma(c, c, Float64(d * d))));
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(d * N[(b / c), $MachinePrecision] + a), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -1.25e+60], t$95$0, If[LessEqual[c, 1.85e-125], N[(N[(a * N[(c / d), $MachinePrecision] + b), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 6.2e+48], N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{c}\\
    \mathbf{if}\;c \leq -1.25 \cdot 10^{+60}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;c \leq 1.85 \cdot 10^{-125}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\
    
    \mathbf{elif}\;c \leq 6.2 \cdot 10^{+48}:\\
    \;\;\;\;\mathsf{fma}\left(a, c, b \cdot d\right) \cdot \frac{1}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if c < -1.24999999999999994e60 or 6.20000000000000011e48 < c

      1. Initial program 44.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-/.f6475.4

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

        \[\leadsto \color{blue}{\frac{a}{c}} \]
      6. Taylor expanded in c around inf

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

          \[\leadsto \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. lower-fma.f64N/A

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

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

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

      if -1.24999999999999994e60 < c < 1.85e-125

      1. Initial program 65.0%

        \[\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. associate-/l*N/A

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

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

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

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

      if 1.85e-125 < c < 6.20000000000000011e48

      1. Initial program 84.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. div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 3: 80.4% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{c}\\ \mathbf{if}\;c \leq -1.25 \cdot 10^{+60}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 1.85 \cdot 10^{-125}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\ \mathbf{elif}\;c \leq 6.2 \cdot 10^{+48}:\\ \;\;\;\;\frac{b \cdot d + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (a b c d)
     :precision binary64
     (let* ((t_0 (/ (fma d (/ b c) a) c)))
       (if (<= c -1.25e+60)
         t_0
         (if (<= c 1.85e-125)
           (/ (fma a (/ c d) b) d)
           (if (<= c 6.2e+48) (/ (+ (* b d) (* c a)) (+ (* d d) (* c c))) t_0)))))
    double code(double a, double b, double c, double d) {
    	double t_0 = fma(d, (b / c), a) / c;
    	double tmp;
    	if (c <= -1.25e+60) {
    		tmp = t_0;
    	} else if (c <= 1.85e-125) {
    		tmp = fma(a, (c / d), b) / d;
    	} else if (c <= 6.2e+48) {
    		tmp = ((b * d) + (c * a)) / ((d * d) + (c * c));
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    function code(a, b, c, d)
    	t_0 = Float64(fma(d, Float64(b / c), a) / c)
    	tmp = 0.0
    	if (c <= -1.25e+60)
    		tmp = t_0;
    	elseif (c <= 1.85e-125)
    		tmp = Float64(fma(a, Float64(c / d), b) / d);
    	elseif (c <= 6.2e+48)
    		tmp = Float64(Float64(Float64(b * d) + Float64(c * a)) / Float64(Float64(d * d) + Float64(c * c)));
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(d * N[(b / c), $MachinePrecision] + a), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -1.25e+60], t$95$0, If[LessEqual[c, 1.85e-125], N[(N[(a * N[(c / d), $MachinePrecision] + b), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 6.2e+48], N[(N[(N[(b * d), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{c}\\
    \mathbf{if}\;c \leq -1.25 \cdot 10^{+60}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;c \leq 1.85 \cdot 10^{-125}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\
    
    \mathbf{elif}\;c \leq 6.2 \cdot 10^{+48}:\\
    \;\;\;\;\frac{b \cdot d + c \cdot a}{d \cdot d + c \cdot c}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if c < -1.24999999999999994e60 or 6.20000000000000011e48 < c

      1. Initial program 44.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-/.f6475.4

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

        \[\leadsto \color{blue}{\frac{a}{c}} \]
      6. Taylor expanded in c around inf

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

          \[\leadsto \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. lower-fma.f64N/A

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

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

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

      if -1.24999999999999994e60 < c < 1.85e-125

      1. Initial program 65.0%

        \[\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. associate-/l*N/A

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

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

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

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

      if 1.85e-125 < c < 6.20000000000000011e48

      1. Initial program 84.3%

        \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
      2. Add Preprocessing
    3. Recombined 3 regimes into one program.
    4. Final simplification83.9%

      \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.25 \cdot 10^{+60}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{c}\\ \mathbf{elif}\;c \leq 1.85 \cdot 10^{-125}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\ \mathbf{elif}\;c \leq 6.2 \cdot 10^{+48}:\\ \;\;\;\;\frac{b \cdot d + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{c}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 4: 77.5% accurate, 0.7× speedup?

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

      1. Initial program 45.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}{c}} \]
      4. Step-by-step derivation
        1. lower-/.f6476.0

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

        \[\leadsto \color{blue}{\frac{a}{c}} \]
      6. Taylor expanded in c around inf

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

          \[\leadsto \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. lower-fma.f64N/A

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

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

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

      if -1.24999999999999994e60 < c < 3.0999999999999999e-52

      1. Initial program 65.2%

        \[\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. associate-/l*N/A

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

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

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

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

      if 3.0999999999999999e-52 < c < 4.50000000000000002e118

      1. Initial program 79.5%

        \[\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. lower-/.f64N/A

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

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

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

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

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

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

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

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

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

        if 4.50000000000000002e118 < c

        1. Initial program 39.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 + \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. associate-/l*N/A

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

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

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

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

      Alternative 5: 77.5% accurate, 0.8× speedup?

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

        1. Initial program 45.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}{c}} \]
        4. Step-by-step derivation
          1. lower-/.f6476.0

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

          \[\leadsto \color{blue}{\frac{a}{c}} \]
        6. Taylor expanded in c around inf

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

            \[\leadsto \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. lower-fma.f64N/A

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

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

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

        if -1.24999999999999994e60 < c < 3.0999999999999999e-52

        1. Initial program 65.2%

          \[\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. associate-/l*N/A

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

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

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

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

        if 3.0999999999999999e-52 < c < 4.50000000000000002e118

        1. Initial program 79.5%

          \[\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. lower-/.f64N/A

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

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

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

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

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

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

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

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

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

          if 4.50000000000000002e118 < c

          1. Initial program 39.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 + \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. associate-/l*N/A

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

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

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

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.25 \cdot 10^{+60}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{c}\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{-52}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\ \mathbf{elif}\;c \leq 4.5 \cdot 10^{+118}:\\ \;\;\;\;a \cdot \frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, \frac{d}{c}, a\right)}{c}\\ \end{array} \]
        9. Add Preprocessing

        Alternative 6: 77.3% accurate, 0.8× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(b, \frac{d}{c}, a\right)}{c}\\ \mathbf{if}\;c \leq -1.25 \cdot 10^{+60}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{-52}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\ \mathbf{elif}\;c \leq 4.5 \cdot 10^{+118}:\\ \;\;\;\;a \cdot \frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
        (FPCore (a b c d)
         :precision binary64
         (let* ((t_0 (/ (fma b (/ d c) a) c)))
           (if (<= c -1.25e+60)
             t_0
             (if (<= c 3.1e-52)
               (/ (fma a (/ c d) b) d)
               (if (<= c 4.5e+118) (* a (/ c (fma c c (* d d)))) t_0)))))
        double code(double a, double b, double c, double d) {
        	double t_0 = fma(b, (d / c), a) / c;
        	double tmp;
        	if (c <= -1.25e+60) {
        		tmp = t_0;
        	} else if (c <= 3.1e-52) {
        		tmp = fma(a, (c / d), b) / d;
        	} else if (c <= 4.5e+118) {
        		tmp = a * (c / fma(c, c, (d * d)));
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        function code(a, b, c, d)
        	t_0 = Float64(fma(b, Float64(d / c), a) / c)
        	tmp = 0.0
        	if (c <= -1.25e+60)
        		tmp = t_0;
        	elseif (c <= 3.1e-52)
        		tmp = Float64(fma(a, Float64(c / d), b) / d);
        	elseif (c <= 4.5e+118)
        		tmp = Float64(a * Float64(c / fma(c, c, Float64(d * d))));
        	else
        		tmp = t_0;
        	end
        	return tmp
        end
        
        code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * N[(d / c), $MachinePrecision] + a), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -1.25e+60], t$95$0, If[LessEqual[c, 3.1e-52], N[(N[(a * N[(c / d), $MachinePrecision] + b), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 4.5e+118], N[(a * N[(c / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \frac{\mathsf{fma}\left(b, \frac{d}{c}, a\right)}{c}\\
        \mathbf{if}\;c \leq -1.25 \cdot 10^{+60}:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;c \leq 3.1 \cdot 10^{-52}:\\
        \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\
        
        \mathbf{elif}\;c \leq 4.5 \cdot 10^{+118}:\\
        \;\;\;\;a \cdot \frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if c < -1.24999999999999994e60 or 4.50000000000000002e118 < c

          1. Initial program 42.6%

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

            \[\leadsto \color{blue}{\frac{a + \frac{b \cdot d}{c}}{c}} \]
          4. Step-by-step derivation
            1. 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. lower-fma.f64N/A

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

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

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

          if -1.24999999999999994e60 < c < 3.0999999999999999e-52

          1. Initial program 65.2%

            \[\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. associate-/l*N/A

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

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

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

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

          if 3.0999999999999999e-52 < c < 4.50000000000000002e118

          1. Initial program 79.5%

            \[\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. lower-/.f64N/A

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

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

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

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

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

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

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

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

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.25 \cdot 10^{+60}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, \frac{d}{c}, a\right)}{c}\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{-52}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\ \mathbf{elif}\;c \leq 4.5 \cdot 10^{+118}:\\ \;\;\;\;a \cdot \frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, \frac{d}{c}, a\right)}{c}\\ \end{array} \]
          9. Add Preprocessing

          Alternative 7: 73.4% accurate, 0.8× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -1.25 \cdot 10^{+60}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{-52}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\ \mathbf{elif}\;c \leq 1.3 \cdot 10^{+164}:\\ \;\;\;\;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 -1.25e+60)
             (/ a c)
             (if (<= c 3.1e-52)
               (/ (fma a (/ c d) b) d)
               (if (<= c 1.3e+164) (* a (/ c (fma c c (* d d)))) (/ a c)))))
          double code(double a, double b, double c, double d) {
          	double tmp;
          	if (c <= -1.25e+60) {
          		tmp = a / c;
          	} else if (c <= 3.1e-52) {
          		tmp = fma(a, (c / d), b) / d;
          	} else if (c <= 1.3e+164) {
          		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 <= -1.25e+60)
          		tmp = Float64(a / c);
          	elseif (c <= 3.1e-52)
          		tmp = Float64(fma(a, Float64(c / d), b) / d);
          	elseif (c <= 1.3e+164)
          		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, -1.25e+60], N[(a / c), $MachinePrecision], If[LessEqual[c, 3.1e-52], N[(N[(a * N[(c / d), $MachinePrecision] + b), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1.3e+164], 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 -1.25 \cdot 10^{+60}:\\
          \;\;\;\;\frac{a}{c}\\
          
          \mathbf{elif}\;c \leq 3.1 \cdot 10^{-52}:\\
          \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\
          
          \mathbf{elif}\;c \leq 1.3 \cdot 10^{+164}:\\
          \;\;\;\;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 < -1.24999999999999994e60 or 1.3e164 < c

            1. Initial program 40.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-/.f6476.9

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

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

            if -1.24999999999999994e60 < c < 3.0999999999999999e-52

            1. Initial program 65.2%

              \[\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. associate-/l*N/A

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

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

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

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

            if 3.0999999999999999e-52 < c < 1.3e164

            1. Initial program 72.8%

              \[\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. lower-/.f64N/A

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

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

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

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

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

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

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

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

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

              \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.25 \cdot 10^{+60}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{-52}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\ \mathbf{elif}\;c \leq 1.3 \cdot 10^{+164}:\\ \;\;\;\;a \cdot \frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
            9. Add Preprocessing

            Alternative 8: 65.0% accurate, 0.8× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -3.8 \cdot 10^{+57}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 7.8 \cdot 10^{-53}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 1.3 \cdot 10^{+164}:\\ \;\;\;\;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 -3.8e+57)
               (/ a c)
               (if (<= c 7.8e-53)
                 (/ b d)
                 (if (<= c 1.3e+164) (* a (/ c (fma c c (* d d)))) (/ a c)))))
            double code(double a, double b, double c, double d) {
            	double tmp;
            	if (c <= -3.8e+57) {
            		tmp = a / c;
            	} else if (c <= 7.8e-53) {
            		tmp = b / d;
            	} else if (c <= 1.3e+164) {
            		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 <= -3.8e+57)
            		tmp = Float64(a / c);
            	elseif (c <= 7.8e-53)
            		tmp = Float64(b / d);
            	elseif (c <= 1.3e+164)
            		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, -3.8e+57], N[(a / c), $MachinePrecision], If[LessEqual[c, 7.8e-53], N[(b / d), $MachinePrecision], If[LessEqual[c, 1.3e+164], 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.8 \cdot 10^{+57}:\\
            \;\;\;\;\frac{a}{c}\\
            
            \mathbf{elif}\;c \leq 7.8 \cdot 10^{-53}:\\
            \;\;\;\;\frac{b}{d}\\
            
            \mathbf{elif}\;c \leq 1.3 \cdot 10^{+164}:\\
            \;\;\;\;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 < -3.7999999999999999e57 or 1.3e164 < c

              1. Initial program 41.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}{c}} \]
              4. Step-by-step derivation
                1. lower-/.f6475.3

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

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

              if -3.7999999999999999e57 < c < 7.8000000000000004e-53

              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 c around 0

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

                  \[\leadsto \color{blue}{\frac{b}{d}} \]
              5. Applied rewrites67.8%

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

              if 7.8000000000000004e-53 < c < 1.3e164

              1. Initial program 72.8%

                \[\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. lower-/.f64N/A

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

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

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

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

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

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

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

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

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

                \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.8 \cdot 10^{+57}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 7.8 \cdot 10^{-53}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 1.3 \cdot 10^{+164}:\\ \;\;\;\;a \cdot \frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
              9. Add Preprocessing

              Alternative 9: 63.8% accurate, 1.1× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -3.8 \cdot 10^{+57}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{-25}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{c}{a}}\\ \end{array} \end{array} \]
              (FPCore (a b c d)
               :precision binary64
               (if (<= c -3.8e+57) (/ a c) (if (<= c 3.1e-25) (/ b d) (/ 1.0 (/ c a)))))
              double code(double a, double b, double c, double d) {
              	double tmp;
              	if (c <= -3.8e+57) {
              		tmp = a / c;
              	} else if (c <= 3.1e-25) {
              		tmp = b / d;
              	} else {
              		tmp = 1.0 / (c / a);
              	}
              	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 (c <= (-3.8d+57)) then
                      tmp = a / c
                  else if (c <= 3.1d-25) then
                      tmp = b / d
                  else
                      tmp = 1.0d0 / (c / a)
                  end if
                  code = tmp
              end function
              
              public static double code(double a, double b, double c, double d) {
              	double tmp;
              	if (c <= -3.8e+57) {
              		tmp = a / c;
              	} else if (c <= 3.1e-25) {
              		tmp = b / d;
              	} else {
              		tmp = 1.0 / (c / a);
              	}
              	return tmp;
              }
              
              def code(a, b, c, d):
              	tmp = 0
              	if c <= -3.8e+57:
              		tmp = a / c
              	elif c <= 3.1e-25:
              		tmp = b / d
              	else:
              		tmp = 1.0 / (c / a)
              	return tmp
              
              function code(a, b, c, d)
              	tmp = 0.0
              	if (c <= -3.8e+57)
              		tmp = Float64(a / c);
              	elseif (c <= 3.1e-25)
              		tmp = Float64(b / d);
              	else
              		tmp = Float64(1.0 / Float64(c / a));
              	end
              	return tmp
              end
              
              function tmp_2 = code(a, b, c, d)
              	tmp = 0.0;
              	if (c <= -3.8e+57)
              		tmp = a / c;
              	elseif (c <= 3.1e-25)
              		tmp = b / d;
              	else
              		tmp = 1.0 / (c / a);
              	end
              	tmp_2 = tmp;
              end
              
              code[a_, b_, c_, d_] := If[LessEqual[c, -3.8e+57], N[(a / c), $MachinePrecision], If[LessEqual[c, 3.1e-25], N[(b / d), $MachinePrecision], N[(1.0 / N[(c / a), $MachinePrecision]), $MachinePrecision]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;c \leq -3.8 \cdot 10^{+57}:\\
              \;\;\;\;\frac{a}{c}\\
              
              \mathbf{elif}\;c \leq 3.1 \cdot 10^{-25}:\\
              \;\;\;\;\frac{b}{d}\\
              
              \mathbf{else}:\\
              \;\;\;\;\frac{1}{\frac{c}{a}}\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 3 regimes
              2. if c < -3.7999999999999999e57

                1. Initial program 45.3%

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

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

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

                if -3.7999999999999999e57 < c < 3.09999999999999995e-25

                1. Initial program 66.0%

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

                    \[\leadsto \color{blue}{\frac{b}{d}} \]
                5. Applied rewrites66.1%

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

                if 3.09999999999999995e-25 < c

                1. Initial program 56.1%

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

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

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

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

                Alternative 10: 64.0% accurate, 1.6× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -3.8 \cdot 10^{+57}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{-25}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \end{array} \]
                (FPCore (a b c d)
                 :precision binary64
                 (if (<= c -3.8e+57) (/ a c) (if (<= c 3.1e-25) (/ b d) (/ a c))))
                double code(double a, double b, double c, double d) {
                	double tmp;
                	if (c <= -3.8e+57) {
                		tmp = a / c;
                	} else if (c <= 3.1e-25) {
                		tmp = b / d;
                	} else {
                		tmp = a / c;
                	}
                	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 (c <= (-3.8d+57)) then
                        tmp = a / c
                    else if (c <= 3.1d-25) then
                        tmp = b / d
                    else
                        tmp = a / c
                    end if
                    code = tmp
                end function
                
                public static double code(double a, double b, double c, double d) {
                	double tmp;
                	if (c <= -3.8e+57) {
                		tmp = a / c;
                	} else if (c <= 3.1e-25) {
                		tmp = b / d;
                	} else {
                		tmp = a / c;
                	}
                	return tmp;
                }
                
                def code(a, b, c, d):
                	tmp = 0
                	if c <= -3.8e+57:
                		tmp = a / c
                	elif c <= 3.1e-25:
                		tmp = b / d
                	else:
                		tmp = a / c
                	return tmp
                
                function code(a, b, c, d)
                	tmp = 0.0
                	if (c <= -3.8e+57)
                		tmp = Float64(a / c);
                	elseif (c <= 3.1e-25)
                		tmp = Float64(b / d);
                	else
                		tmp = Float64(a / c);
                	end
                	return tmp
                end
                
                function tmp_2 = code(a, b, c, d)
                	tmp = 0.0;
                	if (c <= -3.8e+57)
                		tmp = a / c;
                	elseif (c <= 3.1e-25)
                		tmp = b / d;
                	else
                		tmp = a / c;
                	end
                	tmp_2 = tmp;
                end
                
                code[a_, b_, c_, d_] := If[LessEqual[c, -3.8e+57], N[(a / c), $MachinePrecision], If[LessEqual[c, 3.1e-25], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;c \leq -3.8 \cdot 10^{+57}:\\
                \;\;\;\;\frac{a}{c}\\
                
                \mathbf{elif}\;c \leq 3.1 \cdot 10^{-25}:\\
                \;\;\;\;\frac{b}{d}\\
                
                \mathbf{else}:\\
                \;\;\;\;\frac{a}{c}\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if c < -3.7999999999999999e57 or 3.09999999999999995e-25 < c

                  1. Initial program 51.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-/.f6471.9

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

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

                  if -3.7999999999999999e57 < c < 3.09999999999999995e-25

                  1. Initial program 66.0%

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

                      \[\leadsto \color{blue}{\frac{b}{d}} \]
                  5. Applied rewrites66.1%

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

                Alternative 11: 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 58.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-/.f6445.9

                    \[\leadsto \color{blue}{\frac{a}{c}} \]
                5. Applied rewrites45.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;
                }
                
                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 2024226 
                (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))))