Suppose $\mathbb{R}$ be the set of all real numbers and $f:\mathbb{R}\rightarrow \mathbb{R}$ is a function such that the following equation hold for all $x,y \in \mathbb{R}$
(i) $f(x+y) = f(x) + f(y)$
(ii) $f(xy) = f(x)f(y)$
Show that for $\forall x\in \mathbb{R}$, either $f(x)=0$ or $f(x)=x$.
I know to solve this if it is instead of real numbers, it is integers using mathematical induction.
Any help will be appreciated.
Note that$$f(1)=f(1^2)=f(1)^2$$and that therefore $f(1)=0$ or $f(1)=1$.
If $f(1)=0$, then, for any $x$, $f(x)=f(x\times1)=f(x)\times f(1)=0$.
Now, suppose that $f(1)=1$. Note that $f$ is order-preserving. In fact, if $x\geqslant0$, then $x=y^2$ for some $y$ and so$$f(x)=f(y^2)=f(y)^2\geqslant0.$$Therefore, $a\leqslant b\implies f(a)\leqslant f(b)$.
On the other hand, $f|_{\mathbb Q}$ is linear. In fact, since $f(x+y)=f(x)+f(y)$, it is easy to prove by inductain that if $n\in\mathbb{Z}^+$ and if $q\in\mathbb Q$, $f(nq)=nf(q)$. But then, if $n\in\mathbb Z$ and $n<0$, then $f\bigl((-n)q\bigr)=(-n)f(q)$, which is equivalent to $f(nq)=nf(q)$. Finally, if $n\in\mathbb Z$ and $m\in\mathbb N$, then$$mf\left(\frac nmq\right)=f(nq)=nf(q)$$and therefore $f\left(\frac nmq\right)=\frac nmf(q)$.
It follows from this fact together with the fact that $f(1)=1$ that $(\forall q\in\mathbb Q):f(q)=q$. But this, together with the fact that $f$ is order preserving (and that $\mathbb Q$ is dense in $\mathbb R$) implies that $f$ is the identity function. In fact, if $x\in\mathbb R$ and if $\varepsilon>0$, you take rational numbers $q_1$ and $q_2$ such that $q_1\leqslant x\leqslant q_2$ and that $q_2-q_1<\varepsilon$. But then $f(q_1)\leqslant f(x)\leqslant f(q_2)$, which means that $q_1\leqslant f(x)\leqslant q_2$. So, $\left\lvert f(x)-x\right\rvert<\varepsilon$. Since this occurs for each $\varepsilon>0$, $f(x)=x$.