I am trying to prove or disprove the following statement.
Let $f : [0, +\infty) \rightarrow \mathbb{R}$ be a continuous nonnegative function such that $f(0) = 0$ and $\displaystyle \lim_{x \to +\infty} f(x) = 0$. Then $f$ attains an absolute maximum.
I can show that such a function is bounded, but I don't know whether the above statement is true or false. I have tried to prove it using some ideas from the proof of Weierstrass extreme value theorem, but I was not successful. Could anyone give a hint for the proof or a counterexample?
EDIT. Using Jack D'Aurizio's comment below, I think I can prove the statement. If $f \equiv 0$, then the statement is trivial. Otherwise, there exists $x_1 \in [0, +\infty)$ such that $f(x_1) > 0$. Since $\displaystyle \lim_{x \to +\infty} f(x) = 0$, there exists $x_0 \geqslant x_1$ such that \begin{equation*} |f(x)| \leqslant f(x_1) \quad \forall \, x \geqslant x_0. \end{equation*} By Weierstrass's theorem, there exists $\overline{x} \in [0, x_0]$ such that $f(x) \leqslant f(\overline{x}) \enspace \forall \, x \in [0, x_0]$. Besides, $f(x_1) \leqslant f(\overline{x})$, because $x_1 \in [0, x_0]$. Then, we have \begin{equation*} f(x) \leqslant f(x_1) \leqslant f(\overline{x}) \quad \forall \, x \geqslant x_0. \end{equation*} $f(\overline{x})$ is the maximum value of $f$ on $[0, +\infty)$.
Is this proof correct? If it is, can it be improved?