Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose $(M,d)$ a metric space. I want to show that if every continuous real-valued function on $M$ attains a maximum, then the space must be compact. I was trying to do this by assuming $M$ non-compact and showing explicitly a function which does not attain a maximum. If $M$ is not bounded it's enough to take the distance from a fixed point as we can always find a sequence which "exits" every compact and pushes the distance at infinity. But what if $M$ is bounded? Thank you

share|cite|improve this question
up vote 20 down vote accepted

If $M$ is not compact then there is a sequence $(x_n)$ without convergent subsequences. The sequence is a closed discrete subspace so the map $f: \{x_n:n\in\mathbb N\}\to \mathbb R$ given by $x_n\to n$ is continuous. By the Tietze extension theorem it has a continuous extension $F: M\to\mathbb R$. Clearly, $F$ is unbounded.

share|cite|improve this answer
Small point: you need to make sure your sequence has no duplicate entries for that function to be well-defined. – Chris Eagle Feb 27 '12 at 22:09
You don't really need to appeal to Tietze. Define $f(x) = \sum_n n \max(1 - d(x, x_n)/\epsilon_n, 0)$ where $\epsilon_n > 0$ is small enough that there are no $x_j \ne x_n$ with $d(x_j, x_n) < 4 \epsilon_n$. – Robert Israel Feb 27 '12 at 23:19
Thanks a lot to you all! All the answers really helped me a lot! Thanks! – fatoddsun Feb 28 '12 at 10:38

This is not meant to replace azarel’s answer, but rather to show in more detail just how unbounded real-valued functions arise in non-compact metric spaces.

Recall that if a metric space $\langle X,d\rangle$ is not compact, then either it’s not complete, or it’s not totally bounded.

If it’s not complete, it has a Cauchy sequence $\langle x_n:n\in\omega\rangle$ that does not converge; define $$f:X\to\mathbb{R}:x\mapsto\lim_{n\to\infty}d(x,x_n)\;.$$

Intuitively, $f(x)$ is the distance from $x$ to the non-existent point to which the Cauchy sequence wants to converge, so you’d expect $f$ to exist and be continuous, and indeed this isn’t hard to prove. Moreover, $f(x)$ is never $0$, because the Cauchy sequence has no limit in $X$. Thus, the function $$g:X\to\mathbb{R}:x\mapsto\frac1{f(x)}$$ is continuous, and it’s also clearly unbounded, since $$\lim_{n\to\infty}g(x_n)=\infty\;.$$ In effect we’ve pushed that non-existent limit of the Cauchy sequence out to be a point at infinity.

If $X$ is not totally bounded, there is an $r>0$ such that no finite collection of open $r$-balls covers $X$. Thus, we may recursively construct a sequence $\langle x_n:n\in\omega\rangle$ such that for each $n\in\omega$, $$x_n\in X\setminus\bigcup_{k<n}B(x_k,r)\;,$$ where $B(x_k,r)$ is the open ball of radius $r$ centred at $x_k$. Note that $d(x_m,x_n)\ge r$ whenever $m<n<\omega$, so $\{B(x_n,r/3):n\in\omega\}$ is an infinite family of pairwise disjoint open balls of radius $r/3$. Now let

$$g:X\to\mathbb{R}:x\mapsto\begin{cases} 0,&\text{if }x\in X\setminus\bigcup_{n\in\omega}B\left(x_n,\frac{r}3\right)\\\\ \frac{3n}r\left(\frac{r}3-d(x,x_n)\right),&\text{if }x\in B\left(x_n,\frac{r}3\right)\;. \end{cases}$$

Clearly $g(x_n)=n$ for each $n\in\omega$, so $g$ is unbounded, and once again it isn’t hard to show that $g$ is continuous.

This time the intuitive idea is to replace the continuous function $$B(x,s)\to\mathbb{R}:y\mapsto d(x,y)$$ that measures distance from the centre of a ball with the function $$B(x,s)\to\mathbb{R}:y\mapsto s-d(x,y)\tag{1}$$ that in a sense measures distance from the boundary of the ball, and then ‘blow up’ the function in $(1)$, making the ball’s radius look bigger than $s$. Since we have infinitely many balls to play with, and they don’t interfere with one another, we can get arbitrarily large ‘blow-up’.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.