I've just wrote my own script to solve the homogeneous heat equation in the unit square $[0,1] \times [0,1]$ with homogeneous Dirichlet boundary conditions and an initial data $u_0(x,y)$. Namely
$$ u_t = u_{xx} + u_{yy} \\u_{| \partial \Omega} = 0 \\u(x,y,0)=u_0(x,y)$$
Now, in order to verify my implementation, I need to find an analytical solution and compare my numerical solution.
But I found only solutions in terms of infinite series. Does anyone know an initial conditon $u_0(x)$ for which the analytical solution is easy, in order to put it on my script and do an error analysis?
Best Answer
You are correct that the general solution can only be expressed as infinite series. However, you can take a single term of this series and that will also be a solution. For example, the function $$u(x,y) = e^{-\pi^2(m^2+n^2)t}\sin m\pi x\sin n\pi y$$ is a solution for $u_0(x,y) = \sin m\pi x\sin n\pi y$ where $m$ and $n$ are integers