Let $f: \mathbb{R} \rightarrow \mathbb{R}$ be continuous such that $$\lim_{x\to\infty} f(x) = \lim_{x\to -\infty}f(x) = 0$$ Show that there $\exists x_0\in\mathbb{R}: \, \mid f(x)\mid \, ≤ \, \mid f(x_0)\mid$ for $\forall x \in \mathbb{R}$.
Basically, this means I have to show that $f$ has a maximum on $\mathbb{R}$, right? There was a theorem in a lecture which said:
Let $f: D \rightarrow \mathbb{R}$ be continuous and $K \subset D$ be compact. Then $f$ has a maximum on $\mathbb{R}$.
However, I cannot use the theorem since $\mathbb{R}$ is not compact. From what I've understood the theorem fails if not compact because there is no maximum if one of the limits is $±\infty$. My approach would've been that:
But since $$\lim_{x\to\infty} f(x) = \lim_{x\to -\infty}f(x) = 0$$ and obviously $$ \mid f(x)\mid\, ≥ 0 $$ $f$ must have a maximum on $\mathbb{R} \setminus \{ \infty, -\infty \} $ since f is continuous.
Is the idea acceptable?