“91974˙CH02˙ﬁnal” — 2012/12/14 — 13:58 — page 49 — #5
2.4 The Archimedes Approach 49
In the sections that follow, we will explore a number of interesting techniques for approxi-
mating pi. Remember that none of them can give us an exact answer.
2.1 Run the help command as follows: help('turtle'). Note the quotes around turtle.
2.2 Run the help command as follows: help(turtle). What is the diﬀerence?
2.3 import turtle and repeat the last exercise.
2.4 Run the help command on the math.sin function.
2.5 Explore the random module using the help facility. What does the randrange function
do? What does the randint function do?
2.4 The Archimedes Approach
The ﬁrst technique we will consider, attributed to the mathematician Archimedes, makes
use of a many-sided polygon to approximate the circumference of a circle. Recall that pi
is related to the circumference of a circle by the equation C =2πr where r is the radius of
the circle. Given a circle of radius 1, sometimes called a unit circle, this equation can be
rearranged to give π =
or simply π =
The Archimedes approach, shown in Figure 2.2, will use the distance around a polygon
that is inscribed within a unit circle. By using a polygon with increasing numbers of sides
(therefore decreasing side length), the total distance around the polygon will come closer
and closer to the actual circumference of the circle. Does this sound familiar? Of course,
no matter how large the number of sides, we will never truly reach the actual circle.
Figure 2.2 shows more of the details that will be needed to understand how this approxi-
mation will work. If we assume that the polygon has n sides of length s, we can then focus
our attention on a small slice of the polygon. In the triangle shown, the side labeled h will
have a length of 1 since we are assuming a unit circle. The angle labeled B can be easily
computed by remembering that there are 360 degrees in a circle. This means that angle
B is 360 ÷ n. Therefore, angle A is
B. In addition, we also know that the highlighted
triangle is a right triangle so that the side opposite angle A has a length of
Now we have to use a bit of trigonometry. In a right triangle (see Figure 2.3), the ratio of
the opposite side to the long side (or hypotenuse) is equal to the sine of angle A. Because
our triangle has a hypotenuse of length 1, we know that
s will simply be equal to the