Comment #8 on issue 2723 by [email protected]: What should summation() do
with non-integer limits?
http://code.google.com/p/sympy/issues/detail?id=2723
If we take the definition of summation(f(k), (k, a, b) as f(a) + f(a + 1)
+ ... + f(a + n) where n = floor(b - a) assuming a <= b, then I don't see
theoretical reason why not to allow this (although there are some technical
difficulties). I tried Maxima and it perfectly allows non integer limits,
though it gives different results than SymPy, e.g.:
In [26]: summation(x, (x, S(3)/2, 5))
Out[26]: 117/8
(%i14) sum(x, x, 3/2, 5);
(%o14) 12
The reason for this difference is that SymPy computes a closed form for
sum(x, (x, a, b)) and then substitutes values for a and b. Maxima, however,
for numerical limits (at least in this case) does direct evaluation of
individual terms (which is better visible when using exp(x) instead of x),
e.g:
(%i27) sum(exp(x), x, 3/2, 5), simpsum;
9/2 7/2 5/2 3/2
(%o27) %e + %e + %e + %e
Notice that we obtain different results if we start with symbolic limits:
(%i28) sum(exp(x), x, a, b), simpsum;
b + 1 a
%e - %e
(%o28) -------------
%e - 1
(%i29) subst(3/2, a, %);
b + 1 3/2
%e - %e
(%o29) ---------------
%e - 1
(%i30) subst(5, b, %);
6 3/2
%e - %e
(%o30) -----------
%e - 1
(%i31) float(%);
(%o31) 232.1779220468
(%i32) float(%o27);
(%o32) 139.7967662902557
And in SymPy:
In [39]: summation(exp(x), (x, S(3)/2, 5))
Out[39]:
6 3/2
- ℯ + ℯ
───────────
-ℯ + 1
In [40]: N(_)
Out[40]: 232.177922046800
This is wrong (unless we take a different definition of fractional
summation (Lebesgue integral?)). I think we should impose that b - a in
Integers, either by checking assumptions on a, b or b - a, or return
conditional statement as it is done by meijer-g integrator (note that we
should invent something better than simply using Piecewise, because in case
of .subs(), the final result will be still incorrect -> we need Cases()
that will allow .subs() to fail), or take upper limit as a + floor(b - a).
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.