?

Average Error: 14.1 → 9.6
Time: 59.8s
Precision: binary64
Cost: 14344

?

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

\mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-231}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}}{4}}\\

\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.0000000000000001e256

    1. Initial program 50.6

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

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

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

      [Start]50.6

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

      rational_best-simplify-3 [<=]50.6

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

      rational_best-simplify-6 [=>]50.6

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

      rational_best-simplify-55 [=>]24.0

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

      rational_best-simplify-1 [=>]24.0

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

      rational_best-simplify-1 [<=]24.0

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

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

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

      [Start]50.5

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

      rational_best-simplify-3 [=>]50.5

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

      rational_best-simplify-6 [=>]50.5

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

      rational_best-simplify-1 [=>]50.5

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

      metadata-eval [<=]50.5

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

      rational_best-simplify-54 [<=]50.5

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

      rational_best-simplify-1 [<=]50.5

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

      rational_best-simplify-50 [=>]24.0

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

      rational_best-simplify-1 [=>]24.0

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

      rational_best-simplify-54 [=>]24.0

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

      rational_best-simplify-49 [=>]24.0

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

      metadata-eval [=>]24.0

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

    if -4.0000000000000001e256 < (/.f64 h l) < -2e-231

    1. Initial program 14.5

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

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

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

      [Start]14.5

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

      rational_best-simplify-3 [<=]14.5

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

      rational_best-simplify-6 [=>]14.5

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

      rational_best-simplify-55 [=>]15.8

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

      rational_best-simplify-1 [=>]15.8

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

      rational_best-simplify-1 [<=]15.8

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

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

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

    if -2e-231 < (/.f64 h l)

    1. Initial program 8.4

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

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

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

Alternatives

Alternative 1
Error10.9
Cost13824
\[w0 \cdot \sqrt{1 - h \cdot \left({\left(\frac{D \cdot M}{d}\right)}^{2} \cdot \frac{0.25}{\ell}\right)} \]
Alternative 2
Error10.9
Cost13824
\[w0 \cdot \sqrt{1 - h \cdot \frac{0.25 \cdot {\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}} \]
Alternative 3
Error14.0
Cost64
\[w0 \]

Error

Reproduce?

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