| Alternative 1 | |
|---|---|
| Accuracy | 86.7% |
| Cost | 27784 |
(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
(pow
(exp 0.5)
(fma -2.0 (- (log D)) (log (* (/ M (/ l M)) (* (/ h (* d d)) -0.25))))))
(if (<= t_0 1e-116)
(* w0 (sqrt (- 1.0 t_0)))
(*
w0
(sqrt
(- 1.0 (* M (/ 0.25 (* (/ d D) (* (/ l M) (/ d (* D h)))))))))))))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 * pow(exp(0.5), fma(-2.0, -log(D), log(((M / (l / M)) * ((h / (d * d)) * -0.25)))));
} else if (t_0 <= 1e-116) {
tmp = w0 * sqrt((1.0 - t_0));
} else {
tmp = w0 * sqrt((1.0 - (M * (0.25 / ((d / D) * ((l / M) * (d / (D * h))))))));
}
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 * (exp(0.5) ^ fma(-2.0, Float64(-log(D)), log(Float64(Float64(M / Float64(l / M)) * Float64(Float64(h / Float64(d * d)) * -0.25)))))); elseif (t_0 <= 1e-116) tmp = Float64(w0 * sqrt(Float64(1.0 - t_0))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(M * Float64(0.25 / Float64(Float64(d / D) * Float64(Float64(l / M) * Float64(d / Float64(D * h))))))))); end return 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[Power[N[Exp[0.5], $MachinePrecision], N[(-2.0 * (-N[Log[D], $MachinePrecision]) + N[Log[N[(N[(M / N[(l / M), $MachinePrecision]), $MachinePrecision] * N[(N[(h / N[(d * d), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e-116], N[(w0 * N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(M * N[(0.25 / N[(N[(d / D), $MachinePrecision] * N[(N[(l / M), $MachinePrecision] * N[(d / N[(D * h), $MachinePrecision]), $MachinePrecision]), $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}
t_0 := {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;w0 \cdot {\left(e^{0.5}\right)}^{\left(\mathsf{fma}\left(-2, -\log D, \log \left(\frac{M}{\frac{\ell}{M}} \cdot \left(\frac{h}{d \cdot d} \cdot -0.25\right)\right)\right)\right)}\\
\mathbf{elif}\;t_0 \leq 10^{-116}:\\
\;\;\;\;w0 \cdot \sqrt{1 - t_0}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - M \cdot \frac{0.25}{\frac{d}{D} \cdot \left(\frac{\ell}{M} \cdot \frac{d}{D \cdot h}\right)}}\\
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < -inf.0Initial program 0.0%
Applied egg-rr14.4%
Applied egg-rr12.2%
Simplified12.4%
[Start]12.2 | \[ w0 \cdot e^{0.5 \cdot \mathsf{log1p}\left(\frac{-M}{\frac{\frac{2}{D} \cdot \left(\frac{d}{M} \cdot \frac{\ell}{h}\right)}{0.5 \cdot \frac{D}{d}}}\right)}
\] |
|---|---|
exp-prod [=>]12.1 | \[ w0 \cdot \color{blue}{{\left(e^{0.5}\right)}^{\left(\mathsf{log1p}\left(\frac{-M}{\frac{\frac{2}{D} \cdot \left(\frac{d}{M} \cdot \frac{\ell}{h}\right)}{0.5 \cdot \frac{D}{d}}}\right)\right)}}
\] |
associate-/r/ [=>]11.4 | \[ w0 \cdot {\left(e^{0.5}\right)}^{\left(\mathsf{log1p}\left(\color{blue}{\frac{-M}{\frac{2}{D} \cdot \left(\frac{d}{M} \cdot \frac{\ell}{h}\right)} \cdot \left(0.5 \cdot \frac{D}{d}\right)}\right)\right)}
\] |
Taylor expanded in D around inf 11.7%
Simplified13.7%
[Start]11.7 | \[ w0 \cdot {\left(e^{0.5}\right)}^{\left(-2 \cdot \log \left(\frac{1}{D}\right) + \log \left(-0.25 \cdot \frac{{M}^{2} \cdot h}{\ell \cdot {d}^{2}}\right)\right)}
\] |
|---|---|
fma-def [=>]11.7 | \[ w0 \cdot {\left(e^{0.5}\right)}^{\color{blue}{\left(\mathsf{fma}\left(-2, \log \left(\frac{1}{D}\right), \log \left(-0.25 \cdot \frac{{M}^{2} \cdot h}{\ell \cdot {d}^{2}}\right)\right)\right)}}
\] |
log-rec [=>]11.7 | \[ w0 \cdot {\left(e^{0.5}\right)}^{\left(\mathsf{fma}\left(-2, \color{blue}{-\log D}, \log \left(-0.25 \cdot \frac{{M}^{2} \cdot h}{\ell \cdot {d}^{2}}\right)\right)\right)}
\] |
*-commutative [=>]11.7 | \[ w0 \cdot {\left(e^{0.5}\right)}^{\left(\mathsf{fma}\left(-2, -\log D, \log \color{blue}{\left(\frac{{M}^{2} \cdot h}{\ell \cdot {d}^{2}} \cdot -0.25\right)}\right)\right)}
\] |
times-frac [=>]11.7 | \[ w0 \cdot {\left(e^{0.5}\right)}^{\left(\mathsf{fma}\left(-2, -\log D, \log \left(\color{blue}{\left(\frac{{M}^{2}}{\ell} \cdot \frac{h}{{d}^{2}}\right)} \cdot -0.25\right)\right)\right)}
\] |
associate-*l* [=>]11.7 | \[ w0 \cdot {\left(e^{0.5}\right)}^{\left(\mathsf{fma}\left(-2, -\log D, \log \color{blue}{\left(\frac{{M}^{2}}{\ell} \cdot \left(\frac{h}{{d}^{2}} \cdot -0.25\right)\right)}\right)\right)}
\] |
unpow2 [=>]11.7 | \[ w0 \cdot {\left(e^{0.5}\right)}^{\left(\mathsf{fma}\left(-2, -\log D, \log \left(\frac{\color{blue}{M \cdot M}}{\ell} \cdot \left(\frac{h}{{d}^{2}} \cdot -0.25\right)\right)\right)\right)}
\] |
associate-/l* [=>]13.7 | \[ w0 \cdot {\left(e^{0.5}\right)}^{\left(\mathsf{fma}\left(-2, -\log D, \log \left(\color{blue}{\frac{M}{\frac{\ell}{M}}} \cdot \left(\frac{h}{{d}^{2}} \cdot -0.25\right)\right)\right)\right)}
\] |
unpow2 [=>]13.7 | \[ w0 \cdot {\left(e^{0.5}\right)}^{\left(\mathsf{fma}\left(-2, -\log D, \log \left(\frac{M}{\frac{\ell}{M}} \cdot \left(\frac{h}{\color{blue}{d \cdot d}} \cdot -0.25\right)\right)\right)\right)}
\] |
if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < 9.9999999999999999e-117Initial program 99.8%
if 9.9999999999999999e-117 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) Initial program 31.1%
Applied egg-rr38.8%
Simplified37.0%
[Start]38.8 | \[ w0 \cdot \sqrt{1 - \frac{M \cdot \left(-D\right)}{\frac{\ell}{h} \cdot \left(\left(\frac{2}{D} \cdot \frac{d}{M}\right) \cdot \left(d \cdot -2\right)\right)}}
\] |
|---|---|
*-commutative [=>]38.8 | \[ w0 \cdot \sqrt{1 - \frac{M \cdot \left(-D\right)}{\frac{\ell}{h} \cdot \color{blue}{\left(\left(d \cdot -2\right) \cdot \left(\frac{2}{D} \cdot \frac{d}{M}\right)\right)}}}
\] |
associate-*r* [=>]41.0 | \[ w0 \cdot \sqrt{1 - \frac{M \cdot \left(-D\right)}{\color{blue}{\left(\frac{\ell}{h} \cdot \left(d \cdot -2\right)\right) \cdot \left(\frac{2}{D} \cdot \frac{d}{M}\right)}}}
\] |
*-commutative [=>]41.0 | \[ w0 \cdot \sqrt{1 - \frac{M \cdot \left(-D\right)}{\left(\frac{\ell}{h} \cdot \left(d \cdot -2\right)\right) \cdot \color{blue}{\left(\frac{d}{M} \cdot \frac{2}{D}\right)}}}
\] |
associate-*l/ [=>]40.4 | \[ w0 \cdot \sqrt{1 - \frac{M \cdot \left(-D\right)}{\left(\frac{\ell}{h} \cdot \left(d \cdot -2\right)\right) \cdot \color{blue}{\frac{d \cdot \frac{2}{D}}{M}}}}
\] |
associate-*r/ [=>]40.4 | \[ w0 \cdot \sqrt{1 - \frac{M \cdot \left(-D\right)}{\left(\frac{\ell}{h} \cdot \left(d \cdot -2\right)\right) \cdot \frac{\color{blue}{\frac{d \cdot 2}{D}}}{M}}}
\] |
*-commutative [<=]40.4 | \[ w0 \cdot \sqrt{1 - \frac{M \cdot \left(-D\right)}{\left(\frac{\ell}{h} \cdot \left(d \cdot -2\right)\right) \cdot \frac{\frac{\color{blue}{2 \cdot d}}{D}}{M}}}
\] |
associate-*r/ [<=]40.4 | \[ w0 \cdot \sqrt{1 - \frac{M \cdot \left(-D\right)}{\left(\frac{\ell}{h} \cdot \left(d \cdot -2\right)\right) \cdot \frac{\color{blue}{2 \cdot \frac{d}{D}}}{M}}}
\] |
associate-*r/ [=>]37.8 | \[ w0 \cdot \sqrt{1 - \frac{M \cdot \left(-D\right)}{\color{blue}{\frac{\left(\frac{\ell}{h} \cdot \left(d \cdot -2\right)\right) \cdot \left(2 \cdot \frac{d}{D}\right)}{M}}}}
\] |
associate-*r* [<=]35.0 | \[ w0 \cdot \sqrt{1 - \frac{M \cdot \left(-D\right)}{\frac{\color{blue}{\frac{\ell}{h} \cdot \left(\left(d \cdot -2\right) \cdot \left(2 \cdot \frac{d}{D}\right)\right)}}{M}}}
\] |
associate-/l* [<=]30.5 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{\left(M \cdot \left(-D\right)\right) \cdot M}{\frac{\ell}{h} \cdot \left(\left(d \cdot -2\right) \cdot \left(2 \cdot \frac{d}{D}\right)\right)}}}
\] |
*-commutative [<=]30.5 | \[ w0 \cdot \sqrt{1 - \frac{\left(M \cdot \left(-D\right)\right) \cdot M}{\frac{\ell}{h} \cdot \color{blue}{\left(\left(2 \cdot \frac{d}{D}\right) \cdot \left(d \cdot -2\right)\right)}}}
\] |
times-frac [=>]33.0 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{M \cdot \left(-D\right)}{\frac{\ell}{h}} \cdot \frac{M}{\left(2 \cdot \frac{d}{D}\right) \cdot \left(d \cdot -2\right)}}}
\] |
Applied egg-rr70.3%
Applied egg-rr67.1%
Simplified78.3%
[Start]67.1 | \[ w0 \cdot \sqrt{1 - \left(\left(0 - e^{\mathsf{log1p}\left(M \cdot \frac{\frac{M}{\ell} \cdot \left(D \cdot h\right)}{\frac{d}{D} \cdot \left(d \cdot -4\right)}\right)}\right) + 1\right)}
\] |
|---|---|
associate-+l- [=>]67.1 | \[ w0 \cdot \sqrt{1 - \color{blue}{\left(0 - \left(e^{\mathsf{log1p}\left(M \cdot \frac{\frac{M}{\ell} \cdot \left(D \cdot h\right)}{\frac{d}{D} \cdot \left(d \cdot -4\right)}\right)} - 1\right)\right)}}
\] |
expm1-def [=>]67.1 | \[ w0 \cdot \sqrt{1 - \left(0 - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(M \cdot \frac{\frac{M}{\ell} \cdot \left(D \cdot h\right)}{\frac{d}{D} \cdot \left(d \cdot -4\right)}\right)\right)}\right)}
\] |
expm1-log1p [=>]67.4 | \[ w0 \cdot \sqrt{1 - \left(0 - \color{blue}{M \cdot \frac{\frac{M}{\ell} \cdot \left(D \cdot h\right)}{\frac{d}{D} \cdot \left(d \cdot -4\right)}}\right)}
\] |
sub0-neg [=>]67.4 | \[ w0 \cdot \sqrt{1 - \color{blue}{\left(-M \cdot \frac{\frac{M}{\ell} \cdot \left(D \cdot h\right)}{\frac{d}{D} \cdot \left(d \cdot -4\right)}\right)}}
\] |
mul-1-neg [<=]67.4 | \[ w0 \cdot \sqrt{1 - \color{blue}{-1 \cdot \left(M \cdot \frac{\frac{M}{\ell} \cdot \left(D \cdot h\right)}{\frac{d}{D} \cdot \left(d \cdot -4\right)}\right)}}
\] |
associate-*r/ [=>]63.4 | \[ w0 \cdot \sqrt{1 - -1 \cdot \color{blue}{\frac{M \cdot \left(\frac{M}{\ell} \cdot \left(D \cdot h\right)\right)}{\frac{d}{D} \cdot \left(d \cdot -4\right)}}}
\] |
associate-*r/ [=>]63.4 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{-1 \cdot \left(M \cdot \left(\frac{M}{\ell} \cdot \left(D \cdot h\right)\right)\right)}{\frac{d}{D} \cdot \left(d \cdot -4\right)}}}
\] |
associate-/l* [=>]63.4 | \[ w0 \cdot \sqrt{1 - \color{blue}{\frac{-1}{\frac{\frac{d}{D} \cdot \left(d \cdot -4\right)}{M \cdot \left(\frac{M}{\ell} \cdot \left(D \cdot h\right)\right)}}}}
\] |
/-rgt-identity [<=]63.4 | \[ w0 \cdot \sqrt{1 - \frac{-1}{\frac{\frac{d}{D} \cdot \left(d \cdot -4\right)}{\color{blue}{\frac{M \cdot \left(\frac{M}{\ell} \cdot \left(D \cdot h\right)\right)}{1}}}}}
\] |
associate-/l* [=>]63.4 | \[ w0 \cdot \sqrt{1 - \frac{-1}{\frac{\frac{d}{D} \cdot \left(d \cdot -4\right)}{\color{blue}{\frac{M}{\frac{1}{\frac{M}{\ell} \cdot \left(D \cdot h\right)}}}}}}
\] |
associate-*l/ [=>]64.4 | \[ w0 \cdot \sqrt{1 - \frac{-1}{\frac{\frac{d}{D} \cdot \left(d \cdot -4\right)}{\frac{M}{\frac{1}{\color{blue}{\frac{M \cdot \left(D \cdot h\right)}{\ell}}}}}}}
\] |
associate-/l* [<=]65.1 | \[ w0 \cdot \sqrt{1 - \frac{-1}{\frac{\frac{d}{D} \cdot \left(d \cdot -4\right)}{\frac{M}{\color{blue}{\frac{1 \cdot \ell}{M \cdot \left(D \cdot h\right)}}}}}}
\] |
associate-*r/ [<=]65.1 | \[ w0 \cdot \sqrt{1 - \frac{-1}{\frac{\frac{d}{D} \cdot \left(d \cdot -4\right)}{\frac{M}{\color{blue}{1 \cdot \frac{\ell}{M \cdot \left(D \cdot h\right)}}}}}}
\] |
*-lft-identity [=>]65.1 | \[ w0 \cdot \sqrt{1 - \frac{-1}{\frac{\frac{d}{D} \cdot \left(d \cdot -4\right)}{\frac{M}{\color{blue}{\frac{\ell}{M \cdot \left(D \cdot h\right)}}}}}}
\] |
Final simplification85.8%
| Alternative 1 | |
|---|---|
| Accuracy | 86.7% |
| Cost | 27784 |
| Alternative 2 | |
|---|---|
| Accuracy | 82.8% |
| Cost | 14344 |
| Alternative 3 | |
|---|---|
| Accuracy | 84.0% |
| Cost | 8392 |
| Alternative 4 | |
|---|---|
| Accuracy | 84.1% |
| Cost | 8264 |
| Alternative 5 | |
|---|---|
| Accuracy | 82.8% |
| Cost | 8264 |
| Alternative 6 | |
|---|---|
| Accuracy | 80.9% |
| Cost | 8140 |
| Alternative 7 | |
|---|---|
| Accuracy | 81.7% |
| Cost | 7876 |
| Alternative 8 | |
|---|---|
| Accuracy | 78.5% |
| Cost | 64 |
herbie shell --seed 2023125
(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))))))