TITLE: When can we use derivative test to identify injective function?
QUESTION [5 upvotes]: I have doubt regarding first derivative test for identifying whether a function is injective or not:
For example:
$$f(x)=\ln x$$ has domain $(0, \infty)$.
Now 
$$f'(x)=\frac{1}{x} \gt 0$$ hence $f(x)=\ln x$ is strictly increasing and hence injective.
But if we consider:
$$f(x)=\tan x$$
$$f'(x)=\sec^2 x \gt 0$$
But still $\tan x$ is not injective.
So can I know the formal conditions to test whether a function is injective or not?

REPLY [2 votes]: When you gave the $\log{}$ example, you specified the domain over which you're interested, but not in the case of the $\tan{}.$ Why not? The domain  of definition of a function is very important and should be specified always, not least in this situation -- i.e., when you want to conclude from the constant sign of the derivative to injectivity. It all depends on the domain.
I shall assume the domain of $\tan{}$ is the maximal possible one, since you do not specify it. Now, this domain is different from the one for the $\log{}$ in that it is not an interval, but a union of intervals. This is why the conclusion does not follow, and the test failed. If a function has a derivative with constant sign over an interval, then it is strictly monotone over that interval, and hence injective there. This is what can be safely used. It makes a statement valid over intervals, but is silent about unions of intervals, for example.