# If $X$ is compact and $C(X)$ is the space of all continuous real valued functions. Prove $C(X)$ is a complete metric space.

Let $X$ be a compact metric space and define $C(X)$ to be the space of all continuous real valued functions on $X$ with a metric defined by $$d(f,g)=\sup_{x \in X} |f(x) -g(x)|.$$ Show that $C(X)$ is a complete metric space.

How can I start this problem?

• OK so what is your question? Commented Apr 26, 2016 at 13:43
• How can a subsquence of functions $(f_{n_k})_k$ converge to a value in $f(X) \subseteq \mathbb{R}$? And what is even $f$ in your last paragraph -- you take an arbitrary (Cauchy?) sequence $(f_n)_n$, what is $f$ with regard to that? Commented Apr 26, 2016 at 13:56
• Your last line all sequence $f_n$ have a convergent subsequence $f_{n_k}$ is not correct. I believe you want to show for all Cauchy sequence $f_n$, there exists a limit in $C(X)$. The way to show this is to invoke Arzelà–Ascoli theorem, you check the assumption of the theorem and it shows there exists a subsequence $f_{n_k} \rightarrow f$ in $C(X)$, but since $f_n$ is Cauchy, you can show the entire sequence also converges to $f$.
– Xiao
Commented Apr 26, 2016 at 14:39

You have to show that every Cauchy sequence $(f_n)$ of $C(X)$ converges. Let $(f_n)$ be a Cauchy sequence of $C(X)$, for every $c>0$, there exists $N>0$ such that $n,m>N$ implies that $\sup_{x\in X}\mid f_n(x)-f_m(x)\mid<c,$ this implies that $(f_n(x))$ is a Cauchy sequence. Since $R$ is complete, $f_n(x)$ converges towards $f(x)$.

It remains to show that the function defined on $X$ by $x\rightarrow f(x)$ is continuous. Firstly, remark that there exists $N>0$, such that for every $x\in X$, $n,m>N$, $\sup_{x\in X}\mid f_n(x)-f_m(x)\mid <c/4$. This implies that $$\lim_{m\to\infty}\mid f_n(x)-f_m(x)\mid =\mid f_n(x)-f(x)\mid \leq c/4$$ for $n>N$.

Let $n>N$, since $f_n$ is continuous, there exists $e>0$ such that $d(x,y)<e$ implies that $\mid f_n(x)-f_n(y)\mid< c/4$. This implies that for $d(x,y)<e$ we have: $$\mid f(x)-f(y)\mid \leq \mid f(x)-f_n(x)\mid +\mid f_n(x)-f_n(y)\mid+\mid f_n(y)-f(y)\mid < c/4+c/4+c/4=3c/4<c.$$ Henceforth, $f$ is continuous

• Where is the compactness of X used in this proof? Commented Nov 6, 2016 at 9:50
• why did you assume that $X\subset \mathbb{R}$ ? Commented Oct 26, 2019 at 5:19
• @user166305, the compactness to guarantee the finiteness in definition of the norm. Remind that a continuous function on compact set is bounded. Commented Oct 31, 2020 at 11:46

For $C(X)$ denoting the set of continuous, real-valued functions on $X$, we want to show

$X$ compact $\iff$ $C(X)$ complete.

Note that we can follow the same procedure for showing that $C([a,b])$ complete $\iff X$ compact.

Define $\lVert f \rVert_{max} = \max_{x \in X} \{f(x)\}$ as the uniform metric for $f \in C(X)$. Then we have that this is a norm which induces a metric $\lVert g - h \rVert$ for every $g,h \in C(X)$. The idea of the proof is then to take an arbitrary Cauchy sequence, find a convergent subsequence, and then show that whatever function this subsequence converges to (and hence the Cauchy sequence converges to) is continuous, i.e., in $C(X)$.

Since $X$ is compact, by the Extreme Value Theorem, every continuous function on $X$ attains its maximum. Thus we can use the uniform metric to measure an arbitrary Cauchy sequence. Let $\{f_n\}$ be an arbitrary Cauchy sequence in $C(X)$. Then $\exists N \in \mathbb{N}$ such that $$\lVert f_{n}(x) - f_{m}(x) \rVert_{max} \leq \epsilon \quad \forall n,m \geq N$$ Now, we claim that there exists a convergent subsequence $\{f_{n_k}\}$ with $$\lVert f_{n_k}(x) - f_{n_{k+1}}(x) \rVert_{max} \leq 1/2^k \quad \forall n,m \geq N$$ and see this by setting $\epsilon = 1/2^k$ and adjusting our original $N$ such that for each $k$, we let $n_k = \max\{N_1,\ldots,N_k\}$.

So we have $\{f_{n_k}\} \rightarrow f \implies \{f_n\} \rightarrow f$ and have to show $f$ is continuous. We use the uniform metric: $$\lVert f(x) - f(y) \rVert_{max} \leq \lVert f(x) - f_{n_k}(x) \rVert_{max} + \lVert f_{n_k}(x) - f_{n_k}(y) \rVert_{max} + \lVert f_{n_k}(y) - f(y) \rVert_{max}$$ We can bound the first and third terms by adjusting $N$ and can bound the middle term since $f_{n_k}$ is continuous (for all $x \in X$ by construction of our metric).