Solving the heat equation using Fourier series