Limit of an integral which converges to the limit of the integrand function Let $f$ be an integrable function from $[0, \infty)$ to $[0, \infty)$ and let $k>0$ be a constant.
I think it is true that
$$
\left|\int_{t-k}^t f(s) ds - f(t) \right| \rightarrow 0 
$$
as $t \rightarrow \infty.$
My tentative proof is the following.
Let us fix for the moment $t>0.$
Then
$$
\left|\int_{t-k}^t f(s) ds - f(t) \right|= \left|F(t)-F(t-k) - f(t) \right|
$$
where $F$ is the primitive of $f$ and is therefore a continuous function.
By the mean value theorem we have that there exists a point $\overline t \in [t-k, t]$ such that
$$
F'(\overline t ) =f(\overline t) = \frac{F(t)-F(t-k)} {k} 
$$
therefore
$$
\left|F(t)-F(t-k) - f(t) \right|=\left| k f(\overline t) - f(t)\right| \rightarrow 0 
$$
as $t \rightarrow \infty.$
Is this proof correct?
 A: First of all, $f$ might not be continuous. Thus a primitive might not exist. One can still define
$$ F(x) = \int_a^x f(s) ds$$
for some fixed $a$, however this $F$ might not be differentiable (see this comment below). If $F$ is not everywhere differentiable, you cannot apply Mean Value Theorem.
Even if $f$ is everywhere continuous, so $F$ is differentiable, at the end you have only
$$|kf(\bar t) - f(t)|$$
which does not tend to zero.
After all, the result is false: counterexample: let $f$ be defined by
$$ f(x) = \begin{cases} n^2 (x-n) & x\in [n, n+1/n^2], n\in \mathbb N,\\
-n^2 (x-n-1/n^2)+1 & x\in [n+1/n^2, n+2/n^2], n\in \mathbb N, \\
0 &\text{otherwise.}\end{cases}$$
that is, for each $n\in \mathbb N$, the graph of $f$ in $[n, n+1]$ is a triangle with base $[n, n+2/n^2]$ and height one (so area is $1/n^2$). Then
$$\int_0^\infty f(x) dx = \sum \frac{1}{n^2} <\infty,$$
but
$$
\int_{t-k}^t f(x) dx - f(t)
$$
diverges (note that the first term tends to zero, while the second one diverges. Indeed, any integrable functions such that the limit at $+\infty$ does not exist are counterexamples).
A: *

*The function
$$f(x)=\sum^\infty_{n=0}n^{-3}\mathbb{1}_{[n,n+\tfrac1n]}(x)$$, i.e. $f(x)=n^{-3}$ if $n\leq x\leq n+\frac1n$ for some $n\in\mathbb{N}$ and zero otherwise, is integrable and does not satisfy the desired condition for any constant $k$ (other than $k=0$).
Of course, $f$ is not continuous, but with a little effort, we can construct a similar function $g$ (try to modify $f$ a little) that is continuous and still would not satisfy the desired result.


*Here is another interesting example
$$h(x)=x^2e^{-x^8\sin^2x}$$
Ths function is integrable on $[0,\infty)$, $\mathcal{C}^\infty(0,\infty))$ and does not satisfy the statement either.
