2D Heat Equation with special initial condition I want to solve the 2 dimensional heat equation on a square $\Omega = \{ (x,y) : 0 < x < \pi, 0 < y < 2\pi \}$ with the Fourier Method
\begin{align*}
 \partial_t u - \Delta u & = 0 & \quad \mbox{ on } \Omega \times (0,T) \\
 u(x,y, t) & = 0 & \quad \mbox{for } (x,y) \in \partial \Omega, t \in [0,T], \\
 u(x,y, 0) & = x(\pi - x)(\pi - |y - \pi|) & \quad \mbox{for } (x,y) \in \Omega.
\end{align*}
With separation of variables I found
$$
 u(x,y,t) = \psi(x,y) \varphi(t)
$$
with
$$
 \psi(x,y) = \left( \sum_k A_k \sin(k x) \right) \cdot \left( \sum_l B_l \sin(l/2 y) \right)
$$
and
$$
 \varphi(t) = C e^{-2t}.
$$
But I have no idea how to incorporate the initial condition
$$
 u(x,y,0) = x(\pi - x)(\pi - |y - \pi|).
$$
So how to handle such an initial conditions?
 A: We start with a new solution:
$$u(x,y,t)=C e^{-2t}\left( \sum_k A_k \sin^2(k x) \right) \cdot \left( \sum_l B_l \sin^2( l y/2) \right)$$
They satisfy the boundary conditions for $(x,y) \in \partial \Omega$.
Now we need to determine $A_k$ and $B_l$ from the initial condition:
$$x(\pi-x)(\pi-|\pi-y|)=C \left( \sum_k A_k \sin^2(k x) \right) \cdot \left( \sum_l B_l \sin^2( l y/2) \right)$$
We can multiply both sides by $\sin^2(m x)\sin^2(n y/2)$ and integrate the result over $\int_0^\pi dx \int_0^{2\pi} dy$, obtaining (set $C=1$):
$$\frac{\pi}{12}\left(\pi^2+\frac{3}{m^2}\right)\left(\frac{1+(-1)^{n+1}}{n^2}+\frac{\pi^2}{2}\right)=\left(\frac{\pi}{4}+\delta_{k,m}\frac{\pi}{2}\right)A_k\left(\frac{\pi}{2}+\delta_{l,n}\pi\right)B_l$$
Therefore we can set:
$$\frac{1}{6}\left(\pi^2+\frac{3}{m^2}\right)=\left(\frac{1}{2}+\delta_{k,m}\right)A_k$$
$$\frac{1}{\pi}\left(\frac{1+(-1)^{n+1}}{n^2}+\frac{\pi^2}{2}\right)=\left(\frac{1}{2}+\delta_{l,n}\right)B_l$$
Define matrix $U_{k,m}=(1/2)+\delta_{k,m}$, then $A_k$ and $B_l$ are given by:
$$A_k=\sum_m \left(U^{-1}\right)_{k,m}\frac{1}{6}\left(\pi^2+\frac{3}{m^2}\right)$$
$$B_l=\sum_n \left(U^{-1}\right)_{l,n}\frac{1}{\pi}\left(\frac{1+(-1)^{n+1}}{n^2}+\frac{\pi^2}{2}\right)$$
A: The separation of variables solution for this equation has the general form
$$
     u(x,y,t)=\sum_{m=1}^{\infty}\sum_{n=1}^{\infty}C_{n,m}e^{-t(n^{2}+m^{2}/4)}\sin(nx)\sin(my/2).
$$
It's easy to verify that each term in the sum is a solution of the heat equation, and each term vanishes on $\partial\Omega$ for $t \ge 0$. The only question is how to choose $C_{n,m}$, which is done using orthogonality relations. You want to choose $C_{n,m}$ such that
$$
       u(x,y,0)=\sum_{n,m}C_{n,m}\sin(nx)\sin(my/2).
$$
So,
$$
     \int_{0}^{2\pi}\int_{0}^{\pi}u(x,y,0)\sin(n'x)\sin(m'y/2)\,dx\,dy \\ =
     C_{n',m'}\int_{0}^{\pi}\sin^{2}(n'x)\,dx\int_{0}^{2\pi}\sin^{2}(m'y)\,dy
    = C_{n',m'}\frac{\pi^{2}}{2}.
$$
That gives
$$
    C_{n',m'} = \frac{2}{\pi^{2}}\int_{0}^{2\pi}\int_{0}^{\pi}x(\pi-x)(\pi-|y-\pi|)\sin(n'x)\sin(m'y/2)\,dx\,dy \\
   = \frac{2}{\pi^{2}}\int_{0}^{2\pi}(\pi-|y-\pi|)\sin(m'y/2)\,dy
                      \int_{0}^{\pi}x(\pi-x)\sin(n'x)\,dx.
$$
A: Here we just give the explicit formulas for coefficients $C_{n',m'}$ in T.A.E's solution:
$$C_{n,m}  = \frac{2}{\pi^{2}}A_{m}B_{n}$$
$$A_{2m+1}=\int_{0}^{2\pi}(\pi-|y-\pi|)\sin((2m+1)y/2)\,dy=\frac{8(-1)^m}{(1+2m)^2}. A_{2m}=0$$
$$B_{2n+1}=\int_{0}^{\pi}x(\pi-x)\sin(nx)\,dx=\frac{4}{(1+2n)^3},B_{2n}=0$$
The reason we have $B_{2n}=0$ is because the initial condition $x(\pi-x)$ is symmetric if we swap $x$ with $\pi-x$, so is function $\sin((2n+1)x)$, while as the function $\sin(2nx)$ is not.
Similarly initial condition $\pi-|y-\pi|$ is symmetric if we swap $y$ with $2\pi-y$, so is function $\sin((2m+1)y/2)$, while as the function $\sin(2my/2)$ is not.
-mike
