Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.3% → 87.6%
Time: 9.8s
Alternatives: 11
Speedup: 2.0×

Specification

?
\[\begin{array}{l} \\ w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
real(8) function code(w0, m, d, h, l, d_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_1
    code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
def code(w0, M, D, h, l, d):
	return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
function code(w0, M, D, h, l, d)
	return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)))))
end
function tmp = code(w0, M, D, h, l, d)
	tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l))));
end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\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: 81.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
real(8) function code(w0, m, d, h, l, d_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_1
    code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
def code(w0, M, D, h, l, d):
	return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
function code(w0, M, D, h, l, d)
	return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)))))
end
function tmp = code(w0, M, D, h, l, d)
	tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l))));
end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\end{array}

Alternative 1: 87.6% accurate, 2.0× speedup?

\[\begin{array}{l} \\ w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{-0.5 \cdot \left(D \cdot M\right)}{d} \cdot h}{\ell} \cdot \frac{0.5}{d}, D \cdot M, 1\right)} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (*
  w0
  (sqrt (fma (* (/ (* (/ (* -0.5 (* D M)) d) h) l) (/ 0.5 d)) (* D M) 1.0))))
double code(double w0, double M, double D, double h, double l, double d) {
	return w0 * sqrt(fma((((((-0.5 * (D * M)) / d) * h) / l) * (0.5 / d)), (D * M), 1.0));
}
function code(w0, M, D, h, l, d)
	return Float64(w0 * sqrt(fma(Float64(Float64(Float64(Float64(Float64(-0.5 * Float64(D * M)) / d) * h) / l) * Float64(0.5 / d)), Float64(D * M), 1.0)))
end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(N[(N[(N[(N[(N[(-0.5 * N[(D * M), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision] * N[(0.5 / d), $MachinePrecision]), $MachinePrecision] * N[(D * M), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{-0.5 \cdot \left(D \cdot M\right)}{d} \cdot h}{\ell} \cdot \frac{0.5}{d}, D \cdot M, 1\right)}
\end{array}
Derivation
  1. Initial program 78.7%

    \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto w0 \cdot \sqrt{\color{blue}{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    2. sub-negN/A

      \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
    3. +-commutativeN/A

      \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) + 1}} \]
    4. lift-*.f64N/A

      \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\right)\right) + 1} \]
    5. lift-/.f64N/A

      \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \color{blue}{\frac{h}{\ell}}\right)\right) + 1} \]
    6. associate-*r/N/A

      \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot h}{\ell}}\right)\right) + 1} \]
    7. distribute-neg-frac2N/A

      \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot h}{\mathsf{neg}\left(\ell\right)}} + 1} \]
    8. lift-pow.f64N/A

      \[\leadsto w0 \cdot \sqrt{\frac{\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}} \cdot h}{\mathsf{neg}\left(\ell\right)} + 1} \]
    9. unpow2N/A

      \[\leadsto w0 \cdot \sqrt{\frac{\color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)} \cdot h}{\mathsf{neg}\left(\ell\right)} + 1} \]
    10. associate-*l*N/A

      \[\leadsto w0 \cdot \sqrt{\frac{\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \left(\frac{M \cdot D}{2 \cdot d} \cdot h\right)}}{\mathsf{neg}\left(\ell\right)} + 1} \]
    11. associate-/l*N/A

      \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \frac{\frac{M \cdot D}{2 \cdot d} \cdot h}{\mathsf{neg}\left(\ell\right)}} + 1} \]
    12. lower-fma.f64N/A

      \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{M \cdot D}{2 \cdot d}, \frac{\frac{M \cdot D}{2 \cdot d} \cdot h}{\mathsf{neg}\left(\ell\right)}, 1\right)}} \]
  4. Applied rewrites84.7%

    \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(\frac{0.5}{d} \cdot M\right) \cdot D, \frac{\left(D \cdot 0.5\right) \cdot \left(\frac{M}{d} \cdot h\right)}{-\ell}, 1\right)}} \]
  5. Applied rewrites88.4%

    \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{\frac{-0.5 \cdot \left(D \cdot M\right)}{d} \cdot h}{\ell} \cdot \frac{0.5}{d}, D \cdot M, 1\right)}} \]
  6. Add Preprocessing

Alternative 2: 78.5% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+47}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\left(M \cdot h\right) \cdot D}{d} \cdot -0.25}{\ell \cdot d}, D \cdot M, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \mathsf{fma}\left(\left(\frac{h \cdot M}{d} \cdot \frac{\frac{M}{\ell}}{d}\right) \cdot D, -0.125 \cdot D, 1\right)\\ \end{array} \end{array} \]
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) -2e+47)
   (* w0 (sqrt (fma (/ (* (/ (* (* M h) D) d) -0.25) (* l d)) (* D M) 1.0)))
   (* w0 (fma (* (* (/ (* h M) d) (/ (/ M l) d)) D) (* -0.125 D) 1.0))))
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -2e+47) {
		tmp = w0 * sqrt(fma((((((M * h) * D) / d) * -0.25) / (l * d)), (D * M), 1.0));
	} else {
		tmp = w0 * fma(((((h * M) / d) * ((M / l) / d)) * D), (-0.125 * D), 1.0);
	}
	return tmp;
}
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -2e+47)
		tmp = Float64(w0 * sqrt(fma(Float64(Float64(Float64(Float64(Float64(M * h) * D) / d) * -0.25) / Float64(l * d)), Float64(D * M), 1.0)));
	else
		tmp = Float64(w0 * fma(Float64(Float64(Float64(Float64(h * M) / d) * Float64(Float64(M / l) / d)) * D), Float64(-0.125 * D), 1.0));
	end
	return tmp
end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -2e+47], N[(w0 * N[Sqrt[N[(N[(N[(N[(N[(N[(M * h), $MachinePrecision] * D), $MachinePrecision] / d), $MachinePrecision] * -0.25), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision] * N[(D * M), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[(N[(N[(N[(N[(h * M), $MachinePrecision] / d), $MachinePrecision] * N[(N[(M / l), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision] * N[(-0.125 * D), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+47}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\left(M \cdot h\right) \cdot D}{d} \cdot -0.25}{\ell \cdot d}, D \cdot M, 1\right)}\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(\left(\frac{h \cdot M}{d} \cdot \frac{\frac{M}{\ell}}{d}\right) \cdot D, -0.125 \cdot D, 1\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -2.0000000000000001e47

    1. Initial program 62.0%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
      2. sub-negN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
      3. +-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) + 1}} \]
      4. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\right)\right) + 1} \]
      5. lift-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \color{blue}{\frac{h}{\ell}}\right)\right) + 1} \]
      6. associate-*r/N/A

        \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot h}{\ell}}\right)\right) + 1} \]
      7. distribute-neg-frac2N/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot h}{\mathsf{neg}\left(\ell\right)}} + 1} \]
      8. lift-pow.f64N/A

        \[\leadsto w0 \cdot \sqrt{\frac{\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}} \cdot h}{\mathsf{neg}\left(\ell\right)} + 1} \]
      9. unpow2N/A

        \[\leadsto w0 \cdot \sqrt{\frac{\color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)} \cdot h}{\mathsf{neg}\left(\ell\right)} + 1} \]
      10. associate-*l*N/A

        \[\leadsto w0 \cdot \sqrt{\frac{\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \left(\frac{M \cdot D}{2 \cdot d} \cdot h\right)}}{\mathsf{neg}\left(\ell\right)} + 1} \]
      11. associate-/l*N/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \frac{\frac{M \cdot D}{2 \cdot d} \cdot h}{\mathsf{neg}\left(\ell\right)}} + 1} \]
      12. lower-fma.f64N/A

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{M \cdot D}{2 \cdot d}, \frac{\frac{M \cdot D}{2 \cdot d} \cdot h}{\mathsf{neg}\left(\ell\right)}, 1\right)}} \]
    4. Applied rewrites58.1%

      \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(\frac{0.5}{d} \cdot M\right) \cdot D, \frac{\left(D \cdot 0.5\right) \cdot \left(\frac{M}{d} \cdot h\right)}{-\ell}, 1\right)}} \]
    5. Applied rewrites64.5%

      \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{\frac{-0.5 \cdot \left(D \cdot M\right)}{d} \cdot h}{\ell} \cdot \frac{0.5}{d}, D \cdot M, 1\right)}} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d} \cdot h}{\ell} \cdot \frac{\frac{1}{2}}{d}}, D \cdot M, 1\right)} \]
      2. lift-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d} \cdot h}{\ell}} \cdot \frac{\frac{1}{2}}{d}, D \cdot M, 1\right)} \]
      3. lift-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d} \cdot h}{\ell} \cdot \color{blue}{\frac{\frac{1}{2}}{d}}, D \cdot M, 1\right)} \]
      4. frac-timesN/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\left(\frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d} \cdot h\right) \cdot \frac{1}{2}}{\ell \cdot d}}, D \cdot M, 1\right)} \]
      5. *-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(\frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d} \cdot h\right) \cdot \frac{1}{2}}{\color{blue}{d \cdot \ell}}, D \cdot M, 1\right)} \]
      6. lower-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\left(\frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d} \cdot h\right) \cdot \frac{1}{2}}{d \cdot \ell}}, D \cdot M, 1\right)} \]
      7. *-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\frac{1}{2} \cdot \left(\frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d} \cdot h\right)}}{d \cdot \ell}, D \cdot M, 1\right)} \]
      8. lower-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\frac{1}{2} \cdot \left(\frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d} \cdot h\right)}}{d \cdot \ell}, D \cdot M, 1\right)} \]
      9. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{1}{2} \cdot \color{blue}{\left(\frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d} \cdot h\right)}}{d \cdot \ell}, D \cdot M, 1\right)} \]
      10. *-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{1}{2} \cdot \color{blue}{\left(h \cdot \frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d}\right)}}{d \cdot \ell}, D \cdot M, 1\right)} \]
      11. lower-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{1}{2} \cdot \color{blue}{\left(h \cdot \frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d}\right)}}{d \cdot \ell}, D \cdot M, 1\right)} \]
      12. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{1}{2} \cdot \left(h \cdot \frac{\color{blue}{\frac{-1}{2} \cdot \left(D \cdot M\right)}}{d}\right)}{d \cdot \ell}, D \cdot M, 1\right)} \]
      13. *-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{1}{2} \cdot \left(h \cdot \frac{\color{blue}{\left(D \cdot M\right) \cdot \frac{-1}{2}}}{d}\right)}{d \cdot \ell}, D \cdot M, 1\right)} \]
      14. lower-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{1}{2} \cdot \left(h \cdot \frac{\color{blue}{\left(D \cdot M\right) \cdot \frac{-1}{2}}}{d}\right)}{d \cdot \ell}, D \cdot M, 1\right)} \]
      15. lift-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{1}{2} \cdot \left(h \cdot \frac{\color{blue}{\left(D \cdot M\right)} \cdot \frac{-1}{2}}{d}\right)}{d \cdot \ell}, D \cdot M, 1\right)} \]
      16. *-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{1}{2} \cdot \left(h \cdot \frac{\color{blue}{\left(M \cdot D\right)} \cdot \frac{-1}{2}}{d}\right)}{d \cdot \ell}, D \cdot M, 1\right)} \]
      17. lower-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{1}{2} \cdot \left(h \cdot \frac{\color{blue}{\left(M \cdot D\right)} \cdot \frac{-1}{2}}{d}\right)}{d \cdot \ell}, D \cdot M, 1\right)} \]
      18. *-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{1}{2} \cdot \left(h \cdot \frac{\left(M \cdot D\right) \cdot \frac{-1}{2}}{d}\right)}{\color{blue}{\ell \cdot d}}, D \cdot M, 1\right)} \]
      19. lower-*.f6462.0

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{0.5 \cdot \left(h \cdot \frac{\left(M \cdot D\right) \cdot -0.5}{d}\right)}{\color{blue}{\ell \cdot d}}, D \cdot M, 1\right)} \]
    7. Applied rewrites62.0%

      \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{0.5 \cdot \left(h \cdot \frac{\left(M \cdot D\right) \cdot -0.5}{d}\right)}{\ell \cdot d}}, D \cdot M, 1\right)} \]
    8. Taylor expanded in M around 0

      \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\frac{-1}{4} \cdot \frac{D \cdot \left(M \cdot h\right)}{d}}}{\ell \cdot d}, D \cdot M, 1\right)} \]
    9. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\frac{D \cdot \left(M \cdot h\right)}{d} \cdot \frac{-1}{4}}}{\ell \cdot d}, D \cdot M, 1\right)} \]
      2. lower-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\frac{D \cdot \left(M \cdot h\right)}{d} \cdot \frac{-1}{4}}}{\ell \cdot d}, D \cdot M, 1\right)} \]
      3. lower-/.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\frac{D \cdot \left(M \cdot h\right)}{d}} \cdot \frac{-1}{4}}{\ell \cdot d}, D \cdot M, 1\right)} \]
      4. *-commutativeN/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\color{blue}{\left(M \cdot h\right) \cdot D}}{d} \cdot \frac{-1}{4}}{\ell \cdot d}, D \cdot M, 1\right)} \]
      5. lower-*.f64N/A

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\color{blue}{\left(M \cdot h\right) \cdot D}}{d} \cdot \frac{-1}{4}}{\ell \cdot d}, D \cdot M, 1\right)} \]
      6. lower-*.f6454.3

        \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\color{blue}{\left(M \cdot h\right)} \cdot D}{d} \cdot -0.25}{\ell \cdot d}, D \cdot M, 1\right)} \]
    10. Applied rewrites54.3%

      \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\frac{\left(M \cdot h\right) \cdot D}{d} \cdot -0.25}}{\ell \cdot d}, D \cdot M, 1\right)} \]

    if -2.0000000000000001e47 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))

    1. Initial program 85.6%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Add Preprocessing
    3. Taylor expanded in M around 0

      \[\leadsto w0 \cdot \color{blue}{\left(1 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto w0 \cdot \color{blue}{\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell} + 1\right)} \]
      2. *-commutativeN/A

        \[\leadsto w0 \cdot \left(\color{blue}{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell} \cdot \frac{-1}{8}} + 1\right) \]
      3. associate-/l*N/A

        \[\leadsto w0 \cdot \left(\color{blue}{\left({D}^{2} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}\right)} \cdot \frac{-1}{8} + 1\right) \]
      4. associate-*r*N/A

        \[\leadsto w0 \cdot \left(\color{blue}{{D}^{2} \cdot \left(\frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell} \cdot \frac{-1}{8}\right)} + 1\right) \]
      5. *-commutativeN/A

        \[\leadsto w0 \cdot \left({D}^{2} \cdot \color{blue}{\left(\frac{-1}{8} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}\right)} + 1\right) \]
      6. associate-*r*N/A

        \[\leadsto w0 \cdot \left(\color{blue}{\left({D}^{2} \cdot \frac{-1}{8}\right) \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}} + 1\right) \]
      7. lower-fma.f64N/A

        \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left({D}^{2} \cdot \frac{-1}{8}, \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}, 1\right)} \]
    5. Applied rewrites64.7%

      \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left(\left(D \cdot D\right) \cdot -0.125, \frac{h}{d \cdot d} \cdot \frac{M \cdot M}{\ell}, 1\right)} \]
    6. Step-by-step derivation
      1. Applied rewrites70.9%

        \[\leadsto w0 \cdot \mathsf{fma}\left(\left(D \cdot D\right) \cdot -0.125, M \cdot \color{blue}{\frac{h \cdot M}{\left(d \cdot d\right) \cdot \ell}}, 1\right) \]
      2. Step-by-step derivation
        1. Applied rewrites89.2%

          \[\leadsto w0 \cdot \mathsf{fma}\left(\left(\frac{h \cdot M}{d} \cdot \frac{\frac{M}{\ell}}{d}\right) \cdot D, \color{blue}{-0.125 \cdot D}, 1\right) \]
      3. Recombined 2 regimes into one program.
      4. Add Preprocessing

      Alternative 3: 76.2% accurate, 0.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -5 \cdot 10^{+47}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\left(-0.25 \cdot \frac{D}{d \cdot d}\right) \cdot \frac{M \cdot h}{\ell}, D \cdot M, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \mathsf{fma}\left(\left(\frac{h \cdot M}{d} \cdot \frac{\frac{M}{\ell}}{d}\right) \cdot D, -0.125 \cdot D, 1\right)\\ \end{array} \end{array} \]
      (FPCore (w0 M D h l d)
       :precision binary64
       (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) -5e+47)
         (* w0 (sqrt (fma (* (* -0.25 (/ D (* d d))) (/ (* M h) l)) (* D M) 1.0)))
         (* w0 (fma (* (* (/ (* h M) d) (/ (/ M l) d)) D) (* -0.125 D) 1.0))))
      double code(double w0, double M, double D, double h, double l, double d) {
      	double tmp;
      	if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -5e+47) {
      		tmp = w0 * sqrt(fma(((-0.25 * (D / (d * d))) * ((M * h) / l)), (D * M), 1.0));
      	} else {
      		tmp = w0 * fma(((((h * M) / d) * ((M / l) / d)) * D), (-0.125 * D), 1.0);
      	}
      	return tmp;
      }
      
      function code(w0, M, D, h, l, d)
      	tmp = 0.0
      	if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -5e+47)
      		tmp = Float64(w0 * sqrt(fma(Float64(Float64(-0.25 * Float64(D / Float64(d * d))) * Float64(Float64(M * h) / l)), Float64(D * M), 1.0)));
      	else
      		tmp = Float64(w0 * fma(Float64(Float64(Float64(Float64(h * M) / d) * Float64(Float64(M / l) / d)) * D), Float64(-0.125 * D), 1.0));
      	end
      	return tmp
      end
      
      code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -5e+47], N[(w0 * N[Sqrt[N[(N[(N[(-0.25 * N[(D / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(M * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * N[(D * M), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[(N[(N[(N[(N[(h * M), $MachinePrecision] / d), $MachinePrecision] * N[(N[(M / l), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision] * N[(-0.125 * D), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -5 \cdot 10^{+47}:\\
      \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\left(-0.25 \cdot \frac{D}{d \cdot d}\right) \cdot \frac{M \cdot h}{\ell}, D \cdot M, 1\right)}\\
      
      \mathbf{else}:\\
      \;\;\;\;w0 \cdot \mathsf{fma}\left(\left(\frac{h \cdot M}{d} \cdot \frac{\frac{M}{\ell}}{d}\right) \cdot D, -0.125 \cdot D, 1\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -5.00000000000000022e47

        1. Initial program 61.5%

          \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. lift--.f64N/A

            \[\leadsto w0 \cdot \sqrt{\color{blue}{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
          2. sub-negN/A

            \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
          3. +-commutativeN/A

            \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) + 1}} \]
          4. lift-*.f64N/A

            \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\right)\right) + 1} \]
          5. lift-/.f64N/A

            \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \color{blue}{\frac{h}{\ell}}\right)\right) + 1} \]
          6. associate-*r/N/A

            \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot h}{\ell}}\right)\right) + 1} \]
          7. distribute-neg-frac2N/A

            \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot h}{\mathsf{neg}\left(\ell\right)}} + 1} \]
          8. lift-pow.f64N/A

            \[\leadsto w0 \cdot \sqrt{\frac{\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}} \cdot h}{\mathsf{neg}\left(\ell\right)} + 1} \]
          9. unpow2N/A

            \[\leadsto w0 \cdot \sqrt{\frac{\color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)} \cdot h}{\mathsf{neg}\left(\ell\right)} + 1} \]
          10. associate-*l*N/A

            \[\leadsto w0 \cdot \sqrt{\frac{\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \left(\frac{M \cdot D}{2 \cdot d} \cdot h\right)}}{\mathsf{neg}\left(\ell\right)} + 1} \]
          11. associate-/l*N/A

            \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \frac{\frac{M \cdot D}{2 \cdot d} \cdot h}{\mathsf{neg}\left(\ell\right)}} + 1} \]
          12. lower-fma.f64N/A

            \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{M \cdot D}{2 \cdot d}, \frac{\frac{M \cdot D}{2 \cdot d} \cdot h}{\mathsf{neg}\left(\ell\right)}, 1\right)}} \]
        4. Applied rewrites58.9%

          \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(\frac{0.5}{d} \cdot M\right) \cdot D, \frac{\left(D \cdot 0.5\right) \cdot \left(\frac{M}{d} \cdot h\right)}{-\ell}, 1\right)}} \]
        5. Applied rewrites64.0%

          \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{\frac{-0.5 \cdot \left(D \cdot M\right)}{d} \cdot h}{\ell} \cdot \frac{0.5}{d}, D \cdot M, 1\right)}} \]
        6. Step-by-step derivation
          1. lift-*.f64N/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d} \cdot h}{\ell} \cdot \frac{\frac{1}{2}}{d}}, D \cdot M, 1\right)} \]
          2. lift-/.f64N/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d} \cdot h}{\ell}} \cdot \frac{\frac{1}{2}}{d}, D \cdot M, 1\right)} \]
          3. lift-/.f64N/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d} \cdot h}{\ell} \cdot \color{blue}{\frac{\frac{1}{2}}{d}}, D \cdot M, 1\right)} \]
          4. frac-timesN/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\left(\frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d} \cdot h\right) \cdot \frac{1}{2}}{\ell \cdot d}}, D \cdot M, 1\right)} \]
          5. *-commutativeN/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(\frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d} \cdot h\right) \cdot \frac{1}{2}}{\color{blue}{d \cdot \ell}}, D \cdot M, 1\right)} \]
          6. lower-/.f64N/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\left(\frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d} \cdot h\right) \cdot \frac{1}{2}}{d \cdot \ell}}, D \cdot M, 1\right)} \]
          7. *-commutativeN/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\frac{1}{2} \cdot \left(\frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d} \cdot h\right)}}{d \cdot \ell}, D \cdot M, 1\right)} \]
          8. lower-*.f64N/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\frac{1}{2} \cdot \left(\frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d} \cdot h\right)}}{d \cdot \ell}, D \cdot M, 1\right)} \]
          9. lift-*.f64N/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{1}{2} \cdot \color{blue}{\left(\frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d} \cdot h\right)}}{d \cdot \ell}, D \cdot M, 1\right)} \]
          10. *-commutativeN/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{1}{2} \cdot \color{blue}{\left(h \cdot \frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d}\right)}}{d \cdot \ell}, D \cdot M, 1\right)} \]
          11. lower-*.f64N/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{1}{2} \cdot \color{blue}{\left(h \cdot \frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d}\right)}}{d \cdot \ell}, D \cdot M, 1\right)} \]
          12. lift-*.f64N/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{1}{2} \cdot \left(h \cdot \frac{\color{blue}{\frac{-1}{2} \cdot \left(D \cdot M\right)}}{d}\right)}{d \cdot \ell}, D \cdot M, 1\right)} \]
          13. *-commutativeN/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{1}{2} \cdot \left(h \cdot \frac{\color{blue}{\left(D \cdot M\right) \cdot \frac{-1}{2}}}{d}\right)}{d \cdot \ell}, D \cdot M, 1\right)} \]
          14. lower-*.f64N/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{1}{2} \cdot \left(h \cdot \frac{\color{blue}{\left(D \cdot M\right) \cdot \frac{-1}{2}}}{d}\right)}{d \cdot \ell}, D \cdot M, 1\right)} \]
          15. lift-*.f64N/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{1}{2} \cdot \left(h \cdot \frac{\color{blue}{\left(D \cdot M\right)} \cdot \frac{-1}{2}}{d}\right)}{d \cdot \ell}, D \cdot M, 1\right)} \]
          16. *-commutativeN/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{1}{2} \cdot \left(h \cdot \frac{\color{blue}{\left(M \cdot D\right)} \cdot \frac{-1}{2}}{d}\right)}{d \cdot \ell}, D \cdot M, 1\right)} \]
          17. lower-*.f64N/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{1}{2} \cdot \left(h \cdot \frac{\color{blue}{\left(M \cdot D\right)} \cdot \frac{-1}{2}}{d}\right)}{d \cdot \ell}, D \cdot M, 1\right)} \]
          18. *-commutativeN/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{1}{2} \cdot \left(h \cdot \frac{\left(M \cdot D\right) \cdot \frac{-1}{2}}{d}\right)}{\color{blue}{\ell \cdot d}}, D \cdot M, 1\right)} \]
          19. lower-*.f6461.5

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{0.5 \cdot \left(h \cdot \frac{\left(M \cdot D\right) \cdot -0.5}{d}\right)}{\color{blue}{\ell \cdot d}}, D \cdot M, 1\right)} \]
        7. Applied rewrites61.5%

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{0.5 \cdot \left(h \cdot \frac{\left(M \cdot D\right) \cdot -0.5}{d}\right)}{\ell \cdot d}}, D \cdot M, 1\right)} \]
        8. Taylor expanded in M around 0

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{-1}{4} \cdot \frac{D \cdot \left(M \cdot h\right)}{{d}^{2} \cdot \ell}}, D \cdot M, 1\right)} \]
        9. Step-by-step derivation
          1. times-fracN/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-1}{4} \cdot \color{blue}{\left(\frac{D}{{d}^{2}} \cdot \frac{M \cdot h}{\ell}\right)}, D \cdot M, 1\right)} \]
          2. associate-*r*N/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\left(\frac{-1}{4} \cdot \frac{D}{{d}^{2}}\right) \cdot \frac{M \cdot h}{\ell}}, D \cdot M, 1\right)} \]
          3. lower-*.f64N/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\left(\frac{-1}{4} \cdot \frac{D}{{d}^{2}}\right) \cdot \frac{M \cdot h}{\ell}}, D \cdot M, 1\right)} \]
          4. lower-*.f64N/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\left(\frac{-1}{4} \cdot \frac{D}{{d}^{2}}\right)} \cdot \frac{M \cdot h}{\ell}, D \cdot M, 1\right)} \]
          5. lower-/.f64N/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\left(\frac{-1}{4} \cdot \color{blue}{\frac{D}{{d}^{2}}}\right) \cdot \frac{M \cdot h}{\ell}, D \cdot M, 1\right)} \]
          6. unpow2N/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\left(\frac{-1}{4} \cdot \frac{D}{\color{blue}{d \cdot d}}\right) \cdot \frac{M \cdot h}{\ell}, D \cdot M, 1\right)} \]
          7. lower-*.f64N/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\left(\frac{-1}{4} \cdot \frac{D}{\color{blue}{d \cdot d}}\right) \cdot \frac{M \cdot h}{\ell}, D \cdot M, 1\right)} \]
          8. lower-/.f64N/A

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\left(\frac{-1}{4} \cdot \frac{D}{d \cdot d}\right) \cdot \color{blue}{\frac{M \cdot h}{\ell}}, D \cdot M, 1\right)} \]
          9. lower-*.f6450.0

            \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\left(-0.25 \cdot \frac{D}{d \cdot d}\right) \cdot \frac{\color{blue}{M \cdot h}}{\ell}, D \cdot M, 1\right)} \]
        10. Applied rewrites50.0%

          \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\left(-0.25 \cdot \frac{D}{d \cdot d}\right) \cdot \frac{M \cdot h}{\ell}}, D \cdot M, 1\right)} \]

        if -5.00000000000000022e47 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))

        1. Initial program 85.7%

          \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
        2. Add Preprocessing
        3. Taylor expanded in M around 0

          \[\leadsto w0 \cdot \color{blue}{\left(1 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)} \]
        4. Step-by-step derivation
          1. +-commutativeN/A

            \[\leadsto w0 \cdot \color{blue}{\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell} + 1\right)} \]
          2. *-commutativeN/A

            \[\leadsto w0 \cdot \left(\color{blue}{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell} \cdot \frac{-1}{8}} + 1\right) \]
          3. associate-/l*N/A

            \[\leadsto w0 \cdot \left(\color{blue}{\left({D}^{2} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}\right)} \cdot \frac{-1}{8} + 1\right) \]
          4. associate-*r*N/A

            \[\leadsto w0 \cdot \left(\color{blue}{{D}^{2} \cdot \left(\frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell} \cdot \frac{-1}{8}\right)} + 1\right) \]
          5. *-commutativeN/A

            \[\leadsto w0 \cdot \left({D}^{2} \cdot \color{blue}{\left(\frac{-1}{8} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}\right)} + 1\right) \]
          6. associate-*r*N/A

            \[\leadsto w0 \cdot \left(\color{blue}{\left({D}^{2} \cdot \frac{-1}{8}\right) \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}} + 1\right) \]
          7. lower-fma.f64N/A

            \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left({D}^{2} \cdot \frac{-1}{8}, \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}, 1\right)} \]
        5. Applied rewrites64.3%

          \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left(\left(D \cdot D\right) \cdot -0.125, \frac{h}{d \cdot d} \cdot \frac{M \cdot M}{\ell}, 1\right)} \]
        6. Step-by-step derivation
          1. Applied rewrites70.5%

            \[\leadsto w0 \cdot \mathsf{fma}\left(\left(D \cdot D\right) \cdot -0.125, M \cdot \color{blue}{\frac{h \cdot M}{\left(d \cdot d\right) \cdot \ell}}, 1\right) \]
          2. Step-by-step derivation
            1. Applied rewrites88.7%

              \[\leadsto w0 \cdot \mathsf{fma}\left(\left(\frac{h \cdot M}{d} \cdot \frac{\frac{M}{\ell}}{d}\right) \cdot D, \color{blue}{-0.125 \cdot D}, 1\right) \]
          3. Recombined 2 regimes into one program.
          4. Add Preprocessing

          Alternative 4: 78.8% accurate, 0.8× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -1 \cdot 10^{+76}:\\ \;\;\;\;w0 \cdot \mathsf{fma}\left(\left(D \cdot D\right) \cdot -0.125, M \cdot \left(M \cdot \frac{h}{\left(d \cdot d\right) \cdot \ell}\right), 1\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \end{array} \]
          (FPCore (w0 M D h l d)
           :precision binary64
           (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) -1e+76)
             (* w0 (fma (* (* D D) -0.125) (* M (* M (/ h (* (* d d) l)))) 1.0))
             (* w0 1.0)))
          double code(double w0, double M, double D, double h, double l, double d) {
          	double tmp;
          	if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -1e+76) {
          		tmp = w0 * fma(((D * D) * -0.125), (M * (M * (h / ((d * d) * l)))), 1.0);
          	} else {
          		tmp = w0 * 1.0;
          	}
          	return tmp;
          }
          
          function code(w0, M, D, h, l, d)
          	tmp = 0.0
          	if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -1e+76)
          		tmp = Float64(w0 * fma(Float64(Float64(D * D) * -0.125), Float64(M * Float64(M * Float64(h / Float64(Float64(d * d) * l)))), 1.0));
          	else
          		tmp = Float64(w0 * 1.0);
          	end
          	return tmp
          end
          
          code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -1e+76], N[(w0 * N[(N[(N[(D * D), $MachinePrecision] * -0.125), $MachinePrecision] * N[(M * N[(M * N[(h / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -1 \cdot 10^{+76}:\\
          \;\;\;\;w0 \cdot \mathsf{fma}\left(\left(D \cdot D\right) \cdot -0.125, M \cdot \left(M \cdot \frac{h}{\left(d \cdot d\right) \cdot \ell}\right), 1\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;w0 \cdot 1\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -1e76

            1. Initial program 59.9%

              \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
            2. Add Preprocessing
            3. Taylor expanded in M around 0

              \[\leadsto w0 \cdot \color{blue}{\left(1 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)} \]
            4. Step-by-step derivation
              1. +-commutativeN/A

                \[\leadsto w0 \cdot \color{blue}{\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell} + 1\right)} \]
              2. *-commutativeN/A

                \[\leadsto w0 \cdot \left(\color{blue}{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell} \cdot \frac{-1}{8}} + 1\right) \]
              3. associate-/l*N/A

                \[\leadsto w0 \cdot \left(\color{blue}{\left({D}^{2} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}\right)} \cdot \frac{-1}{8} + 1\right) \]
              4. associate-*r*N/A

                \[\leadsto w0 \cdot \left(\color{blue}{{D}^{2} \cdot \left(\frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell} \cdot \frac{-1}{8}\right)} + 1\right) \]
              5. *-commutativeN/A

                \[\leadsto w0 \cdot \left({D}^{2} \cdot \color{blue}{\left(\frac{-1}{8} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}\right)} + 1\right) \]
              6. associate-*r*N/A

                \[\leadsto w0 \cdot \left(\color{blue}{\left({D}^{2} \cdot \frac{-1}{8}\right) \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}} + 1\right) \]
              7. lower-fma.f64N/A

                \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left({D}^{2} \cdot \frac{-1}{8}, \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}, 1\right)} \]
            5. Applied rewrites38.1%

              \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left(\left(D \cdot D\right) \cdot -0.125, \frac{h}{d \cdot d} \cdot \frac{M \cdot M}{\ell}, 1\right)} \]
            6. Step-by-step derivation
              1. Applied rewrites42.9%

                \[\leadsto w0 \cdot \mathsf{fma}\left(\left(D \cdot D\right) \cdot -0.125, M \cdot \color{blue}{\frac{h \cdot M}{\left(d \cdot d\right) \cdot \ell}}, 1\right) \]
              2. Step-by-step derivation
                1. Applied rewrites44.3%

                  \[\leadsto w0 \cdot \mathsf{fma}\left(\left(D \cdot D\right) \cdot -0.125, M \cdot \left(M \cdot \color{blue}{\frac{h}{\left(d \cdot d\right) \cdot \ell}}\right), 1\right) \]

                if -1e76 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))

                1. Initial program 85.9%

                  \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                2. Add Preprocessing
                3. Taylor expanded in M around 0

                  \[\leadsto w0 \cdot \color{blue}{1} \]
                4. Step-by-step derivation
                  1. Applied rewrites94.5%

                    \[\leadsto w0 \cdot \color{blue}{1} \]
                5. Recombined 2 regimes into one program.
                6. Add Preprocessing

                Alternative 5: 79.7% accurate, 0.8× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+47}:\\ \;\;\;\;w0 \cdot \mathsf{fma}\left(D, D \cdot \left(\left(-0.125 \cdot \frac{M \cdot h}{\left(d \cdot d\right) \cdot \ell}\right) \cdot M\right), 1\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \end{array} \]
                (FPCore (w0 M D h l d)
                 :precision binary64
                 (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) -2e+47)
                   (* w0 (fma D (* D (* (* -0.125 (/ (* M h) (* (* d d) l))) M)) 1.0))
                   (* w0 1.0)))
                double code(double w0, double M, double D, double h, double l, double d) {
                	double tmp;
                	if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -2e+47) {
                		tmp = w0 * fma(D, (D * ((-0.125 * ((M * h) / ((d * d) * l))) * M)), 1.0);
                	} else {
                		tmp = w0 * 1.0;
                	}
                	return tmp;
                }
                
                function code(w0, M, D, h, l, d)
                	tmp = 0.0
                	if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -2e+47)
                		tmp = Float64(w0 * fma(D, Float64(D * Float64(Float64(-0.125 * Float64(Float64(M * h) / Float64(Float64(d * d) * l))) * M)), 1.0));
                	else
                		tmp = Float64(w0 * 1.0);
                	end
                	return tmp
                end
                
                code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -2e+47], N[(w0 * N[(D * N[(D * N[(N[(-0.125 * N[(N[(M * h), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * M), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+47}:\\
                \;\;\;\;w0 \cdot \mathsf{fma}\left(D, D \cdot \left(\left(-0.125 \cdot \frac{M \cdot h}{\left(d \cdot d\right) \cdot \ell}\right) \cdot M\right), 1\right)\\
                
                \mathbf{else}:\\
                \;\;\;\;w0 \cdot 1\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -2.0000000000000001e47

                  1. Initial program 62.0%

                    \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                  2. Add Preprocessing
                  3. Taylor expanded in M around 0

                    \[\leadsto w0 \cdot \color{blue}{\left(1 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)} \]
                  4. Step-by-step derivation
                    1. +-commutativeN/A

                      \[\leadsto w0 \cdot \color{blue}{\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell} + 1\right)} \]
                    2. *-commutativeN/A

                      \[\leadsto w0 \cdot \left(\color{blue}{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell} \cdot \frac{-1}{8}} + 1\right) \]
                    3. associate-/l*N/A

                      \[\leadsto w0 \cdot \left(\color{blue}{\left({D}^{2} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}\right)} \cdot \frac{-1}{8} + 1\right) \]
                    4. associate-*r*N/A

                      \[\leadsto w0 \cdot \left(\color{blue}{{D}^{2} \cdot \left(\frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell} \cdot \frac{-1}{8}\right)} + 1\right) \]
                    5. *-commutativeN/A

                      \[\leadsto w0 \cdot \left({D}^{2} \cdot \color{blue}{\left(\frac{-1}{8} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}\right)} + 1\right) \]
                    6. associate-*r*N/A

                      \[\leadsto w0 \cdot \left(\color{blue}{\left({D}^{2} \cdot \frac{-1}{8}\right) \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}} + 1\right) \]
                    7. lower-fma.f64N/A

                      \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left({D}^{2} \cdot \frac{-1}{8}, \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}, 1\right)} \]
                  5. Applied rewrites36.2%

                    \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left(\left(D \cdot D\right) \cdot -0.125, \frac{h}{d \cdot d} \cdot \frac{M \cdot M}{\ell}, 1\right)} \]
                  6. Step-by-step derivation
                    1. Applied rewrites38.4%

                      \[\leadsto w0 \cdot \mathsf{fma}\left(D, \color{blue}{D \cdot \left(\left(-0.125 \cdot \frac{M \cdot M}{\ell}\right) \cdot \frac{h}{d \cdot d}\right)}, 1\right) \]
                    2. Step-by-step derivation
                      1. Applied rewrites44.3%

                        \[\leadsto w0 \cdot \mathsf{fma}\left(D, D \cdot \left(\left(-0.125 \cdot \left(\frac{M}{d \cdot d} \cdot \frac{h}{\ell}\right)\right) \cdot \color{blue}{M}\right), 1\right) \]
                      2. Step-by-step derivation
                        1. Applied rewrites43.0%

                          \[\leadsto w0 \cdot \mathsf{fma}\left(D, D \cdot \left(\left(-0.125 \cdot \frac{M \cdot h}{\left(d \cdot d\right) \cdot \ell}\right) \cdot M\right), 1\right) \]

                        if -2.0000000000000001e47 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))

                        1. Initial program 85.6%

                          \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                        2. Add Preprocessing
                        3. Taylor expanded in M around 0

                          \[\leadsto w0 \cdot \color{blue}{1} \]
                        4. Step-by-step derivation
                          1. Applied rewrites96.3%

                            \[\leadsto w0 \cdot \color{blue}{1} \]
                        5. Recombined 2 regimes into one program.
                        6. Add Preprocessing

                        Alternative 6: 78.6% accurate, 0.8× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \leq 10^{-291}:\\ \;\;\;\;w0 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \mathsf{fma}\left(D, D \cdot \left(\left(-0.125 \cdot \frac{\frac{M}{d} \cdot h}{\ell \cdot d}\right) \cdot M\right), 1\right)\\ \end{array} \end{array} \]
                        (FPCore (w0 M D h l d)
                         :precision binary64
                         (if (<= (pow (/ (* M D) (* 2.0 d)) 2.0) 1e-291)
                           (* w0 1.0)
                           (* w0 (fma D (* D (* (* -0.125 (/ (* (/ M d) h) (* l d))) M)) 1.0))))
                        double code(double w0, double M, double D, double h, double l, double d) {
                        	double tmp;
                        	if (pow(((M * D) / (2.0 * d)), 2.0) <= 1e-291) {
                        		tmp = w0 * 1.0;
                        	} else {
                        		tmp = w0 * fma(D, (D * ((-0.125 * (((M / d) * h) / (l * d))) * M)), 1.0);
                        	}
                        	return tmp;
                        }
                        
                        function code(w0, M, D, h, l, d)
                        	tmp = 0.0
                        	if ((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) <= 1e-291)
                        		tmp = Float64(w0 * 1.0);
                        	else
                        		tmp = Float64(w0 * fma(D, Float64(D * Float64(Float64(-0.125 * Float64(Float64(Float64(M / d) * h) / Float64(l * d))) * M)), 1.0));
                        	end
                        	return tmp
                        end
                        
                        code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], 1e-291], N[(w0 * 1.0), $MachinePrecision], N[(w0 * N[(D * N[(D * N[(N[(-0.125 * N[(N[(N[(M / d), $MachinePrecision] * h), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * M), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \leq 10^{-291}:\\
                        \;\;\;\;w0 \cdot 1\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;w0 \cdot \mathsf{fma}\left(D, D \cdot \left(\left(-0.125 \cdot \frac{\frac{M}{d} \cdot h}{\ell \cdot d}\right) \cdot M\right), 1\right)\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) < 9.99999999999999962e-292

                          1. Initial program 87.9%

                            \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                          2. Add Preprocessing
                          3. Taylor expanded in M around 0

                            \[\leadsto w0 \cdot \color{blue}{1} \]
                          4. Step-by-step derivation
                            1. Applied rewrites100.0%

                              \[\leadsto w0 \cdot \color{blue}{1} \]

                            if 9.99999999999999962e-292 < (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))

                            1. Initial program 70.1%

                              \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                            2. Add Preprocessing
                            3. Taylor expanded in M around 0

                              \[\leadsto w0 \cdot \color{blue}{\left(1 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)} \]
                            4. Step-by-step derivation
                              1. +-commutativeN/A

                                \[\leadsto w0 \cdot \color{blue}{\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell} + 1\right)} \]
                              2. *-commutativeN/A

                                \[\leadsto w0 \cdot \left(\color{blue}{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell} \cdot \frac{-1}{8}} + 1\right) \]
                              3. associate-/l*N/A

                                \[\leadsto w0 \cdot \left(\color{blue}{\left({D}^{2} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}\right)} \cdot \frac{-1}{8} + 1\right) \]
                              4. associate-*r*N/A

                                \[\leadsto w0 \cdot \left(\color{blue}{{D}^{2} \cdot \left(\frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell} \cdot \frac{-1}{8}\right)} + 1\right) \]
                              5. *-commutativeN/A

                                \[\leadsto w0 \cdot \left({D}^{2} \cdot \color{blue}{\left(\frac{-1}{8} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}\right)} + 1\right) \]
                              6. associate-*r*N/A

                                \[\leadsto w0 \cdot \left(\color{blue}{\left({D}^{2} \cdot \frac{-1}{8}\right) \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}} + 1\right) \]
                              7. lower-fma.f64N/A

                                \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left({D}^{2} \cdot \frac{-1}{8}, \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}, 1\right)} \]
                            5. Applied rewrites37.3%

                              \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left(\left(D \cdot D\right) \cdot -0.125, \frac{h}{d \cdot d} \cdot \frac{M \cdot M}{\ell}, 1\right)} \]
                            6. Step-by-step derivation
                              1. Applied rewrites44.8%

                                \[\leadsto w0 \cdot \mathsf{fma}\left(D, \color{blue}{D \cdot \left(\left(-0.125 \cdot \frac{M \cdot M}{\ell}\right) \cdot \frac{h}{d \cdot d}\right)}, 1\right) \]
                              2. Step-by-step derivation
                                1. Applied rewrites50.5%

                                  \[\leadsto w0 \cdot \mathsf{fma}\left(D, D \cdot \left(\left(-0.125 \cdot \left(\frac{M}{d \cdot d} \cdot \frac{h}{\ell}\right)\right) \cdot \color{blue}{M}\right), 1\right) \]
                                2. Step-by-step derivation
                                  1. Applied rewrites62.6%

                                    \[\leadsto w0 \cdot \mathsf{fma}\left(D, D \cdot \left(\left(-0.125 \cdot \frac{\frac{M}{d} \cdot h}{\ell \cdot d}\right) \cdot M\right), 1\right) \]
                                3. Recombined 2 regimes into one program.
                                4. Add Preprocessing

                                Alternative 7: 78.6% accurate, 0.8× speedup?

                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \leq 10^{-291}:\\ \;\;\;\;w0 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \mathsf{fma}\left(D, D \cdot \left(\left(-0.125 \cdot \left(\frac{M}{d} \cdot \frac{h}{\ell \cdot d}\right)\right) \cdot M\right), 1\right)\\ \end{array} \end{array} \]
                                (FPCore (w0 M D h l d)
                                 :precision binary64
                                 (if (<= (pow (/ (* M D) (* 2.0 d)) 2.0) 1e-291)
                                   (* w0 1.0)
                                   (* w0 (fma D (* D (* (* -0.125 (* (/ M d) (/ h (* l d)))) M)) 1.0))))
                                double code(double w0, double M, double D, double h, double l, double d) {
                                	double tmp;
                                	if (pow(((M * D) / (2.0 * d)), 2.0) <= 1e-291) {
                                		tmp = w0 * 1.0;
                                	} else {
                                		tmp = w0 * fma(D, (D * ((-0.125 * ((M / d) * (h / (l * d)))) * M)), 1.0);
                                	}
                                	return tmp;
                                }
                                
                                function code(w0, M, D, h, l, d)
                                	tmp = 0.0
                                	if ((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) <= 1e-291)
                                		tmp = Float64(w0 * 1.0);
                                	else
                                		tmp = Float64(w0 * fma(D, Float64(D * Float64(Float64(-0.125 * Float64(Float64(M / d) * Float64(h / Float64(l * d)))) * M)), 1.0));
                                	end
                                	return tmp
                                end
                                
                                code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], 1e-291], N[(w0 * 1.0), $MachinePrecision], N[(w0 * N[(D * N[(D * N[(N[(-0.125 * N[(N[(M / d), $MachinePrecision] * N[(h / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * M), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
                                
                                \begin{array}{l}
                                
                                \\
                                \begin{array}{l}
                                \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \leq 10^{-291}:\\
                                \;\;\;\;w0 \cdot 1\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;w0 \cdot \mathsf{fma}\left(D, D \cdot \left(\left(-0.125 \cdot \left(\frac{M}{d} \cdot \frac{h}{\ell \cdot d}\right)\right) \cdot M\right), 1\right)\\
                                
                                
                                \end{array}
                                \end{array}
                                
                                Derivation
                                1. Split input into 2 regimes
                                2. if (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) < 9.99999999999999962e-292

                                  1. Initial program 87.9%

                                    \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                                  2. Add Preprocessing
                                  3. Taylor expanded in M around 0

                                    \[\leadsto w0 \cdot \color{blue}{1} \]
                                  4. Step-by-step derivation
                                    1. Applied rewrites100.0%

                                      \[\leadsto w0 \cdot \color{blue}{1} \]

                                    if 9.99999999999999962e-292 < (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))

                                    1. Initial program 70.1%

                                      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                                    2. Add Preprocessing
                                    3. Taylor expanded in M around 0

                                      \[\leadsto w0 \cdot \color{blue}{\left(1 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)} \]
                                    4. Step-by-step derivation
                                      1. +-commutativeN/A

                                        \[\leadsto w0 \cdot \color{blue}{\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell} + 1\right)} \]
                                      2. *-commutativeN/A

                                        \[\leadsto w0 \cdot \left(\color{blue}{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell} \cdot \frac{-1}{8}} + 1\right) \]
                                      3. associate-/l*N/A

                                        \[\leadsto w0 \cdot \left(\color{blue}{\left({D}^{2} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}\right)} \cdot \frac{-1}{8} + 1\right) \]
                                      4. associate-*r*N/A

                                        \[\leadsto w0 \cdot \left(\color{blue}{{D}^{2} \cdot \left(\frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell} \cdot \frac{-1}{8}\right)} + 1\right) \]
                                      5. *-commutativeN/A

                                        \[\leadsto w0 \cdot \left({D}^{2} \cdot \color{blue}{\left(\frac{-1}{8} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}\right)} + 1\right) \]
                                      6. associate-*r*N/A

                                        \[\leadsto w0 \cdot \left(\color{blue}{\left({D}^{2} \cdot \frac{-1}{8}\right) \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}} + 1\right) \]
                                      7. lower-fma.f64N/A

                                        \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left({D}^{2} \cdot \frac{-1}{8}, \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}, 1\right)} \]
                                    5. Applied rewrites37.3%

                                      \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left(\left(D \cdot D\right) \cdot -0.125, \frac{h}{d \cdot d} \cdot \frac{M \cdot M}{\ell}, 1\right)} \]
                                    6. Step-by-step derivation
                                      1. Applied rewrites44.8%

                                        \[\leadsto w0 \cdot \mathsf{fma}\left(D, \color{blue}{D \cdot \left(\left(-0.125 \cdot \frac{M \cdot M}{\ell}\right) \cdot \frac{h}{d \cdot d}\right)}, 1\right) \]
                                      2. Step-by-step derivation
                                        1. Applied rewrites50.5%

                                          \[\leadsto w0 \cdot \mathsf{fma}\left(D, D \cdot \left(\left(-0.125 \cdot \left(\frac{M}{d \cdot d} \cdot \frac{h}{\ell}\right)\right) \cdot \color{blue}{M}\right), 1\right) \]
                                        2. Step-by-step derivation
                                          1. Applied rewrites62.6%

                                            \[\leadsto w0 \cdot \mathsf{fma}\left(D, D \cdot \left(\left(-0.125 \cdot \left(\frac{M}{d} \cdot \frac{h}{\ell \cdot d}\right)\right) \cdot M\right), 1\right) \]
                                        3. Recombined 2 regimes into one program.
                                        4. Add Preprocessing

                                        Alternative 8: 78.0% accurate, 1.6× speedup?

                                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{M \cdot D}{2 \cdot d} \leq 5 \cdot 10^{-80}:\\ \;\;\;\;w0 \cdot \mathsf{fma}\left(\left(\frac{h \cdot M}{d} \cdot \frac{\frac{M}{\ell}}{d}\right) \cdot D, -0.125 \cdot D, 1\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{h \cdot \left(\left(M \cdot D\right) \cdot -0.5\right)}{\ell \cdot d} \cdot \frac{0.5}{d}, D \cdot M, 1\right)}\\ \end{array} \end{array} \]
                                        (FPCore (w0 M D h l d)
                                         :precision binary64
                                         (if (<= (/ (* M D) (* 2.0 d)) 5e-80)
                                           (* w0 (fma (* (* (/ (* h M) d) (/ (/ M l) d)) D) (* -0.125 D) 1.0))
                                           (*
                                            w0
                                            (sqrt
                                             (fma (* (/ (* h (* (* M D) -0.5)) (* l d)) (/ 0.5 d)) (* D M) 1.0)))))
                                        double code(double w0, double M, double D, double h, double l, double d) {
                                        	double tmp;
                                        	if (((M * D) / (2.0 * d)) <= 5e-80) {
                                        		tmp = w0 * fma(((((h * M) / d) * ((M / l) / d)) * D), (-0.125 * D), 1.0);
                                        	} else {
                                        		tmp = w0 * sqrt(fma((((h * ((M * D) * -0.5)) / (l * d)) * (0.5 / d)), (D * M), 1.0));
                                        	}
                                        	return tmp;
                                        }
                                        
                                        function code(w0, M, D, h, l, d)
                                        	tmp = 0.0
                                        	if (Float64(Float64(M * D) / Float64(2.0 * d)) <= 5e-80)
                                        		tmp = Float64(w0 * fma(Float64(Float64(Float64(Float64(h * M) / d) * Float64(Float64(M / l) / d)) * D), Float64(-0.125 * D), 1.0));
                                        	else
                                        		tmp = Float64(w0 * sqrt(fma(Float64(Float64(Float64(h * Float64(Float64(M * D) * -0.5)) / Float64(l * d)) * Float64(0.5 / d)), Float64(D * M), 1.0)));
                                        	end
                                        	return tmp
                                        end
                                        
                                        code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 5e-80], N[(w0 * N[(N[(N[(N[(N[(h * M), $MachinePrecision] / d), $MachinePrecision] * N[(N[(M / l), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision] * N[(-0.125 * D), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(N[(N[(N[(h * N[(N[(M * D), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision] * N[(0.5 / d), $MachinePrecision]), $MachinePrecision] * N[(D * M), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
                                        
                                        \begin{array}{l}
                                        
                                        \\
                                        \begin{array}{l}
                                        \mathbf{if}\;\frac{M \cdot D}{2 \cdot d} \leq 5 \cdot 10^{-80}:\\
                                        \;\;\;\;w0 \cdot \mathsf{fma}\left(\left(\frac{h \cdot M}{d} \cdot \frac{\frac{M}{\ell}}{d}\right) \cdot D, -0.125 \cdot D, 1\right)\\
                                        
                                        \mathbf{else}:\\
                                        \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{h \cdot \left(\left(M \cdot D\right) \cdot -0.5\right)}{\ell \cdot d} \cdot \frac{0.5}{d}, D \cdot M, 1\right)}\\
                                        
                                        
                                        \end{array}
                                        \end{array}
                                        
                                        Derivation
                                        1. Split input into 2 regimes
                                        2. if (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) < 5e-80

                                          1. Initial program 81.3%

                                            \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                                          2. Add Preprocessing
                                          3. Taylor expanded in M around 0

                                            \[\leadsto w0 \cdot \color{blue}{\left(1 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)} \]
                                          4. Step-by-step derivation
                                            1. +-commutativeN/A

                                              \[\leadsto w0 \cdot \color{blue}{\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell} + 1\right)} \]
                                            2. *-commutativeN/A

                                              \[\leadsto w0 \cdot \left(\color{blue}{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell} \cdot \frac{-1}{8}} + 1\right) \]
                                            3. associate-/l*N/A

                                              \[\leadsto w0 \cdot \left(\color{blue}{\left({D}^{2} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}\right)} \cdot \frac{-1}{8} + 1\right) \]
                                            4. associate-*r*N/A

                                              \[\leadsto w0 \cdot \left(\color{blue}{{D}^{2} \cdot \left(\frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell} \cdot \frac{-1}{8}\right)} + 1\right) \]
                                            5. *-commutativeN/A

                                              \[\leadsto w0 \cdot \left({D}^{2} \cdot \color{blue}{\left(\frac{-1}{8} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}\right)} + 1\right) \]
                                            6. associate-*r*N/A

                                              \[\leadsto w0 \cdot \left(\color{blue}{\left({D}^{2} \cdot \frac{-1}{8}\right) \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}} + 1\right) \]
                                            7. lower-fma.f64N/A

                                              \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left({D}^{2} \cdot \frac{-1}{8}, \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}, 1\right)} \]
                                          5. Applied rewrites61.5%

                                            \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left(\left(D \cdot D\right) \cdot -0.125, \frac{h}{d \cdot d} \cdot \frac{M \cdot M}{\ell}, 1\right)} \]
                                          6. Step-by-step derivation
                                            1. Applied rewrites66.1%

                                              \[\leadsto w0 \cdot \mathsf{fma}\left(\left(D \cdot D\right) \cdot -0.125, M \cdot \color{blue}{\frac{h \cdot M}{\left(d \cdot d\right) \cdot \ell}}, 1\right) \]
                                            2. Step-by-step derivation
                                              1. Applied rewrites80.2%

                                                \[\leadsto w0 \cdot \mathsf{fma}\left(\left(\frac{h \cdot M}{d} \cdot \frac{\frac{M}{\ell}}{d}\right) \cdot D, \color{blue}{-0.125 \cdot D}, 1\right) \]

                                              if 5e-80 < (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d))

                                              1. Initial program 68.7%

                                                \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                                              2. Add Preprocessing
                                              3. Step-by-step derivation
                                                1. lift--.f64N/A

                                                  \[\leadsto w0 \cdot \sqrt{\color{blue}{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
                                                2. sub-negN/A

                                                  \[\leadsto w0 \cdot \sqrt{\color{blue}{1 + \left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)}} \]
                                                3. +-commutativeN/A

                                                  \[\leadsto w0 \cdot \sqrt{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) + 1}} \]
                                                4. lift-*.f64N/A

                                                  \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\right)\right) + 1} \]
                                                5. lift-/.f64N/A

                                                  \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \color{blue}{\frac{h}{\ell}}\right)\right) + 1} \]
                                                6. associate-*r/N/A

                                                  \[\leadsto w0 \cdot \sqrt{\left(\mathsf{neg}\left(\color{blue}{\frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot h}{\ell}}\right)\right) + 1} \]
                                                7. distribute-neg-frac2N/A

                                                  \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot h}{\mathsf{neg}\left(\ell\right)}} + 1} \]
                                                8. lift-pow.f64N/A

                                                  \[\leadsto w0 \cdot \sqrt{\frac{\color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}} \cdot h}{\mathsf{neg}\left(\ell\right)} + 1} \]
                                                9. unpow2N/A

                                                  \[\leadsto w0 \cdot \sqrt{\frac{\color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)} \cdot h}{\mathsf{neg}\left(\ell\right)} + 1} \]
                                                10. associate-*l*N/A

                                                  \[\leadsto w0 \cdot \sqrt{\frac{\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \left(\frac{M \cdot D}{2 \cdot d} \cdot h\right)}}{\mathsf{neg}\left(\ell\right)} + 1} \]
                                                11. associate-/l*N/A

                                                  \[\leadsto w0 \cdot \sqrt{\color{blue}{\frac{M \cdot D}{2 \cdot d} \cdot \frac{\frac{M \cdot D}{2 \cdot d} \cdot h}{\mathsf{neg}\left(\ell\right)}} + 1} \]
                                                12. lower-fma.f64N/A

                                                  \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{M \cdot D}{2 \cdot d}, \frac{\frac{M \cdot D}{2 \cdot d} \cdot h}{\mathsf{neg}\left(\ell\right)}, 1\right)}} \]
                                              4. Applied rewrites69.0%

                                                \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\left(\frac{0.5}{d} \cdot M\right) \cdot D, \frac{\left(D \cdot 0.5\right) \cdot \left(\frac{M}{d} \cdot h\right)}{-\ell}, 1\right)}} \]
                                              5. Applied rewrites72.6%

                                                \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{\frac{-0.5 \cdot \left(D \cdot M\right)}{d} \cdot h}{\ell} \cdot \frac{0.5}{d}, D \cdot M, 1\right)}} \]
                                              6. Step-by-step derivation
                                                1. lift-/.f64N/A

                                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d} \cdot h}{\ell}} \cdot \frac{\frac{1}{2}}{d}, D \cdot M, 1\right)} \]
                                                2. lift-*.f64N/A

                                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{\frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d} \cdot h}}{\ell} \cdot \frac{\frac{1}{2}}{d}, D \cdot M, 1\right)} \]
                                                3. associate-/l*N/A

                                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\left(\frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d} \cdot \frac{h}{\ell}\right)} \cdot \frac{\frac{1}{2}}{d}, D \cdot M, 1\right)} \]
                                                4. lift-/.f64N/A

                                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\left(\color{blue}{\frac{\frac{-1}{2} \cdot \left(D \cdot M\right)}{d}} \cdot \frac{h}{\ell}\right) \cdot \frac{\frac{1}{2}}{d}, D \cdot M, 1\right)} \]
                                                5. frac-timesN/A

                                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\left(\frac{-1}{2} \cdot \left(D \cdot M\right)\right) \cdot h}{d \cdot \ell}} \cdot \frac{\frac{1}{2}}{d}, D \cdot M, 1\right)} \]
                                                6. lower-/.f64N/A

                                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{\left(\frac{-1}{2} \cdot \left(D \cdot M\right)\right) \cdot h}{d \cdot \ell}} \cdot \frac{\frac{1}{2}}{d}, D \cdot M, 1\right)} \]
                                                7. *-commutativeN/A

                                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{h \cdot \left(\frac{-1}{2} \cdot \left(D \cdot M\right)\right)}}{d \cdot \ell} \cdot \frac{\frac{1}{2}}{d}, D \cdot M, 1\right)} \]
                                                8. lower-*.f64N/A

                                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\color{blue}{h \cdot \left(\frac{-1}{2} \cdot \left(D \cdot M\right)\right)}}{d \cdot \ell} \cdot \frac{\frac{1}{2}}{d}, D \cdot M, 1\right)} \]
                                                9. lift-*.f64N/A

                                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{h \cdot \color{blue}{\left(\frac{-1}{2} \cdot \left(D \cdot M\right)\right)}}{d \cdot \ell} \cdot \frac{\frac{1}{2}}{d}, D \cdot M, 1\right)} \]
                                                10. *-commutativeN/A

                                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{h \cdot \color{blue}{\left(\left(D \cdot M\right) \cdot \frac{-1}{2}\right)}}{d \cdot \ell} \cdot \frac{\frac{1}{2}}{d}, D \cdot M, 1\right)} \]
                                                11. lower-*.f64N/A

                                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{h \cdot \color{blue}{\left(\left(D \cdot M\right) \cdot \frac{-1}{2}\right)}}{d \cdot \ell} \cdot \frac{\frac{1}{2}}{d}, D \cdot M, 1\right)} \]
                                                12. lift-*.f64N/A

                                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{h \cdot \left(\color{blue}{\left(D \cdot M\right)} \cdot \frac{-1}{2}\right)}{d \cdot \ell} \cdot \frac{\frac{1}{2}}{d}, D \cdot M, 1\right)} \]
                                                13. *-commutativeN/A

                                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{h \cdot \left(\color{blue}{\left(M \cdot D\right)} \cdot \frac{-1}{2}\right)}{d \cdot \ell} \cdot \frac{\frac{1}{2}}{d}, D \cdot M, 1\right)} \]
                                                14. lower-*.f64N/A

                                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{h \cdot \left(\color{blue}{\left(M \cdot D\right)} \cdot \frac{-1}{2}\right)}{d \cdot \ell} \cdot \frac{\frac{1}{2}}{d}, D \cdot M, 1\right)} \]
                                                15. *-commutativeN/A

                                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{h \cdot \left(\left(M \cdot D\right) \cdot \frac{-1}{2}\right)}{\color{blue}{\ell \cdot d}} \cdot \frac{\frac{1}{2}}{d}, D \cdot M, 1\right)} \]
                                                16. lower-*.f6468.8

                                                  \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\frac{h \cdot \left(\left(M \cdot D\right) \cdot -0.5\right)}{\color{blue}{\ell \cdot d}} \cdot \frac{0.5}{d}, D \cdot M, 1\right)} \]
                                              7. Applied rewrites68.8%

                                                \[\leadsto w0 \cdot \sqrt{\mathsf{fma}\left(\color{blue}{\frac{h \cdot \left(\left(M \cdot D\right) \cdot -0.5\right)}{\ell \cdot d}} \cdot \frac{0.5}{d}, D \cdot M, 1\right)} \]
                                            3. Recombined 2 regimes into one program.
                                            4. Add Preprocessing

                                            Alternative 9: 75.3% accurate, 2.4× speedup?

                                            \[\begin{array}{l} \\ w0 \cdot \mathsf{fma}\left(\left(\frac{h \cdot M}{d} \cdot \frac{\frac{M}{\ell}}{d}\right) \cdot D, -0.125 \cdot D, 1\right) \end{array} \]
                                            (FPCore (w0 M D h l d)
                                             :precision binary64
                                             (* w0 (fma (* (* (/ (* h M) d) (/ (/ M l) d)) D) (* -0.125 D) 1.0)))
                                            double code(double w0, double M, double D, double h, double l, double d) {
                                            	return w0 * fma(((((h * M) / d) * ((M / l) / d)) * D), (-0.125 * D), 1.0);
                                            }
                                            
                                            function code(w0, M, D, h, l, d)
                                            	return Float64(w0 * fma(Float64(Float64(Float64(Float64(h * M) / d) * Float64(Float64(M / l) / d)) * D), Float64(-0.125 * D), 1.0))
                                            end
                                            
                                            code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[(N[(N[(N[(N[(h * M), $MachinePrecision] / d), $MachinePrecision] * N[(N[(M / l), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision] * N[(-0.125 * D), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
                                            
                                            \begin{array}{l}
                                            
                                            \\
                                            w0 \cdot \mathsf{fma}\left(\left(\frac{h \cdot M}{d} \cdot \frac{\frac{M}{\ell}}{d}\right) \cdot D, -0.125 \cdot D, 1\right)
                                            \end{array}
                                            
                                            Derivation
                                            1. Initial program 78.7%

                                              \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                                            2. Add Preprocessing
                                            3. Taylor expanded in M around 0

                                              \[\leadsto w0 \cdot \color{blue}{\left(1 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)} \]
                                            4. Step-by-step derivation
                                              1. +-commutativeN/A

                                                \[\leadsto w0 \cdot \color{blue}{\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell} + 1\right)} \]
                                              2. *-commutativeN/A

                                                \[\leadsto w0 \cdot \left(\color{blue}{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell} \cdot \frac{-1}{8}} + 1\right) \]
                                              3. associate-/l*N/A

                                                \[\leadsto w0 \cdot \left(\color{blue}{\left({D}^{2} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}\right)} \cdot \frac{-1}{8} + 1\right) \]
                                              4. associate-*r*N/A

                                                \[\leadsto w0 \cdot \left(\color{blue}{{D}^{2} \cdot \left(\frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell} \cdot \frac{-1}{8}\right)} + 1\right) \]
                                              5. *-commutativeN/A

                                                \[\leadsto w0 \cdot \left({D}^{2} \cdot \color{blue}{\left(\frac{-1}{8} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}\right)} + 1\right) \]
                                              6. associate-*r*N/A

                                                \[\leadsto w0 \cdot \left(\color{blue}{\left({D}^{2} \cdot \frac{-1}{8}\right) \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}} + 1\right) \]
                                              7. lower-fma.f64N/A

                                                \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left({D}^{2} \cdot \frac{-1}{8}, \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}, 1\right)} \]
                                            5. Applied rewrites56.3%

                                              \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left(\left(D \cdot D\right) \cdot -0.125, \frac{h}{d \cdot d} \cdot \frac{M \cdot M}{\ell}, 1\right)} \]
                                            6. Step-by-step derivation
                                              1. Applied rewrites62.0%

                                                \[\leadsto w0 \cdot \mathsf{fma}\left(\left(D \cdot D\right) \cdot -0.125, M \cdot \color{blue}{\frac{h \cdot M}{\left(d \cdot d\right) \cdot \ell}}, 1\right) \]
                                              2. Step-by-step derivation
                                                1. Applied rewrites75.4%

                                                  \[\leadsto w0 \cdot \mathsf{fma}\left(\left(\frac{h \cdot M}{d} \cdot \frac{\frac{M}{\ell}}{d}\right) \cdot D, \color{blue}{-0.125 \cdot D}, 1\right) \]
                                                2. Add Preprocessing

                                                Alternative 10: 70.8% accurate, 2.5× speedup?

                                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;M \cdot D \leq 10^{-36}:\\ \;\;\;\;w0 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \mathsf{fma}\left(D, D \cdot \left(h \cdot \frac{-0.125 \cdot \left(M \cdot M\right)}{\left(d \cdot d\right) \cdot \ell}\right), 1\right)\\ \end{array} \end{array} \]
                                                (FPCore (w0 M D h l d)
                                                 :precision binary64
                                                 (if (<= (* M D) 1e-36)
                                                   (* w0 1.0)
                                                   (* w0 (fma D (* D (* h (/ (* -0.125 (* M M)) (* (* d d) l)))) 1.0))))
                                                double code(double w0, double M, double D, double h, double l, double d) {
                                                	double tmp;
                                                	if ((M * D) <= 1e-36) {
                                                		tmp = w0 * 1.0;
                                                	} else {
                                                		tmp = w0 * fma(D, (D * (h * ((-0.125 * (M * M)) / ((d * d) * l)))), 1.0);
                                                	}
                                                	return tmp;
                                                }
                                                
                                                function code(w0, M, D, h, l, d)
                                                	tmp = 0.0
                                                	if (Float64(M * D) <= 1e-36)
                                                		tmp = Float64(w0 * 1.0);
                                                	else
                                                		tmp = Float64(w0 * fma(D, Float64(D * Float64(h * Float64(Float64(-0.125 * Float64(M * M)) / Float64(Float64(d * d) * l)))), 1.0));
                                                	end
                                                	return tmp
                                                end
                                                
                                                code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(M * D), $MachinePrecision], 1e-36], N[(w0 * 1.0), $MachinePrecision], N[(w0 * N[(D * N[(D * N[(h * N[(N[(-0.125 * N[(M * M), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
                                                
                                                \begin{array}{l}
                                                
                                                \\
                                                \begin{array}{l}
                                                \mathbf{if}\;M \cdot D \leq 10^{-36}:\\
                                                \;\;\;\;w0 \cdot 1\\
                                                
                                                \mathbf{else}:\\
                                                \;\;\;\;w0 \cdot \mathsf{fma}\left(D, D \cdot \left(h \cdot \frac{-0.125 \cdot \left(M \cdot M\right)}{\left(d \cdot d\right) \cdot \ell}\right), 1\right)\\
                                                
                                                
                                                \end{array}
                                                \end{array}
                                                
                                                Derivation
                                                1. Split input into 2 regimes
                                                2. if (*.f64 M D) < 9.9999999999999994e-37

                                                  1. Initial program 82.4%

                                                    \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                                                  2. Add Preprocessing
                                                  3. Taylor expanded in M around 0

                                                    \[\leadsto w0 \cdot \color{blue}{1} \]
                                                  4. Step-by-step derivation
                                                    1. Applied rewrites78.6%

                                                      \[\leadsto w0 \cdot \color{blue}{1} \]

                                                    if 9.9999999999999994e-37 < (*.f64 M D)

                                                    1. Initial program 61.3%

                                                      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                                                    2. Add Preprocessing
                                                    3. Taylor expanded in M around 0

                                                      \[\leadsto w0 \cdot \color{blue}{\left(1 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}\right)} \]
                                                    4. Step-by-step derivation
                                                      1. +-commutativeN/A

                                                        \[\leadsto w0 \cdot \color{blue}{\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell} + 1\right)} \]
                                                      2. *-commutativeN/A

                                                        \[\leadsto w0 \cdot \left(\color{blue}{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell} \cdot \frac{-1}{8}} + 1\right) \]
                                                      3. associate-/l*N/A

                                                        \[\leadsto w0 \cdot \left(\color{blue}{\left({D}^{2} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}\right)} \cdot \frac{-1}{8} + 1\right) \]
                                                      4. associate-*r*N/A

                                                        \[\leadsto w0 \cdot \left(\color{blue}{{D}^{2} \cdot \left(\frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell} \cdot \frac{-1}{8}\right)} + 1\right) \]
                                                      5. *-commutativeN/A

                                                        \[\leadsto w0 \cdot \left({D}^{2} \cdot \color{blue}{\left(\frac{-1}{8} \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}\right)} + 1\right) \]
                                                      6. associate-*r*N/A

                                                        \[\leadsto w0 \cdot \left(\color{blue}{\left({D}^{2} \cdot \frac{-1}{8}\right) \cdot \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}} + 1\right) \]
                                                      7. lower-fma.f64N/A

                                                        \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left({D}^{2} \cdot \frac{-1}{8}, \frac{{M}^{2} \cdot h}{{d}^{2} \cdot \ell}, 1\right)} \]
                                                    5. Applied rewrites43.0%

                                                      \[\leadsto w0 \cdot \color{blue}{\mathsf{fma}\left(\left(D \cdot D\right) \cdot -0.125, \frac{h}{d \cdot d} \cdot \frac{M \cdot M}{\ell}, 1\right)} \]
                                                    6. Step-by-step derivation
                                                      1. Applied rewrites48.0%

                                                        \[\leadsto w0 \cdot \mathsf{fma}\left(D, \color{blue}{D \cdot \left(\left(-0.125 \cdot \frac{M \cdot M}{\ell}\right) \cdot \frac{h}{d \cdot d}\right)}, 1\right) \]
                                                      2. Step-by-step derivation
                                                        1. Applied rewrites45.6%

                                                          \[\leadsto w0 \cdot \mathsf{fma}\left(D, D \cdot \frac{\left(\left(M \cdot M\right) \cdot -0.125\right) \cdot h}{\color{blue}{\left(d \cdot d\right) \cdot \ell}}, 1\right) \]
                                                        2. Step-by-step derivation
                                                          1. Applied rewrites52.5%

                                                            \[\leadsto w0 \cdot \mathsf{fma}\left(D, D \cdot \left(h \cdot \color{blue}{\frac{-0.125 \cdot \left(M \cdot M\right)}{\left(d \cdot d\right) \cdot \ell}}\right), 1\right) \]
                                                        3. Recombined 2 regimes into one program.
                                                        4. Add Preprocessing

                                                        Alternative 11: 68.4% accurate, 26.2× speedup?

                                                        \[\begin{array}{l} \\ w0 \cdot 1 \end{array} \]
                                                        (FPCore (w0 M D h l d) :precision binary64 (* w0 1.0))
                                                        double code(double w0, double M, double D, double h, double l, double d) {
                                                        	return w0 * 1.0;
                                                        }
                                                        
                                                        real(8) function code(w0, m, d, h, l, d_1)
                                                            real(8), intent (in) :: w0
                                                            real(8), intent (in) :: m
                                                            real(8), intent (in) :: d
                                                            real(8), intent (in) :: h
                                                            real(8), intent (in) :: l
                                                            real(8), intent (in) :: d_1
                                                            code = w0 * 1.0d0
                                                        end function
                                                        
                                                        public static double code(double w0, double M, double D, double h, double l, double d) {
                                                        	return w0 * 1.0;
                                                        }
                                                        
                                                        def code(w0, M, D, h, l, d):
                                                        	return w0 * 1.0
                                                        
                                                        function code(w0, M, D, h, l, d)
                                                        	return Float64(w0 * 1.0)
                                                        end
                                                        
                                                        function tmp = code(w0, M, D, h, l, d)
                                                        	tmp = w0 * 1.0;
                                                        end
                                                        
                                                        code[w0_, M_, D_, h_, l_, d_] := N[(w0 * 1.0), $MachinePrecision]
                                                        
                                                        \begin{array}{l}
                                                        
                                                        \\
                                                        w0 \cdot 1
                                                        \end{array}
                                                        
                                                        Derivation
                                                        1. Initial program 78.7%

                                                          \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                                                        2. Add Preprocessing
                                                        3. Taylor expanded in M around 0

                                                          \[\leadsto w0 \cdot \color{blue}{1} \]
                                                        4. Step-by-step derivation
                                                          1. Applied rewrites69.7%

                                                            \[\leadsto w0 \cdot \color{blue}{1} \]
                                                          2. Add Preprocessing

                                                          Reproduce

                                                          ?
                                                          herbie shell --seed 2024321 
                                                          (FPCore (w0 M D h l d)
                                                            :name "Henrywood and Agarwal, Equation (9a)"
                                                            :precision binary64
                                                            (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))