Monday, May 16, 2016

Leibniz Formula for Pi

With pi being irrational, we're all familiar with various approximations for it:
  • 22/7
  • 3.14
  • 355/113
  • 3.1416

I've always been fascinated with how to calculate pi, and was amazed when I first learned of the Leibniz formula for calculating it:

pi/4 = 1 - 1/3 + 1/5 - 1/7 + 1/9 - ...

I was shocked that such a simple formula could calculate it, and worked diligently trying to use it to calculate pi myself, only to discover that it zeroes in on pi *very* slowly: 



I've only recently discovered that the Leibniz formula can be written as an Euler product (the math of which I'm sure my wife could expand upon):


pi/4 = 3/4 * 5/4 * 7/8 * 11/12 * 13/12 * 17/16 ...

In this product, each numerator is an odd prime number, and each denominator is the nearest multiple of four to the numerator.   Here, in one simple equation, was something relating two of my favorite math subjects, pi and prime numbers.   You can see it converges a little more haphazardly than the previous equation (and just as slowly):

2 comments:

  1. Hi, could you please explain how you generated those graphs?

    ReplyDelete
  2. pi/4 is approximately 0.79 -- that's the center line you see. I then started successively summing terms from the Leibniz formula ( 1, -1/3, 1/5, etc. ) and plotting those points. The vertical axis is the current sum of the terms, the horizontal axis is the number of terms being summed.

    ReplyDelete