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

If you want to compute the number of all the "x" in your graph, then
we can easily make sure that the left boundary of that double triangle
is always smaller or equal to the right one by using "Abs":

a = k - 2
b = 2 - k

Sk = Sum(1, (x, -Abs(a), Abs(b))).doit()
Sk
Abs(-k + 2) + Abs(k - 2) + 1

M = Sum(Sk, (k, 0, 4)).doit()
M
17

which is correct.


This is similar on how to use integration to compute the area below a curve.

integrate(sin(x), (x, 0, 2*pi))
0

which is of course "wrong" or rather not what we asked for because the area
carries a sign. The error is not in the math or implementation but simply
comes from an unsuitable problem statement.

Indeed, if we pose the correct question, we get the "right" answer:

Abs(integrate(sin(x), (x, 0, pi))) + Abs(integrate(sin(x), (x, pi, 2*pi)))
4

Note that I split the integral at x=pi because Sympy does a bad job on
integrate(Abs(sin(x)), (x, 0, 2*pi)).


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