# minimum and maximum problem

I have some difficulties to solve this problem

Let $f\colon\mathbb R\to\mathbb R$ a continuous function such that $$\lim_{x \to-\infty}f(x)=\lim_{x \to+\infty}f(x).$$ Prove that $f$ has a minimum or a maximum in $\mathbb R$ (in the sense that it could also have them both).

-
It is not hard, provided we know the relatively difficult result that a function continuous on a closed ordinary interval $[a,b]$ attains a max and a min on that interval. –  André Nicolas Jan 10 '12 at 8:52

Write $\lim_{|x| \rightarrow \infty} f = l$. Fix $\epsilon$. By definition, away from an interval $I = [-R, R]$, $f$ lies within $\epsilon$ of $l$, and on $I$ $f$ is bounded by compactness, we deduce $f$ is bounded everywhere, hence $\inf f(\mathbb{R}), \sup f(\mathbb{R})$ exist.

From here it's case checking: if the $\inf$ and $\sup$ agree, $f$ is constant, if they disagree, $l$ is at most one of them, and since they are distinct they are separated by some epsilon, we deduce that the other must be obtained on an interval of the form $[-R, R]$ and by compactness is actually achieved by the function.

-

Suppose that the common limit is the real number $c$. Move $f$ up or down so that the limit is $0$. Call the resulting function $g$.

If $g$ is $0$ everywhere, we are finished. Otherwise, $g$ is either somewhere positive, or somewhere negative, or both.

Suppose first that $g$ is positive somewhere. Then for some $a$, and some positive $\epsilon$, we have $g(a)=\epsilon$.

There exists a real number $R$ such that $|g(x)|<\epsilon$ if $|x|>R$. On the interval $[-R, R]$, the function $g$ attains a maximum value. That value is at least $\epsilon$, so it is greater than $g(x)$ for any $x$ such that $|x| >R$. It follows that $g$ attains a global maximum.

If $g$ is somewhere negative, a mild modification of the above argument shows that $g$ attains a global minimum. Alternately, we can consider the function $-g$.

The result also holds if the limits are the same in the extended sense, for example if both limits are $+\infty$. Pick any real $a$, and let $f(a)=b$. There is an $R$ such that $f(x)>b$ if $|x|>R$. On the interval $[-R, R]$, the function $f$ attains a minimum value. That minimum value is $\le b$. Since $f(x)>b$ for $|x|>R$, that minimum value is a global minimum value.

-

If $f$ is constant, then it has a maximum and minimum trivially. Suppose $f$ is not constant, so we have $f(a)-f(b)>\epsilon$ for some $\epsilon>0,a,b\in \mathbb{R}$. Since $\lim_{x \to-\infty}f(x)=\lim_{x \to+\infty}f(x)$ we have some $M$ such that $x\geq M\implies |f(x)-\lim\limits_{x\to-\infty} f(x)|<\epsilon/4$ and some $N$ such that $x\geq N\implies |f(-x)-\lim\limits_{x\to+\infty} f(x)|<\epsilon/4$, so for $|x|>\max\{M,N\}$ we have $|f(-x)-f(x)|<\epsilon/2$. If we choose $x$ such that $|x|\geq a,b$ then we have that $f$ must attain a minimum or maximum on $[-|x|,|x|]$, as we have some point in between which is either above or below both endpoints.

-