Complex division, real part

Percentage Accurate: 61.8% → 83.4%
Time: 7.2s
Alternatives: 11
Speedup: 1.6×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 61.8% accurate, 1.0× speedup?

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

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

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

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

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

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

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


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

    1. Initial program 32.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.9000000000000002e112 < d < -6.1999999999999996e-156

    1. Initial program 81.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.1999999999999996e-156 < d < 6.19999999999999963e-154

    1. Initial program 72.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{d \cdot b}}{c} + a}{c} \]
      4. associate-*l/N/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-/.f6492.9

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

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

    if 6.19999999999999963e-154 < d < 4.10000000000000031e94

    1. Initial program 80.9%

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

        \[\leadsto \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.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-*.f6480.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.f6480.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 rewrites80.9%

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

    if 4.10000000000000031e94 < d

    1. Initial program 31.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.9 \cdot 10^{+112}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}{d}\\ \mathbf{elif}\;d \leq -6.2 \cdot 10^{-156}:\\ \;\;\;\;\mathsf{fma}\left(a, \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}, d \cdot \frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right)\\ \mathbf{elif}\;d \leq 6.2 \cdot 10^{-154}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\ \mathbf{elif}\;d \leq 4.1 \cdot 10^{+94}:\\ \;\;\;\;\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(a, \frac{c}{d}, b\right)}{d}\\ \end{array} \]
    9. Add Preprocessing

    Alternative 2: 62.3% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{d \cdot d}\\ \mathbf{if}\;d \leq -1.9 \cdot 10^{+152}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq -2.65 \cdot 10^{-87}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq -2.2 \cdot 10^{-156}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot a\\ \mathbf{elif}\;d \leq 4.8 \cdot 10^{-115}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, a, d \cdot b\right)}{c \cdot c}\\ \mathbf{elif}\;d \leq 1.06 \cdot 10^{+97}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \end{array} \]
    (FPCore (a b c d)
     :precision binary64
     (let* ((t_0 (/ (fma d b (* c a)) (* d d))))
       (if (<= d -1.9e+152)
         (/ b d)
         (if (<= d -2.65e-87)
           t_0
           (if (<= d -2.2e-156)
             (* (/ c (fma d d (* c c))) a)
             (if (<= d 4.8e-115)
               (/ (fma c a (* d b)) (* c c))
               (if (<= d 1.06e+97) t_0 (/ b d))))))))
    double code(double a, double b, double c, double d) {
    	double t_0 = fma(d, b, (c * a)) / (d * d);
    	double tmp;
    	if (d <= -1.9e+152) {
    		tmp = b / d;
    	} else if (d <= -2.65e-87) {
    		tmp = t_0;
    	} else if (d <= -2.2e-156) {
    		tmp = (c / fma(d, d, (c * c))) * a;
    	} else if (d <= 4.8e-115) {
    		tmp = fma(c, a, (d * b)) / (c * c);
    	} else if (d <= 1.06e+97) {
    		tmp = t_0;
    	} else {
    		tmp = b / d;
    	}
    	return tmp;
    }
    
    function code(a, b, c, d)
    	t_0 = Float64(fma(d, b, Float64(c * a)) / Float64(d * d))
    	tmp = 0.0
    	if (d <= -1.9e+152)
    		tmp = Float64(b / d);
    	elseif (d <= -2.65e-87)
    		tmp = t_0;
    	elseif (d <= -2.2e-156)
    		tmp = Float64(Float64(c / fma(d, d, Float64(c * c))) * a);
    	elseif (d <= 4.8e-115)
    		tmp = Float64(fma(c, a, Float64(d * b)) / Float64(c * c));
    	elseif (d <= 1.06e+97)
    		tmp = t_0;
    	else
    		tmp = Float64(b / d);
    	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), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.9e+152], N[(b / d), $MachinePrecision], If[LessEqual[d, -2.65e-87], t$95$0, If[LessEqual[d, -2.2e-156], N[(N[(c / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[d, 4.8e-115], N[(N[(c * a + N[(d * b), $MachinePrecision]), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.06e+97], t$95$0, N[(b / d), $MachinePrecision]]]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{d \cdot d}\\
    \mathbf{if}\;d \leq -1.9 \cdot 10^{+152}:\\
    \;\;\;\;\frac{b}{d}\\
    
    \mathbf{elif}\;d \leq -2.65 \cdot 10^{-87}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;d \leq -2.2 \cdot 10^{-156}:\\
    \;\;\;\;\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot a\\
    
    \mathbf{elif}\;d \leq 4.8 \cdot 10^{-115}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(c, a, d \cdot b\right)}{c \cdot c}\\
    
    \mathbf{elif}\;d \leq 1.06 \cdot 10^{+97}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{b}{d}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 4 regimes
    2. if d < -1.9e152 or 1.05999999999999994e97 < d

      1. Initial program 27.0%

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

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

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

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

      if -1.9e152 < d < -2.64999999999999993e-87 or 4.80000000000000042e-115 < d < 1.05999999999999994e97

      1. Initial program 80.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.f6480.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-*.f6480.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.f6480.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 rewrites80.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 c around 0

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

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

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

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

      if -2.64999999999999993e-87 < d < -2.1999999999999999e-156

      1. Initial program 72.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -2.1999999999999999e-156 < d < 4.80000000000000042e-115

      1. Initial program 74.7%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.9 \cdot 10^{+152}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq -2.65 \cdot 10^{-87}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{d \cdot d}\\ \mathbf{elif}\;d \leq -2.2 \cdot 10^{-156}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot a\\ \mathbf{elif}\;d \leq 4.8 \cdot 10^{-115}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, a, d \cdot b\right)}{c \cdot c}\\ \mathbf{elif}\;d \leq 1.06 \cdot 10^{+97}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 3: 82.1% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\ \mathbf{if}\;d \leq -3.6 \cdot 10^{+68}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}{d}\\ \mathbf{elif}\;d \leq -6.2 \cdot 10^{-156}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, \frac{d}{a}, c\right)}{t\_0} \cdot a\\ \mathbf{elif}\;d \leq 6.2 \cdot 10^{-154}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\ \mathbf{elif}\;d \leq 4.1 \cdot 10^{+94}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\ \end{array} \end{array} \]
    (FPCore (a b c d)
     :precision binary64
     (let* ((t_0 (fma d d (* c c))))
       (if (<= d -3.6e+68)
         (/ (fma (/ a d) c b) d)
         (if (<= d -6.2e-156)
           (* (/ (fma b (/ d a) c) t_0) a)
           (if (<= d 6.2e-154)
             (/ (fma (/ d c) b a) c)
             (if (<= d 4.1e+94)
               (/ (fma d b (* c a)) t_0)
               (/ (fma a (/ c d) b) d)))))))
    double code(double a, double b, double c, double d) {
    	double t_0 = fma(d, d, (c * c));
    	double tmp;
    	if (d <= -3.6e+68) {
    		tmp = fma((a / d), c, b) / d;
    	} else if (d <= -6.2e-156) {
    		tmp = (fma(b, (d / a), c) / t_0) * a;
    	} else if (d <= 6.2e-154) {
    		tmp = fma((d / c), b, a) / c;
    	} else if (d <= 4.1e+94) {
    		tmp = fma(d, b, (c * a)) / t_0;
    	} else {
    		tmp = fma(a, (c / d), b) / d;
    	}
    	return tmp;
    }
    
    function code(a, b, c, d)
    	t_0 = fma(d, d, Float64(c * c))
    	tmp = 0.0
    	if (d <= -3.6e+68)
    		tmp = Float64(fma(Float64(a / d), c, b) / d);
    	elseif (d <= -6.2e-156)
    		tmp = Float64(Float64(fma(b, Float64(d / a), c) / t_0) * a);
    	elseif (d <= 6.2e-154)
    		tmp = Float64(fma(Float64(d / c), b, a) / c);
    	elseif (d <= 4.1e+94)
    		tmp = Float64(fma(d, b, Float64(c * a)) / t_0);
    	else
    		tmp = Float64(fma(a, Float64(c / d), b) / d);
    	end
    	return tmp
    end
    
    code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.6e+68], N[(N[(N[(a / d), $MachinePrecision] * c + b), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -6.2e-156], N[(N[(N[(b * N[(d / a), $MachinePrecision] + c), $MachinePrecision] / t$95$0), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[d, 6.2e-154], N[(N[(N[(d / c), $MachinePrecision] * b + a), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 4.1e+94], N[(N[(d * b + N[(c * a), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(a * N[(c / d), $MachinePrecision] + b), $MachinePrecision] / d), $MachinePrecision]]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
    \mathbf{if}\;d \leq -3.6 \cdot 10^{+68}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}{d}\\
    
    \mathbf{elif}\;d \leq -6.2 \cdot 10^{-156}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(b, \frac{d}{a}, c\right)}{t\_0} \cdot a\\
    
    \mathbf{elif}\;d \leq 6.2 \cdot 10^{-154}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\
    
    \mathbf{elif}\;d \leq 4.1 \cdot 10^{+94}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{t\_0}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 5 regimes
    2. if d < -3.5999999999999999e68

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

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

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

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

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

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

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

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

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

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

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

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

      if -3.5999999999999999e68 < d < -6.1999999999999996e-156

      1. Initial program 83.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -6.1999999999999996e-156 < d < 6.19999999999999963e-154

      1. Initial program 72.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\frac{\color{blue}{d \cdot b}}{c} + a}{c} \]
        4. associate-*l/N/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-/.f6492.9

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

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

      if 6.19999999999999963e-154 < d < 4.10000000000000031e94

      1. Initial program 80.9%

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

          \[\leadsto \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.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-*.f6480.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.f6480.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 rewrites80.9%

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

      if 4.10000000000000031e94 < d

      1. Initial program 31.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.6 \cdot 10^{+68}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}{d}\\ \mathbf{elif}\;d \leq -6.2 \cdot 10^{-156}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, \frac{d}{a}, c\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot a\\ \mathbf{elif}\;d \leq 6.2 \cdot 10^{-154}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\ \mathbf{elif}\;d \leq 4.1 \cdot 10^{+94}:\\ \;\;\;\;\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(a, \frac{c}{d}, b\right)}{d}\\ \end{array} \]
      9. Add Preprocessing

      Alternative 4: 83.1% 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}\;d \leq -9.5 \cdot 10^{+75}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}{d}\\ \mathbf{elif}\;d \leq -1.9 \cdot 10^{-132}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 6.2 \cdot 10^{-154}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\ \mathbf{elif}\;d \leq 4.1 \cdot 10^{+94}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\ \end{array} \end{array} \]
      (FPCore (a b c d)
       :precision binary64
       (let* ((t_0 (/ (fma d b (* c a)) (fma d d (* c c)))))
         (if (<= d -9.5e+75)
           (/ (fma (/ a d) c b) d)
           (if (<= d -1.9e-132)
             t_0
             (if (<= d 6.2e-154)
               (/ (fma (/ d c) b a) c)
               (if (<= d 4.1e+94) t_0 (/ (fma a (/ c d) b) d)))))))
      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 (d <= -9.5e+75) {
      		tmp = fma((a / d), c, b) / d;
      	} else if (d <= -1.9e-132) {
      		tmp = t_0;
      	} else if (d <= 6.2e-154) {
      		tmp = fma((d / c), b, a) / c;
      	} else if (d <= 4.1e+94) {
      		tmp = t_0;
      	} else {
      		tmp = fma(a, (c / d), b) / d;
      	}
      	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 (d <= -9.5e+75)
      		tmp = Float64(fma(Float64(a / d), c, b) / d);
      	elseif (d <= -1.9e-132)
      		tmp = t_0;
      	elseif (d <= 6.2e-154)
      		tmp = Float64(fma(Float64(d / c), b, a) / c);
      	elseif (d <= 4.1e+94)
      		tmp = t_0;
      	else
      		tmp = Float64(fma(a, Float64(c / d), b) / d);
      	end
      	return tmp
      end
      
      code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(d * b + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -9.5e+75], N[(N[(N[(a / d), $MachinePrecision] * c + b), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -1.9e-132], t$95$0, If[LessEqual[d, 6.2e-154], N[(N[(N[(d / c), $MachinePrecision] * b + a), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 4.1e+94], t$95$0, N[(N[(a * N[(c / d), $MachinePrecision] + b), $MachinePrecision] / d), $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}\;d \leq -9.5 \cdot 10^{+75}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}{d}\\
      
      \mathbf{elif}\;d \leq -1.9 \cdot 10^{-132}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;d \leq 6.2 \cdot 10^{-154}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\
      
      \mathbf{elif}\;d \leq 4.1 \cdot 10^{+94}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 4 regimes
      2. if d < -9.50000000000000061e75

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

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

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

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

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

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

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

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

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

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

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

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

        if -9.50000000000000061e75 < d < -1.8999999999999998e-132 or 6.19999999999999963e-154 < d < 4.10000000000000031e94

        1. Initial program 83.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.f6483.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-*.f6483.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.f6483.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 rewrites83.7%

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

        if -1.8999999999999998e-132 < d < 6.19999999999999963e-154

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{\frac{\color{blue}{d \cdot b}}{c} + a}{c} \]
          4. associate-*l/N/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-/.f6490.6

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

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

        if 4.10000000000000031e94 < d

        1. Initial program 31.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -9.5 \cdot 10^{+75}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{a}{d}, c, b\right)}{d}\\ \mathbf{elif}\;d \leq -1.9 \cdot 10^{-132}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;d \leq 6.2 \cdot 10^{-154}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\ \mathbf{elif}\;d \leq 4.1 \cdot 10^{+94}:\\ \;\;\;\;\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(a, \frac{c}{d}, b\right)}{d}\\ \end{array} \]
        9. Add Preprocessing

        Alternative 5: 63.1% accurate, 0.7× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\ \mathbf{if}\;d \leq -1.1 \cdot 10^{-25}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq -2.2 \cdot 10^{-156}:\\ \;\;\;\;\frac{c}{t\_0} \cdot a\\ \mathbf{elif}\;d \leq 1.16 \cdot 10^{-104}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, a, d \cdot b\right)}{c \cdot c}\\ \mathbf{elif}\;d \leq 6.9 \cdot 10^{+137}:\\ \;\;\;\;\frac{d}{t\_0} \cdot b\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \end{array} \]
        (FPCore (a b c d)
         :precision binary64
         (let* ((t_0 (fma d d (* c c))))
           (if (<= d -1.1e-25)
             (/ b d)
             (if (<= d -2.2e-156)
               (* (/ c t_0) a)
               (if (<= d 1.16e-104)
                 (/ (fma c a (* d b)) (* c c))
                 (if (<= d 6.9e+137) (* (/ d t_0) b) (/ b d)))))))
        double code(double a, double b, double c, double d) {
        	double t_0 = fma(d, d, (c * c));
        	double tmp;
        	if (d <= -1.1e-25) {
        		tmp = b / d;
        	} else if (d <= -2.2e-156) {
        		tmp = (c / t_0) * a;
        	} else if (d <= 1.16e-104) {
        		tmp = fma(c, a, (d * b)) / (c * c);
        	} else if (d <= 6.9e+137) {
        		tmp = (d / t_0) * b;
        	} else {
        		tmp = b / d;
        	}
        	return tmp;
        }
        
        function code(a, b, c, d)
        	t_0 = fma(d, d, Float64(c * c))
        	tmp = 0.0
        	if (d <= -1.1e-25)
        		tmp = Float64(b / d);
        	elseif (d <= -2.2e-156)
        		tmp = Float64(Float64(c / t_0) * a);
        	elseif (d <= 1.16e-104)
        		tmp = Float64(fma(c, a, Float64(d * b)) / Float64(c * c));
        	elseif (d <= 6.9e+137)
        		tmp = Float64(Float64(d / t_0) * b);
        	else
        		tmp = Float64(b / d);
        	end
        	return tmp
        end
        
        code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.1e-25], N[(b / d), $MachinePrecision], If[LessEqual[d, -2.2e-156], N[(N[(c / t$95$0), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[d, 1.16e-104], N[(N[(c * a + N[(d * b), $MachinePrecision]), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6.9e+137], N[(N[(d / t$95$0), $MachinePrecision] * b), $MachinePrecision], N[(b / d), $MachinePrecision]]]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
        \mathbf{if}\;d \leq -1.1 \cdot 10^{-25}:\\
        \;\;\;\;\frac{b}{d}\\
        
        \mathbf{elif}\;d \leq -2.2 \cdot 10^{-156}:\\
        \;\;\;\;\frac{c}{t\_0} \cdot a\\
        
        \mathbf{elif}\;d \leq 1.16 \cdot 10^{-104}:\\
        \;\;\;\;\frac{\mathsf{fma}\left(c, a, d \cdot b\right)}{c \cdot c}\\
        
        \mathbf{elif}\;d \leq 6.9 \cdot 10^{+137}:\\
        \;\;\;\;\frac{d}{t\_0} \cdot b\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{b}{d}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 4 regimes
        2. if d < -1.1000000000000001e-25 or 6.90000000000000039e137 < d

          1. Initial program 45.0%

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

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

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

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

          if -1.1000000000000001e-25 < d < -2.1999999999999999e-156

          1. Initial program 79.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if -2.1999999999999999e-156 < d < 1.16000000000000001e-104

          1. Initial program 75.3%

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

            \[\leadsto \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-*.f6470.5

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

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

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

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

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

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

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

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

          if 1.16000000000000001e-104 < d < 6.90000000000000039e137

          1. Initial program 71.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.1 \cdot 10^{-25}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq -2.2 \cdot 10^{-156}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot a\\ \mathbf{elif}\;d \leq 1.16 \cdot 10^{-104}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, a, d \cdot b\right)}{c \cdot c}\\ \mathbf{elif}\;d \leq 6.9 \cdot 10^{+137}:\\ \;\;\;\;\frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot b\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \]
        5. Add Preprocessing

        Alternative 6: 72.7% accurate, 0.8× speedup?

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

          1. Initial program 32.2%

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

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

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

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

          if -1.9e152 < d < -6.79999999999999992e-46

          1. Initial program 81.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.f6481.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-*.f6481.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.f6481.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 rewrites81.4%

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

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

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

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

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

          if -6.79999999999999992e-46 < d < 1.55e63

          1. Initial program 74.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{\frac{\color{blue}{d \cdot b}}{c} + a}{c} \]
            4. associate-*l/N/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-/.f6477.4

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

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.9 \cdot 10^{+152}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq -6.8 \cdot 10^{-46}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, b, c \cdot a\right)}{d \cdot d}\\ \mathbf{elif}\;d \leq 1.55 \cdot 10^{+63}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \]
        5. Add Preprocessing

        Alternative 7: 77.6% accurate, 0.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if -6.79999999999999992e-46 < d < 4.49999999999999999e62

            1. Initial program 74.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \frac{\frac{\color{blue}{d \cdot b}}{c} + a}{c} \]
              4. associate-*l/N/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-/.f6477.4

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

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

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

          Alternative 8: 78.0% accurate, 0.9× speedup?

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

            1. Initial program 51.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \frac{\frac{\color{blue}{d \cdot b}}{c} + a}{c} \]
              4. associate-*l/N/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-/.f6474.4

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

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

            if -1.65e-22 < c < 9500

            1. Initial program 73.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              if 9500 < c

              1. Initial program 47.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-/.f6472.6

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

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

              \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.65 \cdot 10^{-22}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, b, a\right)}{c}\\ \mathbf{elif}\;c \leq 9500:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{c}, d, a\right)}{c}\\ \end{array} \]
            9. Add Preprocessing

            Alternative 9: 62.9% accurate, 0.9× speedup?

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

              1. Initial program 49.1%

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

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

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

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

              if -1.1000000000000001e-25 < d < -1.60000000000000006e-155

              1. Initial program 79.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              if -1.60000000000000006e-155 < d < 1.32e19

              1. Initial program 75.7%

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

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

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

                \[\leadsto \color{blue}{\frac{a}{c}} \]
            3. Recombined 3 regimes into one program.
            4. Final simplification62.3%

              \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.1 \cdot 10^{-25}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq -1.6 \cdot 10^{-155}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot a\\ \mathbf{elif}\;d \leq 1.32 \cdot 10^{+19}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \]
            5. Add Preprocessing

            Alternative 10: 63.0% accurate, 1.6× speedup?

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

              1. Initial program 52.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-/.f6457.4

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

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

              if -2.00000000000000011e-32 < c < 3.10000000000000011e-40

              1. Initial program 72.8%

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

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

                  \[\leadsto \color{blue}{\frac{b}{d}} \]
              5. Applied rewrites61.7%

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

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

            Alternative 11: 43.0% accurate, 3.2× speedup?

            \[\begin{array}{l} \\ \frac{a}{c} \end{array} \]
            (FPCore (a b c d) :precision binary64 (/ a c))
            double code(double a, double b, double c, double d) {
            	return a / c;
            }
            
            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 62.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-/.f6438.4

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

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

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

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|d\right| < \left|c\right|:\\ \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\ \end{array} \end{array} \]
            (FPCore (a b c d)
             :precision binary64
             (if (< (fabs d) (fabs c))
               (/ (+ a (* b (/ d c))) (+ c (* d (/ d c))))
               (/ (+ b (* a (/ c d))) (+ d (* c (/ c d))))))
            double code(double a, double b, double c, double d) {
            	double tmp;
            	if (fabs(d) < fabs(c)) {
            		tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
            	} else {
            		tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
            	}
            	return tmp;
            }
            
            real(8) function code(a, b, c, d)
                real(8), intent (in) :: a
                real(8), intent (in) :: b
                real(8), intent (in) :: c
                real(8), intent (in) :: d
                real(8) :: tmp
                if (abs(d) < abs(c)) then
                    tmp = (a + (b * (d / c))) / (c + (d * (d / c)))
                else
                    tmp = (b + (a * (c / d))) / (d + (c * (c / d)))
                end if
                code = tmp
            end function
            
            public static double code(double a, double b, double c, double d) {
            	double tmp;
            	if (Math.abs(d) < Math.abs(c)) {
            		tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
            	} else {
            		tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
            	}
            	return tmp;
            }
            
            def code(a, b, c, d):
            	tmp = 0
            	if math.fabs(d) < math.fabs(c):
            		tmp = (a + (b * (d / c))) / (c + (d * (d / c)))
            	else:
            		tmp = (b + (a * (c / d))) / (d + (c * (c / d)))
            	return tmp
            
            function code(a, b, c, d)
            	tmp = 0.0
            	if (abs(d) < abs(c))
            		tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c))));
            	else
            		tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d))));
            	end
            	return tmp
            end
            
            function tmp_2 = code(a, b, c, d)
            	tmp = 0.0;
            	if (abs(d) < abs(c))
            		tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
            	else
            		tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
            	end
            	tmp_2 = tmp;
            end
            
            code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;\left|d\right| < \left|c\right|:\\
            \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
            
            
            \end{array}
            \end{array}
            

            Reproduce

            ?
            herbie shell --seed 2024332 
            (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))))