Problem 3

Find the solution, [Maple Math] , to the heat equation on a bar where one end is insulated, the temperature is held

constant at the other end, and the initial temperature distribution is specified. More specifically, solve

[Maple Math] with [Maple Math] , [Maple Math] , and [Maple Math] ,

where [Maple Math] , [Maple Math] , and [Maple Math] .

First, clear the workspace and define [Maple Math] .

> restart: f := x -> x*(Pi - x);

[Maple Math]

Start by assuming a separable solution of the form [Maple Math] . Then we can conclude that if there is a

solution of this form, then [Maple Math] and [Maple Math] must satisfy two ordinary differential equations of the form

[Maple Math] and [Maple Math] , where the separation constant, [Maple Math] , is the same for both equations.

We consider the possible values of [Maple Math] , and their role in the equation for [Maple Math] . Note that the boundary

conditions imply that [Maple Math] and [Maple Math] .

[Maple Math]

[Maple Math]

[Maple Math]

With these values of [Maple Math] we see that there are solutions for the [Maple Math] equation that are given by

[Maple Math]

Thus there are solutions to the heat equation of the form

[Maple Math] .

We can instruct Maple to verify this as follows:

> u[k] := (x,t) -> c[k]*exp(-((2*k-1)/2)^2*t)*cos((2*k-1)*x/2);

[Maple Math]

> D[2](u[k])(x,t) - D[1,1](u[k])(x,t);

[Maple Math]

We have one remaining condition to satisfy, namely [Maple Math] .

Since we have an infinite set of solutions, each with an unspecified coefficient, [Maple Math] , can we find a linear

combination, which yields the solution? That is, can we write [Maple Math] ?

The answer is yes , provided we can find coefficients [Maple Math] , such that

[Maple Math] .

But this is just the answer to Problem 1 - or is it?

Unfortunately, the answer to Problem 1 does NOT give us the answer to this problem

because the frequency term in Problem 1 is simply [Maple Math] while the frequency term here is [Maple Math] .

The preceding work constitutes the answer I was looking for on the test. Curiosity demands that we

say something about the coefficients of the series that we just derived. As the book mentions in

Section 16.1 on page 791, the Sturm-Liouville theorem (Section 6.1) asserts that this will work and

that the coefficients can be calculated from

[Maple Math]

Note that the term in the denominator is exactly what we need if we want to reproduce a single term of

the series.

One immediate observation is that the Sine series converges much more quickly than the Cosine series.

The maximum error is almost 100 times smaller with only half as many terms. This is because the function and

the first derivative are continuous under the odd extension.

> d[k] := int((cos((2*k-1)*x/2))^2,x=0..Pi);

[Maple Math]

> c[k] := (1/d[k])*int(f(x)*cos((2*k-1)*x/2),x=0..Pi);

[Maple Math]

> ccoef := unapply(c[k],k);

[Maple Math]

> c[1] := ccoef(1);c[2] := ccoef(2);c[3] := ccoef(3);c[4] := ccoef(4);

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

> HF := (x,N) -> sum(ccoef(k)*cos((2*k-1)*x/2),k=1..N);

[Maple Math]

> plot([f(x),HF(x,1),HF(x,2),HF(x,3),HF(x,4)],x=0..Pi);

[Maple Plot]

Notice that each of the partial sums has a zero derivative at [Maple Math] , which is one of the requirements of the solution.

However, since [Maple Math] has a derivative of [Maple Math] at [Maple Math] , the series converges slowly at [Maple Math] . On the other hand it

definitely seems to be converging. This is further supported by the error plot for 25 terms.

> plot(f(x)-HF(x,25),x=0..Pi);

[Maple Plot]

An approximation to the solultion using 25 terms is thus

> u[25] := (x,t) -> sum(ccoef(k)*exp(-((2*k-1)/2)^2*t)*cos((2*k-1)*x/2),k=1..25);

[Maple Math]

We can get a plot of this approximate solution. It shows the temperature rising at the insulated end with a zero derivative.

It also shows that the total heat in the rod is decreasing as the temperature in the rod decays to zero, the temperature at

the far end.

> plot3d(u[25],0..Pi,0..1,axes=BOXED,labels=['x','t','u']);

[Maple Plot]

We can also use Maple's plot package to show this solution in a movie.

> with(plots): animate(u[25](x,t), x=0..Pi, t=0..4);

[Maple Plot]