New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weird value of a sum #19745
Comments
There is an issue #5822 for this. It's calculated like this: In [1]: Sum(x, (x, y, z)).doit()
Out[1]:
2 2
y y z z
- ── + ─ + ── + ─
2 2 2 2
In [2]: Sum(x, (x, y, z)).doit().subs({y:1, z:Rational(3, 2)})
Out[2]: 15/8 Some parts of the implementation of Sum assume that the bounds are integers but nothing prevents giving non-integer bounds. There have been suggestions to disallow non-integer bounds and also suggestions to make sense of them in some way. The behaviour of Sum in a number of ways does not match the definition given in the docstring: Karr's definition referred to there would imply that In [8]: Sum(f(x), (x, 1, 4)).doit()
Out[8]: f(1) + f(2) + f(3) + f(4) Also Karr's definition would imply that flipping the limits is equivalent to introducing a minus sign but that isn't what we get: In [17]: Sum(f(x), (x, 4, 1)).doit()
Out[17]: -f(2) - f(3) So the current behaviour does not match Karr's definition at all as far as I can tell. The behaviour for inverted limits is non-sensical and the behaviour for ordinary limits does not match the documented definition. Also having looked at Karr's paper there doesn't seem to be any definition of a summation with non-integer bounds. The paper seems to take it as implicitly obvious that the bounds are integers. It seems that we need to fix what is the actual definition of |
Closes sympy/sympy#19745 Closes sympy/sympy#9358
The Karr summation convention explained in more details to prevent misunderstanding (e.g. see example in sympy/sympy#19745 (comment)). Few doctests provided.
Sum(x,(x,1,Integer(3)/2)).doit()
gives15/8
. How is it calculated and how sympy handles non-integer bounds?The text was updated successfully, but these errors were encountered: