Existence of a maximum value for a continuous function defined on $\mathbb{R}$ Let $f: \mathbb R \to \mathbb R$ be a continuous function. Presume that $f(x) > 0$ for every $x \in \mathbb R$ and $f(x) \le \frac {1}{|x|}$ for all $x \neq 0$. Show that f reaches its maximum value in $\mathbb R$.
So $f(x)$ can't be big when it's far from $0$, I was thinking of using extreme value theorem in something like $[-1,1]$. Can someone show me how to do that, or am I doing it wrong?
 A: Instead of the interval $[−1,1]$, consider the interval $K=[-1/f(0),1/f(0)]$ (note that $f(0)>0$) and see the behaviour of $f$ in $K$ and in the complement $K^c$.
For $x\in K^c$, then $|x|>1/f(0)$ and we have that 
$$f(x) \leq\frac{1}{|x|}<f(0).$$
Moreover, since $f$ is continuous and positive in the compact interval $K$ then it attains a positive maximum value there, say $f(x_0)$ with $x_0\in K$. Note that $f(x_0)\geq f(0)$ because $0\in K$.
Hence for $x\in\mathbb{R}=K\cup K^c$,
$$f(x)\leq \max\left(f(0),f(x_0)\right)=f(x_0).$$
Therefore $x_0$ is a maximum point for $f$ in $\mathbb{R}$.
A: Let $S \subset \mathbb{R}^+$ the set of values taken by $f$. It is an interval (because the direct image by a continuous function of a convex set is itself convex).
In fact, $S$ is bounded, because on $[-1,1]$, continuous function $f$ attains its maximum and, on $(-\infty,-1] \cup [1,+\infty)$, $f$ is evidently bounded by $1$.
It is clear that the two constraints $f>0$ and $f(x)<1/|x|$ make $S$ an open interval on its left end. But is $S$ closed or open on its right end. Is it  $S=(a,b]$ or $S=(a,b)$ ?
In both cases, without prejudging the result, there exist a sequence $x_n$ such that $$\lim_{n \rightarrow \infty} f(x_n)=b.$$
In particular, there exist a $n_0$ such that, 
$$\tag{1}n>n_0 \ \ \ \Rightarrow \ \ \ f(x_n)>b/2  \ \ \ \Rightarrow \ \ \ x_n \in [-2/b,2/b].$$ 
(for the last implication: otherwise if $|x_n|>2/b$, we would have $f(x_n)<\dfrac{1}{|x_n|}<b/2$ ; contradiction with $f(x_n)>b/2$.)
But, on this compact interval $[-2/b,2/b]$, $f$ reaches its maximum.
Thus $S$ is of the form $(a,b]$.
