Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.0% → 89.3%
Time: 14.9s
Alternatives: 4
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 4 alternatives:

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

Initial Program: 81.0% 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.3% accurate, 0.5× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ w0\_m = \left|w0\right| \\ w0\_s = \mathsf{copysign}\left(1, w0\right) \\ [w0_m, M, D_m, h, l, d] = \mathsf{sort}([w0_m, M, D_m, h, l, d])\\ \\ \begin{array}{l} t_0 := M \cdot \left(D\_m \cdot \frac{0.5}{d}\right)\\ w0\_s \cdot \begin{array}{l} \mathbf{if}\;w0\_m \cdot \sqrt{1 - {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq 5 \cdot 10^{+183}:\\ \;\;\;\;w0\_m \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(D\_m \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;w0\_m \cdot \sqrt{1 - \frac{h \cdot t\_0}{\frac{\ell}{t\_0}}}\\ \end{array} \end{array} \end{array} \]
D_m = (fabs.f64 D)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M D_m h l d)
 :precision binary64
 (let* ((t_0 (* M (* D_m (/ 0.5 d)))))
   (*
    w0_s
    (if (<=
         (* w0_m (sqrt (- 1.0 (* (pow (/ (* M D_m) (* 2.0 d)) 2.0) (/ h l)))))
         5e+183)
      (* w0_m (sqrt (- 1.0 (* (/ h l) (pow (* D_m (/ (/ M 2.0) d)) 2.0)))))
      (* w0_m (sqrt (- 1.0 (/ (* h t_0) (/ l t_0)))))))))
D_m = fabs(D);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M && M < D_m && D_m < h && h < l && l < d);
double code(double w0_s, double w0_m, double M, double D_m, double h, double l, double d) {
	double t_0 = M * (D_m * (0.5 / d));
	double tmp;
	if ((w0_m * sqrt((1.0 - (pow(((M * D_m) / (2.0 * d)), 2.0) * (h / l))))) <= 5e+183) {
		tmp = w0_m * sqrt((1.0 - ((h / l) * pow((D_m * ((M / 2.0) / d)), 2.0))));
	} else {
		tmp = w0_m * sqrt((1.0 - ((h * t_0) / (l / t_0))));
	}
	return w0_s * tmp;
}
D_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m, d_m, h, l, d)
    real(8), intent (in) :: w0_s
    real(8), intent (in) :: w0_m
    real(8), intent (in) :: m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = m * (d_m * (0.5d0 / d))
    if ((w0_m * sqrt((1.0d0 - ((((m * d_m) / (2.0d0 * d)) ** 2.0d0) * (h / l))))) <= 5d+183) then
        tmp = w0_m * sqrt((1.0d0 - ((h / l) * ((d_m * ((m / 2.0d0) / d)) ** 2.0d0))))
    else
        tmp = w0_m * sqrt((1.0d0 - ((h * t_0) / (l / t_0))))
    end if
    code = w0_s * tmp
end function
D_m = Math.abs(D);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M && M < D_m && D_m < h && h < l && l < d;
public static double code(double w0_s, double w0_m, double M, double D_m, double h, double l, double d) {
	double t_0 = M * (D_m * (0.5 / d));
	double tmp;
	if ((w0_m * Math.sqrt((1.0 - (Math.pow(((M * D_m) / (2.0 * d)), 2.0) * (h / l))))) <= 5e+183) {
		tmp = w0_m * Math.sqrt((1.0 - ((h / l) * Math.pow((D_m * ((M / 2.0) / d)), 2.0))));
	} else {
		tmp = w0_m * Math.sqrt((1.0 - ((h * t_0) / (l / t_0))));
	}
	return w0_s * tmp;
}
D_m = math.fabs(D)
w0\_m = math.fabs(w0)
w0\_s = math.copysign(1.0, w0)
[w0_m, M, D_m, h, l, d] = sort([w0_m, M, D_m, h, l, d])
def code(w0_s, w0_m, M, D_m, h, l, d):
	t_0 = M * (D_m * (0.5 / d))
	tmp = 0
	if (w0_m * math.sqrt((1.0 - (math.pow(((M * D_m) / (2.0 * d)), 2.0) * (h / l))))) <= 5e+183:
		tmp = w0_m * math.sqrt((1.0 - ((h / l) * math.pow((D_m * ((M / 2.0) / d)), 2.0))))
	else:
		tmp = w0_m * math.sqrt((1.0 - ((h * t_0) / (l / t_0))))
	return w0_s * tmp
D_m = abs(D)
w0\_m = abs(w0)
w0\_s = copysign(1.0, w0)
w0_m, M, D_m, h, l, d = sort([w0_m, M, D_m, h, l, d])
function code(w0_s, w0_m, M, D_m, h, l, d)
	t_0 = Float64(M * Float64(D_m * Float64(0.5 / d)))
	tmp = 0.0
	if (Float64(w0_m * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) <= 5e+183)
		tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(D_m * Float64(Float64(M / 2.0) / d)) ^ 2.0)))));
	else
		tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(Float64(h * t_0) / Float64(l / t_0)))));
	end
	return Float64(w0_s * tmp)
end
D_m = abs(D);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M, D_m, h, l, d = num2cell(sort([w0_m, M, D_m, h, l, d])){:}
function tmp_2 = code(w0_s, w0_m, M, D_m, h, l, d)
	t_0 = M * (D_m * (0.5 / d));
	tmp = 0.0;
	if ((w0_m * sqrt((1.0 - ((((M * D_m) / (2.0 * d)) ^ 2.0) * (h / l))))) <= 5e+183)
		tmp = w0_m * sqrt((1.0 - ((h / l) * ((D_m * ((M / 2.0) / d)) ^ 2.0))));
	else
		tmp = w0_m * sqrt((1.0 - ((h * t_0) / (l / t_0))));
	end
	tmp_2 = w0_s * tmp;
end
D_m = N[Abs[D], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(M * N[(D$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(w0$95$s * If[LessEqual[N[(w0$95$m * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 5e+183], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(D$95$m * N[(N[(M / 2.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(N[(h * t$95$0), $MachinePrecision] / N[(l / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M, D_m, h, l, d] = \mathsf{sort}([w0_m, M, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := M \cdot \left(D\_m \cdot \frac{0.5}{d}\right)\\
w0\_s \cdot \begin{array}{l}
\mathbf{if}\;w0\_m \cdot \sqrt{1 - {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq 5 \cdot 10^{+183}:\\
\;\;\;\;w0\_m \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(D\_m \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}\\

\mathbf{else}:\\
\;\;\;\;w0\_m \cdot \sqrt{1 - \frac{h \cdot t\_0}{\frac{\ell}{t\_0}}}\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 w0 (sqrt.f64 (-.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.00000000000000009e183

    1. Initial program 95.7%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified95.1%

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

    if 5.00000000000000009e183 < (*.f64 w0 (sqrt.f64 (-.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 57.1%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified58.8%

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. clear-num58.8%

        \[\leadsto w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \color{blue}{\frac{1}{\frac{\ell}{h}}}} \]
      2. un-div-inv62.5%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}{\frac{\ell}{h}}}} \]
      3. clear-num62.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - h \cdot \frac{{\color{blue}{\left(\frac{\frac{D}{d} \cdot M}{2}\right)}}^{2}}{\ell}} \]
      11. *-commutative79.0%

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

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

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

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

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

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{h \cdot \frac{{\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}}{\ell}}} \]
    8. Step-by-step derivation
      1. unpow279.0%

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

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

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

        \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right)\right) \cdot \frac{D \cdot \frac{M}{2 \cdot d}}{\ell}\right)} \]
      5. metadata-eval82.5%

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

        \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \frac{D \cdot \color{blue}{\left(M \cdot \frac{1}{2 \cdot d}\right)}}{\ell}\right)} \]
      7. associate-/r*82.6%

        \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \frac{D \cdot \left(M \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right)}{\ell}\right)} \]
      8. metadata-eval82.6%

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

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

      \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \color{blue}{\left(0.5 \cdot \frac{D \cdot M}{d \cdot \ell}\right)}\right)} \]
    11. Step-by-step derivation
      1. associate-*r/75.5%

        \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \color{blue}{\frac{0.5 \cdot \left(D \cdot M\right)}{d \cdot \ell}}\right)} \]
      2. associate-/r*79.1%

        \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \color{blue}{\frac{\frac{0.5 \cdot \left(D \cdot M\right)}{d}}{\ell}}\right)} \]
      3. associate-*l/79.1%

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

        \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \frac{\color{blue}{\left(D \cdot M\right) \cdot \frac{0.5}{d}}}{\ell}\right)} \]
      5. associate-*r*82.6%

        \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \frac{\color{blue}{D \cdot \left(M \cdot \frac{0.5}{d}\right)}}{\ell}\right)} \]
      6. associate-*r/80.9%

        \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \color{blue}{\left(D \cdot \frac{M \cdot \frac{0.5}{d}}{\ell}\right)}\right)} \]
      7. associate-*r/80.9%

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

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

        \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \left(D \cdot \frac{M \cdot 0.5}{\color{blue}{d \cdot \ell}}\right)\right)} \]
      10. *-commutative77.6%

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

      \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \color{blue}{\left(D \cdot \frac{0.5 \cdot M}{d \cdot \ell}\right)}\right)} \]
    13. Step-by-step derivation
      1. associate-*r*77.2%

        \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\color{blue}{\left(\left(D \cdot M\right) \cdot \frac{0.5}{d}\right)} \cdot \left(D \cdot \frac{0.5 \cdot M}{d \cdot \ell}\right)\right)} \]
      2. div-inv77.2%

        \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(\left(D \cdot M\right) \cdot \color{blue}{\left(0.5 \cdot \frac{1}{d}\right)}\right) \cdot \left(D \cdot \frac{0.5 \cdot M}{d \cdot \ell}\right)\right)} \]
      3. associate-*r*77.2%

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

        \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(\left(\left(D \cdot M\right) \cdot \color{blue}{\frac{1}{2}}\right) \cdot \frac{1}{d}\right) \cdot \left(D \cdot \frac{0.5 \cdot M}{d \cdot \ell}\right)\right)} \]
      5. div-inv77.2%

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

        \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(\color{blue}{\frac{1}{\frac{2}{D \cdot M}}} \cdot \frac{1}{d}\right) \cdot \left(D \cdot \frac{0.5 \cdot M}{d \cdot \ell}\right)\right)} \]
      7. div-inv77.2%

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

        \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\color{blue}{\frac{1}{\frac{2}{D \cdot M} \cdot d}} \cdot \left(D \cdot \frac{0.5 \cdot M}{d \cdot \ell}\right)\right)} \]
      9. associate-/r*77.4%

        \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\frac{1}{\frac{2}{D \cdot M} \cdot d} \cdot \left(D \cdot \color{blue}{\frac{\frac{0.5 \cdot M}{d}}{\ell}}\right)\right)} \]
      10. *-commutative77.4%

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

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

        \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\frac{1}{\frac{2}{D \cdot M} \cdot d} \cdot \color{blue}{\frac{D \cdot \left(M \cdot \frac{0.5}{d}\right)}{\ell}}\right)} \]
      13. associate-*r*79.1%

        \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\left(h \cdot \frac{1}{\frac{2}{D \cdot M} \cdot d}\right) \cdot \frac{D \cdot \left(M \cdot \frac{0.5}{d}\right)}{\ell}}} \]
      14. clear-num79.1%

        \[\leadsto w0 \cdot \sqrt{1 - \left(h \cdot \frac{1}{\frac{2}{D \cdot M} \cdot d}\right) \cdot \color{blue}{\frac{1}{\frac{\ell}{D \cdot \left(M \cdot \frac{0.5}{d}\right)}}}} \]
    14. Applied egg-rr86.1%

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

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

Alternative 2: 88.6% accurate, 1.8× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ w0\_m = \left|w0\right| \\ w0\_s = \mathsf{copysign}\left(1, w0\right) \\ [w0_m, M, D_m, h, l, d] = \mathsf{sort}([w0_m, M, D_m, h, l, d])\\ \\ \begin{array}{l} t_0 := D\_m \cdot \left(M \cdot \frac{0.5}{d}\right)\\ w0\_s \cdot \left(w0\_m \cdot \sqrt{1 - h \cdot \left(t\_0 \cdot \frac{t\_0}{\ell}\right)}\right) \end{array} \end{array} \]
D_m = (fabs.f64 D)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M D_m h l d)
 :precision binary64
 (let* ((t_0 (* D_m (* M (/ 0.5 d)))))
   (* w0_s (* w0_m (sqrt (- 1.0 (* h (* t_0 (/ t_0 l)))))))))
D_m = fabs(D);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M && M < D_m && D_m < h && h < l && l < d);
double code(double w0_s, double w0_m, double M, double D_m, double h, double l, double d) {
	double t_0 = D_m * (M * (0.5 / d));
	return w0_s * (w0_m * sqrt((1.0 - (h * (t_0 * (t_0 / l))))));
}
D_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m, d_m, h, l, d)
    real(8), intent (in) :: w0_s
    real(8), intent (in) :: w0_m
    real(8), intent (in) :: m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    real(8) :: t_0
    t_0 = d_m * (m * (0.5d0 / d))
    code = w0_s * (w0_m * sqrt((1.0d0 - (h * (t_0 * (t_0 / l))))))
end function
D_m = Math.abs(D);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M && M < D_m && D_m < h && h < l && l < d;
public static double code(double w0_s, double w0_m, double M, double D_m, double h, double l, double d) {
	double t_0 = D_m * (M * (0.5 / d));
	return w0_s * (w0_m * Math.sqrt((1.0 - (h * (t_0 * (t_0 / l))))));
}
D_m = math.fabs(D)
w0\_m = math.fabs(w0)
w0\_s = math.copysign(1.0, w0)
[w0_m, M, D_m, h, l, d] = sort([w0_m, M, D_m, h, l, d])
def code(w0_s, w0_m, M, D_m, h, l, d):
	t_0 = D_m * (M * (0.5 / d))
	return w0_s * (w0_m * math.sqrt((1.0 - (h * (t_0 * (t_0 / l))))))
D_m = abs(D)
w0\_m = abs(w0)
w0\_s = copysign(1.0, w0)
w0_m, M, D_m, h, l, d = sort([w0_m, M, D_m, h, l, d])
function code(w0_s, w0_m, M, D_m, h, l, d)
	t_0 = Float64(D_m * Float64(M * Float64(0.5 / d)))
	return Float64(w0_s * Float64(w0_m * sqrt(Float64(1.0 - Float64(h * Float64(t_0 * Float64(t_0 / l)))))))
end
D_m = abs(D);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M, D_m, h, l, d = num2cell(sort([w0_m, M, D_m, h, l, d])){:}
function tmp = code(w0_s, w0_m, M, D_m, h, l, d)
	t_0 = D_m * (M * (0.5 / d));
	tmp = w0_s * (w0_m * sqrt((1.0 - (h * (t_0 * (t_0 / l))))));
end
D_m = N[Abs[D], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(D$95$m * N[(M * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(w0$95$s * N[(w0$95$m * N[Sqrt[N[(1.0 - N[(h * N[(t$95$0 * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M, D_m, h, l, d] = \mathsf{sort}([w0_m, M, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := D\_m \cdot \left(M \cdot \frac{0.5}{d}\right)\\
w0\_s \cdot \left(w0\_m \cdot \sqrt{1 - h \cdot \left(t\_0 \cdot \frac{t\_0}{\ell}\right)}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 87.4%

    \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
  2. Simplified87.3%

    \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. clear-num86.9%

      \[\leadsto w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \color{blue}{\frac{1}{\frac{\ell}{h}}}} \]
    2. un-div-inv87.7%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}{\frac{\ell}{h}}}} \]
    3. clear-num87.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{h \cdot \frac{{\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}}{\ell}}} \]
  8. Step-by-step derivation
    1. unpow290.9%

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

      \[\leadsto w0 \cdot \sqrt{1 - h \cdot \color{blue}{\left(\left(D \cdot \frac{M}{2 \cdot d}\right) \cdot \frac{D \cdot \frac{M}{2 \cdot d}}{\ell}\right)}} \]
    3. div-inv91.7%

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

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

      \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{\color{blue}{0.5}}{d}\right)\right) \cdot \frac{D \cdot \frac{M}{2 \cdot d}}{\ell}\right)} \]
    6. div-inv91.7%

      \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \frac{D \cdot \color{blue}{\left(M \cdot \frac{1}{2 \cdot d}\right)}}{\ell}\right)} \]
    7. associate-/r*91.7%

      \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \frac{D \cdot \left(M \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right)}{\ell}\right)} \]
    8. metadata-eval91.7%

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

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

Alternative 3: 84.4% accurate, 1.8× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ w0\_m = \left|w0\right| \\ w0\_s = \mathsf{copysign}\left(1, w0\right) \\ [w0_m, M, D_m, h, l, d] = \mathsf{sort}([w0_m, M, D_m, h, l, d])\\ \\ w0\_s \cdot \left(w0\_m \cdot \sqrt{1 - h \cdot \left(\left(D\_m \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \left(D\_m \cdot \frac{M \cdot 0.5}{d \cdot \ell}\right)\right)}\right) \end{array} \]
D_m = (fabs.f64 D)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M D_m h l d)
 :precision binary64
 (*
  w0_s
  (*
   w0_m
   (sqrt
    (- 1.0 (* h (* (* D_m (* M (/ 0.5 d))) (* D_m (/ (* M 0.5) (* d l))))))))))
D_m = fabs(D);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M && M < D_m && D_m < h && h < l && l < d);
double code(double w0_s, double w0_m, double M, double D_m, double h, double l, double d) {
	return w0_s * (w0_m * sqrt((1.0 - (h * ((D_m * (M * (0.5 / d))) * (D_m * ((M * 0.5) / (d * l))))))));
}
D_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m, d_m, h, l, d)
    real(8), intent (in) :: w0_s
    real(8), intent (in) :: w0_m
    real(8), intent (in) :: m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    code = w0_s * (w0_m * sqrt((1.0d0 - (h * ((d_m * (m * (0.5d0 / d))) * (d_m * ((m * 0.5d0) / (d * l))))))))
end function
D_m = Math.abs(D);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M && M < D_m && D_m < h && h < l && l < d;
public static double code(double w0_s, double w0_m, double M, double D_m, double h, double l, double d) {
	return w0_s * (w0_m * Math.sqrt((1.0 - (h * ((D_m * (M * (0.5 / d))) * (D_m * ((M * 0.5) / (d * l))))))));
}
D_m = math.fabs(D)
w0\_m = math.fabs(w0)
w0\_s = math.copysign(1.0, w0)
[w0_m, M, D_m, h, l, d] = sort([w0_m, M, D_m, h, l, d])
def code(w0_s, w0_m, M, D_m, h, l, d):
	return w0_s * (w0_m * math.sqrt((1.0 - (h * ((D_m * (M * (0.5 / d))) * (D_m * ((M * 0.5) / (d * l))))))))
D_m = abs(D)
w0\_m = abs(w0)
w0\_s = copysign(1.0, w0)
w0_m, M, D_m, h, l, d = sort([w0_m, M, D_m, h, l, d])
function code(w0_s, w0_m, M, D_m, h, l, d)
	return Float64(w0_s * Float64(w0_m * sqrt(Float64(1.0 - Float64(h * Float64(Float64(D_m * Float64(M * Float64(0.5 / d))) * Float64(D_m * Float64(Float64(M * 0.5) / Float64(d * l)))))))))
end
D_m = abs(D);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M, D_m, h, l, d = num2cell(sort([w0_m, M, D_m, h, l, d])){:}
function tmp = code(w0_s, w0_m, M, D_m, h, l, d)
	tmp = w0_s * (w0_m * sqrt((1.0 - (h * ((D_m * (M * (0.5 / d))) * (D_m * ((M * 0.5) / (d * l))))))));
end
D_m = N[Abs[D], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M_, D$95$m_, h_, l_, d_] := N[(w0$95$s * N[(w0$95$m * N[Sqrt[N[(1.0 - N[(h * N[(N[(D$95$m * N[(M * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(D$95$m * N[(N[(M * 0.5), $MachinePrecision] / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M, D_m, h, l, d] = \mathsf{sort}([w0_m, M, D_m, h, l, d])\\
\\
w0\_s \cdot \left(w0\_m \cdot \sqrt{1 - h \cdot \left(\left(D\_m \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \left(D\_m \cdot \frac{M \cdot 0.5}{d \cdot \ell}\right)\right)}\right)
\end{array}
Derivation
  1. Initial program 87.4%

    \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
  2. Simplified87.3%

    \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. clear-num86.9%

      \[\leadsto w0 \cdot \sqrt{1 - {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot \color{blue}{\frac{1}{\frac{\ell}{h}}}} \]
    2. un-div-inv87.7%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}{\frac{\ell}{h}}}} \]
    3. clear-num87.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{h \cdot \frac{{\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}}{\ell}}} \]
  8. Step-by-step derivation
    1. unpow290.9%

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

      \[\leadsto w0 \cdot \sqrt{1 - h \cdot \color{blue}{\left(\left(D \cdot \frac{M}{2 \cdot d}\right) \cdot \frac{D \cdot \frac{M}{2 \cdot d}}{\ell}\right)}} \]
    3. div-inv91.7%

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

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

      \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{\color{blue}{0.5}}{d}\right)\right) \cdot \frac{D \cdot \frac{M}{2 \cdot d}}{\ell}\right)} \]
    6. div-inv91.7%

      \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \frac{D \cdot \color{blue}{\left(M \cdot \frac{1}{2 \cdot d}\right)}}{\ell}\right)} \]
    7. associate-/r*91.7%

      \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \frac{D \cdot \left(M \cdot \color{blue}{\frac{\frac{1}{2}}{d}}\right)}{\ell}\right)} \]
    8. metadata-eval91.7%

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

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

    \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \color{blue}{\left(0.5 \cdot \frac{D \cdot M}{d \cdot \ell}\right)}\right)} \]
  11. Step-by-step derivation
    1. associate-*r/88.7%

      \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \color{blue}{\frac{0.5 \cdot \left(D \cdot M\right)}{d \cdot \ell}}\right)} \]
    2. associate-/r*90.6%

      \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \color{blue}{\frac{\frac{0.5 \cdot \left(D \cdot M\right)}{d}}{\ell}}\right)} \]
    3. associate-*l/90.6%

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

      \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \frac{\color{blue}{\left(D \cdot M\right) \cdot \frac{0.5}{d}}}{\ell}\right)} \]
    5. associate-*r*91.7%

      \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \frac{\color{blue}{D \cdot \left(M \cdot \frac{0.5}{d}\right)}}{\ell}\right)} \]
    6. associate-*r/89.1%

      \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \color{blue}{\left(D \cdot \frac{M \cdot \frac{0.5}{d}}{\ell}\right)}\right)} \]
    7. associate-*r/89.1%

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

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

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

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

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

    \[\leadsto w0 \cdot \sqrt{1 - h \cdot \left(\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \left(D \cdot \frac{M \cdot 0.5}{d \cdot \ell}\right)\right)} \]
  14. Add Preprocessing

Alternative 4: 68.2% accurate, 216.0× speedup?

\[\begin{array}{l} D_m = \left|D\right| \\ w0\_m = \left|w0\right| \\ w0\_s = \mathsf{copysign}\left(1, w0\right) \\ [w0_m, M, D_m, h, l, d] = \mathsf{sort}([w0_m, M, D_m, h, l, d])\\ \\ w0\_s \cdot w0\_m \end{array} \]
D_m = (fabs.f64 D)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M D_m h l d) :precision binary64 (* w0_s w0_m))
D_m = fabs(D);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M && M < D_m && D_m < h && h < l && l < d);
double code(double w0_s, double w0_m, double M, double D_m, double h, double l, double d) {
	return w0_s * w0_m;
}
D_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m, d_m, h, l, d)
    real(8), intent (in) :: w0_s
    real(8), intent (in) :: w0_m
    real(8), intent (in) :: m
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d
    code = w0_s * w0_m
end function
D_m = Math.abs(D);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M && M < D_m && D_m < h && h < l && l < d;
public static double code(double w0_s, double w0_m, double M, double D_m, double h, double l, double d) {
	return w0_s * w0_m;
}
D_m = math.fabs(D)
w0\_m = math.fabs(w0)
w0\_s = math.copysign(1.0, w0)
[w0_m, M, D_m, h, l, d] = sort([w0_m, M, D_m, h, l, d])
def code(w0_s, w0_m, M, D_m, h, l, d):
	return w0_s * w0_m
D_m = abs(D)
w0\_m = abs(w0)
w0\_s = copysign(1.0, w0)
w0_m, M, D_m, h, l, d = sort([w0_m, M, D_m, h, l, d])
function code(w0_s, w0_m, M, D_m, h, l, d)
	return Float64(w0_s * w0_m)
end
D_m = abs(D);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M, D_m, h, l, d = num2cell(sort([w0_m, M, D_m, h, l, d])){:}
function tmp = code(w0_s, w0_m, M, D_m, h, l, d)
	tmp = w0_s * w0_m;
end
D_m = N[Abs[D], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M_, D$95$m_, h_, l_, d_] := N[(w0$95$s * w0$95$m), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M, D_m, h, l, d] = \mathsf{sort}([w0_m, M, D_m, h, l, d])\\
\\
w0\_s \cdot w0\_m
\end{array}
Derivation
  1. Initial program 87.4%

    \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
  2. Simplified87.3%

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

    \[\leadsto \color{blue}{w0} \]
  5. Add Preprocessing

Reproduce

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