| Alternative 1 | |
|---|---|
| Accuracy | 92.0% |
| Cost | 26624 |
\[\frac{\cos M}{e^{\left(\ell - \left|n - m\right|\right) + {\left(\frac{m + n}{2} - M\right)}^{2}}}
\]
(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 (/ (cos M) (exp (+ (log1p (expm1 (pow (- (* (+ m n) 0.5) M) 2.0))) (- l (fabs (- n m)))))))
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) {
return cos(M) / exp((log1p(expm1(pow((((m + n) * 0.5) - M), 2.0))) + (l - fabs((n - m)))));
}
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) / Math.exp((Math.log1p(Math.expm1(Math.pow((((m + n) * 0.5) - M), 2.0))) + (l - Math.abs((n - m)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
def code(K, m, n, M, l): return math.cos(M) / math.exp((math.log1p(math.expm1(math.pow((((m + n) * 0.5) - M), 2.0))) + (l - math.fabs((n - m)))))
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) return Float64(cos(M) / exp(Float64(log1p(expm1((Float64(Float64(Float64(m + n) * 0.5) - M) ^ 2.0))) + Float64(l - abs(Float64(n - m)))))) 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_] := N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(N[Log[1 + N[(Exp[N[Power[N[(N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision] + N[(l - N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $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)}
\frac{\cos M}{e^{\mathsf{log1p}\left(\mathsf{expm1}\left({\left(\left(m + n\right) \cdot 0.5 - M\right)}^{2}\right)\right) + \left(\ell - \left|n - m\right|\right)}}
Results
Initial program 72.9%
Simplified72.9%
[Start]72.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 [=>]72.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+ [=>]72.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 [=>]21.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/ [=>]21.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* [=>]21.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/ [<=]21.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 [=>]19.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 91.6%
Simplified91.6%
[Start]91.6 | \[ \frac{\cos \left(-M\right)}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|n - m\right|\right)}}
\] |
|---|---|
cos-neg [=>]91.6 | \[ \frac{\color{blue}{\cos M}}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|n - m\right|\right)}}
\] |
Applied egg-rr91.6%
[Start]91.6 | \[ \frac{\cos M}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|n - m\right|\right)}}
\] |
|---|---|
log1p-expm1-u [=>]91.6 | \[ \frac{\cos M}{e^{\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right)} + \left(\ell - \left|n - m\right|\right)}}
\] |
div-inv [=>]91.6 | \[ \frac{\cos M}{e^{\mathsf{log1p}\left(\mathsf{expm1}\left({\left(\color{blue}{\left(m + n\right) \cdot \frac{1}{2}} - M\right)}^{2}\right)\right) + \left(\ell - \left|n - m\right|\right)}}
\] |
metadata-eval [=>]91.6 | \[ \frac{\cos M}{e^{\mathsf{log1p}\left(\mathsf{expm1}\left({\left(\left(m + n\right) \cdot \color{blue}{0.5} - M\right)}^{2}\right)\right) + \left(\ell - \left|n - m\right|\right)}}
\] |
Final simplification91.6%
| Alternative 1 | |
|---|---|
| Accuracy | 92.0% |
| Cost | 26624 |
| Alternative 2 | |
|---|---|
| Accuracy | 65.5% |
| Cost | 20428 |
| Alternative 3 | |
|---|---|
| Accuracy | 55.2% |
| Cost | 20168 |
| Alternative 4 | |
|---|---|
| Accuracy | 58.5% |
| Cost | 13764 |
| Alternative 5 | |
|---|---|
| Accuracy | 30.3% |
| Cost | 12992 |
| Alternative 6 | |
|---|---|
| Accuracy | 7.2% |
| Cost | 6464 |
herbie shell --seed 2023157
(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)))))))