Problem: Solve the following initial-boundary value problem for the heat equation:
\[
u_t = u_{xx}, \quad 0 < x < \pi, \quad t > 0,
\]
with boundary conditions:
\[
u(0, t) = 0, \quad u(\pi, t) = 0, \quad t > 0,
\]
and initial condition:
\[
u(x, 0) = \sin(3x), \quad 0 \leq x \leq \pi.
\]
Solution: The given PDE is the heat equation:
\[
u_t = u_{xx}, \quad 0 < x < \pi, \quad t > 0,
\]
with boundary conditions:
\[
u(0, t) = 0, \quad u(\pi, t) = 0, \quad t > 0,
\]
and initial condition:
\[
u(x, 0) = \sin(3x), \quad 0 \leq x \leq \pi.
\]
Step 1: Assume a separable solution. We assume a solution of the form:
\[
u(x, t) = X(x) T(t).
\]
Substituting into the heat equation, we get:
\[
X(x) T'(t) = X''(x) T(t).
\]
Dividing both sides by \( X(x) T(t) \), we obtain:
\[
\frac{T'(t)}{T(t)} = \frac{X''(x)}{X(x)} = -\lambda,
\]
where \( \lambda > 0 \) is a separation constant. If $\lambda \leq 0$, then one can show that $X(x) = 0$, which will imply the trivial solution. Thus, we will consider $\lambda > 0$.
Step 2: Solve the spatial ODE. The spatial part of the equation is:
\[
X''(x) + \lambda X(x) = 0.
\]
The boundary conditions \( u(0, t) = 0 \) and \( u(\pi, t) = 0 \) imply:
\[
X(0) = 0, \quad X(\pi) = 0.
\]
The general solution to this ODE is:
\[
X(x) = A \cos(\sqrt{\lambda} x) + B \sin(\sqrt{\lambda} x).
\]
Applying the boundary conditions, we find:
\[
X(0) = A = 0, \quad X(\pi) = B \sin(\sqrt{\lambda} \pi) = 0.
\]
For non-trivial solutions, \( \sin(\sqrt{\lambda} \pi) = 0 \), which implies:
\[
\sqrt{\lambda} = n, \quad n = 1, 2, 3, \dots.
\]
Thus, the eigenvalues are \( \lambda_n = n^2 \), and the corresponding eigenfunctions are:
\[
X_n(x) = \sin(nx).
\]
Step 3: Solve the time dependent ODE. The temporal part of the equation is:
\[
T'(t) + \lambda T(t) = 0.
\]
For \( \lambda_n = n^2 \), the solution is:
\[
T_n(t) = C_n e^{-n^2 t}.
\]
Step 4: Construct the general solution. The general solution to the heat equation is:
\[
u(x, t) = \sum_{n=1}^{\infty} C_n \sin(nx) e^{-n^2 t}.
\]
Step 5: Apply the initial condition.
The initial condition \( u(x, 0) = \sin(3x) \) implies:
\[
\sin(3x) = \sum_{n=1}^{\infty} C_n \sin(nx).
\]
Thus, we have
\[
C_n =
\begin{cases}
1, & n = 3, \\
0, & n \neq 3.
\end{cases}
\]
Therefore, the solution to the initial-boundary value problem is:
\[
u(x, t) = \sin(3x) e^{-9t}.
\]