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

No, the correct answer is:

In [103]: [ Sum(Sum(1,(i,-2+k,2-k)),(k,0,j)).doit() for j in range(5)]
Out[103]: [5, 8, 9, 8, 5]

If we look at the individual summands:

In [106]: [ [ Sum(1,(i,-2+k,2-k)) for k in range(j+1) ] for j in range(5) ]
Out[106]:
[[Sum(1, (i, -2, 2))],
 [Sum(1, (i, -2, 2)), Sum(1, (i, -1, 1))],
 [Sum(1, (i, -2, 2)), Sum(1, (i, -1, 1)), Sum(1, (i, 0, 0))],
 [Sum(1, (i, -2, 2)),
  Sum(1, (i, -1, 1)),
  Sum(1, (i, 0, 0)),
  Sum(1, (i, 1, -1))],
 [Sum(1, (i, -2, 2)),
  Sum(1, (i, -1, 1)),
  Sum(1, (i, 0, 0)),
  Sum(1, (i, 1, -1)),
  Sum(1, (i, 2, -2))]]

In [107]: [ [ Sum(1,(i,-2+k,2-k)).doit() for k in range(j+1) ] for j in range(5) ]
Out[107]: [[5], [5, 3], [5, 3, 1], [5, 3, 1, -1], [5, 3, 1, -1, -3]]


If we look at some specific sum we have for example:

In [121]: S = Sum(1, (i, -1, 1))

In [122]: S.doit()
Out[122]: 3

In [123]: S = Sum(1, (i, 1, -1))

In [124]: S.doit()
Out[124]: -1

These contribution do not cancel out nor do the sum up as if there were some "abs".

Interchanging limits works as follows:

In [127]: S = Sum(i, (i, a, b))

In [128]: Sr = reverse_order(S, i)

In [129]: Sr
Out[129]: Sum(-i, (i, b + 1, a - 1))

In [130]: S.doit()
Out[130]: -a**2/2 + a/2 + b**2/2 + b/2

In [131]: Sr.doit()
Out[131]: -a**2/2 + a/2 + b**2/2 + b/2

Simply exchanging a and b without shifting misses boundary terms and does NOT conserve the value of the sum.


--
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