Skip to main content

5 Methods for Approximating Pi

Animated pi symbol
Happy super-π day! π-day falls on March 14 every year, because the month-day combination results in 3-14, which are the first 3 digits of π. But this π-day is particularly special: include the year, and you get 3-14-15, the first 5 digits of π. We won't get another π-day like this for another 100 years, so you better enjoy this one!

A particularly special time will be at 9:26:53 PM tonight, when we'll get 3-14-15 9:26:53, or the first 10 digits of π.

In honor of the occasion, I'm going to post 5 simple methods for approximating the value of π.


1. String and Tape Measure

Draw a circle with a diameter of 1 foot and put a piece of string around the edge. Cut the string until it's the right length, and then measure it with a tape measure. The string should be about π feet long.

This can be implemented more accurately using a computer program: take the arc length of √(1 - x2) on the interval (-1, 1). The result should be π.




2. Monte Carlo

Using the Monte Carlo method, the value for π can be approximated by drawing a square with a circle fitting perfectly inside it, and throwing rice high over the square. Let a equal the total number of grains that fall inside the square, and let b equal the number of grains that fall inside the circle. Assume the circle's radius is 1 unit, so the area of the circle is π square units. The square's area is 4 square units. On average, b / a = π / 4, so π = b * 4 / a.

This can also be implemented using a computer program. Pick random points with x-values between -1 and 1 and y-values between -1 and 1. Count the number of points within a distance of 1 from the origin, and proceed with the math as before.




3. cos(π/2) = 0

When most people talk about an angle, they use degrees - as in 90° (a right angle), 180° (a U-turn), and 360° (1 full turn, or very dizzy). But mathematicians use radians, which involves looking at the circumference of a unit circle, so instead of a full circle being 360°, it's equal to 2π (the circumference of a unit circle). A U-turn, or 180°, is equal to π, and a right-angle (90°) is equal to π/2.

Using radians, cosine of π/2 is equal to 0. So to figure out what π is, just plug some angles in and see what works. When you get an angle that works, multiply by 2 and you have π. (For my post about sine and cosine, click here.)

If you use an angle that is too big, the cosine is negative; if use an angle that's too small, cosine is positive. So, instead of making random guesses, you can actually improve your guesses over time.

In fact, because cosine is negative when the angle is too big, and cosine is positive when the angle is too small, the following method that I discovered works really well (where θ is the angle being tested):
A. Start with θ = 0
B. Add cos(θ) to θ
C. Go back to step B

After repeating those steps only 4 times, and multiplying your angle by 2, you'll get a surprisingly good approximation of π.

Alternatively, if you know the Taylor series for arcsin(x), you could use that to find the value for arcsin(1) and double it to get π.




4. Integral

We want to find the area of a circle, right? So why not just, well, find the area?

The formula for the top half of a circle is √(1 - x2). If we take the integral of that function from -1 to 1, and multiply by 2, then bingo! We get pi. (For those who haven't reached calculus, the integral is the area under the curve.) To do this, a numerical approximation works well: start with x = -1, and gradually increase x until it reaches 1; meanwhile, evaluate √(1 - x2) at each point, multiply by the step size, multiply by two, and add the values all together. (You can also use the indefinite integral, but that involves arcsin(x), which would require a Taylor series to solve.)

This technique works best when implemented using a computer program. In JavaScript, you would use some code like this (try changing "step" to something smaller than 0.1!):




5. Many-sided polygon

A circle is like a polygon with tons of sides, right? So if you can find the area of a 1000-sided polygon, that should be pretty close to π. Now how might we do this?

Suppose we have an n-sided polygon. The angle of a single sector of the polygon is equal to 360°/n degrees. Divide the sector into 2 right-angled triangles, and each triangle has an angle of 180°/n degrees. Now assume that the base of each triangle has a length of 1. We can get the area of each triangle by taking 1*tan(180°/n)/2. Since we divided each sector into 2 parts, we multiply by 2 to get the area of the sector: tan(180°/n). Multiply by the number of sectors to get n*tan(180°/n) for the area of the polygon.

But tan(θ) = sin(θ) as θ approaches zero, so the area of an n-sided polygon is equal to n*sin(180°/n).

Now, when x is very large, we can get a reasonable approximation for π. There's one problem, though. When a computer calculates sin(θ) in degrees, it converts to radians using a built-in value of π. In other words, our formula relies on somebody else's value of π in order to compute its own value of π. Which is stupid.

However, we can use geometry to prove that the value of sin(45°) = cos(45°) = 1/(√2). Based on that, we can use the half-angle formulas for sin and cos to compute values of sin(45/2°), sin((45/2)/2°), and smaller angles. To make sure our angles are half values of 45°, we can only work with polygons that have 8*2m sides (with m an integer).

I'll leave it at that.


New posts every month - subscribe for free!


Comments

Popular posts from this blog

Should Tau Replace Pi?

The digits of π, organized in a very new way Happy π-day! And happy π-month! Today's month and day - that is, March 14 or 3.14 - includes the first 3 digits of π. And today's month and year - March 2014 or 3.14 - also includes the first 3 digits of π. We won't have another double-day for π for the next 100 years, so enjoy this one! For the special occasion, I'm posting two π-related posts - one for π-month, and the other for π-day. In both posts, I'm setting the font size to approximately π * π + π + π. This is the first post, for π-month; to see the second, go to http://greatmst.blogspot.com/2014/03/pi-month-pi-day-post-2-5-common-pi-myths.html . In this post, I am including an essay I wrote about whether π or τ is the more superior constant. This was written for people who know very little about math, so the basic idea should be easy to understand even for people who are not mathematically inclined. Should Tau Replace Pi? A constant is any number or value that ne...

The Geminids

The Geminid meteor shower is coming up! At 2:00 AM, on December 14 (that's Thursday night, or Friday morning), you can see anywhere from 100 to 150 meteors per hour - depending on the sky and weather conditions. That's more than 1 meteor per minute! This particular meteor shower comes from a 5.1 km wide asteroid called 3200 Phaethon. Flecks of debris fall off this asteroid in a trail around the sun. These bits are called meteoroids . Every year, in December, Earth passes through this stream of meteoroids; when one of them enters Earth's atmosphere, it burns up and we see a meteor. If the meteor is brighter than Venus, it's called a fireball. Fireballs are much less common than meteors. This year, viewing conditions will be especially good; the peak occurs only 1 day past new moon. If you live in an area with lots of light pollution, you will definitely want to drive into the country. If you think the weather will be bad, go out a day or two before or after the peak. Kee...

Which Hurts More?

212° F Let's play a little game. I'll list a bunch of possible actions. Each action will have 2 variations, (a) and (b). You choose either (a) or (b), depending on which would be safer (or less painful). Each of the questions will involve an oven hot enough to bake a cake (350° F), and a pot of boiling water (assume we're at sea level). So... would you rather: 1.     (a) Stick your hand in the oven     (b) Stick your hand in the boiling water   ... for a period of 10 seconds 2.     (a) Leave a fork in the oven     (b) Leave a fork in boiling water   ... for a period of 15 minutes. Then hold the fork tight with your bare hand. 3. Fill a jar to the top with cool tap water. Then:    (a) Place the jar in the oven    (b) Place the jar in the boiling water   ... for a specific, but unknown, period of time. Then remove the jar and put your hand in it. First see if you can figure these out yourself. They shouldn't be too...