?

Average Error: 14.1 → 9.0
Time: 22.4s
Precision: binary64
Cost: 14084

?

\[ \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 := \frac{D}{d} \cdot \left(M \cdot 0.5\right)\\ \mathbf{if}\;\frac{h}{\ell} \leq -5 \cdot 10^{+211}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {t_0}^{2}}{\ell}}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-275}:\\ \;\;\;\;w0 \cdot \sqrt{1 - t_0 \cdot \frac{t_0}{\frac{\ell}{h}}}\\ \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 (* (/ D d) (* M 0.5))))
   (if (<= (/ h l) -5e+211)
     (* w0 (sqrt (- 1.0 (/ (* h (pow t_0 2.0)) l))))
     (if (<= (/ h l) -2e-275)
       (* w0 (sqrt (- 1.0 (* t_0 (/ t_0 (/ l h))))))
       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 = (D / d) * (M * 0.5);
	double tmp;
	if ((h / l) <= -5e+211) {
		tmp = w0 * sqrt((1.0 - ((h * pow(t_0, 2.0)) / l)));
	} else if ((h / l) <= -2e-275) {
		tmp = w0 * sqrt((1.0 - (t_0 * (t_0 / (l / h)))));
	} else {
		tmp = w0;
	}
	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 = (d / d_1) * (m * 0.5d0)
    if ((h / l) <= (-5d+211)) then
        tmp = w0 * sqrt((1.0d0 - ((h * (t_0 ** 2.0d0)) / l)))
    else if ((h / l) <= (-2d-275)) then
        tmp = w0 * sqrt((1.0d0 - (t_0 * (t_0 / (l / h)))))
    else
        tmp = w0
    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 = (D / d) * (M * 0.5);
	double tmp;
	if ((h / l) <= -5e+211) {
		tmp = w0 * Math.sqrt((1.0 - ((h * Math.pow(t_0, 2.0)) / l)));
	} else if ((h / l) <= -2e-275) {
		tmp = w0 * Math.sqrt((1.0 - (t_0 * (t_0 / (l / h)))));
	} 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 = (D / d) * (M * 0.5)
	tmp = 0
	if (h / l) <= -5e+211:
		tmp = w0 * math.sqrt((1.0 - ((h * math.pow(t_0, 2.0)) / l)))
	elif (h / l) <= -2e-275:
		tmp = w0 * math.sqrt((1.0 - (t_0 * (t_0 / (l / h)))))
	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(D / d) * Float64(M * 0.5))
	tmp = 0.0
	if (Float64(h / l) <= -5e+211)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (t_0 ^ 2.0)) / l))));
	elseif (Float64(h / l) <= -2e-275)
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(t_0 * Float64(t_0 / Float64(l / h))))));
	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 = (D / d) * (M * 0.5);
	tmp = 0.0;
	if ((h / l) <= -5e+211)
		tmp = w0 * sqrt((1.0 - ((h * (t_0 ^ 2.0)) / l)));
	elseif ((h / l) <= -2e-275)
		tmp = w0 * sqrt((1.0 - (t_0 * (t_0 / (l / h)))));
	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[(D / d), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(h / l), $MachinePrecision], -5e+211], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(h / l), $MachinePrecision], -2e-275], N[(w0 * N[Sqrt[N[(1.0 - N[(t$95$0 * N[(t$95$0 / N[(l / h), $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 := \frac{D}{d} \cdot \left(M \cdot 0.5\right)\\
\mathbf{if}\;\frac{h}{\ell} \leq -5 \cdot 10^{+211}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {t_0}^{2}}{\ell}}\\

\mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-275}:\\
\;\;\;\;w0 \cdot \sqrt{1 - t_0 \cdot \frac{t_0}{\frac{\ell}{h}}}\\

\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) < -4.9999999999999995e211

    1. Initial program 42.6

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

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

      [Start]42.6

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

      associate-*l/ [<=]42.9

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

      *-commutative [=>]42.9

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

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

    if -4.9999999999999995e211 < (/.f64 h l) < -1.99999999999999987e-275

    1. Initial program 14.4

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

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

      [Start]14.4

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

      associate-*l/ [<=]14.8

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

      *-commutative [=>]14.8

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

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

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

    if -1.99999999999999987e-275 < (/.f64 h l)

    1. Initial program 7.7

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

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

      [Start]7.7

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

      associate-*l/ [<=]7.7

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

      *-commutative [=>]7.7

      \[ 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 3.2

      \[\leadsto \color{blue}{w0} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification9.0

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

Alternatives

Alternative 1
Error8.5
Cost21188
\[\begin{array}{l} t_0 := 1 - \frac{h}{\ell} \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}\\ \mathbf{if}\;t_0 \leq 2 \cdot 10^{+286}:\\ \;\;\;\;w0 \cdot \sqrt{t_0}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \left(h \cdot \frac{\frac{D}{d}}{\frac{\ell}{M \cdot 0.5}}\right)}\\ \end{array} \]
Alternative 2
Error9.0
Cost8392
\[\begin{array}{l} t_0 := \frac{D}{d} \cdot \left(M \cdot 0.5\right)\\ \mathbf{if}\;\frac{h}{\ell} \leq -\infty:\\ \;\;\;\;w0 \cdot \sqrt{1 - h \cdot \frac{M \cdot \left(M \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}{\ell \cdot \left(2 \cdot \frac{d}{D}\right)}}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-275}:\\ \;\;\;\;w0 \cdot \sqrt{1 - t_0 \cdot \frac{t_0}{\frac{\ell}{h}}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 3
Error11.0
Cost8269
\[\begin{array}{l} \mathbf{if}\;M \leq -2.1 \cdot 10^{+77}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(D \cdot M\right) \cdot \frac{D \cdot M}{\left(\frac{\ell}{h} \cdot 4\right) \cdot \left(d \cdot d\right)}}\\ \mathbf{elif}\;M \leq -4 \cdot 10^{-184} \lor \neg \left(M \leq 1.45 \cdot 10^{-225}\right):\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \left(h \cdot \frac{\frac{D}{d}}{\frac{\ell}{M \cdot 0.5}}\right)}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + h \cdot \frac{\frac{D \cdot M}{\frac{-4}{\frac{\frac{D \cdot M}{d}}{d}}}}{\ell}}\\ \end{array} \]
Alternative 4
Error10.5
Cost8268
\[\begin{array}{l} \mathbf{if}\;M \leq -7.8 \cdot 10^{+178}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(D \cdot M\right) \cdot \frac{D \cdot M}{\left(\frac{\ell}{h} \cdot 4\right) \cdot \left(d \cdot d\right)}}\\ \mathbf{elif}\;M \leq -5 \cdot 10^{-86}:\\ \;\;\;\;w0 \cdot \sqrt{1 - h \cdot \frac{M \cdot \left(M \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}{\ell \cdot \left(2 \cdot \frac{d}{D}\right)}}\\ \mathbf{elif}\;M \leq 1.5 \cdot 10^{-225}:\\ \;\;\;\;w0 \cdot \sqrt{1 + h \cdot \frac{\frac{D \cdot M}{\frac{-4}{\frac{\frac{D \cdot M}{d}}{d}}}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \left(h \cdot \frac{\frac{D}{d}}{\frac{\ell}{M \cdot 0.5}}\right)}\\ \end{array} \]
Alternative 5
Error11.5
Cost8264
\[\begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -5 \cdot 10^{-36}:\\ \;\;\;\;w0 \cdot \sqrt{1 + h \cdot \frac{\frac{D \cdot M}{\frac{-4}{\frac{\frac{D}{d} \cdot M}{d}}}}{\ell}}\\ \mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-275}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{\frac{d}{\frac{\frac{\frac{h}{\ell}}{4}}{d}}}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 6
Error13.6
Cost8140
\[\begin{array}{l} t_0 := \frac{M \cdot M}{d}\\ \mathbf{if}\;M \leq -4 \cdot 10^{+149}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \left(D \cdot M\right) \cdot \frac{D \cdot M}{\left(\frac{\ell}{h} \cdot 4\right) \cdot \left(d \cdot d\right)}}\\ \mathbf{elif}\;M \leq -2 \cdot 10^{-132}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{D \cdot t_0}{\frac{d}{h \cdot D}} \cdot \frac{-0.25}{\ell}}\\ \mathbf{elif}\;M \leq 1.1 \cdot 10^{-68}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \left(t_0 \cdot \frac{D \cdot \left(h \cdot D\right)}{d}\right) \cdot \frac{-0.25}{\ell}}\\ \end{array} \]
Alternative 7
Error13.9
Cost8009
\[\begin{array}{l} \mathbf{if}\;d \leq -9.8 \cdot 10^{-154} \lor \neg \left(d \leq 1.95 \cdot 10^{-40}\right):\\ \;\;\;\;w0 \cdot \sqrt{1 - h \cdot \frac{\left(D \cdot M\right) \cdot \left(0.25 \cdot \frac{D \cdot M}{d \cdot d}\right)}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{D \cdot \left(D \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)}{d} \cdot \frac{\frac{-0.25}{\ell}}{d}}\\ \end{array} \]
Alternative 8
Error14.1
Cost8008
\[\begin{array}{l} \mathbf{if}\;M \leq -2.12 \cdot 10^{+133}:\\ \;\;\;\;w0\\ \mathbf{elif}\;M \leq -1.15 \cdot 10^{-9}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \left(\frac{M \cdot M}{d} \cdot \frac{D \cdot \left(h \cdot D\right)}{d}\right) \cdot \frac{-0.25}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 9
Error13.5
Cost8008
\[\begin{array}{l} \mathbf{if}\;M \leq -4 \cdot 10^{-184}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{D \cdot M}{\frac{d}{h \cdot D} \cdot \frac{d}{M}} \cdot \frac{-0.25}{\ell}}\\ \mathbf{elif}\;M \leq 6.5 \cdot 10^{-70}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \left(\frac{M \cdot M}{d} \cdot \frac{D \cdot \left(h \cdot D\right)}{d}\right) \cdot \frac{-0.25}{\ell}}\\ \end{array} \]
Alternative 10
Error14.1
Cost64
\[w0 \]

Error

Reproduce?

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