TITLE: A continuous function such that $f(x)=(f(x))^2$ for all $x$ is constant
QUESTION [8 upvotes]: Let $f(x)=(f(x))^2$ that is continuous for every $x \in\mathbb  R$.
Prove using the intermediate value theorem that this function is constant.

I noticed that the $f(x)$ could only be equal to : $1,0$
I know I can evaluate its limit at infinity:
$\lim_{x\to\infty}f(x)=1$
$\lim_{x\to-\infty}f(x)=1$
Can I conclude anything from that that the function is constant?
I know there exist a $c\in R$ such that $1\le f(c) \le 1$, but exists is not proving that for all $c \in R$ :S
Can someone please arrange the mess I've done?:)
Thanks

REPLY [10 votes]: A continuous function $\mathbb{R} \to \mathbb{R}$ whose image consists of finitely many points is constant.
Indeed, if $f: \mathbb{R} \to \mathbb{R}$ is continuous and not constant, there are $a,b \in \mathbb{R}$ with $f(a) < f(b)$. By the intermediate value theorem, $f$ will take all values in the interval $[f(a),f(b)]$, which are infinitely many values.

REPLY [3 votes]: To note that the only two possible values are $0$ and $1$ is a good start. 
Whatever you did to get the limits is false.
Assume the function takes the value $0$ for some $x$ and $1$ for some $y$ and apply the intermediate value theorem to get a contradiction to the function taking only the values $0$ and $1$.  
Then you will know the function is either constant $0$ or constant $1$.