On 06/06/11 13:21, Jason Grout wrote:
> One big difference is that if you just are adding things together
> (your floop function), Sage doesn't have to be smart or do anything
> complicated; it just puts the terms all together. However, the Sage
> sum function, the way you are using it, tries to find a nice
> expression for the sum. Technically (if I followed the code correctly
> just now), it calls maxima to evaluate the sum, then to try to
> simplify the sum. This is *much* more work than the floop function,
> which doesn't call any external program and doesn't try to be smart
> about getting a nice simplified expression for the sum.
>
> One cool thing about Sage being an open source solution is that I
> could follow what was happening in the function and figure out where
> the slowdown was. To do this, I first found the sum source code by
> evaluating "sum??". Looking at the if statement in the source code, I
> saw that it first called the .sum() method if an object had a .sum()
> method. So I can take one of your terms:
>
> sage: n=var('n')
> sage:
> term=(2*(((-1)^n-1)/(n*pi)^2*cos(n*pi*x)-(-1)^n/(n*pi)*sin(n*pi*x))).subs(n=1)
>
> and I ask to see the source code of the sum method:
>
> sage: term.sum??
>
> This shows that it calls the sage.calculus.calculus.symbolic_sum
> function. Finally, I look up that function:
>
> sage: sage.calculus.calculus.symbolic_sum??
>
> and I see the calls to maxima and the call to simplify (ratsimp) the
> sum in maxima.
>
> Thanks,
>
> Jason
>
Thanks a lot for such a detailed answer! I appreciate your help very much.
Best wishes,
Ignas
--
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org