Example 4. Consider
the heat equation where
. The
length of the rod is
. Assume
that the ends of the rod are held at the
temperature
. Assume
that the initial temperature distribution is
.
Apply the Crank-Nicolson method with
and
obtain temperature distributions for
. Compare
the solution with the exact solution:
.
(Is the Crank-Nicolson method stable when r > 1 ?)
Solution 4.
Now set up the table of solutions.
Setting up the tri-diagonal matrx with n rows. Indeed,
we could get away with
rows,
but the implementation is nice this way. The following
matrix will usually use
.
Next, solve it.
![[Graphics:../Images/CrankNicolsonMod_gr_122.gif]](../Images/CrankNicolsonMod_gr_122.gif)
Compare with the analytic solution.
![[Graphics:../Images/CrankNicolsonMod_gr_131.gif]](../Images/CrankNicolsonMod_gr_131.gif)
(c) John H. Mathews 2004