If $f(t)\geq0$ and $\dot{f}(t)=g(t)+h(t)$ with $g(t)\leq0$ and $\lim_{t\to+\infty}h(t)=0$, can we prove that $\lim_{t\to+\infty}\dot{f}(t)=0$? I have the following question: If $f(t)\geq0$ and $\dot{f}(t)=g(t)+h(t)$ with $g(t)\leq0$ and $\lim_{t\to+\infty}h(t)=0$, can we prove that $\lim_{t\to+\infty}\dot{f}(t)=0$? Note that both $g(t)$ and $h(t)$ are continuous functions. This question is related to an engineering problem in the field of sensor networks.
 A: No. Define $h(t)=1$ for $t \in [1,2)$, $h(t)=\frac{1}{2}$ for $t \in [2, 4)$ and so on $h(t)=2^{-k}$ for $t \in [2^k, 2^{k+1})$. Note that the integral of $h$ for each interval $[2^k, 2^{k+1})$ is equal to $1$. Now let $g(t)=-1$ if $t \in [2^k, 2^k+1)$ for some positive integer $k$ and $g(t)=0$ otherwise, then the integral of $g$ for each interval $[2^k, 2^{k+1})$ is equal to $-1$. Hence th two cancel out of each such interval and if we set $f(0)=1$ then $f(t) \in [0,2]$ for all $t$.
With some more effort one can construct continous or even smooth examples of $g, h$ with the same basic idea.
A: The answer is no.
We set $h(t) \equiv 0$ so that $h(t)\to 0$ trivially.

*

*For $g$, put $g(t)=0$ for $t<1$, on each interval $[n,n+1)$, $n\ge 1$, we make $g(t) = -1$ for a time $2^{-n}$, and $0$ otherwise. For example
$$
g(t) = \begin{cases}  -1 & t\in[1,1+1/2) \\ 0 & t\in [1+1/2,2)\\-1 & t\in[2,2+1/4)\\
0 & t\in [2+1/4,3)\\ -1& t\in [3, 3+1/8)\\ 0 & t\in[3+1/8,4)\\ \vdots & \vdots \qquad \vdots \end{cases}
$$
Clearly then, $f'=g$ has no limit, and if we make $f(0)$ large enough, say $f(0) = 100$, then $f\ge 0$ for all time. In fact, the integral of $g$ over all times is precisely $\sum_{n=1}^\infty - 2^{-n}= -1$, so $f(0)=1$ is enough.


*With more work, a continuously differentiable example is possible. Let $\phi(x)$ be your favourite smooth function compactly supported on $[0,1]$ with $\phi(1/2) = 2$ and $\int_0^1 \phi dx = 1$. Define
$$\phi_n(x) = \phi(2^n(x-n))$$
Then $\phi_n$ is compactly supported on $[n, n+2^{-n}]$, with integral  $\int_n^{n+1} \phi_n dx = 2^{-n}$. Now define $g_1(t) = -\sum_{n=1}^\infty \phi_n(t) $, i.e.
$$
g(t) = \begin{cases}  -\phi_1(t) & t\in[1,2) \\
-\phi_2(t) & t\in[2,3)\\
-\phi_3(t) & t\in[3,4) \\ \vdots & \vdots \qquad \vdots \end{cases}
$$
Then $f'=g \in C^\infty$, $g\le 0$, and $\int_0^\infty g dx = -1.$ So  if we choose $f(0)=1$, then $f\ge 0$. As $g(n+2^{-n-1}) = -2$ and $g(n)=0$ for all $n$, $f'$ has no limit.


*In the comments, the OP asked (I'm paraphrasing) if enforcing $g<0$ can prevent the counterexample. The answer is still no. Just choose $f'(t)=g(t)= -\sum_{n=1}^\infty \phi_n(t) - e^{-t} $. Now $g<0$, and $\int_0^\infty g dx = -2  $. So now if we choose $f(0)=2$, then $f> 0$ for all $t$, and this is still a counterexample. (And if we choose $f(0)>2$ then $\lim_{t\to\infty} f(t)>0$ also.) 
Desmos has trouble plotting such an example, but this approximate plot for $t<5$ may give you some intuition.Green ($\color{green}\blacksquare$) is $\phi$, blue ($\color{blue}\blacksquare$) is $g=f'$, and purple ($\color{purple}\blacksquare$) is $f$.
A: To add to one of the answers above: no. This answer is similar, but is continuous (hence avoides the non-differentiability problem).
Again, let $h(x) = 0$, so it converges to 0.
Now let $g(x) = \frac{-1}{2^x}$. We can find options for $f(x)$ simply by integrating $g(x)$.
$$f(x) = f(0) + \int_{0}^{x}g(y)dy = f(0) + \int_{0}^{x}\frac{-1}{2^y}dy = f(0) + \frac{2^{-x} - 1}{\log 2} \to f(0) - \frac{1}{\log 2}$$
So if we say that $f(0) = 1 + \frac{1}{\log 2}$ we have our counter example:

*

*$f(x) = 1 + \frac{2^{-x}}{\log 2} > 0$.

*$g(x) = \frac{1}{2^x} < 0$.

*$h(x) = 0 \to 0$.

*$f'(x) = g(x) + h(x)$

*$f(x) \to f(0) - \frac{1}{\log{2}} = 1 \neq 0$.

And $f(x)$ is infinitely continuously derivable (in case that's a requirement).
EDIT: whoops I switched $t$ for $x$. Doesn't change the counter example though.
