Proving a function $\frac{1}{2y}\int_{x-y}^{x+y} f(t) dt=f(x)$ is a linear polynomial

Here's the question:

Let $f:\mathbb{R}\to\mathbb{R}$ be a twice differentiable function such that $$\frac{1}{2y}\int_{x-y}^{x+y} f(t) dt=f(x)\text{ for all }x\in\mathbb{R},y>0$$ Show that there exist $a,b\in\mathbb{R}$ such that $f(x)=ax+b$ for all $x\in\mathbb{R}$.


My attempt:

It immediately follows from Fundamental Theorem of Calculus that $f'(x)=\frac{1}{2y} \left( f(x+y)-f(x-y) \right)$ for all $x\in\mathbb{R},y>0$.

Let $x\in\mathbb{R}$ and $y>0$ be arbitrary. Then there is a $c\in(x-y, x+y)$ such that $\frac{f(x+y)-f(x-y)}{2y}=f'(c)$. But $\frac{f(x+y)-f(x-y)}{2y}=f'(x)$ hence, $f'(x)=f'(c)$. But since $x$ was arbitrary, $f'(x)=f'(c)$ for all $x\in\mathbb{R}$. Hence, it follows again by Fundamental Theorem of Calculus that $f(x)=f'(c)x+f(0)$ for all $x\in\mathbb{R}$.


It appears to me as if my proof is correct but I never used the "twice differentiable part". Are there any flaws in my proof? Alternative proofs are welcome.


EDIT: As pointed out by David, my proof is wrong. Hints would be appreciated.


Solution 1:

Rewriting the equation as

$$\int_{x-y}^{x+y}f(t)dt=2yf(x)$$

and differentiating the above equation twice with respect to y one obtains that:

$$f'(x+y)=f'(x-y)$$ from which one can conclude that, after setting respectively $x\rightarrow x-y$ and $x\rightarrow x+y$: $$f'(x-2y)=f'(x)=f'(x+2y) ~~\forall y>0$$

which overrides the fact that y is defined to be positive and sets all values that $f$ takes on the axis equal (if y was a real number we would be able to conclude that simply by virtue of the 2nd equation written). Thus $f'$ is constant and we finally find that

$$f(x)=Cx+D$$

for C,D real numbers. One can check with backsubstitution that there are no other constraints on the two parameters.

In light of this proof, I don't have a good answer as to why $f$ needs to be twice differentiable.

Solution 2:

Since $\int_{x-y}^{x+y} {f(t)dt}= 2yf(x)$, $f(x+y)+f(x-y)=2f(x)$by differentiating by $y$. This means that $f(x)$is symmetric by (x, f(x))for all $x$