Calculus/Leibniz' formula for pi

In mathematics, the Madhava-Leibniz formula for π, was discovered in India by Indian mathematician and astronomer Madhava of Sangamagrama, Kerala in 14th or 15th century. It was rediscovered and named after 17th century mathematician, states that

$$1-\frac{1}{3}+\frac{1}{5}-\frac{1}{7}+\frac{1}{9}-\cdots=\frac{\pi}{4},$$

an alternating series. While the series is easy to write and calculate, it is a very inefficient method for calculating $$\pi$$, so it is seldom used in modern calculations of $$\pi$$.

Proof
By the, this series converges. It satisfies both of the test's criteria:


 * I) The terms decrease monotonically in absolute value.
 * II) The terms tend to 0 as the index $$n$$ tends to infinity.

Leibniz' formula for $$\pi$$ is a special case of the Gregory's series for the arctangent,

$$\arctan x = x - \frac{x^3}{3} + \frac{x^5}{5} - \frac{x^7}{7} + \cdots $$,

discovered by mathematician James Gregory in 1668.

Since $$\tan \frac{\pi}{4} = 1 $$, and thus, $$\arctan 1 = \frac{\pi}{4}$$, the formula is derived, and proved, by plugging $$x = 1$$ into Gregory's series.

It is worth noting that $$x = 1$$ lies on the boundary of the circle of convergence for Gregory's series. For $$x>1$$, the alternating series fails both criteria: for $$x>1$$, the terms increase in absolute value, and the terms tend to infinity, the opposite of what needs to be true for an alternating series to converge. Even a value of $$x$$ very close to 1, but still greater than it, such as $$x = 1.0001$$, still lies outside the series' radius of convergence.

Table
The following is a table of the first 10 partial sums and a selected list of other notable partial sums. This series converges to $$\frac{\pi}{4},$$ which to 16 significant figures, is 0.7853981633974483. The approximations for $$\pi$$ itself, found by multiplying the partial sums by four, are also shown. To 16 significant figures, $$\pi = 3.1415926535897932$$.

Note: The second and third partial sums are exactly $$ \frac{2}{3} $$ and $$ \frac{13}{15}$$, respectively. Both decimals feature a repeating "6"; for these entries, only the first three sixes are shown, followed by three dots to show that the sixes repeat endlessly. For all later terms, the sums are rounded to 9 digits after the decimal point, or the nearest billionth.

An interesting curiosity
You may have noticed that the later partial sums chosen at "round" numbers like 100 or 5000, look very similar to the limiting sums. For example, the partial sum of 3.131592903 at 100 terms, even after disagreeing with "3.14159265..." with a "3" instead of a "4" on the second digit, agrees for the next four digits, sharing the "1592" part. And the partial sum of 3.140592654 at 1000 terms differs on the third digit, but then goes on to agree with pi on the "59265" part. Similar behavior can also be seen in the second column of partial sums, such as the 250th term, which disagrees on the third digit but agrees from the fourth digit to the eighth digit (0.78439816 instead of 0.78539816). This pattern is very consistent throughout the remaining partial sums in the table. This is not an accident. This can be predicted using the. For any positive integer $$n$$, one can get a very close approximation of the $$n$$th approximation for $$\pi$$ with the following formula:


 * If $$n$$ is odd, the $$n$$th approximation for $$\pi$$ is approximately $$\pi + \frac{1}{n}$$, and the $$n$$th partial sum is approximately $$\frac{\pi}{4} + \frac{1}{4n}$$.
 * If $$n$$ is even, the $$n$$th approximation for $$\pi$$ is approximately $$\pi - \frac{1}{n}$$, and the $$n$$th partial sum is approximately $$\frac{\pi}{4} - \frac{1}{4n}$$.

The error of this approximation is on the order of $$n^{-3}$$ so this approximation is remarkably accurate even for relatively small values of $$n$$. Even after only four terms, the approximation of 0.722898163 predicted by the formula differs from the true partial sum of 0.723809524 by only about $$\frac{1}{1100}$$, which is less than 10−3. The error is less than 10−6 for all $$n>40$$ and less than 10−10 for all $$n>856$$.