Is $u(x,t)=e^{-9t}\sin(3x)-e^{-t}\sin(x)$ has separable variable?

I had to solve the equation $$u_t(t,x)=u_{xx}(t,x)$$ with $$x\in (0,\pi), t>0$$ s.t. $$u(t,0)=u(t,\pi)=0$$ for $$t>0$$ and $$u(0,x)=\sin(3x)-\sin(x)$$ for $$x\in (0,\pi)$$. So I tried to find solutions with separable variable, i.e. of the form $$u(x,t)=h(x)f(t).$$

Then I have to solve the equation $$h''(x)=\alpha h(x)$$ with $$h(0)=h(\pi)=0$$. I found $$h_n(x)=\sin(nx)$$ for all $$n$$. Then, I solved $$f'(t)=-n^2f(t)$$ what $$f_n(t)=\alpha _ne^{-n^2t}$$. At the end, $$u_n(t,x)=\alpha _n f_n(t)h_n(x)$$ solve $$u_{t}=u_{xx}$$ with $$u_n(t,0)=u_n(t,\pi)=0$$. To use the last condition, I proved that $$u(t,x)=\sum_{k=0}^\infty u_n(t,x)$$ solve the system and is s.t. $$u(t,0)=u(t,\pi)=0$$. Then I found the $$\alpha _n$$ to get $$u(0,x)=\sin(3x)-\sin(x)$$, and I derived $$\alpha _1=-1$$, $$\alpha _3=1$$ and $$\alpha _n=0$$ for all $$n\neq 1,3$$. So finally, $$u(t,x)=e^{-9t}\sin(3x)-e^{-t}\sin(x).$$

Question : But is it with separable variable ? What are $$h$$ and $$f$$ s.t. $$u(t,x)=h(x)f(t)$$ ? More generaly, does $$f_1(t)g_1(x)+f_2(t)g_2(x)$$ can be written as $$f(t)g(x)$$ ?

• The point is that you need to find $N$ solutions $u_n$, $n=1,2,\cdots N$, each of which has the form $u_n=h_n(x) f_n(t)$. – rafa11111 Dec 7 '18 at 13:23
• I have the solution, it's not the problem. I was looking for separable variable solution, and the solution I found doesn't look with separable variable... but is it ? @rafa11111 – user623855 Dec 7 '18 at 13:33
• The final solution is not separable, but it's not the final solution that needs to be separable, only each of its "bits" (those bits are called eigenfunctions). The eigenfunctions are "special" because they alone solve the PDE with boundary conditions (but not the initial condition). Since the PDE is linear you can sum all eigenfunctions and find the coefficients to satisfy the initial conditions (as you did). When you separate the variables, you are not looking for the final solution already, but only for the eigenfunctions. – rafa11111 Dec 7 '18 at 13:40
• @rafa11111: I would be surprise that $u_n(t,x)$ solve the PDE... for example, $u_0(t,x)=0$ and thus $u_0(0,x)\neq \sin(3x)-\sin(x)$. Also $u_1(t,x)=-e^{-t}\sin(x)$ and thus $u(0,x)\neq \sin(3x)-\sin(x)$... – user623855 Dec 7 '18 at 13:43
• As I said, the eigenfunctions satisfy individually the PDE with boundary conditions, but they do not satisfy the initial conditions. See that each eigenfunction satisfy $u(t,0)=u(t,\pi)=0$. From the boundary conditions, you will find that this family of eigenfunctions satisfy the PDE with B.C.'s: $$u_n(t,x)=A_n e^{-n^2 t} \sin (nx)$$ From the principle of superposition (the PDE is linear), the final solution must be $$u(t,x)=\sum_{n=0}^\infty A_n e^{-n^2 t} \sin (nx),$$ and you did find $A_1 = -1$, $A_3 = 1$ and $A_n=0$ for the remaining terms. – rafa11111 Dec 7 '18 at 13:46

If a sum of separated heat equation solutions of the form $$T(t)X(x)$$ were again such a solution, then the technique of separation of variables would not produce general solutions of heat equation. So don't worry about trying to find a final solution that is separated. Your final solution is correct because it satisfies the heat equation and the boundary conditions, and the solution is unique.