Leibniz Formula for Pi
Leibniz-Madhava Formula and Sums of Squares
The Leibniz-Madhava Series
The formula for 4π as an alternating series of odd reciprocals is:
This series is named after Gottfried Wilhelm Leibniz (17th century), but was first discovered by the Indian mathematician Madhava of Sangamagrama in the 14th century, over 200 years earlier. It is therefore often called the Leibniz–Madhava series.
The series is surprising because π is fundamentally a circle constant (ratio of circumference to diameter), yet the series only involves odd numbers with no obvious connection to circles. However, the series can be derived from the area formula of a circle, revealing a hidden circle.
Good and Bad Odd Numbers
In the sequence of odd numbers 1,3,5,7,9,11,13,15,…, classify them into two types:
Good odd numbers: those of the form 4k+1 (i.e., 1,5,9,13,17,…). When divided by 4, they leave remainder 1.
Bad odd numbers: those of the form 4k+3 (i.e., 3,7,11,15,19,…). When divided by 4, they leave remainder 3.
The positive terms in the Leibniz–Madhava series have denominators that are good odd numbers (1,5,9,…), and the negative terms have denominators that are bad odd numbers (3,7,11,…). This classification is central to the connection with sums of squares.
Counting Lattice Points in a Circle
Consider the integer lattice in the plane: all points (x,y) with integer coordinates. Draw a circle of radius r centered at the origin. Let N(r) be the number of lattice points inside or on the circle. Because each lattice point can be thought of as the center of a unit square, N(r) approximates the area of the circle, which is πr2. As r→∞, the approximation becomes exact:
For example, with r=7, N(7)=149, so π≈149/49≈3.0408, a rough approximation. With r=1000, π is approximated to 3.1415. In the limit, equality holds.
Counting Lattice Points by Representing Integers as Sums of Two Squares
A lattice point (x,y) lies inside the circle of radius r if and only if x2+y2≤r2. Since x and y are integers, the value x2+y2 is an integer between 0 and r2 (inclusive). Therefore, N(r) can be counted by:
List all integers n from 0 to r2.
For each n, count the number of ways to write n as x2+y2 with integers x,y (including negative integers and zero).
Sum all those counts.
Because of the symmetry of the lattice (positive/negative signs, swapping x and y), the number of ways for a positive integer n is always a multiple of 4, except for n=0 (which has exactly 1 way: 02+02). For example:
0: 1 way (the origin)
1: 4 ways ((±1,0) and (0,±1))
2: 4 ways ((±1,±1))
3: 0 ways
4: 4 ways ((±2,0) and (0,±2))
5: 8 ways ((±2,±1) and (±1,±2))
Thus, N(r)=1+4×(total number of representations of 1 to r2), but the representation count for each n is not simply the number of representations; it's the sum of representation counts over n. This is where the good/bad factor theorem simplifies the counting.
Fermat's Christmas Theorem (Prime Case)
Fermat's Christmas Theorem: A prime number p can be expressed as a sum of two integer squares if and only if p is a good prime (i.e., p=2 or p≡1mod4). Bad primes (p≡3mod4) cannot be written as a sum of two squares.
Despite the name, the theorem was first stated by Albert Girard in 1625, 15 years before Fermat's letter to Mersenne on Christmas Day 1640. The first published proof was given by Euler.
This theorem is the prime case of a more general result about all integers.
Jacobi's Two-Square Theorem (General Case)
Jacobi's two-square theorem: Let n be a positive integer. The number of ways to write n as a sum of two integer squares (counting order and signs) is 4(d1(n)−d3(n)), where d1(n) is the number of divisors of n that are congruent to 1mod4 (good odd divisors), and d3(n) is the number of divisors of n that are congruent to 3mod4 (bad odd divisors). That is:
\text{# representations} = 4 \times (\text{# good odd divisors} - \text{# bad odd divisors})
For example, n=18: the odd divisors of 18 are 1,3,9. Good divisors: 1 and 9 (both ≡1mod4). Bad divisor: 3 (≡3mod4). So 2−1=1, times 4 gives 4 ways. Indeed, 18=32+32=(−3)2+32=32+(−3)2=(−3)2+(−3)2, counting order? Actually careful: the representation 32+32 is counted 4 times due to signs of each number (two numbers can each be ±3), that's 4 ways. So the theorem holds.
This theorem is named after Carl Gustav Jacob Jacobi.
Deriving the Leibniz-Madhava Series from Circle Area
To derive the series, combine the lattice-point counting with Jacobi's theorem.
Let r be a positive integer radius. Count N(r) by summing over all n from 0 to r2:
The number 1 accounts for the origin (n=0).
Now, change the summation order: instead of summing over n (columns), sum over each odd divisor (rows). For each odd number d, count how many n in 1,…,r2 have d as a divisor. For a fixed odd d, the multiples of d up to r2 are d,2d,3d,…,⌊r2/d⌋⋅d. So each good odd divisor g contributes +1 for each multiple; each bad odd divisor b contributes −1 for each multiple.
Thus, the total difference (good - bad) summed over n equals:
Now group the odd numbers in order: 1,3,5,7,9,11,…. The sign alternates: 1 is good (positive), 3 is bad (negative), 5 is good (positive), 7 is bad (negative), etc. So we can write:
But careful: the sum includes only odd numbers up to r2? Actually as k increases, the integer part becomes zero for 2k+1>r2, so the sum is finite.
Therefore:
Now recall the limit:
Divide both sides by r2:
The term 1/r2→0. For each fixed k, ⌊r2/(2k+1)⌋/r2→1/(2k+1) as r→∞ (since the floor difference disappears). Interchanging limit and sum (justified by dominated convergence or careful estimation), we obtain:
Dividing both sides by 4 yields the Leibniz-Madhava series:
Thus, the series arises directly from the formula for the area of a circle, using the lattice point count and the sum-of-squares divisor theorem.
The Easy Half: Why Bad Numbers Cannot Be Sums of Two Squares
Fermat's Christmas theorem has an easy half: no integer of the form 4k+3 (bad odd numbers) can be expressed as a sum of two integer squares. This is proved by considering residues modulo 4.
Every integer is congruent to 0,1,2, or 3 modulo 4. When we square an integer:
If n≡0mod4, then n2≡0mod4.
If n≡1mod4, then n2≡1mod4. (Since (4m+1)2=16m2+8m+1≡1)
If n≡2mod4, then n2≡0mod4. ((4m+2)2=16m2+16m+4≡0)
If n≡3mod4, then n2≡1mod4. ((4m+3)2=16m2+24m+9≡1)
So a square is always 0 or 1 modulo 4. The sum of two squares can therefore be:
0+0≡0
0+1≡1
1+0≡1
1+1≡2
Thus, the sum of two squares can never be 3 modulo 4. Therefore no integer of the form 4k+3 can be written as a sum of two integer squares. This proves that all bad odd numbers (and indeed any 4k+3 integer, even if not prime) are not sums of two squares.
The converse (that good primes can be written as sums of two squares) is harder and requires deeper number theory.
The Product Identity: Connecting Primes to All Integers
An ancient identity, known to the Greeks, is the key to extending the prime case to composites:
This shows that if two numbers are each sums of two squares, their product is also a sum of two squares. Since every positive integer is a product of primes, if we know which primes are sums of two squares, we can determine representation for any integer. Jacobi's theorem counts the number of representations using the divisor function.
This identity, together with Fermat's theorem, is the foundation of the general theory of sums of squares.
Summary
The Leibniz-Madhava series for π/4 is more than a mysterious pattern; it emerges naturally from the geometry of counting integer lattice points in a circle. The counting is simplified by Jacobi's two-square theorem, which expresses the number of representations as a difference of divisor counts. Fermat's Christmas theorem classifies primes as sum-of-two-squares representable or not, based on their residue modulo 4. The series derivation elegantly links π, the area of a circle, to the alternating sum of reciprocals of odd numbers, revealing the hidden circle within the series.

Ask anything
We've read this whole study set, so questions about it get the best answers.