$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?
One readily verifies that the affine map $a(x) = 2x+2$ is a differentiable function which solves both the defining equation for $f$ and the derivative constraint $f'(0) = 2$.
Let's prove now the uniqueness of this solution. The defining equation can be rewritten $f\left( \frac{x+y}{3} \right) - \frac{f(x) + f(y)}{3} = \frac{2}{3}$. Differentiating with respect to $x$, we get $f'\left( \frac{x+y}{3} \right) - f'(x)=0$ regardless of the values $x$ and $y$, so that $f'(x)$ is a constant. The constraint $f'(0)=2$ thus yields $f'(x) \equiv 2$, which integrates to $f(x) = 2x+c$. Substituting this result into the defining equation for $f$ readily yields $c=2$.
Remark: Paramanand Singh's answer is better than mine in that it proves that $f$ is differentiable at every point by only using its defining equation and the assumption that it is differentiable at $0$. In that respect it is quite instructive. Be aware however that such a proof is in general rather difficult, hence the frequent assumption that $f$ is differentiable ; one doesn't need then to rely on the definition of a derivative, but can rather merely differentiate the defining equation as I did above.