I have this question: If $f:[0,\infty) \to \mathbb R$ is continuous and $$\lim _{x\to \infty }\:f\left(x\right)\:=\:L$$ then $f$ has a maximum or a minimum on the interval.
I've already proved that this function (on the same terms and limit) is bounded on the interval. I understand why this is true - because the limit can be below the function and then it won't have minimum or above the function and then it wont have maximum. I don't know how to write it formally.
If $f$ is not a constant function there exists $a \geqslant 0$ such that $f(a) \neq L$. Let $M=f(a)$ and let us suppose that $M>L$ (an analoguous reasoning would apply if $M<L)$. We want to prove that $f$ has a maximum. Let $\epsilon=\frac{M-L}{2}>0$.
Since $\lim_{x\to \infty } f(x)=L$ you have the existence of $A > 0$ such that for all $x \geqslant A$, $f(x) \in [L-\epsilon, L+\epsilon]$. Then for all $x \geqslant A$, $f(x) \leqslant L+\frac{M-L}{2} < L + M -L = M$.
On $[0, A]$, $f$ is continuous then has a maximum $B \geqslant M$ (because $a \in [0, A]$). Consequently $f$ has a maximum on $[0, \infty)$.
If $f$ is constant, it should be equal to $L$ and $f$ has a maximum and a minimum.
If $M<L$ we would have proven that $f$ has a minimum on $[0, \infty)$. Note moreover that if there exists $a,\ b$ such that $f(a) \geqslant L$ and $f(b) \leqslant L$ then $f$ has a maximum and a minimum on $[0, \infty)$.