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?

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.
