# Heat equation/Solution to the 2-D Heat Equation
## Definition

The solution to the 2-dimensional heat equation (in rectangular coordinates) deals with two spatial and a time dimension, $u(x,y,t)$. The heat equation, the variable limits, the Robin boundary conditions, and the initial condition are defined as:
${\begin{aligned}u_{t}=k\left[u_{xx}+u_{yy}\right]+h(x,y,t)\\(x,y,t)\in [0,L]\times [0,M]\times [0,\infty )\\\alpha _{1}u(0,y,t)-\beta _{1}u_{x}(0,y,t)=b_{1}(y,t)\\\alpha _{2}u(L,y,t)+\beta _{2}u_{x}(L,y,t)=b_{2}(y,t)\\\alpha _{3}u(x,0,t)-\beta _{3}u_{y}(x,0,t)=b_{3}(x,t)\\\alpha _{4}u(x,M,t)+\beta _{4}u_{y}(x,M,t)=b_{4}(x,t)\\u(x,y,0)=f(x,y)\end{aligned}}$

## Solution

The solution is just an advanced version of the solution in 1 dimension. If you have questions about the steps shown here, review the 1-D solution.

### Step 1: Partition Solution

Just as in the 1-D solution, we partition the solution into a "steady-state" and a "variable" portion:
$u(x,y,t)=\underbrace {s(x,y,t)} _{\text{steady-state}}+\underbrace {v(x,y,t)} _{\text{variable}}$
We substitute this equation into the initial boundary value problem (IBVP):
${\begin{cases}s_{t}+v_{t}=k\left[s_{xx}+v_{xx}+s_{yy}+v_{yy}\right]+h(x,y,t)\\\alpha _{1}s(0,y,t)+\alpha _{1}v(0,y,t)-\beta _{1}s_{x}(0,y,t)-\beta _{1}v_{x}(0,y,t)=b_{1}(y,t)\\\alpha _{2}s(0,y,t)+\alpha _{2}v(L,y,t)+\beta _{2}s_{x}(L,y,t)+\beta _{2}v_{x}(L,y,t)=b_{2}(y,t)\\\alpha _{3}s(x,0,t)+\alpha _{3}v(x,0,t)-\beta _{3}s_{y}(x,0,t)-\beta _{3}v_{y}(x,0,t)=b_{3}(x,t)\\\alpha _{4}s(x,M,t)+\alpha _{4}v(x,M,t)+\beta _{4}s_{y}(x,M,t)+\beta _{4}v_{y}(x,M,t)=b_{4}(x,t)\\s(x,y,0)+v(x,y,0)=f(x,y)\end{cases}}$
We want to set some conditions on s and v:
* Let $s$ satisfy the Laplace equation: $s_{xx}+s_{yy}=0~.$
* Let $s$ satisfy the non-homogeneous boundary conditions.
* Let v satisfy the non-homogeneous equation and homogeneous boundary conditions.
We end up with 2 separate IBVPs:
${\begin{cases}s_{xx}+s_{yy}=0\\\alpha _{1}s(0,y,t)-\beta _{1}s_{x}(0,y,t)=b_{1}(y,t)\\\alpha _{2}s(0,y,t)+\beta _{2}s_{x}(L,y,t)=b_{2}(y,t)\\\alpha _{3}s(x,0,t)-\beta _{3}s_{y}(x,0,t)=b_{3}(x,t)\\\alpha _{4}s(x,M,t)+\beta _{4}s_{y}(x,M,t)=b_{4}(x,t)\\\end{cases}}$
${\begin{cases}v_{t}=k\left[v_{xx}+v_{yy}\right]+h(x,y,t)-s_{t}(x,y,t)\\\alpha _{1}v(0,y,t)-\beta _{1}v_{x}(0,y,t)=0\\\alpha _{2}v(L,y,t)+\beta _{2}v_{x}(L,y,t)=0\\\alpha _{3}v(x,0,t)-\beta _{3}v_{y}(x,0,t)=0\\\alpha _{4}v(x,M,t)+\beta _{4}v_{y}(x,M,t)=0\\v(x,y,0)=f(x,y)-s(x,y,0)\end{cases}}$

### Step 2: Solve Steady-State Portion

Solving for the steady-state portion is exactly like solving the Laplace equation with 4 non-homogeneous boundary conditions. Using that technique, a solution can be found for all types of boundary conditions.

### Step 3: Solve Variable Portion
#### Step 3.1: Solve Associated Homogeneous BVP

The associated homogeneous BVP equation is:
$v_{t}=k\left[v_{xx}+v_{yy}\right]$
The boundary conditions for v are the ones in the IBVP above.

##### Separate Variables

$v(x,y,t)=X(x)Y(y)T(t)$
$\Rightarrow XYT'=k\lbrack X''YT+XY''T\rbrack$
$\Rightarrow {\frac {T'}{kT}}={\frac {X''}{X}}+{\frac {Y''}{Y}}=\mu$
By similar methods, you obtain the following ODEs:
${\begin{cases}T'-\mu kT=0\\X''-\rho X=0\\Y''-\delta Y=0\\\mu =\rho +\delta \quad {\text{ (coupling equation) }}\end{cases}}$

##### Translate Boundary Conditions

$\left.{\begin{aligned}\left[\alpha _{1}X(0)-\beta _{1}X'(0)\right]Y(y)T(t)&=0\\\left[\alpha _{2}X(L)+\beta _{2}X'(L)\right]Y(y)T(t)&=0\\\left[\alpha _{3}Y(0)-\beta _{3}Y'(0)\right]X(x)T(t)&=0\\\left[\alpha _{4}Y(M)+\beta _{4}Y'(M)\right]X(x)T(t)&=0\end{aligned}}\right\$

##### Solve SLPs

$\left.{\begin{aligned}X''-\rho X=0\\\alpha _{1}X(0)-\beta _{1}X'(0)=0\\\alpha _{2}X(L)+\beta _{2}X'(L)=0\end{aligned}}\right\$
$\left.{\begin{aligned}Y''-\delta Y=0\\\alpha _{3}Y(0)-\beta _{3}Y'(0)=0\\\alpha _{4}Y(M)+\beta _{4}Y'(M)=0\end{aligned}}\right\$
We have obtained eigenfunctions that we can use to solve the nonhomogeneous IBVP.

#### Step 3.2: Solve Non-homogeneous IBVP
##### Setup Problem

Just like in the 1-D case, we define v(x,y,t) and q(x,y,t) as infinite sums:
$v(x,y,t):=\sum _{m,n=0}^{\infty }T_{mn}(t)X_{n}(x)Y_{m}(y)$
$q(x,y,t):=\sum _{m,n=0}^{\infty }Q_{mn}(t)X_{n}(x)Y_{m}(y)~,~Q_{mn}(t)={\frac {\int \limits _{0}^{L}\int \limits _{0}^{M}q(x,y,t)X_{n}(x)Y_{m}(y)dydx}{\int \limits _{0}^{L}X_{n}^{2}(x)dx\int \limits _{0}^{M}Y_{m}^{2}(y)dy}}$

##### Determine Coefficients

We then substitute expansion into the PDE:
${\frac {\partial }{\partial t}}\left[\sum T_{mn}(t)X_{n}(x)Y_{m}(y)\right]=k\left\{{\frac {\partial }{\partial x^{2}}}\left[\sum T_{mn}(t)X_{n}(x)Y_{m}(y)\right]+{\frac {\partial }{\partial y^{2}}}\left[\sum T_{mn}(t)X_{n}(x)Y_{m}(y)\right]\right\}+\sum Q_{mn}(t)X_{n}(x)Y_{m}(y)$
$\Rightarrow \sum T_{mn}'(t)X_{n}(x)Y_{m}(y)=k\left\{\sum T_{mn}(t)X_{n}''(x)Y_{m}(y)+\sum T_{mn}(t)X_{n}(x)Y_{m}''(y)\right\}+\sum Q_{mn}(t)X_{n}(x)Y_{m}(y)$
$\Rightarrow \sum T_{mn}'(t)X_{n}(x)Y_{m}(y)=\sum k\left\{T_{mn}(t)[-\lambda _{n}^{2}X_{n}(x)]Y_{m}(y)+\sum T_{mn}(t)X_{n}(x)[-{\hat {\lambda }}_{m}^{2}Y_{m}(y)]\right\}+\sum Q_{mn}(t)X_{n}(x)Y_{m}(y)$
$\Rightarrow \sum \left[T_{mn}'(t)+k(\lambda _{n}^{2}+{\hat {\lambda }}_{m}^{2})\right]X_{n}(x)Y_{m}(y)=\sum Q_{mn}(t)X_{n}(x)Y_{m}(y)$
This implies that $X_{n}(x)\otimes Y_{m}(y)~$ forms an orthogonal basis. This means that we can write the following:
$\Rightarrow T_{mn}'(t)+k(\lambda _{n}^{2}+{\hat {\lambda }}_{m}^{2})=Q_{mn}(t)$
This is a first-order ODE which can be solved using the integration factor:
$\mu (t)=e^{\int k(\lambda _{n}^{2}+{\hat {\lambda }}_{m}^{2})dt}=e^{k(\lambda _{n}^{2}+{\hat {\lambda }}_{m}^{2})t}$
Solving for our coefficient we get:
$T_{mn}(t)=e^{-k(\lambda _{n}^{2}+{\hat {\lambda }}_{m}^{2})t}\int \limits _{0}^{t}e^{k(\lambda _{n}^{2}+{\hat {\lambda }}_{m}^{2})s}Q_{mn}(s)ds+C_{mn}e^{-k(\lambda _{n}^{2}+{\hat {\lambda }}_{m}^{2})t}$

##### Satisfy Initial Condition

We apply the initial condition to our equation above:
${\begin{aligned}v(x,y,0)&=f(x,y)-s(x,y,0)\\&=\sum T_{mn}(0)X_{n}(x)Y_{m}(y)\\&=\sum C_{mn}X_{n}(x)Y_{m}(y)\end{aligned}}$
The Fourier coefficients can be solved using the inner product definition:
$C_{mn}={\frac {\int \limits _{0}^{L}\int \limits _{0}^{M}\left[f(x,y)-s(x,y,0)\right]X_{n}(x)Y_{m}(y)dydx}{\int \limits _{0}^{L}X_{n}^{2}(x)dx\int \limits _{0}^{M}Y_{m}^{2}(y)dy}}$
We have all the necessary information about the variable portion of the function.

### Step 4: Combine Solutions

We now have solved for the "steady-state" and "variable" portions, so we just add them together to get the complete solution to the 2-D heat equation.