Basics Archives Community Services Programming
Hardware Help About Search Your Account
Home :: Archives :: News :: Feature: Calculating Pi

Feature: Calculating Pi
Posted by Nick on 14 March 2000, 03:57 GMT

I hope everyone is having a very happy Pi Day! In case you don't know, today (March 14) is Pi Day. In honor of this, this week's feature will be in homage of our favorite irrational number. Andy Selle has written us a feature regarding pi and its origins.

Check out the updated version instead. It is available in PDF or HTML

# Calculating : an explorative tour

Andrew Selle (aselle@ticalc.org)

### Abstract:

A look at calculating with a TI graphing calculator. This article goes through a variety of methods for finding the ever closer decimal approximation of our favorite trancendental number.

## Introduction

is a very interesting number. We are first introduced to it early in our grade-schooling as a component of the formulas and . It seems odd to us that we need to use this number. Where did it come from? How did we ever figure it out? These our questions that I hope to address and perhaps answer. However, the major point of this article is to explore methods of calculating using a Texas Instruments graphing calculator (and perhaps a few computers).

## History

The history of is a long one. The first significant advancement in the understanding of was the Ancient Greeks. They came up with the concept of inscribing a polygon inside a circle. As you added more sides to the polygon, the polygon became closer and closer to a circle. By taking the ratio between the polygon's area to the circle's area, you could find Thus, the first method of calculating was born.
During the middle ages, time for calculating was not readily available. Even when it was, the polygon inscribing method was very slow and painstaking. It was eventually discovered that an infinite series approximating was a good means to calculate . Once the computer was invented, was quickly calculated to many places.

This history is in no way complete, but it covers the major ideas.

## Math

Obviously, a lot of math is involved in calculating . I will derive all my mathematics as completely as possible, but don't be afraid to skip the derivations if you are not interested. I will highlight the important results found to make this easy.

# Monte Carlo Method

## Derivation

One of my favorite methods, and one of the simplest to understand is the Monte Carlo method. I first ran into this method when I was learning BASIC for my Apple II. One sets up a square that is 2 by 2. One then inscribes a circle inside the square. Random points are then plotted repeatedly. For each point we add one to the variable n, and if the point is within the circle we add one to the variable i. Then to calculate we simply put together what we know. ,areasquare = 4. Now, we can setup the proportion . Thus,

## Implementation

This program can be easily implemented in 8x TI-BASIC as:

:0 --> N0 --> D
:While 1
:rand*2-1 --> X
:rand*2-1 --> Y
:If sqrt(x^2+y^2)=< 1
:N+1 --> N
:End
:D+1 --> D
:Disp (N/D*4)
:End

## Bibliography

1) Dara Hazeghi: Dara's Pi Page http://www.geocities.com/EnchantedForest/5815/,
Accessed 3/4/2000
2) JOC/EFR: Pi Through the Ages http://www-groups.dcs.st-and.ac.uk/

If you don't yet know how to celebrate Pi Day, here's a few tips:

• Watch the movie Pi. It was written rather recently, and it's a bit artsy, but I love it. I'm planning on watching it with friends during the evening.
• Serve pie to your classes, or if you don't have enough pie, have it for dinner!
• Be psychotic like me and memorize sixty digits of pi. :)

Best wishes to you during this Pi Day season.

 The comments below are written by ticalc.org visitors. Their views are not necessarily those of ticalc.org, and ticalc.org takes no responsibility for their content.

Re: Feature: Calculating Pi
Gohan
(Web Page)

Pi=3.14, nothing really to get so excited about. (in my opinion) LoL!

14 March 2000, 05:13 GMT

Re: Re: Feature: Calculating Pi
lexlugger
(Web Page)

According to my physics teacher Pi=3. My teacher also claims that the only numbers ever used in physics are 0, 1, e, Pi, 5, and 10^x where x=any integer.

14 March 2000, 14:15 GMT

Re: Re: Re: Feature: Calculating Pi
Ciaran McCreesh
(Web Page)

I didn't know about the 5, I've seen some 1/2, I suppose that is 5x10^0. Surely c comes in quite a bit as well, I mean isn't the SI stuff based upon it?

Ciaran

14 March 2000, 20:04 GMT

Re: Re: Re: Re: Feature: Calculating Pi
Scott Noveck
(Web Page)

5 * 10^0 = 5

you meant 5 * 10^1

15 March 2000, 03:12 GMT

Re: Re: Re: Re: Re: Feature: Calculating Pi
Ciaran McCreesh
(Web Page)

Actually I meant 10^-1, didn't I? 10^-1 is 0.1 I think.

Ciaran

15 March 2000, 19:47 GMT

Re: Re: Re: Re: Feature: Calculating Pi
Ken

5x10^0
=5x1
=5

15 March 2000, 03:16 GMT

Re: Re: Re: Feature: Calculating Pi
ikecam
(Web Page)

Concerning the number 3, I think your teacher has pi confused with his IQ.

14 March 2000, 21:27 GMT

Re: Re: Re: Re: Feature: Calculating Pi
Native

"Concerning the number 3, I think your teacher has pi confused with his IQ.
"

LOL.
At least its better then people spouting on and on over a subject that they don't know anything about.

Maybe that persons teacher only carries a certain number significant digits.

=)

15 March 2000, 04:27 GMT

Re: Feature: Calculating Pi
Mike Fletcher
(Web Page)

On PI day '99 I found the poem at http://users.aol.com/s6sj7gt/mikerav.htm
It's called "Near a Raven" and it's a constricted poem about PI modeled after Poe, it's something to read with friends on Pi day!
Mike

14 March 2000, 05:16 GMT

Re: Feature: Calculating Pi
RongZeng

So...Did anyone have any pi?

14 March 2000, 05:48 GMT

HELLO PEOPLE!!!!
BrandonAGR
(Web Page)

Jeez you people, do you not even read the article! The code that he presented will not work. The formula is wrong.
I modified the program above to make it better, so here it is. It is written in Ti-83 Basic.

:ClrDraw
:0->N:0->D
:-1->Xmin:1->Xmax
:-1->Ymin:1->Ymax
:Circle(0,0,1
:While 1
:rand*2-1->X
:rand*2-1->Y
:Pt-On(X,Y
:If sqrt(X^2+Y^2)<=1
:N+1->N
:D+1->D
:Text(0,0,(4N/D)
:End

And I don't think that this method is that good, it only gives pi after it runs for like 3 hours.

14 March 2000, 06:03 GMT

Re: HELLO PEOPLE!!!!
BrandonAGR
(Web Page)

Ok, after running this program for exactly 26 minutes and 44.76 seconds, I arrived at the number
3.1453438
And as you all know, pi is:
3.1415927

So basically, it takes about 8 minutes to confirm one digit.
Although I must admit, this is pretty cool, I always wondered how you could calculate pi.

14 March 2000, 06:38 GMT

Re: Re: HELLO PEOPLE!!!!
brentes
(Web Page)

geese people.. this will give an EXACT answer:
****************************************
4(tan-1(1/2)+tan-1(1/3))
****************************************
the tan-1 is the arctangent or whatever

14 March 2000, 06:49 GMT

Re: Re: Re: HELLO PEOPLE!!!!
rabidcow
(Web Page)

or 4*arctan 1

or 1/(sqrt(8)/9801*sum{n=0 to inf}((4n)!(1103 + 26390n)/(n!)^4(396^(4n))))
which gains 8 digits of precision with each term (can't write sigma notation here...)

14 March 2000, 07:10 GMT

Re: Re: Re: Re: HELLO PEOPLE!!!!
Jimmy Mårdell
(Web Page)

This is even faster:

a[0] = sqrt(2); b[0]=0; c[0]=2+sqrt(2);

a[n+1] = (sqrt(a[n])+1/sqrt(a[n]))/2;
b[n+1] = sqrt(a[n])*((b[n]+1)/(a[n]+b[n]));
c[n+1] = c[n]*b[n+1]*(1+a[n+1])/(1+b[n+1]);

DOUBLES the number of correct decimals each iteration. Oh, pi is in c[n] btw.

14 March 2000, 14:23 GMT

Re: Re: Re: Re: Re: HELLO PEOPLE!!!!
Chris Fazio

MY GOD PEOPLE!! How the hell do you figure this out? I THINK I'M GOING INSANE!

14 March 2000, 15:43 GMT

Re: Re: Re: Re: Re: HELLO PEOPLE!!!!
darkness

Jimmy, are you sure this is the right information? When I run it, I get ungodly numbers.....

14 March 2000, 16:40 GMT

Re: Re: Re: Re: Re: HELLO PEOPLE!!!!
rabidcow
(Web Page)

i would have put this one in there before, except i didn't think of using the square brackets :) multiplies by 4 each iteration:
a[0]=6-4sqrt(2)
y[0]=sqrt(2)-1
y[n+1]=(1-(1-y[n]^4)^.25) / (1+(1-y[n]^4)^.25)
a[n+1]=(1+y[n+1])^4*a[n] - 2^(2n+3)*y[n+1]*(1+y[n+1]+y[n+1]^2)

pi being a[n]. there's supposedly one that multiplies by 5 somewhere.
and, no i didn't just figure these out!! they're out of a book. some "s ramanujan" guy figured them out. i have no idea how.

one more thing... just think, in 15 years it'll be 3-14-15

14 March 2000, 18:37 GMT

Re: Re: Re: Re: Re: Re: HELLO PEOPLE!!!!
CircaX
(Web Page)

Ive got an even faster method for calculating pi, but it is accurate to only about 9 decimal places.

the equation is:
2nd button
pi key

yes! the fastest method!

14 March 2000, 20:59 GMT

Re: Re: Re: Re: Re: Re: Re: HELLO PEOPLE!!!!
rabidcow
(Web Page)

naw, that requires actually *finding* the calculator!

15 March 2000, 01:22 GMT

Re: Re: Re: HELLO PEOPLE!!!!
EvanMath

I'm just going to put three unrelated replies here:

To a post much farther up:
I actually did memorize pi to 69 digits, it's quite easy if you do it over a period of a couple weeks, for anybody interested, I also enjoy memorizing poetry, especially Poe's "The Raven". At the moment, I have the first seven stanzas memorized.

To the post two levels down:
pi = 3.14159265+
not 3.1415927

To the post just before this one(the one that I'm actually replying to):
It's not exact. It's only accurate to the calculator's accuracy. Okay,now everybody flame me about how geeky I am :)

14 March 2000, 22:59 GMT

Re: Re: Re: Re: HELLO PEOPLE!!!!
ikecam
(Web Page)

If you do it on a calculator, you'll get an approximation, but the formula does give an exact answer.

15 March 2000, 02:46 GMT

1  2  3  4  5  6  7

You can change the number of comments per page in Account Preferences.

Copyright © 1996-2012, the ticalc.org project. All rights reserved. | Contact Us | Disclaimer