| Alternative 1 | |
|---|---|
| Accuracy | 99.1% |
| Cost | 7104 |
\[U + \ell \cdot \left(2 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot J\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 (+ U (* (cos (* 0.5 K)) (* J (* l (+ (* 0.3333333333333333 (* l l)) 2.0))))))
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 U + (cos((0.5 * K)) * (J * (l * ((0.3333333333333333 * (l * l)) + 2.0))));
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u + (cos((0.5d0 * k)) * (j * (l * ((0.3333333333333333d0 * (l * l)) + 2.0d0))))
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
public static double code(double J, double l, double K, double U) {
return U + (Math.cos((0.5 * K)) * (J * (l * ((0.3333333333333333 * (l * l)) + 2.0))));
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
def code(J, l, K, U): return U + (math.cos((0.5 * K)) * (J * (l * ((0.3333333333333333 * (l * l)) + 2.0))))
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 Float64(U + Float64(cos(Float64(0.5 * K)) * Float64(J * Float64(l * Float64(Float64(0.3333333333333333 * Float64(l * l)) + 2.0))))) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
function tmp = code(J, l, K, U) tmp = U + (cos((0.5 * K)) * (J * (l * ((0.3333333333333333 * (l * l)) + 2.0)))); 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[(U + N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * N[(N[(0.3333333333333333 * N[(l * l), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
U + \cos \left(0.5 \cdot K\right) \cdot \left(J \cdot \left(\ell \cdot \left(0.3333333333333333 \cdot \left(\ell \cdot \ell\right) + 2\right)\right)\right)
Results
Initial program 72.7%
Simplified72.7%
[Start]72.7 | \[ \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\] |
|---|---|
associate-*l* [=>]72.7 | \[ \color{blue}{J \cdot \left(\left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right)\right)} + U
\] |
fma-def [=>]72.7 | \[ \color{blue}{\mathsf{fma}\left(J, \left(e^{\ell} - e^{-\ell}\right) \cdot \cos \left(\frac{K}{2}\right), U\right)}
\] |
Taylor expanded in l around 0 99.4%
Simplified99.4%
[Start]99.4 | \[ 2 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(\ell \cdot J\right)\right) + \left(0.3333333333333333 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left({\ell}^{3} \cdot J\right)\right) + U\right)
\] |
|---|---|
associate-+r+ [=>]99.4 | \[ \color{blue}{\left(2 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(\ell \cdot J\right)\right) + 0.3333333333333333 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left({\ell}^{3} \cdot J\right)\right)\right) + U}
\] |
+-commutative [=>]99.4 | \[ \color{blue}{U + \left(2 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left(\ell \cdot J\right)\right) + 0.3333333333333333 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left({\ell}^{3} \cdot J\right)\right)\right)}
\] |
*-commutative [=>]99.4 | \[ U + \left(\color{blue}{\left(\cos \left(0.5 \cdot K\right) \cdot \left(\ell \cdot J\right)\right) \cdot 2} + 0.3333333333333333 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left({\ell}^{3} \cdot J\right)\right)\right)
\] |
associate-*l* [=>]99.4 | \[ U + \left(\color{blue}{\cos \left(0.5 \cdot K\right) \cdot \left(\left(\ell \cdot J\right) \cdot 2\right)} + 0.3333333333333333 \cdot \left(\cos \left(0.5 \cdot K\right) \cdot \left({\ell}^{3} \cdot J\right)\right)\right)
\] |
*-commutative [=>]99.4 | \[ U + \left(\cos \left(0.5 \cdot K\right) \cdot \left(\left(\ell \cdot J\right) \cdot 2\right) + \color{blue}{\left(\cos \left(0.5 \cdot K\right) \cdot \left({\ell}^{3} \cdot J\right)\right) \cdot 0.3333333333333333}\right)
\] |
associate-*l* [=>]99.4 | \[ U + \left(\cos \left(0.5 \cdot K\right) \cdot \left(\left(\ell \cdot J\right) \cdot 2\right) + \color{blue}{\cos \left(0.5 \cdot K\right) \cdot \left(\left({\ell}^{3} \cdot J\right) \cdot 0.3333333333333333\right)}\right)
\] |
distribute-lft-out [=>]99.4 | \[ U + \color{blue}{\cos \left(0.5 \cdot K\right) \cdot \left(\left(\ell \cdot J\right) \cdot 2 + \left({\ell}^{3} \cdot J\right) \cdot 0.3333333333333333\right)}
\] |
*-commutative [<=]99.4 | \[ U + \cos \left(0.5 \cdot K\right) \cdot \left(\color{blue}{2 \cdot \left(\ell \cdot J\right)} + \left({\ell}^{3} \cdot J\right) \cdot 0.3333333333333333\right)
\] |
associate-*r* [=>]99.4 | \[ U + \cos \left(0.5 \cdot K\right) \cdot \left(\color{blue}{\left(2 \cdot \ell\right) \cdot J} + \left({\ell}^{3} \cdot J\right) \cdot 0.3333333333333333\right)
\] |
*-commutative [<=]99.4 | \[ U + \cos \left(0.5 \cdot K\right) \cdot \left(\left(2 \cdot \ell\right) \cdot J + \color{blue}{0.3333333333333333 \cdot \left({\ell}^{3} \cdot J\right)}\right)
\] |
associate-*r* [=>]99.4 | \[ U + \cos \left(0.5 \cdot K\right) \cdot \left(\left(2 \cdot \ell\right) \cdot J + \color{blue}{\left(0.3333333333333333 \cdot {\ell}^{3}\right) \cdot J}\right)
\] |
distribute-rgt-out [=>]99.4 | \[ U + \cos \left(0.5 \cdot K\right) \cdot \color{blue}{\left(J \cdot \left(2 \cdot \ell + 0.3333333333333333 \cdot {\ell}^{3}\right)\right)}
\] |
+-commutative [<=]99.4 | \[ U + \cos \left(0.5 \cdot K\right) \cdot \left(J \cdot \color{blue}{\left(0.3333333333333333 \cdot {\ell}^{3} + 2 \cdot \ell\right)}\right)
\] |
unpow3 [=>]99.4 | \[ U + \cos \left(0.5 \cdot K\right) \cdot \left(J \cdot \left(0.3333333333333333 \cdot \color{blue}{\left(\left(\ell \cdot \ell\right) \cdot \ell\right)} + 2 \cdot \ell\right)\right)
\] |
associate-*r* [=>]99.4 | \[ U + \cos \left(0.5 \cdot K\right) \cdot \left(J \cdot \left(\color{blue}{\left(0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right) \cdot \ell} + 2 \cdot \ell\right)\right)
\] |
distribute-rgt-out [=>]99.4 | \[ U + \cos \left(0.5 \cdot K\right) \cdot \left(J \cdot \color{blue}{\left(\ell \cdot \left(0.3333333333333333 \cdot \left(\ell \cdot \ell\right) + 2\right)\right)}\right)
\] |
Final simplification99.4%
| Alternative 1 | |
|---|---|
| Accuracy | 99.1% |
| Cost | 7104 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.1% |
| Cost | 7104 |
| Alternative 3 | |
|---|---|
| Accuracy | 99.1% |
| Cost | 7104 |
| Alternative 4 | |
|---|---|
| Accuracy | 86.6% |
| Cost | 960 |
| Alternative 5 | |
|---|---|
| Accuracy | 86.5% |
| Cost | 448 |
| Alternative 6 | |
|---|---|
| Accuracy | 3.6% |
| Cost | 64 |
| Alternative 7 | |
|---|---|
| Accuracy | 71.0% |
| Cost | 64 |
herbie shell --seed 2023152
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))