Problem 3
Find the solution, , 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
with , , and ,
where , , and .
First, clear the workspace and define .
> restart: f := x -> x*(Pi - x);
Start by assuming a separable solution of the form . Then we can conclude that if there is a
solution of this form, then and must satisfy two ordinary differential equations of the form
and , where the separation constant, , is the same for both equations.
We consider the possible values of , and their role in the equation for . Note that the boundary
conditions imply that and .
With these values of we see that there are solutions for the equation that are given by
Thus there are solutions to the heat equation of the form
.
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);
> D[2](u[k])(x,t) - D[1,1](u[k])(x,t);
We have one remaining condition to satisfy, namely .
Since we have an infinite set of solutions, each with an unspecified coefficient, , can we find a linear
combination, which yields the solution? That is, can we write ?
The answer is yes , provided we can find coefficients , such that
.
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 while the frequency term here is .
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
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);
> c[k] := (1/d[k])*int(f(x)*cos((2*k-1)*x/2),x=0..Pi);
> ccoef := unapply(c[k],k);
> c[1] := ccoef(1);c[2] := ccoef(2);c[3] := ccoef(3);c[4] := ccoef(4);
> HF := (x,N) -> sum(ccoef(k)*cos((2*k-1)*x/2),k=1..N);
> plot([f(x),HF(x,1),HF(x,2),HF(x,3),HF(x,4)],x=0..Pi);
Notice that each of the partial sums has a zero derivative at , which is one of the requirements of the solution.
However, since has a derivative of at , the series converges slowly at . 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);
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);
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']);
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);