| Alternative 1 | |
|---|---|
| Error | 0.14% |
| Cost | 13504 |
\[U + \left(J \cdot \left(2 \cdot \sinh \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right)
\]
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
(FPCore (J l K U) :precision binary64 (fma (* (* J 2.0) (sinh l)) (cos (* 0.5 K)) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
double code(double J, double l, double K, double U) {
return fma(((J * 2.0) * sinh(l)), cos((0.5 * K)), U);
}
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function code(J, l, K, U) return fma(Float64(Float64(J * 2.0) * sinh(l)), cos(Float64(0.5 * K)), U) end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
code[J_, l_, K_, U_] := N[(N[(N[(J * 2.0), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] + U), $MachinePrecision]
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\mathsf{fma}\left(\left(J \cdot 2\right) \cdot \sinh \ell, \cos \left(0.5 \cdot K\right), U\right)
Initial program 27.24
Taylor expanded in l around -inf 27.24
Simplified0.14
[Start]27.24 | \[ \left(J \cdot \left(e^{\ell} - e^{-1 \cdot \ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\] |
|---|---|
mul-1-neg [=>]27.24 | \[ \left(J \cdot \left(e^{\ell} - e^{\color{blue}{-\ell}}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\] |
/-rgt-identity [<=]27.24 | \[ \left(J \cdot \color{blue}{\frac{e^{\ell} - e^{-\ell}}{1}}\right) \cdot \cos \left(\frac{K}{2}\right) + U
\] |
metadata-eval [<=]27.24 | \[ \left(J \cdot \frac{e^{\ell} - e^{-\ell}}{\color{blue}{\frac{2}{2}}}\right) \cdot \cos \left(\frac{K}{2}\right) + U
\] |
associate-/l* [<=]27.24 | \[ \left(J \cdot \color{blue}{\frac{\left(e^{\ell} - e^{-\ell}\right) \cdot 2}{2}}\right) \cdot \cos \left(\frac{K}{2}\right) + U
\] |
*-commutative [=>]27.24 | \[ \left(J \cdot \frac{\color{blue}{2 \cdot \left(e^{\ell} - e^{-\ell}\right)}}{2}\right) \cdot \cos \left(\frac{K}{2}\right) + U
\] |
associate-*r/ [<=]27.24 | \[ \left(J \cdot \color{blue}{\left(2 \cdot \frac{e^{\ell} - e^{-\ell}}{2}\right)}\right) \cdot \cos \left(\frac{K}{2}\right) + U
\] |
sinh-def [<=]0.14 | \[ \left(J \cdot \left(2 \cdot \color{blue}{\sinh \ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\] |
Applied egg-rr47.41
Simplified0.15
[Start]47.41 | \[ e^{\mathsf{log1p}\left(\left(J \cdot \left(2 \cdot \sinh \ell\right)\right) \cdot \cos \left(K \cdot 0.5\right)\right)} - \left(1 - U\right)
\] |
|---|---|
associate--r- [=>]25.37 | \[ \color{blue}{\left(e^{\mathsf{log1p}\left(\left(J \cdot \left(2 \cdot \sinh \ell\right)\right) \cdot \cos \left(K \cdot 0.5\right)\right)} - 1\right) + U}
\] |
expm1-def [=>]13.45 | \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(J \cdot \left(2 \cdot \sinh \ell\right)\right) \cdot \cos \left(K \cdot 0.5\right)\right)\right)} + U
\] |
expm1-log1p [=>]0.14 | \[ \color{blue}{\left(J \cdot \left(2 \cdot \sinh \ell\right)\right) \cdot \cos \left(K \cdot 0.5\right)} + U
\] |
fma-udef [<=]0.14 | \[ \color{blue}{\mathsf{fma}\left(J \cdot \left(2 \cdot \sinh \ell\right), \cos \left(K \cdot 0.5\right), U\right)}
\] |
associate-*r* [=>]0.15 | \[ \mathsf{fma}\left(\color{blue}{\left(J \cdot 2\right) \cdot \sinh \ell}, \cos \left(K \cdot 0.5\right), U\right)
\] |
*-commutative [=>]0.15 | \[ \mathsf{fma}\left(\left(J \cdot 2\right) \cdot \sinh \ell, \cos \color{blue}{\left(0.5 \cdot K\right)}, U\right)
\] |
Final simplification0.15
| Alternative 1 | |
|---|---|
| Error | 0.14% |
| Cost | 13504 |
| Alternative 2 | |
|---|---|
| Error | 15.4% |
| Cost | 7504 |
| Alternative 3 | |
|---|---|
| Error | 15.38% |
| Cost | 7504 |
| Alternative 4 | |
|---|---|
| Error | 0.78% |
| Cost | 7488 |
| Alternative 5 | |
|---|---|
| Error | 0.94% |
| Cost | 7104 |
| Alternative 6 | |
|---|---|
| Error | 13.9% |
| Cost | 6848 |
| Alternative 7 | |
|---|---|
| Error | 28.61% |
| Cost | 584 |
| Alternative 8 | |
|---|---|
| Error | 14.33% |
| Cost | 448 |
| Alternative 9 | |
|---|---|
| Error | 29.13% |
| Cost | 64 |
herbie shell --seed 2023090
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))