I have a question about Stone - Weierstrass theorem.

In the space $C[0,2\pi]$ of continuous functions on $[0,2\pi]$ with the sup norm. Consider the spaces $M$ of all trigonometric polynomials.

It's easy to check that $M$ is a subalgebra of $C[0,2\pi]$ and separates points of $[0,2\pi]$ and vanishs at no point of $[0,2\pi]$. So by Stone - Weierstrass theorem, $M$ is dense in $C[0,2\pi]$.

But then I found that the function $f(x)=x$ is not in $\overline{M}$ because $f(0) \neq f(2\pi)$. So my question is: Is there something wrong in my proof? or I misunderstand something?

• The trigonometric polynomials do not separate $0$ and $2\pi$. – DisintegratingByParts Mar 3 '15 at 16:56