TITLE: Different function with the same derivative
QUESTION [12 upvotes]: Today at school I entered in a problem when the professor asked us to differentiate the following function:
$$f(x)=\arctan\left(\frac {x-1}{x+1}\right)$$
With the basic rules of differentiation I came to a confusing result:
$$f'(x)=\frac 1{1+x^2}$$
And the teacher agreed, and so does Wolfram (I checked at home) but what surprised me is that it's the same derivative as
$$f(x)=\arctan x$$
$$f'(x)=\frac 1{1+x^2}$$
So I'm wondering: is that wrong in some sense ? Are the two function equals indeed ? If I integrate $\frac 1{1+x^2}$ what should I choose from the two ? Are there any other examples of different functions with the same derivative?

REPLY [10 votes]: Are you surprised from $3-2=10-9$? ;-) I guess you aren't.
Are you surprised from the fact that $f(x)=x^2$ and $g(x)=x^2+1$ have the same derivative? Not at all, I believe.
The same holds in this case, and it's not the only one! For instance, $f(x)=\arcsin x$ and $g(x)=-\arccos x$ have the same derivative! Also $f(x)=\log x$ and $g(x)=\log(3x)$ do.
The conclusion you can draw is that the two functions differ by a constant on each interval where they are both defined. Since $\arctan\frac{x-1}{x+1}$ is defined for $x\ne-1$, you know that there exist constants $h$ and $k$ such that
$$
\begin{cases}
\arctan\dfrac{x-1}{x+1}=h+\arctan x & \text{for $x<-1$}\\[12px]
\arctan\dfrac{x-1}{x+1}=k+\arctan x & \text{for $x>-1$}
\end{cases}
$$
You can now compute $h$ and $k$, by evaluating the limit at $-\infty$ and at $\infty$:
$$
\frac{\pi}{4}=\lim_{x\to-\infty}\arctan\dfrac{x-1}{x+1}=
\lim_{x\to-\infty}(h+\arctan x)=h-\frac{\pi}{2}
$$
and
$$
\frac{\pi}{4}=\lim_{x\to\infty}\arctan\dfrac{x-1}{x+1}=
\lim_{x\to\infty}(k+\arctan x)=k+\frac{\pi}{2}
$$