Average Error: 14.1 → 8.5
Time: 19.2s
Precision: binary64
Cost: 21188
\[ \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 := 1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\ \mathbf{if}\;t_0 \leq 2 \cdot 10^{+306}:\\ \;\;\;\;w0 \cdot \sqrt{t_0}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{M}{d}}{\frac{4}{D}} \cdot \frac{\frac{M}{d} \cdot \left(D \cdot h\right)}{\ell}}\\ \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 (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)))))
   (if (<= t_0 2e+306)
     (* w0 (sqrt t_0))
     (*
      w0
      (sqrt (- 1.0 (* (/ (/ M d) (/ 4.0 D)) (/ (* (/ M d) (* D h)) l))))))))
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 = 1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l));
	double tmp;
	if (t_0 <= 2e+306) {
		tmp = w0 * sqrt(t_0);
	} else {
		tmp = w0 * sqrt((1.0 - (((M / d) / (4.0 / D)) * (((M / d) * (D * h)) / l))));
	}
	return tmp;
}
real(8) function code(w0, m, d, h, l, d_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_1
    code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
real(8) function code(w0, m, d, h, l, d_1)
    real(8), intent (in) :: w0
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))
    if (t_0 <= 2d+306) then
        tmp = w0 * sqrt(t_0)
    else
        tmp = w0 * sqrt((1.0d0 - (((m / d_1) / (4.0d0 / d)) * (((m / d_1) * (d * h)) / l))))
    end if
    code = tmp
end function
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 = 1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l));
	double tmp;
	if (t_0 <= 2e+306) {
		tmp = w0 * Math.sqrt(t_0);
	} else {
		tmp = w0 * Math.sqrt((1.0 - (((M / d) / (4.0 / D)) * (((M / d) * (D * h)) / l))));
	}
	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 = 1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))
	tmp = 0
	if t_0 <= 2e+306:
		tmp = w0 * math.sqrt(t_0)
	else:
		tmp = w0 * math.sqrt((1.0 - (((M / d) / (4.0 / D)) * (((M / d) * (D * h)) / l))))
	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(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)))
	tmp = 0.0
	if (t_0 <= 2e+306)
		tmp = Float64(w0 * sqrt(t_0));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(M / d) / Float64(4.0 / D)) * Float64(Float64(Float64(M / d) * Float64(D * h)) / l)))));
	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 = 1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l));
	tmp = 0.0;
	if (t_0 <= 2e+306)
		tmp = w0 * sqrt(t_0);
	else
		tmp = w0 * sqrt((1.0 - (((M / d) / (4.0 / D)) * (((M / d) * (D * h)) / l))));
	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[(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]}, If[LessEqual[t$95$0, 2e+306], N[(w0 * N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(M / d), $MachinePrecision] / N[(4.0 / D), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M / d), $MachinePrecision] * N[(D * h), $MachinePrecision]), $MachinePrecision] / l), $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 := 1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t_0 \leq 2 \cdot 10^{+306}:\\
\;\;\;\;w0 \cdot \sqrt{t_0}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))) < 2.00000000000000003e306

    1. Initial program 0.3

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

    if 2.00000000000000003e306 < (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)))

    1. Initial program 63.8

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

      [Start]63.8

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

      times-frac [=>]61.8

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

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

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

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

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

Alternatives

Alternative 1
Error10.5
Cost14345
\[\begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -\infty \lor \neg \left(\frac{h}{\ell} \leq -2 \cdot 10^{+28}\right):\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{M}{d}}{\frac{4}{D}} \cdot \frac{\frac{M}{d} \cdot \left(D \cdot h\right)}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}}\\ \end{array} \]
Alternative 2
Error10.4
Cost8264
\[\begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -4 \cdot 10^{+233}:\\ \;\;\;\;w0\\ \mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-317}:\\ \;\;\;\;w0 \cdot \sqrt{1 - D \cdot \left(\frac{M}{d} \cdot \left(\left(\frac{h}{\ell} \cdot \frac{M}{d}\right) \cdot \frac{D}{4}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 3
Error10.7
Cost8264
\[\begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -1 \cdot 10^{+244}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \left(\frac{M \cdot M}{d} \cdot \frac{h}{d}\right) \cdot \left(\frac{D}{\frac{\ell}{D}} \cdot -0.25\right)}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-317}:\\ \;\;\;\;w0 \cdot \sqrt{1 - D \cdot \left(\frac{M}{d} \cdot \left(\left(\frac{h}{\ell} \cdot \frac{M}{d}\right) \cdot \frac{D}{4}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 4
Error9.8
Cost8264
\[\begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \sqrt{1 + \left(\frac{M \cdot M}{d} \cdot \frac{h}{d}\right) \cdot \left(\frac{D}{\frac{\ell}{D}} \cdot -0.25\right)}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-317}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(\frac{h}{\ell} \cdot \left(D \cdot \frac{M}{d}\right)\right) \cdot \frac{M \cdot \left(D \cdot 0.25\right)}{d}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 5
Error9.4
Cost8264
\[\begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \sqrt{1 + \left(\frac{M \cdot M}{d} \cdot \frac{h}{d}\right) \cdot \left(\frac{D}{\frac{\ell}{D}} \cdot -0.25\right)}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-317}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{M}{d}}{\frac{4}{D}} \cdot \left(\frac{h}{\ell} \cdot \left(D \cdot \frac{M}{d}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 6
Error9.1
Cost8264
\[\begin{array}{l} t_0 := \frac{\frac{M}{d}}{\frac{4}{D}}\\ \mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \sqrt{1 - t_0 \cdot \frac{\left(M \cdot D\right) \cdot h}{d \cdot \ell}}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-317}:\\ \;\;\;\;w0 \cdot \sqrt{1 - t_0 \cdot \left(\frac{h}{\ell} \cdot \left(D \cdot \frac{M}{d}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 7
Error8.9
Cost8264
\[\begin{array}{l} t_0 := \frac{\frac{M}{d}}{\frac{4}{D}}\\ \mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \sqrt{1 - t_0 \cdot \frac{\frac{M}{d} \cdot \left(D \cdot h\right)}{\ell}}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-317}:\\ \;\;\;\;w0 \cdot \sqrt{1 - t_0 \cdot \left(\frac{h}{\ell} \cdot \left(D \cdot \frac{M}{d}\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 8
Error14.1
Cost64
\[w0 \]

Error

Reproduce

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