?

Average Error: 14.3 → 8.7
Time: 19.5s
Precision: binary64
Cost: 28296

?

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

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

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


\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 (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.5

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

      [Start]64.0

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

      associate-/l* [=>]61.5

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

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

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

    if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < -5e9

    1. Initial program 0.6

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

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

      [Start]0.6

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

      associate-/l* [=>]3.7

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

    if -5e9 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))

    1. Initial program 7.0

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

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

      [Start]7.0

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

      associate-/l* [=>]6.9

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M}{\frac{\ell \cdot \left(4 \cdot \frac{d}{D}\right)}{h \cdot \left(M \cdot \frac{D}{d}\right)}}}\\ \mathbf{elif}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -5000000000:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{M}{\frac{2 \cdot d}{D}}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M}{\frac{\left(2 \cdot d\right) \cdot \frac{\ell}{h \cdot \left(\frac{M \cdot D}{d} \cdot 0.5\right)}}{D}}}\\ \end{array} \]

Alternatives

Alternative 1
Error11.7
Cost8004
\[\begin{array}{l} \mathbf{if}\;M \cdot D \leq 10^{-167}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M}{\frac{\ell \cdot \left(4 \cdot \frac{d}{D}\right)}{h \cdot \left(M \cdot \frac{D}{d}\right)}}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - h \cdot \frac{\frac{\frac{M}{\ell}}{\frac{d}{\frac{D}{4}}}}{\frac{d}{M \cdot D}}}\\ \end{array} \]
Alternative 2
Error10.8
Cost8004
\[\begin{array}{l} \mathbf{if}\;d \leq 2.8 \cdot 10^{-261}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M}{\frac{\ell \cdot \left(4 \cdot \frac{d}{D}\right)}{h \cdot \left(M \cdot \frac{D}{d}\right)}}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M}{\frac{\left(2 \cdot d\right) \cdot \frac{\ell}{0.5 \cdot \left(D \cdot \frac{h}{\frac{d}{M}}\right)}}{D}}}\\ \end{array} \]
Alternative 3
Error10.7
Cost8004
\[\begin{array}{l} \mathbf{if}\;d \leq 2 \cdot 10^{-300}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M}{\frac{\left(2 \cdot d\right) \cdot \frac{\ell}{h \cdot \left(\left(M \cdot \frac{D}{d}\right) \cdot 0.5\right)}}{D}}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{M}{\frac{\left(2 \cdot d\right) \cdot \frac{\ell}{0.5 \cdot \left(D \cdot \frac{h}{\frac{d}{M}}\right)}}{D}}}\\ \end{array} \]
Alternative 4
Error14.4
Cost7876
\[\begin{array}{l} \mathbf{if}\;M \leq -5.2 \cdot 10^{+45}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \left(\frac{D}{d \cdot \ell} \cdot \frac{D \cdot \left(M \cdot \left(M \cdot h\right)\right)}{d}\right) \cdot -0.25}\\ \end{array} \]
Alternative 5
Error11.6
Cost7876
\[\begin{array}{l} \mathbf{if}\;D \leq 1.8 \cdot 10^{+91}:\\ \;\;\;\;w0 \cdot \sqrt{1 - h \cdot \frac{M}{\ell \cdot \left(\left(4 \cdot \frac{d}{D}\right) \cdot \frac{\frac{d}{D}}{M}\right)}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \left(\frac{D}{d \cdot \ell} \cdot \frac{D \cdot \left(M \cdot \left(M \cdot h\right)\right)}{d}\right) \cdot -0.25}\\ \end{array} \]
Alternative 6
Error10.2
Cost7872
\[w0 \cdot \sqrt{1 - \frac{M}{\frac{\left(2 \cdot d\right) \cdot \frac{\ell}{h \cdot \left(\frac{M \cdot D}{d} \cdot 0.5\right)}}{D}}} \]
Alternative 7
Error14.2
Cost64
\[w0 \]

Error

Reproduce?

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