| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 13504 |
\[U + 2 \cdot \left(J \cdot \left(\sinh \ell \cdot \cos \left(0.5 \cdot K\right)\right)\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(J, Float64(Float64(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[(J * N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(0.5 * K), $MachinePrecision]], $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(J, \left(2 \cdot \sinh \ell\right) \cdot \cos \left(0.5 \cdot K\right), U\right)
Initial program 17.6
Applied egg-rr32.0
Applied egg-rr44.0
Simplified0.1
[Start]44.0 | \[ e^{\mathsf{log1p}\left(\mathsf{fma}\left(J, 2 \cdot \left(\sinh \ell \cdot \cos \left(K \cdot 0.5\right)\right), U\right)\right)} - 1
\] |
|---|---|
expm1-def [=>]22.3 | \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(J, 2 \cdot \left(\sinh \ell \cdot \cos \left(K \cdot 0.5\right)\right), U\right)\right)\right)}
\] |
expm1-log1p [=>]0.1 | \[ \color{blue}{\mathsf{fma}\left(J, 2 \cdot \left(\sinh \ell \cdot \cos \left(K \cdot 0.5\right)\right), U\right)}
\] |
associate-*r* [=>]0.1 | \[ \mathsf{fma}\left(J, \color{blue}{\left(2 \cdot \sinh \ell\right) \cdot \cos \left(K \cdot 0.5\right)}, U\right)
\] |
*-commutative [<=]0.1 | \[ \mathsf{fma}\left(J, \left(2 \cdot \sinh \ell\right) \cdot \cos \color{blue}{\left(0.5 \cdot K\right)}, U\right)
\] |
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 13504 |
| Alternative 2 | |
|---|---|
| Error | 0.7 |
| Cost | 13376 |
| Alternative 3 | |
|---|---|
| Error | 8.9 |
| Cost | 7240 |
| Alternative 4 | |
|---|---|
| Error | 0.7 |
| Cost | 7104 |
| Alternative 5 | |
|---|---|
| Error | 0.7 |
| Cost | 7104 |
| Alternative 6 | |
|---|---|
| Error | 9.2 |
| Cost | 6848 |
| Alternative 7 | |
|---|---|
| Error | 19.1 |
| Cost | 849 |
| Alternative 8 | |
|---|---|
| Error | 9.5 |
| Cost | 448 |
| Alternative 9 | |
|---|---|
| Error | 18.8 |
| Cost | 64 |
herbie shell --seed 2023010
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))