| Alternative 1 | |
|---|---|
| Error | 10.3 |
| Cost | 8264 |
(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 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))
(if (<= t_0 (- INFINITY))
(* w0 (sqrt (- 1.0 (/ (/ (* h (/ M d)) (/ l D)) (* (/ 4.0 D) (/ d M))))))
(if (<= t_0 1e-29)
(* w0 (sqrt (- 1.0 t_0)))
(*
w0
(sqrt
(+ 1.0 (* (* (/ D d) (/ D d)) (* (/ (* M (* M h)) l) -0.25)))))))))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 = pow(((M * D) / (2.0 * d)), 2.0) * (h / l);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = w0 * sqrt((1.0 - (((h * (M / d)) / (l / D)) / ((4.0 / D) * (d / M)))));
} else if (t_0 <= 1e-29) {
tmp = w0 * sqrt((1.0 - t_0));
} else {
tmp = w0 * sqrt((1.0 + (((D / d) * (D / d)) * (((M * (M * h)) / l) * -0.25))));
}
return tmp;
}
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 = Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = w0 * Math.sqrt((1.0 - (((h * (M / d)) / (l / D)) / ((4.0 / D) * (d / M)))));
} else if (t_0 <= 1e-29) {
tmp = w0 * Math.sqrt((1.0 - t_0));
} else {
tmp = w0 * Math.sqrt((1.0 + (((D / d) * (D / d)) * (((M * (M * h)) / l) * -0.25))));
}
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 = math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l) tmp = 0 if t_0 <= -math.inf: tmp = w0 * math.sqrt((1.0 - (((h * (M / d)) / (l / D)) / ((4.0 / D) * (d / M))))) elif t_0 <= 1e-29: tmp = w0 * math.sqrt((1.0 - t_0)) else: tmp = w0 * math.sqrt((1.0 + (((D / d) * (D / d)) * (((M * (M * h)) / l) * -0.25)))) 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(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(h * Float64(M / d)) / Float64(l / D)) / Float64(Float64(4.0 / D) * Float64(d / M)))))); elseif (t_0 <= 1e-29) tmp = Float64(w0 * sqrt(Float64(1.0 - t_0))); else tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(Float64(D / d) * Float64(D / d)) * Float64(Float64(Float64(M * Float64(M * h)) / l) * -0.25))))); 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 = (((M * D) / (2.0 * d)) ^ 2.0) * (h / l); tmp = 0.0; if (t_0 <= -Inf) tmp = w0 * sqrt((1.0 - (((h * (M / d)) / (l / D)) / ((4.0 / D) * (d / M))))); elseif (t_0 <= 1e-29) tmp = w0 * sqrt((1.0 - t_0)); else tmp = w0 * sqrt((1.0 + (((D / d) * (D / d)) * (((M * (M * h)) / l) * -0.25)))); 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[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(h * N[(M / d), $MachinePrecision]), $MachinePrecision] / N[(l / D), $MachinePrecision]), $MachinePrecision] / N[(N[(4.0 / D), $MachinePrecision] * N[(d / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e-29], N[(w0 * N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 + N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M * N[(M * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * -0.25), $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 := {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{h \cdot \frac{M}{d}}{\frac{\ell}{D}}}{\frac{4}{D} \cdot \frac{d}{M}}}\\
\mathbf{elif}\;t_0 \leq 10^{-29}:\\
\;\;\;\;w0 \cdot \sqrt{1 - t_0}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 + \left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(\frac{M \cdot \left(M \cdot h\right)}{\ell} \cdot -0.25\right)}\\
\end{array}
Results
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < -inf.0Initial program 64.0
Simplified62.1
[Start]64.0 | \[ w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\] |
|---|---|
times-frac [=>]62.1 | \[ w0 \cdot \sqrt{1 - {\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}}
\] |
Applied egg-rr60.4
Applied egg-rr64.0
Simplified55.1
[Start]64.0 | \[ w0 \cdot \sqrt{1 - \left(\frac{h}{\ell} \cdot \frac{\left(D \cdot 0.5\right) \cdot \frac{\left(M \cdot D\right) \cdot M}{d}}{d \cdot 2} + 0\right)}
\] |
|---|---|
+-rgt-identity [=>]64.0 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{h}{\ell} \cdot \frac{\left(D \cdot 0.5\right) \cdot \frac{\left(M \cdot D\right) \cdot M}{d}}{d \cdot 2}}}
\] |
*-commutative [=>]64.0 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(D \cdot 0.5\right) \cdot \frac{\left(M \cdot D\right) \cdot M}{d}}{d \cdot 2} \cdot \frac{h}{\ell}}}
\] |
associate-/r* [=>]64.0 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{\frac{\left(D \cdot 0.5\right) \cdot \frac{\left(M \cdot D\right) \cdot M}{d}}{d}}{2}} \cdot \frac{h}{\ell}}
\] |
associate-*r/ [=>]63.9 | \[ w0 \cdot \sqrt{1 - \frac{\frac{\color{blue}{\frac{\left(D \cdot 0.5\right) \cdot \left(\left(M \cdot D\right) \cdot M\right)}{d}}}{d}}{2} \cdot \frac{h}{\ell}}
\] |
*-commutative [=>]63.9 | \[ w0 \cdot \sqrt{1 - \frac{\frac{\frac{\left(D \cdot 0.5\right) \cdot \color{blue}{\left(M \cdot \left(M \cdot D\right)\right)}}{d}}{d}}{2} \cdot \frac{h}{\ell}}
\] |
associate-*r* [=>]64.0 | \[ w0 \cdot \sqrt{1 - \frac{\frac{\frac{\color{blue}{\left(\left(D \cdot 0.5\right) \cdot M\right) \cdot \left(M \cdot D\right)}}{d}}{d}}{2} \cdot \frac{h}{\ell}}
\] |
associate-*r* [<=]64.0 | \[ w0 \cdot \sqrt{1 - \frac{\frac{\frac{\color{blue}{\left(D \cdot \left(0.5 \cdot M\right)\right)} \cdot \left(M \cdot D\right)}{d}}{d}}{2} \cdot \frac{h}{\ell}}
\] |
*-commutative [<=]64.0 | \[ w0 \cdot \sqrt{1 - \frac{\frac{\frac{\left(D \cdot \color{blue}{\left(M \cdot 0.5\right)}\right) \cdot \left(M \cdot D\right)}{d}}{d}}{2} \cdot \frac{h}{\ell}}
\] |
associate-*r/ [<=]64.0 | \[ w0 \cdot \sqrt{1 - \frac{\frac{\color{blue}{\left(D \cdot \left(M \cdot 0.5\right)\right) \cdot \frac{M \cdot D}{d}}}{d}}{2} \cdot \frac{h}{\ell}}
\] |
associate-*l/ [<=]64.0 | \[ w0 \cdot \sqrt{1 - \frac{\frac{\left(D \cdot \left(M \cdot 0.5\right)\right) \cdot \color{blue}{\left(\frac{M}{d} \cdot D\right)}}{d}}{2} \cdot \frac{h}{\ell}}
\] |
*-commutative [<=]64.0 | \[ w0 \cdot \sqrt{1 - \frac{\frac{\color{blue}{\left(\frac{M}{d} \cdot D\right) \cdot \left(D \cdot \left(M \cdot 0.5\right)\right)}}{d}}{2} \cdot \frac{h}{\ell}}
\] |
associate-*r/ [<=]64.0 | \[ w0 \cdot \sqrt{1 - \frac{\color{blue}{\left(\frac{M}{d} \cdot D\right) \cdot \frac{D \cdot \left(M \cdot 0.5\right)}{d}}}{2} \cdot \frac{h}{\ell}}
\] |
*-commutative [=>]64.0 | \[ w0 \cdot \sqrt{1 - \frac{\color{blue}{\frac{D \cdot \left(M \cdot 0.5\right)}{d} \cdot \left(\frac{M}{d} \cdot D\right)}}{2} \cdot \frac{h}{\ell}}
\] |
associate-*r* [=>]64.0 | \[ w0 \cdot \sqrt{1 - \frac{\frac{\color{blue}{\left(D \cdot M\right) \cdot 0.5}}{d} \cdot \left(\frac{M}{d} \cdot D\right)}{2} \cdot \frac{h}{\ell}}
\] |
*-commutative [<=]64.0 | \[ w0 \cdot \sqrt{1 - \frac{\frac{\color{blue}{\left(M \cdot D\right)} \cdot 0.5}{d} \cdot \left(\frac{M}{d} \cdot D\right)}{2} \cdot \frac{h}{\ell}}
\] |
associate-*l* [=>]64.0 | \[ w0 \cdot \sqrt{1 - \frac{\frac{\color{blue}{M \cdot \left(D \cdot 0.5\right)}}{d} \cdot \left(\frac{M}{d} \cdot D\right)}{2} \cdot \frac{h}{\ell}}
\] |
associate-*l/ [<=]62.1 | \[ w0 \cdot \sqrt{1 - \frac{\color{blue}{\left(\frac{M}{d} \cdot \left(D \cdot 0.5\right)\right)} \cdot \left(\frac{M}{d} \cdot D\right)}{2} \cdot \frac{h}{\ell}}
\] |
associate-*l/ [<=]62.1 | \[ w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{\frac{M}{d} \cdot \left(D \cdot 0.5\right)}{2} \cdot \left(\frac{M}{d} \cdot D\right)\right)} \cdot \frac{h}{\ell}}
\] |
associate-*r/ [<=]62.1 | \[ w0 \cdot \sqrt{1 - \left(\color{blue}{\left(\frac{M}{d} \cdot \frac{D \cdot 0.5}{2}\right)} \cdot \left(\frac{M}{d} \cdot D\right)\right) \cdot \frac{h}{\ell}}
\] |
associate-*r* [<=]54.9 | \[ w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{M}{d} \cdot \frac{D \cdot 0.5}{2}\right) \cdot \left(\left(\frac{M}{d} \cdot D\right) \cdot \frac{h}{\ell}\right)}}
\] |
*-commutative [=>]54.9 | \[ w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{D \cdot 0.5}{2} \cdot \frac{M}{d}\right)} \cdot \left(\left(\frac{M}{d} \cdot D\right) \cdot \frac{h}{\ell}\right)}
\] |
associate-*l* [=>]55.1 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{D \cdot 0.5}{2} \cdot \left(\frac{M}{d} \cdot \left(\left(\frac{M}{d} \cdot D\right) \cdot \frac{h}{\ell}\right)\right)}}
\] |
associate-/l* [=>]55.1 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{D}{\frac{2}{0.5}}} \cdot \left(\frac{M}{d} \cdot \left(\left(\frac{M}{d} \cdot D\right) \cdot \frac{h}{\ell}\right)\right)}
\] |
metadata-eval [=>]55.1 | \[ w0 \cdot \sqrt{1 - \frac{D}{\color{blue}{4}} \cdot \left(\frac{M}{d} \cdot \left(\left(\frac{M}{d} \cdot D\right) \cdot \frac{h}{\ell}\right)\right)}
\] |
*-commutative [=>]55.1 | \[ w0 \cdot \sqrt{1 - \frac{D}{4} \cdot \left(\frac{M}{d} \cdot \color{blue}{\left(\frac{h}{\ell} \cdot \left(\frac{M}{d} \cdot D\right)\right)}\right)}
\] |
*-commutative [=>]55.1 | \[ w0 \cdot \sqrt{1 - \frac{D}{4} \cdot \left(\frac{M}{d} \cdot \left(\frac{h}{\ell} \cdot \color{blue}{\left(D \cdot \frac{M}{d}\right)}\right)\right)}
\] |
Applied egg-rr54.0
Applied egg-rr53.4
if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < 9.99999999999999943e-30Initial program 0.1
if 9.99999999999999943e-30 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) Initial program 56.8
Applied egg-rr19.4
Simplified19.4
[Start]19.4 | \[ w0 \cdot \sqrt{1 - \frac{1}{\frac{\ell}{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h}}}
\] |
|---|---|
associate-/r/ [=>]19.4 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{1}{\ell} \cdot \left({\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h\right)}}
\] |
*-commutative [=>]19.4 | \[ w0 \cdot \sqrt{1 - \color{blue}{\left({\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot h\right) \cdot \frac{1}{\ell}}}
\] |
*-commutative [=>]19.4 | \[ w0 \cdot \sqrt{1 - \color{blue}{\left(h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)} \cdot \frac{1}{\ell}}
\] |
*-commutative [=>]19.4 | \[ w0 \cdot \sqrt{1 - \left(h \cdot {\left(M \cdot \color{blue}{\left(\frac{D}{d} \cdot 0.5\right)}\right)}^{2}\right) \cdot \frac{1}{\ell}}
\] |
associate-*l/ [=>]19.4 | \[ w0 \cdot \sqrt{1 - \left(h \cdot {\left(M \cdot \color{blue}{\frac{D \cdot 0.5}{d}}\right)}^{2}\right) \cdot \frac{1}{\ell}}
\] |
associate-*r/ [=>]21.4 | \[ w0 \cdot \sqrt{1 - \left(h \cdot {\color{blue}{\left(\frac{M \cdot \left(D \cdot 0.5\right)}{d}\right)}}^{2}\right) \cdot \frac{1}{\ell}}
\] |
associate-/l* [=>]19.4 | \[ w0 \cdot \sqrt{1 - \left(h \cdot {\color{blue}{\left(\frac{M}{\frac{d}{D \cdot 0.5}}\right)}}^{2}\right) \cdot \frac{1}{\ell}}
\] |
Taylor expanded in h around 0 34.4
Simplified31.3
[Start]34.4 | \[ w0 \cdot \sqrt{1 - 0.25 \cdot \frac{{D}^{2} \cdot \left(h \cdot {M}^{2}\right)}{\ell \cdot {d}^{2}}}
\] |
|---|---|
*-commutative [=>]34.4 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{{D}^{2} \cdot \left(h \cdot {M}^{2}\right)}{\ell \cdot {d}^{2}} \cdot 0.25}}
\] |
*-commutative [=>]34.4 | \[ w0 \cdot \sqrt{1 - \frac{{D}^{2} \cdot \color{blue}{\left({M}^{2} \cdot h\right)}}{\ell \cdot {d}^{2}} \cdot 0.25}
\] |
*-commutative [=>]34.4 | \[ w0 \cdot \sqrt{1 - \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\color{blue}{{d}^{2} \cdot \ell}} \cdot 0.25}
\] |
*-commutative [<=]34.4 | \[ w0 \cdot \sqrt{1 - \frac{{D}^{2} \cdot \color{blue}{\left(h \cdot {M}^{2}\right)}}{{d}^{2} \cdot \ell} \cdot 0.25}
\] |
times-frac [=>]37.5 | \[ w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{{D}^{2}}{{d}^{2}} \cdot \frac{h \cdot {M}^{2}}{\ell}\right)} \cdot 0.25}
\] |
associate-*l* [=>]37.5 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{{D}^{2}}{{d}^{2}} \cdot \left(\frac{h \cdot {M}^{2}}{\ell} \cdot 0.25\right)}}
\] |
unpow2 [=>]37.5 | \[ w0 \cdot \sqrt{1 - \frac{\color{blue}{D \cdot D}}{{d}^{2}} \cdot \left(\frac{h \cdot {M}^{2}}{\ell} \cdot 0.25\right)}
\] |
unpow2 [=>]37.5 | \[ w0 \cdot \sqrt{1 - \frac{D \cdot D}{\color{blue}{d \cdot d}} \cdot \left(\frac{h \cdot {M}^{2}}{\ell} \cdot 0.25\right)}
\] |
times-frac [=>]31.3 | \[ w0 \cdot \sqrt{1 - \color{blue}{\left(\frac{D}{d} \cdot \frac{D}{d}\right)} \cdot \left(\frac{h \cdot {M}^{2}}{\ell} \cdot 0.25\right)}
\] |
*-commutative [=>]31.3 | \[ w0 \cdot \sqrt{1 - \left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(\frac{\color{blue}{{M}^{2} \cdot h}}{\ell} \cdot 0.25\right)}
\] |
unpow2 [=>]31.3 | \[ w0 \cdot \sqrt{1 - \left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(\frac{\color{blue}{\left(M \cdot M\right)} \cdot h}{\ell} \cdot 0.25\right)}
\] |
associate-/l* [=>]56.0 | \[ w0 \cdot \sqrt{1 - \left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(\color{blue}{\frac{M \cdot M}{\frac{\ell}{h}}} \cdot 0.25\right)}
\] |
associate-/r/ [=>]31.3 | \[ w0 \cdot \sqrt{1 - \left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(\color{blue}{\left(\frac{M \cdot M}{\ell} \cdot h\right)} \cdot 0.25\right)}
\] |
Applied egg-rr25.6
Final simplification9.9
| Alternative 1 | |
|---|---|
| Error | 10.3 |
| Cost | 8264 |
| Alternative 2 | |
|---|---|
| Error | 10.6 |
| Cost | 8264 |
| Alternative 3 | |
|---|---|
| Error | 10.8 |
| Cost | 8140 |
| Alternative 4 | |
|---|---|
| Error | 10.0 |
| Cost | 8140 |
| Alternative 5 | |
|---|---|
| Error | 10.7 |
| Cost | 8140 |
| Alternative 6 | |
|---|---|
| Error | 14.4 |
| Cost | 8008 |
| Alternative 7 | |
|---|---|
| Error | 14.0 |
| Cost | 8004 |
| Alternative 8 | |
|---|---|
| Error | 13.8 |
| Cost | 64 |
herbie shell --seed 2022354
(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))))))