Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 80.7% → 88.8%
Time: 13.3s
Alternatives: 13
Speedup: 1.6×

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 13 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: 80.7% 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: 88.8% accurate, 0.7× speedup?

\[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} t_0 := \frac{M \cdot D}{d \cdot 2}\\ \mathbf{if}\;1 - {t\_0}^{2} \cdot \frac{h}{\ell} \leq 5 \cdot 10^{+293}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(t\_0, \frac{\frac{M \cdot D}{d \cdot -2}}{\frac{\ell}{h}}, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{M}{d} \cdot \left(D \cdot -0.5\right)}{\ell}, \left(M \cdot 0.5\right) \cdot \left(h \cdot \frac{D}{d}\right), 1\right)}\\ \end{array} \end{array} \]
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (/ (* M D) (* d 2.0))))
   (if (<= (- 1.0 (* (pow t_0 2.0) (/ h l))) 5e+293)
     (* w0 (sqrt (fma t_0 (/ (/ (* M D) (* d -2.0)) (/ l h)) 1.0)))
     (*
      w0
      (sqrt
       (fma (/ (* (/ M d) (* D -0.5)) l) (* (* M 0.5) (* h (/ D d))) 1.0))))))
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = (M * D) / (d * 2.0);
	double tmp;
	if ((1.0 - (pow(t_0, 2.0) * (h / l))) <= 5e+293) {
		tmp = w0 * sqrt(fma(t_0, (((M * D) / (d * -2.0)) / (l / h)), 1.0));
	} else {
		tmp = w0 * sqrt(fma((((M / d) * (D * -0.5)) / l), ((M * 0.5) * (h * (D / d))), 1.0));
	}
	return tmp;
}
w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
function code(w0, M, D, h, l, d)
	t_0 = Float64(Float64(M * D) / Float64(d * 2.0))
	tmp = 0.0
	if (Float64(1.0 - Float64((t_0 ^ 2.0) * Float64(h / l))) <= 5e+293)
		tmp = Float64(w0 * sqrt(fma(t_0, Float64(Float64(Float64(M * D) / Float64(d * -2.0)) / Float64(l / h)), 1.0)));
	else
		tmp = Float64(w0 * sqrt(fma(Float64(Float64(Float64(M / d) * Float64(D * -0.5)) / l), Float64(Float64(M * 0.5) * Float64(h * Float64(D / d))), 1.0)));
	end
	return tmp
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 - N[(N[Power[t$95$0, 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+293], N[(w0 * N[Sqrt[N[(t$95$0 * N[(N[(N[(M * D), $MachinePrecision] / N[(d * -2.0), $MachinePrecision]), $MachinePrecision] / N[(l / h), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(N[(N[(N[(M / d), $MachinePrecision] * N[(D * -0.5), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(N[(M * 0.5), $MachinePrecision] * N[(h * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
\begin{array}{l}
t_0 := \frac{M \cdot D}{d \cdot 2}\\
\mathbf{if}\;1 - {t\_0}^{2} \cdot \frac{h}{\ell} \leq 5 \cdot 10^{+293}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(t\_0, \frac{\frac{M \cdot D}{d \cdot -2}}{\frac{\ell}{h}}, 1\right)}\\

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


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

    1. Initial program 99.9%

      \[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{1 - {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
      2. lift-*.f64N/A

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
      7. 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)}} \]
      8. +-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}} \]
      9. 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} \]
      10. distribute-lft-neg-inN/A

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

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

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

    1. Initial program 43.8%

      \[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{1 - {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
      2. lift-*.f64N/A

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
      7. 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)}} \]
      8. +-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. Applied rewrites70.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;1 - {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq 5 \cdot 10^{+293}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{M \cdot D}{d \cdot 2}, \frac{\frac{M \cdot D}{d \cdot -2}}{\frac{\ell}{h}}, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{M}{d} \cdot \left(D \cdot -0.5\right)}{\ell}, \left(M \cdot 0.5\right) \cdot \left(h \cdot \frac{D}{d}\right), 1\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 88.8% accurate, 0.7× speedup?

\[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} t_0 := \frac{M \cdot D}{d \cdot 2}\\ \mathbf{if}\;1 - {t\_0}^{2} \cdot \frac{h}{\ell} \leq 5 \cdot 10^{+293}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(t\_0, \frac{M \cdot D}{d \cdot -2} \cdot \frac{h}{\ell}, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{M}{d} \cdot \left(D \cdot -0.5\right)}{\ell}, \left(M \cdot 0.5\right) \cdot \left(h \cdot \frac{D}{d}\right), 1\right)}\\ \end{array} \end{array} \]
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (/ (* M D) (* d 2.0))))
   (if (<= (- 1.0 (* (pow t_0 2.0) (/ h l))) 5e+293)
     (* w0 (sqrt (fma t_0 (* (/ (* M D) (* d -2.0)) (/ h l)) 1.0)))
     (*
      w0
      (sqrt
       (fma (/ (* (/ M d) (* D -0.5)) l) (* (* M 0.5) (* h (/ D d))) 1.0))))))
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = (M * D) / (d * 2.0);
	double tmp;
	if ((1.0 - (pow(t_0, 2.0) * (h / l))) <= 5e+293) {
		tmp = w0 * sqrt(fma(t_0, (((M * D) / (d * -2.0)) * (h / l)), 1.0));
	} else {
		tmp = w0 * sqrt(fma((((M / d) * (D * -0.5)) / l), ((M * 0.5) * (h * (D / d))), 1.0));
	}
	return tmp;
}
w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
function code(w0, M, D, h, l, d)
	t_0 = Float64(Float64(M * D) / Float64(d * 2.0))
	tmp = 0.0
	if (Float64(1.0 - Float64((t_0 ^ 2.0) * Float64(h / l))) <= 5e+293)
		tmp = Float64(w0 * sqrt(fma(t_0, Float64(Float64(Float64(M * D) / Float64(d * -2.0)) * Float64(h / l)), 1.0)));
	else
		tmp = Float64(w0 * sqrt(fma(Float64(Float64(Float64(M / d) * Float64(D * -0.5)) / l), Float64(Float64(M * 0.5) * Float64(h * Float64(D / d))), 1.0)));
	end
	return tmp
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 - N[(N[Power[t$95$0, 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+293], N[(w0 * N[Sqrt[N[(t$95$0 * N[(N[(N[(M * D), $MachinePrecision] / N[(d * -2.0), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(N[(N[(N[(M / d), $MachinePrecision] * N[(D * -0.5), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(N[(M * 0.5), $MachinePrecision] * N[(h * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
\begin{array}{l}
t_0 := \frac{M \cdot D}{d \cdot 2}\\
\mathbf{if}\;1 - {t\_0}^{2} \cdot \frac{h}{\ell} \leq 5 \cdot 10^{+293}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(t\_0, \frac{M \cdot D}{d \cdot -2} \cdot \frac{h}{\ell}, 1\right)}\\

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


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

    1. Initial program 99.9%

      \[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{1 - {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
      2. lift-*.f64N/A

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
      7. 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)}} \]
      8. +-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}} \]
      9. 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} \]
      10. distribute-lft-neg-inN/A

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

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

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

    1. Initial program 43.8%

      \[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{1 - {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
      2. lift-*.f64N/A

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
      7. 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)}} \]
      8. +-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. Applied rewrites70.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;1 - {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq 5 \cdot 10^{+293}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{M \cdot D}{d \cdot 2}, \frac{M \cdot D}{d \cdot -2} \cdot \frac{h}{\ell}, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{M}{d} \cdot \left(D \cdot -0.5\right)}{\ell}, \left(M \cdot 0.5\right) \cdot \left(h \cdot \frac{D}{d}\right), 1\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 88.0% accurate, 0.7× speedup?

\[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} t_0 := \frac{M \cdot D}{d \cdot 2}\\ \mathbf{if}\;1 - {t\_0}^{2} \cdot \frac{h}{\ell} \leq \infty:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(t\_0, \frac{M \cdot D}{d \cdot -2} \cdot \frac{h}{\ell}, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{M \cdot D}{\left(d \cdot -2\right) \cdot \ell}, h \cdot \frac{\left(M \cdot D\right) \cdot 0.5}{d}, 1\right)}\\ \end{array} \end{array} \]
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (/ (* M D) (* d 2.0))))
   (if (<= (- 1.0 (* (pow t_0 2.0) (/ h l))) INFINITY)
     (* w0 (sqrt (fma t_0 (* (/ (* M D) (* d -2.0)) (/ h l)) 1.0)))
     (*
      w0
      (sqrt
       (fma (/ (* M D) (* (* d -2.0) l)) (* h (/ (* (* M D) 0.5) d)) 1.0))))))
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = (M * D) / (d * 2.0);
	double tmp;
	if ((1.0 - (pow(t_0, 2.0) * (h / l))) <= ((double) INFINITY)) {
		tmp = w0 * sqrt(fma(t_0, (((M * D) / (d * -2.0)) * (h / l)), 1.0));
	} else {
		tmp = w0 * sqrt(fma(((M * D) / ((d * -2.0) * l)), (h * (((M * D) * 0.5) / d)), 1.0));
	}
	return tmp;
}
w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
function code(w0, M, D, h, l, d)
	t_0 = Float64(Float64(M * D) / Float64(d * 2.0))
	tmp = 0.0
	if (Float64(1.0 - Float64((t_0 ^ 2.0) * Float64(h / l))) <= Inf)
		tmp = Float64(w0 * sqrt(fma(t_0, Float64(Float64(Float64(M * D) / Float64(d * -2.0)) * Float64(h / l)), 1.0)));
	else
		tmp = Float64(w0 * sqrt(fma(Float64(Float64(M * D) / Float64(Float64(d * -2.0) * l)), Float64(h * Float64(Float64(Float64(M * D) * 0.5) / d)), 1.0)));
	end
	return tmp
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 - N[(N[Power[t$95$0, 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(w0 * N[Sqrt[N[(t$95$0 * N[(N[(N[(M * D), $MachinePrecision] / N[(d * -2.0), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(N[(N[(M * D), $MachinePrecision] / N[(N[(d * -2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[(h * N[(N[(N[(M * D), $MachinePrecision] * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
\begin{array}{l}
t_0 := \frac{M \cdot D}{d \cdot 2}\\
\mathbf{if}\;1 - {t\_0}^{2} \cdot \frac{h}{\ell} \leq \infty:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(t\_0, \frac{M \cdot D}{d \cdot -2} \cdot \frac{h}{\ell}, 1\right)}\\

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


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

    1. Initial program 90.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{1 - {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
      2. lift-*.f64N/A

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
      7. 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)}} \]
      8. +-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}} \]
      9. 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} \]
      10. distribute-lft-neg-inN/A

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

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

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

    1. Initial program 0.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{1 - {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
      2. lift-*.f64N/A

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
      7. 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)}} \]
      8. +-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. Applied rewrites76.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;1 - {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq \infty:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{M \cdot D}{d \cdot 2}, \frac{M \cdot D}{d \cdot -2} \cdot \frac{h}{\ell}, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{M \cdot D}{\left(d \cdot -2\right) \cdot \ell}, h \cdot \frac{\left(M \cdot D\right) \cdot 0.5}{d}, 1\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 86.9% accurate, 0.7× speedup?

\[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;1 - {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq 1.0002:\\ \;\;\;\;w0 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{M \cdot D}{\left(d \cdot -2\right) \cdot \ell}, h \cdot \frac{\left(M \cdot D\right) \cdot 0.5}{d}, 1\right)}\\ \end{array} \end{array} \]
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
 :precision binary64
 (if (<= (- 1.0 (* (pow (/ (* M D) (* d 2.0)) 2.0) (/ h l))) 1.0002)
   (* w0 1.0)
   (*
    w0
    (sqrt
     (fma (/ (* M D) (* (* d -2.0) l)) (* h (/ (* (* M D) 0.5) d)) 1.0)))))
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
	double tmp;
	if ((1.0 - (pow(((M * D) / (d * 2.0)), 2.0) * (h / l))) <= 1.0002) {
		tmp = w0 * 1.0;
	} else {
		tmp = w0 * sqrt(fma(((M * D) / ((d * -2.0) * l)), (h * (((M * D) * 0.5) / d)), 1.0));
	}
	return tmp;
}
w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
function code(w0, M, D, h, l, d)
	tmp = 0.0
	if (Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0) * Float64(h / l))) <= 1.0002)
		tmp = Float64(w0 * 1.0);
	else
		tmp = Float64(w0 * sqrt(fma(Float64(Float64(M * D) / Float64(Float64(d * -2.0) * l)), Float64(h * Float64(Float64(Float64(M * D) * 0.5) / d)), 1.0)));
	end
	return tmp
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0002], N[(w0 * 1.0), $MachinePrecision], N[(w0 * N[Sqrt[N[(N[(N[(M * D), $MachinePrecision] / N[(N[(d * -2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[(h * N[(N[(N[(M * D), $MachinePrecision] * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;1 - {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq 1.0002:\\
\;\;\;\;w0 \cdot 1\\

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


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

    1. Initial program 100.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}{1} \]
    4. Step-by-step derivation
      1. Applied rewrites99.8%

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

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

      1. Initial program 56.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{1 - {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
        2. lift-*.f64N/A

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

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

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

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

          \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
        7. 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)}} \]
        8. +-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. Applied rewrites75.9%

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

        \[\leadsto w0 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(\frac{M \cdot D}{\ell \cdot \left(d \cdot -2\right)}, \frac{\left(M \cdot D\right) \cdot 0.5}{d} \cdot h, 1\right)}} \]
    5. Recombined 2 regimes into one program.
    6. Final simplification89.2%

      \[\leadsto \begin{array}{l} \mathbf{if}\;1 - {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq 1.0002:\\ \;\;\;\;w0 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{M \cdot D}{\left(d \cdot -2\right) \cdot \ell}, h \cdot \frac{\left(M \cdot D\right) \cdot 0.5}{d}, 1\right)}\\ \end{array} \]
    7. Add Preprocessing

    Alternative 5: 83.1% accurate, 0.7× speedup?

    \[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -1 \cdot 10^{-11}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(\left(M \cdot D\right) \cdot \frac{M \cdot D}{\left(d \cdot d\right) \cdot 4}\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \end{array} \]
    NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
    (FPCore (w0 M D h l d)
     :precision binary64
     (if (<= (* (pow (/ (* M D) (* d 2.0)) 2.0) (/ h l)) -1e-11)
       (* w0 (sqrt (- 1.0 (* (/ h l) (* (* M D) (/ (* M D) (* (* d d) 4.0)))))))
       (* w0 1.0)))
    assert(w0 < M && M < D && D < h && h < l && l < d);
    double code(double w0, double M, double D, double h, double l, double d) {
    	double tmp;
    	if ((pow(((M * D) / (d * 2.0)), 2.0) * (h / l)) <= -1e-11) {
    		tmp = w0 * sqrt((1.0 - ((h / l) * ((M * D) * ((M * D) / ((d * d) * 4.0))))));
    	} else {
    		tmp = w0 * 1.0;
    	}
    	return tmp;
    }
    
    NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
    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
        real(8) :: tmp
        if (((((m * d) / (d_1 * 2.0d0)) ** 2.0d0) * (h / l)) <= (-1d-11)) then
            tmp = w0 * sqrt((1.0d0 - ((h / l) * ((m * d) * ((m * d) / ((d_1 * d_1) * 4.0d0))))))
        else
            tmp = w0 * 1.0d0
        end if
        code = tmp
    end function
    
    assert w0 < M && M < D && D < h && h < l && l < d;
    public static double code(double w0, double M, double D, double h, double l, double d) {
    	double tmp;
    	if ((Math.pow(((M * D) / (d * 2.0)), 2.0) * (h / l)) <= -1e-11) {
    		tmp = w0 * Math.sqrt((1.0 - ((h / l) * ((M * D) * ((M * D) / ((d * d) * 4.0))))));
    	} else {
    		tmp = w0 * 1.0;
    	}
    	return tmp;
    }
    
    [w0, M, D, h, l, d] = sort([w0, M, D, h, l, d])
    def code(w0, M, D, h, l, d):
    	tmp = 0
    	if (math.pow(((M * D) / (d * 2.0)), 2.0) * (h / l)) <= -1e-11:
    		tmp = w0 * math.sqrt((1.0 - ((h / l) * ((M * D) * ((M * D) / ((d * d) * 4.0))))))
    	else:
    		tmp = w0 * 1.0
    	return tmp
    
    w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
    function code(w0, M, D, h, l, d)
    	tmp = 0.0
    	if (Float64((Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0) * Float64(h / l)) <= -1e-11)
    		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * Float64(Float64(M * D) * Float64(Float64(M * D) / Float64(Float64(d * d) * 4.0)))))));
    	else
    		tmp = Float64(w0 * 1.0);
    	end
    	return tmp
    end
    
    w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
    function tmp_2 = code(w0, M, D, h, l, d)
    	tmp = 0.0;
    	if (((((M * D) / (d * 2.0)) ^ 2.0) * (h / l)) <= -1e-11)
    		tmp = w0 * sqrt((1.0 - ((h / l) * ((M * D) * ((M * D) / ((d * d) * 4.0))))));
    	else
    		tmp = w0 * 1.0;
    	end
    	tmp_2 = tmp;
    end
    
    NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
    code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -1e-11], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(N[(M * D), $MachinePrecision] * N[(N[(M * D), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
    
    \begin{array}{l}
    [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
    \\
    \begin{array}{l}
    \mathbf{if}\;{\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -1 \cdot 10^{-11}:\\
    \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(\left(M \cdot D\right) \cdot \frac{M \cdot D}{\left(d \cdot d\right) \cdot 4}\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)) < -9.99999999999999939e-12

      1. Initial program 72.3%

        \[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{1 - {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
        2. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto w0 \cdot \sqrt{1 - \left(\left(M \cdot D\right) \cdot \frac{M \cdot D}{\left(d \cdot d\right) \cdot \color{blue}{4}}\right) \cdot \frac{h}{\ell}} \]
        17. metadata-evalN/A

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

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

          \[\leadsto w0 \cdot \sqrt{1 - \left(\left(M \cdot D\right) \cdot \frac{M \cdot D}{\color{blue}{\left(d \cdot d\right)} \cdot \left(2 + 2\right)}\right) \cdot \frac{h}{\ell}} \]
        20. metadata-eval61.8

          \[\leadsto w0 \cdot \sqrt{1 - \left(\left(M \cdot D\right) \cdot \frac{M \cdot D}{\left(d \cdot d\right) \cdot \color{blue}{4}}\right) \cdot \frac{h}{\ell}} \]
      4. Applied rewrites61.8%

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

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

      1. Initial program 88.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}{1} \]
      4. Step-by-step derivation
        1. Applied rewrites96.5%

          \[\leadsto w0 \cdot \color{blue}{1} \]
      5. Recombined 2 regimes into one program.
      6. Final simplification85.8%

        \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -1 \cdot 10^{-11}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(\left(M \cdot D\right) \cdot \frac{M \cdot D}{\left(d \cdot d\right) \cdot 4}\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \]
      7. Add Preprocessing

      Alternative 6: 83.0% accurate, 0.7× speedup?

      \[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+15}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \left(M \cdot D\right) \cdot \left(\left(M \cdot D\right) \cdot \left(h \cdot \frac{-1}{\left(d \cdot \ell\right) \cdot \left(d \cdot 4\right)}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \end{array} \]
      NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
      (FPCore (w0 M D h l d)
       :precision binary64
       (if (<= (* (pow (/ (* M D) (* d 2.0)) 2.0) (/ h l)) -2e+15)
         (*
          w0
          (sqrt
           (+ 1.0 (* (* M D) (* (* M D) (* h (/ -1.0 (* (* d l) (* d 4.0)))))))))
         (* w0 1.0)))
      assert(w0 < M && M < D && D < h && h < l && l < d);
      double code(double w0, double M, double D, double h, double l, double d) {
      	double tmp;
      	if ((pow(((M * D) / (d * 2.0)), 2.0) * (h / l)) <= -2e+15) {
      		tmp = w0 * sqrt((1.0 + ((M * D) * ((M * D) * (h * (-1.0 / ((d * l) * (d * 4.0))))))));
      	} else {
      		tmp = w0 * 1.0;
      	}
      	return tmp;
      }
      
      NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
      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
          real(8) :: tmp
          if (((((m * d) / (d_1 * 2.0d0)) ** 2.0d0) * (h / l)) <= (-2d+15)) then
              tmp = w0 * sqrt((1.0d0 + ((m * d) * ((m * d) * (h * ((-1.0d0) / ((d_1 * l) * (d_1 * 4.0d0))))))))
          else
              tmp = w0 * 1.0d0
          end if
          code = tmp
      end function
      
      assert w0 < M && M < D && D < h && h < l && l < d;
      public static double code(double w0, double M, double D, double h, double l, double d) {
      	double tmp;
      	if ((Math.pow(((M * D) / (d * 2.0)), 2.0) * (h / l)) <= -2e+15) {
      		tmp = w0 * Math.sqrt((1.0 + ((M * D) * ((M * D) * (h * (-1.0 / ((d * l) * (d * 4.0))))))));
      	} else {
      		tmp = w0 * 1.0;
      	}
      	return tmp;
      }
      
      [w0, M, D, h, l, d] = sort([w0, M, D, h, l, d])
      def code(w0, M, D, h, l, d):
      	tmp = 0
      	if (math.pow(((M * D) / (d * 2.0)), 2.0) * (h / l)) <= -2e+15:
      		tmp = w0 * math.sqrt((1.0 + ((M * D) * ((M * D) * (h * (-1.0 / ((d * l) * (d * 4.0))))))))
      	else:
      		tmp = w0 * 1.0
      	return tmp
      
      w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
      function code(w0, M, D, h, l, d)
      	tmp = 0.0
      	if (Float64((Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0) * Float64(h / l)) <= -2e+15)
      		tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(M * D) * Float64(Float64(M * D) * Float64(h * Float64(-1.0 / Float64(Float64(d * l) * Float64(d * 4.0)))))))));
      	else
      		tmp = Float64(w0 * 1.0);
      	end
      	return tmp
      end
      
      w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
      function tmp_2 = code(w0, M, D, h, l, d)
      	tmp = 0.0;
      	if (((((M * D) / (d * 2.0)) ^ 2.0) * (h / l)) <= -2e+15)
      		tmp = w0 * sqrt((1.0 + ((M * D) * ((M * D) * (h * (-1.0 / ((d * l) * (d * 4.0))))))));
      	else
      		tmp = w0 * 1.0;
      	end
      	tmp_2 = tmp;
      end
      
      NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
      code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -2e+15], N[(w0 * N[Sqrt[N[(1.0 + N[(N[(M * D), $MachinePrecision] * N[(N[(M * D), $MachinePrecision] * N[(h * N[(-1.0 / N[(N[(d * l), $MachinePrecision] * N[(d * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
      
      \begin{array}{l}
      [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
      \\
      \begin{array}{l}
      \mathbf{if}\;{\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+15}:\\
      \;\;\;\;w0 \cdot \sqrt{1 + \left(M \cdot D\right) \cdot \left(\left(M \cdot D\right) \cdot \left(h \cdot \frac{-1}{\left(d \cdot \ell\right) \cdot \left(d \cdot 4\right)}\right)\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)) < -2e15

        1. Initial program 70.9%

          \[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{1 - {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
          2. lift-*.f64N/A

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot w0} \]
          10. lower-*.f6470.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \sqrt{1 - \left(M \cdot D\right) \cdot \left(\left(M \cdot D\right) \cdot \frac{1}{\color{blue}{\frac{\ell \cdot \left(\left(d \cdot d\right) \cdot 4\right)}{h}}}\right)} \cdot w0 \]
        6. Applied rewrites61.9%

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

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

        1. Initial program 88.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 rewrites95.2%

            \[\leadsto w0 \cdot \color{blue}{1} \]
        5. Recombined 2 regimes into one program.
        6. Final simplification85.4%

          \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+15}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \left(M \cdot D\right) \cdot \left(\left(M \cdot D\right) \cdot \left(h \cdot \frac{-1}{\left(d \cdot \ell\right) \cdot \left(d \cdot 4\right)}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \]
        7. Add Preprocessing

        Alternative 7: 82.1% accurate, 0.8× speedup?

        \[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+15}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\left(M \cdot D\right) \cdot \left(-M \cdot D\right), \frac{h}{d \cdot \left(4 \cdot \left(d \cdot \ell\right)\right)}, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \end{array} \]
        NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
        (FPCore (w0 M D h l d)
         :precision binary64
         (if (<= (* (pow (/ (* M D) (* d 2.0)) 2.0) (/ h l)) -2e+15)
           (* w0 (sqrt (fma (* (* M D) (- (* M D))) (/ h (* d (* 4.0 (* d l)))) 1.0)))
           (* w0 1.0)))
        assert(w0 < M && M < D && D < h && h < l && l < d);
        double code(double w0, double M, double D, double h, double l, double d) {
        	double tmp;
        	if ((pow(((M * D) / (d * 2.0)), 2.0) * (h / l)) <= -2e+15) {
        		tmp = w0 * sqrt(fma(((M * D) * -(M * D)), (h / (d * (4.0 * (d * l)))), 1.0));
        	} else {
        		tmp = w0 * 1.0;
        	}
        	return tmp;
        }
        
        w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
        function code(w0, M, D, h, l, d)
        	tmp = 0.0
        	if (Float64((Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0) * Float64(h / l)) <= -2e+15)
        		tmp = Float64(w0 * sqrt(fma(Float64(Float64(M * D) * Float64(-Float64(M * D))), Float64(h / Float64(d * Float64(4.0 * Float64(d * l)))), 1.0)));
        	else
        		tmp = Float64(w0 * 1.0);
        	end
        	return tmp
        end
        
        NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
        code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -2e+15], N[(w0 * N[Sqrt[N[(N[(N[(M * D), $MachinePrecision] * (-N[(M * D), $MachinePrecision])), $MachinePrecision] * N[(h / N[(d * N[(4.0 * N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
        
        \begin{array}{l}
        [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
        \\
        \begin{array}{l}
        \mathbf{if}\;{\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+15}:\\
        \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\left(M \cdot D\right) \cdot \left(-M \cdot D\right), \frac{h}{d \cdot \left(4 \cdot \left(d \cdot \ell\right)\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)) < -2e15

          1. Initial program 70.9%

            \[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{1 - {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
            2. lift-*.f64N/A

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot w0} \]
            10. lower-*.f6470.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \sqrt{1 - \left(M \cdot D\right) \cdot \left(\left(M \cdot D\right) \cdot \frac{1}{\color{blue}{\frac{\ell \cdot \left(\left(d \cdot d\right) \cdot 4\right)}{h}}}\right)} \cdot w0 \]
          6. Applied rewrites61.9%

            \[\leadsto \sqrt{1 - \color{blue}{\left(M \cdot D\right) \cdot \left(\left(M \cdot D\right) \cdot \left(\frac{1}{\left(d \cdot \ell\right) \cdot \left(d \cdot 4\right)} \cdot h\right)\right)}} \cdot w0 \]
          7. Applied rewrites59.9%

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

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

          1. Initial program 88.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 rewrites95.2%

              \[\leadsto w0 \cdot \color{blue}{1} \]
          5. Recombined 2 regimes into one program.
          6. Final simplification84.9%

            \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+15}:\\ \;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\left(M \cdot D\right) \cdot \left(-M \cdot D\right), \frac{h}{d \cdot \left(4 \cdot \left(d \cdot \ell\right)\right)}, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \]
          7. Add Preprocessing

          Alternative 8: 82.0% accurate, 0.8× speedup?

          \[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -500000000:\\ \;\;\;\;w0 \cdot \sqrt{1 - h \cdot \frac{M \cdot \left(D \cdot \left(M \cdot D\right)\right)}{\left(d \cdot \ell\right) \cdot \left(d \cdot 4\right)}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \end{array} \]
          NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
          (FPCore (w0 M D h l d)
           :precision binary64
           (if (<= (* (pow (/ (* M D) (* d 2.0)) 2.0) (/ h l)) -500000000.0)
             (* w0 (sqrt (- 1.0 (* h (/ (* M (* D (* M D))) (* (* d l) (* d 4.0)))))))
             (* w0 1.0)))
          assert(w0 < M && M < D && D < h && h < l && l < d);
          double code(double w0, double M, double D, double h, double l, double d) {
          	double tmp;
          	if ((pow(((M * D) / (d * 2.0)), 2.0) * (h / l)) <= -500000000.0) {
          		tmp = w0 * sqrt((1.0 - (h * ((M * (D * (M * D))) / ((d * l) * (d * 4.0))))));
          	} else {
          		tmp = w0 * 1.0;
          	}
          	return tmp;
          }
          
          NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
          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
              real(8) :: tmp
              if (((((m * d) / (d_1 * 2.0d0)) ** 2.0d0) * (h / l)) <= (-500000000.0d0)) then
                  tmp = w0 * sqrt((1.0d0 - (h * ((m * (d * (m * d))) / ((d_1 * l) * (d_1 * 4.0d0))))))
              else
                  tmp = w0 * 1.0d0
              end if
              code = tmp
          end function
          
          assert w0 < M && M < D && D < h && h < l && l < d;
          public static double code(double w0, double M, double D, double h, double l, double d) {
          	double tmp;
          	if ((Math.pow(((M * D) / (d * 2.0)), 2.0) * (h / l)) <= -500000000.0) {
          		tmp = w0 * Math.sqrt((1.0 - (h * ((M * (D * (M * D))) / ((d * l) * (d * 4.0))))));
          	} else {
          		tmp = w0 * 1.0;
          	}
          	return tmp;
          }
          
          [w0, M, D, h, l, d] = sort([w0, M, D, h, l, d])
          def code(w0, M, D, h, l, d):
          	tmp = 0
          	if (math.pow(((M * D) / (d * 2.0)), 2.0) * (h / l)) <= -500000000.0:
          		tmp = w0 * math.sqrt((1.0 - (h * ((M * (D * (M * D))) / ((d * l) * (d * 4.0))))))
          	else:
          		tmp = w0 * 1.0
          	return tmp
          
          w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
          function code(w0, M, D, h, l, d)
          	tmp = 0.0
          	if (Float64((Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0) * Float64(h / l)) <= -500000000.0)
          		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64(Float64(M * Float64(D * Float64(M * D))) / Float64(Float64(d * l) * Float64(d * 4.0)))))));
          	else
          		tmp = Float64(w0 * 1.0);
          	end
          	return tmp
          end
          
          w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
          function tmp_2 = code(w0, M, D, h, l, d)
          	tmp = 0.0;
          	if (((((M * D) / (d * 2.0)) ^ 2.0) * (h / l)) <= -500000000.0)
          		tmp = w0 * sqrt((1.0 - (h * ((M * (D * (M * D))) / ((d * l) * (d * 4.0))))));
          	else
          		tmp = w0 * 1.0;
          	end
          	tmp_2 = tmp;
          end
          
          NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
          code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -500000000.0], N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(N[(M * N[(D * N[(M * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(d * l), $MachinePrecision] * N[(d * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
          
          \begin{array}{l}
          [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
          \\
          \begin{array}{l}
          \mathbf{if}\;{\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -500000000:\\
          \;\;\;\;w0 \cdot \sqrt{1 - h \cdot \frac{M \cdot \left(D \cdot \left(M \cdot D\right)\right)}{\left(d \cdot \ell\right) \cdot \left(d \cdot 4\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)) < -5e8

            1. Initial program 71.3%

              \[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{1 - {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
              2. lift-*.f64N/A

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

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

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

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

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

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

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

                \[\leadsto \color{blue}{\sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot w0} \]
              10. lower-*.f6471.3

                \[\leadsto \color{blue}{\sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot w0} \]
            4. Applied rewrites60.4%

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \sqrt{1 - \color{blue}{\frac{M \cdot \left(D \cdot \left(M \cdot D\right)\right)}{\ell \cdot \left(\left(d \cdot d\right) \cdot 4\right)} \cdot h}} \cdot w0 \]
            6. Applied rewrites55.4%

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

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

            1. Initial program 88.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}{1} \]
            4. Step-by-step derivation
              1. Applied rewrites95.6%

                \[\leadsto w0 \cdot \color{blue}{1} \]
            5. Recombined 2 regimes into one program.
            6. Final simplification83.7%

              \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -500000000:\\ \;\;\;\;w0 \cdot \sqrt{1 - h \cdot \frac{M \cdot \left(D \cdot \left(M \cdot D\right)\right)}{\left(d \cdot \ell\right) \cdot \left(d \cdot 4\right)}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \]
            7. Add Preprocessing

            Alternative 9: 81.8% accurate, 0.8× speedup?

            \[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -20:\\ \;\;\;\;w0 \cdot \sqrt{\frac{\left(M \cdot \left(M \cdot D\right)\right) \cdot \left(D \cdot \left(h \cdot -0.25\right)\right)}{d \cdot \left(d \cdot \ell\right)}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \end{array} \]
            NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
            (FPCore (w0 M D h l d)
             :precision binary64
             (if (<= (* (pow (/ (* M D) (* d 2.0)) 2.0) (/ h l)) -20.0)
               (* w0 (sqrt (/ (* (* M (* M D)) (* D (* h -0.25))) (* d (* d l)))))
               (* w0 1.0)))
            assert(w0 < M && M < D && D < h && h < l && l < d);
            double code(double w0, double M, double D, double h, double l, double d) {
            	double tmp;
            	if ((pow(((M * D) / (d * 2.0)), 2.0) * (h / l)) <= -20.0) {
            		tmp = w0 * sqrt((((M * (M * D)) * (D * (h * -0.25))) / (d * (d * l))));
            	} else {
            		tmp = w0 * 1.0;
            	}
            	return tmp;
            }
            
            NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
            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
                real(8) :: tmp
                if (((((m * d) / (d_1 * 2.0d0)) ** 2.0d0) * (h / l)) <= (-20.0d0)) then
                    tmp = w0 * sqrt((((m * (m * d)) * (d * (h * (-0.25d0)))) / (d_1 * (d_1 * l))))
                else
                    tmp = w0 * 1.0d0
                end if
                code = tmp
            end function
            
            assert w0 < M && M < D && D < h && h < l && l < d;
            public static double code(double w0, double M, double D, double h, double l, double d) {
            	double tmp;
            	if ((Math.pow(((M * D) / (d * 2.0)), 2.0) * (h / l)) <= -20.0) {
            		tmp = w0 * Math.sqrt((((M * (M * D)) * (D * (h * -0.25))) / (d * (d * l))));
            	} else {
            		tmp = w0 * 1.0;
            	}
            	return tmp;
            }
            
            [w0, M, D, h, l, d] = sort([w0, M, D, h, l, d])
            def code(w0, M, D, h, l, d):
            	tmp = 0
            	if (math.pow(((M * D) / (d * 2.0)), 2.0) * (h / l)) <= -20.0:
            		tmp = w0 * math.sqrt((((M * (M * D)) * (D * (h * -0.25))) / (d * (d * l))))
            	else:
            		tmp = w0 * 1.0
            	return tmp
            
            w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
            function code(w0, M, D, h, l, d)
            	tmp = 0.0
            	if (Float64((Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0) * Float64(h / l)) <= -20.0)
            		tmp = Float64(w0 * sqrt(Float64(Float64(Float64(M * Float64(M * D)) * Float64(D * Float64(h * -0.25))) / Float64(d * Float64(d * l)))));
            	else
            		tmp = Float64(w0 * 1.0);
            	end
            	return tmp
            end
            
            w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
            function tmp_2 = code(w0, M, D, h, l, d)
            	tmp = 0.0;
            	if (((((M * D) / (d * 2.0)) ^ 2.0) * (h / l)) <= -20.0)
            		tmp = w0 * sqrt((((M * (M * D)) * (D * (h * -0.25))) / (d * (d * l))));
            	else
            		tmp = w0 * 1.0;
            	end
            	tmp_2 = tmp;
            end
            
            NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
            code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -20.0], N[(w0 * N[Sqrt[N[(N[(N[(M * N[(M * D), $MachinePrecision]), $MachinePrecision] * N[(D * N[(h * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d * N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
            
            \begin{array}{l}
            [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
            \\
            \begin{array}{l}
            \mathbf{if}\;{\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -20:\\
            \;\;\;\;w0 \cdot \sqrt{\frac{\left(M \cdot \left(M \cdot D\right)\right) \cdot \left(D \cdot \left(h \cdot -0.25\right)\right)}{d \cdot \left(d \cdot \ell\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)) < -20

              1. Initial program 71.6%

                \[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{1 - {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                2. lift-*.f64N/A

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

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

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

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

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

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

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

                  \[\leadsto \color{blue}{\sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot w0} \]
                10. lower-*.f6471.6

                  \[\leadsto \color{blue}{\sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot w0} \]
              4. Applied rewrites59.6%

                \[\leadsto \color{blue}{\sqrt{1 - \frac{M \cdot \left(D \cdot \left(M \cdot D\right)\right)}{\frac{\ell}{h} \cdot \left(\left(d \cdot d\right) \cdot 4\right)}} \cdot w0} \]
              5. Taylor expanded in M around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \sqrt{\left(D \cdot D\right) \cdot \frac{\frac{-1}{4} \cdot \left(\left(M \cdot M\right) \cdot h\right)}{\color{blue}{d \cdot \left(d \cdot \ell\right)}}} \cdot w0 \]
                17. lower-*.f6446.1

                  \[\leadsto \sqrt{\left(D \cdot D\right) \cdot \frac{-0.25 \cdot \left(\left(M \cdot M\right) \cdot h\right)}{d \cdot \color{blue}{\left(d \cdot \ell\right)}}} \cdot w0 \]
              7. Applied rewrites46.1%

                \[\leadsto \sqrt{\color{blue}{\left(D \cdot D\right) \cdot \frac{-0.25 \cdot \left(\left(M \cdot M\right) \cdot h\right)}{d \cdot \left(d \cdot \ell\right)}}} \cdot w0 \]
              8. Applied rewrites49.9%

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

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

                  \[\leadsto \sqrt{\color{blue}{\frac{\left(D \cdot \left(D \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)\right) \cdot \frac{-1}{4}}{\ell \cdot \left(d \cdot d\right)}}} \cdot w0 \]
                3. lift-*.f6449.9

                  \[\leadsto \color{blue}{\sqrt{\frac{\left(D \cdot \left(D \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)\right) \cdot -0.25}{\ell \cdot \left(d \cdot d\right)}} \cdot w0} \]
              10. Applied rewrites47.8%

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

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

              1. Initial program 88.2%

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

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

                \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -20:\\ \;\;\;\;w0 \cdot \sqrt{\frac{\left(M \cdot \left(M \cdot D\right)\right) \cdot \left(D \cdot \left(h \cdot -0.25\right)\right)}{d \cdot \left(d \cdot \ell\right)}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \]
              7. Add Preprocessing

              Alternative 10: 79.0% accurate, 0.8× speedup?

              \[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -500000000:\\ \;\;\;\;w0 \cdot \sqrt{\left(D \cdot D\right) \cdot \frac{-0.25 \cdot \left(h \cdot \left(M \cdot M\right)\right)}{d \cdot \left(d \cdot \ell\right)}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \end{array} \]
              NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
              (FPCore (w0 M D h l d)
               :precision binary64
               (if (<= (* (pow (/ (* M D) (* d 2.0)) 2.0) (/ h l)) -500000000.0)
                 (* w0 (sqrt (* (* D D) (/ (* -0.25 (* h (* M M))) (* d (* d l))))))
                 (* w0 1.0)))
              assert(w0 < M && M < D && D < h && h < l && l < d);
              double code(double w0, double M, double D, double h, double l, double d) {
              	double tmp;
              	if ((pow(((M * D) / (d * 2.0)), 2.0) * (h / l)) <= -500000000.0) {
              		tmp = w0 * sqrt(((D * D) * ((-0.25 * (h * (M * M))) / (d * (d * l)))));
              	} else {
              		tmp = w0 * 1.0;
              	}
              	return tmp;
              }
              
              NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
              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
                  real(8) :: tmp
                  if (((((m * d) / (d_1 * 2.0d0)) ** 2.0d0) * (h / l)) <= (-500000000.0d0)) then
                      tmp = w0 * sqrt(((d * d) * (((-0.25d0) * (h * (m * m))) / (d_1 * (d_1 * l)))))
                  else
                      tmp = w0 * 1.0d0
                  end if
                  code = tmp
              end function
              
              assert w0 < M && M < D && D < h && h < l && l < d;
              public static double code(double w0, double M, double D, double h, double l, double d) {
              	double tmp;
              	if ((Math.pow(((M * D) / (d * 2.0)), 2.0) * (h / l)) <= -500000000.0) {
              		tmp = w0 * Math.sqrt(((D * D) * ((-0.25 * (h * (M * M))) / (d * (d * l)))));
              	} else {
              		tmp = w0 * 1.0;
              	}
              	return tmp;
              }
              
              [w0, M, D, h, l, d] = sort([w0, M, D, h, l, d])
              def code(w0, M, D, h, l, d):
              	tmp = 0
              	if (math.pow(((M * D) / (d * 2.0)), 2.0) * (h / l)) <= -500000000.0:
              		tmp = w0 * math.sqrt(((D * D) * ((-0.25 * (h * (M * M))) / (d * (d * l)))))
              	else:
              		tmp = w0 * 1.0
              	return tmp
              
              w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
              function code(w0, M, D, h, l, d)
              	tmp = 0.0
              	if (Float64((Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0) * Float64(h / l)) <= -500000000.0)
              		tmp = Float64(w0 * sqrt(Float64(Float64(D * D) * Float64(Float64(-0.25 * Float64(h * Float64(M * M))) / Float64(d * Float64(d * l))))));
              	else
              		tmp = Float64(w0 * 1.0);
              	end
              	return tmp
              end
              
              w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
              function tmp_2 = code(w0, M, D, h, l, d)
              	tmp = 0.0;
              	if (((((M * D) / (d * 2.0)) ^ 2.0) * (h / l)) <= -500000000.0)
              		tmp = w0 * sqrt(((D * D) * ((-0.25 * (h * (M * M))) / (d * (d * l)))));
              	else
              		tmp = w0 * 1.0;
              	end
              	tmp_2 = tmp;
              end
              
              NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
              code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -500000000.0], N[(w0 * N[Sqrt[N[(N[(D * D), $MachinePrecision] * N[(N[(-0.25 * N[(h * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d * N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
              
              \begin{array}{l}
              [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
              \\
              \begin{array}{l}
              \mathbf{if}\;{\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -500000000:\\
              \;\;\;\;w0 \cdot \sqrt{\left(D \cdot D\right) \cdot \frac{-0.25 \cdot \left(h \cdot \left(M \cdot M\right)\right)}{d \cdot \left(d \cdot \ell\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)) < -5e8

                1. Initial program 71.3%

                  \[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{1 - {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                  2. lift-*.f64N/A

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{\sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot w0} \]
                  10. lower-*.f6471.3

                    \[\leadsto \color{blue}{\sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot w0} \]
                4. Applied rewrites60.4%

                  \[\leadsto \color{blue}{\sqrt{1 - \frac{M \cdot \left(D \cdot \left(M \cdot D\right)\right)}{\frac{\ell}{h} \cdot \left(\left(d \cdot d\right) \cdot 4\right)}} \cdot w0} \]
                5. Taylor expanded in M around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \sqrt{\left(D \cdot D\right) \cdot \frac{\frac{-1}{4} \cdot \left(\left(M \cdot M\right) \cdot h\right)}{\color{blue}{d \cdot \left(d \cdot \ell\right)}}} \cdot w0 \]
                  17. lower-*.f6446.7

                    \[\leadsto \sqrt{\left(D \cdot D\right) \cdot \frac{-0.25 \cdot \left(\left(M \cdot M\right) \cdot h\right)}{d \cdot \color{blue}{\left(d \cdot \ell\right)}}} \cdot w0 \]
                7. Applied rewrites46.7%

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

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

                1. Initial program 88.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}{1} \]
                4. Step-by-step derivation
                  1. Applied rewrites95.6%

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

                  \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -500000000:\\ \;\;\;\;w0 \cdot \sqrt{\left(D \cdot D\right) \cdot \frac{-0.25 \cdot \left(h \cdot \left(M \cdot M\right)\right)}{d \cdot \left(d \cdot \ell\right)}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \]
                7. Add Preprocessing

                Alternative 11: 77.9% accurate, 0.8× speedup?

                \[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+15}:\\ \;\;\;\;\mathsf{fma}\left(D \cdot D, \frac{-0.125 \cdot \left(h \cdot \left(M \cdot \left(w0 \cdot M\right)\right)\right)}{\ell \cdot \left(d \cdot d\right)}, w0\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \end{array} \]
                NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
                (FPCore (w0 M D h l d)
                 :precision binary64
                 (if (<= (* (pow (/ (* M D) (* d 2.0)) 2.0) (/ h l)) -2e+15)
                   (fma (* D D) (/ (* -0.125 (* h (* M (* w0 M)))) (* l (* d d))) w0)
                   (* w0 1.0)))
                assert(w0 < M && M < D && D < h && h < l && l < d);
                double code(double w0, double M, double D, double h, double l, double d) {
                	double tmp;
                	if ((pow(((M * D) / (d * 2.0)), 2.0) * (h / l)) <= -2e+15) {
                		tmp = fma((D * D), ((-0.125 * (h * (M * (w0 * M)))) / (l * (d * d))), w0);
                	} else {
                		tmp = w0 * 1.0;
                	}
                	return tmp;
                }
                
                w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
                function code(w0, M, D, h, l, d)
                	tmp = 0.0
                	if (Float64((Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0) * Float64(h / l)) <= -2e+15)
                		tmp = fma(Float64(D * D), Float64(Float64(-0.125 * Float64(h * Float64(M * Float64(w0 * M)))) / Float64(l * Float64(d * d))), w0);
                	else
                		tmp = Float64(w0 * 1.0);
                	end
                	return tmp
                end
                
                NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
                code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -2e+15], N[(N[(D * D), $MachinePrecision] * N[(N[(-0.125 * N[(h * N[(M * N[(w0 * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l * N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + w0), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
                
                \begin{array}{l}
                [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
                \\
                \begin{array}{l}
                \mathbf{if}\;{\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+15}:\\
                \;\;\;\;\mathsf{fma}\left(D \cdot D, \frac{-0.125 \cdot \left(h \cdot \left(M \cdot \left(w0 \cdot M\right)\right)\right)}{\ell \cdot \left(d \cdot d\right)}, w0\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)) < -2e15

                  1. Initial program 70.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 \color{blue}{w0 + \frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}} \]
                  4. Step-by-step derivation
                    1. +-commutativeN/A

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

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

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

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

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

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

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

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

                  1. Initial program 88.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 rewrites95.2%

                      \[\leadsto w0 \cdot \color{blue}{1} \]
                  5. Recombined 2 regimes into one program.
                  6. Final simplification79.8%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+15}:\\ \;\;\;\;\mathsf{fma}\left(D \cdot D, \frac{-0.125 \cdot \left(h \cdot \left(M \cdot \left(w0 \cdot M\right)\right)\right)}{\ell \cdot \left(d \cdot d\right)}, w0\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot 1\\ \end{array} \]
                  7. Add Preprocessing

                  Alternative 12: 88.8% accurate, 1.6× speedup?

                  \[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{M \cdot D}{d \cdot -2}}{\ell}, \frac{\frac{M \cdot D}{d \cdot 2}}{\frac{1}{h}}, 1\right)} \end{array} \]
                  NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
                  (FPCore (w0 M D h l d)
                   :precision binary64
                   (*
                    w0
                    (sqrt
                     (fma
                      (/ (/ (* M D) (* d -2.0)) l)
                      (/ (/ (* M D) (* d 2.0)) (/ 1.0 h))
                      1.0))))
                  assert(w0 < M && M < D && D < h && h < l && l < d);
                  double code(double w0, double M, double D, double h, double l, double d) {
                  	return w0 * sqrt(fma((((M * D) / (d * -2.0)) / l), (((M * D) / (d * 2.0)) / (1.0 / h)), 1.0));
                  }
                  
                  w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
                  function code(w0, M, D, h, l, d)
                  	return Float64(w0 * sqrt(fma(Float64(Float64(Float64(M * D) / Float64(d * -2.0)) / l), Float64(Float64(Float64(M * D) / Float64(d * 2.0)) / Float64(1.0 / h)), 1.0)))
                  end
                  
                  NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
                  code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(N[(N[(N[(M * D), $MachinePrecision] / N[(d * -2.0), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision] / N[(1.0 / h), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
                  
                  \begin{array}{l}
                  [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
                  \\
                  w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{M \cdot D}{d \cdot -2}}{\ell}, \frac{\frac{M \cdot D}{d \cdot 2}}{\frac{1}{h}}, 1\right)}
                  \end{array}
                  
                  Derivation
                  1. Initial program 83.3%

                    \[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{1 - {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
                    2. lift-*.f64N/A

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

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

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

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

                      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
                    7. 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)}} \]
                    8. +-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. Applied rewrites90.7%

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

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

                  Alternative 13: 68.2% accurate, 26.2× speedup?

                  \[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ w0 \cdot 1 \end{array} \]
                  NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
                  (FPCore (w0 M D h l d) :precision binary64 (* w0 1.0))
                  assert(w0 < M && M < D && D < h && h < l && l < d);
                  double code(double w0, double M, double D, double h, double l, double d) {
                  	return w0 * 1.0;
                  }
                  
                  NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
                  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
                  
                  assert w0 < M && M < D && D < h && h < l && l < d;
                  public static double code(double w0, double M, double D, double h, double l, double d) {
                  	return w0 * 1.0;
                  }
                  
                  [w0, M, D, h, l, d] = sort([w0, M, D, h, l, d])
                  def code(w0, M, D, h, l, d):
                  	return w0 * 1.0
                  
                  w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
                  function code(w0, M, D, h, l, d)
                  	return Float64(w0 * 1.0)
                  end
                  
                  w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
                  function tmp = code(w0, M, D, h, l, d)
                  	tmp = w0 * 1.0;
                  end
                  
                  NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
                  code[w0_, M_, D_, h_, l_, d_] := N[(w0 * 1.0), $MachinePrecision]
                  
                  \begin{array}{l}
                  [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
                  \\
                  w0 \cdot 1
                  \end{array}
                  
                  Derivation
                  1. Initial program 83.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}{1} \]
                  4. Step-by-step derivation
                    1. Applied rewrites68.9%

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

                    Reproduce

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