Average Error: 14.1 → 9.7
Time: 10.3s
Precision: binary64
\[ \begin{array}{c}[M, D] = \mathsf{sort}([M, D])\\ \end{array} \]
\[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
\[\begin{array}{l} t_0 := M \cdot \left(0.5 \cdot \frac{D}{d}\right)\\ t_1 := t_0 \cdot \sqrt{h}\\ t_2 := \sqrt[3]{1 - h \cdot \frac{{t_0}^{2}}{\ell}}\\ \mathbf{if}\;h \leq -3.85 \cdot 10^{-218}:\\ \;\;\;\;w0 \cdot \left(\sqrt{{t_2}^{2}} \cdot \sqrt{t_2}\right)\\ \mathbf{elif}\;h \leq 1.15 \cdot 10^{-194}:\\ \;\;\;\;w0\\ \mathbf{elif}\;h \leq 2.1 \cdot 10^{-192}:\\ \;\;\;\;\sqrt{\left(-0.25 \cdot \frac{h}{\ell}\right) \cdot \frac{M \cdot M}{d \cdot d}} \cdot \left(w0 \cdot D\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - t_1 \cdot \left(t_1 \cdot \frac{1}{\ell}\right)}\\ \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))))))
(FPCore (w0 M D h l d)
 :precision binary64
 (let* ((t_0 (* M (* 0.5 (/ D d))))
        (t_1 (* t_0 (sqrt h)))
        (t_2 (cbrt (- 1.0 (* h (/ (pow t_0 2.0) l))))))
   (if (<= h -3.85e-218)
     (* w0 (* (sqrt (pow t_2 2.0)) (sqrt t_2)))
     (if (<= h 1.15e-194)
       w0
       (if (<= h 2.1e-192)
         (* (sqrt (* (* -0.25 (/ h l)) (/ (* M M) (* d d)))) (* w0 D))
         (* w0 (sqrt (- 1.0 (* t_1 (* t_1 (/ 1.0 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))));
}
double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = M * (0.5 * (D / d));
	double t_1 = t_0 * sqrt(h);
	double t_2 = cbrt((1.0 - (h * (pow(t_0, 2.0) / l))));
	double tmp;
	if (h <= -3.85e-218) {
		tmp = w0 * (sqrt(pow(t_2, 2.0)) * sqrt(t_2));
	} else if (h <= 1.15e-194) {
		tmp = w0;
	} else if (h <= 2.1e-192) {
		tmp = sqrt(((-0.25 * (h / l)) * ((M * M) / (d * d)))) * (w0 * D);
	} else {
		tmp = w0 * sqrt((1.0 - (t_1 * (t_1 * (1.0 / l)))));
	}
	return tmp;
}
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))));
}
public static double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = M * (0.5 * (D / d));
	double t_1 = t_0 * Math.sqrt(h);
	double t_2 = Math.cbrt((1.0 - (h * (Math.pow(t_0, 2.0) / l))));
	double tmp;
	if (h <= -3.85e-218) {
		tmp = w0 * (Math.sqrt(Math.pow(t_2, 2.0)) * Math.sqrt(t_2));
	} else if (h <= 1.15e-194) {
		tmp = w0;
	} else if (h <= 2.1e-192) {
		tmp = Math.sqrt(((-0.25 * (h / l)) * ((M * M) / (d * d)))) * (w0 * D);
	} else {
		tmp = w0 * Math.sqrt((1.0 - (t_1 * (t_1 * (1.0 / l)))));
	}
	return tmp;
}
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 code(w0, M, D, h, l, d)
	t_0 = Float64(M * Float64(0.5 * Float64(D / d)))
	t_1 = Float64(t_0 * sqrt(h))
	t_2 = cbrt(Float64(1.0 - Float64(h * Float64((t_0 ^ 2.0) / l))))
	tmp = 0.0
	if (h <= -3.85e-218)
		tmp = Float64(w0 * Float64(sqrt((t_2 ^ 2.0)) * sqrt(t_2)));
	elseif (h <= 1.15e-194)
		tmp = w0;
	elseif (h <= 2.1e-192)
		tmp = Float64(sqrt(Float64(Float64(-0.25 * Float64(h / l)) * Float64(Float64(M * M) / Float64(d * d)))) * Float64(w0 * D));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(t_1 * Float64(t_1 * Float64(1.0 / l))))));
	end
	return tmp
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]
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(M * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(1.0 - N[(h * N[(N[Power[t$95$0, 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[h, -3.85e-218], N[(w0 * N[(N[Sqrt[N[Power[t$95$2, 2.0], $MachinePrecision]], $MachinePrecision] * N[Sqrt[t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 1.15e-194], w0, If[LessEqual[h, 2.1e-192], N[(N[Sqrt[N[(N[(-0.25 * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[(N[(M * M), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(w0 * D), $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(t$95$1 * N[(t$95$1 * N[(1.0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\begin{array}{l}
t_0 := M \cdot \left(0.5 \cdot \frac{D}{d}\right)\\
t_1 := t_0 \cdot \sqrt{h}\\
t_2 := \sqrt[3]{1 - h \cdot \frac{{t_0}^{2}}{\ell}}\\
\mathbf{if}\;h \leq -3.85 \cdot 10^{-218}:\\
\;\;\;\;w0 \cdot \left(\sqrt{{t_2}^{2}} \cdot \sqrt{t_2}\right)\\

\mathbf{elif}\;h \leq 1.15 \cdot 10^{-194}:\\
\;\;\;\;w0\\

\mathbf{elif}\;h \leq 2.1 \cdot 10^{-192}:\\
\;\;\;\;\sqrt{\left(-0.25 \cdot \frac{h}{\ell}\right) \cdot \frac{M \cdot M}{d \cdot d}} \cdot \left(w0 \cdot D\right)\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - t_1 \cdot \left(t_1 \cdot \frac{1}{\ell}\right)}\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if h < -3.8500000000000002e-218

    1. Initial program 14.8

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

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

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

    if -3.8500000000000002e-218 < h < 1.15000000000000001e-194

    1. Initial program 10.2

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

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

    if 1.15000000000000001e-194 < h < 2.09999999999999993e-192

    1. Initial program 8.0

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

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

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

    if 2.09999999999999993e-192 < h

    1. Initial program 15.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -3.85 \cdot 10^{-218}:\\ \;\;\;\;w0 \cdot \left(\sqrt{{\left(\sqrt[3]{1 - h \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}}{\ell}}\right)}^{2}} \cdot \sqrt{\sqrt[3]{1 - h \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}}{\ell}}}\right)\\ \mathbf{elif}\;h \leq 1.15 \cdot 10^{-194}:\\ \;\;\;\;w0\\ \mathbf{elif}\;h \leq 2.1 \cdot 10^{-192}:\\ \;\;\;\;\sqrt{\left(-0.25 \cdot \frac{h}{\ell}\right) \cdot \frac{M \cdot M}{d \cdot d}} \cdot \left(w0 \cdot D\right)\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right) \cdot \sqrt{h}\right) \cdot \left(\left(\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right) \cdot \sqrt{h}\right) \cdot \frac{1}{\ell}\right)}\\ \end{array} \]

Reproduce

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