Solution to a Sturm–Liouville problem Suppose we want to find a solution to the following Sturm-Liouville problem:
\begin{align}
&u_t=u_{xx},\quad 0\leq x\leq\pi,\ t>0\\\
&u(x,0)=x\\
&u(0,t)=u(\pi,t)=0
\end{align}
I thought about just using separation of variables to compute the series solution, that is, look for solutions of the form:
\begin{equation}
u(x,t)=X(x)T(t)
\end{equation}
But i've not been able to quite get the fourier coefficients right, and therefore I can't seem to find the solution. Summarizing, I want to know what is the actual solution to the heat equation.
 A: 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(nx)$ for $n=1,2,3,\cdots,$ with corresponding $\lambda_n=-n^2$ and $T_n(t)=e^{-n^2 t}$. The general solution is
$$
                  u(x,t)=\sum_{n=1}^{\infty}C_ne^{-n^2 t}\sin(nx)
$$
where the constants $C_n$ are determined by
$$
                 x= u(x,0)=\sum_{n=1}^{\infty}C_n\sin(n x).
$$
Therefore,
$$
             \int_0^{\pi}x\sin(n x)dx = C_n\int_0^{\pi}\sin^2(n x)dx \\
         C_n = \frac{\int_0^{\pi}x\sin(n x)dx}{\int_0^{\pi}\sin^2(n x)dx}
$$
The full solution is
$$
         u(x,t)=\sum_{n=1}^{\infty}\frac{\int_0^{\pi}x\sin(n x)dx}{\int_0^{\pi}\sin^2(n x)dx}e^{-n^2 t}\sin(n x).
$$
The denominator is easily evaluated:
$$
     \int_0^{\pi}\sin^2(nx)dx
       = \frac{1}{2}\int_0^{2\pi}\sin^2(nx)dx \\
       = \frac{1}{4}\int_0^{2\pi}\sin^2(nx)+\cos^2(nx) dx = \frac{\pi}{2}
$$
