I know that this integral can be evaluated in many ways, but my doubt comes by doing a thing in this specific way.
I was trying to evaluate $$\int_0^{\pi}\frac{1}{\cos x} \text{d}x$$ I would like to multiply for $\frac{\cos x}{\cos x}$, but $\cos x=0$ if $x=\frac{\pi}{2}$ and the integration interval contains $x=\frac{\pi}{2}$; so I suspect that the fractions $\frac{1}{\cos x}$ and $\frac{\cos x}{\cos^2 x}$ aren't equivalent because of this.
So my doubts are:
(1) Can I avoid this problem by using the fact that two integrals are the same if I separate the integration interval in a finite number of points? Like this: $$\int_0^{\pi}\frac{1}{\cos x} \text{d}x=\int_0^{\frac{\pi}{2}}\frac{1}{\cos x} \text{d}x+\int_\frac{\pi}{2}^{\pi}\frac{1}{\cos x} \text{d}x$$ But I'm suspicious, because both integrals on RHS are divergent while the one on LHS isn't. What is the error in doing this? I suspect that this comes by the fact that the fractions aren't equivalent. Am I right? If I'm wrong, what is the reason why this doesn't work?
(2) When am I allowed to manipulate the integrand function? Only when I'm sure that the integrand functions are equivalent in the integration interval?
Thanks for your time.