Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

The following integral can be obtained using the online Wolfram integrator

$$ \int \frac{dx}{1+\cos^2 x} = \frac{\tan^{-1}(\frac{\tan x}{\sqrt{2}})}{\sqrt{2}}$$

Now assume we are performing this integration between $0$ and $2\pi$. Hence the result of the integration is zero.

On the other hand when looking at the integrand, $\displaystyle \frac{1}{1+\cos^2 x}$, we see that it is a periodic function that is never negative. The fact that it is never negative guarantees that the result of the integration will never be zero (i.e., intuitively there is a positive area under the curve).

What is going on here?

share|improve this question
No paradox here, simply the fact that one applies a result out of its applicability range. To wit, the RHS is not continuous on $(0,2\pi)$ but jumps at points $\pi/2$ and $3\pi/2$. Since the size of each jump is $\pi/\sqrt2$ and there are two jumps, one can even use this very formula to get the correct value of the LHS, namely $\pi\sqrt2$. –  Did Jul 14 '12 at 21:37
It's a pretty common problem with things like Wolfram Alpha. See this and this for instance. –  Guess who it is. Jul 15 '12 at 1:09
A related question. –  Guess who it is. Jul 16 '12 at 16:23

5 Answers 5

up vote 1 down vote accepted

An unusual substitution, the "$\tan(z/2)$"substitution, is being done here. You must take a careful look at what you are integrating. Here is a reference on this substitution.

share|improve this answer
In your case, integrate on $[0,\pi/2]$ and multiply by 4. You can do this because of symmetries. –  ncmathsadist Jul 14 '12 at 21:57
Yeah got it thanks. So the antiderivative must be continuous across the domain of integration to be able to substitute with the integral limits, right? –  Revo Jul 14 '12 at 22:00
Yes. You have to watch out for that. –  ncmathsadist Jul 14 '12 at 22:03
@Revo If $F$ is an antiderivative of $f$, this means that $F' = f$ so in particular $F$ must be continuous. (Otherwise $F$ can't be differentiable.) –  mrf Jul 14 '12 at 22:34
@Revo: "Every calculus student knows that antiderivatives can contain an arbitrary additive constant. But in fact, there’s more arbitrariness than that: one can add different constants on different parts of the interval." –  Guess who it is. Jul 15 '12 at 1:11

(This is an expansion of my earlier comment.)

Consider the function

$$f_c(x)=\frac{x}{\sqrt 2}-\frac1{\sqrt 2}\arctan\left(\frac{\sin\,2x}{3+2\sqrt{2}+\cos\,2x}\right)$$

You can check that the derivative of $f_c(x)$ is $\dfrac1{1+\cos^2 x}$. The relevance of this function is that $f_c(x)$, unlike the function $f(x)=\dfrac1{\sqrt 2}\arctan\left(\dfrac{\tan\,x}{\sqrt 2}\right)$ given in the OP, has no discontinuities within the integration interval $[0,2\pi]$:

plot of two antiderivatives


$$\int_0^{2\pi}\frac{\mathrm dx}{1+\cos^2 x}=\left.\frac{x}{\sqrt 2}-\frac1{\sqrt 2}\arctan\left(\frac{\sin\,2x}{3+2\sqrt{2}+\cos\,2x}\right)\right|_0^{2\pi}=\pi\sqrt 2$$

One wonders how the two functions $f(x)$ and $f_c(x)$ could look so different and yet have the same derivative. A plot of $f_c(x)-f(x)$ shows the difference:


Here, we see that the two functions differ not by a constant, but by a piecewise constant function (i.e., a step function). In fact, the Fundamental Theorem of the Calculus can be stated a bit more generally than is usual in textbooks. To quote Oleksandr Pavlyk's blog entry on this subject,

Every calculus student knows that antiderivatives can contain an arbitrary additive constant. But in fact, there’s more arbitrariness than that: one can add different constants on different parts of the interval.

As already mentioned in the previous answers, the trouble lies in the use of the Weierstrass substitution; the source of the problem, simply put, is that the substitution function used happens to be discontinuous within the interval of integration. Thus, to properly evaluate definite integrals of rational functions of sine and cosine, one has to be careful in using the Weierstrass substitution, and must pay attention to the behavior near the singularities.

Jeffrey and Rich, in their paper, discuss methods for computer algebra systems to cope with this particular weakness of the Weierstrass substitution.

For the sake of completeness, here's a general formula for an antiderivative of $\dfrac1{p+q\cos^2 x}$ that is continuous over the real line:

$$\int\frac{\mathrm dx}{p+q\cos^2 x}=\frac1{\sqrt{p(p+q)}}\left(x-\arctan\left(\frac{q\sin\,2x}{2p+q+2\sqrt{p(p+q)}+q\cos\,2x}\right)\right)$$

share|improve this answer
the paper is available at Jeffrey's homepage ('Offprint service'). –  Raymond Manzoni Jul 15 '12 at 10:51
Thanks @Raymond! –  Guess who it is. Jul 15 '12 at 10:52

Quite simple: the $\arctan$ function is multivalued, so you have to add the appropriate multiples of $\pi$ to the function to get at the right result, i.e. $\sqrt{2}\pi$

share|improve this answer

The antiderivative you are using is not continuous from $0$ to $2\pi$. Ask Wolfram to graph it. Then try to see if you can adjust it by constants on various intervals to make it continuous, and you will see that the integral is quite far from $0$.

share|improve this answer

The problem here is not with the integrand; instead, it is with the antiderivative of the integrand on the interval of integration $(0,2\pi)$, where the antiderivative of the integrand is discontinuous at $\pi/2$ and $3\pi/2$. This suggests that we split the interval of integration to three intervals; namely, $(0,\pi/2)$, $(\pi/2,3\pi/2)$, and $(3\pi/2,2\pi)$. Doing that, we get the right answer $\sqrt 2 \pi$.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.