Substitute g(x)=f(x)−x, x∈R. Considering the given conditions we get f(2x)=g(2x)+2x≥g(x)+2x⇔g(2x)≥g(x) and f(3x)=g(3x)+3x≤g(x)+3x⇔g(3x)≤g(x). In other words, ∀x∈R:g(3x)≤g(x)≤g(2x).
Let us consider ∀a>0 and let m=minx∈[−a,a]g(x) and M=maxx∈[−a,a]g(x). By Weierstrass theorem there exists x0∈[−a,a] such that g(x0)=M.
Now define a sequence as follows: xn=3−nx0, n=1,2,…. Consequently we get ∀x∈R:g(3x)≤g(x)⇒g(xn)≤g(xn+1),∀n∈N. From this follows g(xn)≥g(x0)=M,∀n∈N and xn∈[−a,a],∀n∈N⇒g(xn)≤M and ∀n∈N:g(xn)=M.
Since g(x) is a continuous function, limn→∞(g(xn))=g(limn→∞xn)=g(0)=0=M⇒∀x∈[−a,a]:g(x)≤0. Similarly we get g(2x)≥g(x),∀x∈R⇒g(x)≥0,x∈[−a,a]. Therefore ∀x∈[−a,a]:g(x)≡0. It implies ∀x∈R:g(x)≡0 and f(x)=x.