TITLE: How can this be proved $\lim_{x\to\infty}(f(x)+f'(x))=l$
QUESTION [9 upvotes]: If $$\lim_{x\to\infty}(f(x)+f'(x))=l$$
then prove that $$\lim_{x\to\infty}f(x)=l \text{ and } \lim_{x\to\infty}f'(x)=0 $$

I assume four cases
$$\begin{array}{c|c|c|c|} 
 & f(x) & f'(x) \\ \hline
\text{1} & \infty & -\infty \\ \hline
\text{2} & -\infty & \infty \\ \hline
\text{3} & l & 0 \\ \hline
\text{4} & 0 & l \\ \hline
\end{array}$$
and elimination(1,2,4) of not possible cases can give the answer(3).

My work is not a correct/perfect or flaw proof.What would be a correct one or is this correct.

REPLY [5 votes]: This is the solution coming straight from Hardy's Pure Mathematics and is truly beautiful. Before solving this problem Hardy solves a simple problem:

If $f(x) \to L$ and $f'(x) \to L'$ as $x \to \infty$ then $L' = 0$.

This is easy to do via mean value theorem as we have have $f(x) - f(x/2) = (x/2)f'(c)$ for some $c \in (x/2, x)$. If $L' \neq 0$ then we have contradiction as we take limits with $x \to \infty$ in the above relation.

[If $x \to \infty$ then $x/2 \to \infty$ and hence LHS $f(x) - f(x/2) \to L - L = 0$. Again since $x/2 < c < x$ therefore when $x \to \infty$ then $c$ also tends to $\infty$ and hence $f'(c) \to L'$. Then the RHS $(x/2)f'(c)$ tends to $(x/2)L'$ i.e. to $+\infty$ if $L' > 0$ and to $-\infty$ if $L' < 0$. Hence there is no choice for $L'$ except that $L' = 0$.]

Next we attack the current problem. We are given that $f(x) + f'(x) \to L$ when $x \to \infty$ and we need to show that $f(x) \to L$ and $f'(x) \to 0$ as $x \to \infty$. Hardy simplifies the problem by setting $f(x) = \phi(x) + L$ so that $f'(x) = \phi'(x)$ and  $\phi(x) + \phi'(x) \to 0$ as $x \to \infty$.

[Hardy defines a new function $\phi(x) = f(x) - L$ and then $f(x) + f'(x) = \phi(x) + L + \phi'(x) \to L$ and cancel $L$ from both sides to get $\phi(x) + \phi'(x) \to 0$].

To solve the problem we need to show that both $\phi(x)$ and $\phi'(x)$ tend to $0$ as $x \to \infty$.

[If we show $\phi(x) \to 0$ then $f(x) = L + \phi(x) \to L$ and $f'(x) = \phi'(x) \to 0$ so that we get the original version of the problem.]

Now the argument by Hardy is beautiful and I quote him verbatim:
"If $\phi'(x)$ is of constant sign, say positive, for all sufficiently large values of $x$, then $\phi(x)$ steadily increases and must tend to a limit $A$ or to $\infty$.

[If the derivative $\phi'(x)$ is positive then original function $\phi(x)$ is strictly increasing for all large values of $x$. And there is a very standard theorem that if a function $\phi(x)$ is increasing then $\phi(x)$ tends to a limit or to $\infty$ as $x \to \infty$.]

If $\phi(x) \to \infty$ then $\phi'(x) \to -\infty$ [because $\phi(x) + \phi'(x) \to 0$] which contradicts our hypothesis [we have assumed that $\phi'(x) > 0$ for large values of $x$ and this is incompatible with $\phi'(x) \to -\infty$].
If $\phi(x) \to A$ then $\phi'(x) \to -A$ [because $\phi(x) + \phi'(x) \to 0$] and this is impossible unless $A = 0$ [from our previous result mentioned in beginning of answer]. 
Similarly we may dispose of the case in which $\phi'(x)$ is ultimately negative.

[If $\phi'(x)$ is negative then $\phi(x)$ is decreasing for large $x$. Now there is  again a very standard theorem which says that if $\phi(x)$ is decreasing for all large $x$ then it either tends to a limit or to $-\infty$ as $x \to \infty$. If $\phi(x) \to -\infty$ then because of the relation $\phi(x) + \phi'(x) \to 0$ we get that $\phi'(x) \to \infty$ and this is incompatible with the fact that $\phi'(x)$ is negative for large $x$. If on the other hand we have $\phi(x) \to B$ then again $\phi'(x) \to -B$ and by the result mentioned in the beginning of answer this is possible only when $B = 0$.]

If $\phi'(x)$ changes sign for values of $x$ which surpass all limit, then these are the maxima and minima of $\phi(x)$.

[Note that a when a derivative changes sign it must also vanish somewhere in between and hence we will obtain points where $\phi'(x) = 0$ and before and after this point the derivative $\phi'(x)$ is of opposite signs.  Such points are the maxima and minima of $\phi(x)$ and $\phi(x)$ takes local minimum and maximum values at these points. Since $\phi'(x)$ changes sign for values $x$ which go beyond any limit, this will lead to infinitely many points $x$ which are maxima or minima of $\phi(x)$.]

If $x$ has a large value corresponding to a maximum or a minimum of $\phi(x)$, then $\phi(x) + \phi'(x)$ is small [because it tends to zero] and $\phi'(x) = 0$ [because derivative vanishes at points of maxima/minima], so that $\phi(x)$ is small. A fortiori the other values of $\phi(x)$ are small when $x$ is large. [We see that the maximum and minimum values of $\phi(x)$ are small and hence all the other intermediate values of $\phi(x)$ are also small so that for large $x$ all values of $\phi(x)$ are small. And thus $\phi(x) \to 0$ in this case also.]"
Thus in all cases $\phi(x) \to 0$ and hence $\phi'(x) \to 0$.
Update: Based on comment from OP I add details inline enclosed in [].