Ways of Calculating PI

1) Calculate PI by by "shooting a cannon" at a round pond of radius 1 unit inscribed within a 2X2 square of land.Corners of land are: (0,0),(1,0),(1,1),(0,1)

A "Splash" is defined as the event when the cannon lands in water.
A "Thud" is defined as the event when the cannon lands on ground (in square).
Shots=Number of shots fired.
Ratio=Splashes/Shots.
Now ratio=1/(4*PI)

ALGORITHM:
1)Generate X & Y coordinates of shots randomly, shots++
2)dx=1-X,dy-i-Y,i.e ditance from origin.
3)dist=sqrt((dx*dx)+(dy*dy))
4)if disy<=1.0 splashes++ else thuds++
5)ratio=splashes/shots
6)PI=ratio * 4;
7)Go to 1 if accuracr not achived.

2) There is wooden plan with planks of equal width.Drop a pin on floor.If any part of pin touches the crakcs b/w boards, it is a HIT.
ratio=HITS/Total drops of pin, and
PI=ratio/10

ALGORITHM:
1)Generate horizontal position of one end of pin as dx.Generate angle of pin from horizontal as theta.
2)If theta<=90)
If (dx+Cos(theta)>=1)hits++
else If (dx-cos(180-theta))<=0) hits++
3)ratio=hits/drops


3)(PI/6)^2=1= (1/2)^2 + (1/3)^2 + (1/4)^2 +.........