Basics Archives Community Services Programming
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
(Web Page)

Here's an interesting tidbit, distantly related to the topic at hand.

e^(pi * i) + 1

You can use your calculator :)

I think I found that in someone's signature file at slashdot :)

14 March 2000, 06:55 GMT

Re: Re: Feature: Calculating Pi
Mike Grass

My calculus book last year said something like this about Euler's equation (e^(pi*i)+1=0):

"This amazingly compact equation, which brings together five of the most celebrated numbers in mathematics, is an example of how truly beautiful and simple math can be."

Anyway, I thought I would share that. The book then went on to explain (with Taylor approximations) how Euler came up with the equation.

Ahh, calculus :)

14 March 2000, 07:15 GMT

Re: Re: Re: Feature: Calculating Pi
Ian Bui
(Web Page)

Yes, e^(i*x)=cosx+isinx.
e^(i*pi)=cos(pi)+isin(pi)=-1
Therefore, e^(i*pi)+1=0

14 March 2000, 07:30 GMT

Re: Re: Feature: Calculating Pi
grinik

I was given a question about that expression a while ago, and my TI-89 gives a domain error. I don't have any other Texas Instruments calculators, so I don't know if that is a normal thing to happen or not. <possibly offensive>
Also, my Casio CFX-9850G gives a memory error.
</possibly offensive>

Does anyone know any more about what's going on in the calculators' brains than I do?

14 March 2000, 23:27 GMT

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

e^(i*pi) spits out -1 on the TI-86. But unlike the 89, it's doing it numerically, so it doesn't have to know the rules of imaginary exponent manipulation. Try putting the 89 in approximation mode.

15 March 2000, 02:50 GMT

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

The 89 needs some proper modes set (I believe it's complex format = rectangular and something else). If i^i works under the current mode than so will e^(pi*i)+1=0

15 March 2000, 03:16 GMT

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

It has to be in radian mode

16 March 2000, 23:05 GMT

Re: Re: Re: Feature: Calculating Pi
WhySanity

I happen to own a CFX-9850GB Plus and am after a Alebra FX 2.0 <-- check it out... shows you how to solve the equation... step by step... symbolic manipulation too

15 March 2000, 04:09 GMT

Re: 89, imaginary exponents
Niten
(Web Page)

You're using AMS 1.00/1.05, right? Just upgrade to AMS 2.03... it handles imaginary exponents just fine :)

(I tried it out with VTI on AMS 1.00 and my real 89 with AMS 2.03, showing _exactly_ how much of a social life I have ;) )

Other benifits of AMS 2.03 are faster and more precise results when finding approximate roots of something using solve or csolve and the added delta-List function... just other things I've noticed when doing team rounds with friends who have 89s. There's probably more, I guess... who knows.

15 March 2000, 05:00 GMT

Re: Feature: Calculating Pi
Robert Xeon Smith
(Web Page)

Beat ya' all. I got 100 digits memorized. I wish I had more time for the next 100.

Here's how I chunked it up to memorize it. :-D

3.14159
2653589
793
23846
26433
832
795
0288419
7169399
375
105
8209
749
4459230
781640
628
620
8998
6280
3482
5342
117
067

S.T.L.

14 March 2000, 07:02 GMT

Re: Re: Feature: Calculating Pi
MaraZ

I can do better.

PI=

3.1415
9265
3589
7932
3846
26433
83279
50288
41971
69399
3751
05820
974
944
59230
78164
062862
0899
8628
03482
5342
1170
679
8214
8086
5132
823066
4709
3844
60955
05822
31725
3594
08128
48111
74502
84102
70193
85211
05559
6446
2294
8954
9303
8196
44288
10975
665

totally 213 decimals. beat that.

14 March 2000, 17:10 GMT

Re: Re: Re: Feature: Calculating Pi
JaggedFlame

actually, if you scroll up, you'll see someone who beat that (took me forever to page down through his post) ;-)

14 March 2000, 23:32 GMT

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

I do believe he was reciting that from his calculator's memory...

15 March 2000, 00:30 GMT

Re: Re: Re: Re: Feature: Calculating Pi
Philip Ringsmuth
(Web Page)

You mean my post with 50,000 digits? They deleted that because it was obviously breaking some regulation. Oh well, I could always post it again...

-Fil

15 March 2000, 04:56 GMT

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

I could post 12.5 million digits (and I actually know them all off by heart, smirk, well actually I know 700 and a bit) if I could be bothered copying them from another file I have.

Ciaran

15 March 2000, 19:49 GMT

Re: Feature: Calculating Pi
Ian Bui
(Web Page)

OH MY GOSH!!! I hadn't realized it was Pi day, but I was walking around with my Great Book of Pi today showing it off. What a coincidence!

14 March 2000, 07:27 GMT

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

You guys should check out the book 'Pi in the Sky' -- can't remember the author -- it's about number theory, etc,etc -- lots of great examples, anecdotes, and biographies. Great section on the development of numerosity, too.

14 March 2000, 18:25 GMT

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

Imagine publishing a book that was only the number pi?
AND having it at least novel size? (over 200 pages)

14 March 2000, 21:02 GMT

Re: Re: Re: Re: Feature: Calculating Pi
JaggedFlame

no, it should be 31415926535 pages long (any longer would make the book too big to fit in a library) ;-)

14 March 2000, 23:33 GMT

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

Or how about 3.14159 pages? It would certainly be easier to publish...

15 March 2000, 18:08 GMT

Re: Re: Re: Re: Re: Re: Feature: Calculating Pi
Nick Chaves
(Web Page)

How do you have .14159 of a page? Because, really, if you think about it, every page is a whole page in and of itself.

Nick

"To me, boxing is like a ballet, except there's no choreography and the dancers hit each other."

16 March 2000, 02:13 GMT

Re: Re: Re: Feature: Calculating Pi
perl-guy

_Pi in the Sky: Counting, Thinking, and Being_ by John D. Barrow. Oxford: Clarendon Press, 1992. ISBN 0-19-853956-8.

I recently got it but haven't had time to read much of it. It looks really good thought. It has lots of interesting facts. For example, did you know that Pathagoras was the leader of a math cult whose religious foundations were crushed when they discovered the square-root of two (by none other than the Pythagorean Theorem of course)?