Using the Stone-Weierstrass Theorem to prove a set of functions is uniformly dense. I am trying to solve the following problem. Any hints or corrections would be appreciated.
Let $C[0,1]$ be the set of all real-valued continuous functions $[0,1]$. Given $N \in \mathbb{N}$, let 
$$ A_N = \left \lbrace  \sum_{k=0}^n c_k \cos kNx : c_k \in \mathbb{R}, n \in \mathbb{N} \right \rbrace.$$
We say $A_N$ is uniformly dense in $C[0,1]$ if for any $f \in C[0,1]$ there exists a sequence of functions $f_n \in A_N$ such that $f_n$ converges uniformly to $f$ on $[0,1]$. Determine for which values of $N$ $A_N$ is uniformly dense in $C[0,1]$.  Prove your claim.
I am using the notes from Prof. Orr Shalit.  If $A$ is a subspace of $C_{\mathbb{R}}(X)$ then it is said to be a subalgebra if for all $f, g \in A$, $fg \in A$. A subalgebra $A$ is said to separate points if for all $x, y \in X$, there exists some $f \in A$ such that $f(x) \neq f(y)$.  A subalgebra is said to be closed if it is a closed subset with respect to the metric.  We now the apply the Stone-Weierstrass Theorem.
[Stone-Weierstrass Theorem (real version)]: Let $A$ be a closed subalgebra of $C_{\mathbb{R}}(X)$ which contains the constant functions and separates the points.  Then $A= C_{\mathbb{R}}(X)$. 
The metric is the $\sup$ norm and $X=[0,1]$,
$A_N$ contains constants (with $n=0$).  If $f, g$ are in $A_N$ then $fg$ is in $A_N$ since the product of $$\cos kNx  \cdot \cos m N x = \dfrac{1}{2} [ \cos((k-m)Nx) + \cos((k+m)Nx) ]$$
will be in $A_N$.  For $N =1$, $k=1$ , $c_k \neq 0$, $f = \cos(x)$, we have $f(x) \neq f(y)$ for all $x \neq y \in [0,1]$. So $A$ separates points.
I'm not certain as to how to prove $A_N$ is a closed subset.
 A: You've shown each $A_N$ is a subalgebra of $C[0,1]$ that contains the constants. By S-W, $A_N$ is dense in $C[0,1]$ iff $A_N$ separates points. You showed $A_1$ separates points, but for some reason you didn't consider any other values of $N.$
Note that for $N=1,2,3,$ $\cos Nx$ is injective on $[0,1].$ This follows because $\cos x$ is injective on $[0,\pi],$ and for these values of $N,$ $x\to Nx$ maps $[0,1]$ injectively into $[0,\pi].$
Trouble starts with $N=4.$ Note that $\pi/4 \in (0,1).$ For $k=0,1,2,\dots,$ we have
$$\cos 4k(\pi/4+h) = \cos (k\pi + 4kh) = \cos (k\pi - 4kh) = \cos 4k(\pi/4-h)$$
for all $h\in (0,1-\pi/4).$  Thus $A_4$ does not separate points. The same is true for any $N>4$ by similar reasoning.
So the answer to the question is: $N=1,2,3.$
A: There is no need to prove that $A_N$ is a closed subset. Since you are trying to prove that $A_N$ is dense in $C[0,1]$, what you want to show is that $\overline{A_N}=C[0,1]$. Since clearly $A_N \ne C[0,1]$, then if what you are trying to prove is to be true, then $A_N$ will not be closed.
At the heart of the issue is that, since you have shown that $A_N$ is a subalgebra which contains the constant functions and separates points, then $\overline{A_N}$ is a closed subalgebra which contains the constant functions and separates points. The result then follows by Stone-Weierstrass.
