?

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

\mathbf{elif}\;t_0 \leq 0.2:\\
\;\;\;\;w0 \cdot \sqrt{1 - t_0}\\

\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 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < -inf.0

    1. Initial program 0.0%

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

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

      [Start]0.0

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

      associate-*l/ [<=]3.2

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

      *-commutative [=>]3.2

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

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

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

      [Start]3.2

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

      +-rgt-identity [=>]3.2

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

      associate-*r/ [=>]9.6

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

      associate-*l/ [<=]9.6

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

      *-commutative [=>]9.6

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

      associate-*r* [=>]9.6

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

      associate-*l/ [=>]7.8

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

      *-commutative [<=]7.8

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

      metadata-eval [<=]7.8

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

      times-frac [<=]7.8

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

      neg-mul-1 [<=]7.8

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

      distribute-rgt-neg-in [=>]7.8

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

      *-commutative [<=]7.8

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

      associate-/l* [=>]10.0

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

      *-commutative [=>]10.0

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

      neg-mul-1 [=>]10.0

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

      times-frac [=>]10.0

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

      metadata-eval [=>]10.0

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

      associate-*r/ [=>]10.0

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

      associate-/l* [<=]7.8

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

      times-frac [=>]10.1

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

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

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

    1. Initial program 99.8%

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

    if 0.20000000000000001 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))

    1. Initial program 0.6%

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

      \[\leadsto \color{blue}{w0 \cdot \sqrt{1 - {\left(D \cdot \frac{M}{2 \cdot 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/ [<=]5.0

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

      *-commutative [=>]5.0

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

      \[\leadsto \color{blue}{w0} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification86.6%

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

Alternatives

Alternative 1
Accuracy81.9%
Cost8272
\[\begin{array}{l} t_0 := M \cdot \left(D \cdot \frac{M}{d}\right)\\ t_1 := w0 \cdot \sqrt{1 - \frac{t_0}{\frac{\frac{\ell \cdot \left(d \cdot 4\right)}{h}}{D}}}\\ \mathbf{if}\;d \leq -1 \cdot 10^{+129}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq -1100000000000:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{\left(M \cdot D\right) \cdot \left(h \cdot \left(M \cdot D\right)\right)}{d \cdot \left(d \cdot \ell\right)} \cdot -0.25}\\ \mathbf{elif}\;d \leq 4.5 \cdot 10^{-189}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{t_0}{\left(d \cdot 4\right) \cdot \frac{\ell}{D \cdot h}}}\\ \mathbf{elif}\;d \leq 6 \cdot 10^{+151}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{D \cdot \left(M \cdot h\right)}{\ell} \cdot \left(\frac{M}{d} \cdot \frac{D}{d \cdot 4}\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Accuracy82.9%
Cost8264
\[\begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -1 \cdot 10^{+285}:\\ \;\;\;\;w0\\ \mathbf{elif}\;\frac{h}{\ell} \leq -1 \cdot 10^{-280}:\\ \;\;\;\;w0 \cdot \sqrt{1 - M \cdot \left(\left(D \cdot \frac{M}{d}\right) \cdot \frac{\frac{D}{\frac{\ell}{h}}}{d \cdot 4}\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 3
Accuracy84.7%
Cost8137
\[\begin{array}{l} t_0 := 2 \cdot \frac{d}{M}\\ \mathbf{if}\;h \leq -1 \cdot 10^{-256} \lor \neg \left(h \leq 6 \cdot 10^{-184}\right):\\ \;\;\;\;w0 \cdot \sqrt{1 - h \cdot \left(\frac{D}{\ell \cdot t_0} \cdot \frac{D}{t_0}\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(M \cdot \left(D \cdot \frac{h}{\ell}\right)\right) \cdot \left(M \cdot \left(D \cdot \frac{0.25}{d}\right)\right)}{d}}\\ \end{array} \]
Alternative 4
Accuracy79.7%
Cost8008
\[\begin{array}{l} \mathbf{if}\;d \leq 3.45 \cdot 10^{-96}:\\ \;\;\;\;w0\\ \mathbf{elif}\;d \leq 6.5 \cdot 10^{+140}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{\left(M \cdot D\right) \cdot \left(h \cdot \left(M \cdot D\right)\right)}{d \cdot \left(d \cdot \ell\right)} \cdot -0.25}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 5
Accuracy78.9%
Cost64
\[w0 \]

Error

Reproduce?

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