Skip to the content of the web site.

Project P.1: Series approximations of pi

Estimating the value of $\pi$ has been an area of interest for mathematicians for millennia. From an engineering point-of-view, a 16-decimal digit approximation, 3.1415926535897932, is more than sufficient. Never-the-less, it can be fun to find $\pi$ to a given number of digits.

Series solutions are most often used today. Implement any of the following series to find an approximation to $\pi$ by calculating the series and then applying the appropriate algebra to get the value of $\pi$:

  • ${\frac {1}{1^{2}}}+{\frac {1}{2^{2}}}+{\frac {1}{3^{2}}}+{\frac {1}{4^{2}}}+\cdots ={\frac {\pi ^{2}}{6}}$
  • $\frac {1}{1^{4}}+\frac {1}{2^{4}}+\frac {1}{3^{4}}+\frac {1}{4^{4}}+\cdots ={\frac {\pi ^{4}}{90}}$
  • $\sum _{n=1}^{\infty }{\frac {(-1)^{n+1}}{n^{2}}}={\frac {\pi ^{2}}{12}}$
  • $\sum _{n=1}^{\infty }{\frac {1}{(2n)^{2}}} = {\frac {\pi ^{2}}{24}}$
  • $\sum _{n=0}^{\infty }{\frac {(-1)^{n}}{2n+1}} = \frac {\pi }{4}$
  • $\sum _{n=0}^{\infty }\frac{1}{(2n+1)^2} = {\frac {\pi ^{2}}{8}}$
  • $\sum _{n=0}^{\infty }\frac {(-1)^{n}}{(2n+1)^3} = {\frac {\pi ^{3}}{32}}$
  • $\sum _{n=0}^{\infty }{\frac {1}{(4n+1)(4n+3)}}={\frac {\pi }{8}}$

These formulas are modified from Wikipedia.

If all the terms are positive, there are two approaches you can use:

  1. Start with the first term and add successively smaller terms until the sum does not change.
  2. Find that term that is smaller than $\frac{\pi}{2^{52}}$ and start by adding successively larger terms until you get back to the first.

If the terms alternate between positive and negative, you can group them in pairs that add together to be positive and use the previous two approaches.