A bounded function in $\Bbb R$ with closed graph is continuous.
It is known that if a function $f:\Bbb R\to \Bbb R$ is continuous then its graph is closed.
Proof. Let $(x_n)_{n\in\Bbb N}$ be a sequence in $\Bbb R$ so that the sequence $(x_n,f(x_n))_{n\in\Bbb N}$ is convergent in $\Bbb R^2$ at a point $(x,y)\in\Bbb R^2$. Then as the convergence in $\Bbb R^2$ is point-wise we have$$(x_n,f(x_n)) \xrightarrow{n\to \infty} (x,y) \Longrightarrow x_n\to x \ \ \& \ \ f(x_n)\to y $$Now, from the continuity of $f$ we have that
$$x_n \to x \Longrightarrow f(x_n)\to f(x)$$
and from the uniquence of the limits we assume that $y=f(x)$.
So, $\lim_{n\to\infty}(x_n,f(x_n))=(x,f(x))\in G(f)$ and so $G(f)$ is closed.
We know that the converse is not true in general, that is if the graph of a real function $f$ is closed we cannot conclude that $f$ is continuous. One counter-example is the function:$$f: \Bbb R \to \Bbb R, \ \ f(x)=\begin{cases} \text{$\frac{1}{x} \ \ \ \ $ if } x \neq 0 \\ \text{$0 \ \ \ \ \ $ if } x= 0 \end{cases}$$
$f$ is discontinuous at $x=0$ and $G(f)=\left\{ \left(0,0\right)\right\} \cup\left\{ (x,\frac{1}{x})\big|x\in\mathbb{R}\setminus\left\{ 0\right\} \right\} $ is closed because both of the sets are closed.
BUT if we add that $f$ is bounded, then it can be proved that $f$ is continuous. I am having trouble in the proof. Here is my attempt:
Attempt of a proof. Let $(x_n)_{n\in\Bbb N}$ be a real sequence that converges to some $x\in\Bbb R$. We need to prove that $f(x_n)\xrightarrow{n\to \infty}f(x)$. We have that for all $n\in\Bbb N$ $(x_n,f(x_n))\in G(f)$ and that $((x_n,f(x_n))_{n\in\Bbb N}$ is bounded on $\Bbb R^2$ (since $(x_n)_{n\in\Bbb N}$ is convergent and $f$ is bounded). So from the Bolzano-Weierstrass theorem there exists a subsequence $(x_{k_n})_{n\in\Bbb N}$ of $(x_{n})_{n\in\Bbb N}$ so that $(x_{k_n},f(x_{k_n}))_{n\in\Bbb N}$ converges. Now, because $G(f)$ is a closed set $\exists x'\in\Bbb R :(x_{k_n},f(x_{k_n}))\to (x',f(x')) $ and so $x_{k_n}\to x'$ and $f(x_{k_n})\to f(x')$. Moreover, $x_n\to x \ \ \& \ \ x_{k_n}\to x' \Longrightarrow x=x'$ and so $f(x_{k_n})\to f(x)$.
I cannot go any further than this.
$\endgroup$ 23 Answers
$\begingroup$Another way to think about this (not following the OP's approach, but using compactness in a slightly different way):
To show that $f$ is continuous, it's enough to show that the restriction $f_{|I}: I \to \mathbb R$ is continuous for each closed interval $I \subset \mathbb R$; this is what we'll do.
Let $\Gamma_f \subset \mathbb R^2$ denote the graph of $f$, which is closed by assumption. Then $\Gamma_{f_{|I}} := \Gamma_f \bigcap (I \times \mathbb R)$, which is the graph of $f_{|I}$, is closed in $I\times \mathbb R$. The assumption that $f$ is bounded shows that it is also bounded, and so it is a compact subset of $I\times \mathbb R$.
Now it is a general property of graphs that the projection $\Gamma_{f_{|I}} \to I$ given by $(x,y) \mapsto x$ is continuous and bijective. A continuous bijection between compact topological spaces is necessarily a homeomorphism. Taking the inverse homeomorphism we obtain a homeomorphism $I \to \Gamma_{f_{|I}}$, which when composed with the (continuous) projection $\Gamma_{f_{|I}} \to \mathbb R$ defined by $(x,y) \mapsto y$, gives the function $f_{|I}: I \to \mathbb R$, but now realized as a composite of continuous functions. This shows that $f$ is continuous.
(We also see that we don't need to assume that $f$ is bounded, but just that $f$ is bounded when restricted to bounded subsets of $\mathbb R$ --- a property that every continuous function on $\mathbb R$ satisfies; of course, this is also clear with the OP's proof strategy (as completed in the other answers). )
$\endgroup$ $\begingroup$Very good so far. To finish it, assume that $\bigl(f(x_n)\bigr)$ didn't converge to $f(x)$. Then there would be an $\varepsilon > 0$ and a subsequence $(x_{n_k})$ of $(x_n)$ with $\lvert f(x_{n_k}) - f(x)\rvert \geqslant \varepsilon$ for all $k$. Apply your argument to the sequence $(y_k)$ given by $y_k = x_{n_k}$ to obtain the contradiction that $f(y_{k_m}) \to f(x)$ for some subsequence of $(y_k)$, although by construction $\lvert f(y_k) - f(x)\rvert \geqslant \varepsilon$ for all $k$. So the initial assumption is untenable, and we conclude that $f(x_n) \to f(x)$. Since the sequence $(x_n)$ converging to $x$ was arbitrary, $f$ is continuous at $x$. Since $x$ was arbitrary, $f$ is globally continuous.
$\endgroup$ $\begingroup$Here's a summary of the ideas presented above.
If $\lim_{n\to\infty} x_n =x$, yet $f(x_n)$ does not converge to $f(x)$, WLOG, $\limsup_{n\to\infty} f(x_n) > f(x)$ (otherwise replace by $-f$), then there exists a subsequence $(x_{n_k})$ such that $\lim_{k\to\infty} f(x_{n_k}) = \limsup_{n\to\infty} f(x_n)> f(x)$. Since $G(f)$ is closed, $(x,\limsup_{n\to\infty} f(x_n))\in G(f)$, in contradiction to $G$ being the graph of a function.
$\endgroup$