Solution (source code)

= Solution

Try a <linear function> $f(x)=cx$. The <functional equation> becomes $c^2x=(c+1)x$ for all $x$, so $c$ must be a <root of a polynomial> $c^2-c-1$. Its two <roots of a polynomial> give
$$
\boxed{f(x)=\frac{1+\sqrt5}{2}x}
\qquad\text{or}\qquad
\boxed{f(x)=\frac{1-\sqrt5}{2}x.}
$$
For either choice, $c^2=c+1$ proves the required equality directly. The positive coefficient is the <golden ratio>.