?

Average Error: 14.6 → 9.8
Time: 15.4s
Precision: binary64
Cost: 14345

?

\[ \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 -5 \cdot 10^{+24} \lor \neg \left(\frac{h}{\ell} \leq 0\right):\\ \;\;\;\;w0 \cdot \sqrt{1 - h \cdot \frac{{\left(\frac{M}{\frac{d}{D \cdot 0.5}}\right)}^{2}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{D}{\frac{d}{M}}}{\frac{\frac{\frac{\frac{\ell}{h}}{M}}{D}}{\frac{0.25}{d}}}}\\ \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 (or (<= (/ h l) -5e+24) (not (<= (/ h l) 0.0)))
   (* w0 (sqrt (- 1.0 (* h (/ (pow (/ M (/ d (* D 0.5))) 2.0) l)))))
   (* w0 (sqrt (- 1.0 (/ (/ D (/ d M)) (/ (/ (/ (/ l h) M) D) (/ 0.25 d))))))))
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) <= -5e+24) || !((h / l) <= 0.0)) {
		tmp = w0 * sqrt((1.0 - (h * (pow((M / (d / (D * 0.5))), 2.0) / l))));
	} else {
		tmp = w0 * sqrt((1.0 - ((D / (d / M)) / ((((l / h) / M) / D) / (0.25 / d)))));
	}
	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) <= (-5d+24)) .or. (.not. ((h / l) <= 0.0d0))) then
        tmp = w0 * sqrt((1.0d0 - (h * (((m / (d_1 / (d * 0.5d0))) ** 2.0d0) / l))))
    else
        tmp = w0 * sqrt((1.0d0 - ((d / (d_1 / m)) / ((((l / h) / m) / d) / (0.25d0 / d_1)))))
    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) <= -5e+24) || !((h / l) <= 0.0)) {
		tmp = w0 * Math.sqrt((1.0 - (h * (Math.pow((M / (d / (D * 0.5))), 2.0) / l))));
	} else {
		tmp = w0 * Math.sqrt((1.0 - ((D / (d / M)) / ((((l / h) / M) / D) / (0.25 / d)))));
	}
	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) <= -5e+24) or not ((h / l) <= 0.0):
		tmp = w0 * math.sqrt((1.0 - (h * (math.pow((M / (d / (D * 0.5))), 2.0) / l))))
	else:
		tmp = w0 * math.sqrt((1.0 - ((D / (d / M)) / ((((l / h) / M) / D) / (0.25 / d)))))
	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) <= -5e+24) || !(Float64(h / l) <= 0.0))
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64((Float64(M / Float64(d / Float64(D * 0.5))) ^ 2.0) / l)))));
	else
		tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(D / Float64(d / M)) / Float64(Float64(Float64(Float64(l / h) / M) / D) / Float64(0.25 / d))))));
	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) <= -5e+24) || ~(((h / l) <= 0.0)))
		tmp = w0 * sqrt((1.0 - (h * (((M / (d / (D * 0.5))) ^ 2.0) / l))));
	else
		tmp = w0 * sqrt((1.0 - ((D / (d / M)) / ((((l / h) / M) / D) / (0.25 / d)))));
	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[Or[LessEqual[N[(h / l), $MachinePrecision], -5e+24], N[Not[LessEqual[N[(h / l), $MachinePrecision], 0.0]], $MachinePrecision]], N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(N[Power[N[(M / N[(d / N[(D * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(D / N[(d / M), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(N[(l / h), $MachinePrecision] / M), $MachinePrecision] / D), $MachinePrecision] / N[(0.25 / d), $MachinePrecision]), $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}
\mathbf{if}\;\frac{h}{\ell} \leq -5 \cdot 10^{+24} \lor \neg \left(\frac{h}{\ell} \leq 0\right):\\
\;\;\;\;w0 \cdot \sqrt{1 - h \cdot \frac{{\left(\frac{M}{\frac{d}{D \cdot 0.5}}\right)}^{2}}{\ell}}\\

\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{D}{\frac{d}{M}}}{\frac{\frac{\frac{\frac{\ell}{h}}{M}}{D}}{\frac{0.25}{d}}}}\\


\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 h l) < -5.00000000000000045e24 or -0.0 < (/.f64 h l)

    1. Initial program 14.6

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

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

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

      [Start]14.6

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

      +-rgt-identity [=>]14.6

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

      associate-*r/ [=>]8.5

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

      associate-*l/ [<=]8.6

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

      *-commutative [=>]8.6

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

      associate-*r* [=>]8.6

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

      associate-*r/ [=>]8.5

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

      associate-*l* [=>]8.5

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

      *-commutative [=>]8.5

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

      associate-/l* [=>]8.5

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

    if -5.00000000000000045e24 < (/.f64 h l) < -0.0

    1. Initial program 14.6

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

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

      [Start]14.6

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

      associate-*l/ [<=]14.5

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

      *-commutative [=>]14.5

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

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

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

      [Start]24.5

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

      times-frac [=>]20.0

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

      *-commutative [=>]20.0

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

      associate-/l* [=>]20.2

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

      *-commutative [=>]20.2

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

      associate-*l* [=>]20.2

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

      times-frac [=>]14.6

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

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

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

      [Start]15.7

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

      +-rgt-identity [=>]15.7

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

      associate-*r/ [=>]16.8

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

      *-commutative [=>]16.8

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

      associate-*r/ [=>]17.7

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

      associate-*l/ [<=]17.3

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

      *-commutative [=>]17.3

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

      associate-/l* [=>]16.7

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

      associate-/r/ [<=]16.2

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

      associate-/r* [<=]16.2

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

      associate-*r* [=>]15.6

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

      *-commutative [<=]15.6

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

      associate-/l* [=>]13.3

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

      associate-*r/ [=>]13.4

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

      associate-/l* [=>]13.1

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

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

Alternatives

Alternative 1
Error14.2
Cost8140
\[\begin{array}{l} t_0 := w0 \cdot \sqrt{1 - \left(h \cdot \frac{M}{\ell}\right) \cdot \frac{M \cdot \frac{D \cdot 0.25}{d}}{\frac{d}{D}}}\\ \mathbf{if}\;h \leq -5 \cdot 10^{-159}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;h \leq 1.55 \cdot 10^{-35}:\\ \;\;\;\;w0\\ \mathbf{elif}\;h \leq 2.05 \cdot 10^{+121}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{\left(M \cdot D\right) \cdot \left(h \cdot \left(M \cdot D\right)\right)}{d \cdot \left(\ell \cdot d\right)} \cdot -0.25}\\ \end{array} \]
Alternative 2
Error15.0
Cost8008
\[\begin{array}{l} \mathbf{if}\;w0 \leq 1.45 \cdot 10^{-164}:\\ \;\;\;\;w0\\ \mathbf{elif}\;w0 \leq 8 \cdot 10^{+95}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{\left(M \cdot D\right) \cdot \left(h \cdot \left(M \cdot D\right)\right)}{d \cdot \left(\ell \cdot d\right)} \cdot -0.25}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 3
Error12.8
Cost7744
\[w0 \cdot \sqrt{1 - \frac{D \cdot \frac{M}{d}}{4 \cdot \left(d \cdot \frac{\ell}{h \cdot \left(M \cdot D\right)}\right)}} \]
Alternative 4
Error14.1
Cost64
\[w0 \]

Error

Reproduce?

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