Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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)$.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

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}}$$

share|improve this answer
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
add comment

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
share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.