Show that if $f :[0,\infty[ \rightarrow\mathbb{R}$ is continous then $f$ attain a maximum. Show that if $f :[0,\infty[ \rightarrow\mathbb{R}$ is continous with $\lim \limits_{x \to 0} f(x) = 0$ and $\lim\limits_{x \to\infty} f(x) = 0$ then $f$ attain a maximum.
Suppose by contradiction that the real $M=\max_{x\in[0,\infty[}f(x)$ does not exist and suppose that $f \not\le 0$, $\forall x\in[0,\infty[$. Otherwise, $M=0$
Then by definition, $\forall M\in\mathbb{R}$, $ \exists x \in[0, \infty[$ such that $f(x) \ge M$.
So, let $M\ge 0$,
By assumption, $\lim\limits_{x \to\infty} f(x) = 0$  $\Leftrightarrow$ $\exists A_M$, $\forall x \gt A_M \Rightarrow$ $\lvert f(x)\rvert \le M$.
So, $\not\exists x \in]A_M, \infty[$ that verified $f(x) \ge M$.
Since, $ x \not\in]A_M, \infty[$,  $x$ has to be in the interval $[0,A_M]$.
But, since $f$ is continous on a closed interval, by the extreme value theorem, $\exists \beta \in \mathbf{Im_f} =\{f(x) \in\mathbb{R}: x \in[0,A_M]\} $ $\mathbf {s.t}$ $\forall x \in [0,A_M]$ we have $f(x)\le\beta$.
This is a contradiction to our conclusion that there is not a maximum for $f$. 
Can someone tell me if my proof is correct, if not why and how to make it true ?

Since $f$ is continuous and $\lim_{x \to 0}f(x)= \lim_{x \to \infty}f(x)=0$ there exists a $\delta > 0$ such that $|f(x)| \leq 1$ for all $x \leq \delta$ and $x \geq 1/\delta $.  But then $f$ is continuous on the compact set $[\delta, 1/\delta]$ and so it attains its supremum there.
