Deviant Art Shop Mobile More Submit Join Login

# Calculating Pi with a Cannonby DovSherman

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.

### The Artist has requested Critique on this Artwork

Featured By Owner Mar 26, 2016  Student Digital Artist
Man it looks like that cannon is rocking out to some death metal
Featured By Owner Jun 27, 2011  Hobbyist General Artist
how long can this go on??!! I left it on left and came back and it was still shooting! Is there a limit??!!
Featured By Owner Jun 5, 2010
Very nice. We'll keep working on the "random" bit. What did you use for this?
Featured By Owner Jun 8, 2010  Professional Digital Artist
I'm sorry but I don't understand the question. Use for what?
Featured By Owner Jun 8, 2010
As in, did you write the code for this? And what program did you use for the graphics?

I'm no computer guy, just mathy and physicsy. I am interested in what exactly you're running here...

I'm afraid my questions are vague because my understanding is similarly vague...
Featured By Owner Jun 10, 2010  Professional Digital Artist
Oh, I see. It's a very simple Flash-based program, written with Flash Actionscript. I made the graphics myself - the canon using Swift3D and the rest with the simple graphics editor built into Flash.
Featured By Owner May 3, 2009
This is so amazing...so simple and yet - brilliant.
Featured By Owner Nov 22, 2008
isn't it somehow connected with the integral over the circular path?
Featured By Owner Apr 26, 2008
Wow... Thats an interesting way to calculate pi. I wish we did something like this in my math class.
thecoming Featured By Owner Oct 2, 2007
Jesus, you must know your computer programming
Featured By Owner Sep 1, 2007  Student Digital Artist
Wow, How long does this thing go for? It's well over 2000 right now and still going!
Featured By Owner Jul 2, 2007
things that make you go hmmm..
grrr math
Featured By Owner May 28, 2007
Interesting... and a touch confusing.
Featured By Owner May 10, 2007
Youre a math major arent you?
Featured By Owner Mar 8, 2010  Professional Digital Artist
No. My BA degree is in Animation. But I almost majored in Computer Science and I've been programming almost as long as I have been drawing. I took honors math classes in high school and was nominated to the NC School of Science and Math but just missed making it in on a technicality.
Featured By Owner Mar 24, 2007
Nice flash Yay for probobility theories!

Request: speed up the time between cannon fires and see how long it takes to get the first 100 digits of pi
Featured By Owner Mar 5, 2007
If I open the dictionary to the word "geek", do I find your face?
Featured By Owner Jan 27, 2007
Isn't the area of a circle Pi*radius squared? o_O
Featured By Owner Feb 13, 2007  Professional Digital Artist
Close. A circle with a radius of R has an area of 2*Pi*(R squared). If the circle is the same width as a square, that square has a diameter of 2R and an area of (2R) squared.

So that's 2*Pi*R*R for a circle and 4*R*R for a square. If we factor out the R squared, we get a ratio of 2*Pi to 4.
Featured By Owner Dec 5, 2009
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.
Featured By Owner Mar 6, 2010  Professional Digital Artist
Yes, that's what I said. 4*R*R == 4r^2
Featured By Owner Dec 17, 2008
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 =]
Featured By Owner Jan 6, 2007
Cool idea.
Never have heard of such a thing but now I know, kudos to you.
Featured By Owner Dec 24, 2006
I thought that if the cannon in thid deviation is alive cutely.
Piscatella Featured By Owner Dec 5, 2006
An artist and a nerd!!! ( and I really admire nerds and geeks) You are my hero!!!
Featured By Owner Feb 9, 2006
Awesome! I can only guess as to what possessed you to create this, but you did quite a good job at it. Fascinating.
Featured By Owner Dec 2, 2005
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.
Featured By Owner 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.
Featured By Owner Nov 27, 2005  Professional Digital Artist
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]
Featured By Owner Nov 26, 2005  Hobbyist Writer
It would be interesting if you actually graphed the results of certain number of random sessions with a certain limit. Even though this may not be truly random (and thus accurate) it would be interesting to just see what it comes up with as a result over time. At 1200 right now its hovering in the 3.10-3.11 range and randomly decreasing.
Featured By Owner Nov 26, 2005  Professional Digital Artist
It would run more quickly without the graphics, of course, and, when the idea for this program was first suggested in Scientific American (1985), Joshua Simons of the Harvard Medical School ran the program for one week, calculating 4 billion cannonball shots and coming up with an estimate of 3.14157 which is very good up until that 7 which, in Pi, is a 9.

Joseph McKean, a statistician at Western Michigan University, theorized that each additional digit of accuracy would require that the number of cannonball shots be increased by a factor of 100 which mounts up very quickly. For the first fifty digits, you'd need to calculate for a full googol of cannonball shots which would require more time than the expected lifespan of the universe.
Featured By Owner Nov 26, 2005  Professional Photographer
In theory, if this cannon fires enough times (for instance, infinity), it will get the exact number of Pi, right?
Featured By Owner Nov 26, 2005  Professional Digital Artist
It would definitely take infinity to do it. Even allowing for the fact that we're limited to the number of digits a computer can handle and the fact that random number generation isn't truly random (so the distribution may not be even), there's no way that two integers (the number of shots and the number of hits) can ever exactly match Pi. Pi is an irrational number which means that it can't be expressed as a ratio of two integers. However, in theory, it should get closer and closer to a match and, if it ran for infinity, it would come infinitely close to matching Pi.
Featured By Owner Feb 25, 2010  Student Filmographer
Yea, it would take a looooong time. Mine went well over 3000 and it was oy just past the 4 digit, and it was getting very slow since it was almost out of spots.
Featured By Owner Dec 17, 2005  Professional Photographer
So... much... math...
Featured By Owner Dec 17, 2005  Professional Digital Artist
Ah, but it's really, really simple math. The formula is....

4 x (number of shots that hit pond) / (number of shots total) = something close to PI
Featured By Owner Dec 18, 2005  Professional Photographer
For me, math ≠ simple.
Featured By Owner Nov 26, 2005   Interface Designer
wow, can you do my homework? lol

### Details

Submitted on
November 25, 2005
Image Size
10.9 KB
Resolution
500×550
Thumb

Views
15,782
Favourites
54 (who?)