Connect via MCP →

Enter Calculation

Formula

Formula: Pi (π) Calculation from Inscribed and Circumscribed Polygons
Show calculation steps (1)
  1. Initial bounds

    Initial bounds: Pi (π) Calculation from Inscribed and Circumscribed Polygons

    Square branch starts from a square; hexagon branch starts from a regular hexagon. Both bracket pi.

Advertisement

Results

Approximate π
3.1415926535897927
midpoint of the inscribed and circumscribed bounds
Circumscribed perimeter a (upper bound) 3.1415926535897927
Inscribed perimeter b (lower bound) 3.1415926535897927
Final polygon side count 536,870,912

What this calculator does

This tool approximates the mathematical constant pi (π) using the classical method of Archimedes. For a circle of diameter 1, the circumference is exactly π. A regular polygon drawn snugly around the circle (circumscribed) has a perimeter slightly larger than π, while a regular polygon drawn inside the circle (inscribed) has a perimeter slightly smaller than π. By repeatedly doubling the number of sides, both perimeters squeeze toward π from above and below.

A circle with a regular hexagon inscribed inside it and a larger regular hexagon circumscribed around it, sharing the same center.
Archimedes' method squeezes pi between an inscribed polygon (smaller) and a circumscribed polygon (larger).

How to use it

Pick a starting polygon — a square (4-gon) or a hexagon (6-gon). Enter the number of doubling loops n; after n loops the polygon has \(4\cdot 2^{n}\) sides (square branch) or \(6\cdot 2^{n}\) sides (hexagon branch). Choose how many digits to display. The calculator stops early once the bounds agree to machine precision, so a large n is perfectly safe.

The formula explained

Let a be the circumscribed-polygon perimeter and b the inscribed-polygon perimeter. Each iteration applies $$a = \frac{2\,a\,b}{a+b},$$ the harmonic mean of the previous a and b, then $$b = \sqrt{a\,b},$$ the geometric mean of the new a and the old b. The square branch starts at \(a_0=4\) and \(b_0=2\sqrt{2}\approx 2.8284271\); the hexagon branch starts at \(a_0=2\sqrt{3}\approx 3.4641016\) and \(b_0=3\). At all times \(b < \pi < a\).

Advertisement
Sequence of three circles showing polygons with increasing number of sides converging to the circle shape.
Doubling the number of sides makes both bounds converge toward pi.

Worked example

Starting from a square: \(a_0=4\), \(b_0=2.82842712\). First loop gives $$a_1=\frac{2\cdot 4\cdot 2.82842712}{6.82842712}=3.31370850$$ and $$b_1=\sqrt{3.31370850\cdot 2.82842712}=3.06146746.$$ Second loop yields \(a_2\approx 3.18259788\), \(b_2\approx 3.12144515\). After about 25 doublings the bracket collapses to \(3.141592653589793\), the full double-precision value of π.

FAQ

Why a circle of diameter 1? Because then the circumference equals π exactly, so the polygon perimeters are direct estimates of π with no scaling.

Why does it stop before n loops? Standard double-precision arithmetic carries about 15–16 significant figures. Once a and b are identical to that precision, more loops cannot improve the answer, so iteration ends early.

Square or hexagon — which is better? Both converge to the same value. The hexagon starts closer to π, so it reaches a given accuracy in slightly fewer doublings.

Last updated: