?

Average Error: 14.0 → 9.6
Time: 20.5s
Precision: binary64
Cost: 14088

?

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

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

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


\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 l < -3.69999999999999971e-275

    1. Initial program 12.6

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

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

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

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

      [Start]31.0

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

      associate-*r/ [=>]31.0

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

      *-commutative [=>]31.0

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

      associate-*r/ [<=]31.0

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

      *-commutative [=>]31.0

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

      times-frac [=>]31.2

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

      unpow2 [=>]31.2

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

      unpow2 [=>]31.2

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

      times-frac [=>]22.3

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

      *-commutative [<=]22.3

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

      unpow2 [=>]22.3

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

      associate-*l* [=>]20.2

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

      \[\leadsto w0 \cdot \sqrt{1 - 0.25 \cdot \color{blue}{\frac{\frac{D}{d} \cdot M}{\frac{d}{D} \cdot \frac{\ell}{M \cdot h}}}} \]
    6. Applied egg-rr9.1

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

    if -3.69999999999999971e-275 < l < 2e3

    1. Initial program 20.7

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

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

      [Start]20.7

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

      associate-*l/ [<=]20.7

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

      *-commutative [=>]20.7

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

      \[\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 2e3 < l

    1. Initial program 10.4

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

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

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

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

Alternatives

Alternative 1
Error8.5
Cost27784
\[\begin{array}{l} t_0 := {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}\\ t_1 := \frac{D}{d} \cdot M\\ t_2 := \ell \cdot \frac{d}{D}\\ \mathbf{if}\;t_0 \leq 10^{-196}:\\ \;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \frac{t_1}{\frac{\frac{t_2}{M}}{h}}}\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+271}:\\ \;\;\;\;w0 \cdot \sqrt{1 - t_0 \cdot \frac{h}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{t_1}{\frac{t_2}{M \cdot h}} \cdot -0.25}\\ \end{array} \]
Alternative 2
Error13.6
Cost8141
\[\begin{array}{l} \mathbf{if}\;M \leq -1.55 \cdot 10^{+31}:\\ \;\;\;\;w0\\ \mathbf{elif}\;M \leq -1 \cdot 10^{-169} \lor \neg \left(M \leq 2.9 \cdot 10^{-199}\right):\\ \;\;\;\;w0 \cdot \sqrt{1 + \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(h \cdot \frac{M}{\frac{\ell}{M}}\right)\right) \cdot -0.25}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 3
Error13.2
Cost8141
\[\begin{array}{l} \mathbf{if}\;M \leq -1 \cdot 10^{+30}:\\ \;\;\;\;w0\\ \mathbf{elif}\;M \leq -9.5 \cdot 10^{-90} \lor \neg \left(M \leq 10^{-189}\right):\\ \;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \frac{D \cdot \left(M \cdot \left(M \cdot h\right)\right)}{\frac{d}{D} \cdot \left(\ell \cdot d\right)}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 4
Error12.3
Cost8141
\[\begin{array}{l} \mathbf{if}\;M \leq -1.25 \cdot 10^{+42}:\\ \;\;\;\;w0\\ \mathbf{elif}\;M \leq -6.8 \cdot 10^{-157} \lor \neg \left(M \leq 10^{-102}\right):\\ \;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \frac{M \cdot \left(M \cdot h\right)}{\frac{d}{D} \cdot \left(\ell \cdot \frac{d}{D}\right)}}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 5
Error13.5
Cost8140
\[\begin{array}{l} t_0 := \frac{D}{d} \cdot \frac{D}{d}\\ \mathbf{if}\;M \leq -1.9 \cdot 10^{+30}:\\ \;\;\;\;w0\\ \mathbf{elif}\;M \leq -1.5 \cdot 10^{-168}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \left(t_0 \cdot \left(h \cdot \frac{M}{\frac{\ell}{M}}\right)\right) \cdot -0.25}\\ \mathbf{elif}\;M \leq 2.9 \cdot 10^{-199}:\\ \;\;\;\;w0\\ \mathbf{else}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \left(t_0 \cdot \frac{M \cdot \left(M \cdot h\right)}{\ell}\right) \cdot -0.25}\\ \end{array} \]
Alternative 6
Error11.7
Cost8004
\[\begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -4 \cdot 10^{-233}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{\frac{D}{d} \cdot M}{\frac{d}{D} \cdot \frac{\ell}{M \cdot h}} \cdot -0.25}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 7
Error11.2
Cost8004
\[\begin{array}{l} \mathbf{if}\;\frac{h}{\ell} \leq -4 \cdot 10^{-233}:\\ \;\;\;\;w0 \cdot \sqrt{1 + \frac{\frac{D}{d} \cdot M}{\frac{\ell \cdot \frac{d}{D}}{M \cdot h}} \cdot -0.25}\\ \mathbf{else}:\\ \;\;\;\;w0\\ \end{array} \]
Alternative 8
Error9.1
Cost7876
\[\begin{array}{l} \mathbf{if}\;D \leq 1.8 \cdot 10^{+68}:\\ \;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \frac{\frac{D}{d} \cdot M}{\frac{\frac{\ell \cdot \frac{d}{D}}{M}}{h}}}\\ \mathbf{else}:\\ \;\;\;\;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)}\\ \end{array} \]
Alternative 9
Error9.9
Cost7744
\[w0 \cdot \sqrt{1 - 0.25 \cdot \frac{\frac{D}{d} \cdot M}{\frac{\frac{\ell \cdot \frac{d}{D}}{M}}{h}}} \]
Alternative 10
Error13.6
Cost64
\[w0 \]

Error

Reproduce?

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