[sage-support] Re: Speeding up the for loop

2008-10-09 Thread Jason Grout
Byungchul Cha wrote: > > Thanks for all of your help. I did > > 1. Importing sin and cos using "from math import sin, cos" > 2. Removing pi and sqrt out of the loops, following Jason's > suggestion: > twopi = 2*n(pi); mystep = twopi/n(sqrt(number_of_points)) > By the way, RR(pi) is faster tha

[sage-support] Re: Speeding up the for loop

2008-10-09 Thread Byungchul Cha
Thanks for all of your help. I did 1. Importing sin and cos using "from math import sin, cos" 2. Removing pi and sqrt out of the loops, following Jason's suggestion: twopi = 2*n(pi); mystep = twopi/n(sqrt(number_of_points)) and I got CPU time: 0.21 s, Wall time: 0.25 s. This looks much reasona

[sage-support] Re: Speeding up the for loop

2008-10-09 Thread William Stein
Byungchul Cha wrote: > > I am using sage for my calc III students. The following short code > produces about 500 points on a sphere. > > pts=[]; number_of_points=500 > for t1 in srange(0, pi, n(pi/sqrt(number_of_points))): > for t2 in srange(0, 2*pi, n(2*pi/sqrt(number_of_points))): > pts.

[sage-support] Re: Speeding up the for loop

2008-10-09 Thread Jason Grout
Marshall Hampton wrote: > I think the culprit is the "pi" in the srange, which gets Maxima too > involved (and maxima as called through sage is slow). This may > improve very soon as there is some work being done to shift basic > symbolic things like "pi" to a more python-based backend. > > Anyw

[sage-support] Re: Speeding up the for loop

2008-10-09 Thread Marshall Hampton
I think the culprit is the "pi" in the srange, which gets Maxima too involved (and maxima as called through sage is slow). This may improve very soon as there is some work being done to shift basic symbolic things like "pi" to a more python-based backend. Anyway for the moment you can avoid this