Approximating Pi

by George Beck

This notebook shows how to approximate pi by using the areas of polygons.

Discussion

Approximating Pi by Using Regular Polygons

A circle of radius r has area pi r^2, so when r is 1 the area is pi. Any figure contained inside the circle will have area less than pi, and any figure enclosing the circle will have area bigger than pi. The defined function PiPolygons shows the unit circle and its regular inscribed and circumscribed polygons. It calculates the areas of the polygons, which are approximations of pi.

PiPolygons[3];

PiPolygons[4];

PiPolygons[5];

PiPolygons[9];

PiPolygons[16];

PiPolygons[100];

Implementation

Method

To calculate the area of the inscribed polygon, break it into n triangles of height Cos[a/2] and base 2 Sin[a/2], where a is the angle at 2 N[Pi] / n. 
The area is n/2 base height = n / 2 (2 Sin[a/2] Cos[a/2]) == n / 2 Sin[a].  

For the circumscribed polygon, the triangles have height 1 and base 2 Tan[a  / 2].

Usage messages

PiInterval::usage = "PiInterval[n] gives the areas of 
the inscribed and circumscribed regular polygons of a 
unit circle.";

PiPolygons::usage = "PiPolygons[n] draws the inscribed 
and circumscribed regular n-sided polygons of a unit 
circle.";

Function definitions

SetOptions[Graphics, AspectRatio -> Automatic];

Needs["Graphics`Colors`"]

PiInterval[n_] := {n/2 Sin[N[Pi] / n], n Tan[N[Pi] / n]}

PiPolygons[n_] := Module[
	{a, vertices, VERTICES, i}, 
	a = 2 N[Pi] / n;
	Print["Pi is in the interval ", 
		{n / 2 Sin[a], n Tan[a/2]}, "."];	
	vertices = Table[
		{Cos[i a], Sin[i a]}, 
		{i, 0, n - 1}
	];
	VERTICES = Table[ 
		Sec[a / 2] {Cos[i a], Sin[i a]}, 
		{i, 0, n - 1}
	];
	Show[Graphics[
		{
			Green, Polygon[VERTICES], 
			Red, Disk[{0, 0}, 1], 
			Green, Polygon[vertices], 
			Thickness[.007], Blue, 
			Line[Append[VERTICES, VERTICES[[1]] ] ], 
			Circle[{0, 0}, 1], 
			Line[Append[vertices, vertices[[1]] ] ]
		}
	]]
]