Example 3.  Consider the heat equation where  [Graphics:Images/CrankNicolsonMod_gr_81.gif].  The length of the rod is  [Graphics:Images/CrankNicolsonMod_gr_82.gif].  Assume that the ends of the rod are held at the temperature  [Graphics:Images/CrankNicolsonMod_gr_83.gif].  Assume that the initial temperature distribution is

        [Graphics:Images/CrankNicolsonMod_gr_84.gif].
      
Apply the Crank-Nicolson method with  [Graphics:Images/CrankNicolsonMod_gr_85.gif]  and obtain temperature distributions for  [Graphics:Images/CrankNicolsonMod_gr_86.gif].  Compare the solution with the exact solution:

        [Graphics:Images/CrankNicolsonMod_gr_87.gif].
     
We will use  [Graphics:Images/CrankNicolsonMod_gr_88.gif] .  This forces  This forces  [Graphics:Images/CrankNicolsonMod_gr_89.gif].  

Solution 3.

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


Now set up the table of solutions.

 

 

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

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

 

 

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

Next, solve it.

[Graphics:../Images/CrankNicolsonMod_gr_95.gif]
[Graphics:../Images/CrankNicolsonMod_gr_96.gif]


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

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

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

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

[Graphics:../Images/CrankNicolsonMod_gr_101.gif]
[Graphics:../Images/CrankNicolsonMod_gr_102.gif]
[Graphics:../Images/CrankNicolsonMod_gr_103.gif]
[Graphics:../Images/CrankNicolsonMod_gr_104.gif]


Compare with the analytic solution.

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


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

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

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(c) John H. Mathews 2004