Average Error: 14.1 → 10.6
Time: 8.6s
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 := D \cdot \left(\sqrt{\left(\frac{h}{\ell} \cdot \left(\frac{M}{d} \cdot \frac{M}{d}\right)\right) \cdot -0.25} \cdot w0\right)\\ t_1 := \frac{M \cdot D}{2 \cdot d}\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+69}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+94}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \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 (* D (* (sqrt (* (* (/ h l) (* (/ M d) (/ M d))) -0.25)) w0)))
        (t_1 (/ (* M D) (* 2.0 d))))
   (if (<= t_1 -1e+69)
     t_0
     (if (<= t_1 5e+94)
       (* w0 (sqrt (- 1.0 (/ (* h (pow (* (* M 0.5) (/ D d)) 2.0)) l))))
       t_0))))
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 = D * (sqrt((((h / l) * ((M / d) * (M / d))) * -0.25)) * w0);
	double t_1 = (M * D) / (2.0 * d);
	double tmp;
	if (t_1 <= -1e+69) {
		tmp = t_0;
	} else if (t_1 <= 5e+94) {
		tmp = w0 * sqrt((1.0 - ((h * pow(((M * 0.5) * (D / d)), 2.0)) / l)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
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
real(8) function code(w0, m, d, h, l, d_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = d * (sqrt((((h / l) * ((m / d_1) * (m / d_1))) * (-0.25d0))) * w0)
    t_1 = (m * d) / (2.0d0 * d_1)
    if (t_1 <= (-1d+69)) then
        tmp = t_0
    else if (t_1 <= 5d+94) then
        tmp = w0 * sqrt((1.0d0 - ((h * (((m * 0.5d0) * (d / d_1)) ** 2.0d0)) / l)))
    else
        tmp = t_0
    end if
    code = tmp
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))));
}
public static double code(double w0, double M, double D, double h, double l, double d) {
	double t_0 = D * (Math.sqrt((((h / l) * ((M / d) * (M / d))) * -0.25)) * w0);
	double t_1 = (M * D) / (2.0 * d);
	double tmp;
	if (t_1 <= -1e+69) {
		tmp = t_0;
	} else if (t_1 <= 5e+94) {
		tmp = w0 * Math.sqrt((1.0 - ((h * Math.pow(((M * 0.5) * (D / d)), 2.0)) / l)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
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))))
def code(w0, M, D, h, l, d):
	t_0 = D * (math.sqrt((((h / l) * ((M / d) * (M / d))) * -0.25)) * w0)
	t_1 = (M * D) / (2.0 * d)
	tmp = 0
	if t_1 <= -1e+69:
		tmp = t_0
	elif t_1 <= 5e+94:
		tmp = w0 * math.sqrt((1.0 - ((h * math.pow(((M * 0.5) * (D / d)), 2.0)) / l)))
	else:
		tmp = t_0
	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(D * Float64(sqrt(Float64(Float64(Float64(h / l) * Float64(Float64(M / d) * Float64(M / d))) * -0.25)) * w0))
	t_1 = Float64(Float64(M * D) / Float64(2.0 * d))
	tmp = 0.0
	if (t_1 <= -1e+69)
		tmp = t_0;
	elseif (t_1 <= 5e+94)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(Float64(M * 0.5) * Float64(D / d)) ^ 2.0)) / l))));
	else
		tmp = t_0;
	end
	return tmp
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
function tmp_2 = code(w0, M, D, h, l, d)
	t_0 = D * (sqrt((((h / l) * ((M / d) * (M / d))) * -0.25)) * w0);
	t_1 = (M * D) / (2.0 * d);
	tmp = 0.0;
	if (t_1 <= -1e+69)
		tmp = t_0;
	elseif (t_1 <= 5e+94)
		tmp = w0 * sqrt((1.0 - ((h * (((M * 0.5) * (D / d)) ^ 2.0)) / l)));
	else
		tmp = t_0;
	end
	tmp_2 = 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[(D * N[(N[Sqrt[N[(N[(N[(h / l), $MachinePrecision] * N[(N[(M / d), $MachinePrecision] * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+69], t$95$0, If[LessEqual[t$95$1, 5e+94], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(N[(M * 0.5), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]]
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\begin{array}{l}
t_0 := D \cdot \left(\sqrt{\left(\frac{h}{\ell} \cdot \left(\frac{M}{d} \cdot \frac{M}{d}\right)\right) \cdot -0.25} \cdot w0\right)\\
t_1 := \frac{M \cdot D}{2 \cdot d}\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{+69}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+94}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(\left(M \cdot 0.5\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 M D) (*.f64 2 d)) < -1.0000000000000001e69 or 5.0000000000000001e94 < (/.f64 (*.f64 M D) (*.f64 2 d))

    1. Initial program 47.5

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

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

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

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

    if -1.0000000000000001e69 < (/.f64 (*.f64 M D) (*.f64 2 d)) < 5.0000000000000001e94

    1. Initial program 6.7

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

      \[\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. Recombined 2 regimes into one program.
  4. Final simplification10.6

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

Reproduce

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