Average Error: 14.4 → 7.8
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 := \left(M \cdot 0.5\right) \cdot \frac{D}{d}\\ t_1 := w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;w0 \cdot \left(D \cdot \sqrt{\left(\frac{h}{\ell} \cdot \left(\frac{M}{d} \cdot \frac{M}{d}\right)\right) \cdot -0.25}\right)\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+260}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{M \cdot D}{d}\right)}^{2}}{\frac{\ell}{h}}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{t_0}{\ell} \cdot \frac{t_0}{\frac{1}{h}}}\\ \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
         (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)))))))
   (if (<= t_1 (- INFINITY))
     (* w0 (* D (sqrt (* (* (/ h l) (* (/ M d) (/ M d))) -0.25))))
     (if (<= t_1 5e+260)
       (* w0 (sqrt (- 1.0 (/ (pow (* 0.5 (/ (* M D) d)) 2.0) (/ l h)))))
       (* w0 (sqrt (- 1.0 (* (/ t_0 l) (/ t_0 (/ 1.0 h))))))))))
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 = w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = w0 * (D * sqrt((((h / l) * ((M / d) * (M / d))) * -0.25)));
	} else if (t_1 <= 5e+260) {
		tmp = w0 * sqrt((1.0 - (pow((0.5 * ((M * D) / d)), 2.0) / (l / h))));
	} else {
		tmp = w0 * sqrt((1.0 - ((t_0 / l) * (t_0 / (1.0 / h)))));
	}
	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 = w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = w0 * (D * Math.sqrt((((h / l) * ((M / d) * (M / d))) * -0.25)));
	} else if (t_1 <= 5e+260) {
		tmp = w0 * Math.sqrt((1.0 - (Math.pow((0.5 * ((M * D) / d)), 2.0) / (l / h))));
	} else {
		tmp = w0 * Math.sqrt((1.0 - ((t_0 / l) * (t_0 / (1.0 / h)))));
	}
	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 * 0.5) * (D / d)
	t_1 = w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
	tmp = 0
	if t_1 <= -math.inf:
		tmp = w0 * (D * math.sqrt((((h / l) * ((M / d) * (M / d))) * -0.25)))
	elif t_1 <= 5e+260:
		tmp = w0 * math.sqrt((1.0 - (math.pow((0.5 * ((M * D) / d)), 2.0) / (l / h))))
	else:
		tmp = w0 * math.sqrt((1.0 - ((t_0 / l) * (t_0 / (1.0 / h)))))
	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 * 0.5) * Float64(D / d))
	t_1 = Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)))))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(w0 * Float64(D * sqrt(Float64(Float64(Float64(h / l) * Float64(Float64(M / d) * Float64(M / d))) * -0.25))));
	elseif (t_1 <= 5e+260)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(0.5 * Float64(Float64(M * D) / d)) ^ 2.0) / Float64(l / h)))));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(t_0 / l) * Float64(t_0 / Float64(1.0 / h))))));
	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 * 0.5) * (D / d);
	t_1 = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l))));
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = w0 * (D * sqrt((((h / l) * ((M / d) * (M / d))) * -0.25)));
	elseif (t_1 <= 5e+260)
		tmp = w0 * sqrt((1.0 - (((0.5 * ((M * D) / d)) ^ 2.0) / (l / h))));
	else
		tmp = w0 * sqrt((1.0 - ((t_0 / l) * (t_0 / (1.0 / h)))));
	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 * 0.5), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = 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]}, If[LessEqual[t$95$1, (-Infinity)], N[(w0 * N[(D * N[Sqrt[N[(N[(N[(h / l), $MachinePrecision] * N[(N[(M / d), $MachinePrecision] * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+260], N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(0.5 * N[(N[(M * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / N[(l / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(t$95$0 / l), $MachinePrecision] * N[(t$95$0 / N[(1.0 / h), $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 := \left(M \cdot 0.5\right) \cdot \frac{D}{d}\\
t_1 := w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;w0 \cdot \left(D \cdot \sqrt{\left(\frac{h}{\ell} \cdot \left(\frac{M}{d} \cdot \frac{M}{d}\right)\right) \cdot -0.25}\right)\\

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

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{t_0}{\ell} \cdot \frac{t_0}{\frac{1}{h}}}\\


\end{array}

Error

Bits error versus w0

Bits error versus M

Bits error versus D

Bits error versus h

Bits error versus l

Bits error versus d

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if (*.f64 w0 (sqrt.f64 (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.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. Simplified61.4

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

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

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

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

    if -inf.0 < (*.f64 w0 (sqrt.f64 (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))))) < 4.9999999999999996e260

    1. Initial program 0.1

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

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

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

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

    if 4.9999999999999996e260 < (*.f64 w0 (sqrt.f64 (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)))))

    1. Initial program 53.9

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

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

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

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

    \[\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 -\infty:\\ \;\;\;\;w0 \cdot \left(D \cdot \sqrt{\left(\frac{h}{\ell} \cdot \left(\frac{M}{d} \cdot \frac{M}{d}\right)\right) \cdot -0.25}\right)\\ \mathbf{elif}\;w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq 5 \cdot 10^{+260}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{M \cdot D}{d}\right)}^{2}}{\frac{\ell}{h}}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(M \cdot 0.5\right) \cdot \frac{D}{d}}{\ell} \cdot \frac{\left(M \cdot 0.5\right) \cdot \frac{D}{d}}{\frac{1}{h}}}\\ \end{array} \]

Reproduce

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