1. Home
  2. Explore
  3. Mathematics
  4. Leibniz Formula for Pi

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Leibniz Formula for Pi

Speaker 1Speaker 2

Leibniz Formula for Pi

6:32
0:00-6:32
  1. Michael

    Hope, have you ever seen that beautiful formula for pi over 4? It equals 1 minus 1/3 plus 1/5 minus 1/7 and so on. It's called the Leibniz formula, but did you know that it was actually discovered by the Indian mathematician Madhava in the 14th century, over 200 years before Leibniz?

  2. Hope

    Really? I had no idea. And it is stunning — pi, which is all about circles, coming from the odd numbers. There's no circle in sight, yet the numbers just fit together perfectly.

  3. Michael

    Exactly! And here's the amazing part: even though the formula doesn't look circular, when you look hard enough, a huge circle is hidden inside it. That's what we're going to explore today. The key is to think about lattice points inside a circle on a grid.

  4. Hope

    Lattice points? You mean points with integer coordinates? Like a coordinate plane with dots at every (x, y) where x and y are integers?

  5. Michael

    Right. So you draw a circle centered at the origin with radius r, and you count how many lattice points are inside. That number, N(r), is roughly equal to the area of the circle. Because each lattice point owns a unit square. So N(r) ≈ π r².

  6. Hope

    And then as r gets larger and larger, the approximation gets better, right? So pi is approximately N(r) divided by r². For example, with r=7, N(r)=149, so pi ≈ 149/49 ≈ 3.0408. Not great, but it improves as r grows.

  7. Michael

    Yes, and in the limit as r goes to infinity, it becomes an equality. But to get the Leibniz formula, we need a different way to count those lattice points. Because N(r) can also be found by counting how many ways each integer can be written as a sum of two squares.

  8. Hope

    That's clever. For each lattice point (a, b), its distance squared from the origin is a² + b². So every point inside the circle corresponds to a number d = a² + b² that is ≤ r². So if we count all ways to write numbers from 0 to r² as sums of two squares, we get N(r).

  9. Michael

    Exactly. And there's a beautiful theorem that tells us exactly how many ways each integer can be written as a sum of two squares. It involves splitting the odd numbers into two types: numbers that are 1 mod 4, which are 'good', and numbers that are 3 mod 4, which are 'bad'.

  10. Hope

    So like 1, 5, 9 are good, and 3, 7, 11 are bad. And the theorem says: the number of ways to write an integer n as a sum of two squares is 4 times (the number of good odd factors of n minus the number of bad odd factors). That's stunning!

  11. Michael

    For example, 18 has odd factors 1, 3, 9. 1 and 9 are good, 3 is bad, so 2-1=1, times 4 = 4. So there are four ways to write 18 as a sum of two squares. And you can check: (±3)² + (±3)² works, and also (±? well, you can find them). This theorem is Jacobi's two-square theorem.

  12. Hope

    Now, how does that help us get N(r)? Because we need to sum this 4(good-bad) over all numbers from 1 to r², then add 1 for the origin. That seems like a big sum.

  13. Michael

    Right, but there's a trick. Instead of summing column by column (for each integer n), we can sum row by row for each odd factor. For a given odd number d, how many multiples of d are there up to r²? That's just the integer part of r² divided by d. So we add these up for the good odds, subtract for the bad, multiply by 4, add 1, and we get N(r).

  14. Hope

    Let's see that for r=7. The good odds up to 49 are 1, 5, 9, 13, ... and the bad are 3, 7, 11, ... . The integer parts: floor(49/1)=49 for good 1, floor(49/5)=9 for good 5, etc. Summing all good and all bad, subtracting, we get 37. Times 4 plus 1 gives 149. That matches! So for general r, N(r) = 4 * ( sum over good d of floor(r²/d) - sum over bad d of floor(r²/d) ) + 1.

  15. Michael

    Now, divide both sides by r². As r→∞, floor(r²/d)/r² → 1/d. So the left side tends to π, and the right side becomes 4 times (1/1 - 1/3 + 1/5 - 1/7 + ... ) because the good odds are 1,5,9,... and bad are 3,7,11,... . But wait, the series from good odds is 1 + 1/5 + 1/9 + ... and from bad is 1/3 + 1/7 + 1/11 + ... . That's not alternating at first glance.

  16. Hope

    But look at the order: good and bad alternate if we list all odd numbers. So the sum over all odds with alternating signs is exactly (1 - 1/3 + 1/5 - 1/7 + ...). And our formula has plus for good, minus for bad. So when we take the limit, we get π = 4 * (1 - 1/3 + 1/5 - 1/7 + ...). Divide both sides by 4 and we get the Leibniz-Madhava formula!

  17. Michael

    Exactly. So the formula really comes from the area of a circle, with a detour through counting lattice points and the Jacobi two-square theorem. Now, what about Fermat's Christmas theorem? It's a special case of Jacobi's theorem for primes.

  18. Hope

    For a prime p, its only odd factors are 1 and p. If p is good (1 mod 4), then good factors: 1 and p, bad: none, so 2-0=2, times 4 = 8. So p can be written as a sum of two squares. If p is bad (3 mod 4), then good: just 1, bad: p, so 1-1=0, times 4 = 0. So no representation. That's Fermat's Christmas theorem.

  19. Michael

    And the name comes from Fermat mentioning it in a letter to Mersenne on Christmas Day 1640. Though Albert Girard stated it earlier, and Euler gave the first proof. There's even a one-sentence proof by Don Zagier from 1990, but it's famously cryptic.

  20. Hope

    There's also an easy half: proving that no bad odd number (4k+3) can be a sum of two squares. Because any integer squared is either 0 or 1 mod 4, so sum of two squares is 0, 1, or 2 mod 4, never 3. That's simple but elegant.

  21. Michael

    And finally, to go from primes to all numbers, there's a key identity: (a² + b²)(c² + d²) = (ac - bd)² + (ad + bc)². This product formula shows that if two numbers are sums of two squares, their product is too. So knowing the prime pattern lets you handle composites.

  22. Hope

    Wow, it's all connected. So the Leibniz-Madhava formula isn't just a random series — it's a window into the geometry of circles and the arithmetic of sums of squares. Thanks for sharing this, Michael!

  23. Michael

    My pleasure! And if you want to go deeper, check out Hilbert and Cohn-Vossen's book 'Geometry and the Imagination' — it's where I first saw this connection. For now, I think we've covered it all. Frohe Weihnachten!

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent