# Solving Heat PDEs

#### Markov

##### Member
1) Solve

\begin{aligned} {u_t} &= K{u_{xx}},{\text{ }}0 < x < L,{\text{ }}t > 0, \\ u(0,t) &= 0,{\text{ }}u(L,t) = 0,{\text{ for }}t > 0, \\ u(x,0) &= 6\sin \frac{{3\pi x}}{L}. \end{aligned}

2) Solve

\begin{aligned} {u_t} &= 4{u_{xx}},{\text{ }}0 < x < 1,{\text{ }}t > 0, \\ u(0,t) &= 0,{\text{ }}u(1,t) = 0,{\text{ for }}t > 0, \\ u(x,0) &= x^2(1-x),\text{ for }x\in[0,1]. \end{aligned}

Is there a standard procedure to solve this?

#### dwsmith

##### Well-known member
You can use the method of eigenfunction expansion.

Your solutions will be of the form $\sum a_ne^{-\lambda_nkt}\varphi_n(x)$

#### Markov

##### Member
What's that method? Could you show me how to make the first one?

#### dwsmith

##### Well-known member
What's that method? Could you show me how to make the first one?
$u(x,t)=\varphi(x)T(t)$

$u_{xx}=\varphi'' T$

$u_{t}=\varphi T'$

Substitution: $\varphi T'=K\varphi'' T$

Separation of variables $\dfrac{\varphi''}{\varphi}=\dfrac{T'}{TK}=-\lambda$

Then we have $\dfrac{\varphi''}{\varphi}=-\lambda \Rightarrow \varphi''+\lambda\varphi=0 \Rightarrow \varphi(x)=C_1\cos\left(x\sqrt{\lambda}\right)+C_2\sin\left(x\sqrt{\lambda}\right)$

Now we have to solve
$\varphi_1(0) = 1$ and $\varphi_1'(0) = 0$
$\varphi_2(0) = 0$ and $\varphi_2'(0) = 1$

Doing so yields $\varphi(x)=A\cos\left(x\sqrt{\lambda}\right)+ \dfrac{ B\sin\left(x\sqrt{ \lambda }\right) }{ \sqrt{\lambda} }$

Use conditions

$u(0,t) = A = 0$

$\varphi(x)= \dfrac{B\sin\left(x\sqrt{ \lambda }\right)}{\sqrt{ \lambda }}$

$u(L,t) = \dfrac{ B\sin\left(L\sqrt{\lambda}\right) }{\sqrt{ \lambda }} = 0\Rightarrow \sin\left(L\sqrt{\lambda}\right) =0$

$\lambda_n=\left(\dfrac{\pi n}{L}\right)^2$

$\varphi_n(x)=\dfrac{L}{\pi n}\sin\left(\dfrac{x\pi n}{L}\right)$

Now you can solve for $\dfrac{T'}{KT}= - \lambda$.

Then use Fourier Analysis to find the coefficient $a_n$.

Then you will have $u(x,t) = \sum a_n \varphi(x)T(t)$

Evaluate $\sin(x+yi)$ against your eigenvalue to determine if you have complex solutions or not.

Last edited:

#### Markov

##### Member
Thanks a lot!

Then use Fourier Analysis to find the coefficient $a_n$.
What's the formula for this?

#### dwsmith

##### Well-known member
Thanks a lot!

What's the formula for this?
$$\int_0^Lf(x)\sin\left(\frac{x\pi n}{L}\right)dx = \sum_{n=1}^{\infty}a_n\int_0^L\sin\left(\frac{n\pi x}{L}\right)\sin\left(\frac{m\pi x}{L}\right)dx$$
Every time on the RHS is zero except for when n = m because you have an orthogonal system on an interval.

$u(x,0) = f(x)$

Last edited:

#### Markov

##### Member
Now you can solve for $\dfrac{T'}{KT}= - \lambda$.
Okay, on this part, do I need to get the solution in terms of trigonometric functions as the other equation you solved?

#### dwsmith

##### Well-known member
Okay, on this part, do I need to get the solution in terms of trigonometric functions as the other equation you solved?
That is just an simply ODE. How would you solve it in general?