Why the inverse of this functions not working? If 

$f(x) = (x+2)^2+2$

then we get 2 inverse functions for this function:


$f^{-1}(x) = -2+\sqrt{x-2}$ 
$f^{-1}(x) = -2-\sqrt{x-2}$


If we input functions and inverse functions in to each other we must get "x" back.
But why we don't get "x" when we input function $f(x) = (x+2)^2+2$ into second inverse function $f^{-1}(x) = -2-\sqrt{x-2}$

$f^-1(f(x)) = -2-\sqrt{f(x)-2}$

= $-2-\sqrt{(x+2)^2+2-2}$

= $-2-\sqrt{(x+2)^2}$

= $-2-(x+2)$

= $-2-x-2$

= $-4-x$ ≠ x
As a real-valued function on the reals $f$ is not an invertible function. So, treating some other function as if it were the inverse to $f$ is a recipe for disappointment.

A restriction of $f$, however, is an invertible function from $[-2, \infty)$ to $[2, \infty)$, and the first function you listed is the inverse.

Another restriction of $f$ is an invertible function from $(-\infty, -2]$ to $[2, \infty)$, and the second function you listed is the inverse.



In the second case, the error in your calculation of $f^{-1}(f(x))$ is that if $x \in (-\infty,- 2]$, then $\sqrt{(x+2)^2} \neq x+2$, since $\sqrt{}$ is being used to mean the positive square root, but $x+2$ is negative.
$x=(y+2)^2+2$ here I have interchanged $x$ and $y$.  Now solve for $y$ to get $f^{-1}$.

So, $y=\sqrt{x-2}-2=f^{-1}(x)$.

Remember,  however,  that since $f$ isn't $1-1$, it doesn't have an inverse.  In general,  it has to pass the horizontal line test to have an inverse.  The function I have found is, however,  the inverse to $f$ restricted to $[-2, \infty) $...