Thursday, September 17, 2009

AN ODE TO 'pi'

3.141592653589793......

The ratio of circumference to diameter, may be no other number has intrigued and troubled mathematicians any more. The Bible puts pi as 3 ..... while many fanatics have spend the prime of their lives computing the 'little' that lies beyond 3 ... Ludolph van Ceulen from Leiden is sure worth a mention .... and he took the 35 digits of his computation to his tombstone after his death in 1610 ..... the exoticism of pi doesn't end here ..... and Feynman point is another interesting aspect of the unending digits of pi....

It must be appreciated that pi is not just another constant .....and is far from the likes of physical constants as G,h and c ..... and is also distinctly different from root 2, gamma, e and iota .... the physical constants are structured by the physical theory and are found to vary with time..... while e, iota, gamma etc can be said to be product of our chosen number system and the bias of our prevalent mathematical structure ....... while, pi is engraved in mother nature ..... it is ubiquitous and omnipresent .... pi enunciates why every circle mimics every other circle .... and so is true for every sphere..... Various physical theories as electrostatics, fluid-dynamics and gravitation have confirmed the presence of pi in their formulation , i.e: Stokes Equation, Gauss's Law, Kepler's law .....

The only other constant which may compete for similar prominence is phi , though phi is more subtle and not really as often visible as pi .... well..... I must stop with these rhetorics ... and get to business ...... 2 python recursions (1) Ramanujan's formulation (2) Wallis Product.

(1) Ramanujan's formulation

One of the most exotic and 'very fast converging' series for computing pi was given by Ramanujan...

A corresponding python program is ....

Fig 1. piramanujan.py

The program gives very accurate value of pi (3.14159265381), however the limit of recursion is reached in about 20 terms ...

(2) Wallis Product

An evaluation of pi in a 'product' form of an infinite series was given by English mathematician John Wallis.

The python program is ....

Fig 2. piwallis.py

The limit of recursion is at about 995 terms .

Though life can be made much easier ... away from these recursions by importing pi from math .....

Fig 2. pisimple.py

3 comments:

Luke said...

slow to converge

>>>
>>> def zeta(x):
    if x == 1:
        return 1
    else:
        return 1.0/x**2 + zeta(x-1)


>>> (pi(700)*6)**0.5
3.140229146424105
>>>

Luke said...

sorry that should be

>>> (zeta(700)*6)**0.5

Under Water Coconut said...

THe formulation is correct. Thank you for the informative post. Emperor Clubs is an Online Casino in Malaysia that offers more than just casino games. We offer more than 100 Slot Games Malaysia that really can help reduce stress, have fun as well as refreshing your mind.