Try $f(x)=x(1-x)\,\sin\frac{1}{x(1-x)}$ on $(0,1)$ and $f(0)=f(1)=0.$ It's obviously continuous, and the difference quotient at the endpoints takes all values between -1 and 1.
No! The problem with your proof is that $U$ depends on $n$, and could thus get smaller with rising $n$.
Consider this counter example:
Let $k_n$ be a function so that $k_n$ is $n-1$ times continously differentiable on $\mathbb R$ and $n$ times c.d. only on $(-1/n,1/n)$. Also we want $k_n^{(m)}<1/2^{n-m}$ for $0\leq m\leq n$ and $k^{(m)}=0$ outside of $[-1/n,1/n]$ for $m<n$. For example we can take some function like $\chi_{[-1/n,1/n]}(x)(1/n^2-x^2)^n$, scale in such a way that the bound to the derivatives hold.
Define $f_m(x) = \sum_{n=0}^m k_n$. It is clear to see that $f_m$ converges uniformly to some $f$ (as $\sum_{n=m+1}^\infty |k_n| < \sum_{n=m+1}^\infty 1/2^{m+1} \frac{1}{1+1/2} = 1/2^m$).
Also we get that if $m>n$ then $f_m$ is $n$-times differentiable on $(-1/n,1/n)$. Also it is equal to $f_{m-1}$ outside of $[-1/(m+1),1/(m+1)]$. Thus it is only $n-1$ times differentiable in $\pm 1/n$.
Then it is easy to see that
$ f_m^{(n)} $ converges uniformly against some $g_n$ within $(-1/n,1/n)$ (for the same reason as to why $f_m$ converges).
But this implies that $f$ is $n$ times differentiable on $(-1/n,1/n)$ so that $f^{(n)}=g_n$. On the other hand $f$ is equal to $f_n$ outside of $[-1/{n+1},1/{n+1}]$, so it is only $n-1$ times differentiable in $\pm 1/n$.
But thus we get that $f$ is smooth in $x=0$, but only $n-1$ times differentiable in $\pm1/n$ and thus not smooth an any neighborhood of $0$.
Best Answer
I am only three years late, so I am probably just wasting time.... but it is an interesting question, so.... I will only prove that $f$ can be extended to $(-\infty,0)$. The case $(1,\infty)$ is similar. Construct a $C_{c}^{\infty}(\mathbb{R})$ function $\psi$ such that $\psi=1$ in $[0,\frac{1}{2}]$ and $\psi(x)=0$ for $x\geq\frac{3}{4}$ and define the function $g(x):=f(x)\psi(x)$. By extending $g$ to be zero for $x\geq1$, we have that $g$ is $C^{\infty}$ in $[0,\infty)$ and $g=f$ in $[0,\frac{1}{2}]$. Let $\phi:[1,\infty )\rightarrow\mathbb{R}$ be a continuous function be such that $$ \int_{1}^{\infty}\phi(t)\,dt=1,\quad\int_{1}^{\infty}t^{n}\phi(t)\,dt=0,\quad \lim_{t\rightarrow\infty}t^{n}\phi(t)=0 $$ for all $n\in\mathbb{N}$. For $x<0$ define $$ h(x)=\int_{1}^{\infty}\phi(t)g(x(1-t))\,dt. $$ Note that since $t\geq1$, $x-tx>0$ and so $h$ is well-defined. Since $g$ is bounded, by the Lebesgue dominated convergence theorem, $$ \lim_{x\rightarrow0^{\_}}h(x)=\int_{1}^{\infty}\phi(t)\lim_{x\rightarrow 0^{\_}}g(x(1-t))\,dt=g(0)\int_{1}^{\infty}\phi(t)\,dt=1g(0)=f(0). $$ Since all the derivatives of $g$ are bounded, by the Lebesgue dominated convergence theorem, we can differentiate under the integral sign to get that for $x<0$, $$ h^{(n)}(x)=\int_{1}^{\infty}\phi(t)(1-t)^{n}g^{(n)}(x(1-t))\,dt. $$ Again by the Lebesgue dominated convergence theorem, \begin{align*} \lim_{x\rightarrow0^{\_}}h^{(n)}(x) & =\int_{1}^{\infty}\phi(t)(1-t)^{n}% \lim_{x\rightarrow0^{\_}}g^{(n)}(x(1-t))\,dt=g^{(n)}(0)\int_{1}^{\infty }(1-t)^{n}\phi(t)\,dt\\ & =1g^{(n)}(0)=f^{(n)}(0), \end{align*} where by the binomial theorem $$ \int_{1}^{\infty}(1-t)^{n}\phi(t)\,dt=\int_{1}^{\infty}\phi(t)\,dt+\sum _{k}c_{k}\int_{1}^{\infty}t^{k}\phi(t)\,dt=1+0. $$ This shows that $h$ is a $C^{\infty}$ extension of $f$ to $(-\infty,0)$.