Number of functions for $(f(x))^2=x^2$ If $f\colon\mathbb{R}\to\mathbb{R}$ is a function such that
 $$(f(x))^2=x^2$$
  for all  $x$ , then
1) The number of such functions are?
2) How many of them are continuous?  
I can see 4 functions:
 $y=x$
$y=-x$
$y=|x|$
$y=-|x|$
and they are continuous.
So I get
$1)$ $4$
and
$2)$ $4$
But the answer provided is
1) infinite
2) 4  
Any help?
 A: For any $x\in\mathbb{R}\setminus\{0\}$ you are free to define $f(x)$ as $x$ or $-x$, so you have $2^c$ solutions.
Obviously, just four of them (the ones you found) are continuous.
A: Let $A\subseteq \mathbb R\setminus\{0\}$. Then  you can define
$$f_A(x)=\begin{cases}x&\text{if $x\in A$}\\-x&\text{if $x\notin A$}\end{cases} $$
Then $f_A$ has the desired property and any two of these functions are different.
You merely listed the four solutions belonging to $A=\mathbb R-\{0\}$, $A=\emptyset$, $A=(0,\infty)$, $A=(-\infty,0)$, but of course, there are infinitely many choices for $A$.
A: If $f(x)$ is continuous, you have found the four options. If $f(x)$ is not assumed to be continuous however, you can't even expect $f$ to be continuous at any point of $\mathbb R \backslash \{0\}$: take for instance
$$
f(x) = 
\begin{cases}
x & \text{ if } x \in \mathbb Q \\
-x & \text{ if } x \in \mathbb R \backslash \mathbb Q \\
\end{cases}.
$$
The idea is that the absence of continuity gives you no control whether $f(x) > 0$ or $f(x) < 0$ given a few values of the functions, which you have in the continuous case. In the non-continuous case, you're basically flipping a coin at each $x \in \mathbb R \backslash \{0\}$, so you have $2^{|\mathbb R|}$ options (this is infinite). 
Hope that helps,
A: If $y=x^2$ then $x=\pm y$ so there are infinitely many such functions. The functions that you want are the ones that satisfy $f(x)=\pm x$ for any $x$.
There are many such functions (uncountably many as they are in bijection with the subjects of $\mathbb R$).
To answer the question as to how many such functions there are the answer is $4$. The reason for this is that if $f(x_0)=x_0$ then $f(x)=x$ for all $x$ that has the same sign as $x$.
