Definite integral $\int_0^{2\pi}\frac{1}{\cos^2(x)}dx$ I encountered this very simple problem recently, but I got stuck on it because I think I am missing something.
It is easy to see that indefinite integral $\int\frac{1}{\cos^2(x)}dx$ is $\tan(x)+C$. Also because $\frac{1}{\cos^2(x)}\geq0$ with the inequality being strict on some interval, the definite integral $\int_0^{2\pi}\frac{1}{\cos^2(x)}dx$ should be strictly positive. But when I evaluate it using the indefinite form result, I get $\tan(2\pi)-\tan(0)=0$, which puzzles me.
I guess this may be common in trigonometric integration and that there should be a trick to get the actual result, but could someone shed some light on this problem?
 A: $$\int_0^{2\pi} \frac{1}{\cos^2x}dx$$
Since the integrand is periodic in $x$ with period $\pi$, we have
$$2\int_0^{\pi} \frac{1}{\cos^2x}dx$$
Also note that the integrand is vertically asymptotic at $x=\frac{\pi}{2}$, so now we have
$$ 2\lim\limits_{a\to\frac{\pi}{2}^-}\int_0^a \frac{1}{\cos^2x}dx+ 2\lim\limits_{b\to\frac{\pi}{2}^+}\int_b^\pi \frac{1}{\cos^2x}dx$$
$$ =2\lim\limits_{a\to\frac{\pi}{2}^-} \left[\tan(a)-\tan(0)\right]+ 2\lim\limits_{b\to\frac{\pi}{2}^+} \left[\tan(\pi)-\tan(b)\right]$$
$$ =2\lim\limits_{a\to\frac{\pi}{2}^-} \left[\tan(a)\right]- 2\lim\limits_{b\to\frac{\pi}{2}^+} \left[\tan(b)\right]=\infty$$
Therefore 
$$\int_0^{2\pi} \frac{1}{\cos^2x}dx\Rightarrow \mbox{diverges}$$
A: This is a trigonometric analog to the classic paradox that
$$\int_{-1}^1{1\over x^2}dx={-1\over x}\Big|_{-1}^1=-1-1=-2$$
despite the fact that $1/x^2$ is strictly positive, hence its definite integral should give a positive result for the area beneath the curve.  The explanation (as given by k170), lies in the fact that improper integrals have to be given careful treatment.
