?

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

\mathbf{elif}\;t_0 \leq 0.0005:\\
\;\;\;\;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.8%

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

      times-frac [=>]3.8

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

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

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

      [Start]2.8

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

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\mathsf{hypot}\left(1, \sqrt{\frac{-0.25 \cdot D}{\frac{\frac{\ell}{h}}{D}}} \cdot \frac{M}{d}\right)\right)} - 1\right)} \cdot w0 \]
    6. Simplified36.6%

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

      [Start]29.1

      \[ \left(e^{\mathsf{log1p}\left(\mathsf{hypot}\left(1, \sqrt{\frac{-0.25 \cdot D}{\frac{\frac{\ell}{h}}{D}}} \cdot \frac{M}{d}\right)\right)} - 1\right) \cdot w0 \]

      expm1-def [=>]29.1

      \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{hypot}\left(1, \sqrt{\frac{-0.25 \cdot D}{\frac{\frac{\ell}{h}}{D}}} \cdot \frac{M}{d}\right)\right)\right)} \cdot w0 \]

      expm1-log1p [=>]31.7

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

      *-commutative [=>]31.7

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

      associate-/r/ [=>]31.7

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

      *-commutative [=>]31.7

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

      associate-/r/ [=>]36.6

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

      *-commutative [=>]36.6

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

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

    1. Initial program 99.8%

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

    if 5.0000000000000001e-4 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))

    1. Initial program 0.9%

      \[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}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}} \]
      Proof

      [Start]0.9

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

      times-frac [=>]6.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\ \;\;\;\;\mathsf{hypot}\left(1, \frac{M}{d} \cdot \sqrt{D \cdot \left(h \cdot \frac{D \cdot -0.25}{\ell}\right)}\right) \cdot w0\\ \mathbf{elif}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq 0.0005:\\ \;\;\;\;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
Accuracy85.9%
Cost27784
\[\begin{array}{l} t_0 := {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\\ \mathbf{if}\;t_0 \leq 0:\\ \;\;\;\;w0\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{+286}:\\ \;\;\;\;w0 \cdot \sqrt{1 - t_0 \cdot \frac{h}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \frac{D}{\left(d \cdot \frac{d}{M}\right) \cdot \frac{\frac{\ell}{D \cdot h}}{M}}}\\ \end{array} \]
Alternative 2
Accuracy84.4%
Cost14344
\[\begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{-0.25 \cdot \left(D \cdot D\right)}{\ell \cdot \left(\frac{d}{M} \cdot \frac{d}{M \cdot h}\right)}}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -5 \cdot 10^{-194}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\left(M \cdot D\right) \cdot \frac{0.5}{d}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 3
Accuracy83.0%
Cost14344
\[\begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{-0.25 \cdot \left(D \cdot D\right)}{\ell \cdot \left(\frac{d}{M} \cdot \frac{d}{M \cdot h}\right)}}\\ \mathbf{elif}\;\frac{h}{\ell} \leq 2 \cdot 10^{-282}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 4
Accuracy79.8%
Cost8524
\[\begin{array}{l} t_0 := d \cdot \frac{d}{M}\\ \mathbf{if}\;\frac{h}{\ell} \leq -5 \cdot 10^{+122}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \frac{D}{t_0 \cdot \frac{\frac{\ell}{D}}{M \cdot h}}}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -1 \cdot 10^{-26}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \frac{D}{\frac{\frac{\ell}{h}}{D} \cdot \left(\frac{d}{M} \cdot \frac{d}{M}\right)}}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -1 \cdot 10^{-181}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \frac{D}{t_0 \cdot \frac{\frac{\ell}{D \cdot h}}{M}}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 5
Accuracy80.2%
Cost8264
\[\begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -2 \cdot 10^{+296}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{-0.25}{\frac{d \cdot \left(d \cdot \ell\right)}{h \cdot \left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right)}}}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -1 \cdot 10^{-181}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \frac{M \cdot D}{\frac{d}{\frac{M}{d}} \cdot \frac{\frac{\ell}{h}}{D}}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 6
Accuracy80.3%
Cost8264
\[\begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -5 \cdot 10^{+234}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{-0.25 \cdot \left(D \cdot D\right)}{\ell \cdot \left(\frac{d}{M} \cdot \frac{d}{M \cdot h}\right)}}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -1 \cdot 10^{-181}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \frac{M \cdot D}{\frac{d}{\frac{M}{d}} \cdot \frac{\frac{\ell}{h}}{D}}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 7
Accuracy76.5%
Cost8140
\[\begin{array}{l} t_0 := d \cdot \frac{d}{M}\\ \mathbf{if}\;D \leq 5 \cdot 10^{-128}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \frac{D}{t_0 \cdot \frac{\frac{\ell}{D \cdot h}}{M}}}\\ \mathbf{elif}\;D \leq 5 \cdot 10^{+27}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \frac{D \cdot \left(D \cdot h\right)}{\ell \cdot \left(\frac{d}{M} \cdot \frac{d}{M}\right)}}\\ \mathbf{elif}\;D \leq 4.2 \cdot 10^{+79}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \frac{D}{t_0 \cdot \frac{\frac{\ell}{D}}{M \cdot h}}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 8
Accuracy78.4%
Cost8008
\[\begin{array}{l} \mathbf{if}\;d \leq -5 \cdot 10^{+185}:\\ \;\;\;\;w0\\ \mathbf{elif}\;d \leq -5 \cdot 10^{+31}:\\ \;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \frac{D}{\left(d \cdot \frac{d}{M}\right) \cdot \frac{\frac{\ell}{D}}{M \cdot h}}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 9
Accuracy78.5%
Cost64
\[w0 \]

Error

Reproduce?

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