I recently noticed on Youtube a solution to an indefinite integral that I think is a useful chance to clarify an important point about antidifferentiation of a given function.

The integral I am talking about is \[\mathcal I = \int \frac1{\cos^2x(1+\tan^2x)}dx.\]The proposed solution is based on the substitution \(\tan x = u\), that leads to \[\mathcal I = \int \frac1{1+u^2} du,\]that is\[\mathcal I = \arctan u + C,\] where \(C\) is an arbitrary constant. Replacing back the original function yields \[\mathcal I = \arctan(\tan x) + C.\tag{1}\label{eq3177:1}\]

Now, what is suggested is that \(\arctan(\tan x)\) is simply equal to \(x\); so that the solution proposed by the author of the video is \[\mathcal I = x + C.\]


Here are now a couple of questions.

  1. If the proposed solution is correct, then the RHS of \eqref{eq3177:1} should represent all possible antiderivatives of the integrand. But derivating that expression just leads to \(1\). How is this possible?
  2. Is it true that \(\arctan (\tan x) = x\)? At first sight it looks as if we were applying a function and then its inverse, but this is not the case (recall in fact that \(\tan x\) is not a bijective function). Note for example that \(\arctan (\tan x)\) is periodic, and, also, it is not defined for \(x = \frac{\pi}2 + k\pi\)!

Starting from the first question, note that, for \(x\neq \frac{\pi}2 + k\pi\) we have that the integrand is equal to\begin{eqnarray}f(x) &=& \frac1{\cos^2x(1+\tan^2x)} =\\ &=& \frac1{\cos^2x\left(1+\frac{\sin^2x}{\cos^2x}\right)}=\\ &=&\frac1{\cos^2x + \sin^2x}=1.\end{eqnarray}

So it is correct that the integrand is equal to \(1\), where it is defined. But can we actually ignore the domain of \(f(x)\)?

The answer is no, and analyzing why this is the case brings us to the second question. Below is a plot of \(F(x) = \arctan (\tan x)\).

Note that in the range \(|x| < \frac{\pi}2\), this function coincides with \(G(x) = x\). Also, whenever it is defined (that is again for \(x\neq\frac{\pi}2+k\pi\)) the derivative of \(F(x)\) is equal, too, to \(1\).

So both \(F(x)\) and \(G(x)\) are valid antiderivatives of \(f(x)\) in its domain.

They do not differ by a constant, though. And this is the most important observation! As a matter of fact, when the integrand is defined over a disjoint union of two or more open intervals, then a different additive constant can be chosen in each interval, thus generating a much ‘larger’ set of antiderivatives then those represented by either\[F(x) = \arctan(\tan x)+C\] or\[G(x) = x + C.\] For example, if restricted to the usual domain, \[H(x) = \begin{cases}x & (|x|<\frac{\pi}2)\\ x-\frac{\pi}2&(x<-\frac{\pi}2)\\x+\frac{\pi}2 & (x> \frac{\pi}2)\end{cases}\]is another valid antiderivative of \(f(x)\).

In conclusion, taking into account the domain of the original function leads to a correct definition of the set of all its valid antiderivatives .


As a further exercise, in the domain \(\Bbb R – \{0\}\) find all the antiderivatives of \(f(x) = -\frac1{x^2}\).