Complex division, real part

Percentage Accurate: 62.0% → 82.6%
Time: 7.4s
Alternatives: 12
Speedup: 0.9×

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

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

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

\mathbf{elif}\;c \leq -6 \cdot 10^{-146}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 1.2 \cdot 10^{+114}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -2.39999999999999981e28 or 1.2e114 < c

    1. Initial program 37.4%

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

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

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

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

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

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

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

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

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

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

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

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

      if -2.39999999999999981e28 < c < -6.00000000000000038e-146 or 1.35000000000000005e-103 < c < 1.2e114

      1. Initial program 86.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -6.00000000000000038e-146 < c < 1.35000000000000005e-103

      1. Initial program 65.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
      6. 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. *-commutativeN/A

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

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

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

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

          \[\leadsto \frac{\mathsf{fma}\left(\frac{-1}{d} \cdot \left(-c\right), a, b\right)}{d} \]
      9. Recombined 3 regimes into one program.
      10. Final simplification87.4%

        \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.4 \cdot 10^{+28}:\\ \;\;\;\;\mathsf{fma}\left(\frac{d}{c}, \frac{b}{c}, \frac{a}{c}\right)\\ \mathbf{elif}\;c \leq -6 \cdot 10^{-146}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;c \leq 1.35 \cdot 10^{-103}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{-1}{d} \cdot \left(-c\right), a, b\right)}{d}\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{+114}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{d}{c}, \frac{b}{c}, \frac{a}{c}\right)\\ \end{array} \]
      11. Add Preprocessing

      Alternative 2: 82.6% accurate, 0.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{if}\;c \leq -2.4 \cdot 10^{+28}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\ \mathbf{elif}\;c \leq -6 \cdot 10^{-146}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 1.35 \cdot 10^{-103}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{-1}{d} \cdot \left(-c\right), a, b\right)}{d}\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{+114}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\ \end{array} \end{array} \]
      (FPCore (a b c d)
       :precision binary64
       (let* ((t_0 (/ (fma d b (* c a)) (fma d d (* c c)))))
         (if (<= c -2.4e+28)
           (/ (fma (/ d c) b a) c)
           (if (<= c -6e-146)
             t_0
             (if (<= c 1.35e-103)
               (/ (fma (* (/ -1.0 d) (- c)) a b) d)
               (if (<= c 1.2e+114) t_0 (/ (fma (/ b c) d a) c)))))))
      double code(double a, double b, double c, double d) {
      	double t_0 = fma(d, b, (c * a)) / fma(d, d, (c * c));
      	double tmp;
      	if (c <= -2.4e+28) {
      		tmp = fma((d / c), b, a) / c;
      	} else if (c <= -6e-146) {
      		tmp = t_0;
      	} else if (c <= 1.35e-103) {
      		tmp = fma(((-1.0 / d) * -c), a, b) / d;
      	} else if (c <= 1.2e+114) {
      		tmp = t_0;
      	} else {
      		tmp = fma((b / c), d, a) / c;
      	}
      	return tmp;
      }
      
      function code(a, b, c, d)
      	t_0 = Float64(fma(d, b, Float64(c * a)) / fma(d, d, Float64(c * c)))
      	tmp = 0.0
      	if (c <= -2.4e+28)
      		tmp = Float64(fma(Float64(d / c), b, a) / c);
      	elseif (c <= -6e-146)
      		tmp = t_0;
      	elseif (c <= 1.35e-103)
      		tmp = Float64(fma(Float64(Float64(-1.0 / d) * Float64(-c)), a, b) / d);
      	elseif (c <= 1.2e+114)
      		tmp = t_0;
      	else
      		tmp = Float64(fma(Float64(b / c), d, a) / c);
      	end
      	return tmp
      end
      
      code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(d * b + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.4e+28], N[(N[(N[(d / c), $MachinePrecision] * b + a), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -6e-146], t$95$0, If[LessEqual[c, 1.35e-103], N[(N[(N[(N[(-1.0 / d), $MachinePrecision] * (-c)), $MachinePrecision] * a + b), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1.2e+114], t$95$0, N[(N[(N[(b / c), $MachinePrecision] * d + a), $MachinePrecision] / c), $MachinePrecision]]]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
      \mathbf{if}\;c \leq -2.4 \cdot 10^{+28}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\
      
      \mathbf{elif}\;c \leq -6 \cdot 10^{-146}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;c \leq 1.35 \cdot 10^{-103}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(\frac{-1}{d} \cdot \left(-c\right), a, b\right)}{d}\\
      
      \mathbf{elif}\;c \leq 1.2 \cdot 10^{+114}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 4 regimes
      2. if c < -2.39999999999999981e28

        1. Initial program 40.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if -2.39999999999999981e28 < c < -6.00000000000000038e-146 or 1.35000000000000005e-103 < c < 1.2e114

        1. Initial program 86.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if -6.00000000000000038e-146 < c < 1.35000000000000005e-103

        1. Initial program 65.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
        6. 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. *-commutativeN/A

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

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

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

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

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

          if 1.2e114 < c

          1. Initial program 34.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-/.f6483.0

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

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.4 \cdot 10^{+28}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\ \mathbf{elif}\;c \leq -6 \cdot 10^{-146}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;c \leq 1.35 \cdot 10^{-103}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{-1}{d} \cdot \left(-c\right), a, b\right)}{d}\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{+114}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\ \end{array} \]
        11. Add Preprocessing

        Alternative 3: 82.6% accurate, 0.7× speedup?

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

          1. Initial program 40.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if -2.39999999999999981e28 < c < -6.00000000000000038e-146 or 1.35000000000000005e-103 < c < 1.2e114

          1. Initial program 86.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if -6.00000000000000038e-146 < c < 1.35000000000000005e-103

          1. Initial program 65.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
          6. 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. *-commutativeN/A

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

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

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

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

          if 1.2e114 < c

          1. Initial program 34.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-/.f6483.0

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

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.4 \cdot 10^{+28}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\ \mathbf{elif}\;c \leq -6 \cdot 10^{-146}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;c \leq 1.35 \cdot 10^{-103}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{d}\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{+114}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\ \end{array} \]
        5. Add Preprocessing

        Alternative 4: 64.2% accurate, 0.7× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -1.45 \cdot 10^{+37}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq -1.4 \cdot 10^{-165}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot a\\ \mathbf{elif}\;c \leq 3.6 \cdot 10^{-99}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 3.9 \cdot 10^{+108}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \end{array} \]
        (FPCore (a b c d)
         :precision binary64
         (if (<= c -1.45e+37)
           (/ a c)
           (if (<= c -1.4e-165)
             (* (/ c (fma c c (* d d))) a)
             (if (<= c 3.6e-99)
               (/ b d)
               (if (<= c 3.9e+108) (/ (fma a c (* b d)) (* c c)) (/ a c))))))
        double code(double a, double b, double c, double d) {
        	double tmp;
        	if (c <= -1.45e+37) {
        		tmp = a / c;
        	} else if (c <= -1.4e-165) {
        		tmp = (c / fma(c, c, (d * d))) * a;
        	} else if (c <= 3.6e-99) {
        		tmp = b / d;
        	} else if (c <= 3.9e+108) {
        		tmp = fma(a, c, (b * d)) / (c * c);
        	} else {
        		tmp = a / c;
        	}
        	return tmp;
        }
        
        function code(a, b, c, d)
        	tmp = 0.0
        	if (c <= -1.45e+37)
        		tmp = Float64(a / c);
        	elseif (c <= -1.4e-165)
        		tmp = Float64(Float64(c / fma(c, c, Float64(d * d))) * a);
        	elseif (c <= 3.6e-99)
        		tmp = Float64(b / d);
        	elseif (c <= 3.9e+108)
        		tmp = Float64(fma(a, c, Float64(b * d)) / Float64(c * c));
        	else
        		tmp = Float64(a / c);
        	end
        	return tmp
        end
        
        code[a_, b_, c_, d_] := If[LessEqual[c, -1.45e+37], N[(a / c), $MachinePrecision], If[LessEqual[c, -1.4e-165], N[(N[(c / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[c, 3.6e-99], N[(b / d), $MachinePrecision], If[LessEqual[c, 3.9e+108], N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], N[(a / c), $MachinePrecision]]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;c \leq -1.45 \cdot 10^{+37}:\\
        \;\;\;\;\frac{a}{c}\\
        
        \mathbf{elif}\;c \leq -1.4 \cdot 10^{-165}:\\
        \;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot a\\
        
        \mathbf{elif}\;c \leq 3.6 \cdot 10^{-99}:\\
        \;\;\;\;\frac{b}{d}\\
        
        \mathbf{elif}\;c \leq 3.9 \cdot 10^{+108}:\\
        \;\;\;\;\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{c \cdot c}\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{a}{c}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 4 regimes
        2. if c < -1.44999999999999989e37 or 3.89999999999999985e108 < c

          1. Initial program 38.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.9

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

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

          if -1.44999999999999989e37 < c < -1.4e-165

          1. Initial program 76.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if -1.4e-165 < c < 3.6000000000000001e-99

          1. Initial program 66.5%

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

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

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

          if 3.6000000000000001e-99 < c < 3.89999999999999985e108

          1. Initial program 83.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 \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-*.f6467.7

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

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

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

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

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.45 \cdot 10^{+37}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq -1.4 \cdot 10^{-165}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot a\\ \mathbf{elif}\;c \leq 3.6 \cdot 10^{-99}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 3.9 \cdot 10^{+108}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
        5. Add Preprocessing

        Alternative 5: 63.5% accurate, 0.7× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot a\\ \mathbf{if}\;c \leq -1.45 \cdot 10^{+37}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq -1.4 \cdot 10^{-165}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 1.05 \cdot 10^{-174}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 5.3 \cdot 10^{+126}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \end{array} \]
        (FPCore (a b c d)
         :precision binary64
         (let* ((t_0 (* (/ c (fma c c (* d d))) a)))
           (if (<= c -1.45e+37)
             (/ a c)
             (if (<= c -1.4e-165)
               t_0
               (if (<= c 1.05e-174) (/ b d) (if (<= c 5.3e+126) t_0 (/ a c)))))))
        double code(double a, double b, double c, double d) {
        	double t_0 = (c / fma(c, c, (d * d))) * a;
        	double tmp;
        	if (c <= -1.45e+37) {
        		tmp = a / c;
        	} else if (c <= -1.4e-165) {
        		tmp = t_0;
        	} else if (c <= 1.05e-174) {
        		tmp = b / d;
        	} else if (c <= 5.3e+126) {
        		tmp = t_0;
        	} else {
        		tmp = a / c;
        	}
        	return tmp;
        }
        
        function code(a, b, c, d)
        	t_0 = Float64(Float64(c / fma(c, c, Float64(d * d))) * a)
        	tmp = 0.0
        	if (c <= -1.45e+37)
        		tmp = Float64(a / c);
        	elseif (c <= -1.4e-165)
        		tmp = t_0;
        	elseif (c <= 1.05e-174)
        		tmp = Float64(b / d);
        	elseif (c <= 5.3e+126)
        		tmp = t_0;
        	else
        		tmp = Float64(a / c);
        	end
        	return tmp
        end
        
        code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[c, -1.45e+37], N[(a / c), $MachinePrecision], If[LessEqual[c, -1.4e-165], t$95$0, If[LessEqual[c, 1.05e-174], N[(b / d), $MachinePrecision], If[LessEqual[c, 5.3e+126], t$95$0, N[(a / c), $MachinePrecision]]]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot a\\
        \mathbf{if}\;c \leq -1.45 \cdot 10^{+37}:\\
        \;\;\;\;\frac{a}{c}\\
        
        \mathbf{elif}\;c \leq -1.4 \cdot 10^{-165}:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;c \leq 1.05 \cdot 10^{-174}:\\
        \;\;\;\;\frac{b}{d}\\
        
        \mathbf{elif}\;c \leq 5.3 \cdot 10^{+126}:\\
        \;\;\;\;t\_0\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{a}{c}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if c < -1.44999999999999989e37 or 5.30000000000000028e126 < c

          1. Initial program 37.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 -1.44999999999999989e37 < c < -1.4e-165 or 1.05000000000000005e-174 < c < 5.30000000000000028e126

          1. Initial program 80.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 \frac{\color{blue}{a \cdot c + b \cdot d}}{c \cdot c + d \cdot d} \]
            2. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if -1.4e-165 < c < 1.05000000000000005e-174

          1. Initial program 62.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-/.f6478.2

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

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.45 \cdot 10^{+37}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq -1.4 \cdot 10^{-165}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot a\\ \mathbf{elif}\;c \leq 1.05 \cdot 10^{-174}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 5.3 \cdot 10^{+126}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot a\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
        5. Add Preprocessing

        Alternative 6: 71.7% accurate, 0.8× speedup?

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

          1. Initial program 38.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-/.f6481.3

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

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

          if -8.50000000000000007e80 < c < 2.8000000000000001e-76

          1. Initial program 67.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.4

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

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

          if 2.8000000000000001e-76 < c < 3.89999999999999985e108

          1. Initial program 85.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 \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-*.f6468.6

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

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

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

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

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -8.5 \cdot 10^{+80}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 2.8 \cdot 10^{-76}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}{d}\\ \mathbf{elif}\;c \leq 3.9 \cdot 10^{+108}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
        5. Add Preprocessing

        Alternative 7: 74.2% accurate, 0.9× speedup?

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

          1. Initial program 55.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if -6.00000000000000038e-146 < c < 2.8000000000000001e-76

          1. Initial program 66.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
          6. 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. *-commutativeN/A

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

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

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

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

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

        Alternative 8: 77.9% accurate, 0.9× speedup?

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

          1. Initial program 49.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 + \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-/.f6480.7

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

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

          if -2.3e30 < c < 3.5000000000000001e-62

          1. Initial program 70.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 \frac{\color{blue}{a \cdot c + b \cdot d}}{c \cdot c + d \cdot d} \]
            2. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\frac{b + \frac{a \cdot c}{d}}{d}} \]
          6. 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. *-commutativeN/A

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

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

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

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

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

        Alternative 9: 77.2% accurate, 0.9× speedup?

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

          1. Initial program 49.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 + \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-/.f6480.7

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

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

          if -2.3e30 < c < 3.5000000000000001e-62

          1. Initial program 70.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-/.f6481.7

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

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

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

        Alternative 10: 62.5% accurate, 0.9× speedup?

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

          1. Initial program 49.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-/.f6470.9

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

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

          if -3.70000000000000016e30 < c < -1.4e-165

          1. Initial program 78.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-*.f6460.8

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

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

          if -1.4e-165 < c < 3.5000000000000001e-62

          1. Initial program 67.5%

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

              \[\leadsto \color{blue}{\frac{b}{d}} \]
          5. Applied rewrites72.3%

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.7 \cdot 10^{+30}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq -1.4 \cdot 10^{-165}:\\ \;\;\;\;\frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot c\\ \mathbf{elif}\;c \leq 3.5 \cdot 10^{-62}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
        5. Add Preprocessing

        Alternative 11: 60.7% accurate, 1.6× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -5.2 \cdot 10^{-146} \lor \neg \left(c \leq 3.5 \cdot 10^{-62}\right):\\ \;\;\;\;\frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \end{array} \]
        (FPCore (a b c d)
         :precision binary64
         (if (or (<= c -5.2e-146) (not (<= c 3.5e-62))) (/ a c) (/ b d)))
        double code(double a, double b, double c, double d) {
        	double tmp;
        	if ((c <= -5.2e-146) || !(c <= 3.5e-62)) {
        		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 ((c <= (-5.2d-146)) .or. (.not. (c <= 3.5d-62))) then
                tmp = a / c
            else
                tmp = b / d
            end if
            code = tmp
        end function
        
        public static double code(double a, double b, double c, double d) {
        	double tmp;
        	if ((c <= -5.2e-146) || !(c <= 3.5e-62)) {
        		tmp = a / c;
        	} else {
        		tmp = b / d;
        	}
        	return tmp;
        }
        
        def code(a, b, c, d):
        	tmp = 0
        	if (c <= -5.2e-146) or not (c <= 3.5e-62):
        		tmp = a / c
        	else:
        		tmp = b / d
        	return tmp
        
        function code(a, b, c, d)
        	tmp = 0.0
        	if ((c <= -5.2e-146) || !(c <= 3.5e-62))
        		tmp = Float64(a / c);
        	else
        		tmp = Float64(b / d);
        	end
        	return tmp
        end
        
        function tmp_2 = code(a, b, c, d)
        	tmp = 0.0;
        	if ((c <= -5.2e-146) || ~((c <= 3.5e-62)))
        		tmp = a / c;
        	else
        		tmp = b / d;
        	end
        	tmp_2 = tmp;
        end
        
        code[a_, b_, c_, d_] := If[Or[LessEqual[c, -5.2e-146], N[Not[LessEqual[c, 3.5e-62]], $MachinePrecision]], N[(a / c), $MachinePrecision], N[(b / d), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;c \leq -5.2 \cdot 10^{-146} \lor \neg \left(c \leq 3.5 \cdot 10^{-62}\right):\\
        \;\;\;\;\frac{a}{c}\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{b}{d}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if c < -5.19999999999999974e-146 or 3.5000000000000001e-62 < c

          1. Initial program 55.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-/.f6465.3

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

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

          if -5.19999999999999974e-146 < c < 3.5000000000000001e-62

          1. Initial program 67.5%

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

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

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

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

        Alternative 12: 43.8% 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 59.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}{c}} \]
        4. Step-by-step derivation
          1. lower-/.f6447.7

            \[\leadsto \color{blue}{\frac{a}{c}} \]
        5. Applied rewrites47.7%

          \[\leadsto \color{blue}{\frac{a}{c}} \]
        6. Final simplification47.7%

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