I'm in a problem involving the heat equation:
\begin{cases} u_{t}=\frac{1}{10}u_{xx}\\ u_{x}(0,t)=u_{x}(\pi,t)=0 \\ u(x,0)=3-4\cos(2x) \end{cases}
Using separation of variables, and using the first boundary condition, I found
$$u(x,t)=\sum_{n=1}^{\infty}a_{n}\exp\left[\frac{-(n+1)^{2}t}{10}\right]\sin\left[\left(n+\frac{1}{2}\right)x\right] $$
I just need to use the second boundary condition to have the value for each $a_{n}$, but I don't know how to do this, since
$$u(x,0)=3-4\cos(2x)=\sum_{n=1}^{\infty}a_{n}\sin\left[\left(n+\frac{1}{2}\right)x\right]$$
If the boundary condition was like $3-4\sin(2x)$ would be easier. How to deal with it?
From your boundary conditions it is clear that the solution has to be something like this $$u(x,t) = \sum_{n=0}^\infty b_n(t)\cos(n x)\tag1$$ because clearly $$u_x(x,t) = -\sum_{n=0}^\infty nb_n(t)\sin(nx)\\ u_x(0,t) = -\sum_{n=0}^\infty nb_n(t)\underbrace{\sin(n0)}_{\text{is zero even}\\ \text{for }x=\pi} = u_x(\pi,t) = 0\;\;\;\;\forall n\in\mathbb{N}$$ The solution $(1)$ it is clearly a good solution even judging on the initial condition which can be written as a sum of cosines $$u(x,0) = 3\cos(0)-4\cos(2x)$$
Now using the "Fourier method", we use the ansatz $(1)$ and substitute it in the equation to find $b_n(t)$, which gives us an ODE in the variable $b_n(t)$, mainly $$b'_n(t) = \frac{n^2}{10}b_n(t)\\ b_n(t) = c_n e^{\frac{n^2}{10}t}$$
To finde the solution to the PDE we just have to use the initial condition $$u(x,t) = \sum_{n=0}^\infty c_n e^{\frac{n^2}{10}t}\cos(nx)\\ u(x,0) = \sum_{n=0}^\infty c_n e^{\frac{n^2}{10}0}\cos(nx) = \sum_{n=0}^\infty c_n \cos(nx) = 3\cos(0)-4\cos(2x)$$ from which we get $$n=0\implies c_n=3 \\n=2 \implies c_n=-4$$
So the solution is $$u(x,t) = 3-4e^{\frac{4}{10}t}\cos(2x)=3-4e^{\frac{2}{5}t}\cos(2x)$$