2. Consider a metal bar, which occupies $0 < x < 1$. The initial temperature in the bar is
$\theta(x, 0) = -2 \cos(\pi x)$, for $0 < x < 1$.
The temperature $\theta(x, t)$ is governed by the heat equation
$\frac{\partial \theta}{\partial t} = 3 \frac{\partial^2 \theta}{\partial x^2}$, for $0 < x < 1$ and $t > 0$.
The ends of the bar are insulated, so $\theta(x, t)$ satisfies the boundary conditions
$\frac{\partial \theta}{\partial x}(0, t) = 0$, $\frac{\partial \theta}{\partial x}(1, t) = 0$.
(i) Use the method of separation of variables to find the solution $\theta(x, t)$ satisfying the
equations (1), (2) and (3).
(ii) Assume now that the initial condition (1) is replaced by
$\theta(x, 0) = f(x) = \begin{cases} x, & \text{if } 0 < x \le 1/2 \\ 1 - x, & \text{if } 1/2 < x < 1 \end{cases}$
By calculating
$A_0 = 2 \int_0^1 f(x) dx$, $A_n = 2 \int_0^1 f(x) \cos(n \pi x) dx$,
find the solution $\theta(x, t)$ satisfying the equations (2), (3) and (4).