My first Python program.. Calculating pi geometrically.

Ron Adam radam2 at tampabay.rr.com
Sat Nov 1 16:09:26 EST 2003


On Sat, 01 Nov 2003 19:09:42 GMT, GrayGeek <jkrepsBEAR at FISHneb.rr.com>
wrote:

>Ron Adam wrote:
>
>> On Sat, 01 Nov 2003 12:35:45 +0100, Irmen de Jong
>> <irmen at -NOSPAM-REMOVETHIS-xs4all.nl> wrote:
>> 
>>>Ron Adam wrote:
>>>
>>>> Doing it geometrically was strictly a learning exercise.  And I did
>>>> learn quite a bit by doing it.
>>>
>>>And you only scratched the surface of what Python offers you :-)
>>>While it's nice to hear that you learned a lot by making this
>>>arithmetic python program, it certainly is not the most
>>>inspiring thing that Python is capable of...
>>>
>>>I even think you learned more about calculating Pi than you
>>>did about programming in Python ;-)
>>>
>>>--Irmen
>> 
>> The challenging parts were,  figuring out how to do the calculation
>> without using sin or cos,  (nice geometry refresher), getting the gmpy
>> module to work and how to set the precision, and working out by trial
>> and error the precision calculation.   If there is a formula to
>> convert digits of precision to bits of precision, I'd like to know.
>> And the last was to figure out how to use the clock and timedelta
>> functions.
>> 
>> Other interesting things I learned was how to convert to and from
>> stings,  use slices, and for-in loops are very fast for small lists,
>> but can eat up a lot of memory, hit the swap file and be extremely
>> slow for large lists. For-in loops aren't suited for everything.
>> 
>> And yes, before I started, I did not know how to calculate pi.  So you
>> are right about that.  ;-)   That was an interesting subject in it
>> self.
>> 
>> Overall, it was a very good learning project.
>> 
>> _Ron
>
>As I recall, Ron, your method is the same one used by Archimedes when he
>computed PI.  
>http://itech.fgcu.edu/faculty/clindsey/mhf4404/archimedes/archimedes.html
> The method of diminishing triangles is SO similar to Gauss & Newton's
>method of diminishing rectangles one wonders how much faster the scientific
>advances of Man would have occurred if Archimedes had gone on to develop
>Calculus.  

Yes,  the concept is the same, but slightly different method.   All
the examples I found used trig functions to do it with or used ratios
related to trig functions.  I used vectors to get around that.  

How much did calculus contributed to advances in mankind after it was
developed?  I think other developments in production methods and
economics had a bigger impact and didn't require calculus. 

Correction, a quick search found this....
http://www-gap.dcs.st-and.ac.uk/~history/HistTopics/The_rise_of_calculus.html

This shows calculus was developed over quite a long time in
conjunction with, and driven by developments in production,  which in
turn were related to economics. 

But 2,500 years is a long time ago and who knows what would have
happened?  What would have happened if the telescope was invented
sooner?   :-)

Something interesting about gmpy accuracy is after calculating pi to
10,000 digits and displaying the entire floating point number, only
the last 4 digits are off due to rounding errors.  I think that is
exceptional and only occasionally are the last 5 digits not correct.
I get around that by calculating at least 5 extra digits and then
truncating.   

_Ron

      




More information about the Python-list mailing list