Henrywood and Agarwal, Equation (9a)

Percentage Accurate: 81.4% → 88.0%
Time: 22.1s
Alternatives: 5
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 5 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.4% 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.0% accurate, 0.3× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ d_m = \left|d\right| \\ w0\_m = \left|w0\right| \\ w0\_s = \mathsf{copysign}\left(1, w0\right) \\ [w0_m, M_m, D, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D, h, l, d_m])\\ \\ w0\_s \cdot \begin{array}{l} \mathbf{if}\;{\left(\frac{M\_m \cdot D}{2 \cdot d\_m}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\ \;\;\;\;{\left(\sqrt{w0\_m} \cdot {\left(e^{0.25}\right)}^{\left(\log \left(-0.25 \cdot \frac{h \cdot {\left(M\_m \cdot D\right)}^{2}}{\ell}\right) + -2 \cdot \log d\_m\right)}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;w0\_m \cdot \sqrt{1 - h \cdot \frac{{\left(D \cdot \left(M\_m \cdot \frac{0.5}{d\_m}\right)\right)}^{2}}{\ell}}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
d_m = (fabs.f64 d)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M_m, D, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D h l d_m)
 :precision binary64
 (*
  w0_s
  (if (<= (* (pow (/ (* M_m D) (* 2.0 d_m)) 2.0) (/ h l)) (- INFINITY))
    (pow
     (*
      (sqrt w0_m)
      (pow
       (exp 0.25)
       (+ (log (* -0.25 (/ (* h (pow (* M_m D) 2.0)) l))) (* -2.0 (log d_m)))))
     2.0)
    (* w0_m (sqrt (- 1.0 (* h (/ (pow (* D (* M_m (/ 0.5 d_m))) 2.0) l))))))))
M_m = fabs(M);
d_m = fabs(d);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D && D < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D, double h, double l, double d_m) {
	double tmp;
	if ((pow(((M_m * D) / (2.0 * d_m)), 2.0) * (h / l)) <= -((double) INFINITY)) {
		tmp = pow((sqrt(w0_m) * pow(exp(0.25), (log((-0.25 * ((h * pow((M_m * D), 2.0)) / l))) + (-2.0 * log(d_m))))), 2.0);
	} else {
		tmp = w0_m * sqrt((1.0 - (h * (pow((D * (M_m * (0.5 / d_m))), 2.0) / l))));
	}
	return w0_s * tmp;
}
M_m = Math.abs(M);
d_m = Math.abs(d);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D && D < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D, double h, double l, double d_m) {
	double tmp;
	if ((Math.pow(((M_m * D) / (2.0 * d_m)), 2.0) * (h / l)) <= -Double.POSITIVE_INFINITY) {
		tmp = Math.pow((Math.sqrt(w0_m) * Math.pow(Math.exp(0.25), (Math.log((-0.25 * ((h * Math.pow((M_m * D), 2.0)) / l))) + (-2.0 * Math.log(d_m))))), 2.0);
	} else {
		tmp = w0_m * Math.sqrt((1.0 - (h * (Math.pow((D * (M_m * (0.5 / d_m))), 2.0) / l))));
	}
	return w0_s * tmp;
}
M_m = math.fabs(M)
d_m = math.fabs(d)
w0\_m = math.fabs(w0)
w0\_s = math.copysign(1.0, w0)
[w0_m, M_m, D, h, l, d_m] = sort([w0_m, M_m, D, h, l, d_m])
def code(w0_s, w0_m, M_m, D, h, l, d_m):
	tmp = 0
	if (math.pow(((M_m * D) / (2.0 * d_m)), 2.0) * (h / l)) <= -math.inf:
		tmp = math.pow((math.sqrt(w0_m) * math.pow(math.exp(0.25), (math.log((-0.25 * ((h * math.pow((M_m * D), 2.0)) / l))) + (-2.0 * math.log(d_m))))), 2.0)
	else:
		tmp = w0_m * math.sqrt((1.0 - (h * (math.pow((D * (M_m * (0.5 / d_m))), 2.0) / l))))
	return w0_s * tmp
M_m = abs(M)
d_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0, w0)
w0_m, M_m, D, h, l, d_m = sort([w0_m, M_m, D, h, l, d_m])
function code(w0_s, w0_m, M_m, D, h, l, d_m)
	tmp = 0.0
	if (Float64((Float64(Float64(M_m * D) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l)) <= Float64(-Inf))
		tmp = Float64(sqrt(w0_m) * (exp(0.25) ^ Float64(log(Float64(-0.25 * Float64(Float64(h * (Float64(M_m * D) ^ 2.0)) / l))) + Float64(-2.0 * log(d_m))))) ^ 2.0;
	else
		tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(h * Float64((Float64(D * Float64(M_m * Float64(0.5 / d_m))) ^ 2.0) / l)))));
	end
	return Float64(w0_s * tmp)
end
M_m = abs(M);
d_m = abs(d);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M_m, D, h, l, d_m = num2cell(sort([w0_m, M_m, D, h, l, d_m])){:}
function tmp_2 = code(w0_s, w0_m, M_m, D, h, l, d_m)
	tmp = 0.0;
	if (((((M_m * D) / (2.0 * d_m)) ^ 2.0) * (h / l)) <= -Inf)
		tmp = (sqrt(w0_m) * (exp(0.25) ^ (log((-0.25 * ((h * ((M_m * D) ^ 2.0)) / l))) + (-2.0 * log(d_m))))) ^ 2.0;
	else
		tmp = w0_m * sqrt((1.0 - (h * (((D * (M_m * (0.5 / d_m))) ^ 2.0) / l))));
	end
	tmp_2 = w0_s * tmp;
end
M_m = N[Abs[M], $MachinePrecision]
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_m, D, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D_, h_, l_, d$95$m_] := N[(w0$95$s * If[LessEqual[N[(N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], (-Infinity)], N[Power[N[(N[Sqrt[w0$95$m], $MachinePrecision] * N[Power[N[Exp[0.25], $MachinePrecision], N[(N[Log[N[(-0.25 * N[(N[(h * N[Power[N[(M$95$m * D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(-2.0 * N[Log[d$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(h * N[(N[Power[N[(D * N[(M$95$m * N[(0.5 / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
d_m = \left|d\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D, h, l, d_m])\\
\\
w0\_s \cdot \begin{array}{l}
\mathbf{if}\;{\left(\frac{M\_m \cdot D}{2 \cdot d\_m}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\
\;\;\;\;{\left(\sqrt{w0\_m} \cdot {\left(e^{0.25}\right)}^{\left(\log \left(-0.25 \cdot \frac{h \cdot {\left(M\_m \cdot D\right)}^{2}}{\ell}\right) + -2 \cdot \log d\_m\right)}\right)}^{2}\\

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


\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)) < -inf.0

    1. Initial program 51.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {\color{blue}{\left(\sqrt{w0} \cdot e^{0.25 \cdot \left(\log \left(-0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}\right) + -2 \cdot \log d\right)}\right)}}^{2} \]
    11. Step-by-step derivation
      1. exp-prod7.1%

        \[\leadsto {\left(\sqrt{w0} \cdot \color{blue}{{\left(e^{0.25}\right)}^{\left(\log \left(-0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}\right) + -2 \cdot \log d\right)}}\right)}^{2} \]
      2. distribute-lft-neg-in7.1%

        \[\leadsto {\left(\sqrt{w0} \cdot {\left(e^{0.25}\right)}^{\left(\log \color{blue}{\left(\left(-0.25\right) \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}\right)} + -2 \cdot \log d\right)}\right)}^{2} \]
      3. metadata-eval7.1%

        \[\leadsto {\left(\sqrt{w0} \cdot {\left(e^{0.25}\right)}^{\left(\log \left(\color{blue}{-0.25} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\ell}\right) + -2 \cdot \log d\right)}\right)}^{2} \]
      4. associate-*r*7.1%

        \[\leadsto {\left(\sqrt{w0} \cdot {\left(e^{0.25}\right)}^{\left(\log \left(-0.25 \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}}{\ell}\right) + -2 \cdot \log d\right)}\right)}^{2} \]
      5. unpow27.1%

        \[\leadsto {\left(\sqrt{w0} \cdot {\left(e^{0.25}\right)}^{\left(\log \left(-0.25 \cdot \frac{\left(\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}\right) \cdot h}{\ell}\right) + -2 \cdot \log d\right)}\right)}^{2} \]
      6. unpow27.1%

        \[\leadsto {\left(\sqrt{w0} \cdot {\left(e^{0.25}\right)}^{\left(\log \left(-0.25 \cdot \frac{\left(\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}\right) \cdot h}{\ell}\right) + -2 \cdot \log d\right)}\right)}^{2} \]
      7. swap-sqr11.6%

        \[\leadsto {\left(\sqrt{w0} \cdot {\left(e^{0.25}\right)}^{\left(\log \left(-0.25 \cdot \frac{\color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)} \cdot h}{\ell}\right) + -2 \cdot \log d\right)}\right)}^{2} \]
      8. unpow211.6%

        \[\leadsto {\left(\sqrt{w0} \cdot {\left(e^{0.25}\right)}^{\left(\log \left(-0.25 \cdot \frac{\color{blue}{{\left(D \cdot M\right)}^{2}} \cdot h}{\ell}\right) + -2 \cdot \log d\right)}\right)}^{2} \]
    12. Simplified11.6%

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

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

    1. Initial program 89.3%

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified88.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-num88.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-inv88.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 86.6% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 80.1% accurate, 1.9× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ d_m = \left|d\right| \\ w0\_m = \left|w0\right| \\ w0\_s = \mathsf{copysign}\left(1, w0\right) \\ [w0_m, M_m, D, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D, h, l, d_m])\\ \\ w0\_s \cdot \left(w0\_m + -0.125 \cdot \left(h \cdot \left(w0\_m \cdot \frac{{\left(D \cdot \frac{M\_m}{d\_m}\right)}^{2}}{\ell}\right)\right)\right) \end{array} \]
M_m = (fabs.f64 M)
d_m = (fabs.f64 d)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M_m, D, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D h l d_m)
 :precision binary64
 (* w0_s (+ w0_m (* -0.125 (* h (* w0_m (/ (pow (* D (/ M_m d_m)) 2.0) l)))))))
M_m = fabs(M);
d_m = fabs(d);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D && D < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D, double h, double l, double d_m) {
	return w0_s * (w0_m + (-0.125 * (h * (w0_m * (pow((D * (M_m / d_m)), 2.0) / l)))));
}
M_m = abs(m)
d_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M_m, D, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m_m, d, h, l, d_m)
    real(8), intent (in) :: w0_s
    real(8), intent (in) :: w0_m
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_m
    code = w0_s * (w0_m + ((-0.125d0) * (h * (w0_m * (((d * (m_m / d_m)) ** 2.0d0) / l)))))
end function
M_m = Math.abs(M);
d_m = Math.abs(d);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D && D < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D, double h, double l, double d_m) {
	return w0_s * (w0_m + (-0.125 * (h * (w0_m * (Math.pow((D * (M_m / d_m)), 2.0) / l)))));
}
M_m = math.fabs(M)
d_m = math.fabs(d)
w0\_m = math.fabs(w0)
w0\_s = math.copysign(1.0, w0)
[w0_m, M_m, D, h, l, d_m] = sort([w0_m, M_m, D, h, l, d_m])
def code(w0_s, w0_m, M_m, D, h, l, d_m):
	return w0_s * (w0_m + (-0.125 * (h * (w0_m * (math.pow((D * (M_m / d_m)), 2.0) / l)))))
M_m = abs(M)
d_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0, w0)
w0_m, M_m, D, h, l, d_m = sort([w0_m, M_m, D, h, l, d_m])
function code(w0_s, w0_m, M_m, D, h, l, d_m)
	return Float64(w0_s * Float64(w0_m + Float64(-0.125 * Float64(h * Float64(w0_m * Float64((Float64(D * Float64(M_m / d_m)) ^ 2.0) / l))))))
end
M_m = abs(M);
d_m = abs(d);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M_m, D, h, l, d_m = num2cell(sort([w0_m, M_m, D, h, l, d_m])){:}
function tmp = code(w0_s, w0_m, M_m, D, h, l, d_m)
	tmp = w0_s * (w0_m + (-0.125 * (h * (w0_m * (((D * (M_m / d_m)) ^ 2.0) / l)))));
end
M_m = N[Abs[M], $MachinePrecision]
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_m, D, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D_, h_, l_, d$95$m_] := N[(w0$95$s * N[(w0$95$m + N[(-0.125 * N[(h * N[(w0$95$m * N[(N[Power[N[(D * N[(M$95$m / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
d_m = \left|d\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D, h, l, d_m])\\
\\
w0\_s \cdot \left(w0\_m + -0.125 \cdot \left(h \cdot \left(w0\_m \cdot \frac{{\left(D \cdot \frac{M\_m}{d\_m}\right)}^{2}}{\ell}\right)\right)\right)
\end{array}
Derivation
  1. Initial program 76.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{w0 + -0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}} \]
  11. Simplified70.9%

    \[\leadsto \color{blue}{w0 + -0.125 \cdot \left(h \cdot \left(\frac{w0}{\ell} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right)} \]
  12. Taylor expanded in w0 around 0 52.0%

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

      \[\leadsto w0 + -0.125 \cdot \left(h \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot w0}}{{d}^{2} \cdot \ell}\right) \]
    2. times-frac52.0%

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

      \[\leadsto w0 + -0.125 \cdot \left(h \cdot \left(\color{blue}{\left({D}^{2} \cdot \frac{{M}^{2}}{{d}^{2}}\right)} \cdot \frac{w0}{\ell}\right)\right) \]
    4. unpow252.0%

      \[\leadsto w0 + -0.125 \cdot \left(h \cdot \left(\left(\color{blue}{\left(D \cdot D\right)} \cdot \frac{{M}^{2}}{{d}^{2}}\right) \cdot \frac{w0}{\ell}\right)\right) \]
    5. unpow252.0%

      \[\leadsto w0 + -0.125 \cdot \left(h \cdot \left(\left(\left(D \cdot D\right) \cdot \frac{\color{blue}{M \cdot M}}{{d}^{2}}\right) \cdot \frac{w0}{\ell}\right)\right) \]
    6. unpow252.0%

      \[\leadsto w0 + -0.125 \cdot \left(h \cdot \left(\left(\left(D \cdot D\right) \cdot \frac{M \cdot M}{\color{blue}{d \cdot d}}\right) \cdot \frac{w0}{\ell}\right)\right) \]
    7. times-frac63.1%

      \[\leadsto w0 + -0.125 \cdot \left(h \cdot \left(\left(\left(D \cdot D\right) \cdot \color{blue}{\left(\frac{M}{d} \cdot \frac{M}{d}\right)}\right) \cdot \frac{w0}{\ell}\right)\right) \]
    8. swap-sqr70.9%

      \[\leadsto w0 + -0.125 \cdot \left(h \cdot \left(\color{blue}{\left(\left(D \cdot \frac{M}{d}\right) \cdot \left(D \cdot \frac{M}{d}\right)\right)} \cdot \frac{w0}{\ell}\right)\right) \]
    9. unpow270.9%

      \[\leadsto w0 + -0.125 \cdot \left(h \cdot \left(\color{blue}{{\left(D \cdot \frac{M}{d}\right)}^{2}} \cdot \frac{w0}{\ell}\right)\right) \]
    10. associate-*r/74.5%

      \[\leadsto w0 + -0.125 \cdot \left(h \cdot \color{blue}{\frac{{\left(D \cdot \frac{M}{d}\right)}^{2} \cdot w0}{\ell}}\right) \]
    11. *-commutative74.5%

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

      \[\leadsto w0 + -0.125 \cdot \left(h \cdot \color{blue}{\left(w0 \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{\ell}\right)}\right) \]
  14. Simplified75.3%

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

Alternative 4: 76.5% accurate, 8.3× speedup?

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

\mathbf{else}:\\
\;\;\;\;w0\_m + -0.125 \cdot \left(h \cdot \left(\frac{w0\_m}{\ell} \cdot \left(t\_0 \cdot t\_0\right)\right)\right)\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 3.4999999999999998e75

    1. Initial program 78.3%

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

      \[\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 64.7%

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

    if 3.4999999999999998e75 < D

    1. Initial program 66.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{w0 + -0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w0\right)\right)}{{d}^{2} \cdot \ell}} \]
    11. Simplified61.6%

      \[\leadsto \color{blue}{w0 + -0.125 \cdot \left(h \cdot \left(\frac{w0}{\ell} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right)} \]
    12. Step-by-step derivation
      1. unpow261.6%

        \[\leadsto w0 + -0.125 \cdot \left(h \cdot \left(\frac{w0}{\ell} \cdot \color{blue}{\left(\left(D \cdot \frac{M}{d}\right) \cdot \left(D \cdot \frac{M}{d}\right)\right)}\right)\right) \]
    13. Applied egg-rr61.6%

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

Alternative 5: 68.3% accurate, 216.0× speedup?

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

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

    \[\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 60.1%

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

Reproduce

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