The set of points of boundedness of a function is open I was reading (self study) the book by Thomson Bruckner and Bruckner and ran into one of the exercises that I think I have the proof for by not sure it is right. The statement of the problem goes as follows.
A function $f:\mathbb{R} \mapsto \mathbb{R}$ is said to be bounded at a point $x_o$ provided there are positive number $\epsilon$ and $M$ so that $|f(x)| < M$. for all $x \in (x_o - \epsilon, x_o + \epsilon)$. Show that the set of points at which a function is bounded is open. Let $E$ be an arbitrary closed set. Is it possible to construct a function $f:\mathbb{R} \mapsto \mathbb{R}$ so that the set of points at which f is not bounded is precisely the set E?
My Proof of the first section of the problem was as follows. Let $B_f = \{x : |f(x)| < M, M > 0 \}$ the set of all points where $f$ is bounded (note $M = sup(\{M_x : x \in \mathbb{R}, |f(x)| < M_x\})$ over each $x$, This $sup(\{M_x : x \in \mathbb{R}, |f(x)| < M_x\})$ is bounded and exists, since each $M_x$ is bounded). Then if for every $x \in B_f$ we have by our definition of bounded function at a point, $\forall x \in B_f \ \exists \epsilon > 0 \text{ and } \forall x \in (x - \epsilon, x + \epsilon)$ we have $|f(x)| < M_x$, but this would mean $(x - \epsilon, x + \epsilon) \subset B_f$ which means that $x$ is a interior point of $B_f$. The conclusion follows that $B_f$ is open. 
I have no clue how to construct the function for the second half of the question.
I was wondering if my proof is right? If someone can provide an example for the second part of the question I would be extremely thankful.
 A: Your proof for the first part of the question has some problems.... Note that your set $B_f$ actually depends on the particular $M>0$ which is use to define it, but later you lose track of this dependence when you argue that $x$ is an interior point of $B_f$ using $M_x >0$, which may turn out to have $M_x > M$!
For the second half of the question, the answer is that, yes, for any closed set $E \subseteq \mathbb{R}$, there is a function $f:\mathbb{R} \to \mathbb{R}$ which blows up exactly on $E$. A good start is to define
$$
\begin{align*}
f(x) = \frac{1}{\mathrm{distance}(x,E)} && \text{ for all } x \in \mathbb{R} \setminus E
\end{align*}$$
This partial definition guarantees that


*

*$f$ is bounded at every point in $\mathbb{R} \setminus E$, and

*$f$ is unbounded at every boundary point of $E$.


We need to finish defining $f$ so that it is also unbounded on the interior of $E$. For this, we clearly need a lemma like:

Lemma: Let $U$ be any open subset of $\mathbb{R}$. Then, there is a function $U \to \mathbb{R}$ which is unbounded at every point of $U$. 

I'm sure there are various ways to prove this lemma. The first thing which came to my mind is the following argument

Proof: Let $x_1,x_2,x_3,\ldots$ be real numbers, chosen such that the cosets $x_n + \mathbb{Q}$ are pairwise disjoint. Define $g : U \to \mathbb{R}$ by
  $$g(x) = \begin{cases}
\frac{1}{n} && \text{ if } x \in x_n +\mathbb{Q} \text{ for some } n \\
0 && \text{ if } x \notin x_n + \mathbb{Q} \text{ for all } n \\
\end{cases}$$
  Since each coset $x_n + \mathbb{Q}$ has dense intersection with $U$,  $g$ blows up at each point of $U$. $\square$

Anyway, however this lemma is proved, we can find a function $g:\mathrm{interior}(E) \to \mathbb{R}$ which is unbounded at each point of $\mathrm{interior}(E)$ and use it to finish off our definition of $f$:
$$f(x) = \begin{cases}
\frac{1}{\mathrm{distance}(x,E)} && \text{ if } x \notin E \\
g(x) && \text{ if } x \in \mathrm{interior}(E) \\
0 && \text{ if } x \in \mathrm{boundary}(E) \\
\end{cases}$$
