Comment #30 on issue 3128 by someb...@bluewin.ch: Sum and Product manipulations
http://code.google.com/p/sympy/issues/detail?id=3128

Ok, and now back to the original topic. From the inital list:

- [x] Addition of two sums / products with the same limits
- [x] Addition of two sums with different limits (like Sum(i, (i, 0, k)) + Sum(i, (i, k, m)))
- [x] Change of index
- [ ] Product of Sums
- [x] Reorder multiple sums or products
- [x] Reverse order of limits
- [ ] The inverse of any of the above rules

Point 1 works:

In [117]: S1 = Sum(i, (i, a, b))
In [118]: S2 = Sum(i**2, (i, a, b))
In [119]: S1+S2
Out[119]: Sum(i, (i, a, b)) + Sum(i**2, (i, a, b))
In [120]: simplify(_)
Out[120]: Sum(i**2 + i, (i, a, b))

In [133]: P1 = Product(i, (i, a, b))
In [137]: P2 = Product(i**3+i, (i, a, b))
In [138]: P1*P2
Out[138]: Product(i, (i, a, b))*Product(i**3 + i, (i, a, b))
In [139]: simplify(_)
Out[139]: Product(i**4 + i**2, (i, a, b))


Point 2 works in special cases, could maybe be improved:

In [127]: Sum(i, (i, 0, k)) + Sum(i, (i, k+1, m))
Out[127]: Sum(i, (i, 0, k)) + Sum(i, (i, k + 1, m))
In [128]: simplify(_)
Out[128]: Sum(i, (i, 0, m))

In [125]: Sum(i, (i, 0, k)) + Sum(i, (i, k, m))
Out[125]: Sum(i, (i, 0, k)) + Sum(i, (i, k, m))
In [126]: simplify(_)
Out[126]: Sum(i, (i, 0, k)) + Sum(i, (i, k, m))

In [131]: Sum(i, (i, 0, k)) + Sum(i, (i, k+12, m))
Out[131]: Sum(i, (i, 0, k)) + Sum(i, (i, k + 12, m))
In [132]: simplify(_)
Out[132]: Sum(i, (i, 0, k)) + Sum(i, (i, k + 12, m))

In [140]: P1 = Product(i, (i, a, b))
In [143]: P2 = Product(i, (i, b+1, c))
In [144]: P1*P2
Out[144]: Product(i, (i, a, b))*Product(i, (i, b + 1, c))
In [145]: simplify(_)
Out[145]: Product(i, (i, a, c))


There are clearly bugs with point 4:

In [156]: S1
Out[156]: Sum(i, (i, a, b))
In [157]: S2
Out[157]: Sum(i**2, (i, a, b))
In [158]: S1*S2
Out[158]: Sum(i, (i, a, b))*Sum(i**2, (i, a, b))
In [159]: simplify(_)
Out[159]: Sum(i**2, (i, a, b))
In [160]: _ - S2
Out[160]: 0


--
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 sympy-issues+unsubscr...@googlegroups.com.
To post to this group, send email to sympy-issues@googlegroups.com.
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