May contain sensitive content
This filter hides content that may be inappropriate for some viewers
Log in to view

Deviation Actions

DovSherman's avatar

Calculating Pi with a Cannon

Published:
By
24K Views

Description

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.
Image details
Image size
500x550px 10.89 KB
Sensitive Content
© 2005 - 2022 DovSherman
Comments40
Join the community to add your comment. Already a deviant? Log In

I remember reading about this... this... project in a (computing?) magazine in the 80s. But I never really got it. I tried creating this simulation on a 32-bit system, and the results seemed to converge on 3.6. I also wondered how the randomness was defined. Do you just choose and random x and y for the field? Or a random elevation, azimuth and range for the cannon?