Solution to a Sturm–Liouville problem

Solution 1:

When you set $u(x,t)=X(x)T(t)$, then you can use separation of variables to solve the resulting equations: $$ \frac{T'(t)}{T(t)} = \lambda = \frac{X''(x)}{X(x)} \\ X(0)=X(\pi)=0. $$ This gives $X_n(x)=\sin(n\pi x)$ for $n=1,2,3,\cdots,$ with corresponding $\lambda_n=-n^2\pi^2$ and $T_n(t)=e^{-n^2\pi^2 t}$. The general solution is $$ u(x,t)=\sum_{n=1}^{\infty}C_ne^{-n^2\pi^2 t}\sin(n\pi x) $$ where the constants $C_n$ are determined by $$ x= u(x,0)=\sum_{n=1}^{\infty}C_n\sin(n\pi x). $$ Therefore, $$ \int_0^{\pi}x\sin(n\pi x)dx = C_n\int_0^{\pi}\sin^2(n\pi x)dx \\ C_n = \frac{\int_0^{\pi}x\sin(n\pi x)dx}{\int_0^{\pi}\sin^2(n\pi x)dx} $$ The full solution is $$ u(x,t)=\sum_{n=1}^{\infty}\frac{\int_0^{\pi}x\sin(n\pi x)dx}{\int_0^{\pi}\sin^2(n\pi x)dx}e^{-n^2\pi^2 t}\sin(n\pi x). $$