# Get minimum N in approximation of pi

The following expression is an approximation of PI, where N determines the precision.

$$\pi (N) = \frac{4}{N} \sum_{i=1}^{N}\frac{1}{1 +\left ( \frac{i -\frac{1}{2}}{N} \right )^{2}}$$

If I want to find an approximation with an error less than a given amount $E$, I would like to find mathematically the N I have to use, or at least some boundaries where that N has to be.

I've tried approximating the error function, but I couldn't get anything precise enough.

Take into account that for the given error $E$ I can obtain $\pi(N)$.

-

## 2 Answers

Clearly, this is a Riemann sum for the integral

$$\pi = 4 \int_0^1 dx \frac{1}{1+x^2}$$

The difference between the Riemann sum above and this integral value is about $|f''(\xi)|/(12 N^2)$, where $f(x)=1/(1+x^2)$ and $\xi$ is the point at which $f''(x)$ is a maximum over $[0,1]$. As this value is $2$ at $\xi = 0$, the value of $N$ for a given error $E$ is about

$$N=\sqrt{\frac{1}{6 E}}$$

-
Thanks, exactly what I was looking for! Although after some testing I have found that it works using $N=\sqrt{\frac{1}{12 E}}$ instead and rounding down the result. –  Chevi Feb 8 '13 at 8:35
I meant to say rounding up –  Chevi Feb 8 '13 at 15:58

I cannot offer a mathematical formula, but at least this should give you an idea of how fast (slow) the series converges to pie, a small table with results:

    1    0.0584
2    0.0208
3    0.0093
4    0.0052
5    0.0033
6    0.0023
7    0.0017
8    0.0013
9    0.0010
10    0.0008
20    0.0002
50    0.00003
100    0.000008
1000    0.00000008
2000    0.00000002
5000    0.000000003
10000    0.0000000008

-