Problem.
Does $$\int_{0}^{\pi ^2} \frac{dx}{1 - \cos \sqrt{x}}$$ converge or diverge?
Solution.
I solved this problem by noticing that $\cos \sqrt{x} \rightarrow 1 - \frac{x}{2}$, when $x \rightarrow 0$. Then, I separated the integral into $$ \int_{0}^{\pi ^2} \frac{dx}{1 - \cos \sqrt{x}} = \int_0^n \frac{dx}{1 - 1 + x/2} + \int_{n}^{\pi ^2} \frac{dx}{1 - \cos \sqrt{x}}, $$ where $n$ is sufficiently close to $0$ for the equality to be arbitrarily close to being true.
Now,
$$\int_0^n \frac{dx}{1 - 1 + x/2} = \int_0^n \frac{2}{x} \: dx \rightarrow \infty$$
and, hence, $$\int_{0}^{\pi ^2} \frac{dx}{1 - \cos \sqrt{x}} \quad \text{diverges}$$
Question.
Is this a rigorous way to show that the integral diverges? What makes me suspicious is the step where I let "$n$ be sufficiently close to $0$ fot the equality to being arbitrarily close to true". Is this fine to do?
What you could have done is a Taylor expansion at $x=0$ $$\frac{1}{1-\cos \left(\sqrt{x}\right)}=\frac{2}{x}+\frac{1}{6}+\frac{x}{120}+O\left(x^{2}\right)$$ This is sufficient to show the problem of integrating from $x=0$.
On the other side, doing the same at $x=\pi ^2$ $$\frac{1}{1-\cos \left(\sqrt{x}\right)}=\frac{1}{2}+\frac{\left(x-\pi ^2\right)^2}{32 \pi ^2}+O\left(\left(x-\pi^2\right)^3\right)$$ shows that there is no problem at the upper bound.