# Is a continuous function necessarily the pointwise limit of a sequence of uniformly continuous functions?

The pointwise limit of a sequence of uniformly continuous functions needn't be continuous. I've been wondering about the converse:

Is a continuous function $$f$$ necessarily the pointwise limit of some sequence of uniformly continuous functions $$(f_n)_{n\in\mathbb{N}}$$?

I'm having trouble establishing or disproving this.

If the domain of $$f$$ is $$\Bbb R$$, then the answer is yes. The proof is quite easy: let $$f_n: \Bbb R \to \Bbb R$$ defined by $$f_n(x)= \begin{cases} f(-n) & x<-n \\ f(x) & -n \le x \le n \\ f(n) & x>n \end{cases}$$ these are uniformly continuous and they pointwise converge to $$f$$.
• Why are the $f_n$ uniformly continuous (in $-n\leq x\leq n$)? We only know that $f$ is continuous. Jun 5, 2021 at 15:01
• That's because on a compact set every continuous function is uniformly continuous. If you extend as a constant function outside the boundary of $[-n,n]$ it remains uniformly continuous. Jun 5, 2021 at 15:07