# 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?

• You have to break it up into smaller integrals because it's improper, with discontinuities at $\pi/2, 3\pi/2$. Dec 22 '14 at 10:53
• Integrating between $0$ and $\pi/2$ reveals a problem...
– user65203
Dec 22 '14 at 11:01
• This integral does not converge. Dec 22 '14 at 11:08
• Thanks a lot to all of you! So it is common to break improper integrals into pieces to evaluate them. In this example the function is discontinuous at $\frac{\pi}{2}+k\pi$, but I have encountered the problem with continuous functions as well, so I guess there is no general rule about how to split the integral. Dec 22 '14 at 23:55

$$\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}$$
$$\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.