# Solving solution given initial condition condition

Suppose we know that: $$u_t=ku_{xx},~~~~~~~~0<x<l,~~~t>0$$

and $$u(x,t)=\sum_{i=0}^\infty[C_n~cos(n\pi x/l) ~e^{-w_nkt}]$$ where $w_n=\frac{n\pi}{l} ~~~ for~~n=1,2,3,...$

What if the initial condition is something contains sine function, for example: $$u(x,0)=sin(\pi x/l)$$ Is is possible solve this out to get the solution? Cheers

This is where you use the orthogonality of the eigenfunctions to determine the coefficients $C_n$. At $t=0$, for $0<x<\ell$ we have $$\sin\left(\frac{\pi x}\ell\right)=\sum_{m=0}^{\infty}C_m\cos\left(\frac{m\pi x}{\ell}\right)$$ \begin{align}\int_0^{\ell}\sin\left(\frac{\pi x}{\ell}\right)dx&=\left.-\frac{\ell}{\pi}\cos\left(\frac{\pi x}{\ell}\right)\right|_0^{\ell}=\frac{2\ell}{\pi}\\ &=\sum_{m=0}^{\infty}C_m\int_0^{\ell}\cos\left(\frac{m\pi x}{\ell}\right)dx=\sum_{m=0}^{\infty}C_m\ell\delta_{m0}=\ell C_0\end{align} \begin{align}\int_0^{\ell}\sin\left(\frac{\pi x}{\ell}\right)\cos\left(\frac{\pi x}{\ell}\right)dx&=\left.\frac{\ell}{2\pi}\sin^2\left(\frac{\pi x}{\ell}\right)\right|_0^{\ell}=0\\&=\sum_{m=0}^{\infty}C_m\int_0^{\ell}\cos\left(\frac{m\pi x}{\ell}\right)\cos\left(\frac{\pi x}{\ell}\right)dx\\ &=\sum_{m=0}^{\infty}C_m\frac{\ell}2\delta_{m1}=\frac{\ell}2C_1\end{align} \begin{align}\int_0^{\ell}\sin\left(\frac{\pi x}{\ell}\right)\cos\left(\frac{n\pi x}{\ell}\right)dx&=\frac12\int_0^{\ell}\left[\sin\left(\frac{(n+1)\pi x}{\ell}\right)-\sin\left(\frac{(n-1)\pi x}{\ell}\right)\right]dx\\ &=\frac{\ell}{2\pi}\left[-\frac{\cos\left(\frac{(n+1)\pi x}{\ell}\right)}{n+1}+\frac{\cos\left(\frac{(n-1)\pi x}{\ell}\right)}{n-1}\right]_0^{\ell}\\ &=\frac{\ell}{2\pi}\left[\frac{(-1)^n}{n+1}-\frac{(-1)^n}{n-1}+\frac1{n+1}-\frac1{n+1}\right]\\ &=-\frac{\ell\left[(-1)^n+1\right]}{\pi(n^2-1)}\\ &=\sum_{m=0}^{\infty}C_m\int_0^{\ell}\cos\left(\frac{m\pi x}{\ell}\right)\cos\left(\frac{n\pi x}{\ell}\right)dx\\ &=\sum_{m=0}^{\infty}C_m\frac{\ell}2\delta_{mn}=\frac{\ell}2C_n\end{align} So $C_0=\frac2{\pi}$, other even $C_{2n}=-\frac4{\pi(4n^2-1)}$, and all odd $C_{2n+1}=0$.