TITLE: Does pointwise convergence against a continuous function imply uniform convergence?
QUESTION [5 upvotes]: Let $(f_n)_{n\in\mathbb{N}}$ be a sequence of functions with $f_n:\mathbb{R}\rightarrow[0,1]$ for all $n\in\mathbb{N}$ and $f:\mathbb{R}\rightarrow[0,1]$ continuous such that $\lim_{n\rightarrow\infty}f_n(x)=f(x)$ for all $x\in\mathbb{R}$.
Is it now possible to show that $f_n$ converges uniformly to $f$?

REPLY [18 votes]: Your example,
$$
f_n(x) = \begin{cases}
 e^{1-1/({1-((n+1) x-1)^2})} & 0<x<\frac{2}{n+1} \\
 0 & \text{otherwise,}
\end{cases}
$$
behaves something like so:

I think it's crystal clear that this is a continuous (even differentiable, I think) sequence of functions that converges pointwise to zero. The convergence clearly can't be uniform, since there's always a point where the value of $f_n$ is $1$.
The example I had in mind looks something like this:

Note that the graph consists of just straight line segments, so it's quite simple to write down a piecewise formula for this.  In fact:
$$
f_n(x) = \begin{cases}
 (n+1) x & 0<x<\frac{1}{n+1} \\
 2-(n+1) x & \frac{1}{n+1}<x<\frac{2}{n+1} \\
 0 & \text{otherwise}.
\end{cases}
$$
I emphasize, though, that (in my approach, at least) the picture comes first.