$f(a+b)=f(a)+f(b)$ but $f$ is not linear

Can you show me a continuous function $f \colon \mathbb{R}^n\to\mathbb{R}^m$ that satisfies $f(a+b)=f(a)+f(b)$ but is not linear?

We have that
$$f(0)=f(0+0)=2f(0)\implies f(0)=0\\
f(x-x)=f(0)=f(x)+f(-x)=0\implies f(-x)=-f(x)\\
f(nx)=f(x+x+\dots+x)=f(x)+\dots+f(x)=nf(x)\quad \forall n \in \mathbb{N}$$
But $$
f(-nx)=-f(nx)=-nf(x)
$$
So:
$$
f(ax)=af(x) \quad \forall a \in \mathbb{Z}
$$

Solutions Collecting From Web of "$f(a+b)=f(a)+f(b)$ but $f$ is not linear"

Nobody can, because a continuous function $f \colon \mathbb{R}^n\to\mathbb{R}^m$ satisfying
$$
f(x+y)=f(x)+f(y)
$$
for all $x,y\in\mathbb{R}^n$ is linear.

The proof is quite easy.

  1. $f(ax)=af(x)$ for all $a\in\mathbb{Z}$ and $x\in\mathbb{R}^n$
  2. $f(\frac{a}{b}x)=\frac{a}{b}f(x)$, for all $\frac{a}{b}\in\mathbb{Q}$ and all $x\in\mathbb{R}^n$

  3. $f(rx)=rf(x)$, for all $r\in\mathbb{R}$ and all $x\in\mathbb{R}^n$.

For the last step, if $r\in\mathbb{R}$, consider a sequence $q_k$ in $\mathbb{Q}$ converging to $r$. Then $q_kx$ is a sequence in $\mathbb{R}^n$ converging to $rx$ and $q_kf(x)$ is a sequence in $\mathbb{R}^m$ converging to $rf(x)$. By continuity of $f$,
$$
f(rx)=f(\lim_{k\to\infty}q_kx)=
\lim_{k\to\infty}f(q_kx)=
\lim_{k\to\infty}q_kf(x)=
rf(x)
$$

The general counterexample for a function satisfying
$$ f(a+b)=f(a)+f(b) $$
but not being linear is to take a Hamel basis and acting with different linear maps on the elements of such a basis.