Consider convergent series, Estimate number of terms in double precision

47 Views Asked by At

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!

3

There are 3 best solutions below

0
On BEST ANSWER

$$\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$$

1
On

You want to estimate the difference between the approximation $\sum_{k=1}^n 1/k^2$ and the exact $\sum_{k=1}^\infty 1/k^2$, i.e.

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

For small values of $n=1,2,3,...$ the error is: $0.644934$, $0.394934$, $0.283822$, $0.221322$, $0.1813229$... It is clear that the error decreases rather slowly. Using a calculator here, I found that for $n=10$, the error is $0.095166$, for $n=100$, the error is $0.00995$, for $n=1000$ the error is $0.000999$.

Can you see a pattern?

0
On

Use the inequalities $$ \frac1k-\frac1{k+1}=\frac1{k^2+k}<\color{darkblue}{\frac1{k^2}}<\frac1{k^2-k}<\frac1{k-1}-\frac1k $$ and telescoping sums to find for the series remainder $$ \frac1{n+1} < \color{darkblue}{\sum_{k=n+1}^\infty\frac1{k^2}} < \frac1n $$ This gives an interval of length $\frac1n-\frac1{n+1}=\frac1{n^2+n}$ for the series remainder. Using a point in the middle as remainder estimate gives about half of the interval length as error bound.

           partial sum        remainder       1/remainder     |    partial sum v2    remainder v2
n=10^01, 1.5497677311665408, 9.516634e-02, n+0.5+7.917457e-03 | 1.6450058264046361, -7.175956e-05
n=10^02, 1.6349839001848929, 9.950167e-03, n+0.5+8.291655e-04 | 1.6449341489411118, -8.209289e-08
n=10^03, 1.6439345666815597, 9.995002e-04, n+0.5+8.329158e-05 | 1.6449340669314347, -8.320834e-11
n=10^04, 1.6448340718480596, 9.999500e-05, n+0.5+8.322095e-06 | 1.6449340668483097, -8.321263e-14
n=10^05, 1.6449240668982263, 9.999950e-06, n+0.5+1.886263e-06 | 1.6449340668482266, -1.886241e-16
n=10^06, 1.6449330668487263, 9.999995e-07, n+0.5-9.507779e-05 | 1.6449340668482264, 9.507775e-17

where the partial sum is computed via reverse summation. The "v2" partial sum is corrected with $\frac1{n+0.5}$ as estimate of the remainder value.

The error of the corrected partial sum can again be estimated $$ \sum_{k=1}^\infty\frac1{k^2}=\sum_{k=1}^n\frac1{k^2}+\frac1{n+\frac12}-\sum_{k=n+1}^\infty\left[\frac1{k^2-\frac14}-\frac1{k^2}\right] \\~\\ \frac14\sum_{k=n+1}^\infty\left[\frac1{(k^2-\frac14)k^2}\right] <-\frac1{8n^4}+\frac14\int_n^\infty\frac1{x^4}dx=\frac1{12n^3}-\frac1{8n^4} $$ using the trapezoidal rule and noticing the concavity of the integrand. This estimate confirms that the corrected partial sum for $n=10^5$ has an error at the scale of the machine precision.