Solution of homogeneous heat equation for easy initial datum

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?

• Shouldn't your initial data depend on two variables, namely $u(x,y,0) = u_0(x,y)$?
– Hugo
Commented Nov 21, 2019 at 23:14
• Yes sure, edited thanks! Commented Nov 21, 2019 at 23:14

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
• Thanks for your answer! But $u_0$ doesn't seems to satisfy the requirement to be $0$ at the boundary Commented Nov 21, 2019 at 23:27
• Many thanks! graphically my solutions is okay! I'd like to ask you one more question: once I obtain my numerical solution $\hat{u}$, I have a $Nx \times N_y$ matrix where in the entry $(i,j)$ I have the solution at point $(x_i,y_j)$ of the grid. To compare the error w.r.t the analytical solution at the final time $\bar{t}$, i.e. $u(x,y,\bar{t})$ , is it okay to do $|| \hat{u} - u||$ in some norm ? Commented Nov 22, 2019 at 10:30