# Thread: Solution to Heat Equation

1. ## Solution to Heat Equation

Somebody asked me to try to explain better than the book the solution to the heat equation.

The equation is:
$\alpha ^2 u_{xx} = u_t$ which is satisfied for all $0 and $t>0$.

This is called "heat equation" because that is what the equation is about. Let $u(x,t)$ represent a point at $x$ and time $t$ then the heat (temperature) at that point in time is given by $u(x,t)$. The equation above says that if we are given a bar with length $L$ and a certain physical property (density, specific heat, ... ) which is the constant $\alpha^2$ (the reason why it is squared is because it is less messy when we take square roots later on). Then it is modeled by that equation.

Now just like ODE's which need to have an initial value problem otherwise they have infinitely many solutions we have the same situation with PDE's we need to have an initial value called the boundary value problem.

So let $u(x,0)=f(x)$ this means that at $t=0$, i.e. initial state, the temperature distribution at every single point $x$ is given by $f(x)$.

Now, the simpliest case of the heat equation is a bar with isulated bar, mathematically it means the temperature at the ends is always zero. Thus, $u(0,t) = u(L,t)$ for all $t$.

Thus, the heat equation together with the boundary value problem is written as:
$\left\{ \begin{array}{c}\alpha^2 u_{xx} = u_t \mbox{ for }00 \\ u(x,0)=f(x) \mbox{ for }0\leq x\leq L \\ u(0,t)=u(L,t)=0 \mbox{ for }t\geq 0 \end{array} \right\}$

Does it make sense so far? That is just the meaning of the physics behind this problem.

2. There is an important type of problem that is reoccuring when solving certain PDE's it is given below:

$y''+ky=0 \mbox{ with }y(0)=0 \mbox{ and }y(L)=0 \ \ (1)$

Now there are trivial solutions (uninteresting, i.e. $y=0$) and non-trivial solutions i.e. the "non-obvious".

Those value of $k$ are called the eigenvalues and those functions corresponding to that $k$ are called the eigenfunctions.

Remark 1: The book uses $\lambda$ instead but I will not because it is more difficult in LaTeX.

Remark 2: They are called eigenvalues because they are similar to eigenvalues of a matrix. Remember the eigenvalues of a matrix is when it has non-trivial solutions $A\bold{x}=k\bold{x}$, but that is something else. I am just saying the idea is the same.

It is extremely important for use to answer the following question.

"What are the eigenvalues and the eigenfunctions of the differencial equation $(1)$?"

There is a general theory written about this, called Strum-Liouville Theory in the most general case about eigenvalues and eigenfunctions. But that is not important for us, we can answer that question posted above with a little work.

Now there are three cases $k<0,k=0,k>0$.
We will consider each case respectively.

Case 1: Then the general solution to $(1)$ is $y=C_1\exp (x\sqrt{-k})+C_2 \exp (-x\sqrt{-k})$
We need to also satisfy the endpoints, thus,
$C_1 + C_2 =0$
$C_1 \exp (L\sqrt{-k}) + C_2 \exp (L\sqrt{-k})=0$
The above is a linear system for $C_1,C_2$ it turns out that the only solution is $C_1=C_2=0$ because the determinant is non-zero (that is Cramer's Rule).
Which means that $y=0$ is the only solution to $(1)$. Ah! But that is a trivial solution, hence there are no eigenfunctions for $k>0$.

Case 2: Then the general solution is $y=C_1+C_2 x$. We need to satisfy the conditions:
$C_1+C_2(0)=0$
$C_1+C_2(L)=0$
The first equation implies $C_1=0$ but then $C_2=0$ by the second equation. Again a trivial solution. Thus $k=0$ is not an eigenvalue of $(1)$.

Case 3: The solution is given by $y=C_1\sin (x\sqrt{k}) + C_2\cos (x\sqrt{k})$. This leads to the linear systems:
$C_1(0)+C_2(1) = 0$
$C_1\sin (L \sqrt{k})+C_2 \cos (L\sqrt{k})=0$
The first equation forces $C_2=0$ which by the second equation means:
$C_1\sin (L\sqrt{k}) = 0$
But does that mean $C_1=0$?
No! Because if $L\sqrt{k} = \pi n$ then $C_1$ can be anything.
So when $\sqrt{k} = \frac{\pi n}{L}\implies k = \frac{\pi^2 n^2}{L^2}$ there are non-trivial solutions! In fact, those solutions are $y=C_1\sin (x\sqrt{k}) = C_1\sin \left( \frac{\pi n x}{L} \right)$ for any $C_1$.

In conclusion, we have showed in detail that the eigenvalues to equation $(1)$ are:
$k = \frac{\pi^2 n^2}{L^2}$.
And the eigenfunctions are (up to a multiplicative constant):
$y=\sin \left( \frac{\pi n x}{L} \right)$.

Just note, there are infinitely many eigenvalues for that equation. But soon we will see why this observation is extremely extremely important to the elegant solution of the heat equation.

3. Now we will give the solution to the boundary value problem:
$
\left\{ \begin{array}{c}\alpha^2 u_{xx} = u_t \mbox{ for }0$

The method that is used here is Seperation of Variables. We assume that a solution to the above problem can be written as $u(x,t) = X(x)T(t)$, i.e. as a product of two functions with seperated variables. Why we do that? I do not have a good answer to that nor do I know what motivated Euler/Fourier/Bernoulli when they used similar approaches to solving differencial equations. I just think that the problem was too difficult, thus they just considered what will happen if they indeed have seperated variables, and it worked! In math it is okay to assume that a solution has a particlar form and use it, the problem is that most of the time it does not work. But here it works.

If we subsitute that into the PDE we have:
$\alpha^2 X''T = XT'$
Thus,
$\frac{X''}{X} = \frac{T'}{\alpha^2T}$

Now the LHS is a function of only $x$ and RHS is a function of only $t$ the only way they are equal is when they are constants.
Thus, (we use $-k$ because it looks neater later on).
$\frac{X''}{X} = -k$
$\frac{T'}{\alpha^2 T}=-k$

Thus, we have,
$\left\{ \begin{array}{c} X'' + kX=0 \\ T'+\alpha^2 k T=0 \end{array} \right\}$

The above is simply a system without any constraints, i.e. the boundary value problem.

Remember we need to also satisfy the boundary conditions.
First, $u(0,t)=X(0)T(t)=0$. That means $X(0)=0$ or $T(t)=0$ but if $T(t)=0$ then $u(x,t)=X(x)T(t)=0$ which is an obvious solution. Thus $X(0)=0$. Similarly $u(L,t)=X(L)T(t)=0$ by similar reasoning $X(L)=0$.

Thus, we have that,
$X''+kX=0 \mbox{ with }X(0)=0\mbox{ and }X(L)=0$

Now this a problem that we considered we already considered before. That above differencial equation can have trivial solutions, i.e. $X(x)=0$ in that case $u(x,t)=X(x)T(t)=0$ which is a trivial solution. And that is what we do not want. So we know that $k$ has to be. It has to be $k_n = \pi^2 n^2 / L^2$. With solutions $X_n(x) = \sin (\pi n x / L)$.

But then in the second equation:
$T'+(n^2\pi^2 \alpha^2t/L^2)T=0$
With,
$T(t) = \exp (-\pi^2 n^2 \alpha^2 t/L^2)$
Thus, the possible solutions are (ignoring multiplicative constants):
$u_n(x,t)=\exp (-\pi^2n^2 \alpha^2 t/L^2) \sin (\pi n x/L)$

Now here is the important observation, that is $u_i(x,t)$ is a solution and so is $u_j(x,t)$ then $C_1u_i(x,t)+C_2u_j(x,t)$. Meaning all linear combinations of these are solutions are themselves solutions. Since there are infinitely many such functions we have infinitely many such linear combinations for each $n$ thus we claim that,
$\sum_{n=1}^{\infty}a_n u_n(x,t) = \sum_{n=1}^{\infty} a_n e^{-\pi^2 n^2 \alpha^2 t/L^2} \sin \frac{\pi n x}{L}$

It remains to find the coefficients $a_n$ which completely solves the boundary value problem. We still never considered the contrainst $u(x,0)=f(x) \mbox{ for }0\leq x\leq L$.

$u(x,0)=\sum_{n=1}^{\infty} a_n \sin \frac{\pi n x}{L}=f(x)$

But that is the Fourier Sine Series for $f(x)$!
Amazing!

That means the coefficients are determined as,
$a_n = \frac{2}{L} \int_0^L f(x)\sin \frac{\pi nx}{L} dx$.

That is a solution. The $a_n$ are the coefficients that you need to chose. The rest is trivial.

4. ## Other versions

Now what if you have time-dependence, a first order term, say b(x,t)*u(x,t)_x, and a killing, say k(x,t)*u(x,t)?

How will this affect my solution for say standard u(x,0)=f(x)?

I'm an applied person and I don't do a lot of variable transformations so does anyone know where I can pick up on these matters? I think I remember that there was some simple trick to get rid of 1st order derivative. But perhaps that was on the course in Ordinary Differential Eqs?

For example, in multiple dimensions rotation is standard trick to get rid of mixed diffusion coefficients a(i,j) in front of 2nd order terms delta x(i)x(j).
For 2D I found
alpha= cos (theta), beta = sin (theta)
cot (2*theta) = (a(1,1)-a(2,2))/2*a(1,2)
and the transformation is
x = alpha *x' - beta * y'
y = beta * x' + alpha * y'

(I hope I got that right)

Also I know some geometric invariant for my problem is b(x,t)/a(x,t)^2. Anybody know about classifications of solutions in different types?
I could not find any of this in my books. I've read Arfken & Weber Mathematical Methods for Physicists (4ed) but I can't say I understand all of it...

5. Originally Posted by BasicIdeaIsSimple
Now what if you have time-dependence, a first order term, say b(x,t)*u(x,t)_x, and a killing, say k(x,t)*u(x,t)?

How will this affect my solution for say standard u(x,0)=f(x)?
I am not exatcly sure what you are asking?

Are you asking me what do you do if this is not a homogenous boundary value problem? As in $u(x,0)\not =0 \mbox{ or }u(x,L)\not = 0$. ?

Or are you asking me if there is another method to solve the heat equation?

I'm an applied person and I don't do a lot of variable transformations so does anyone know where I can pick up on these matters? I think I remember that there was some simple trick to get rid of 1st order derivative. But perhaps that was on the course in Ordinary Differential Eqs?

I've read Arfken & Weber Mathematical Methods for Physicists (4ed) but I can't say I understand all of it...
Of course not, because that is a book on Mathematical Physics. An all books on Mathematical Physics are complete manure. Just throw them into the garbage. They do not explain anything, they just love to introduce variable substitutions that are questionable and manipulate them without much sense and explanation.

6. ## Diffusion coefficient and Integrating factor

Sorry I think my previous input just added to confusion. So I have removed it.

7. ## Which book?

Originally Posted by ThePerfectHacker
Somebody asked me to try to explain better than the book the solution to the heat equation.
Which book is that?

8. Originally Posted by BasicIdeaIsSimple
Which book is that?
Elementary Differential Equations and Boundary Value Problems, 8th Edition. By Boyce

9. Originally Posted by BasicIdeaIsSimple
Actually what I'm looking for is a "bag of tricks". Rotation is one trick, the integrating factor is another one etc. Well, I guess I'm loooking for geometric invariants. But I have problems understanding the abstract literature. And I'm confident I'm not the only one!
I am not familar with your method.

By rotations do you mean using the variable substitution $r=\sqrt{x^2+y^2}$ and $\tan^{-1} \frac{y}{x}$? And see where that leads you?

10. ## I can feel the heat...

No, I didn't mean polar coordinates. I just meant diagonalization so that new diagonal terms a(i,i) consists of eigenvalues for the original matrix a(i,j). This I picked up from p.135 in an old book "Intro to pdes: from fourier series to boundary value problems" Addison-Wesley 1970, by Arne Broman. Please note I'm sincerely trying to get some pedagogical advice here. I'm not a professional mathematician! I want to use maths to model phenomena.

11. ## State and time-dependent coefficients?

Originally Posted by ThePerfectHacker
I am not exatcly sure what you are asking?

Are you asking me what do you do if this is not a homogenous boundary value problem? As in $u(x,0)\not =0 \mbox{ or }u(x,L)\not = 0$. ?

Or are you asking me if there is another method to solve the heat equation?
Sorry I haven't read your book ... But after this I will of course! You write u(x,L) which must be a typo? If I understand correctly you have explained how to find the solution using the separation of variables method for boundary conditions u(0,t)=u(L,t)=0, all t, "isolated bar", and "initial heat" given by u(x,0)=f(x) when the coefficient alpha is constant.

I want to know what we can say about the solutions to more complicated versions of the basic pde such as time- and state-dependent coefficients including a first order term, i e

$a(x,t) \, u_{xx}(x,t) +b(x,t) \, u_x (x,t) = u_t(x,t)
$
for u(x,0)=f(x).

Also I want to know how the solutions are affected by different boundary conditions on x=0 and x=L. And what solutions do we find in higher dimensions when x belongs to different geometric objects in 2-3 dimensions?

I'm not sure if these questions are relevant for this forum so please advise!

12. I'm not sure if these questions are relevant for this forum so please advise!
No they are not. They have nothing to do with the heat equation. They are simply more generalized equations. By definition, the heat equation is $\frac{\partial u}{\partial t} = \frac{1}{c^2}\cdot \nabla^2 u$. That is the most generalized equation. But it is not how you written it.

Originally Posted by BasicIdeaIsSimple

$a(x,t) \, u_{xx}(x,t) +b(x,t) \, u_x (x,t) = u_t(x,t)
$
for u(x,0)=f(x).

Also I want to know how the solutions are affected by different boundary conditions on x=0 and x=L. And what solutions do we find in higher dimensions when x belongs to different geometric objects in 2-3 dimensions?
What you typed is known as a Quasilinear Equation, it can be reduced by a techinique known as Method of Charachteristics.

13. ## Back to the heat

Thanks I'll check out the quasilinear reference you provided. Back to the standard heat eq. Fix a point x*: 0<x*<L and define
f(x)=1 for x<=x* and
f(x)=0 for x>x*.
(This is one fcn I just don't know how to write two-liners here)
How do you solve that?

14. Originally Posted by BasicIdeaIsSimple
Thanks I'll check out the quasilinear reference you provided. Back to the standard heat eq. Fix a point x*: 0<x*<L and define
f(x)=1 for x<=x* and
f(x)=0 for x>x*.
(This is one fcn I just don't know how to write two-liners here)
How do you solve that?
We need to know the coefficients $a_n$ which are,

$a_n = \frac{2}{L}\int_0^L f(x) \sin \frac{\pi n x}{L} dx = \frac{2}{L} \left( \int_0^{x_0}\sin \frac{\pi nx}{L} dx\right)$

15. ## Gauss kernel

Sorry, separation of variables does not work in this case because of the jump in boundary condition u(x,0)=f(x) at point x*. I'm afraid I cannot explain why. But I know that for an unbounded bar: -infinity <x<+inf the unique solution is the well-known Gauss kernel

$u(x,t)= \frac{1}{2\alpha \sqrt{\pi t}}\, exp \left( - \frac{(x-x^*)^2}{4\alpha^2t}\right)$

This is Example 1 on p.217 in Karlin & Taylor "Second Course in Stochastic Processes", Academic Press 1981. So perhaps the boundary conditions come into play in different ways depending on where x* lies in between your 0<x<L? I find these interesting topics to investigate further.

I hope the connection to Gauss will provide a challenge for you.

Page 1 of 2 12 Last