Find all functions $f$ which are continuous on $\mathbb R$ and which satisfy the equation $f(x)^2=x^2$ for all $x \in \mathbb R$.
Clearly $f(x)=x, -x, |x|, -|x|$ all satisfy the condition. However, how can I show that these must be the only possible choices? The condition guarantees that $|f(x)|=|x|$, for all $x$ so I think it's quite obvious that these four choices are the only possibilities. But I don't see why continuity is necessary. If $f$ does not need to be continuous, are there other possibilities? Then how can I use continuity to guarantee that these are the only choices?