Question about $\tan^{-1}(\tan(x))$ We talk about $\tan^{-1}(x)$ in $(-\frac{\pi}{2} \ \ \frac{\pi}{2})$ interval because it's one-to-one. But we can also consider other intervals like $(\frac{\pi}{2},\pi)$ , $(\pi,\frac{3\pi}{2}),\dots$. When we want to find value of $\tan^{-1}(\tan(\frac{4\pi}{3}))$ , the $\frac{4\pi}{3}$ is wrong answer because it's not in $(-\frac{\pi}{2},\frac{\pi}{2})$ interval. But I think we can say  $\tan^{-1}(\tan(x)) = x $ or   $\tan(\tan^{-1}(x)) = x $  in any intervals (that is pointed out)
What's my mistake ?
 A: The maps $(-\frac\pi2,\frac\pi2)\to\mathbb{R},x\mapsto\tan(x)$ and $\mathbb{R}\to(-\frac\pi2,\frac\pi2),x\mapsto\arctan(x)$ are bijections and each one is the inverse of the other one.
Hence we have :
$$\forall x\in\mathbb{R},\,\tan(\arctan(x))=x$$
and
$$\forall x\in(-\frac\pi2,\frac\pi2),\,\arctan(\tan(x))=x$$
Now consider any $\displaystyle{x\in\mathbb{R}-\{\frac\pi2+k\pi;\,k\in\mathbb{Z}\}}$.
There exists a unique integer $k$ such that $x-k\pi\in(-\frac\pi2,\frac\pi2)$; so :
$$\arctan(\tan(x-k\pi))=x-k\pi$$
but $\tan(x-k\pi)=(-1)^k\tan(x)$ and $\arctan(-t)=-\arctan(t)$ for every $t\in\mathbb{R}$.
Hence :
$$\arctan(\tan(x))=(-1)^k(x-k\pi)$$
If you prefer an even more explicit formula, you can observe that the condition $$-\frac\pi2<x-k\pi<\frac\pi2$$ is equivalent to $$k<\frac x\pi+\frac12<k+1$$ so that :
$$\boxed{\forall x\in\mathbb{R}-\{\frac\pi2+k\pi;\,k\in\mathbb{Z}\},\;\arctan(\tan(x))=(-1)^{\lfloor\frac x\pi+\frac12\rfloor}\left(x-\left\lfloor\frac x\pi+\frac12\right\rfloor\pi\right)}$$
A: The tangent function reports a number between $(-\infty, \infty)$ in accordance with the angle input from the domain. So the formula $\tan(\tan^{-1}(x))$ reports the tangent of the angle between $(\frac{-\pi}{2},\frac{\pi}{2})$ whose tangent is $x,$ and hence will always return $x.$ 
On the other hand, $\tan^{-1}(\tan(x))$ is the angle between $(\frac{-\pi}{2},\frac{\pi}{2})$ that shares the same value as the tangent of the angle $x.$ Hence, $\tan^{-1}(\tan(x))=x$ if and only if $x \in (-\frac{\pi}{2}, \frac{\pi}{2}).$ However, the above description does imply $\tan^{-1}(\tan(x))=x+k\pi$ where $k \in \mathbb{Z}.$ 
A: This is an object lesson in why $\tan^{-1}$ is a misleading and hence poor notation!
We know that the restriction of the function $\tan$ to the interval $\left(-\frac{\pi}{2}, \frac{\pi}{2}\right)$ is bijective, so it is invertible. We denote this inverse, which we often called the arctangent by
$$\arctan := \left(\tan\vert_{\left(-\frac{\pi}{2}, \frac{\pi}{2}\right)}\right)^{-1} .$$
Concretely, this is the function that takes as its argument the slope $m$ of a line $L$ in the plane and returns the (signed) angle $\arctan m$ in $\left(-\frac{\pi}{2}, \frac{\pi}{2}\right)$ formed by the $x$-axis and $L$.
Since $\tan\vert_{\left(-\frac{\pi}{2}, \frac{\pi}{2}\right)}$ and $\arctan$ are inverses, we have
$$\left(\tan\vert_{\left(-\frac{\pi}{2}, \frac{\pi}{2}\right)} \circ \arctan\right)(y) = y \qquad \textrm{and} \qquad \left(\arctan \circ \left(\tan\vert_{\left(-\frac{\pi}{2}, \frac{\pi}{2}\right)}\right)\right)(x) = x.$$
The first equation tells us that $\tan \arctan y = y$ for any real $y$. The second equation, however, guarantees that $\arctan \tan x$ only for $x \in \left(-\frac{\pi}{2}, \frac{\pi}{2}\right)$---of course, this equation can't hold for any other $x$, for the simple reason that the image of $\arctan$ is $\left(-\frac{\pi}{2}, \frac{\pi}{2}\right)$! On the other hand, since we know that $\tan (x + \pi k) = \tan x$ precisely for integers $k$, we can conclude a slightly weaker statement for general $x$, namely that $$\arctan \tan x = x \pmod \pi .$$
