?

Average Accuracy: 67.3% → 74.5%
Time: 15.8s
Precision: binary64
Cost: 8392

?

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

\mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-315}:\\
\;\;\;\;w0 \cdot \sqrt{1 - t_0 \cdot \left(t_0 \cdot \frac{h}{\ell}\right)}\\

\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 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. Applied egg-rr35.4%

      \[\leadsto w0 \cdot \sqrt{1 - \color{blue}{\frac{{\left(M \cdot \left(D \cdot \frac{0.5}{d}\right)\right)}^{2} \cdot 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-*r/ [=>]35.7

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

      div-inv [=>]35.7

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

      associate-*l* [=>]35.4

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

      associate-/r* [=>]35.4

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

      metadata-eval [=>]35.4

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

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

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

      [Start]24.8

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

      associate-*r* [=>]27.7

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

      unpow2 [=>]27.7

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

      times-frac [=>]27.0

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

      unpow2 [=>]27.0

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

      unpow2 [=>]27.0

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

      unswap-sqr [=>]32.6

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

    if -inf.0 < (/.f64 h l) < -2.0000000019e-315

    1. Initial program 62.0%

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

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

      [Start]62.0

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

      clear-num [=>]61.9

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

      un-div-inv [=>]62.0

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

      div-inv [=>]61.9

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

      associate-*l* [=>]61.8

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

      associate-/r* [=>]61.8

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

      metadata-eval [=>]61.8

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

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

      [Start]61.8

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

      div-inv [=>]61.8

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

      unpow2 [=>]61.8

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

      clear-num [<=]61.8

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

      associate-*l* [=>]64.4

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

    if -2.0000000019e-315 < (/.f64 h l)

    1. Initial program 86.5%

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

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

      [Start]86.5

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

      associate-/l* [=>]86.7

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

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

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

Alternatives

Alternative 1
Accuracy68.8%
Cost8008
\[\begin{array}{l} \mathbf{if}\;\ell \leq -1.7 \cdot 10^{-233}:\\ \;\;\;\;w0\\ \mathbf{elif}\;\ell \leq 3.3 \cdot 10^{-127}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{0.25 \cdot \left(\frac{\left(M \cdot D\right) \cdot \left(M \cdot D\right)}{d} \cdot \frac{h}{d}\right)}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 2
Accuracy74.5%
Cost8000
\[\begin{array}{l} t_0 := M \cdot \left(D \cdot \frac{0.5}{d}\right)\\ w0 \cdot \sqrt{1 - \frac{t_0}{\ell} \cdot \frac{t_0}{\frac{1}{h}}} \end{array} \]
Alternative 3
Accuracy68.3%
Cost64
\[w0 \]

Error

Reproduce?

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