What is the domain of $f^2$ if $f(x)=\sqrt{x+2}$ Now, $f(x)$ is defined for all values of $x$ for which $x+2 \geq 0$

$x+2 \geq 0 \implies x \geq -2$
So, $\mathrm{Domain}(f)=[-2,\infty)$ which means $f : [-2,\infty) \longrightarrow \Bbb R$
$f^2(x) = \Big (f(x) \Big )^2=(\sqrt{x+2})^2=x+2$
So, $f^2$ is defined for all values of $x$, right? So, shouldn't $f^2:\Bbb R \longrightarrow \Bbb R$ ?
According to my textbook, $f^2:[-2,\infty) \longrightarrow \Bbb R$
But if we take something outside of $[-2,\infty)$, for example $-5$ and put it in $f^2(x)$, we get:

$f^2(-5) = \Big (f(-5) \Big )^2=(\sqrt{-5+2})^2=(\sqrt {-3})^2=(-3) \in \Bbb R$
Doesn't this mean that $f^2$ is defined for values outside the domain of $f$ as well? So, am I right or is the book right? If the book's right, where am I wrong?
Thanks!
 A: You have written $f^2(-5)=(f(-5))^2$. It is correct, however, look at the inside function of the RHS. It is $f(-5)$. Can you define $f(-5)$? No. That means $f^2(-5)$ is undefined. Similarly $f^2$ is undefined for any $x<-2$. So, your book is correct.
A: $f^2$ is the square of $f$. If $f$ is not defined, neither is $f^2$.
A: The textbook is correct. The domain of $f(x)=\sqrt{x+2}$ is $[-2,\infty)$ which therefore implies that the domain of $f^2(x)$ is also $[-2,\infty)$. 
The new function that you constructed, $h(x)=x+2$, is the not the same as $f^2(x)$ since the domain of $h(x)$ is $(-\infty,\infty)$ while the domain of $f^2(x)$ is $[-2,\infty)$. 
A: $f^n(x)$ exists only in the domain of $f(x)$. This is because the value of $f(x) \notin R \space \forall \space x \notin D$, where $D$ is the domain. It is only a coincidence that squaring the complex number brings it to the real plane.
Here's a graph for verification.

Notice how the domain of $g(x)$ is only $[-2,\infty)$ and not $R$. Thus, your book is correct in this case.
A: 
for example $-5$ and put it in $f^2(x)$, we get:
  $$f^2(-5) = \Big (f(-5) \Big )^2=(\sqrt{-5+2})^2 =(\sqrt {-3})^2=(-3) \in \Bbb R$$ 

(conclusion in) your answer is not that correct.
Assume you are given a function $f(x)=\frac{x}{x}$. What do you think is the domain of this? $\mathbb{R}$ (because it reduces to $f(x)=1$)? No! Actually the domain is $\mathbb{R} \setminus \{0\}$. And similarly the domain of $f(x)=(\sqrt{x})^2$ is $[0,+\infty)$ not $\mathbb{R}$ 
