Thursday, September 17, 2009

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 .....

Wednesday, September 16, 2009

The problem which put Euler on the path of immortality was the BASEL PROBLEM solved in 1735, 91 years since it was proposed . Succinctly put Euler's proof was ;

Using this result to obtain a recursion for pi in Python !

Pic 1. pi.py

At 500 terms the result is 3.13968..... not too far from the sinister 3.1415.....The recursions are good till about 995 terms (3.14063326091) after which one comes across .... RuntimeError: maximum recursion depth exceeded

Similar programs may be devised on more series as given by Euler, as .....

RECURSIONS FOR e

e the base of natural logarithm is yet another important constant in mathematics .... and once again related to Euler .....

A python program on this recursion is designed via the factorial function ....

Pic 2. e.py

The limit of recursion is around n = 170 which yields a very accurate value of e.

Program 1 (stars.py)This program comes along with examples in the official pygame package , very nice introductory example. With every mouse click the supposed center of the screen moves to that point. Creates a good illusion and can be used as the start-up for further futuristic starry games and animations.

Video 1. Program 1

Program 2 (parallaxstars.py)I came across this example from Chapter 8 of Will's book, this example creates an illusion that the stars close to the observer are moving faster than those in the background, unlike last example ... a mouse click does no good to the program ! once again a good program and can be used as background for futuristic games.

Video 2. Program 2

It is worth nothing that both these Pygame GUI's generate random stars and does not use any images to blit the screen.

Python works cool , but lacks the interpreter mode. Another online interpreter specifically for Python is Try Python which preserves the Python Chevron (>>>) and is in the interpreter mode. Zamplizer is another multi-lingual online platform.

Sunday, September 6, 2009

Allen Downey in his book Think Python poses the reader with a problem !

Write a function named check_fermat that takes four parameters — a, b, c and n — and that checks to see if Fermat’s theorem holds.

Fig 1. Fermat's last Theorem

A suitable program may be made as;

Fig 2. Python Code for check_fermat

However, it must be noted that this sort of treatment may never form some basis of an alternative proof of Fermat's last Theorem, which was the holy grail of mathematics till 1995 when Andrew Wiles established the proof for the 358 year old puzzle.