Search
As of October, 2016, Embarcadero is offering a free release
of Delphi (Delphi
10.1 Berlin Starter Edition ). There
are a few restrictions, but it is a welcome step toward making
more programmers aware of the joys of Delphi. They do say
"Offer may be withdrawn at any time", so don't delay if you want
to check it out. Please use the
feedback
link to let me know if the link stops working.
Support DFF  Shop
If you shop at Amazon anyway, consider using
this link. We receive a few cents from each purchase.
Thanks.
Support DFF  Donate
If you benefit from the website, in terms of
knowledge, entertainment value, or something otherwise useful,
consider making a donation via PayPal to help defray the
costs. (No PayPal account necessary to donate via credit
card.) Transaction is secure.
Contact
Feedback:
Send an
email with your comments about this program (or anything else).

 
Problem Description
Archimedes made a significant contribution to mathematics when he developed
the first
iterative method for calculating the value of Pi with greater
precision that then existed. This program satisfies my curiosity about how
he did it.
Background & Techniques
Here is an illustrated description of Archimedes' method for estimating Pi
developed a couple of hundred years BC. Starting with circumscribed and
inscribed hexagons for a given circle, he calculated the perimeters and used the
ratio of each perimeter to the diameter of the given circle as an estimate of
Pi ( = Circumference/Diameter). Since the circumscribed perimeter will be larger than the circumference of
the circle, the derived estimate of Pi will be too large. Similarly the
inscribed perimeter will be too small and produce a low estimate. As the number
of sides increases, the two estimates converge towards Pi.

Pi is between
3.0 and 3.464
(but it gets better)! 
Archimedes started with what was probably the largest number of sides for which
he knew the actual ratio of the side lengths to the diameter, a hexagon. He then
cleverly derived the ratios for 12 sided regular polygons and repeated the same logic for 24, 48, and 96 sided polygons. Most
online
explanations of Archimedes procedure cheat and use trigonometry but here we'll
do it the way Archimedes did it using only algebra and geometry. The English
translation of Proposition 3 in "The Measure of a Circle" used as my
source and is from "The
Works of Archimedes" translated from Greek by T. L. Heath and published in 1897.
A free download is available
here.
After 4 iterations, Archimedes determined that the true value of Pi lies
between 3^{10}/_{71} and 3^{1}/_{7} . Decimal terminology had not yet been
developed so he used rational fraction estimates for irrational values, starting
with estimates for the square root of 3, but making sure that the error
introduced only made his estimate worse than if he could have used the true
value. Pretty smart fellow!
In the text below, I'll describe the "clever" part in getting from the
known perimeter of the hexagon to the perimeter of the 12 sided polygon.
Actually, he only needed to concentrate on the length of one side and what
happens to side lengths if we bisect the N sides to create a polygon with 2N sides.
The technique for interior and exterior side lengths both use Euclid's Angle
Bisector Theorem: "The angle bisector any angle in a triangle divides the
opposite side in the same ratio as the sides adjacent to the angle." It is from
Euclid's Book VI, Proposition 3 and, as Heath did, we'll refer to it as
EUCL
VI.3 when it is used in the following explanations. Archimedes tended to omit intermediate steps
and explanations in his proofs. Heath added some explanatory text in his
translation and I've added more explanation for the parts that weren't as
obvious to me as they must have been to Archimedes and Heath.
Circumscribed Detail
Here is Archimedes' derivation of the Pi estimate for circumscribed polygons.
Heath placed his explanations in [ ] brackets which I have tried to retain.
For the exterior hexagon, he considers the triangle formed by connecting point
O, the circle's center to point A, the point of tangency of a side, to point C,
the end of that side. He knows that angle AOC is 1/3 of a right angle (30
degrees to us). He also knows that, for such a triangle (which we commonly call
a 306090 triangle):
Archimedes then says:
(1) the ratio of OA:AC [= sqrt(3):1] >265:153 and
(2) the OC:AC ratio is [= 2:1] = 306:153.
Me: From this we can derive a 1st estimate of Pi as the perimeter divided by the
diameter (twice the length of OA ) or 12*AC/(2*OA) = 6*(AC/OA)=6*1/sqrt(3)=3.464
or, for Archimedes since decimal notation did not yet exist, it would be ratios
of the semiperimeter to the radius = 6/(265/153) = 918/265 which also happens
to be 3.464. We'll use this same concept to
track the values for the rest of the exercise.
Now he goes on to work on the on the 12 sided polygon:
Archimedes: First, draw OD bisecting the angle AOC and meeting AC in D.
Me: So that now AD represents half
the length of one side of a 12 sided polygon.
Archimedes:
Now CO:OA=CD:DA [By EUCL VI.3]
So that [(CO+OA):OA = CA:DA or]
(CO+OA):CA = OA:DA
Me: I had to step through it this way:
CO/OA=CD:DA
CO/OA+1 = CD/DA +1
==> CO/OA+OA/OA = CD/DA + DA/DA
==> (CO+OA)/OA = (CD+DA)/DA
==> [(CO+OA)/OA = CA/DA]
Multiply both sides of the above by OA/CA to get
==> (CO+OA):CA = OA:DA
Archmedes: Therefore [by (1) and (2)] OD/DA > 571/153 (3)
Me: The estimate for Pi, for the 12 sided polygon, if A. had bothered to record
it, is
Pi < 12*AD/OA=12*153/571 = 3.215
Archimedes:
Hence OD^{2} : AD^{2)} [= (OA^{2} + AD^{2})
: AD^{2}] > (571^{2} + 153^{2}) : 153^{2}
> 349350 : 23409,
So that OD/DA > 591^{1}/_{8} : 153 (4)
Me: Pythagoras allows us to replace the square of hypotenuse OD with the
sum of the squares of sides OA and AD. We now have the ratios for the triangle AOD which we can bisect again, giving
Archimedes' point E for the 24 sided polygon and giving an OA/AE ratio of
1162.125/153 and a Pi estimate of 24*153/1162.125=3.160.
Similarly Archimedes uses AOE to calculate AOF for the 48 sided case, he gets
2334 1/4 : 153 and we can calculate Pi < 153*48/2334.25 = 3.1462.
An finally, from AOG, the 96 side case, he gets 4673 1/2 : 153 and Pi <
153*96/4673.5 = 3.1428 which he expresses as 3 ^{1}/_{7}. His completed figure includes
one additional line, AH, merely to show the full extent of a side for the final
polygon
Inscribed Detail
Calculating Pi estimates for the inscribed polygons seemed trickier than for
circumscribed. Again, I'll expand the Archimedes proof to add my explanations of
things which may not be obvious to us mere mortals.
Archimedes: Let AB be the diameter of a circle and let AC meeting the circle at
C make the angle CAB equal to one third of a right angle. Join BC.
Then AC:CB [sqrt(3):1)] < 1351 :780.
Me: This time the estimate of sqrt(3) is greater than the true value so we can be
sure that it does not make the estimate, which will always be low, closer than
the rest of the mathematics might indicate.
We can make our first estimate of Pi from the known ratios From the given
triangle; we know that the ratio of the diameter (AB) to one side of the hexagon
(CB) is 1/2 so our initial (low) estimate of the value of Pi is 6/2 or 3.00.
Archimedes: First let AD bisect the angle BAC and meet BC in d and the circle in
D. Join BD.
Then angle BAD = angle dAC = angle dBD and the angles at D and C are both right
angles.
It follows that the triangles ADB [ACd], and BDd are similar.
Me: BAD = dAC by construction . Angles at D and C are right angles because they
are angles inscribed in a semicircle which are always right angles. (Search the Web
for "angle inscribed semicircle" for many proofs). The vertical angles at
d are
equal. So angle dAC = 18090Cda = 18090DdB = DBd, The three triangles thus all have the same three angle values
and so are similar by definition.
Archimedes:
Therefore AD : DB = BD : Dd [=AC : Cd] =AB : Bd [Eucl. VI.3] = AB + AC : Bd + Cd
= AB + AC : BC or BA + AC : BC = AD : DB
Me: It might be obvious to geometers, but it wasn't clear to me that if AC:Cd=AB:Bd
then it is also true that AC:Cd = (AC+AB):(Cd+Bd). Here's my proof:
AC/Cd=AB/Bd = some constant, k. So AC= k*Cd and AB = k*Bd.
Adding these
equations, we get AC+AB=k*Cd+k*Bd, so AC+AB= k*(Cd+Bd) and (AC+AB)/(Cd+Bd)=k.
===> (AC+AB) : (Cd+Bd) = k = AC:Cd
Archimedes: But AC:CB < 1351:780 from above while BA:BC = 2:1 = 1550:780
Therefore AD:DB < 2911 : 780 (1)
[Hence AB^{2}:BD^{2} < (2911^{2} + 780^{2}) :
780^{2} < 9082321:608400]
Thus AB:BD < 3013 3/4: 780 (2)
Me: This is enough to give us our estimate for the 12 sided inscribed polygons.
Because AB is the hypotenuse of right triangle ABD, AB:DB less than the
calculated value 3013 3/4 :780 and Pi > 12* (780/3013.75) = 3.1057
Now the hard thinking is done and with the help of a calculator or computer,
even most of the work is done. Archimedes bisects DAB with AE to get the 24
sided ratios. AB:BE < 1838 9/11: 240 (4)
giving the 24 sided case estimate: Pi >
24*(240/1838.818) = 3.1325. Similarly
48 side case: AB:BF < 1009 1/6: 66 and Pi > 48*66/1009.167 = 3.1392 and
96 side case: AB:BG < 2017 1/6: 66 and Pi > 96*66/2017.167  3.1410
A few final notes:
 Archimedes use of rational fractions raises the question: "When did the
positional notation decimal system develop?" The answer from
http://en.wikipedia.org/wiki/HinduArabic_numeral_system is:
"The Hindu–Arabic numeral system or Hindu
numeral system is a positional decimal numeral system developed by the
9th century by Indian mathematicians, adopted by Persian (AlKhwarizmi's
circa 825 book On the Calculation with Hindu Numerals) and Arabic
mathematicians (AlKindi's circa 830 volumes On the Use of the Indian
Numerals), and spread to the western world by the High Middle Ages."
 The statements about the values Archimedes used for sqrt(3) seemed
to need verification. Here's what I found:
 For the circumscribed case, 265/153 is indeed less than the sqrt(3).
This value represents the length of the radius which appears the denominator
of the Pi estimate, making that estimate larger that the true value.
 For inscribed, the assumed sqrt(3) value, 1351/780 is larger than
the which, thanks to Pythagoras, forces the calculated polygon side value to
be too small which in turn forces the Pi estimate to be too small.
 If you download the PDF version of the Heath text, he has an
extensive introduction which is interesting but the the text used here is
from page numbers 9398 of "Measurement of a Circle" and
starts around PDF page number 281.
 I entered many letter combinations describing lines, angles, and
triangles as I transcribed and expanded on Archimedes' text. In the
process I'm sure that there is more than one typo. If you work through
the text and find any of these, please let me know.
Programmer's Notes:
There is nothing particularly complex about the code, just a lot of fiddling
with trig functions to draw the figures simulating Archimedes'. The
results displayed in the string grid are based on the rational number
approximations used by Archimedes, but for the graphics there was no reason not
to use sine and cosine functions. For readability, the detail images
posted above show only the first iteration moving from 6 to 12 sides but the
original figures and my simulation has additional lines for a side of the 24, 48
and 96 side cases. This meant using little tricks like offsetting
the letters labeling the lines representing shorter sides so they do not
overlap. I spent more hours this week working on the mathematics and text
than on the code, so I'll keep this short. Use the feedback links to
inquire if you have questions about the code (or the math).
The source code references some routines from our
DFF Library so, if you have not already done so, you will need to
download the library before recompiling.
Running/Exploring the Program
Suggestions for Further Explorations

By abandoning the graphics and the rational
number approximations, it would be interesting to add a button to carry the
iteration process further, say 100 iterations to see how accurate the
estimates would be with 10^{30 }sided polygons.
J 

. 


Original: March 28, 2010 
Modified:
February 18, 2016

