Comment #13 on issue 1727 by smichr: fix namespace clashes
http://code.google.com/p/sympy/issues/detail?id=1727
OK, I think the answer for this issue is already present in sympy: if you
can do the sum, do it, otherwise leave it as unevaluated and drop sum from
sympy. Here is the rationale:
1) Integral and integrate are both necessary since integrals are sometimes
not evaluable and the user can easily select whether to have it attempted
or not by using integrate.
2) Products and sums are always easy if they have numerical limits.
3) There is not integrate equivalent to Product; Product is automatically
evaluated if given numerical limits:
>>> Product(x, (x, 1, 3))
6
If given symbolic limits it remains (as it must) unevaluted:
>>> Product(x, (x, 1, y))
Product(x, x, 1, y)
4) giving sum a dual nature involves a performance hit on the builtin sum
result.
5) the use of summation is grammatically ackward and long; the
grammatically correct term for the action, summate, sounds ackward since it
is not in common use.
6) Since Sum and Product are so similar they should behave the same.
There is no need for the sum() function which clashes with python's
builtin. This way, as Aaron points out, the user that uses Sum with
something that has a numerical answer will not think that sympy cannot do
it -- and won't find out that sympy can do it until they find the doit
method.
>>> Sum(x, (x, 1, 3))
6
What they may want to know later is how to represent such a sum as
unevaluated, like they would get for the symbolic sum:
>>> Sum(x, (x, 1,y ))
Sum(x, (x, 1, y)) # see note below
And that is the time to tell them about evaluate=False (which should be
implemented for Product and Sum in the case of receiving the keyword
evaluate=False and numerical ranges.)
Note: Sum and Product should have a unified appearance: Product arguments
are shown flat and Sum arguments are shown within a tuple.
--
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.