# A little maths puzzle in two parts

I like solving little maths puzzles, deriving known results using nothing more complicated than secondary school level trigonometry, algebra and maybe a little calculus. The one below is actually two puzzles, but both have to do with regular polygons.

## Part 1 Approximating π by the perimeter of a regular polygon

Can one approximate $\pi$ by the perimeter of regular polygon with increasing numbers of sides inscribed in a unit circle, so starting with a triangle, then a hexagon, a dodecagon,... ? You may say that is obvious: the more sides, the closer the polygon approximates a circle. But I still wanted to work out the proof.

From Figure 1, clearly $$$$b=2\,sin\frac{\alpha}{2}\label{eq:1}$$$$ For a polygon with *n* sides, we have $$$$\alpha=\frac{2\pi}{n}\label{eq:2}$$$$ So we can express the lenght of the side of a polygon as a function of the number of sides as $$$$b(n)=2\,sin\frac{\pi}{n}\label{eq:3}$$$$ The perimeter of a regular polygon is obviously \begin{align} n.b(n) & = & 2n\,sin\frac{\pi}{n}\label{eq:4}\\ & = & 2\pi\frac{sin\frac{\pi}{n}}{\frac{\pi}{n}}\nonumber \end{align} We know that $$$$\underset{x\rightarrow0}{lim}\frac{sin\,x}{x}=1\label{eq:5}$$$$ This is easily proven using de l’Hôpital’s rule

Using $x=\frac{\pi}{n}$ it follows indeed that $$$$\underset{n\rightarrow\infty}{lim}n.b(n)=2\pi\label{eq:6}$$$$ In other words the perimeter of successive polygons inscribed in a unit circle does approach $2\pi$ -- which of course comes hardly as a surprise. The following code implements this starting from a polygon with a given number of sides $n$ . The argument $h$ is half of the length of the side, and $n_{max}$ is the number of iterations. What the algorithm does is recursively creating polygons with $n, 2n, 4n, 8n, ...$ sides. The example starts from a triangle so $n=3$ and $h=\sqrt(3)/2$.

-- n: # sides of the polygon
-- h: half of the length of a side

approx_pi n h n_max
| n == n_max = n*h
| otherwise =
approx_pi (2*n) (sqrt ((1 - sqrt (1-h*h) )/2)) n_max
-- e.g starting from a triangle.

Updated