Here is Prob. 8, Chap. 4 in the book Principles of Mathematical Analysis by Walter Rudin, 3rd edition:
Let $f$ be a real uniformly continuous function on the bounded set $E$ in $\mathbb{R}^1$. Prove that $f$ is bounded on $E$.
Show that the conclusion is false if boundedness of $E$ is omitted from the hypothesis.
My effort:
Since $f$ is uniformly continuous on $E$, we can find a real number $\delta > 0$ such that $$ \vert f(x) - f(y) \vert < 1$$ for all points $x, y \in E$ for which $\vert x-y \vert < \delta$.
Let $a = \inf E$ and $b = \sup E$. Now let $N$ be a natural number such that $$N > \frac{b-a}{\delta}.$$ Then $$0 \leq \frac{b-a}{N} < \delta.$$
Now for each $k \in \{ 1, \ldots, N \}$, let $$I_k = \left[ a + \frac{(b-a)(k-1)}{N} , \ a + \frac{(b-a)k}{N} \right].$$ Then the length of $I_k$ is exactly $\frac{b-a}{N}$, and therefore we can conclude that, for any points $x, y \in E \cap I_k$, the distance $$\vert f(x) - f(y) \vert < 1.$$ Moreover, if $E \cap I_k$ is non-empty, then we take $x_k$ to be an arbitrary but fixed point in $E \cap I_k$, for each $k$, and note that, for any point $x \in E \cap I_k$, the following holds. $$ \vert f(x) \vert \leq \left\vert f(x) - f\left(x_k \right) \right\vert + \left\vert f\left( x_k \right) \right\vert < 1 + \left\vert f\left( x_k \right) \right\vert.$$
So if $x \in E$, then $x \in I_j$ for some $j$, and so $x \in E \cap I_j$ for that same $j$. Therefore we have $$ \vert f(x) \vert < 1 + \left\vert f\left( x_j \right) \right\vert \leq 1 + \max_{k=1}^N \left\vert f\left( x_k \right) \right\vert = 1 + M,$$ where $M$ is any real number such that $$ M > \max_{k=1}^N \left\vert f\left( x_k \right) \right\vert,$$ showing that $f$ is bounded on $E$.
Is this proof correct? If so, then can we generalize this result to a uniformly continuous mapping of a bounded subset of a given metric space into a metric space? If not, then where have I erred?
Can we find any real uniformly continuous function other than the identity function on $\mathbb{R}^1$ which is unbounded on any unbounded subset of $\mathbb{R}^1$?