Proving $f(x)$ attains $\max$ or $\min$ when $f(x)\to0$ as $|x|\to\infty$. 
Suppose $f:\Bbb R\to\Bbb R$ is continuous such that $f(x)\to0$ as $|x|\to\infty$. Prove that $f$ attains either a maximum or a minimum.

My attempt at the question :
Given $\epsilon > 0 \ \ \exists \ \alpha > 0$ such that
$\ |f(x)| < \epsilon\ \ \ \forall \ \ \  \ |x| > \alpha$  
Now, when  $\ \ x \in [-\alpha,\ \alpha] $, by the Extreme value theorem, since $f(x)$ is a continuous function on a closed interval, it attains a maximum (say $ M$) and a minimum (say $m$).  
I am stuck at this part. I think the way to move forward is by using the fact that we can make $ \epsilon $ as small as possible. But I don't know how to prove that it will surely attain a maximum or a minimum or both.
 A: You are basically done. Here are 2 proofs:
WLOG assume f is not a constant. For every ε we can find an α such that for all x outside of (-α,α), |f(x)| is ε-small. 
Since f is not constant it has a supremum S and infimum I over the whole space with S≠I. Since f is bounded, S and I are not infinite. Since S≠I, at least one is not zero. Choose ε small enough so that max(|S|,|I|)>ε.
we then know that there is α such that |f(x)| < ε for all |x|>α, so we only have to maximise/minimise the function on the compact set [-α,α] which we can do by EVT. Either the max is S or the min is I; this proves the result. 
Alternatively, choose $\alpha$ minimally (as an infimum) and assume without loss $f$ is not constant. Suppose for a contradiction that $f$ does not achieve its sup and also does not achieve its inf. If $M\geq\varepsilon$ then M is a global maximum and if $m\leq-\varepsilon$ then m is a global minimum. So the only way for this to happen is if $m$ and $M$ are in $(-ε,ε)$; this leads to a contradiction as ε→0. (see chat/comments for details)
