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

For the 1-dimensional case, the solution takes the form $u(x,t)$ since we are only concerned with one spatial direction and time. Thus the heat equation takes the form:
$u_{t}=ku_{xx}+h(x,t)$
where k is our diffusivity constant and h(x,t) is the representation of internal heat sources. For our example, we impose the Robin boundary conditions, the initial condition, and the following bounds on our variables:
$(x,t)\in [0,L]\times [0,\infty )$ $u(x,0)=f(x)$ $\alpha _{1}u(0,t)-\beta _{1}u_{x}(0,t)=b_{1}(t)$ $\alpha _{2}u(L,t)+\beta _{2}u_{x}(L,t)=b_{2}(t)$ $\alpha _{j},\beta _{j}\geq 0,\alpha _{j}^{2}+\beta _{j}^{2}\neq 0$
Notice that the boundary conditions are non-homogeneous and time-dependent. The next few steps will illustrate one way to achieve a solution.

## Solution
### Step 1: Partition Solution

In order to get a solution, we can partition the function into a "transient" or "variable" solution and a "steady-state" solution:
$u(x,t)=\underbrace {s(x,t)} _{\text{steady-state}}+\underbrace {v(x,t)} _{\text{variable}}$
Substitute this relation into our original heat equation, boundary conditions and initial condition:
$s_{t}+v_{t}=ks_{xx}+kv_{xx}+h(x,t)$ $\alpha _{1}s(0,t)+\alpha _{1}v(0,t)-\beta _{1}s_{x}(0,t)-\beta _{1}v_{x}(0,t)=b_{1}(t)$ $\alpha _{2}s(L,t)+\alpha _{2}v(L,t)+\beta _{2}s_{x}(L,t)+\beta _{2}v_{x}(L,t)=b_{2}(t)$ $s(x,0)+v(x,0)=f(x)$
We will also impose conditions on our partitioned solutions. Part of the beauty of partitioning the solution is being able to divide the boundary conditions among both parts. The following conditions will be imposed:
* We will choose the steady-state solution to be linear in x, which means that $s_{xx}=0~.$
* We will let the steady-state solution handle the non-homogeneous boundary conditions.
* We will let the variable portion satisfy the non-homogeneous equation and homogeneous boundary conditions.
Thus, we have constructed two separate initial boundary value problems (IBVPs):
${\begin{cases}s_{xx}=0\\\alpha _{1}s(0,t)-\beta _{1}s_{x}(0,t)=b_{1}(t)\\\alpha _{2}s(L,t)+\beta _{2}s_{x}(L,t)=b_{2}(t)\end{cases}}$
${\begin{cases}v_{t}=kv_{xx}-s_{t}+h(x,t)\\\alpha _{1}v(0,t)-\beta _{1}v_{x}(0,t)=0\\\alpha _{2}v(L,t)+\beta _{2}v_{x}(L,t)=0\\v(x,0)=f(x)-s(x,0)\end{cases}}$
Note that the sum $s(x,t)+v(x,t)$ satisfies all conditions of the original IBVP.

### Step 2: Solve Steady-state Partition
#### Assumption 1

We are assuming that S is linear in x, so our equation take the form:
$s(x,t)=m(t)x+b(t)$
We will see why this is only an assumption because doesn't cover all the different boundary condition types. Applying the boundary conditions, we get:
${\begin{aligned}\alpha _{1}&b(t)-\beta _{1}&m(t)=&b_{1}(t)\\\alpha _{2}&b(t)+(\alpha _{2}L+\beta _{2})&m(t)=&b_{2}(t)\end{aligned}}$
Solving for $b(t)$ and $m(t)$ :
$b(t)={\frac {\begin{vmatrix}b_{1}(t)&-\beta _{1}\\b_{2}(t)&\alpha _{2}L+\beta _{2}\end{vmatrix}}{\begin{vmatrix}\alpha _{1}&-\beta _{1}\\\alpha _{2}&\alpha _{2}L+\beta _{2}\end{vmatrix}}}={\frac {(\alpha _{2}L+\beta _{2})b_{1}(t)+\beta _{1}b_{2}(t)}{\alpha _{1}\alpha _{2}L+\alpha _{1}\beta _{2}+\alpha _{2}\beta _{1}}}$ $m(t)={\frac {\begin{vmatrix}\alpha _{1}&b_{1}(t)\\\alpha _{2}&b_{2}(t)\end{vmatrix}}{\begin{vmatrix}\alpha _{1}&-\beta _{1}\\\alpha _{2}&\alpha _{2}L+\beta _{2}\end{vmatrix}}}={\frac {\alpha _{1}b_{2}(t)-\alpha _{2}b_{1}(t)}{\alpha _{1}\alpha _{2}L+\alpha _{1}\beta _{2}+\alpha _{2}\beta _{1}}}$ $s(x,t)={\frac {\alpha _{1}b_{2}(t)-\alpha _{2}b_{1}(t)}{\alpha _{1}\alpha _{2}L+\alpha _{1}\beta _{2}+\alpha _{2}\beta _{1}}}x+{\frac {(\alpha _{2}L+\beta _{2})b_{1}(t)+\beta _{1}b_{2}(t)}{\alpha _{1}\alpha _{2}L+\alpha _{1}\beta _{2}+\alpha _{2}\beta _{1}}}$
That means that the coefficients are only defined as long as $\alpha _{1}\alpha _{2}L+\alpha _{1}\beta _{2}+\alpha _{2}\beta _{1}\neq 0~.$ This means that the linear assumption of s(x,t) only holds if the boundary conditions are not both Neumann type (i.e. $\alpha _{1},\alpha _{2}\neq 0$ ). Knowing the coefficients $\alpha _{1},\alpha _{2},\beta _{1},\beta _{2}$ from the original boundary conditions will yield the coefficients for s(x,t).

#### Assumption 2

For the case where both boundary conditions are Neumann type, a different assumption must be made. The linear assumption didn't yield any solution, so let's assume s has a quadratic relationship with x:
$s(x,t)=a(t)x^{2}+b(t)x+c(t)~.$
For convenience, we choose $c(t)=0~.$ In this Neumann-Neumann condition, the only boundary conditions we have are:
${\begin{cases}s_{x}(0,t)=b_{1}(t),\beta _{1}=1{\text{ for simplicity}}\\s_{x}(L,t)=b_{2}(t),\beta _{2}=1{\text{ for simplicity}}\end{cases}}$
Solving the assumption for the boundary conditions:
${\begin{aligned}s_{x}(0,t)&=b_{1}(t)=b(t)\\s_{x}(L,t)&=b_{2}(t)=2a(t)L+b(t)\end{aligned}}\quad \Rightarrow \quad \left\{{\begin{aligned}b(t)&=b_{1}(t)\\a(t)&={\frac {b_{2}(t)-b_{1}(t)}{2L}}\end{aligned}}\right.$
Thus we arrive at the solution to the "steady-state" solution:
$s(x,t)={\frac {b_{2}(t)-b_{1}(t)}{2L}}x^{2}+b_{1}(t)x~.$

### Step 3: Solve Variable Partition

The equation for the variable portion is:
$v_{t}=kv_{xx}-s_{t}+h(x,t)+ks_{xx}$

#### For Assumption 1

In order to simplify the equation, we can define a new function:
$q(x,t):=h(x,t)-s_{t}(x,t)$

#### For Assumption 2

In order to simplify the equation, we can define a new function:
$q(x,t):=h(x,t)-s_{t}(x,t)+ks_{xx}(x,t)$

#### Step 3.1: Solve the Associated Homogeneous IBVP

The associated homogeneous IBVP is as follows:
${\begin{cases}v_{t}=kv_{xx}\\\alpha _{1}v(0,t)-\beta _{1}v_{x}(0,t)=0\\\alpha _{2}v(L,t)+\beta _{2}v_{x}(L,t)=0\end{cases}}$

##### Separate Variables

$v(x,t)=X(x)T(t)\Rightarrow XT'=kX''T\Rightarrow {\frac {T'}{kT}}={\frac {X''}{X}}=\mu$

##### Translate Boundary Conditions

${\begin{aligned}0&=\alpha _{1}X(0)T(t)-\beta _{1}X'(0)T(t)&\\&=\left[\alpha _{1}X(0)-\beta _{1}X'(0)\right]T(t)&\forall t\in [0,\infty )\\\end{aligned}}\quad \Rightarrow \quad \alpha _{1}X(0)-\beta _{1}X'(0)=0$
${\begin{aligned}0&=\alpha _{2}X(L)T(t)+\beta _{2}X'(L)T(t)&\\&=\left[\alpha _{2}X(L)+\beta _{2}X'(L)\right]T(t)&\forall t\in [0,\infty )\\\end{aligned}}\quad \Rightarrow \quad \alpha _{2}X(L)+\beta _{2}X'(L)=0$

##### Solve the SLP

$\left.{\begin{aligned}X''-\mu X=0\\\alpha _{1}X(0)-\beta _{1}X'(0)=0\\\alpha _{2}X(L)+\beta _{2}X'(L)=0\end{aligned}}\right\$

#### Step 3.2: Solve the Non-homogeneous BVP

The BVP is as follows:
${\begin{cases}v_{t}=kv_{xx}+q(x,t)\\\alpha _{1}v(0,t)-\beta _{1}v_{x}(0,t)=0\\\alpha _{2}v(L,t)+\beta _{2}v_{x}(L,t)=0\\v(x,0)=f(x)-s(x,0)\end{cases}}$
In order to solve the problem, let:
$v(x,t):=\sum _{n=0}^{\infty }T_{n}(t)X_{n}(x)$
where the time-dependent Fourier coefficients will be determined later. Also, let:
$q(x,t):=\sum _{n=0}^{\infty }Q_{n}(t)X_{n}(x)$
where the Fourier coefficients are given by the inner product:
$Q_{n}(t)={\frac {\int \limits _{0}^{L}q(x,t)X_{n}(x)dx}{\int \limits _{0}^{L}X_{n}(x)\cdot X_{n}(x)dx}}~.$
In order to solve for the coefficients $T_{n}(t)$, we have to substitute the relations above into the original PDE. The term-by-term differentiation of v is legitimate since the partial derivatives of v are continuous. v satisfies the same spatial boundary conditions as the eigenfunction:
${\frac {\partial }{\partial t}}\left[\sum _{n=0}^{\infty }T_{n}(t)X_{n}(x)\right]=k{\frac {\partial ^{2}}{\partial x^{2}}}\left[\sum _{n=0}^{\infty }T_{n}(t)X_{n}(x)\right]+\sum _{n=0}^{\infty }Q_{n}(t)X_{n}(x)$ $\sum _{n=0}^{\infty }T_{n}'(t)X_{n}(x)=k\sum _{n=0}^{\infty }T_{n}(t)X_{n}''(x)+\sum _{n=0}^{\infty }Q_{n}(t)X_{n}(x)$
Since the eigenfunction $X_{n}(x)$ satisfies the ODE $X''+\lambda _{n}^{2}X=0\Rightarrow X_{n}''(x)=-\lambda _{n}^{2}X_{n}(x)$ ,
$\sum _{n=0}^{\infty }T_{n}'(t)X_{n}(x)=\sum _{n=0}^{\infty }-k\lambda _{n}^{2}T_{n}(t)X_{n}(x)+\sum _{n=0}^{\infty }Q_{n}(t)X_{n}(x)$ $\sum _{n=0}^{\infty }\left[T_{n}'(t)+k\lambda _{n}^{2}T_{n}(t)\right]X_{n}(x)=\sum _{n=0}^{\infty }Q_{n}(t)X_{n}(x)$
Since $X_{n}(x)$ forms a basis and is therefore linearly independent:
$T_{n}'(t)+k\lambda _{n}^{2}T_{n}(t)=Q_{n}(t)$
which is a first order non-homogeneous linear equation. The integrating factor $\mu (t)=e^{\int k\lambda _{n}^{2}dt}=e^{k\lambda _{n}^{2}t}$ . Solving the equation yields:
$T_{n}(t)=e^{-k\lambda _{n}^{2}t}\int \limits _{0}^{t}e^{k\lambda _{n}^{2}s}Q_{n}(s)ds+C_{n}e^{-k\lambda _{n}^{2}t}$
The constant $C_{n}$ allows us to satisfy the initial condition:
$v(x,0)=f(x)-s(x,0)=\sum _{n=0}^{\infty }T_{n}(0)X_{n}(x)=\sum _{n=0}^{\infty }C_{n}X_{n}(x)~.$ $C_{n}={\frac {\int \limits _{0}^{L}\left[f(x)-s(x,0)\right]X_{n}(x)dx}{\int \limits _{0}^{L}X_{n}(x)\cdot X_{n}(x)dx}}~.$
We can now substitute all the expressions to get the variable portion $v(x,t)$:
* Compute and substitute $C_{n}$ and $Q_{n}(t)$ into $T_{n}(t)~.$
* Compute and substitute $T_{n}(t)$ and $X_{n}(x)$ into $v(x,t):=\sum _{n=0}^{\infty }T_{n}(t)X_{n}(x)~.$

### Step 4: Combine Solutions

The complete solution for $u(x,t)$ can be found by adding the "steady-state" solution and the "variable" solutions. The result can easily be checked by graphing in a symbolic solver like Mathematica or Maple.