Example 3. 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:
.
We will use
. This forces This forces
.
Solution 3.
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_97.gif]](../Images/CrankNicolsonMod_gr_97.gif)
Compare with the analytic solution.
![[Graphics:../Images/CrankNicolsonMod_gr_106.gif]](../Images/CrankNicolsonMod_gr_106.gif)
(c) John H. Mathews 2004