[Tutor] Numeric Package

cino hilliard hillcino368@hotmail.com
Mon Feb 24 19:05:02 2003


<html><div style='background-color:'><DIV>
<P>The following uses the arbitrary integer long of python to compute Pi. Can some one help getting this to use&nbsp;the Numeric package in float arbitrary precision.?&nbsp;</P>
<P><BR>def piasn(n):<BR>&nbsp;&nbsp;&nbsp;&nbsp; n1=n*7/2+5<BR>&nbsp;&nbsp;&nbsp;&nbsp; n2=n/2 + 5<BR>&nbsp;&nbsp;&nbsp;&nbsp; import time<BR>&nbsp;&nbsp;&nbsp;&nbsp; t1=time.time()<BR>&nbsp;&nbsp;&nbsp;&nbsp; m=n+5<BR>&nbsp;&nbsp;&nbsp;&nbsp; p,x,d = 3*10**m,3*10**m,1<BR>&nbsp;&nbsp;&nbsp;&nbsp; t1=time.time()<BR>&nbsp;&nbsp;&nbsp;&nbsp; while d &lt;= n1:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x=x*d/(d+1) &gt;&gt; 2<BR>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x=x*d/(d+1)/4<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p=p+x/(d+2)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d += 2<BR>&nbsp;&nbsp;&nbsp;&nbsp; t2=time.time()<BR>&nbsp;&nbsp;&nbsp;&nbsp; print "Pi = ",p<BR>&nbsp;&nbsp;&nbsp;&nbsp; print "sec to calc",t2-t1</P>
<P>Cino Hilliard<BR></P></DIV></div><br clear=all><hr>Add photos to your e-mail with <a href="http://g.msn.com/8HMAENUS/2746">MSN 8.</a> Get 2 months FREE*.</html>