Deviant Login Shop  Join deviantART for FREE Take the Tour


Submitted on
November 25, 2005
Image Size
10.9 KB


12,375 (2 today)
50 (who?)
This is a simulation which uses a cannon to calculate PI.

Given a circular pond in a square field where the pond and field have the same diameter, we fire a cannon into the field over and over, hitting randomly and count the number of times we hit the pond.

Because the area of a square is (W squared) where "W" is the width of the square and because the area of a circle is (PI times D squared) where "D" is the diameter of the circle, if a circle and square have the same width, the ratio of the area of the circle to the area of the square is PI / 4.

So we keep shooting cannonballs into the field and then we check the ratio of times we hit the pond divided by the times we fired in total. Take that ratio, multiply by 4 and we get our current guess at the value of PI. As the number of cannonballs fired increases, we should get closer and closer to PI.

Keep in mind that, while this is a valid method of calculating PI, it is also very inefficient as each additional digit of accuracy requires 10x as many shots as the previous digit.
Add a Comment:
What are you talking about? A circle with radius r has an area of Pi(r^2). But the radius is only half the width of the square, so the sides are 2r and the area is 4r^2.
Yes, that's what I said. 4*R*R == 4r^2
I thought the area of a circle was simply Pi r2, and the circumference formula was the one that required the coefficient of two (i.e. 2 Pi r). Then factoring out the r2 from your area equation you get a ratio of Pi: 4, which is what you have based your program on...
I'm sorry if I come across as... something. I'm just confused myself and trying to clarify =]
Cool idea.
Never have heard of such a thing but now I know, kudos to you.
I thought that if the cannon in thid deviation is alive cutely.
Piscatella Dec 5, 2006
An artist and a nerd!!! ( and I really admire nerds and geeks) You are my hero!!!
Awesome! I can only guess as to what possessed you to create this, but you did quite a good job at it. Fascinating. :D
I find this really interesting. It makes it seem very simple. I watched 2600 fires and got 3.10162....... Great job for whatever the reason of creating it. I enjoyed it very much.
pczelda Nov 27, 2005   Digital Artist
How do you calculate the exact value of Pi to X? (Given that X's value is any position in or after 3.14). I've always wondered how you do it, but never knew how.
In simplest terms, Pi is the ratio of a circle's diameter to its circumference so you can get a crude estimate for Pi simply by measuring a dinner plate with a tape measure.

More accurate methods have been devised by various thinkers throughout history from Archimedes to Newton and more.

There's a good article on various methods for calculating Pi at [link]
Add a Comment: