A sequence of continuously differentiable functions with non-differentiable limit Working in the metric space $C[a,b]$, the set of continuous functions $f:[a,b]\rightarrow[a,b]$, with the supremum metric, I need to demonstrate that $C^1[a,b]$, the subset of continuously differentiable functions, is not closed.

So I believe that I need to construct a sequence of continuously differentiable functions which converge in the supremum metric to a continuous, non-differentiable limit.

It looks to me like converging with respect to the supremum metric is the same as uniform convergence. A function I know that is continuous but not differentiable is $|x|$ at $x=0$ so I can adapt this to put the non-differentiable bit in $[a,b]$ by translation.

So I want something that converges uniformly to $|x-\frac{a+b}{2}|=\sqrt{(x-\frac{a+b}{2})^2}$. My first thought is: $$f_n(x):=\sqrt{(x-\frac{a+b}{2})^2+\frac{1}{n}}$$

So now I need to work out what the value of the following is, and hope it tends to $0$ as $n \rightarrow \infty$:

$$ \sup_{x\in[a,b]}\sqrt{(x-\frac{a+b}{2})^2+\frac{1}{n}} $$

By differentiating, I see there's a minimum at $x=\frac{a+b}{2}$ and no other turning points, so the maximum is achieved at either $x=a$ or $x=b$ and it turns out that $f_n(a)=f_n(b)=\sqrt{(\frac{a+b}{2})^2+\frac{1}{n}}$. But this doesn't tend to $0$ as $n \rightarrow\infty$.

So do I need a different example, or is my reasoning mistaken?
Answering my own question. Per this answer to another question, we want not that $\sup_{x\in[a,b]}|f_n(x)|\rightarrow0$ as $n\rightarrow\infty$, but that:

$$\sup_{x\in[a,b]}|f_n(x)\color{red}{-f(x)}|\rightarrow0 \text{ as } n\rightarrow\infty$$

With the example $f_n(x):=\sqrt{(x-\frac{a+b}{2})^2+\frac{1}{n}}$, we have that

$$ \sup_{x\in[a,b]}|f_n(x)-f(x)|=|\sqrt{(\frac{a+b}{2})^2+\frac{1}{n}}-|\frac{a+b}{2}|| $$

and this tends to $0$ as $n\rightarrow\infty$. Hence the convergence is uniform.

This method also works for the example $\sqrt {x+\frac 1 {n^{2}}} \to \sqrt x$ given by another user.
Let $a=-1,b=1.$ By Weierstraß, there is a sequence of polynomials which converges uniformly to $|x|$ on $[-1,1]$, but $|x|$ is not differentiable at $x=0.$