My first Python program.. Calculating pi geometrically.
GrayGeek
jkrepsBEAR at FISHneb.rr.com
Sat Nov 1 14:09:42 EST 2003
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.
--
-
GrayGeek
More information about the Python-list
mailing list