Vieta's Formula

by George Beck

This notebook continues the discussion on aproximating pi by calculating the areas of a circle using inscribed and circumscribed regular polygons. We illustrate Vieta's formula, which is the oldest exact result derived for pi.

The formula

In PiSqueeze the points are the upper and lower estimates of pi calculated from the areas of polygons of n sides. To get a good approximation we need a lot of sides. The line in the middle is the approximation from Vieta's formula, which calculates the area of a regular polygon of 2^n sides.

PiSqueeze[100];

Vieta's formula gives very good apprximations to pi for quite low values of n.

Table[NVieta[n], {n, 10}]

Vieta's formula states that 2 / pi is equal to the infinite product of a sequence of nested square roots. The first 5 terms are shown here.

VietaSequence[5]

The first term is Sqrt[2] / 2, and it has the same form as the others. Mathematica automatically simplified it.

Sqrt[2] / 2

This is the 20th term. It gives pi to more than a dozen decimal places.

VietaTerm[20]

Derivation of the formula

To derive Vieta's formula we need to combine several results from calculus and trigonometry.
We won't prove these results but we will illustrate them here. For any x, x / 2^n tends to 0 as n tends to infinity.

2^n Sin[x / 2^n] tends to 1 as n tends to infinity

Sin[x] / x tends 1 as x tends to 0.

When x is large Sin[x] and x are rather different.

Plot[{x, Sin[x]}, {x, -10, 10}];

But when x is small Sin[x] and x are aproximately the same.

Plot[{x, Sin[x]}, {x, -1, 1}];

Mathematically this is expressed in terms of limits.

Limit[Sin[x] / x, x -> 0]

If x is any fixed number, x / 2^n tends to 0 as n gets large.

Limit[1 / 2^n, n -> Infinity]

So Sin[x / 2^n] / (1 / 2^n)] will tend to x.

Limit[Sin[x / 2^n] / (1 / 2^n), n -> Infinity]

This limit can be rewritten more simply as follows, since 1 / (1 / 2^n) is 2^n.

Limit[2^n Sin[x / 2^n], n -> Infinity]

Euler's formula

We apply and keep reapplying the rule Sin[x] -> 2 Cos[x/2] Sin[x/2].

SinRule = Sin[z_] :> 2 Cos[z/2] Sin[z/2];

y = Sin[x]; 
z = {y}; 
Do[y = y /. SinRule; z = Append[z, y], {5}]; 
TableForm[z]

Each of these products is equal to Sin[x]. As n tends to infinity the product of the first and last terms tends to x, as we saw above. Taking the limit and dividing by x, we get a formula of Euler:

Sin[x] / x == Product[Cos[x / 2^n], {n, 1, Infinity}]

Vieta's formula

We substitute pi/2 for x.

% /. x -> Pi / 2

All that is left to do is to verify that the cosines are nested square roots. Mathematically this would be proved by induction. Here we illustrate the result for one term by defining a second  rule that we apply repeatedly.

CosRule = Cos[z_] :> Sqrt[(Cos[2 z] + 1) / 2];

Cos[Pi / 2 ^ 6] //. CosRule

This simplifies to the previous form of nested square roots.

Simplify[%]

For numerical calculations it is much faster to use N early (as in the definition of NVieta) and to avoid such symbolic formulas.

Implementation

SetOptions[Plot, AspectRatio -> Automatic];

Needs["Calculus`Limit`"]

Usage messages

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

PiSqueeze::usage = "PiSqueeze[n] gives a graph of the 
upper and lower bounds to pi based on inscribed 
and circumscribed polygons of n sides, together with a 
graph of Vieta's formula.";

NVieta::usage = "NVieta[n] gives an approximation to pi 
using a product of n terms.";

VietaSequence::usage = "VietaSequence[n] gives the first n 
terms of Vieta's formula.";

VietaTerm::usage = "VietaTerm[n] gives the n-th 
term of Vieta's formula.";

Function definitions

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

PiSqueeze[n_] := Module[
	{a, lower, upper, middle, i}, 
	a = 2 N[Pi] / i;
	lower = ListPlot[
		Table[
			i / 2 Sin[2 N[Pi] / i], 
			{i, 3, n}
		], 
		DisplayFunction -> Identity
	];
	upper = ListPlot[Table[i Tan[N[Pi] / i], {i, 3, n}],
		DisplayFunction -> Identity];
	middle = ListPlot[Table[NVieta[i], 
		{i, Max[20, Floor @ Log @ n]}],
		DisplayFunction -> Identity, 
		PlotJoined -> True];
	Show[{lower, upper, middle}, 
		DisplayFunction -> $DisplayFunction]
]

NVieta[n_] :=  2 / NProduct[Cos[Pi / 2^i], {i, 2, n}]

VietaTerm[n_] := 
	Fold[Sqrt[#2 + #1]&, 0, Table[2, {n}]] / 2

VietaSequence[n_] := 
	Rest @ FoldList[Sqrt[#2 + #1]&, 0, Table[2, {n}]] / 2