# Accuracy from approximating $\zeta(2)$ with a partial sum

This is for an introductory numerical analysis class. The answer shouldn't be too complicated, but if you have one, feel free to post it.

Figure out what $n$ should be such that $$\sum_{k=n+1}^\infty {1\over k^2}<10^{-8}.$$

My Simple Algebraic Attempt

We know that

$$\sum_{k=1}^\infty {1\over k^2} = \sum_{k=1}^n {1\over k^2} + \sum_{k=n+1}^\infty {1 \over k^2} \implies \sum_{k=n+1}^\infty {1 \over k^2} = \sum_{k=1}^\infty {1\over k^2} - \sum_{k=1}^n {1\over k^2}$$

And

$$\sum_{k=1}^\infty {1\over k^2} = \zeta(2)={\pi^2 \over6}$$

So,

$$\sum_{k=n+1}^\infty {1 \over k^2} = {\pi^2 \over6} - \sum_{k=1}^n {1\over k^2}$$

Then,

$$\sum_{k=n+1}^\infty {1 \over k^2} < 10^{-8} \implies {\pi^2 \over6} - \sum_{k=1}^n {1\over k^2} < 10^{-8} \implies \sum_{k=1}^n {1\over k^2} > {\pi^2 \over6} - 10^{-8}$$

I'm currently trying to brute force an answer to the last expression, but is there a better way to do this?

-
Is there any additional information to the question? In particular, is it sufficient to find any $n$ such that the inequality holds, or must we find the minimal $n$ ? – Ragib Zaman Sep 9 '12 at 17:25
Hm, it doesn't say to find a minimal $n$. The assignment doesn't give much more information. – Brandon Amos Sep 9 '12 at 17:30

Since $\displaystyle \frac{1}{k^2} < \frac{1}{(k-1)k } = \frac{1}{k-1} - \frac{1}{k}$ we can bound your term by a telescoping sum: $$\sum_{k=n+1}^{\infty} \frac{1}{k^2} < \left(\frac{1}{n} - \frac{1}{n+1} \right)+\left(\frac{1}{n+1} - \frac{1}{n+2} \right)+\left(\frac{1}{n+2} - \frac{1}{n+3} \right) + \cdots = \frac{1}{n}$$ so $n=10^8$ works. The estimate we used isn't too weak, and this $n$ shouldn't be much worse than the minimal $n.$

-
Hm, sure. I also tried bounding it by an integral and got $n=10^8$. – Brandon Amos Sep 9 '12 at 17:36
I was going to use this method, but I was too slow. :-) – robjohn Sep 9 '12 at 17:38
@robjohn I was going to add the integral method in an edit, but I was too slow as well! – Ragib Zaman Sep 9 '12 at 17:39
Actually, I think you can bound the difference between this approximation and the real answer by $\frac{1}{n^2}$ which would make the minimal $n$ $10^8-1$. – anonymous Sep 9 '12 at 17:42

Hint: $$\sum_{k=n+1}^\infty\frac1{k^2}\le\int_n^\infty\frac1{x^2}\mathrm{d}x=\frac1n$$

-
This is what I initially tried, but I wasn't sure about it. Thanks for verifying! – Brandon Amos Sep 9 '12 at 17:38
$\sum_{k=n+1}^\infty\frac1{k^2} \ge \int_{n+1}^\infty\frac1{x^2}\mathrm{d}x=\frac{1}{n+1}$ so you can bound from both sides – Henry Sep 9 '12 at 17:42
@Henry: nice. Add that to your answer and undelete it :-) – robjohn Sep 9 '12 at 17:45

A simple idea is to replace the remainder of the series by the corresponding integral : $$\sum_{k=N+1}^\infty \frac 1{k^2}\sim \int_{N+1}^\infty \frac {dk}{k^2}$$ or get the inequality : $$\sum_{k=N+1}^\infty \frac 1{k^2}< \int_N^\infty \frac {dk}{k^2}=\frac 1N$$

If you wish more precision you may use Euler Maclaurin formula and get (for $x=2$ in your case) : $$\zeta(x)-\sum_{k=1}^N \frac 1{k^x} \sim \frac 1{(x-1)N^{x-1}}-\frac 1{2\,N^x} + \frac x{12\,N^{x+1}} - \frac {x\,(x+1)(x+2)}{720\,N^{x+3}} +\frac {x\,(x+1)(x+2)(x+3)(x+4)}{30240\,N^{x+5}} +...$$ (the constants $\ \frac 1{2},\ \frac 1{12},\ \frac 1{720}$ are $\frac {|B_n|}{n!}$ with $B_n$ a Bernoulli number)

This is an asymptotic expansion and the error made corresponds to the first term omitted.

-
For the exponent $2$, I did this very thing in this answer. – robjohn Sep 9 '12 at 18:03
@robjohn: I like this method (much simpler to implement than Riemann-Siegel and with a much more direct error term) and the numerical details that you showed in your answer (+1: I fear I missed that thread...). This formula has the interesting feature of becoming exact for negative integer $x$ (only the first terms are not $0$). – Raymond Manzoni Sep 9 '12 at 18:15
Yes, because the EMS formula terminates for polynomials. More generally, I showed in this answer that if the Fourier transform of a function is supported within $[-1,1]$, then the EMS formula converges for that function. – robjohn Sep 9 '12 at 22:34