| Alternative 1 | |
|---|---|
| Accuracy | 92.1% |
| Cost | 33088 |
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
(FPCore (K m n M l) :precision binary64 (if (<= l 740.0) (/ (cos M) (exp (+ (pow (fma 0.5 (+ m n) (- M)) 2.0) (- m n)))) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 740.0) {
tmp = cos(M) / exp((pow(fma(0.5, (m + n), -M), 2.0) + (m - n)));
} else {
tmp = exp(-l);
}
return tmp;
}
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function code(K, m, n, M, l) tmp = 0.0 if (l <= 740.0) tmp = Float64(cos(M) / exp(Float64((fma(0.5, Float64(m + n), Float64(-M)) ^ 2.0) + Float64(m - n)))); else tmp = exp(Float64(-l)); end return tmp end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[K_, m_, n_, M_, l_] := If[LessEqual[l, 740.0], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(N[Power[N[(0.5 * N[(m + n), $MachinePrecision] + (-M)), $MachinePrecision], 2.0], $MachinePrecision] + N[(m - n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\begin{array}{l}
\mathbf{if}\;\ell \leq 740:\\
\;\;\;\;\frac{\cos M}{e^{{\left(\mathsf{fma}\left(0.5, m + n, -M\right)\right)}^{2} + \left(m - n\right)}}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
if l < 740Initial program 67.9%
Simplified68.0%
[Start]67.9 | \[ \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\] |
|---|---|
sub-neg [=>]67.9 | \[ \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \color{blue}{\left(\ell + \left(-\left|m - n\right|\right)\right)}}
\] |
associate--r+ [=>]67.9 | \[ \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{\left(\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \ell\right) - \left(-\left|m - n\right|\right)}}
\] |
exp-diff [=>]16.9 | \[ \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \color{blue}{\frac{e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \ell}}{e^{-\left|m - n\right|}}}
\] |
associate-*r/ [=>]16.9 | \[ \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \ell}}{e^{-\left|m - n\right|}}}
\] |
associate-/l* [=>]16.9 | \[ \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{\frac{e^{-\left|m - n\right|}}{e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \ell}}}}
\] |
associate-*r/ [<=]16.9 | \[ \frac{\cos \left(\color{blue}{K \cdot \frac{m + n}{2}} - M\right)}{\frac{e^{-\left|m - n\right|}}{e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \ell}}}
\] |
exp-diff [=>]13.8 | \[ \frac{\cos \left(K \cdot \frac{m + n}{2} - M\right)}{\frac{e^{-\left|m - n\right|}}{\color{blue}{\frac{e^{-{\left(\frac{m + n}{2} - M\right)}^{2}}}{e^{\ell}}}}}
\] |
Taylor expanded in K around 0 89.7%
Simplified89.7%
[Start]89.7 | \[ \frac{\cos \left(-M\right)}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|n - m\right|\right)}}
\] |
|---|---|
cos-neg [=>]89.7 | \[ \frac{\color{blue}{\cos M}}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|n - m\right|\right)}}
\] |
Taylor expanded in l around 0 89.7%
Simplified89.7%
[Start]89.7 | \[ \frac{\cos M}{e^{{\left(0.5 \cdot \left(n + m\right) - M\right)}^{2} - \left|n - m\right|}}
\] |
|---|---|
sub-neg [=>]89.7 | \[ \frac{\cos M}{e^{\color{blue}{{\left(0.5 \cdot \left(n + m\right) - M\right)}^{2} + \left(-\left|n - m\right|\right)}}}
\] |
fma-neg [=>]89.7 | \[ \frac{\cos M}{e^{{\color{blue}{\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}}^{2} + \left(-\left|n - m\right|\right)}}
\] |
neg-sub0 [=>]89.7 | \[ \frac{\cos M}{e^{{\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \color{blue}{\left(0 - \left|n - m\right|\right)}}}
\] |
unpow1 [<=]89.7 | \[ \frac{\cos M}{e^{{\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \left(0 - \left|\color{blue}{{\left(n - m\right)}^{1}}\right|\right)}}
\] |
sqr-pow [=>]45.0 | \[ \frac{\cos M}{e^{{\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \left(0 - \left|\color{blue}{{\left(n - m\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(n - m\right)}^{\left(\frac{1}{2}\right)}}\right|\right)}}
\] |
fabs-sqr [=>]45.0 | \[ \frac{\cos M}{e^{{\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \left(0 - \color{blue}{{\left(n - m\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(n - m\right)}^{\left(\frac{1}{2}\right)}}\right)}}
\] |
sqr-pow [<=]89.7 | \[ \frac{\cos M}{e^{{\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \left(0 - \color{blue}{{\left(n - m\right)}^{1}}\right)}}
\] |
unpow1 [=>]89.7 | \[ \frac{\cos M}{e^{{\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \left(0 - \color{blue}{\left(n - m\right)}\right)}}
\] |
associate--r- [=>]89.7 | \[ \frac{\cos M}{e^{{\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \color{blue}{\left(\left(0 - n\right) + m\right)}}}
\] |
neg-sub0 [<=]89.7 | \[ \frac{\cos M}{e^{{\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \left(\color{blue}{\left(-n\right)} + m\right)}}
\] |
mul-1-neg [<=]89.7 | \[ \frac{\cos M}{e^{{\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \left(\color{blue}{-1 \cdot n} + m\right)}}
\] |
+-commutative [=>]89.7 | \[ \frac{\cos M}{e^{{\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \color{blue}{\left(m + -1 \cdot n\right)}}}
\] |
mul-1-neg [=>]89.7 | \[ \frac{\cos M}{e^{{\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \left(m + \color{blue}{\left(-n\right)}\right)}}
\] |
sub-neg [<=]89.7 | \[ \frac{\cos M}{e^{{\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \color{blue}{\left(m - n\right)}}}
\] |
if 740 < l Initial program 80.7%
Simplified80.7%
[Start]80.7 | \[ \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\] |
|---|---|
sub-neg [=>]80.7 | \[ \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \color{blue}{\left(\ell + \left(-\left|m - n\right|\right)\right)}}
\] |
associate--r+ [=>]80.7 | \[ \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{\left(\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \ell\right) - \left(-\left|m - n\right|\right)}}
\] |
exp-diff [=>]26.0 | \[ \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \color{blue}{\frac{e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \ell}}{e^{-\left|m - n\right|}}}
\] |
associate-*r/ [=>]26.0 | \[ \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \ell}}{e^{-\left|m - n\right|}}}
\] |
associate-/l* [=>]26.0 | \[ \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{\frac{e^{-\left|m - n\right|}}{e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \ell}}}}
\] |
associate-*r/ [<=]26.0 | \[ \frac{\cos \left(\color{blue}{K \cdot \frac{m + n}{2}} - M\right)}{\frac{e^{-\left|m - n\right|}}{e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \ell}}}
\] |
exp-diff [=>]26.0 | \[ \frac{\cos \left(K \cdot \frac{m + n}{2} - M\right)}{\frac{e^{-\left|m - n\right|}}{\color{blue}{\frac{e^{-{\left(\frac{m + n}{2} - M\right)}^{2}}}{e^{\ell}}}}}
\] |
Taylor expanded in K around 0 100.0%
Simplified100.0%
[Start]100.0 | \[ \frac{\cos \left(-M\right)}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|n - m\right|\right)}}
\] |
|---|---|
cos-neg [=>]100.0 | \[ \frac{\color{blue}{\cos M}}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|n - m\right|\right)}}
\] |
Taylor expanded in l around inf 100.0%
Taylor expanded in M around 0 100.0%
Simplified100.0%
[Start]100.0 | \[ \frac{1}{e^{\ell}}
\] |
|---|---|
rec-exp [=>]100.0 | \[ \color{blue}{e^{-\ell}}
\] |
Final simplification92.2%
| Alternative 1 | |
|---|---|
| Accuracy | 92.1% |
| Cost | 33088 |
| Alternative 2 | |
|---|---|
| Accuracy | 92.2% |
| Cost | 26624 |
| Alternative 3 | |
|---|---|
| Accuracy | 64.0% |
| Cost | 20689 |
| Alternative 4 | |
|---|---|
| Accuracy | 63.9% |
| Cost | 19784 |
| Alternative 5 | |
|---|---|
| Accuracy | 65.3% |
| Cost | 13380 |
| Alternative 6 | |
|---|---|
| Accuracy | 64.0% |
| Cost | 13256 |
| Alternative 7 | |
|---|---|
| Accuracy | 64.0% |
| Cost | 13256 |
| Alternative 8 | |
|---|---|
| Accuracy | 64.0% |
| Cost | 7508 |
| Alternative 9 | |
|---|---|
| Accuracy | 65.8% |
| Cost | 6852 |
| Alternative 10 | |
|---|---|
| Accuracy | 29.6% |
| Cost | 6528 |
| Alternative 11 | |
|---|---|
| Accuracy | 6.9% |
| Cost | 6464 |
| Alternative 12 | |
|---|---|
| Accuracy | 6.9% |
| Cost | 64 |
herbie shell --seed 2023153
(FPCore (K m n M l)
:name "Maksimov and Kolovsky, Equation (32)"
:precision binary64
(* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))