# Estimating error when calculating $\pi^2$ with $8 + \frac{8}{3^2} + \frac{8}{5^2} + \frac{8}{7^2} + \cdots$

While answering a CodeReview question (Approximating constant $\pi^2$ to within error), I noticed that when calculating the sum $$8 + \dfrac{8}{3^2} + \dfrac{8}{5^2} + \dfrac{8}{7^2} + \dfrac{8}{9^2} + \cdots$$

and stopping at the smallest term larger than $\varepsilon$, the difference to $\pi^2$ seems very close to $\sqrt{2\varepsilon}$.

With $$n = \left\lfloor\frac{\sqrt{\frac{8}{\varepsilon}} - 1}{2} \right\rfloor,$$

it looks like:

$$\sum_{i=0}^n \frac{8}{(2i+1)^2} \approx \pi^2 - \sqrt{2\varepsilon}.$$

For example, with $\varepsilon = 10^{-10}$:

$n = 141421$

$\sum = 9.86959025 \dots$

$\pi^2 - \sum \approx 1.4142170*10^{-5}$

$(\pi^2 - \sum)^2 \approx 2.0000099*10^{-10} \approx 2\varepsilon$

I don't think it's a coincidence, but I don't know where to begin to link

$$\sum_{i=n+1}^\infty \frac{8}{(2i+1)^2}$$ to $\sqrt{2\varepsilon}$.

Wolfram Alpha expresses this sum in terms of a polygamma function but I don't know anything about it.

Is the approximation correct? Is there any simple way to prove it?

• The usual method of estimating the error in such series is the Euler-Maclaurin formula. – Lord Shark the Unknown Mar 8 '18 at 15:58
• I have changed the formatting of the title so as to make it take up less vertical space -- this is a policy to ensure that the scarce space on the main page is distributed evenly over the questions. See here for more information. Please take this into consideration for future questions. Thanks in advance. – GNUSupporter 8964民主女神 地下教會 Mar 15 '18 at 16:35

## 2 Answers

One has $${2\over (2k+1)^2}<{1\over 2k}-{1\over 2k+2}\ ,$$ and therefore (teleskoping sum!) $$0<\sum_{k=n}^\infty{2\over(2k+1)^2}<{1\over 2n}\ ,$$ or $$0<\sum_{k=n}^\infty{8\over(2k+1)^2}<{2\over n}\ .$$ Maybe this will bring you over the top.

• Thanks a lot. If I understand it correctly, we still need another inequality to prove that the sum isn't too far from $\frac{2}{n}$, right? – Eric Duminil Mar 8 '18 at 21:04
• Applying the same logic with ${1\over 2k+1}-{1\over 2k+3} < {2\over (2k+1)^2}$, we obtain $\frac{2}{n+1} < \sum < \frac{2}{n}$, right? That would be a pretty good approximation. – Eric Duminil Mar 9 '18 at 8:12

Recall from calculus the integral test:

$$\displaystyle\sum a(n)\text{ converges if and only if }\int a(x)\text{ converges}$$ where the sequence $a(n)=a_n>0$ and $a_n$ is decreasing, and the function $a(x)$ is continuous.

From the proof of this statement, we can deduce the inequality: if $\sum_{n=1}^\infty a_n=L$, then $$\left|L-\sum_{i=0}^n a_n\right|\leq\int_{n}^\infty a(x)\,dx,$$(see here for help with providing visual intuition as to why the inequality is true) where the notation $a(x)$ is used to represent $a_n$ with the $n$ replaced by $x$. Thus, performing the necessary calculations, we find

\begin{align*} \int_{n}^\infty\frac{8}{(2x+1)^2}\,dx&=\frac{4}{2n+1}\\ &\leq\frac{4}{\sqrt{\frac{8}\varepsilon}-1}\\ &=\frac{1}{\sqrt{\frac{1}{2\varepsilon}}-\frac14}\\ &=\frac{\sqrt{2\varepsilon}}{1-\frac{\sqrt{2\varepsilon}}{4}}\\ &\approx \sqrt{2\varepsilon},\end{align*} where I've taken $$n=\left\lfloor\frac{\sqrt{\frac{8}{\varepsilon}}-1}{2}\right\rfloor.$$

• This looks good, thanks. I'll try to do it again on a piece of paper and come back to comment/accept. – Eric Duminil Mar 8 '18 at 17:07
• Thanks, @EricDuminil. There was one place I had something like $\frac{1}{\sqrt{\frac{1}{2\varepsilon}}+1}$ where I had to use some algebra to simplify (hence I didn't want to type it, at least, not yet haha). – Clayton Mar 8 '18 at 17:15
• First, the integral test has hypotheses that you need to mention. And, although the estimate you give for the error is correct (under the same hypotheses!), I don't see how we can deduce that error estimate from the integral test itself. How does that go? – David C. Ullrich Mar 8 '18 at 17:20
• @DavidC.Ullrich: I suppose it is more from the proof of the integral test than the integral test itself, but the idea is that the sequence/function is positive and decreasing, so we can set it up so the integral is an overestimate (if you prefer to think in terms of Riemann sums, it is like using right endpoints for the estimate). – Clayton Mar 8 '18 at 17:33
• @DavidC.Ullrich: You're right about the test having hypotheses that I ought to mention. I knew I wouldn't have much time when I submitted the answer. At any rate, I'm at fault for not being explicit enough. I have about an hour now, so I'll provide more explanations. If you have any other suggestions, please let me know. – Clayton Mar 8 '18 at 17:36