I have to solve the following boundary value problem: $u_t=u_{xx}$, $u(t,-2)=u(t,2)=0$ and $u(0,x)=f(x)$. I tried to solve the problem using the method of separation of variables. So assume $u(t,x)=v(t)w(x)$. Then the PDE reduces to the two following ODE's: $$v'(t)=\lambda v(t)\text{ and } w''(x)=\lambda w(x)$$ for some constant $\lambda$ to be determined by the boundary values. So for the first one we see that $v(t)=e^{\lambda t}$ is a solution and for the second we have three cases. I only want to look at the case that $\lambda=-\omega^2<0$. Then we have solutions $\cos(\omega x)$ and $\sin(\omega x)$. Now lets look at the boundary conditions. So we have that $u(t,x)=e^{\lambda t}(a\sin(\omega x)+b\cos(\omega x))$. Then $0=e^{-\lambda t}u(t,-2)=a\sin(-2\omega )+b\cos(2\omega)=e^{-\lambda t}u(t,2)=a\sin(2\omega )+b\cos(2\omega)$. So if $\omega_n=n\pi/2$ then we must have that $b=0$. If $\omega_n=n\pi/2+\pi/4$ then we must have that $a=0$. Then I would say that the general solution becomes $$u(t,x)=\sum_{n=1}^{\infty}a_ne^{-t(n\pi/2)^2}\sin(n\pi x/2)+b_ne^{-t(n\pi/2+\pi/4)^2}\cos(x(n\pi/2+\pi/4))$$.
My problem now is that I have no clue how to find the coefficients, since this doesnt look like a normal fouerier series, because the arguments of the sine and cosine are different. Thanks in advance for looking at this.
An easier approach would be to start with the change of variable $y=x+2$ so that you can deal with the problem on $[0,4]$. Then $\sin \left ( \frac{n \pi y}{4} \right )$ will be the appropriate eigenfunctions for homogeneous Dirichlet boundary conditions. The nice thing about this approach is that $\sin(\omega \cdot 0)=0$ and $\cos(\omega \cdot 0)=1$ regardless of what $\omega$ is. This makes dealing with the boundary conditions easier.
With your approach, you essentially have to represent $\sin \left ( \frac{n \pi (x+2)}{4} \right )$ as a sum of a sine and a cosine. This can always be done, but it doesn't seem necessary to me.