The Tangent function fails the horizontal line test, ie There are many values for the independent variable that give the same Dependant variable. This means that The Inverse of the Tangent function is a relation but not a function. We can not find an inverse function for the usual tangent function, but we can find an inverse relation when we only take a little section of the function that does pass the horizontal line test. You will see that the function
f(x) = \tan x, |x|> \frac{\pi}{2} does pass the test. It is a one-to one, monotonically increasing function. Let us also note that the range of this function is the Reals. Now let us define the inverse of this, and observe that it will also be a one-to-one monotonically increasing function, its domain will be the Reals and its range will be all values of y such that |y| < \frac{\pi}{2}. We commonly call this function the arctangent.
Now, by the definition of what it is to be an inverse function, \arctan ( \tan x) = x, but only for |x| < \frac{\pi}{2}. For values \frac{\pi}{2} \pm k\pi, k=1,2,3..., tan x is not defined, or, they are not in the domain of the tangent function, so arctan ( tan x) will not be defined either.
For all other real values, we use the fact that the tangent function has a period of pi, ie f(x) = f(x\pm k\pi), k=1,2,3..., for all values of x in its domain. Using these facts, we can conclude that \arctan (\tan x) = x, |x| < \frac{\pi}{2} and that the function also has a period of pi, since the argument of arctan has a period of pi.
This function is somewhat inaccruately plotted on the Cartestian plain in that image rootX posted up (no offence intended). When drawing the graph, one should have drawn hollow white circles at the points ( \frac{\pi}{2}, \frac{\pi}{2}), (\frac{\pi}{2}, \frac{-\pi}{2}) etc etc, to indicate that the graph does not include that point. Remember the function is not defined at those values.