[Math] If $S$ is not compact, there is a continuous function unbounded on $S$

continuityreal-analysis

problem

This was given to me as a homework problem to prove:

If $S \subseteq \mathbb{R}$ is not compact, then there exists a
continuous function $f : S \rightarrow \mathbb{R}$ that is unbounded
on $S$.

my work

So far I have got this:

If $S \subseteq \mathbb{R}$ is not compact, then there must be a sequence in $S$ that has a subsequence that does not converge to a limit also in $S$.

If it diverges then obviously it is unbounded on $S$. If it does converge to a limit not in $S$, then $(s_{n_k}) \rightarrow y$ with $y \notin S$ for some sequence $(s_n)$ with a subsequence $(s_{n_k})$.

So for this sequence, we now have

$\forall \epsilon >0$ $\exists N \in \mathbb{N}$ such that $n \geq N \rightarrow |s_{n_k}-y| < \epsilon$

Now I take a function that is continuous on $S$ but discontinuous at the limit which is outside of $S$:

$f(x) = \frac{1}{x-y}$

When $n \geq N$, $|s_{n_k}-y|< \epsilon$, so

$\frac{1}{|s_{n_k}-y|}>\frac{1}{\epsilon}$

$|f(s_{n_k})|>\frac{1}{\epsilon}$

This should hold for any $\epsilon$, which can be taken arbitrarily small.

This is where I think I'm stuck. I want to conclude something (since all $s_{n_k}$ are in $S$, $f(x)$ is unbounded on $S$…), but I feel like something is missing.

Is my reasoning correct or am I dramatically missing something? I still have to get used to writing proofs. Any hint/comment is very welcome!

Best Answer

You've correctly concluded that (if $S$ does not contain one of its limit points) $f$ is unbounded. In particular, you can say something like

For any $\epsilon > 0$, there exists an element of our subsequence $s_{n_k} \in S$ for which $$ f(s_{n_k}) > 1/\epsilon $$ Since $\epsilon$ was arbitrary, we may conclude that $f$ is unbounded.

Or, if you want to be very clear (excessively perhaps) about how the definition of unboundedness features, you can write:

For any $M > 0$, we note that there is an element $s \in S$ from our subsequence for which $|s - y| < 1/M$ Thus, we may state that there exists an $s \in S$ for which $$ f(s) > M $$ Since $M$ was arbitrary, we may conclude that $f$ is unbounded.

Note that you need to separately consider the case where $S$ is itself an unbounded (but closed) set, perhaps with $f(x) = x$.