10.3 The Integral Test

Suppose $f$ is a continuous, non-increasing function of $x$ for $x\geq 1$, and $f(n)=a_n$ for $n=1,2,\ldots$. If ${\displaystyle \int_1^\infty f(x)\,dx}$ converges, then (by the integral test) ${\displaystyle \sum_{n=1}^\infty a_n}$ converges, and furthermore ${\displaystyle \sum_{n=1}^j a_n + \int_{j+1}^\infty f(x)\,dx + \frac{1}{2}a_{j+1}}$ approximates the value of the infinite series ${\displaystyle \sum_{n=1}^\infty a_n}$ with an error certain to be less than ${\displaystyle \frac{1}{2}a_{j+1}}$. For example, the series ${\displaystyle \sum_{n=1}^\infty \frac{1}{n^2}}$ can be approximated by ${\displaystyle \sum_{n=1}^{22} \frac{1}{n^2} + \int_{23}^\infty \frac{1}{x^2}\,dx + \frac{1}{2}\frac{1}{(22+1)^2} }$ with error certain to be less than ${\displaystyle \frac{1}{2}\frac{1}{(22+1)^2}=\frac{1}{1058}<0.001}$.

The Matlab code below computes this approximation, the exact value of the series (using the symbolic toolkit command symsum), and finally the actual error in this approximation (which in fact is orders of magnitude less than 0.001).

>> format long >> n=1:23; a=1./n.^2; >> approx = sum( a(1:22) ) + integral( @(x) 1./x.^2, 23, inf ) + (1/2)*a(23) approx = 1.644920373765334 >> syms k >> exact = symsum(1/k^2, 1, Inf) exact = pi^2/6 >> vpa( abs( exact - approx ) ) ans = 0.000013693082892704420074601513116666