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