Rudin mathematical analysis chapter 4 exercise 6 solution Exercise 6, chapter 4 Rudin's "Principles of Mathematical Analysis":

If $f$ is defined on $E$, the graph of $f$ is the set of points $(x, f(x))$, for $x \in E$. In particular, if $E$ is a set of real numbers, and $f$ is rea-valued, the graph of $f$ is a subset of the plane.
Suppose E is compact, and prove that f is continuous on E if and only if its graph is compact.

The following is my solution.
Let $g(x)={(x,f(x)):x\in E}$. For every $\epsilon >0$ there exists $\delta > 0$ such that $d(g(x), g(p))=\sqrt{(x-p)^2+(f(x)-f(p))^2} < \epsilon$ for all points $x \in E$ for which $|x-p|<min(\frac{\epsilon}{\sqrt{2}}, \delta)$. For all points $x \in E$ for which $|x-p|<\delta$, we have $|f(x)-f(p)|<\frac{\epsilon}{\sqrt{2}}$. We can surely find such $\delta$ since $f$ is continuous. We can conclude that $g$ is continuous at $p$, and therefore $g(E)$, the graph is compact.
I would like to ask two questions:

*

*Is my solution to the forward part correct?

*How to prove the inverse part?

Thank you in advance.
 A: Your proof in the forward direction looks fine. For the reverse, suppose that $E$ is compact but $f$ is not continuous. Then we can find a sequence $\{x_n,f(x_n)\}$ so that $\{x_n\}$ converges to $x$ but $\{f(x_n)\}$ does not converge to $f(x)$. By compactness of $E$ we extract a convergent subsequence $\{x_{n_k}, f(x_{n_k})\}$. We know that $f(x_{n_k})$ does not converge to $f(x)$, say it converges to some other value $y$. Then the point $(x,y)$ is the limit point of $\{x_{n_k}, f(x_{n_k})\}$ but is also not contained in $E$ a contradiction. 
A: Try to add details to the answers of @Sheel Stueber.
For the reverse, assume that $E$ is compact but $f$ is not continuous at $x_{0} \in E$. Therefore, $x_{0}$ is a limit point of $E$ (every function is continuous at isolated point). We can find a sequence $\{p_{n}\}$ in $E$ such that $\lim_{n \to \infty} p_{n} = x_{0}$ (Theorem 3.2(d)).
Construct a sequence $\{p_{n}, f(p_{n})\} \in g(E)$, (refer to the question). Because $g(x)={(x, f(x))}$ is compact, by Theorem 3.6(a), we can find a subsequence $\{p_{n_{k}}, f(p_{n_{k}})\}$ converges to $(x_1, y_1) \in g(E)$. By Theorem 3.2(a), $(x_1, y_1)$ is a limit point of $g(E)$. 
Obviously, $\{p_{n_{k}}\}$ is a subsequence of $\{p_{n}\}$, and $\lim_{n \to \infty} p_{n} = x_{0}$, so $\lim_{n_k \to \infty} p_{n_{k}} = x_{0}$. In other words, $x_0=x_1$ and $(x_0, y_1)$ is a limit point of $g(E)$.
Furthermore, because $g(E) \in R^2$ is compact, by Theorem 2.41, $g(E)$ is closed. Then the limit point $(x_0, y_1) \in g(E)$. By definition of function, $y_1=f(x_0)$.
So far, we know $(x_0, f(x_0))$ is a limit point of $g(E)$, i.e., for any $\epsilon > 0$, there is a neighborhood $N_\epsilon (x_0, f(x_0))$ such that $N_\epsilon^* (x_0, f(x_0)) \cap g(E) \neq \emptyset$. In other words, for any $\epsilon > 0$, for all $x \in g^{-1}(N_\epsilon (x_0, f(x_0)) \cap g(E))$, we have $|f(x)-f(x_0)|<\epsilon$ (since $(x-x_0)^2+(f(x)-f(x_0))^2< \epsilon ^2$). We can conclude $f$ is continuous at $x_0$ which contradicts our assumption.
