Proof about twice differentiable function. I've been restudying Real Analysis (in one dimension) and got stuck on one problem. I thought that my proof was correct, but, when I checked the solution, the proof that I saw was way more complicated than mine, so I'm assuming mine was incorrect. With that being said, I would like to know why my solution fails to be correct (or if that's actually the case). The problem is the following:
Let $f: [a, + \infty) \rightarrow \mathbb{R}$ be twice differentiable. Prove that if $\lim_{x \rightarrow \infty} f(x)=f(a)$, then there exists $x \in (a, + \infty)$ such that $f''(x)=0$.
Here is my proof:
If $f$ is constant, we must have $f(x)=f(a)$. Hence, $f''$ vanishes everywhere, and we are done.
Let's then suppose that $f$ is not constant. If $f'(a)$ was both the global maximum and minimum of $f'$, then, for every $x \in [a, + \infty)$, we would have
$$f'(a) \leq f'(x) \leq f'(a).$$ That is, $f'$ is constant, and $f(x)=mx+b$ for some $m, b \in \mathbb{R}$ with $m \neq 0$ (since we are assuming $f$ not to be constant). Therefore, $\lim_{x \rightarrow \infty} f(x)=+ \infty$ or $\lim_{x \rightarrow \infty} f(x)=- \infty$, a contradiction. Thus, $f'(a)$ cannot be both the global maximum and minimum of $f'$. In other words, $f'$ attains an extremum at some point $x \in (a, + \infty)$; but since $f'$ is differentiable and $x$ is an interior point of $(a, + \infty)$, we conclude that $f''(x)=0,$ as desired.
 A: Lemma. (Theorem of Darboux) If $f: [a,b]\to\mathbb R$ is differentiable, and $f'(a)<0<f'(b)$, then there exists a $c\in (a,b)$, such that $f'(c)$.
If $f''(x)\ne 0$, for all $x\in(a,\infty)$, then according to the above result, either $f''(x)>0$, for all $x\in(a,\infty)$ or $f''(x)<0$, for all $x\in(a,\infty)$.
Assume that $f''(x)>0$, for all $x\in(a,\infty)$. (The case, $f''(x)<0$, for all $x\in(a,\infty)$ is treated similarly.) Then $f'$ is strictly increasing, and hence there are three possibilities:
I. $f'(x)>0$, for all $x\in(a,\infty)$.
II. $f'(x)<0$, for all $x\in(a,\infty)$.
III. There is a $b>a$, such that $f'(x)<0$, for all $x\in(a,b)$ and $f'(x)>0$, for all $x\in(b,\infty)$.
In the cases I and III, $f$ tends necessarily to infinity, as $x\to\infty$.
Observe that in I, $f'(x)>f'(a+1)>0$, for $x>a+1$, and hence
$f(x)>(x-a-1)f'(a+1)+f(a+1)\to\infty$.
Similarly, in III, $f'(x)>f'(b+1)>0$, for $x>b+1$, and hence $f(x)>(x-b-1)f'(b+1)+f(b+1)\to\infty$.
In case II, $f$ is strictly decreasing, and hence
$$
\lim_{x\to\infty}f(x)\le f(a+1)<f(a).
$$
So, all there cases lead to contradiction, and hence there exists a $x\in(a,\infty)$, where $f''(x)=0$.
