Example 4.  Consider the heat equation where  [Graphics:Images/CrankNicolsonMod_gr_108.gif].  The length of the rod is  [Graphics:Images/CrankNicolsonMod_gr_109.gif].  Assume that the ends of the rod are held at the temperature  [Graphics:Images/CrankNicolsonMod_gr_110.gif].  Assume that the initial temperature distribution is

        [Graphics:Images/CrankNicolsonMod_gr_111.gif].
      
Apply the Crank-Nicolson method with  [Graphics:Images/CrankNicolsonMod_gr_112.gif]  and obtain temperature distributions for  [Graphics:Images/CrankNicolsonMod_gr_113.gif].  Compare the solution with the exact solution:

        [Graphics:Images/CrankNicolsonMod_gr_114.gif].
     
(Is the Crank-Nicolson method stable when r > 1 ?)

Solution 4.

[Graphics:../Images/CrankNicolsonMod_gr_115.gif]


Now set up the table of solutions.

 

 

[Graphics:../Images/CrankNicolsonMod_gr_116.gif]

Setting up the tri-diagonal matrx with n rows.  Indeed, we could get away with  [Graphics:../Images/CrankNicolsonMod_gr_117.gif]  rows, but the implementation is nice this way.  The following matrix will usually use  [Graphics:../Images/CrankNicolsonMod_gr_118.gif].

 

 

[Graphics:../Images/CrankNicolsonMod_gr_119.gif]

Next, solve it.

[Graphics:../Images/CrankNicolsonMod_gr_120.gif]
[Graphics:../Images/CrankNicolsonMod_gr_121.gif]


[Graphics:../Images/CrankNicolsonMod_gr_122.gif]

[Graphics:../Images/CrankNicolsonMod_gr_123.gif]

[Graphics:../Images/CrankNicolsonMod_gr_124.gif]

[Graphics:../Images/CrankNicolsonMod_gr_125.gif]

[Graphics:../Images/CrankNicolsonMod_gr_126.gif]
[Graphics:../Images/CrankNicolsonMod_gr_127.gif]
[Graphics:../Images/CrankNicolsonMod_gr_128.gif]
[Graphics:../Images/CrankNicolsonMod_gr_129.gif]


Compare with the analytic solution.

[Graphics:../Images/CrankNicolsonMod_gr_130.gif]


[Graphics:../Images/CrankNicolsonMod_gr_131.gif]

[Graphics:../Images/CrankNicolsonMod_gr_132.gif]

[Graphics:../Images/CrankNicolsonMod_gr_133.gif]

[Graphics:../Images/CrankNicolsonMod_gr_134.gif]

[Graphics:../Images/CrankNicolsonMod_gr_135.gif]

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(c) John H. Mathews 2004