Proving there is a max,with two limits given. So I need help with this exercise. If $f$ is a positive and continuous function with 
$$\lim_{x \to -\infty} f(x) = \lim_{x \to +\infty} f(x) = 0 $$ 
Prove that $f(x)$ has a maximum. Thanks in advance :)
 A: Well, go back to the definition of a limit that $\forall\; \varepsilon>0$, there exists $b$ such that $|f(x)-L|<\varepsilon\; \forall\; x>b$. Similarly, there exists $a$ such that $|f(x)-L|<\varepsilon\; \forall\; x<a$. So fix $\varepsilon > 0$. Now, $f(x)$ is bounded by let's say $M>0$ on $[a, b]$ by compactness and the continuity of $f$. But it's also bounded by $\varepsilon$ everywhere else. Hence $f$ is bounded above by $\text{max}(M, \varepsilon)$. Now, continuity demands that $f$ reaches its supremum (it exists by boundedness). That is $f$ has a maximum. 
EDIT: Note that I assumed $f$ was continuous on all of $\mathbb{R}$. Of course, counterexamples exist otherwise.
A: Choose an $B$ such that $$x > B \implies |f(x) - 0| < 1$$ and an $A$ such that $$x < A \implies |f(x)- 0| < 1$$
Now consider $f$ which is continuous on $[A, B]$.
I will show the existence of the real number $x_1 \in [A,B]$ such that $f(x)\le f(x_1)$ for every $x\in [A,B]$.
Note the set $S = \{f(x) : x\in [A,B]\}$ is bounded above. So let $M = \sup S$. Then $f(x) \le M$ for every $x \in [A,B]$. Suppose on the contrary that there does not exist $x_1 \in [A,B]$ such that $f(x_1) = M$. Then $f(x) < M$ for every $x\in [A,B]$.
Now it then follows that the function $$g(x) = \dfrac{1}{M-f(x)}$$ is continuous in the closed inverval $[A,B]$, and is therefore bounded above on $[A.B]$. Suppose that $g(x) \le K$ in the closed interval, where $K>0$ since $g(x)>0$ for every $x \in [A,B]$.
This gives $f(x) \le M-\dfrac1K$ contradicting the assumption that $f(x) < M$ for every $x\in [A,B]$.
Hence there exists $x_1\in [A,B]$ such that $f(x_1)=M$.
You can do the same and show that $f(x)$ has maximum in $(-\infty,A]$ and $[B,\infty)$ and therefore $f(x)$ has maximum in the whole $\mathbb{R}$.
