I have to check the convergence of the improper integral $$ \int_{0}^{\infty} \cos^2x\,dx .$$
I have tried to solve it in the following manner: $$\begin{align}\int_{0}^{\infty}\cos^2x\,dx &= \lim_{B \to \infty} \int_{0}^{B}\cos^2x\,dx \\&= \lim_{B \to \infty} \int_{0}^{B}(1-\sin^2(x))\,dx \\ &= \lim_{B \to \infty}[x]_{0}^{B} -\lim_{B \to \infty} \int_{0}^{B}\sin^2(x)\,dx .\end{align}$$
Now the first term tends to infinity as $B \to \infty,$ so the integral is not convergent.
But unfortunately the answer is given to be convergent. I don't understand how ?
Also I have proven in the same way that $$ \int_{0}^{\infty} (\sin x^2)^2\,dx $$ is divergent. So basically I think that if my process is wrong then I am wrong in both cases.
Am I wrong ? If so, looking for guidance then. Thank you.
You cannot proceed this way, as you end up with something of the form $$ \int_0^B dx\, \cos^2 x = u_B - v_B $$ and $\lim_{B\to\infty} u_B = \infty$. But if $\lim_{B\to\infty} v_B = \infty$ as well, you have an indeterminate form and cannot conclude.
However, note that $\cos^2$ is perdiodic with period $\pi$, so that for any integer $k$ $$ \int_0^{k\pi} dx\, \cos^2 x = k\int_0^\pi dx\, \cos^2 x = k\cdot \frac{\pi}{2} $$ and therefore $$ \int_0^{B} dx\, \cos^2 x = \int_0^{\lfloor B/\pi\rfloor \pi} dx\, \cos^2 x + \underbrace{\int_{\lfloor B/\pi\rfloor \pi}^B dx\, \cos^2 x}_{\geq 0} \geq \lfloor B/\pi\rfloor\cdot \frac{\pi}{2} \xrightarrow[B\to\infty]{} \infty $$