Thursday, December 17, 2009

How does a calculator figure out Pi?

I'm perplexed on how a calculator can find out Pi. Especially when a calculator goes to maybe the hundred billionths place. Does anyone know how a calculator does that?How does a calculator figure out Pi?
There are many ways of calculating pi, both by hand, and by computer. Here is one common way.





Using trig functions, you can see that the tangent of a 45 degree angle = 1 (since sin and cos are the same). 45 degrees is also equal to pi/4 radians.





So atan(1) = pi/4





You can solve for the atan(x) using something called a Taylor series, below.





atan(x) = x - x^3/3 + x^5/5 - x^7/7 + x^9/9...


so:


pi/4 = atan(1) = 1 - 1/3 + 1/5 - 1/7 + 1/9...





atan(1) takes a really long time to converge. In other words, you would have to sum up a whole lot of numbers, just to get a few accurate digits of pi. So some really smart people figured a faster way where:





pi/4 = atan(1) = 4 * atan(1/5) - atan(1/239)


pi = 4 * (4 * atan(1/5) - atan(1/239))


pi = 16 * atan(1/5) - 4 * atan(1/239)





If you have the time, and are bored out of your mind, you can actually sit down and plug (1/5) and (1/239) in the Taylor series equation for atan and solve pi by hand using this formula. You can go out to how ever many digits you feel like, depending on how many sums you want to add up.How does a calculator figure out Pi?
There are infinite series that can be used to find values of pi, for example





π = 4/1 - 4/3 + 4/5 - 4/7+ 4/9 - 4/11.....





Notice that each term gets smaller, so the more terms you use the closer to pi the total gets. A computer can easily to many terms quickly.





There also series that converge much more quickly. These are preferred as you need foewer temrs for higher accuracy.
There is a ';number series'; which is a string of calculations which are very simple. All combined, you get pi. The calculator can do thousands of these calc's in a second. Some calculators just have pi as a fixed number in memory.





Mathgirl, Nice Post! Isn't it amazing that sSome geniuses long before you and I were born came up with those series. Taylor, Finonocci, etc....
Calculators have it built in to whatever the accuracy they work to is. You mean how do computers calculate π to very high precision.





Computers use rapidly converging formulae to calculate π, whose derivation usually relies on very deep and mysterious number theoretic results. As far as I know, the fastest converging series is due to Chudnovsky and Chudnovsky, two brothers who built a supercomputer in their apartment to enumerate π to billions of decimal places. It's the algorithm Mathematica uses, and that can get you a million digits of π in seconds. On my ancient 1500 MHz P4 it takes just 33 seconds.
its like you are dividing 22 by 7 which is the value of pi

No comments:

Post a Comment