Consider convergent series $\sum_{k=1}^\infty {\frac{1}{k^2}}=\frac{\pi^2}{6}$.
Estimate the number of terms needed in order to get $\frac{\pi^2}{6}$ to as much accuracy as you can in double-precision by summing terms in exact arithmetic.
Can someone give me a hint on what method would get me the solution? I am a bit lost. Thank you in advance!
$$\sum_{k=1}^\infty {\frac{1}{k^2}}=\sum_{k=1}^n {\frac{1}{k^2}}+\sum_{k=n+1}^\infty {\frac{1}{k^2}}=H_n^{(2)}+\psi ^{(1)}(n+1)$$
So, you search for $n$ such that $$\psi ^{(1)}(n+1)\quad \leq \quad \epsilon$$ To stay with algebra, by Taylor series $$\psi ^{(1)}(n+1) =\frac{1}{n}-\frac{1}{2 n^2}+\frac{1}{6 n^3}-\frac{1}{30 n^5}+O\left(\frac{1}{n^7}\right)$$ Using power series reversion $$n=\frac{1}{\epsilon }-\frac{1}{2}-\frac{\epsilon }{12}+\frac{11 \epsilon ^3}{720}+O\left(\epsilon ^5\right)$$
So, if $\epsilon$ is really small $n=\frac 1 \epsilon$.
Trying for $\epsilon=10^{-6}$
$$H_{10^6}^{(2)}=\color{red}{1.64493}307\cdots$$ while $$ \frac {\pi^2}6= \color{red}{1.64493407}\cdots$$