Heat partial differential equation initial condition I have an IBVP  
\begin{equation}
\begin{split}
U_t &= 4U_{xx} \\  
U(x,0) &= 3 + 2 \cos(x) - \cos(3x) \\
U_{x}(0,t) &= U_{x}(π,t) \\
&= 0
\end{split}
\end{equation}
For the general solution I got
$$C_{0} + \sum_{n} C_{n} \cos(nx)$$ 
I have $C_{0} = 3$ but I dont know how to get an answer for $C_{n}$.
 A: $$U_t=4U_{xx}$$
Particular solution on the form $U=f(x)g(t)$
$$f(x)g'(t)=4f''(x)g(t) \quad\to\quad \frac{g'(t)}{g(t)}=4\frac{f''(x)}{f(x)}=\text{constant}=C$$
because a function of $x$ cannot be equal to a function of $t$ with any $x$ and any $t$ , except if these functions are the constant function.
Since the condition $U(x,0)$ contains only cosines, we keep only cosines in the solution :
$$f_\nu(x)=\cos(\nu x) \quad\to\quad C=-4\nu^2 \quad\to\quad g_\nu(t)=e^{Ct}=e^{-4\nu^2 t}$$
where $\nu$ is any constant.
Before taking account of the conditions, the solution of the ODE is :
$$U(x,t)=\sum_{\text{any }\nu} A_\nu f_\nu(x)g_\nu(t)= \sum_{\text{any }\nu} A_\nu \cos(\nu x)e^{-4\nu^2 t} \qquad(1)$$
where the coefficients $A_\nu$ are any constants.
Condition : $\quad U(x,0)=3+2\cos(x)-\cos(3x)$
$$U(x,0)=\sum_{\text{any }\nu} A_\nu\cos(\nu x)e^{0}=\sum_{\text{any }\nu}A_\nu\cos(\nu x)=3+2\cos(x)-\cos(3x)$$
Among the infinity of values of $\nu$ only three are convenient : 
$\begin{cases}
\nu=0 \quad\to\quad A_0=3 \\
\nu=1 \quad\to\quad A_1=2 \\
\nu=3 \quad\to\quad A_3=-1 \\
\end{cases}$
All other $\nu$ doesn't exist, so all other $A_\nu=0$.
Bringing the three remaining terms into equation $(1)$ leads to :
$U(x,t)=  3 \cos(0)e^{0 t}+2 \cos(1 x)e^{-4(1^2) t}+(-1) \cos(3 x)e^{-4(3^2) t}$ 
$$U(x,t)=  3+2 \cos(x)e^{-4 t}- \cos(3 x)e^{-36 t}$$ 
You can verify that the condition $U_x(0,t)=U_x(\pi,t)=0$ is satisfied : the terms $\sin(n\pi)=0$ in the derivatives. This is the consequence of "keeping only cosines in the solution" at the beginning of the calculus.
