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 pi: an explorative tour

Andrew Selle (aselle@ticalc.org)


A look at calculating pi 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.


pi is a very interesting number. We are first introduced to it early in our grade-schooling as a component of the formulas A=pi*r^2and C=2*pi*r. 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 pi using a Texas Instruments graphing calculator (and perhaps a few computers).


The history of pi is a long one. The first significant advancement in the understanding of pi 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 pi Thus, the first method of calculating pi was born.
During the middle ages, time for calculating pi 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 arctan was a good means to calculate pi. Once the computer was invented, pi was quickly calculated to many places.

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


Obviously, a lot of math is involved in calculating pi. 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


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. area(circle)=pi*r^2,areasquare = 4. Now, we can setup the proportion 4/pi=i/n. Thus, pi=(4i)/n


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
:D+1 --> D
:Disp (N/D*4)


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 Account Info
(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  Account Info
(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  Account Info
(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?


     14 March 2000, 20:04 GMT

Re: Re: Re: Re: Feature: Calculating Pi
Scott Noveck  Account Info
(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  Account Info
(Web Page)

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


     15 March 2000, 19:47 GMT

Re: Re: Re: Re: Feature: Calculating Pi
Ken Account Info


     15 March 2000, 03:16 GMT

Re: Re: Re: Feature: Calculating Pi
ikecam  Account Info
(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

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

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  Account Info
(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!

     14 March 2000, 05:16 GMT

Re: Feature: Calculating Pi

So...Did anyone have any pi?

     14 March 2000, 05:48 GMT

BrandonAGR  Account Info
(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.

:While 1
:If sqrt(X^2+Y^2)<=1

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

BrandonAGR  Account Info
(Web Page)

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

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

(Web Page)

geese people.. this will give an EXACT answer:
the tan-1 is the arctangent or whatever

     14 March 2000, 06:49 GMT

Re: Re: Re: HELLO PEOPLE!!!!
(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  Account Info
(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  Account Info

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  Account Info

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!!!!
(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:
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  Account Info
(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!!!!
(Web Page)

naw, that requires actually *finding* the calculator!

     15 March 2000, 01:22 GMT

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

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  Account Info
(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