Confusion for the solution of the heat equation in a one dimensional bar The heat equation for a one dimensional bar is given by
$$\frac{\partial}{\partial t} u = k \frac{\partial^2}{\partial x^2}u$$
where $k$ is the diffusion coefficient, and the boundary conditions are given by 
$$u(0,t) = u(L, t) = 0\ \forall t \geq 0$$
where $L$ is the length of the bar. Moreover at time $t = 0$, the temperature is given by a known function $f(x)$, i.e.,
$$u(x, 0) = f(x)\ \forall x \in [0, L].$$
Assuming that $u(x, t) = X(x) \cdot T(t)$, we can reduce the heat equation to the following system
$$\begin{cases}X''(x) + \lambda^2 X(x) &= &0,\\ T'(t) + \lambda^2 k T(t) &= &0. \end{cases}$$
Both equations can be solved, and we have
$$X(x) = A_{+} e^{i \lambda x} + A_{-}e^{-i\lambda x}$$
for the first one, and 
$$T(t) = B e^{-\lambda^2 k t}$$
for the second one. Thus we get
$$u(x, t) = (C_1 e^{i \lambda x} + C_2 e^{-i\lambda x})e^{-\lambda^2 k t}.$$
Assuming $C_1 = -C_2$ and since $\sin(x) = \frac{e^{ix}-e^{-ix}}{2i}$ and $\sin(\lambda L) = 0 \iff \lambda = \frac{m \pi}{L}$, $m \in \mathbb{Z}$, we finally get 
$$u(x, t) = C_1 2 i \sin\left( \frac{m \pi x}{L} \right) e^{-\frac{m^2 \pi^2 kt}{L^2}}.$$
Letting $b_m := C_1 2 i$, the general solution is given by
$$u(x, t) = \sum_{m = -\infty}^{\infty} b_m \sin\left( \frac{m \pi x}{L} \right) e^{-\frac{m^2 \pi^2 kt}{L^2}}.$$
Because of the boundary condition $u(x, 0) = f(x)$, we also have
$$u(x, 0) = \sum_{m = -\infty}^{\infty} b_m \sin\left( \frac{m \pi x}{L} \right) = f(x)$$
which is a Fourier serie in sine of period $2L$ and where $b_m$ is a constant.

Sorry for the long introduction, this is taken from a class I followed, and I have a few questions about it.


*

*Since $b_m$ is constant, do we not have 
$$u(x, 0) = \sum_{m = -\infty}^{\infty} b_m \sin\left( \frac{m \pi x}{L} \right) = \sum_{m = 1}^{\infty} b_m \sin\left( \frac{m \pi x}{L} \right) - \sum_{m = 1}^{\infty} b_m \sin\left( \frac{m \pi x}{L} \right) = 0?$$

*I thought that the bar was heated at a certain $x$ until time $t=0$, and then one would just observe how the heat was diffusing. To simplify the question, assume $L = \pi$, $k = 1$ and $C_1 2 i = 1$, so that the solution is 
$$u(x, t) = \sin\left( mx \right) e^{-m^2 t}.$$
Plugging $m = 2$ above leads to 
$$u(x, 0) = \sin\left(2x\right),$$
meaning that some parts of the bar have a negative temperature. Am I understanding this correctly, or do I make a mistake? Because this is super weird to me that after being heated, some parts of the bar can have subzero temperature.

*What happens if we assume that $u(0,t) = u(L,t) \neq 0$?

*What happens if we assume that $u(0, t) \neq u(L, t)$?

*Can someone provide intuition on what $X(x)$ and $T(t)$ represent in the variable separation?

 A: Proposal 1. : Since $b_m$ is constant, do we not have 
$$u(x, 0) = \sum_{m = -\infty}^{\infty} b_m \sin\left( \frac{m \pi x}{L} \right) = \sum_{m = 1}^{\infty} b_m \sin\left( \frac{m \pi x}{L} \right) - \sum_{m = 1}^{\infty} b_m \sin\left( \frac{m \pi x}{L} \right) = 0?$$
NO. Don't confuse ($b_m$ in $m>0$) and ($b_m$ in $m<0$). 
$$u(x, 0) = \sum_{m = -\infty}^{\infty} b_m \sin\left( \frac{m \pi x}{L} \right) = \sum_{m = 1}^{\infty} b_m \sin\left( \frac{m \pi x}{L} \right) + \sum_{m = 1}^{\infty} b_{-m} \sin\left( \frac{m \pi x}{L} \right)$$
With $B_m=b_m+b_{-m}$ , better use this form of Fourier series : 
$$u(x, 0) = \sum_{m = 1}^{\infty} B_m \sin\left( \frac{m \pi x}{L} \right)$$
Proposal 2. : I thought that the bar was heated at a certain $x$ until time $t=0$, and then one would just observe how the heat was diffusing. To simplify the question, assume $L = \pi$, $k = 1$ and $C_1 2 i = 1$, so that the solution is 
$$u(x, t) = \sin\left( mx \right) e^{-m^2 t}.$$
NO. One cannot separate one term of the series. The Fourrier series a whole :
$$u(x, t) =\sum_{m = 1}^{\infty} B_m \sin\left( mx \right) e^{-m^2 t}.$$
Some $B_m$ can be positive and others negative, depending on the function $f(x)$ on a given range $0<x<L$. 
Of course, at various $t$ some terms are negative but the sum will be such as $u$ remains positive on this limited range insofar $f(x)$ is positive on this range. 
Outside the range where the Fourrier series is considered and where the coefficients are computed, the Fourier series is not valide and the computed $u(x,t)$ has no signifiance (so, doesn't mind if it becomes negative).
