Comment #36 on issue 3128 by [email protected]: Sum and Product manipulations
http://code.google.com/p/sympy/issues/detail?id=3128

Maybe you want to try it?

In that case, consider also what happens if there are more than two Sums in the original expression. How to find a (near) optimum on which sums to combine and how?

Here is another example where I'd like not to have to manually enter E1:

In [293]: E0.doit()
Out[293]: -3**a/2 + 3**(b + 4)/2 + u*(-a**3/3 + a**2/2 - a/6 + b**3/3 + b**2/2 + b/6)

In [294]: simplify(_)
Out[294]: -3**a/2 + 81*3**b/2 + u*(-2*a**3 + 3*a**2 - a + 2*b**3 + 3*b**2 + b)/6

In [295]: simplify(E0)
Out[295]: Sum(3**i, (i, a, b + 3)) + Sum(i**2*u, (i, a, b))

In [296]: E1 = Sum(i**2*u, (i, a, b)) + Sum(3**i, (i, a, b)) + Sum(3**i, (i, b+1, b+3))

In [297]: E1.doit()
Out[297]: -3**a/2 + 3*3**(b + 1)/2 + 3**(b + 2) + 3**(b + 3) + u*(-a**3/3 + a**2/2 - a/6 + b**3/3 + b**2/2 + b/6)

In [298]: simplify(_)
Out[298]: -3**a/2 + 81*3**b/2 + u*(-2*a**3 + 3*a**2 - a + 2*b**3 + 3*b**2 + b)/6

In [299]: simplify(E1)
Out[299]: Sum(3**i, (i, b + 1, b + 3)) + Sum(3**i + i**2*u, (i, a, b))

In [300]: _.doit()
Out[300]: -3**a/2 + 3*3**(b + 1)/2 + 3**(b + 2) + 3**(b + 3) + u*(-a**3/3 + a**2/2 - a/6 + b**3/3 + b**2/2 + b/6)

In [301]: simplify(_)
Out[301]: -3**a/2 + 81*3**b/2 + u*(-2*a**3 + 3*a**2 - a + 2*b**3 + 3*b**2 + b)/6

I hope this gives you some ideas. Btw, all that applies also to Products of course.


--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy-issues.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to