TITLE: Why doesn't the Stone-Weierstrass theorem imply that every function has a power series expansion?
QUESTION [22 upvotes]: I know that not every function has a power series expansion. 
Yet what I don't understand is that for every $C^{\infty}$ functions there is a sequence of polynomial $(P_n)$ such that $P_n$ converges uniformly to $f$. That's to say : 
$$\forall x \in [a,b], f(x) = \lim_{n \to \infty}  \sum_{k = 0}^{\infty} a_{k,n}x^k$$
But then because it converges uniformly why can't I say that : 
$$\forall x \in [a,b], f(x) =   \sum_{k = 0}^{\infty} \lim_{n \to \infty} a_{k,n}x^k$$
And so $f$ has a power series expansion with coefficients: $\lim_{n \to \infty} a_{k,n}x^k$.

REPLY [3 votes]: Yes, but because I have the uniform convergence the switch of limits should work?

As far as I understood correctly the theorem only says that the entire expression converges uniformly. It does not say anything about the convergence of each element inside the sum.
However a sum of functions can be uniformly convergent even if the functions inside the sum are not converging at all!
Counterexample:
$g_{n,k}(x)=\begin{cases}
nx\text{ if }k=1\\
(-nx)\text{ if }k=2\\
0\text{ else}\\
\end{cases}$
$f_n(x)=\sum\limits_{k=0}^{\infty}g_{n,k}(x)$
Then:
$f_n(x)=(nx-nx)=0$ which means that the value of $f_n(x)$ is independent of $n$ which means that all elements in the function series are the same function and therefore the function series converges uniformly to $f(x)=0$.
Please also note that $\lim\limits_{x\to\pm\infty}f(x)=0$ in this example.
The single elements in the sum ($g_{n,1}(x)=nx$ and $g_{n,2}(x)=-nx$) however are diverging both for $n\to\infty$ and for $x\to\pm\infty$.