$\frac{1}{2r}\int_{x-r}^{x+r}f(t)dt \to g(x)$ uniformly when $r\rightarrow \infty$, then $g(x)=ax+b$ 
Suppose $f$ is a Continuous function on $\Bbb R$ and $g: \Bbb R \to \Bbb R$ a function such that $$ \frac{1}{2r}\int_{x-r}^{x+r}f(t)dt \to g(x) \text{ uniformly }$$ when $r\rightarrow \infty$, then show that $g(x)=ax+b$ for some $a,b \in \Bbb R$.

I really have no idea on how to approach the problem. Thanks in advance for help!
 A: We have
$$\frac{1}{2r}\int_{x-a-r}^{x-a +r} f(t)\, dt + \frac{1}{2r}\int_{x+a-r}^{x+a+r} f(t)\, dt \\= \frac{r+a}{r}\frac{1}{2(r+a)}\int_{x - (r+a)}^{ x + (r+a)}f(t) \, dt + \frac{r-a}{r}\frac{1}{{2(r-a)}}\int_{x - (r-a)}^{ x + (r-a)}f(t) \, dt $$
Taking limits with $a$ fixed  we get $g(x- a) + g(x+a) = 2g(x)$ since  $(r \pm a)/r \to 1$ as $r \to \infty$. Substituting with $u = x-a$ and $v = x+a$, it follows that
$$g(u) + g(v) = 2 g ((u+v)/2)$$
Now take $h(x) := g(x) - g(0)$, whence $ h(u) + h(v) = 2h((u+v)/2)$ and $h(0) = 0$.
Thus,
$$h(u+v) = h(u+v) + h(0) = 2h((u+v+0)/2) = 2h((u+v)/2) = h(u) + h(v),$$
and we see that $h$ must be a linear function. It is also continuous as the uniform limit of continuous functions.
Finally, it can be shown that a linear function with points of continuity must be of the form $h(x) = h(1)x$ and, therefore,
$$g(x) = h(x) + g(0) = h(1)x + g(0) = ax+b$$
A: I cannot post comments, so I'll give some idea in form of an answer. First, note that for $x < y$
$$
g(x) - g(y) = \lim_{r\to\infty} \dfrac{1}{2r} \left( \int_{x-r}^{y-r} f(t)dt + \int_{x+r}^{y+r} f(t)dt\right).
$$
For $y = 0$, we get a new function $h(x) := g(x) - g(0)$. If we can prove that $h$ is linear, we are done. From the above, this seems quite probable, because the integrals on the right should only depend on the gap between $x$ and $y$!
For starting, take $x,y < 0$. Then
$$
\dfrac{1}{2r}\int_{(x+y) - r}^{-r} f(t)dt = \dfrac{1}{2r}\left(\int_{x + y-r}^{y-r} f(t)dt + \int_{y-r}^{-r} f(t)dt\right),
$$
giving
$$
\dfrac{r-y}{r}\dfrac{1}{2(r-y)}\int_{x - (r-y)}^{(r-y)} f(t)dt + \dfrac{1}{2r}\int_{x-r}^{-r} f(t)dt \sim \dfrac{1}{2r} \int_{x-r}^{-r} f(t)dt + \dfrac{1}{2r}\int_{y-r}^{-r}f(t)dt.
$$
You can do the same thing with $x$ and $y$ arbitrary (at first sight...?), also for the second integral. This gives the functional equation
$$
h(x+y) = h(x) + h(y),
$$
which is sufficient for linearity, because we know that $g$ is continuous (uniform convergence).
