Code covered by the BSD License  

Highlights from
The Computation of Pi by Archimedes

5.0 | 5 ratings Rate this file 41 Downloads (last 30 days) File Size: 3.33 MB File ID: #29504
image thumbnail

The Computation of Pi by Archimedes



23 Nov 2010 (Updated )

Archimedes wrote 3 1/7 > pi > 3 10/71. This is how he did it.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information

Before there was floating point, or a way to write zero, or algebraic notation, Archimedes bounded the value of pi by estimating the perimeter of regular polygons inside and outside the circle. His computation is repeated and explained here using MATLAB.


Variable Precision Integer Arithmetic and Fractions Toolbox inspired this file.

MATLAB release MATLAB 7.12 (R2011a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (7)
02 Mar 2012 Zachary Danziger  
21 Feb 2012 Derek O'Connor

This is a lovely piece of work and is a credit to the author Bill McKeeman. This is a great example to use when explaining successive approximations and the difference between rational and floating point numbers.

With reference to Bill's and John D'Errico's comments I would like to make two points:


Unfortunately Mathworks's websites are so far behind the times that it makes publishing anything that includes mathematics very difficult, and anything such as Bill's work, nearly impossible, as he notes in his 20 Jun 2011 comment.

Mathworks should look at how Stack Exchange handles typesetting text, mathematics, code, and diagrams. Here are examples of my posts to Math Stack Exchange:

Square Root:

Sign of Perm:

Boolean Inverses:

The last example has a link to Mathworks's Answers

so you can can switch from Stack Exchange to Mathworks and back, to see the stark contrast.


I agree with John's two uses of FEX, but I would add a third: to see BAD code. As John knows well, such code can lead to very lively discussions indeed. These discussions can be very fruitful for all concerned, except perhaps the writer of the code.

It is for this third reason that I deplore Mathworks's policy of allowing code submissions and the discussion surrounding the submission, to be deleted by the author of the code. If authors knew that they could not delete their code, then they might be more careful about what they submit.

24 Jun 2011 Ben Petschel

Ben Petschel (view profile)

Very nice work.

23 Jun 2011 Bill McKeeman

MathWorks just fixed the bug that was messing up the text. So, I'll leave the entry where it is. Thanks Matthew.

Comment only
20 Jun 2011 Bill McKeeman

Unfortunately, MathWorks has made changes in the published form of this submission which make it harder to read. I plan to delete the entry in a few days.

Comment only
26 Nov 2010 Nicolas Cusseau  
24 Nov 2010 John D'Errico

John D'Errico (view profile)

There are two uses for the File Exchange that I love. One is to provide high quality code. The second is to teach others about some interesting part of mathematics and hopefully, write it using well written MATLAB code. This submission eminently qualifies. You can read it and learn something from what Bill has done.

24 Nov 2010

Typo in title page

26 Nov 2010

Rewrote some of the descriptive material.

27 Nov 2010

Improved wording.

01 Dec 2010

Minor fixes, sent wrong file last submission.

03 Dec 2010

Apologies for many updates. Wordsmithing again.

18 Feb 2012

Fixed type in Greek integer

26 Feb 2012

Still trying to change typo in Greek number

29 Feb 2012

Previous version did not have vpi or fr on the MATLAB path -- caused errors.

16 Mar 2012

The submitted zip file still did not have the right contents. Trying again.

23 Aug 2012

Added @vpi and @fr class directories

Contact us