TITLE: Find $f(x)$ if $f\left(\frac{x+y}{3}\right)=\frac{2+f(x)+f(y)}{3}$
QUESTION [7 upvotes]: $f : \mathbb{R} \to \mathbb{R}$ is a differentiable function satisfying $$f\left(\frac{x+y}{3}\right)=\frac{2+f(x)+f(y)}{3}$$
if $f'(0)=2$, find the function
My Try:
we have $$f\left(\frac{x+y}{3}\right)-\frac{f(y)}{3}=\frac{2+f(x)}{3}$$ $\implies$
$$\frac{f\left(\frac{x+y}{3}\right)-\frac{f(y)}{3}}{\frac{x}{3}}=\frac{2+f(x)}{x}$$ 
Now taking Limit $x \to 0$ we have
$$\lim_{x \to 0}\frac{f\left(\frac{x+y}{3}\right)-\frac{f(y)}{3}}{\frac{x}{3}}=\lim_{x \to 0}\frac{2+f(x)}{x}$$ 
$\implies$
$$f'\left(\frac{y}{3}\right)=\lim_{x \to 0}\frac{2+f(x)}{x}$$ 
Now since LHS to be finite , we need $0/0$ form in RHS, hence $f(0)=-2$
Now by L'Hopital's Rule we get
$$f'\left(\frac{y}{3}\right)=f'(0)=2$$
Integrating we get
$$3f\left(\frac{y}{3}\right)=2y+c$$
Putting $y=0$ we get $c=-6$
So
$$3f\left(\frac{y}{3}\right)=2y-6$$
So $$f(y)=2y-2$$
Hence $$f(x)=2x-2$$
But this function is not satisfying given functional equation. 
What went wrong?

REPLY [3 votes]: Using $x=y=0$ in the functional equation we can see that $f(0)=2$. Further note that $$f(x+h)=\frac{2+f(3x)+f(3h)}{3}, f(x) =\frac{2+f(3x)+f(0)}{3}$$ so that $$\frac{f(x+h) - f(x)} {h} =\frac{f(3h)-f(0)}{3h}$$ Taking limits as $h\to 0$ we get $f'(x) =f'(0)=2$ and thus $f(x) =2x+c$ and from $f(0)=2$ we get $c=2$ so that $f(x) =2x+2$. You can check that it satisfies the functional equation.