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

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

\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;w0 \cdot \left(M \cdot \left(-\sqrt{-0.25 \cdot \left(\frac{h}{\ell} \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)}\right)\right)\\

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


\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 4 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. Simplified62.0

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

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

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

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

    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}}} \]

    if 1.6820622892440524e307 < (*.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 63.4

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

      \[\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.2

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

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

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

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

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

    1. Initial program 64.0

      \[w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \]
    2. Simplified60.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-rr23.6

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

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

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

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

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

Reproduce

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