Average Error: 13.9 → 8.3
Time: 49.3s
Precision: binary64
Cost: 8392
\[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
\[\begin{array}{l} t_0 := \frac{M \cdot D}{d}\\ \mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(M \cdot D\right) \cdot \left(\frac{0.5}{d} \cdot \frac{t_0 \cdot h}{2}\right)}{\ell}}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-304}:\\ \;\;\;\;w0 \cdot \sqrt{1 - t_0 \cdot \left(\frac{\frac{\left(M \cdot D\right) \cdot 0.5}{d}}{2} \cdot \frac{h}{\ell}\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \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 D) d)))
   (if (<= (/ h l) (- INFINITY))
     (* w0 (sqrt (- 1.0 (/ (* (* M D) (* (/ 0.5 d) (/ (* t_0 h) 2.0))) l))))
     (if (<= (/ h l) -2e-304)
       (* w0 (sqrt (- 1.0 (* t_0 (* (/ (/ (* (* M D) 0.5) d) 2.0) (/ h l))))))
       w0))))
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 * D) / d;
	double tmp;
	if ((h / l) <= -((double) INFINITY)) {
		tmp = w0 * sqrt((1.0 - (((M * D) * ((0.5 / d) * ((t_0 * h) / 2.0))) / l)));
	} else if ((h / l) <= -2e-304) {
		tmp = w0 * sqrt((1.0 - (t_0 * (((((M * D) * 0.5) / d) / 2.0) * (h / l)))));
	} else {
		tmp = w0;
	}
	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 * D) / d;
	double tmp;
	if ((h / l) <= -Double.POSITIVE_INFINITY) {
		tmp = w0 * Math.sqrt((1.0 - (((M * D) * ((0.5 / d) * ((t_0 * h) / 2.0))) / l)));
	} else if ((h / l) <= -2e-304) {
		tmp = w0 * Math.sqrt((1.0 - (t_0 * (((((M * D) * 0.5) / d) / 2.0) * (h / l)))));
	} else {
		tmp = w0;
	}
	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 = (M * D) / d
	tmp = 0
	if (h / l) <= -math.inf:
		tmp = w0 * math.sqrt((1.0 - (((M * D) * ((0.5 / d) * ((t_0 * h) / 2.0))) / l)))
	elif (h / l) <= -2e-304:
		tmp = w0 * math.sqrt((1.0 - (t_0 * (((((M * D) * 0.5) / d) / 2.0) * (h / l)))))
	else:
		tmp = w0
	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(Float64(M * D) / d)
	tmp = 0.0
	if (Float64(h / l) <= Float64(-Inf))
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(M * D) * Float64(Float64(0.5 / d) * Float64(Float64(t_0 * h) / 2.0))) / l))));
	elseif (Float64(h / l) <= -2e-304)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(t_0 * Float64(Float64(Float64(Float64(Float64(M * D) * 0.5) / d) / 2.0) * Float64(h / l))))));
	else
		tmp = w0;
	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 = (M * D) / d;
	tmp = 0.0;
	if ((h / l) <= -Inf)
		tmp = w0 * sqrt((1.0 - (((M * D) * ((0.5 / d) * ((t_0 * h) / 2.0))) / l)));
	elseif ((h / l) <= -2e-304)
		tmp = w0 * sqrt((1.0 - (t_0 * (((((M * D) * 0.5) / d) / 2.0) * (h / l)))));
	else
		tmp = w0;
	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[(N[(M * D), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[N[(h / l), $MachinePrecision], (-Infinity)], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(M * D), $MachinePrecision] * N[(N[(0.5 / d), $MachinePrecision] * N[(N[(t$95$0 * h), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(h / l), $MachinePrecision], -2e-304], N[(w0 * N[Sqrt[N[(1.0 - N[(t$95$0 * N[(N[(N[(N[(N[(M * D), $MachinePrecision] * 0.5), $MachinePrecision] / d), $MachinePrecision] / 2.0), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]]]
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\begin{array}{l}
t_0 := \frac{M \cdot D}{d}\\
\mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(M \cdot D\right) \cdot \left(\frac{0.5}{d} \cdot \frac{t_0 \cdot h}{2}\right)}{\ell}}\\

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

\mathbf{else}:\\
\;\;\;\;w0\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if (/.f64 h l) < -inf.0

    1. Initial program 64.0

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

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

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

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

    if -inf.0 < (/.f64 h l) < -1.99999999999999994e-304

    1. Initial program 14.3

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

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

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

    if -1.99999999999999994e-304 < (/.f64 h l)

    1. Initial program 7.4

      \[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 2.5

      \[\leadsto \color{blue}{w0} \]
  3. Recombined 3 regimes into one program.

Alternatives

Alternative 1
Error8.3
Cost8392
\[\begin{array}{l} t_0 := \frac{M \cdot D}{d}\\ \mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\frac{\left(M \cdot D\right) \cdot h}{d}}{4} \cdot t_0}{\ell}}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-304}:\\ \;\;\;\;w0 \cdot \sqrt{1 - t_0 \cdot \left(\frac{\frac{\left(M \cdot D\right) \cdot 0.5}{d}}{2} \cdot \frac{h}{\ell}\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 2
Error8.4
Cost8392
\[\begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -5 \cdot 10^{+306}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(M \cdot D\right) \cdot \left(\frac{0.5}{d} \cdot \frac{h \cdot \left(M \cdot D\right)}{d \cdot 2}\right)}{\ell}}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-304}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M \cdot D}{d} \cdot \left(\frac{\frac{\left(M \cdot D\right) \cdot 0.5}{d}}{2} \cdot \frac{h}{\ell}\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 3
Error12.9
Cost8140
\[\begin{array}{l} t_0 := w0 \cdot \sqrt{1 - \frac{D \cdot \frac{h \cdot \left(M \cdot D\right)}{4 \cdot d}}{\ell \cdot d} \cdot M}\\ \mathbf{if}\;D \leq -3.5 \cdot 10^{-208}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;D \leq 5 \cdot 10^{-98}:\\ \;\;\;\;w0\\ \mathbf{elif}\;D \leq 4.3 \cdot 10^{+162}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 4
Error10.5
Cost8004
\[\begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -2 \cdot 10^{-185}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\frac{\left(M \cdot D\right) \cdot h}{d}}{4} \cdot \frac{M \cdot D}{d}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 5
Error13.8
Cost64
\[w0 \]

Error

Reproduce

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