I'm having troubles solving this problem:
Using this:
$$\frac{\pi}{4} = 4\arctan\left(\frac{1}{5}\right) - \arctan\left(\frac{1}{239}\right)$$
And The Maclaurin series for the arctangent function:
$$\arctan(x)=\lim_{n\to\infty}\sum_{i=1}^n\frac{(-1)^{i+1}x^{2i-1}}{2i-1}$$
Determine the number of terms that must be summed to ensure an approximation to $\pi$ to within $10^{-3}$.
I got this: $$\frac{4}{2n+1} \left(\frac{4}{5^{2n+1}}-\frac{1}{239^{2n+1}}\right)<10^{-3}$$ However, I do not know what to do next.
Please help.
EDIT: I'm looking for an analytic approach.
In an alternating decreasing series, the error is smaller than the first term dropped. You can evaluate the two arc tangent series by equally sharing out the error.
Then
$$\begin{align}\frac45&=0.8\\ \frac4{3\cdot5^3}&=0.0106667\cdots\\ \frac4{5\cdot5^5}&=0.000256\end{align}$$
and
$$\begin{align} \frac1{239}=0.00418410041841\cdots.\\ \end{align}$$
Clearly the next term is well below $0.0005$, and we can do with
$$\frac45-\frac4{375}-\frac1{239}=0.7851\cdots$$
to be compared to the true value $0.78539816\cdots$.
Update: I used a tolerance $10^{-3}$ on $\frac\pi4$ instead of on $\pi$, so the discussion must be rewritten with $0.00025$. By luck, the given estimate is still valid, as explained below.
From the above, we can even conclude that the error is smaller than $0.000256$. But for this to hold, we need to keep an extra digit and write $0.78515\cdots$ (true error $0.000249$).
One might argue that $0.000256>0.00025$ and there is a risk of the estimate being wrong, but we remain on the safe side because the error on the second series is certainly much smaller than $0.00025$ and an imbalanced sharing can be used.
For a fully analytical solution, you can express the truncation criterion of the series for $p\arctan(1/q)$ as
$$\frac p{(2n-1)q^{2n-1}}<\epsilon.$$
This is satisfied (a little pessimistically for small $n$) with
$$n=\left\lceil\frac{\log_q\frac p\epsilon+1}2\right\rceil.$$
This estimate tells us to truncate from the fourth and second terms onward, respectively.