From the circle and the right angle — two ideas that built mathematics

π & the Pythagorean Theorem

One number hidden in every circle. One equation hidden in every right angle. Together they let you measure curves and distances across all of mathematics.

The circle constant
\[ \pi=\frac{C}{d}\approx 3.14159265\ldots \]
The right-triangle law
\[ a^{2}+b^{2}=c^{2} \]
π Part I — Pi

01What π Actually Is

Draw any circle. Measure the distance around it (the circumference \(C\)) and the distance across it through the centre (the diameter \(d\)). Divide one by the other. No matter how big or small the circle, you always get the same number:

\[ \pi=\frac{C}{d}=3.14159265358979\ldots \]

That single fact — that the ratio is identical for every circle — is what makes π a genuine constant of the universe rather than a property of one particular circle. We prove it in §4.

π is irrational: it cannot be written as a fraction of two whole numbers, and its decimal expansion never ends and never repeats. It is also transcendental (proved by Lindemann in 1882): it is not the root of any polynomial with integer coefficients. One famous consequence — you cannot "square the circle" with compass and straightedge.

Mnemonic

Count the letters: "May I have a large container of coffee" → 3,1,4,1,5,9,2,6 → 3.1415926. Each word's length is the next digit of π.

02A History of Digits

Ancient civilisations already needed π. The Babylonians used \(25/8=3.125\); an Egyptian scribe in the Rhind papyrus used \((16/9)^2\approx 3.16\). The Hebrew Bible implies a round \(3\).

The first rigorous estimate came from Archimedes (c. 250 BCE). By trapping a circle between inscribed and circumscribed 96-sided polygons, he proved \( \tfrac{223}{71}<\pi<\tfrac{22}{7}\), i.e. \(3.1408<\pi<3.1429\). His method is reborn as an interactive in §6.

Centuries later, infinite series arrived. In 14th-century India, Madhava discovered what Europe later rediscovered as the Gregory–Leibniz series. Newton, Machin, and others pushed on; Machin's 1706 formula reached 100 digits by hand. Today, π is known to over 100 trillion digits — not because anyone needs them, but as a benchmark for algorithms and hardware.

03Circles (and Spheres) by the Numbers

Once you have π, the geometry of round things falls out immediately:

QuantityFormular = 2
Circumference\(C=2\pi r=\pi d\)≈ 12.566
Area of a disk\(A=\pi r^{2}\)≈ 12.566
Surface of a sphere\(S=4\pi r^{2}\)≈ 50.265
Volume of a sphere\(V=\tfrac{4}{3}\pi r^{3}\)≈ 33.510
Radians in a full turn\(2\pi\)≈ 6.283

π also lives far from circles — in probability (the normal distribution carries a \(\sqrt{2\pi}\)), in the Basel sum \(\sum 1/n^2=\pi^2/6\), and in Euler's identity \(e^{i\pi}+1=0\), often called the most beautiful equation in mathematics.

04Why π Is Universal — and Where A = πr² Comes From

Proof — the ratio C∕d is the same for every circle

Claim. For any two circles, \(C/d\) is identical.

Key idea: all circles are similar. Take a circle of radius \(r_1\) and another of radius \(r_2\). Scaling the plane about the first circle's centre by the factor \(k=r_2/r_1\) maps the first circle exactly onto (a copy of) the second.

Scaling multiplies every length by \(k\). A uniform scaling sends a path of length \(L\) to a path of length \(kL\). Applied to the circle, the circumference scales the same way the diameter does:

\[ C_2=k\,C_1,\qquad d_2=k\,d_1. \]

So the ratio is preserved.

\[ \frac{C_2}{d_2}=\frac{kC_1}{kd_1}=\frac{C_1}{d_1}. \]

The two circles were arbitrary, so this common value is one universal constant. We name it \(\pi\).

Proof sketch — the area of a disk is πr²

Slice the disk into \(n\) thin pie-sectors and lay them alternately point-up and point-down, like teeth zipping together. The result is almost a parallelogram.

Its slanted "height" is the radius \(r\). Its "base" is made of the arcs of half the sectors, totalling half the circumference: \(\tfrac12 C=\tfrac12(2\pi r)=\pi r\).

As \(n\to\infty\) the wavy edges straighten and the shape becomes an exact rectangle of base \(\pi r\) and height \(r\):

\[ A=(\text{base})(\text{height})=(\pi r)(r)=\pi r^{2}. \]

05Five Ways to Compute π

π can be approached from dozens of directions. Here are five classics, ordered roughly from slow-and-charming to fast-and-practical. Each becomes runnable Octave in §7, and three become interactive in §6.

① Gregory–Leibniz series

The simplest to state, the slowest to converge — beautiful but impractical (it needs hundreds of terms per digit):

\[ \frac{\pi}{4}=1-\frac13+\frac15-\frac17+\frac19-\cdots=\sum_{k=0}^{\infty}\frac{(-1)^k}{2k+1}. \]

② Nilakantha series

A faster cousin, converging in a tidy telescoping pattern:

\[ \pi=3+\frac{4}{2\cdot3\cdot4}-\frac{4}{4\cdot5\cdot6}+\frac{4}{6\cdot7\cdot8}-\cdots \]

③ Archimedes' polygons

Bracket the circle between an inscribed and a circumscribed regular \(n\)-gon; their perimeters squeeze π from below and above. Doubling \(n\) repeatedly via mean-recurrences needs no π to begin with.

④ Monte Carlo (throwing darts)

Scatter random points in a unit square. The fraction landing inside the quarter-circle approaches \(\pi/4\), so

\[ \pi\approx 4\cdot\frac{\#\{\text{points with }x^2+y^2\le 1\}}{\#\{\text{points total}\}}. \]

⑤ Machin-like & the Basel sum

For real accuracy, Machin's 1706 identity converges blisteringly fast, while Euler's Basel result connects π to the squares:

\[ \frac{\pi}{4}=4\arctan\frac15-\arctan\frac1{239},\qquad \frac{\pi^2}{6}=\sum_{n=1}^{\infty}\frac1{n^2}. \]

06Play — Three Ways to Watch π Appear

Archimedes' squeeze · polygons bracketing π
lower bound (inscribed)
upper bound (circumscribed)
true π
3.14159265

Inscribed perimeter ÷ diameter gives a lower estimate; circumscribed gives an upper one. Archimedes stopped at n = 96.

Monte Carlo · estimate π by throwing darts
points thrown
0
inside circle
0
π estimate = 4·in/total
error vs π

Teal points landed inside the quarter-circle; gold points outside. Convergence is slow (∝ 1/√N) — that's the nature of randomness.

Infinite series · partial sums closing in
partial sum
error vs π

Leibniz oscillates above/below π and crawls; Nilakantha homes in far faster for the same term count.

07GNU Octave for π

Every snippet ran in GNU Octave 8.4; the output shown is the real result.

Leibniz vs Nilakantha — convergence speed

pi_series.m
% Gregory-Leibniz: pi/4 = sum (-1)^k / (2k+1)
N = 1e6;  k = 0:N-1;
leibniz = 4 * sum( (-1).^k ./ (2*k + 1) );

% Nilakantha: pi = 3 + 4/(2*3*4) - 4/(4*5*6) + ...
s = 3;
for i = 1:1e5
  d = 2*i;
  term = 4 / (d*(d+1)*(d+2));
  if mod(i,2) == 1, s = s + term; else, s = s - term; end
end
nilakantha = s;

printf("Leibniz   (1e6 terms): %.10f\n", leibniz);
printf("Nilakantha(1e5 terms): %.12f\n", nilakantha);
printf("builtin pi           : %.12f\n", pi);
outputLeibniz (1e6 terms): 3.1415916536 % only ~6 correct digits Nilakantha(1e5 terms): 3.141592653590 % ~12 digits, far fewer terms builtin pi : 3.141592653590

Archimedes' polygon recurrence (no π required)

pi_archimedes.m
% Circle of diameter 1: perimeters of circ/inscribed n-gons bracket pi.
a = 2*sqrt(3);  b = 3;          % start at the hexagon (n = 6)
n = 6;
for i = 1:5
  printf("n=%-4d  %.8f < pi < %.8f\n", n, b, a);
  a = 2*a*b / (a + b);          % harmonic mean  -> circumscribed
  b = sqrt(a*b);                % geometric mean -> inscribed
  n = n * 2;
end
outputn=6 3.00000000 < pi < 3.46410162 n=12 3.10582854 < pi < 3.21539031 n=24 3.13262861 < pi < 3.15965994 n=48 3.13935020 < pi < 3.14608622 n=96 3.14103195 < pi < 3.14271460 % Archimedes' own bound

Monte Carlo & Machin

pi_montecarlo.m
% Monte Carlo: fraction of random points inside the unit quarter-circle.
N = 1e7;
x = rand(N,1);  y = rand(N,1);
inside = sum(x.^2 + y.^2 <= 1);
printf("Monte Carlo (1e7 pts): %.5f   (varies per run)\n", 4*inside/N);

% Machin's formula: pi/4 = 4*atan(1/5) - atan(1/239)
printf("Machin               : %.15f\n", 16*atan(1/5) - 4*atan(1/239));
output (Monte Carlo differs each run)Monte Carlo (1e7 pts): 3.14158 (varies per run) Machin : 3.141592653589794

08Advanced — Why π Is Irrational (Niven's Proof)

This 1947 proof by Ivan Niven is astonishingly short for so deep a result. It uses only calculus you likely already know.

The whole argument (proof by contradiction)

Suppose \(\pi=p/q\) with \(p,q\) positive integers. For a large integer \(n\) (chosen later), define

\[ f(x)=\frac{x^{n}(p-qx)^{n}}{n!},\qquad F(x)=\sum_{j=0}^{n}(-1)^{j}f^{(2j)}(x). \]

Fact 1 — integrality. Every derivative of \(f\) takes integer values at \(x=0\) and at \(x=\pi=p/q\). (Expanding \(f\) gives coefficients with \(n!\) in the denominator, which the differentiation cancels; symmetry \(f(x)=f(\pi-x)\) handles the second point.) Hence \(F(0)\) and \(F(\pi)\) are integers.

Fact 2 — an exact antiderivative. Because \(F''+F=f\), a direct differentiation shows

\[ \frac{d}{dx}\!\bigl[F'(x)\sin x-F(x)\cos x\bigr]=f(x)\sin x. \]

Integrate from \(0\) to \(\pi\). Using \(\sin\pi=\sin0=0,\ \cos\pi=-1,\ \cos0=1\):

\[ \int_{0}^{\pi} f(x)\sin x\,dx=F(\pi)+F(0)=\text{an integer}. \]

Fact 3 — but the integral is tiny. On \((0,\pi)\) we have \(0<\sin x\le 1\) and \(0 \[ 0<\int_{0}^{\pi} f(x)\sin x\,dx<\frac{\pi^{n+1}p^{n}}{n!}. \]

Contradiction. The right-hand bound \(\to 0\) as \(n\to\infty\) (factorials beat powers). Pick \(n\) large enough to make it \(<1\). Then the integral is an integer strictly between \(0\) and \(1\) — impossible. Therefore no such \(p,q\) exist, and \(\pi\) is irrational.

Part II — The Pythagorean Theorem

09The Statement

In a right triangle — one containing a 90° angle — the square of the longest side (the hypotenuse \(c\), opposite the right angle) equals the sum of the squares of the two shorter sides (the legs \(a\) and \(b\)):

\[ \boxed{\,a^{2}+b^{2}=c^{2}\,}. \]

Read geometrically, it says something striking: the square built on the hypotenuse has exactly the same area as the two squares built on the legs, combined. The interactive in §12 lets you see those three squares balance in real time.

SymbolMeaningExample (3·4·5)
a, bThe two legs (sides at the right angle)3 and 4
cThe hypotenuse (opposite the right angle)5
a²+b²Sum of the leg-squares9 + 16 = 25
The hypotenuse-square25 ✓

10Older Than Pythagoras

Though named for Pythagoras of Samos (c. 570–495 BCE) and his school, the relationship was known far earlier. The Babylonian tablet Plimpton 322 (c. 1800 BCE) lists Pythagorean triples a millennium before him. India's Śulba Sūtras and China's Zhoubi Suanjing record it independently. What the Pythagoreans likely contributed was an early proof — elevating it from a useful rule to a demonstrated truth.

It may be the most-proved theorem in all of mathematics: the 1940 collection The Pythagorean Proposition gathered 370 distinct proofs, and more keep arriving — including, in 2023, a pair from two high-school students using trigonometry.

11Four Proofs

The theorem's charm is how many independent routes reach it. Here are four, from a wordless rearrangement to a U.S. president's contribution.

Proof 1 — rearrangement (the "two squares")

Take a big square of side \(a+b\). Fill it with four identical copies of our right triangle (legs \(a,b\), hypotenuse \(c\)). There are two natural ways to do this.

Arrangement A: tuck the four triangles into the corners so the leftover space is one tilted square of side \(c\). Leftover area \(=c^2\).

Arrangement B: regroup the same four triangles into two rectangles, leaving two upright squares of sides \(a\) and \(b\). Leftover area \(=a^2+b^2\).

Both arrangements sit inside the same \((a+b)\times(a+b)\) square and use the same four triangles, so the leftover areas must be equal:

\[ c^2=a^2+b^2. \]

Algebraically: the big square is \((a+b)^2=a^2+2ab+b^2\); the four triangles total \(4\cdot\tfrac12 ab=2ab\); subtracting leaves \(a^2+b^2\) in B and the tilted \(c^2\) in A.

Proof 2 — similar triangles (drop the altitude)

From the right angle, drop a perpendicular to the hypotenuse, splitting it into two pieces \(p\) and \(q\) with \(p+q=c\).

This creates two smaller triangles, each similar to the original (they share an angle and both have a right angle). Matching corresponding sides:

\[ \frac{a}{c}=\frac{p}{a}\;\Rightarrow\; a^2=pc,\qquad \frac{b}{c}=\frac{q}{b}\;\Rightarrow\; b^2=qc. \]

Add the two results:

\[ a^2+b^2=pc+qc=(p+q)c=c\cdot c=c^2. \]

Proof 3 — President Garfield's trapezoid (1876)

Place two copies of the right triangle to form a right trapezoid with parallel sides \(a\) and \(b\) and slant height \(c\). James A. Garfield — five years before becoming U.S. president — computed its area two ways.

As a trapezoid (average of parallel sides times height):

\[ \text{Area}=\tfrac12 (a+b)(a+b)=\tfrac12 (a+b)^2. \]

As three triangles (two legs-triangles plus the central one with legs \(c,c\)):

\[ \text{Area}=\tfrac12 ab+\tfrac12 ab+\tfrac12 c^2=ab+\tfrac12 c^2. \]

Set them equal and expand \((a+b)^2\):

\[ \tfrac12(a^2+2ab+b^2)=ab+\tfrac12 c^2\;\Rightarrow\; a^2+b^2=c^2. \]

Proof 4 — Euclid's "windmill" (Elements I.47)

Euclid's classic builds the square on each side. He draws a line from the right-angle vertex perpendicular to the hypotenuse, splitting the hypotenuse-square into two rectangles.

Using triangles of equal base and height (which have equal area) and a shared 45°-style shear, he shows each leg-square equals one of those two rectangles: the square on \(a\) equals the rectangle beneath it, and likewise for \(b\).

The two rectangles reassemble the whole hypotenuse-square, so \(a^2+b^2=c^2\). The figure's sail-like shape earned it the nickname "the windmill" (and, to struggling medieval students, the pons asinorum).

12Play — Squares on the Sides

Adjust the two legs. The squares built on each side resize with them, and you can watch the gold and teal leg-squares always sum to the hypotenuse-square.

a² + b² = c² · live

13The Converse — and How to Spot a Right Angle

The theorem runs both ways. The converse says: if three side lengths satisfy \(a^2+b^2=c^2\), then the triangle must be right-angled. This is what lets a carpenter check a corner with a 3-4-5 measurement, or a surveyor square a field with a knotted rope.

Proof of the converse

Suppose a triangle has sides \(a,b,c\) with \(a^2+b^2=c^2\). Build a separate right triangle with legs \(a\) and \(b\); by the forward theorem its hypotenuse is \(\sqrt{a^2+b^2}=c\).

Now both triangles have all three sides equal \((a,b,c)\), so they are congruent (SSS). The corresponding angle in the constructed triangle is a right angle, so the original triangle's angle between \(a\) and \(b\) is too.

More finely, comparing \(a^2+b^2\) to \(c^2\) (with \(c\) the longest side) classifies any triangle:

\[ a^2+b^2>c^2\Rightarrow\text{acute},\qquad =c^2\Rightarrow\text{right},\qquad
Triangle classifier · the converse in action

14Triples, Distance & Beyond

Pythagorean triples

Whole-number solutions like \((3,4,5)\) and \((5,12,13)\) are Pythagorean triples. Euclid's formula generates them all: pick integers \(m>n>0\), then

\[ a=m^2-n^2,\quad b=2mn,\quad c=m^2+n^2 \]

always satisfies \(a^2+b^2=c^2\). Try it below.

Triple generator · Euclid's formula

When m and n share no common factor and aren't both odd, the triple is primitive (not a multiple of a smaller one).

The distance formula — Pythagoras in disguise

Place two points \((x_1,y_1)\) and \((x_2,y_2)\). The straight-line distance between them is just the hypotenuse of a right triangle with legs \(\Delta x\) and \(\Delta y\):

\[ d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}. \]

In three dimensions it extends naturally to \(d=\sqrt{\Delta x^2+\Delta y^2+\Delta z^2}\), and the same idea underlies the \(L^2\) norm used everywhere from physics to machine learning.

When the angle isn't 90° — the Law of Cosines

For a general triangle, Pythagoras gains a correction term controlled by the angle \(C\) between sides \(a\) and \(b\):

\[ c^2=a^2+b^2-2ab\cos C. \]

When \(C=90^\circ\), \(\cos C=0\) and the extra term vanishes — Pythagoras is exactly the right-angle special case.

△ ▽ △

15GNU Octave for Pythagoras

All output below is real, from GNU Octave 8.4.

Use hypot, not sqrt(a^2+b^2)

The naive expression can overflow to infinity for large legs, even when the true answer fits easily in a double. The built-in hypot rescales internally and is safe.

interactive session
a = 3e200;  b = 4e200;        % true hypotenuse is 5e200 (well within range)
printf("naive sqrt(a^2+b^2) = %g\n", sqrt(a^2 + b^2));   % a^2 overflows!
printf("hypot(a,b)          = %g\n", hypot(a, b));        % safe & exact
outputnaive sqrt(a^2+b^2) = Inf hypot(a,b) = 5e+200

Generate every Pythagorean triple with Euclid's formula

triples.m
printf(" m  n     a    b    c   ok?\n");
for m = 2:4
  for n = 1:m-1
    a = m^2 - n^2;  b = 2*m*n;  c = m^2 + n^2;
    printf("%2d %2d  %4d %4d %4d   %d\n", m, n, a, b, c, a^2 + b^2 == c^2);
  end
end
output (the final column 1 = verified a²+b² = c²) m n a b c ok? 2 1 3 4 5 1 3 1 8 6 10 1 3 2 5 12 13 1 4 1 15 8 17 1 4 2 12 16 20 1 4 3 7 24 25 1

Distance, classification, and vectorised hypotenuses

geometry.m
% Distance between two points = norm of the difference vector
P = [1 2];  Q = [4 6];
printf("distance P->Q = %g\n", norm(P - Q));

% Classify a triangle by the converse (c = the longest side)
function t = classify(a, b, c)
  s = sort([a b c]);  a = s(1); b = s(2); c = s(3);
  d = a^2 + b^2 - c^2;
  if abs(d) < 1e-12, t = "right";
  elseif d > 0,      t = "acute";
  else,              t = "obtuse";
  end
end
printf("(3,4,5) -> %s\n", classify(3,4,5));
printf("(4,5,6) -> %s\n", classify(4,5,6));
printf("(2,3,4) -> %s\n", classify(2,3,4));

% Vectorised: hypotenuses of many right triangles at once
A = [3; 5; 8];  B = [4; 12; 15];
disp( hypot(A, B) );
outputdistance P->Q = 5 (3,4,5) -> right (4,5,6) -> acute (2,3,4) -> obtuse 5 13 17