Consider this question
Given that Pi can be estimated using the function 4 * (1 - 1/3 + 1/5 - 1/7 + …) with more terms giving greater accuracy, write a function that calculates Pi to an accuracy of 5 decimal places.
This is typically a programming question but I wonder if it can be done mathematically, too, since the trick is knowing when to stop computing.
I can write that summation as
$$\pi = 4 \sum_{k=0}^{\infty}\frac{(-1)^k}{2k+1}$$
What does it mean to have something to $d$ digits of precision exactly? If $r$ is the result of our computation, do we say that $|\pi-r| \leq \frac{1}{10^{d+1}}$? Is this right?
If so, can we figure out what upper bound on the summation will get us there?
I think it is the same as asking when $$\left|\pi - \sum_{k=0}^{n}\frac{(-1)^k}{2k+1}\right| \leq \frac{1}{10^6}$$
and solving for $n$, right?
Almost right. Usually, "$n$ decimal places" means "less than $5/10^{n+1}.$ Since this is an alternating series, we know the error in using the first $k$ terms is less than the absolute value of the $k+1$st term. So you need to solve $4/(2(k+1)+1) \leq 5/10^6.$