I was trying to assess the convergence/divergence of this integral: $$ \int_0^\pi \frac{1-\cos x}{ x^{2}}dx $$ I thought that I could split it to two integrals: $$ \int_0^\pi \frac{1 }{ x^{2}}dx - \int_0^\pi \frac{\cos x}{x^{2}}dx $$
and conclude that $ \int_0^\pi \frac{1 }{ x^{2}}dx $ is divergent in this domain, so the sum of the integrals is divergent.
However, I was mistaken and this integral is convergent (concluded via a comparison test). But I am still confused - why couldn't I simply split the integral? Is there something I missed?
Thanks in advance!
Since $\infty-\infty$ is undetermined, it can also give a finite number: this is what happens when you split the integrals.
The problem of the divergence of the two "split" integrals is because the denominator goes to zero close to $x=0$. however, let's have a look at the "whole function": close to $x=0$ the cosine behaves as $\cos x = 1-x^2/2 +O(x^4)$, so that $$ \frac{1-\cos x}{x^2} \, = \, \frac{x^2/2 +O(x^4)}{x^2} = 1/2+O(x^2) $$ that is not divergent (in practice the function you have to integrate is well behaved over the integration domain, even in $0$, where it is finite).