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 than n(pi), at least right now.  Behind the 
scenes, n(pi) does some other checks, then eventually basically calls 
RR(pi).  You might also just use math.pi.  But these are tips to just 
shave off a few more milliseconds, which is probably not going to matter 
  at all.

Jason



> and I got CPU time: 0.21 s,  Wall time: 0.25 s. This looks much
> reasonable. Again, thanks for everyone's help.
> 
> BTW, I'm using the latest version of sage and both point and point3d
> work for me.
> 
> On Oct 9, 6:13 pm, William Stein <[EMAIL PROTECTED]> wrote:
>> 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.append((sin(t1)*cos(t2), sin(t1)*sin(t2), cos(t1)))
>>> show(point(pts))
>>> My question is, though, that sage takes, it seems to me, longer time
>>> to execute this than I would expect. (CPU time: 6.66 s,  Wall time:
>>> 48.84 s) Am I making some stupid mistake in the above code, or sage
>>> does something unnecessary, which causes the delay? In my (naive)
>>> point of view, plotting as many as 500 points shouldn't take that long
>>> time... Thanks.
>> Try putting
>>    from math import sin, cos
>> before the rest of your code to use the double precision C-library's
>> sin and cosine functions instead.
>>
>> William
> > 
> 


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to