I got this diffusion problem:
\begin{equation} u_t-\alpha u_{xx}=0 \ \ \ \ \ \ \ 0<x<L, t>0\\ u_x(0,t)=u_x(L,t)=0\\ u(x)=\begin{cases} 0\ \ \ \ \ 0<x<L/2\\ 1\ \ \ \ \ L/2<x<L \end{cases} \end{equation}
Here we can form the ansatz $u(x,t)=u(t)\cos\frac{n\pi}{L}x$, which we insert in the original PDE and obtain $u(t)=Ce^{(-\alpha\frac{n\pi}{L})^2}$.
The general solution is clearly
\begin{equation} u_n(x,t)=Ce^{(-\alpha\frac{n\pi}{L})^2t}\cos\frac{n\pi}{L}x \end{equation}
Forming a Fourier series of the solution, we have:
\begin{equation} u(x,t)=\alpha_0+\sum_{n=1}^\infty \alpha_n e^{(-\alpha\frac{n\pi}{L})^2t}\cos\frac{n\pi}{L}x \end{equation}
where we use the IC:
\begin{equation} u(x,0)=\sum_{n=1}^\infty \alpha_n e^{0}\cos\frac{n\pi}{L}x \end{equation}
Therefore, we can readily calculate the coefficient on that interval $L/2-L$ and get:
\begin{equation} \alpha_n=\frac{2}{L/2}\int_{L/2}^L 1\cdot \cos\frac{n\pi}{L}xdx=0 \end{equation}
and
\begin{equation} \alpha_0=\frac{2}{L/2}\int_{L/2}^L 1dx=1 \end{equation}
Something is clearly wrong here, but all looks correct. What did I miss?
Any help appreciated.