On 6/6/11 7:21 AM, Jason Grout wrote:
On 6/6/11 5:34 AM, Ignas Anikevicius wrote:
Hello,

This is my first message to this list, but I hope, that I have not
broken any rules here. I am writing because I have noticed a strange
thing, which I think should not happen.

I needed to test my maths solutions, so I thought I would just use a
loop to get sage generate the first 600 terms of a particular Fourier
series. But then I remembered that sage has a sum function. So I also
tried the sum function. However, I noticed a very big performance
difference which I did not expect. I was wondering if someone could
explain me why there is such a difference in the performance although
the actual result is the same? Or is the native sum function more clever
or what?

The output of the script and the script itself are attached. Note that I
did not bother to wait for the native sum function to sum 1000 terms, as
it took eternity to finish.

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.


P.S. If you want the sum function to not try being so smart, instead of calling it as sum(expression, variable, start, end), just call it as sum(list of things to sum):

https://gist.github.com/1010165

Thanks,

Jason

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

Reply via email to