Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 80.7% → 89.0%
Time: 16.0s
Alternatives: 15
Speedup: 1.8×

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 15 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: 89.0% accurate, 1.8× speedup?

\[\begin{array}{l} [w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\ \\ \begin{array}{l} t_0 := M \cdot \frac{D}{2 \cdot d}\\ w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot t\_0, t\_0 \cdot \frac{-1}{\ell}, 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 (* 2.0 d)))))
   (* w0 (sqrt (fma (* h t_0) (* t_0 (/ -1.0 l)) 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 / (2.0 * d));
	return w0 * sqrt(fma((h * t_0), (t_0 * (-1.0 / l)), 1.0));
}
w0, M, D, h, l, d = sort([w0, M, D, h, l, d])
function code(w0, M, D, h, l, d)
	t_0 = Float64(M * Float64(D / Float64(2.0 * d)))
	return Float64(w0 * sqrt(fma(Float64(h * t_0), Float64(t_0 * Float64(-1.0 / l)), 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_] := Block[{t$95$0 = N[(M * N[(D / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(w0 * N[Sqrt[N[(N[(h * t$95$0), $MachinePrecision] * N[(t$95$0 * N[(-1.0 / l), $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 := M \cdot \frac{D}{2 \cdot d}\\
w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot t\_0, t\_0 \cdot \frac{-1}{\ell}, 1\right)}
\end{array}
\end{array}
Derivation
  1. Initial program 84.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 82.6% 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}\;\frac{h}{\ell} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \leq -2 \cdot 10^{+15}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(\left(M \cdot D\right) \cdot \frac{M \cdot D}{4 \cdot \left(d \cdot d\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 (<= (* (/ h l) (pow (/ (* M D) (* 2.0 d)) 2.0)) -2e+15)
   (* w0 (sqrt (- 1.0 (* (/ h l) (* (* M D) (/ (* M D) (* 4.0 (* d d))))))))
   (* 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 (((h / l) * pow(((M * D) / (2.0 * d)), 2.0)) <= -2e+15) {
		tmp = w0 * sqrt((1.0 - ((h / l) * ((M * D) * ((M * D) / (4.0 * (d * d)))))));
	} 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 (((h / l) * (((m * d) / (2.0d0 * d_1)) ** 2.0d0)) <= (-2d+15)) then
        tmp = w0 * sqrt((1.0d0 - ((h / l) * ((m * d) * ((m * d) / (4.0d0 * (d_1 * d_1)))))))
    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 (((h / l) * Math.pow(((M * D) / (2.0 * d)), 2.0)) <= -2e+15) {
		tmp = w0 * Math.sqrt((1.0 - ((h / l) * ((M * D) * ((M * D) / (4.0 * (d * d)))))));
	} 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 ((h / l) * math.pow(((M * D) / (2.0 * d)), 2.0)) <= -2e+15:
		tmp = w0 * math.sqrt((1.0 - ((h / l) * ((M * D) * ((M * D) / (4.0 * (d * d)))))))
	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(h / l) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) <= -2e+15)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * Float64(Float64(M * D) * Float64(Float64(M * D) / Float64(4.0 * Float64(d * d))))))));
	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 (((h / l) * (((M * D) / (2.0 * d)) ^ 2.0)) <= -2e+15)
		tmp = w0 * sqrt((1.0 - ((h / l) * ((M * D) * ((M * D) / (4.0 * (d * d)))))));
	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[(h / l), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], -2e+15], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(N[(M * D), $MachinePrecision] * N[(N[(M * D), $MachinePrecision] / N[(4.0 * N[(d * d), $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}\;\frac{h}{\ell} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \leq -2 \cdot 10^{+15}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(\left(M \cdot D\right) \cdot \frac{M \cdot D}{4 \cdot \left(d \cdot d\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 65.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-pow.f64N/A

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}} \cdot \frac{h}{\ell}} \]
      2. 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}} \]
      3. 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}} \]
      4. 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}} \]
      5. 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}} \]
      6. 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}} \]
      7. 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}} \]
      8. 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}} \]
      9. 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}} \]
      10. *-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}} \]
      11. 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}} \]
      12. *-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}} \]
      13. 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}} \]
      14. 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}} \]
      15. 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}} \]
      16. 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}} \]
      17. 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}} \]
      18. metadata-eval55.1

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

      \[\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 -2e15 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))

    1. Initial program 87.6%

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

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

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

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

    Reproduce

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