<?xml version="1.0"?>
<!DOCTYPE html    PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
           "http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="GENERATOR" content="TtM 4.12" />
 <style type="text/css">
 div.p { margin-top: 7pt; }
 span.roman {font-family: serif; font-style: normal; font-weight: normal;} 
</style>
 <style type="text/css">
 .tiny {font-size:30%;}
 .scriptsize {font-size:xx-small;}
 .footnotesize {font-size:x-small;}
 .smaller {font-size:smaller;}
 .small {font-size:small;}
 .normalsize {font-size:medium;}
 .large {font-size:large;}
 .larger {font-size:x-large;}
 .largerstill {font-size:xx-large;}
 .huge {font-size:300%;}
 </style>
<title>chap5.xml</title>
</head>
<body><div>
<table width="100%"><tr><td>
 <a href="index.xml">HEAD</a></td><td align="right">
 <a href="chap4.xml">PREVIOUS
</a></td></tr></table>
 <a id="tth_chAp5"></a><h1>
Chapter 5 <br />Diffusion. Parabolic Partial Differential Equations</h1>
<a id="DiffusionChap">
</a>

<div class="p"><!----></div>
 <a id="tth_sEc5.1"></a><h2>
5.1&nbsp;&nbsp;Diffusion Equations</h2>

<div class="p"><!----></div>
<a 
id="diffusion51296"></a><a 
id="diffusion_equation51297"></a>The diffusion equation,
<a id="diffusive">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow>
<mfrac><mrow><mo>&part;</mo><mi mathvariant="italic">&psi;</mi></mrow>
<mrow><mo>&part;</mo><mi>t</mi></mrow>
</mfrac>
<mo>=</mo><mo>&nabla;</mo><mo>.</mo><mo stretchy="false">(</mo><mi>D</mi><mo>&nabla;</mo><mi mathvariant="italic">&psi;</mi><mo stretchy="false">)</mo><mo>+</mo><mi>s</mi><mo>,</mo></mrow>
    </mstyle></math></td><td width="1">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>1</mn><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>


arises in heat conduction<a 
id="heat_conduction51298"></a>, neutron
transport<a 
id="neutron_transport51299"></a>, particle diffusion<a 
id="particle_diffusion51300"></a> , and
numerous other situations. There is a clear difference between the
time variable, <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>t</mi></mrow></math>, and the spatial variables <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="bold-italic">x</mi></mrow></math>. We'll talk
mostly for brevity as if there is only one spatial
dimension <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>x</mi></mrow></math>, but this discussion can readily be generalized to
multiple spatial dimensions. The highest time derivative is
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mo>&part;</mo><mo stretchy="false">/</mo><mo>&part;</mo><mi>t</mi></mrow></math>, first order. The highest spatial derivative is
second order <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msup><mrow><mo>&part;</mo></mrow><mrow><mn>2</mn></mrow>
</msup>
<mo stretchy="false">/</mo><mo>&part;</mo>
<msup><mrow><mi>x</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow></math>. The equation is classified as parabolic.

<div class="p"><!----></div>
<a id="tth_fIg5.1">
</a>   <img src="figures/nodehyper.png" alt="figures/nodehyper.png" /><a id="nodehyper">
</a>
  
<div style="text-align:center">Figure 5.1: Solving a diffusion problem generally requires a
    combination of spatial boundary conditions and temporal initial
    condition. Then the solution is propagated upward (forward in
    time), to fill in the multi-dimensional (time and space) solution
    domain.<a id="nodehyperl">
</a></div>

<div class="p"><!----></div>
Consequently, boundary conditions<a 
id="boundary_condition_parabolic51301"></a>
are not applied all around a closed contour (in the <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>x</mi></mrow></math>-<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>t</mi></mrow></math> plane) but
generally only at the two ends of the spatial range, and at one
"initial" time, as illustrated in Fig. <a href="chap5.xml#nodehyperl">5.1</a>. The
dependent variable solution is propagated from the initial condition
forward in time (conventionally drawn as the vertical direction).

<div class="p"><!----></div>
 <a id="tth_sEc5.2"></a><h2>
5.2&nbsp;&nbsp;Time Advance Choices and Stability</h2>

<div class="p"><!----></div>
     <a id="tth_sEc5.2.1"></a><h3>
5.2.1&nbsp;&nbsp;Forward Time, Centered Space</h3> 

<div class="p"><!----></div>
<a 
id="forward_in_time52302"></a><a 
id="centered_in_space52303"></a>For simplicity we'll take <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>D</mi></mrow></math> to be uniform in one cartesian
dimension, and the meshes to be uniform with spacing <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi><mi>x</mi></mrow></math> and
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow></math>. Then one way to write the equation in discrete finite
differences is<a 
id="diffusion_finite_difference52304"></a>
<a id="FTCSl">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow>
<mfrac><mrow>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup>
<mo>-</mo>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msubsup>
</mrow>
<mrow><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow>
</mfrac>
<mo>=</mo><mi>D</mi>
<mfrac><mrow>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi><mo>+</mo><mn>1</mn> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msubsup>
<mo>-</mo><mn>2</mn>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msubsup>
<mo>+</mo>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi><mo>-</mo><mn>1</mn> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msubsup>
</mrow>
<mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>x</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>
<mo>+</mo>
<msubsup><mrow><mi>s</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msubsup>
<mo>.</mo></mrow>
    </mstyle></math></td><td width="1">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>2</mn><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>


We use <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></math> to denote time index, and put it as a superscript to
distinguish it from the space indices <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>j</mi></mrow></math> [<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>k</mi></mrow></math>, <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>l</mi></mrow></math>]. Of course this
notation is <em>not</em> raising to a power. Notice
in this equation the <em>second order</em> derivative in space is
naturally centered and symmetric. However, the time derivative is not
centered in time. It is really the value at <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">/</mo><mn>2</mn></mrow></math>, not at the time
index of everything else: <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>n</mi></mrow></math>. This scheme is therefore "Forward" in
Time, but Centered in Space (FTCS)<a 
id="FTCS52305"></a>; see Fig.&nbsp;<a href="chap5.xml#FTCSfig">5.2</a>. 

<div class="p"><!----></div>
<a id="tth_fIg5.2">
</a>   <img src="figures/FTCS.png" alt="figures/FTCS.png" /><a id="FTCS">
</a>
  
<div style="text-align:center">Figure 5.2: Forward Time, Centered Space, (FTCS) difference scheme.</div>
  <a id="FTCSfig">
</a>

<div class="p"><!----></div>
We immediately know from our previous experience that, because it is
not centered in time, this scheme's accuracy is going to be only first
order<a 
id="first-order_accuracy52306"></a> in <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow></math>. Also, this scheme is
<em>explicit</em><a 
id="explicit52307"></a> in time. The <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&psi;</mi></mrow></math> at <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow></math> is
obtained using only prior (<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>n</mi></mrow></math>) values of the other quantities:
<a id="explicitdiff">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup>
<mo>=</mo>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msubsup>
<mo>+</mo>
<mfrac><mrow><mi>D</mi><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow>
<mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>x</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>
<mo stretchy="false">(</mo>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi><mo>+</mo><mn>1</mn> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msubsup>
<mo>-</mo><mn>2</mn>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msubsup>
<mo>+</mo>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi><mo>-</mo><mn>1</mn> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msubsup>
<mo stretchy="false">)</mo><mo>+</mo><mi mathvariant="italic">&Delta;</mi><mi>t</mi><mi>&ensp;&ensp;</mi>
<msubsup><mrow><mi>s</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msubsup>
<mo>.</mo></mrow>
    </mstyle></math></td><td width="1">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>3</mn><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>



<div class="p"><!----></div>
A question then arises as to whether this scheme is
<em>stable</em><a 
id="stability_diffusion_equation52308"></a>. For an ordinary
differential equation, we saw that with explicit integration, there
was a maximum step size that could be allowed before the scheme became
unstable. The same is true for hyperbolic and parabolic partial
differential equations. For stability analysis, we ignore the source
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>S</mi></mrow></math> (because we are really analysing the deviation of the
solution<a href="footnote.xml#tthFtNtACH" id="tthFrefACH"><math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msup><mrow></mrow><mrow><mn>27</mn></mrow>
</msup>
</mrow></math></a>). However, even so, it's a bit
difficult to see immediately how to evaluate the amplification
factor<a 
id="amplification_factor52309"></a>, because for partial differential
equations there is variation in the spatial dimension(s) that has to
be accounted for. It wasn't present for ordinary differential
equations. The way this is generally handled is to turn the partial
differential equation into an ordinary differential equation by
examining separately all the <em>Fourier
  components</em><a 
id="Fourier_representation52310"></a> of the spatial
variation. This sort of analysis is called Von Neumann<a 
id="Von___Neumann_stability52311"></a> stability analysis. It gives a precisely correct
answer only for uniform grids and coefficients, but it is usually
approximately correct, and hence in practice very useful even for
non-uniform cases.

<div class="p"><!----></div>
A Fourier component varies in space like <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>exp</mi><mo stretchy="false">(</mo><mi>i</mi>
<msub><mrow><mi>k</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
<mi>x</mi><mo stretchy="false">)</mo></mrow></math> where <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi>k</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
</mrow></math> is
the wave number in the <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>x</mi></mrow></math>-direction, (and <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>i</mi></mrow></math> is here the square root
of minus 1). For such a Fourier component, <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi></mrow>
</msub>
<mo>&prop;</mo><mi>exp</mi><mo stretchy="false">(</mo>
<msub><mrow><mi mathvariant="italic">ik</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
<mi mathvariant="italic">&Delta;</mi><mi>x</mi><mi>j</mi><mo stretchy="false">)</mo></mrow></math>, so that <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi><mo>+</mo><mn>1</mn></mrow>
</msub>
<mo>=</mo><mi>exp</mi><mo stretchy="false">(</mo>
<msub><mrow><mi mathvariant="italic">ik</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
<mi mathvariant="italic">&Delta;</mi><mi>x</mi><mo stretchy="false">)</mo>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi></mrow>
</msub>
</mrow></math>
and <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi><mo>-</mo><mn>1</mn></mrow>
</msub>
<mo>=</mo><mi>exp</mi><mo stretchy="false">(</mo><mo>-</mo>
<msub><mrow><mi mathvariant="italic">ik</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
<mi mathvariant="italic">&Delta;</mi><mi>x</mi><mo stretchy="false">)</mo>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi></mrow>
</msub>
</mrow></math>. Therefore
<a id="Fourierspace">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi><mo>+</mo><mn>1</mn></mrow>
</msub>
<mo>-</mo><mn>2</mn>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi></mrow>
</msub>
<mo>+</mo>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi><mo>-</mo><mn>1</mn></mrow>
</msub>
<mo>=</mo><mo stretchy="false">(</mo>
<msup><mrow><mi fontstyle="normal">e</mi></mrow><mrow>
<msub><mrow><mi mathvariant="italic">ik</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
<mi mathvariant="italic">&Delta;</mi><mi>x</mi></mrow>
</msup>
<mo>-</mo><mn>2</mn><mo>+</mo>
<msup><mrow><mi fontstyle="normal">e</mi></mrow><mrow><mo>-</mo>
<msub><mrow><mi mathvariant="italic">ik</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
<mi mathvariant="italic">&Delta;</mi><mi>x</mi></mrow>
</msup>
<mo stretchy="false">)</mo>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi></mrow>
</msub>
<mo>=</mo><mo>-</mo><mn>4</mn>
<msup><mrow><mi>sin</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
<mo stretchy="false">(</mo>
<mfrac><mrow>
<msub><mrow><mi>k</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
<mi mathvariant="italic">&Delta;</mi><mi>x</mi></mrow>
<mrow><mn>2</mn></mrow>
</mfrac>
<mo stretchy="false">)</mo>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi></mrow>
</msub>
<mo>.</mo></mrow>
    </mstyle></math></td><td width="1">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>4</mn><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>


Then substituting into eq.&nbsp;(<a href="chap5.xml#explicitdiff">5.3</a>) for this Fourier
component we find
<a id="Fouriergain">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow>
<msup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow>
</msup>
<mo>=</mo>
<munder><mrow>
<munder><mrow><mrow><mo>[</mo><mn>1</mn><mo>-</mo>
<mfrac><mrow><mi>D</mi><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow>
<mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>x</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>
<mn>4</mn>
<msup><mrow><mi>sin</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
<mo stretchy="false">(</mo>
<mfrac><mrow>
<msub><mrow><mi>k</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
<mi mathvariant="italic">&Delta;</mi><mi>x</mi></mrow>
<mrow><mn>2</mn></mrow>
</mfrac>
<mo stretchy="false">)</mo><mo>]</mo></mrow></mrow>
<mo stretchy="true">&UnderBrace;</mo></munder>
</mrow>
<mrow><mi fontstyle="normal">Amplification</mi><mi fontstyle="normal">&ensp;</mi><mi fontstyle="normal">factor</mi></mrow>
</munder>

<msup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow>
</msup>
<mo>.</mo></mrow>
    </mstyle></math></td><td width="1">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>5</mn><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>


The amplification factor from each step to the next is the square
bracket term. If it has a magnitude greater than 1, then instability
will occur. If <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>D</mi></mrow></math> is negative it will in fact be greater than
1. This instability is not a numerical instability, though. It is a
<em>physical</em> instability. The diffusion coefficient must be
positive otherwise the diffusion equation is unstable regardless of
numerical methods. So <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>D</mi></mrow></math> must be positive; and so are <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow></math>,
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi><mi>x</mi></mrow></math>. Therefore numerical instability will arise if the
magnitude of the second
(negative) term in the amplification factor exceeds 2. 

<div class="p"><!----></div>
If <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi>k</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
<mi mathvariant="italic">&Delta;</mi><mi>x</mi></mrow></math> is small, then that will make the second term small
and unproblematic. We are most concerned about larger <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi>k</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
</mrow></math> values
that can make <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msup><mrow><mi>sin</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
<mo stretchy="false">(</mo>
<msub><mrow><mi>k</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
<mi mathvariant="italic">&Delta;</mi><mi>x</mi><mo stretchy="false">/</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></math> approximately unity. In fact,
the largest <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi>k</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
</mrow></math> value that can be represented on a finite
grid<a href="footnote.xml#tthFtNtACI" id="tthFrefACI"><math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msup><mrow></mrow><mrow><mn>28</mn></mrow>
</msup>
</mrow></math></a>  is such that the phase difference
(<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi>k</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
<mi mathvariant="italic">&Delta;</mi><mi>x</mi></mrow></math>) between adjacent values is <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&pi;</mi></mrow></math> radians. That
corresponds to a solution that oscillates in sign between adjacent
nodes. For that Fourier component, therefore, <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msup><mrow><mi>sin</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
<mo stretchy="false">(</mo>
<msub><mrow><mi>k</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
<mi mathvariant="italic">&Delta;</mi><mi>x</mi><mo stretchy="false">/</mo><mn>2</mn><mo stretchy="false">)</mo><mo>=</mo><mn>1</mn></mrow></math>.

<div class="p"><!----></div>
Stability requires <em>all</em> Fourier modes to be stable, including
the worst mode that has <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msup><mrow><mi>sin</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
<mo stretchy="false">(</mo>
<msub><mrow><mi>k</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
<mi mathvariant="italic">&Delta;</mi><mi>x</mi><mo stretchy="false">/</mo><mn>2</mn><mo stretchy="false">)</mo><mo>=</mo><mn>1</mn></mrow></math>. Therefore the
condition for stability<a 
id="stability_condition_diffusion52312"></a> is
<a id="FTCSstability">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow>
<mfrac><mrow><mn>4</mn><mi>D</mi><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow>
<mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>x</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>
<mo>&lt;</mo><mn>2</mn><mo>.</mo></mrow>
    </mstyle></math></td><td width="1">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>6</mn><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>


There is, for the FTCS scheme, a maximum stable timestep equal to
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>x</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
<mo stretchy="false">/</mo><mn>2</mn><mi>D</mi></mrow></math>.

<div class="p"><!----></div>
Incidentally, the fact that <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow></math> must therefore be no bigger
than something proportional to <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>x</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow></math> makes the first order
accuracy in time less of a problem<a 
id="first-order_accuracy52313"></a>. In
fact, for a timestep at the stability limit, as we decrease <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi><mi>x</mi></mrow></math>, improving the spatial accuracy proportional to <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>x</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow></math>
because of the second order accuracy in space, we also improve the
temporal accuracy by the same factor, proportional to <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>x</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow></math>
because <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi><mi>t</mi><mo>&prop;</mo><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>x</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow></math>.

<div class="p"><!----></div>
     <a id="tth_sEc5.2.2"></a><h3>
5.2.2&nbsp;&nbsp;Backward Time, Centered Space. Implicit Scheme.</h3>

<div class="p"><!----></div>
In order to counteract the instability, we learned earlier that
<em>implicit</em><a 
id="implicit52314"></a> schemes are helpful. The natural
implicit time advance is simply to say that we use the values of the
updated variables to evaluate the rest of the equation, instead of the
prior values:
<a id="implicitdiff">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup>
<mo>=</mo>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msubsup>
<mo>+</mo>
<mfrac><mrow><mi>D</mi><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow>
<mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>x</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>
<mo stretchy="false">(</mo>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi><mo>+</mo><mn>1</mn> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup>
<mo>-</mo><mn>2</mn>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup>
<mo>+</mo>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi><mo>-</mo><mn>1</mn> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup>
<mo stretchy="false">)</mo><mo>+</mo><mi mathvariant="italic">&Delta;</mi><mi>t</mi><mi>&ensp;&ensp;</mi>
<msubsup><mrow><mi>s</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup>
<mo>;</mo></mrow>
    </mstyle></math></td><td width="1">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>7</mn><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>


This is a Backward in Time, Centered in Space scheme; illustrated in
Fig. <a href="chap5.xml#BTCSl">5.3</a>.

<div class="p"><!----></div>
<a id="tth_fIg5.3">
</a> <img src="figures/BTCS.png" alt="figures/BTCS.png" /><a id="BTCS">
</a>

<div style="text-align:center">Figure 5.3: Backward time, centered space, (BTCS) difference scheme.<a id="BTCSl">
</a></div>

<div class="p"><!----></div>
We'll see a little later how to actually solve this
equation for the values at <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow></math>, but we can do the same stability
analysis on it without knowing. The combination for the spatial
Fourier mode is just as in eq.&nbsp;(<a href="chap5.xml#Fourierspace">5.4</a>), so the update
equation (ignoring <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>S</mi></mrow></math>) for a Fourier mode is
<a id="Fourierimplicit">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow>
<munder><mrow>
<munder><mrow><mrow><mo>[</mo><mn>1</mn><mo>+</mo>
<mfrac><mrow><mi>D</mi><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow>
<mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>x</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>
<mn>4</mn>
<msup><mrow><mi>sin</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
<mo stretchy="false">(</mo>
<mfrac><mrow>
<msub><mrow><mi>k</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
<mi mathvariant="italic">&Delta;</mi><mi>x</mi></mrow>
<mrow><mn>2</mn></mrow>
</mfrac>
<mo stretchy="false">)</mo><mo>]</mo></mrow></mrow>
<mo stretchy="true">&UnderBrace;</mo></munder>
</mrow>
<mrow><mi fontstyle="normal">Inverse</mi><mi fontstyle="normal">&ensp;</mi><mi fontstyle="normal">of</mi><mi fontstyle="normal">&ensp;</mi><mi fontstyle="normal">Amplification</mi><mi fontstyle="normal">&ensp;</mi><mi fontstyle="normal">factor</mi></mrow>
</munder>

<msup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow>
</msup>
<mo>=</mo>
<msup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow>
</msup>
<mo>.</mo></mrow>
    </mstyle></math></td><td width="1">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>8</mn><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>



<div class="p"><!----></div>
The amplification factor is the inverse of the square bracket factor
on the left. That square bracket has magnitude always greater than
one. Therefore the BTCS<a 
id="backward_time52315"></a><a 
id="BTCS_scheme52316"></a> scheme is
<em>unconditionally stable</em>.  We can take timesteps as large as we
like.

<div class="p"><!----></div>
It turns out, however, that the only first order accuracy of this
scheme, like the FTCS scheme, means that we don't generally want much to
exceed the previously calculated stability limit. If we do so, we
increasingly sacrifice temporal accuracy, even though not stability.

<div class="p"><!----></div>
     <a id="tth_sEc5.2.3"></a><h3>
5.2.3&nbsp;&nbsp;Partially implicit, Crank-Nicholson schemes.</h3>

<div class="p"><!----></div>
<a 
id="Crank-Nicholson_scheme52317"></a><a 
id="theta-implicit52318"></a>The best choice, for optimizing the efficiency of the numerical
solution of diffusive problems is to use a scheme that is part forward
and part backward. A combination of forward and backward, in which
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&theta;</mi></mrow></math> is the weight of the implicit or backward proportion, is
to write
<a id="partimplicitdiff">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow>
<mtable displaystyle="true" align="right" width="80%">
<mtr><mtd columnalign="right" columnspan="1"><mrow>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup>
<mo>=</mo>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msubsup>
</mrow>
</mtd><mtd columnalign="left">
<mrow><mo>+</mo></mrow>
</mtd><mtd columnalign="left">
<mrow><mi mathvariant="italic">&theta;</mi><mrow><mo>[</mo>
<mfrac><mrow><mi>D</mi><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow>
<mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>x</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>
<mo stretchy="false">(</mo>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi><mo>+</mo><mn>1</mn> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup>
<mo>-</mo><mn>2</mn>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup>
<mo>+</mo>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi><mo>-</mo><mn>1</mn> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup>
<mo stretchy="false">)</mo><mo>+</mo><mi mathvariant="italic">&Delta;</mi><mi>t</mi><mi>&ensp;</mi>
<msubsup><mrow><mi>s</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup>
<mo>]</mo></mrow></mrow>
</mtd></mtr>
<mtr><mtd columnalign="right" columnspan="1"><mrow></mrow>
</mtd><mtd columnalign="left">
<mrow><mo>+</mo></mrow>
</mtd><mtd columnalign="left">
<mrow><mo stretchy="false">(</mo><mn>1</mn><mo>-</mo><mi mathvariant="italic">&theta;</mi><mo stretchy="false">)</mo><mrow><mo>[</mo>
<mfrac><mrow><mi>D</mi><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow>
<mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>x</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>
<mo stretchy="false">(</mo>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi><mo>+</mo><mn>1</mn> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msubsup>
<mo>-</mo><mn>2</mn>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msubsup>
<mo>+</mo>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi><mo>-</mo><mn>1</mn> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msubsup>
<mo stretchy="false">)</mo><mo>+</mo><mi mathvariant="italic">&Delta;</mi><mi>t</mi><mi>&ensp;</mi>
<msubsup><mrow><mi>s</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msubsup>
<mo>]</mo></mrow><mo>.</mo></mrow>
</mtd><mtd columnalign="right">&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;<mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>9</mn><mo stretchy="false">)</mo></mtd></mtr>
</mtable>
</mrow>
    </mstyle></math>
</td></tr></table>
<br />

This is sometimes called the "<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&theta;</mi></mrow></math>-implicit" scheme.
The amplification factor<a 
id="amplification_factor52319"></a> is straightforwardly
<a id="amplpartial">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mi>A</mi><mo>=</mo>
<mfrac><mrow><mn>1</mn><mo>-</mo><mo stretchy="false">(</mo><mn>1</mn><mo>-</mo><mi mathvariant="italic">&theta;</mi><mo stretchy="false">)</mo>
<mfrac><mrow><mn>4</mn><mi>D</mi><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow>
<mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>x</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>

<msup><mrow><mi>sin</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
<mo stretchy="false">(</mo>
<mfrac><mrow>
<msub><mrow><mi>k</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
<mi mathvariant="italic">&Delta;</mi><mi>x</mi></mrow>
<mrow><mn>2</mn></mrow>
</mfrac>
<mo stretchy="false">)</mo></mrow>
<mrow><mn>1</mn><mo>+</mo><mi mathvariant="italic">&theta;</mi>
<mfrac><mrow><mn>4</mn><mi>D</mi><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow>
<mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>x</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>

<msup><mrow><mi>sin</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
<mo stretchy="false">(</mo>
<mfrac><mrow>
<msub><mrow><mi>k</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
<mi mathvariant="italic">&Delta;</mi><mi>x</mi></mrow>
<mrow><mn>2</mn></mrow>
</mfrac>
<mo stretchy="false">)</mo></mrow>
</mfrac>
<mo>.</mo></mrow>
    </mstyle></math></td><td width="1">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>10</mn><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>


If <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&theta;</mi><mo>&ge;</mo>
<mfrac><mrow><mn>1</mn></mrow>
<mrow><mn>2</mn></mrow>
</mfrac>
</mrow></math> then <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mo stretchy="false">&verbar;</mo><mi>A</mi><mo stretchy="false">&verbar;</mo><mo>&le;</mo><mn>1</mn></mrow></math>, and the scheme is always
stable. If <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&theta;</mi><mo>&lt;</mo>
<mfrac><mrow><mn>1</mn></mrow>
<mrow><mn>2</mn></mrow>
</mfrac>
</mrow></math>, then <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mo stretchy="false">&verbar;</mo><mi>A</mi><mo stretchy="false">&verbar;</mo><mo>&le;</mo><mn>1</mn></mrow></math> requires the
stability criterion<a 
id="stability_condition_Crank-Nicholson52320"></a>
<a id="thetastability">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mi mathvariant="italic">&Delta;</mi><mi>t</mi><mo>&lt;</mo>
<mfrac><mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>x</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
<mrow><mn>2</mn><mi>D</mi><mo stretchy="false">(</mo><mn>1</mn><mo>-</mo><mn>2</mn><mi mathvariant="italic">&theta;</mi><mo stretchy="false">)</mo></mrow>
</mfrac>
<mo>.</mo></mrow>
    </mstyle></math></td><td width="1">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>11</mn><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>


Thus the minimum degree of implicitness that guarantees
stability for all sizes of timestep is <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&theta;</mi><mo>=</mo>
<mfrac><mrow><mn>1</mn></mrow>
<mrow><mn>2</mn></mrow>
</mfrac>
</mrow></math>. This
choice is called the "Crank-Nicholson" scheme.

<div class="p"><!----></div>
It has a major advantage beyond stability. It is centered in
time. That means it is<a 
id="second-order_accuracy52321"></a> second order
accurate in time (as well as space). This accuracy makes it useful to
take bigger steps than would be allowed by the (explicit advance)
stability limit.

<div class="p"><!----></div>
 <a id="tth_sEc5.3"></a><h2>
5.3&nbsp;&nbsp;Implicit Advancing Matrix Method</h2>

<div class="p"><!----></div>
An implicit or partially implicit<a 
id="implicit_parabolic53322"></a> scheme for
advancing a parabolic equation generally results in equations
containing more than one spatial point value at the updated time, for
example <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup>
</mrow></math>, <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi><mo>-</mo><mn>1</mn> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup>
</mrow></math>,
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi><mo>+</mo><mn>1</mn> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup>
</mrow></math>. Such an equation for all spatial positions can
be written as a matrix equation. Gathering together the terms at <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>n</mi></mrow></math>
and at <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow></math> from eq.&nbsp;(<a href="chap5.xml#partimplicitdiff">5.9</a>), it can be written

<div class="p"><!----></div>
<a id="implicitmatrix">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mrow><mo>(</mo>
<mtable>
<mtr><mtd columnalign="center"><mrow><mo>&dtdot;</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>&dtdot;</mo></mrow></mtd><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow><mo>&dtdot;</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>&dtdot;</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>&dtdot;</mo></mrow></mtd><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd><mtd columnalign="center"><mrow>
<msub><mrow><mi>B</mi></mrow><mrow><mo>-</mo></mrow>
</msub>
</mrow></mtd><mtd columnalign="center"><mrow>
<msub><mrow><mi>B</mi></mrow><mrow><mn>0</mn></mrow>
</msub>
</mrow></mtd><mtd columnalign="center"><mrow>
<msub><mrow><mi>B</mi></mrow><mrow><mo>+</mo></mrow>
</msub>
</mrow></mtd><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd><mtd columnalign="center"><mrow><mo>&dtdot;</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>&dtdot;</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>&dtdot;</mo></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd><mtd columnalign="center"><mrow><mo>&dtdot;</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>&dtdot;</mo></mrow></mtd></mtr></mtable>

<mo>)</mo></mrow><mrow><mo>(</mo>
<mtable>
<mtr><mtd columnalign="center"><mrow>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mn>1</mn> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup>
</mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow>:</mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup>
</mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow>:</mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>J</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup>
</mrow></mtd></mtr></mtable>

<mo>)</mo></mrow><mo>=</mo><mrow><mo>(</mo>
<mtable>
<mtr><mtd columnalign="center"><mrow><mo>&dtdot;</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>&dtdot;</mo></mrow></mtd><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow><mo>&dtdot;</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>&dtdot;</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>&dtdot;</mo></mrow></mtd><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd><mtd columnalign="center"><mrow>
<msub><mrow><mi>C</mi></mrow><mrow><mo>-</mo></mrow>
</msub>
</mrow></mtd><mtd columnalign="center"><mrow>
<msub><mrow><mi>C</mi></mrow><mrow><mn>0</mn></mrow>
</msub>
</mrow></mtd><mtd columnalign="center"><mrow>
<msub><mrow><mi>C</mi></mrow><mrow><mo>+</mo></mrow>
</msub>
</mrow></mtd><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd><mtd columnalign="center"><mrow><mo>&dtdot;</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>&dtdot;</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>&dtdot;</mo></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd><mtd columnalign="center"><mrow><mn>0</mn></mrow></mtd><mtd columnalign="center"><mrow><mo>&dtdot;</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>&dtdot;</mo></mrow></mtd></mtr></mtable>

<mo>)</mo></mrow><mrow><mo>(</mo>
<mtable>
<mtr><mtd columnalign="center"><mrow>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mn>1</mn> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msubsup>
</mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow>:</mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msubsup>
</mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow>:</mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow>
<msubsup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>J</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msubsup>
</mrow></mtd></mtr></mtable>

<mo>)</mo></mrow><mo>+</mo><mrow><mo>(</mo>
<mtable>
<mtr><mtd columnalign="center"><mrow>
<msub><mrow><mi>s</mi></mrow><mrow><mn>1</mn></mrow>
</msub>
</mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow>:</mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow>
<msub><mrow><mi>s</mi></mrow><mrow><mi>j</mi></mrow>
</msub>
</mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow>:</mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow>
<msub><mrow><mi>s</mi></mrow><mrow><mi>J</mi></mrow>
</msub>
</mrow></mtd></mtr></mtable>

<mo>)</mo></mrow></mrow>
    </mstyle></math></td><td width="1">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>12</mn><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>



<div class="p"><!----></div>
or symbolically 
<a id="implicitmatrix2">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mi mathvariant="bold">B</mi>
<msub><mrow><mi mathvariant="bold-italic">&psi;</mi></mrow><mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow>
</msub>
<mo>=</mo><mi mathvariant="bold">C</mi>
<msub><mrow><mi mathvariant="bold-italic">&psi;</mi></mrow><mrow><mi>n</mi></mrow>
</msub>
<mo>+</mo><mi mathvariant="bold">s</mi><mo>,</mo></mrow>
    </mstyle></math></td><td width="1">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>13</mn><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>


where <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>J</mi></mrow></math> is the total length of the spatial mesh (the maximum of
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>j</mi></mrow></math>), and the coefficients are
<a id="impcoef">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow>
<msub><mrow><mi>B</mi></mrow><mrow><mn>0</mn></mrow>
</msub>
<mo>=</mo><mn>1</mn><mo>+</mo><mn>2</mn>
<mfrac><mrow><mi>D</mi><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow>
<mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>x</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>
<mi mathvariant="italic">&theta;</mi><mo>,</mo><mi>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;</mi>
<msub><mrow><mi>B</mi></mrow><mrow><mo>+</mo></mrow>
</msub>
<mo>=</mo>
<msub><mrow><mi>B</mi></mrow><mrow><mo>-</mo></mrow>
</msub>
<mo>=</mo><mo>-</mo>
<mfrac><mrow><mi>D</mi><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow>
<mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>x</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>
<mi mathvariant="italic">&theta;</mi><mo>,</mo></mrow>
    </mstyle></math></td><td width="1">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>14</mn><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>


<a id="impcoef2">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow>
<msub><mrow><mi>C</mi></mrow><mrow><mn>0</mn></mrow>
</msub>
<mo>=</mo><mn>1</mn><mo>-</mo><mn>2</mn>
<mfrac><mrow><mi>D</mi><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow>
<mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>x</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>
<mo stretchy="false">(</mo><mn>1</mn><mo>-</mo><mi mathvariant="italic">&theta;</mi><mo stretchy="false">)</mo><mo>,</mo><mi>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;</mi>
<msub><mrow><mi>C</mi></mrow><mrow><mo>+</mo></mrow>
</msub>
<mo>=</mo>
<msub><mrow><mi>C</mi></mrow><mrow><mo>-</mo></mrow>
</msub>
<mo>=</mo><mo>+</mo>
<mfrac><mrow><mi>D</mi><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow>
<mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>x</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>
<mo stretchy="false">(</mo><mn>1</mn><mo>-</mo><mi mathvariant="italic">&theta;</mi><mo stretchy="false">)</mo><mo>,</mo></mrow>
    </mstyle></math></td><td width="1">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>15</mn><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>


<a id="impcoef3">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mi fontstyle="normal">and</mi><mi>&emsp;&emsp;&emsp;</mi>
<msub><mrow><mi>s</mi></mrow><mrow><mi>j</mi></mrow>
</msub>
<mo>=</mo><mi mathvariant="italic">&Delta;</mi><mi>t</mi><mo stretchy="false">[</mo><mi mathvariant="italic">&theta;</mi>
<msubsup><mrow><mi>s</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msubsup>
<mo>+</mo><mo stretchy="false">(</mo><mn>1</mn><mo>-</mo><mi mathvariant="italic">&theta;</mi><mo stretchy="false">)</mo>
<msubsup><mrow><mi>s</mi></mrow><mrow><mi>j</mi> </mrow>
<mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msubsup>
<mo stretchy="false">]</mo><mo>.</mo></mrow>
    </mstyle></math></td><td width="1">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>16</mn><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>


[Notice the <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow></math> scaling factor in <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi>s</mi></mrow><mrow><mi>j</mi></mrow>
</msub>
</mrow></math>.]

<div class="p"><!----></div>
We are here assuming that the source terms do not depend upon <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&psi;</mi></mrow></math>.
Eq.&nbsp;(<a href="chap5.xml#implicitmatrix2">5.13</a>) can be solved formally by inverting the matrix
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="bold">B</mi></mrow></math>:
<a id="impinv">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow>
<msub><mrow><mi mathvariant="bold-italic">&psi;</mi></mrow><mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow>
</msub>
<mo>=</mo>
<msup><mrow><mi mathvariant="bold">B</mi></mrow><mrow><mo>-</mo><mn>1</mn></mrow>
</msup>
<mi mathvariant="bold">C</mi>
<msub><mrow><mi mathvariant="bold-italic">&psi;</mi></mrow><mrow><mi>n</mi></mrow>
</msub>
<mo>+</mo>
<msup><mrow><mi mathvariant="bold">B</mi></mrow><mrow><mo>-</mo><mn>1</mn></mrow>
</msup>
<mi mathvariant="bold">s</mi><mo>.</mo></mrow>
    </mstyle></math></td><td width="1">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>17</mn><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>


Therefore the additional work involved in using an implicit scheme is
that we have (effectively) to invert the<a 
id="matrix_inversion53323"></a>
matrix <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="bold">B</mi></mrow></math>, and multiply by the inverse at each timestep.

<div class="p"><!----></div>
Provided the mesh is not too large, this can be a managable
approach. In a situation where <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="bold">B</mi></mrow></math> and <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="bold">C</mi></mrow></math> do not change
with time, the inversion<a href="footnote.xml#tthFtNtACJ" id="tthFrefACJ"><math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msup><mrow></mrow><mrow><mn>29</mn></mrow>
</msup>
</mrow></math></a> need only be done once; and each step in time
involves only a matrix multiplication by <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msup><mrow><mi mathvariant="bold">B</mi></mrow><mrow><mo>-</mo><mn>1</mn></mrow>
</msup>
<mi mathvariant="bold">C</mi></mrow></math> of the
values from the previous timestep, <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi mathvariant="bold-italic">&psi;</mi></mrow><mrow><mi>n</mi></mrow>
</msub>
</mrow></math>.

<div class="p"><!----></div>
If the matrix has the tridiagonal<a 
id="tridiagonal53324"></a> form of eq.&nbsp;(<a href="chap5.xml#implicitmatrix">5.12</a>), where the entries are non-zero only on the
diagonal and the immediately adjacent subdiagonals, then it will
certainly be more computationally efficient to solve for the
updated variable by elimination<a href="footnote.xml#tthFtNtADA" id="tthFrefADA"><math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msup><mrow></mrow><mrow><mn>30</mn></mrow>
</msup>
</mrow></math></a><a 
id="elimination_tridiagonal53325"></a> rather than inverting the matrix
and multiplying. This is a reflection of the fact that the matrix
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="bold">B</mi></mrow></math> is <em>sparse</em><a 
id="sparse53326"></a>. All but a very small
fraction of its coefficients are zero. The fundamental problem is that
the inverse of a sparse matrix is generally not sparse. Consequently,
even though multiplication by the original sparse matrix actually
requires only a few individual arithmetic operations, and easy
short-cuts can be implemented, there are no obvious short-cuts for
doing the matrix multiplication by the inverse. As long as we are
implementing solutions in a mathematical system like
Octave<a 
id="Octave53327"></a> using the built-in facilities, we won't notice
any difference because we are not using short-cuts.

<div class="p"><!----></div>
 <a id="tth_sEc5.4"></a><h2>
5.4&nbsp;&nbsp;Multiple Space Dimensions</h2>

<div class="p"><!----></div>

<div class="p"><!----></div>
<a id="tth_fIg5.4">
</a>   <img src="figures/solnplot.png" alt="figures/solnplot.png" /><a id="solnplot">
</a>
  
<div style="text-align:center">Figure 5.4: Example solution, at a particular time, of a diffusion
    equation in two space dimensions. The value of <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&psi;</mi></mrow></math> is
    visualized in this perspective plot as the height of the
    surface.<a id="lsolnplot">
</a></div>

<div class="p"><!----></div>
When there is more than one spatial coordinate dimension, as
illustrated in Fig.&nbsp;<a href="chap5.xml#lsolnplot">5.4</a>, nothing
changes formally about our method of solution of parabolic equations. 
What changes, however, is that we need a systematic way to turn the
entire spatial mesh in multiple 
dimensions<a 
id="multiple_dimensions54328"></a><a 
id="indexing_multiple_dimensions54329"></a>
into a column vector like
those in eq.&nbsp;(<a href="chap5.xml#implicitmatrix">5.12</a>). In other words, we must index
all the spatial positions with a single index <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>j</mi></mrow></math>. But generally if we
have multiple dimensions, the natural (physical) indexing of the
elements of the mesh is by a number of multiple indices equal to the
number of dimensions: e.g.&nbsp;<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>,</mo><mi>l</mi><mo>,</mo><mi>m</mi></mrow>
</msub>
</mrow></math>, where <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>k</mi></mrow></math>, <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>l</mi></mrow></math>,
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>m</mi></mrow></math> correspond to the coordinates <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>x</mi></mrow></math>, <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>y</mi></mrow></math>, <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>z</mi></mrow></math>.

<div class="p"><!----></div>
Reordering<a 
id="reordering_of_mesh_elements54330"></a> the mesh elements is not
a particularly difficult task algebraically, but it requires an
intuitively tricky geometrical mental shift. In general, if we have a
quantity <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>,</mo><mi>l</mi><mo>,</mo><mo>.</mo><mo>.</mo><mo>.</mo></mrow>
</msub>
</mrow></math> indexed on a multidimensional mesh whose
lengths in the different mesh dimensions are <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>K</mi></mrow></math>, <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>L</mi></mrow></math>, ...  then we
re-index them into a single index <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>j</mi></mrow></math> as follows. Start with all
indices equal to 1. Count through the first index, <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>k</mi><mo>=</mo><mn>1</mn><mo>,</mo><mo>.</mo><mo>.</mo><mo>.</mo><mo>,</mo><mi>K</mi></mrow></math>. Then
increment the second index <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>l</mi></mrow></math> and repeat <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>k</mi><mo>=</mo><mn>1</mn><mo>,</mo><mo>.</mo><mo>.</mo><mo>.</mo><mo>,</mo><mi>K</mi></mrow></math>. Continue this
process for <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>l</mi><mo>=</mo><mn>1</mn><mo>,</mo><mo>.</mo><mo>.</mo><mo>.</mo><mo>,</mo><mi>L</mi></mrow></math>. Then increment the next index (if any), and
continue till all indices are exhausted. Incidentally, this is
precisely the order in which the elements<a 
id="order_of_elements54331"></a> are
stored in computer memory<a 
id="computer_memory54332"></a> when using a
language like Fortran<a 
id="Fortran_order54333"></a> when using the entire
allocated array.

<div class="p"><!----></div>
<a id="tth_fIg5.5">
</a>   <img src="figures/pointorder.png" alt="figures/pointorder.png" /><a id="pointorder">
</a>
  
<div style="text-align:center">Figure 5.5: Conversion of a two-dimensional array into a single column
    vector using column order is like stacking all the columns below
    one another.</div>

<div class="p"><!----></div>
The result is that for the giant column vector <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi></mrow>
</msub>
</mrow></math>, the first <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>K</mi></mrow></math>
elements are the original multidimensionally indexed elements
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>,</mo><mn>1</mn><mo>,</mo><mo>.</mo><mo>.</mo><mo>.</mo></mrow>
</msub>
<mo>,</mo><mi>&ensp;</mi><mi>k</mi><mo>=</mo><mn>1</mn><mo>,</mo><mo>.</mo><mo>.</mo><mo>.</mo><mo>,</mo><mi>K</mi></mrow></math>; the next <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>K</mi></mrow></math> elements, <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>j</mi><mo>=</mo><mi>K</mi><mo>+</mo><mn>1</mn><mo>,</mo><mo>.</mo><mo>.</mo><mo>.</mo><mo>,</mo><mn>2</mn><mi>K</mi></mrow></math>,
are the original <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>,</mo><mn>2</mn><mo>,</mo><mo>.</mo><mo>.</mo><mo>.</mo></mrow>
</msub>
</mrow></math> and so on.<a href="footnote.xml#tthFtNtADB" id="tthFrefADB"><math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msup><mrow></mrow><mrow><mn>31</mn></mrow>
</msup>
</mrow></math></a>

<div class="p"><!----></div>
In multiple dimensions, the second derivative operator (something like
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msup><mrow><mo>&nabla;</mo></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow></math>) is represented by a stencil<a 
id="stencil54334"></a>, as illustrated
in eq.&nbsp;(<a href="chap4.xml#stencilmat">4.23</a>). The importance of the reordering of the
elements into a column vector is that although the components of the
stencil that are adjacent in the first index (<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>k</mi></mrow></math>) remain adjacent in
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>j</mi></mrow></math>, those in the other index(es) (<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>l</mi></mrow></math>) do not. For example the
elements <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>,</mo><mi>l</mi></mrow>
</msub>
</mrow></math> and <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>,</mo><mi>l</mi><mo>+</mo><mn>1</mn></mrow>
</msub>
</mrow></math> have <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>j</mi></mrow></math>-indices
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>j</mi><mo>=</mo><mi>K</mi><mo>.</mo><mo stretchy="false">(</mo><mi>l</mi><mo>-</mo><mn>1</mn><mo stretchy="false">)</mo><mo>+</mo><mi>k</mi></mrow></math> and <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>j</mi><mo>=</mo><mi>K</mi><mo>.</mo><mi>l</mi><mo>+</mo><mi>k</mi></mrow></math> respectively; they are a distance <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>K</mi></mrow></math>
apart. This fact means that for multiple spatial dimensions the
matrices <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="bold">B</mi></mrow></math> and <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="bold">C</mi></mrow></math> are no longer simply
tridiagonal. Instead, they have an additional non-zero diagonal, a
distance <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>K</mi></mrow></math> from the main diagonal.  If the boundary conditions are
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&psi;</mi><mo>=</mo><mn>0</mn></mrow></math>, each matrix is
"Block-Tridiagonal"<a 
id="block_tridiagonal54335"></a><a 
id="block_matrix54336"></a>,
having a form like this:
<a id="triplusfringes">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mi>L</mi><mi>&ensp;</mi><mi fontstyle="normal">blocks</mi><mrow><mo>{</mo><mrow><mo>[</mo>
<mtable>
<mtr><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mrow><mo>}</mo>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi fontstyle="normal">Block</mi></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow><mi fontstyle="normal">size</mi></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow><mi>K</mi></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd></mtr></mtable>

<mo> </mo></mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd></mtr></mtable>

</mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd></mtr></mtable>

</mrow></mtd></mtr></mtable>

<mo>]</mo></mrow><mo>}</mo></mrow><mi>J</mi><mo>=</mo><mi>K</mi><mo>&times;</mo><mi>L</mi><mi>&ensp;</mi>
<mtext>rows</mtext>
<mo>.</mo></mrow>
    </mstyle></math></td><td width="1">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>18</mn><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>


Here, <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>c</mi></mrow></math> denotes the coefficient of the <em>center</em> of the stencil,
and <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>a</mi></mrow></math> denotes the coefficients of the <em>adjacent</em> points in the
stencil. One can think of the total matrix as being composed of
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>L</mi><mo>&times;</mo><mi>L</mi></mrow></math> blocks, each of size <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>K</mi><mo>&times;</mo><mi>K</mi></mrow></math>. All the blocks are zero
except the tridiagonal ones. And each non-zero block is itself
tridiagonal (or diagonal). If there are further dimensions <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>M</mi></mrow></math>, then
the giant matrix is a tridiagonal composite of <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>M</mi><mo>&times;</mo><mi>M</mi></mrow></math> blocks,
each of a two dimensional (<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>L</mi><mo>&times;</mo><mi>L</mi></mrow></math> block) type of eq.&nbsp;(<a href="chap5.xml#triplusfringes">5.18</a>). And so on.

<div class="p"><!----></div>
It is very important to think carefully about the boundary
conditions<a 
id="boundary_condition_block54337"></a>. These occur at the boundaries of <em>each block</em>. Notice
how the corner (boundary) entries of the extra subdiagonal blocks make
zero certain coefficients of the subdiagonals of the total matrix.
One important consequence of the block-tridiagonal form
(<a href="chap5.xml#triplusfringes">5.18</a>) is that it is not so easy to do tridiagonal
elimination<a 
id="tridiagonal_elimination54338"></a><a 
id="elimination_tridiagonal54339"></a> rather than matrix inversion. 

<div class="p"><!----></div>
 <a id="tth_sEc5.5"></a><h2>
5.5&nbsp;&nbsp;Estimating Computational Cost</h2>

<div class="p"><!----></div>
The computational cost<a 
id="cost__computational_55340"></a><a 
id="computational_cost55341"></a> of
executing different numerical algorithms often has to be considered
for large scale computing. This cost is generally expressed in the
number of floating point operations (FLOPs)<a 
id="FLOP55342"></a>. Roughly, this is the
number of multiplications (or divisions) required. Additions are cheap.

<div class="p"><!----></div>
For an <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>N</mi><mo>&times;</mo><mi>N</mi></mrow></math> matrix, multiplying into a length-<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>N</mi></mrow></math> column vector
costs (simplemindedly) <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>N</mi></mrow></math> rows times <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>N</mi></mrow></math> operations per row: <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msup><mrow><mi>N</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow></math>
(FLOPs). By extending this to <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>N</mi></mrow></math> columns, we see that multiplying two
matrices costs <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msup><mrow><mi>N</mi></mrow><mrow><mn>3</mn></mrow>
</msup>
</mrow></math>. Although the process of
<em>inversion</em><a href="footnote.xml#tthFtNtADC" id="tthFrefADC"><math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msup><mrow></mrow><mrow><mn>32</mn></mrow>
</msup>
</mrow></math></a> of
a non-singular matrix, seems far more difficult to do, because the
algorithm is much more complicated, it also costs roughly <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msup><mrow><mi>N</mi></mrow><mrow><mn>3</mn></mrow>
</msup>
</mrow></math>
operations<a 
id="cost__computational__matrix_multiplication55343"></a><a 
id="matrix_multiplication_cost55344"></a>. These estimates are accurate only
to within a factor of two or so. But that is enough for most purposes.

<div class="p"><!----></div>
Inverting or multiplying random matrices using Octave on my laptop,
for <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>N</mi><mo>=</mo><mn>1000</mn></mrow></math> takes about 1 second. That seems amazingly fast to me,
because it corresponds to about 1 FLOP per nanosecond. But that's
about what can be achieved these days provided the cache contains
enough of the data. 

<div class="p"><!----></div>
Trouble is that if we are dealing with two-dimensions in space, each
of length <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>K</mi><mo>=</mo><mn>100</mn></mrow></math>, then the side of the matrix we have to invert is
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>J</mi><mo>=</mo>
<msup><mrow><mi>K</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
<mo>=</mo><mn>10000</mn></mrow></math>. A multiplication or inversion would take at least
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msup><mrow><mi>J</mi></mrow><mrow><mn>3</mn></mrow>
</msup>
<mo stretchy="false">/</mo>
<msup><mrow><mn>10</mn></mrow><mrow><mn>9</mn></mrow>
</msup>
<mo>=</mo><mn>1000</mn></mrow></math> seconds; that's a quarter of an hour. Waiting that
long is frustrating, and if many inversions are needed, time rapidly
runs out.

<div class="p"><!----></div>
Inverting the matrix representing a two-dimensional problem takes
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msup><mrow><mi>K</mi></mrow><mrow><mn>6</mn></mrow>
</msup>
</mrow></math> operations. And for a three-dimensional problem it's <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msup><mrow><mi>K</mi></mrow><mrow><mn>9</mn></mrow>
</msup>
</mrow></math>.
This rapid escalation of the cost means that one doesn't generally
approach multidimensional problems in terms of simplistic matrix
inversion. In particular, it is difficult to implement an implicit
scheme for advancing the diffusion equation. And it is probably more
realistic just to use an explicit scheme, recognizing and observing
the stability
limit, eq.&nbsp;(<a href="chap5.xml#FTCSstability">5.6</a>), on maximum time-step size.

<div class="p"><!----></div>

<h2>Worked Example: Crank Nicholson Matrices</h2>

<div class="p"><!----></div>
<a 
id="Crank-Nicholson_scheme55345"></a>Express the following parabolic partial differential equation 
in two space variables (<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>r</mi></mrow></math> and <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&phi;</mi></mrow></math>) and one time variable (<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>t</mi></mrow></math>)
as a matrix equation using the Crank-Nicholson scheme on uniform
grids.<a id="wk5eq1">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow>
<msup><mrow><mo>&nabla;</mo></mrow><mrow><mn>2</mn></mrow>
</msup>
<mi mathvariant="italic">&psi;</mi><mo>=</mo>
<mfrac><mrow><mn>1</mn></mrow>
<mrow>
<msup><mrow><mi>r</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>

<mfrac><mrow><mo>&part;</mo></mrow>
<mrow><mo>&part;</mo><mi>r</mi></mrow>
</mfrac>
<mrow><mo>(</mo>
<msup><mrow><mi>r</mi></mrow><mrow><mn>2</mn></mrow>
</msup>

<mfrac><mrow><mo>&part;</mo><mi mathvariant="italic">&psi;</mi></mrow>
<mrow><mo>&part;</mo><mi>r</mi></mrow>
</mfrac>
<mo>)</mo></mrow><mo>+</mo>
<mfrac><mrow><mn>1</mn></mrow>
<mrow>
<msup><mrow><mi>r</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>

<mfrac><mrow>
<msup><mrow><mo>&part;</mo></mrow><mrow><mn>2</mn></mrow>
</msup>
<mi mathvariant="italic">&psi;</mi></mrow>
<mrow><mo>&part;</mo>
<msup><mrow><mi mathvariant="italic">&phi;</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>
<mo>=</mo>
<mfrac><mrow><mo>&part;</mo><mi mathvariant="italic">&psi;</mi></mrow>
<mrow><mo>&part;</mo><mi>t</mi></mrow>
</mfrac>
<mo>.</mo></mrow>
    </mstyle></math></td><td width="1">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>19</mn><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>


Find the coefficients and layout of the required matrices if the boundary
conditions are <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mfrac><mrow><mo>&part;</mo><mi mathvariant="italic">&psi;</mi></mrow>
<mrow><mo>&part;</mo><mi>r</mi></mrow>
</mfrac>
<mo>=</mo><mn>0</mn></mrow></math> at <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>r</mi><mo>=</mo><mn>0</mn></mrow></math>,
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&psi;</mi><mo>=</mo><mn>0</mn></mrow></math> at <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>r</mi><mo>=</mo><mi>R</mi></mrow></math>, and periodicity in <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&phi;</mi></mrow></math>.

<div class="p"><!----></div>
<br />Let <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>k</mi></mrow></math> and <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>l</mi></mrow></math> be indices in the <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>r</mi></mrow></math> and <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&phi;</mi></mrow></math> coordinates, and let
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi><mi>r</mi></mrow></math> and <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi><mi mathvariant="italic">&phi;</mi></mrow></math> denote their grid spacings. The
finite difference form of the spatial derivative terms is
<a id="wk5eq2">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow>
<mtable displaystyle="true" align="right" width="80%">
<mtr><mtd columnalign="right" columnspan="1"><mrow>
<mfrac><mrow><mn>1</mn></mrow>
<mrow>
<msup><mrow><mi>r</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>

<mfrac><mrow><mo>&part;</mo></mrow>
<mrow><mo>&part;</mo><mi>r</mi></mrow>
</mfrac>

<msub><mrow><mo>(</mo>
<msup><mrow><mi>r</mi></mrow><mrow><mn>2</mn></mrow>
</msup>

<mfrac><mrow><mo>&part;</mo><mi mathvariant="italic">&psi;</mi></mrow>
<mrow><mo>&part;</mo><mi>r</mi></mrow>
</mfrac>
<mo>)</mo></mrow><mrow><mi>k</mi><mo>,</mo><mi>l</mi></mrow>
</msub>
</mrow>
</mtd><mtd columnalign="left">
<mrow><mo>=</mo></mrow>
</mtd><mtd columnalign="left">
<mrow>
<mfrac><mrow><mn>1</mn></mrow>
<mrow>
<msubsup><mrow><mi>r</mi></mrow><mrow><mi>k</mi> </mrow>
<mrow><mn>2</mn></mrow></msubsup>
</mrow>
</mfrac>
<mrow><mo>(</mo>
<msubsup><mrow><mi>r</mi></mrow><mrow><mi>k</mi><mo>+</mo><mn>1</mn><mo stretchy="false">/</mo><mn>2</mn> </mrow>
<mrow><mn>2</mn></mrow></msubsup>

<mfrac><mrow>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>+</mo><mn>1</mn><mo>,</mo><mi>l</mi></mrow>
</msub>
<mo>-</mo>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>,</mo><mi>l</mi></mrow>
</msub>
</mrow>
<mrow>
<msub><mrow><mi>r</mi></mrow><mrow><mi>k</mi><mo>+</mo><mn>1</mn></mrow>
</msub>
<mo>-</mo>
<msub><mrow><mi>r</mi></mrow><mrow><mi>k</mi></mrow>
</msub>
</mrow>
</mfrac>
<mo>-</mo>
<msubsup><mrow><mi>r</mi></mrow><mrow><mi>k</mi><mo>-</mo><mn>1</mn><mo stretchy="false">/</mo><mn>2</mn> </mrow>
<mrow><mn>2</mn></mrow></msubsup>

<mfrac><mrow>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>,</mo><mi>l</mi></mrow>
</msub>
<mo>-</mo>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>-</mo><mn>1</mn><mo>,</mo><mi>l</mi></mrow>
</msub>
</mrow>
<mrow>
<msub><mrow><mi>r</mi></mrow><mrow><mi>k</mi></mrow>
</msub>
<mo>-</mo>
<msub><mrow><mi>r</mi></mrow><mrow><mi>k</mi><mo>-</mo><mn>1</mn></mrow>
</msub>
</mrow>
</mfrac>
<mo>)</mo></mrow>
<mfrac><mrow><mn>1</mn></mrow>
<mrow>
<msub><mrow><mi>r</mi></mrow><mrow><mi>k</mi><mo>+</mo><mn>1</mn><mo stretchy="false">/</mo><mn>2</mn></mrow>
</msub>
<mo>-</mo>
<msub><mrow><mi>r</mi></mrow><mrow><mi>k</mi><mo>-</mo><mn>1</mn><mo stretchy="false">/</mo><mn>2</mn></mrow>
</msub>
</mrow>
</mfrac>
</mrow>
</mtd></mtr>
<mtr><mtd columnalign="right" columnspan="1"><mrow></mrow>
</mtd><mtd columnalign="left">
<mrow><mo>=</mo></mrow>
</mtd><mtd columnalign="left">
<mrow><mrow><mo>[</mo>
<msup><mrow><mo>(</mo>
<mfrac><mrow>
<msub><mrow><mi>r</mi></mrow><mrow><mi>k</mi></mrow>
</msub>
<mo>+</mo>
<mfrac><mrow><mi mathvariant="italic">&Delta;</mi><mi>r</mi></mrow>
<mrow><mn>2</mn></mrow>
</mfrac>
</mrow>
<mrow>
<msub><mrow><mi>r</mi></mrow><mrow><mi>k</mi></mrow>
</msub>
</mrow>
</mfrac>
<mo>)</mo></mrow><mrow><mn>2</mn></mrow>
</msup>
<mo stretchy="false">(</mo>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>+</mo><mn>1</mn><mo>,</mo><mi>l</mi></mrow>
</msub>
<mo>-</mo>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>,</mo><mi>l</mi></mrow>
</msub>
<mo stretchy="false">)</mo><mo>-</mo>
<msup><mrow><mo>(</mo>
<mfrac><mrow>
<msub><mrow><mi>r</mi></mrow><mrow><mi>k</mi></mrow>
</msub>
<mo>-</mo>
<mfrac><mrow><mi mathvariant="italic">&Delta;</mi><mi>r</mi></mrow>
<mrow><mn>2</mn></mrow>
</mfrac>
</mrow>
<mrow>
<msub><mrow><mi>r</mi></mrow><mrow><mi>k</mi></mrow>
</msub>
</mrow>
</mfrac>
<mo>)</mo></mrow><mrow><mn>2</mn></mrow>
</msup>
<mo stretchy="false">(</mo>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>,</mo><mi>l</mi></mrow>
</msub>
<mo>-</mo>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>-</mo><mn>1</mn><mo>,</mo><mi>l</mi></mrow>
</msub>
<mo stretchy="false">)</mo><mo>]</mo></mrow>
<mfrac><mrow><mn>1</mn></mrow>
<mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>r</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>
</mrow>
</mtd></mtr>
<mtr><mtd columnalign="right" columnspan="1"><mrow></mrow>
</mtd><mtd columnalign="left">
<mrow><mo>=</mo></mrow>
</mtd><mtd columnalign="left">
<mrow><mrow><mo>[</mo>
<msup><mrow><mo>(</mo><mn>1</mn><mo>+</mo>
<mfrac><mrow><mi mathvariant="italic">&Delta;</mi><mi>r</mi></mrow>
<mrow><mn>2</mn>
<msub><mrow><mi>r</mi></mrow><mrow><mi>k</mi></mrow>
</msub>
</mrow>
</mfrac>
<mo>)</mo></mrow><mrow><mn>2</mn></mrow>
</msup>

<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>+</mo><mn>1</mn><mo>,</mo><mi>l</mi></mrow>
</msub>
<mo>-</mo><mrow><mo>(</mo><mn>2</mn><mo>+</mo>
<mfrac><mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>r</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
<mrow><mn>2</mn>
<msubsup><mrow><mi>r</mi></mrow><mrow><mi>k</mi> </mrow>
<mrow><mn>2</mn></mrow></msubsup>
</mrow>
</mfrac>
<mo>)</mo></mrow>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>,</mo><mi>l</mi></mrow>
</msub>
<mo>+</mo>
<msup><mrow><mo>(</mo><mn>1</mn><mo>-</mo>
<mfrac><mrow><mi mathvariant="italic">&Delta;</mi><mi>r</mi></mrow>
<mrow><mn>2</mn>
<msub><mrow><mi>r</mi></mrow><mrow><mi>k</mi></mrow>
</msub>
</mrow>
</mfrac>
<mo>)</mo></mrow><mrow><mn>2</mn></mrow>
</msup>

<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>-</mo><mn>1</mn><mo>,</mo><mi>l</mi></mrow>
</msub>
<mo>]</mo></mrow>
<mfrac><mrow><mn>1</mn></mrow>
<mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>r</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>
</mrow>
</mtd></mtr>
<mtr><mtd columnalign="right" columnspan="1"><mrow>
<msub><mrow><mo> </mo>
<mfrac><mrow><mn>1</mn></mrow>
<mrow>
<msup><mrow><mi>r</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>

<mfrac><mrow>
<msup><mrow><mo>&part;</mo></mrow><mrow><mn>2</mn></mrow>
</msup>
<mi mathvariant="italic">&psi;</mi></mrow>
<mrow><mo>&part;</mo>
<msup><mrow><mi mathvariant="italic">&theta;</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>
<mo>|</mo></mrow><mrow><mi>k</mi><mo>,</mo><mi>l</mi></mrow>
</msub>
</mrow>
</mtd><mtd columnalign="left">
<mrow><mo>=</mo></mrow>
</mtd><mtd columnalign="left">
<mrow>
<mfrac><mrow><mn>1</mn></mrow>
<mrow>
<msubsup><mrow><mi>r</mi></mrow><mrow><mi>k</mi> </mrow>
<mrow><mn>2</mn></mrow></msubsup>
</mrow>
</mfrac>
<mrow><mo>(</mo>
<mfrac><mrow>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>,</mo><mi>l</mi><mo>+</mo><mn>1</mn></mrow>
</msub>
<mo>-</mo>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>,</mo><mi>l</mi></mrow>
</msub>
</mrow>
<mrow>
<msub><mrow><mi mathvariant="italic">&theta;</mi></mrow><mrow><mi>l</mi><mo>+</mo><mn>1</mn></mrow>
</msub>
<mo>-</mo>
<msub><mrow><mi mathvariant="italic">&theta;</mi></mrow><mrow><mi>l</mi></mrow>
</msub>
</mrow>
</mfrac>
<mo>-</mo>
<mfrac><mrow>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>,</mo><mi>l</mi></mrow>
</msub>
<mo>-</mo>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>,</mo><mi>l</mi><mo>-</mo><mn>1</mn></mrow>
</msub>
</mrow>
<mrow>
<msub><mrow><mi mathvariant="italic">&theta;</mi></mrow><mrow><mi>l</mi></mrow>
</msub>
<mo>-</mo>
<msub><mrow><mi mathvariant="italic">&theta;</mi></mrow><mrow><mi>l</mi><mo>-</mo><mn>1</mn></mrow>
</msub>
</mrow>
</mfrac>
<mo>)</mo></mrow>
<mfrac><mrow><mn>1</mn></mrow>
<mrow>
<msub><mrow><mi mathvariant="italic">&theta;</mi></mrow><mrow><mi>l</mi><mo>+</mo><mn>1</mn><mo stretchy="false">/</mo><mn>2</mn></mrow>
</msub>
<mo>-</mo>
<msub><mrow><mi mathvariant="italic">&theta;</mi></mrow><mrow><mi>l</mi><mo>-</mo><mn>1</mn><mo stretchy="false">/</mo><mn>2</mn></mrow>
</msub>
</mrow>
</mfrac>
</mrow>
</mtd></mtr>
<mtr><mtd columnalign="right" columnspan="1"><mrow></mrow>
</mtd><mtd columnalign="left">
<mrow><mo>=</mo></mrow>
</mtd><mtd columnalign="left">
<mrow><mrow><mo>(</mo>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>,</mo><mi>l</mi><mo>+</mo><mn>1</mn></mrow>
</msub>
<mo>-</mo><mn>2</mn>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>,</mo><mi>l</mi></mrow>
</msub>
<mo>+</mo>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>k</mi><mo>,</mo><mi>l</mi><mo>-</mo><mn>1</mn></mrow>
</msub>
<mo>)</mo></mrow>
<mfrac><mrow><mn>1</mn></mrow>
<mrow>
<msubsup><mrow><mi>r</mi></mrow><mrow><mi>k</mi> </mrow>
<mrow><mn>2</mn></mrow></msubsup>
<mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi mathvariant="italic">&theta;</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>
<mo>.</mo></mrow>
</mtd><mtd columnalign="right">&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;<mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>20</mn><mo stretchy="false">)</mo></mtd></mtr>
</mtable>
</mrow>
    </mstyle></math>
</td></tr></table>
<br />

Therefore, expressing the positions across the spatial grid in terms
of a single index <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>j</mi><mo>=</mo><mi>k</mi><mo>+</mo><mi>K</mi><mo>.</mo><mo stretchy="false">(</mo><mi>l</mi><mo>-</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></math> (where <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>K</mi></mrow></math> is the size of the
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>k</mi></mrow></math>-grid, and <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>L</mi></mrow></math> of the <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>l</mi></mrow></math>-grid), the differential operator
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msup><mrow><mo>&nabla;</mo></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow></math> becomes a matrix <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="bold">M</mi></mrow></math> multiplying the vector
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="bold-italic">&psi;</mi><mo>=</mo>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mi>j</mi></mrow>
</msub>
</mrow></math>, of the form
<a id="wk5eq3">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mi mathvariant="bold">M</mi><mo>=</mo><mrow><mo> </mo><mrow><mo>[</mo>
<mtable>
<mtr><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>f</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>e</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>b</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>b</mi></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd></mtr></mtable>

</mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>f</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>e</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>b</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>b</mi></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mrow><mo>}</mo>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi fontstyle="normal">Block</mi></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow><mi fontstyle="normal">size</mi></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow><mi>K</mi></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd></mtr></mtable>

<mo> </mo></mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>f</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>e</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>b</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>b</mi></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>f</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>e</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>b</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>b</mi></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd></mtr></mtable>

</mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>d</mi></mrow></mtd></mtr></mtable>

</mrow></mtd><mtd columnalign="center"><mrow>
<mtable>
<mtr><mtd columnalign="center"><mrow><mi>f</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>e</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>b</mi></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow><mo>.</mo></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>b</mi></mrow></mtd></mtr>
<mtr><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow></mrow></mtd><mtd columnalign="center"><mrow><mi>a</mi></mrow></mtd><mtd columnalign="center"><mrow><mi>c</mi></mrow></mtd></mtr></mtable>

</mrow></mtd></mtr></mtable>

<mo>]</mo></mrow><mo>}</mo></mrow>
<mtext>L blocks</mtext>
<mo>.</mo></mrow>
    </mstyle></math></td><td width="1">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>21</mn><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>


The explanation of this form is as follows.
The coefficients of a generic row corresponding to <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>r</mi></mrow></math>-position index <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>k</mi></mrow></math> are
<a id="wk5eq4">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mi>a</mi><mo>=</mo>
<msup><mrow><mo>(</mo><mn>1</mn><mo>-</mo>
<mfrac><mrow><mi mathvariant="italic">&Delta;</mi><mi>r</mi></mrow>
<mrow><mn>2</mn>
<msub><mrow><mi>r</mi></mrow><mrow><mi>k</mi></mrow>
</msub>
</mrow>
</mfrac>
<mo>)</mo></mrow><mrow><mn>2</mn></mrow>
</msup>

<mfrac><mrow><mn>1</mn></mrow>
<mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>r</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>
<mo>,</mo><mi>&emsp;</mi><mi>b</mi><mo>=</mo>
<msup><mrow><mo>(</mo><mn>1</mn><mo>+</mo>
<mfrac><mrow><mi mathvariant="italic">&Delta;</mi><mi>r</mi></mrow>
<mrow><mn>2</mn>
<msub><mrow><mi>r</mi></mrow><mrow><mi>k</mi></mrow>
</msub>
</mrow>
</mfrac>
<mo>)</mo></mrow><mrow><mn>2</mn></mrow>
</msup>

<mfrac><mrow><mn>1</mn></mrow>
<mrow><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>r</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>
<mo>,</mo><mi>&emsp;</mi><mi>d</mi><mo>=</mo>
<mfrac><mrow><mn>1</mn></mrow>
<mrow>
<msubsup><mrow><mi>r</mi></mrow><mrow><mi>k</mi> </mrow>
<mrow><mn>2</mn></mrow></msubsup>
<mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi mathvariant="italic">&phi;</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>
<mo>,</mo><mi>&emsp;</mi><mi>c</mi><mo>=</mo><mo>-</mo><mo stretchy="false">(</mo><mi>a</mi><mo>+</mo><mi>b</mi><mo>+</mo><mn>2</mn><mi>d</mi><mo stretchy="false">)</mo><mo>.</mo></mrow>
    </mstyle></math></td><td width="1">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>22</mn><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>


The periodic boundary 
conditions<a 
id="boundary_condition_periodic55346"></a><a 
id="periodic_boundary_condition55347"></a> in <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&phi;</mi></mrow></math> are implemented by the
appearance of off-diagonal, <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>d</mi></mrow></math>-type, blocks at the upper right and
lower left of the matrix. The <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>r</mi></mrow></math>-boundary conditions are the same for
all the blocks on the diagonal, the tridiagonal<a 
id="block_tridiagonal55348"></a> <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">acb</mi></mrow></math>-type blocks. At
the <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>r</mi><mo>=</mo><mi>R</mi></mrow></math> boundary, (which would be the bottom row of each block), the
condition <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&psi;</mi><mo>=</mo><mn>0</mn></mrow></math> means no contribution arises to the differential
operator from the <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&psi;</mi></mrow></math>-value there. The condition therefore allows
us simply to omit the <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>r</mi><mo>=</mo><mi>R</mi></mrow></math> row from the matrix, choosing the <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>k</mi><mo>=</mo><mi>K</mi></mrow></math>
index to refer to the position <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>r</mi><mo>=</mo><mi>R</mi><mo>-</mo><mi mathvariant="italic">&Delta;</mi><mi>r</mi></mrow></math>.  At the <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>r</mi><mo>=</mo><mn>0</mn></mrow></math> end (the
top row of each block), the condition <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mfrac><mrow><mo>&part;</mo><mi mathvariant="italic">&psi;</mi></mrow>
<mrow><mo>&part;</mo><mi>r</mi></mrow>
</mfrac>
<mo>=</mo><mn>0</mn></mrow></math> can be implemented in a properly centered way by choosing the
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>r</mi></mrow></math>-grid to be aligned to the half-integral positions.<a href="footnote.xml#tthFtNtADD" id="tthFrefADD"><math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msup><mrow></mrow><mrow><mn>33</mn></mrow>
</msup>
</mrow></math></a> In other words,
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi>r</mi></mrow><mrow><mn>0</mn></mrow>
</msub>
<mo>=</mo><mo>-</mo><mi mathvariant="italic">&Delta;</mi><mi>r</mi><mo stretchy="false">/</mo><mn>2</mn></mrow></math>, <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi>r</mi></mrow><mrow><mn>1</mn></mrow>
</msub>
<mo>=</mo><mo>+</mo><mi mathvariant="italic">&Delta;</mi><mi>r</mi><mo stretchy="false">/</mo><mn>2</mn></mrow></math>, <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi>r</mi></mrow><mrow><mi>n</mi></mrow>
</msub>
<mo>=</mo><mo stretchy="false">(</mo><mi>n</mi><mo>-</mo><mn>1</mn><mo stretchy="false">/</mo><mn>2</mn><mo stretchy="false">)</mo><mi mathvariant="italic">&Delta;</mi><mi>r</mi></mrow></math>. (The
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi>r</mi></mrow><mrow><mn>0</mn></mrow>
</msub>
</mrow></math> position values are not represented in the matrices.) In that
case, there is zero contribution to the difference scheme from the
first derivative at position <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi>r</mi></mrow><mrow><mn>1</mn><mo>-</mo><mn>1</mn><mo stretchy="false">/</mo><mn>2</mn></mrow>
</msub>
<mo>=</mo><mn>0</mn></mrow></math> (because <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msup><mrow><mi>r</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow></math> there is
zero), and the <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>r</mi></mrow></math>-second-derivative operator at <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>k</mi><mo>=</mo><mn>1</mn></mrow></math> becomes
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mo stretchy="false">(</mo><mn>1</mn><mo>+</mo>
<mfrac><mrow><mi mathvariant="italic">&Delta;</mi><mi>r</mi></mrow>
<mrow><mn>2</mn>
<msub><mrow><mi>r</mi></mrow><mrow><mn>1</mn></mrow>
</msub>
</mrow>
</mfrac>

<msup><mrow><mo stretchy="false">)</mo></mrow><mrow><mn>2</mn></mrow>
</msup>
<mo stretchy="false">(</mo>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mn>2</mn><mo>,</mo><mi>l</mi></mrow>
</msub>
<mo>-</mo>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mn>1</mn><mo>,</mo><mi>l</mi></mrow>
</msub>
<mo stretchy="false">)</mo><mo stretchy="false">/</mo><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>r</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
<mo>=</mo><mn>4</mn><mo stretchy="false">(</mo>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mn>2</mn><mo>,</mo><mi>l</mi></mrow>
</msub>
<mo>-</mo>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mn>1</mn><mo>,</mo><mi>l</mi></mrow>
</msub>
<mo stretchy="false">)</mo><mo stretchy="false">/</mo><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>r</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow></math>, giving rise to equal and
opposite coefficients <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>e</mi><mo>=</mo><mn>4</mn><mo stretchy="false">/</mo><mi mathvariant="italic">&Delta;</mi>
<msup><mrow><mi>r</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow></math>. The diagonal entry on those
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>k</mi><mo>=</mo><mn>1</mn></mrow></math> rows is minus the sum of all the other coefficients on the row:
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>f</mi><mo>=</mo><mo>-</mo><mo stretchy="false">(</mo><mi>e</mi><mo>+</mo><mn>2</mn><mi>d</mi><mo stretchy="false">)</mo></mrow></math>. 

<div class="p"><!----></div>
The Crank-Nicholson scheme for the differential equation time advance is then 
<a id="wk5eq6">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow>
<msup><mrow><mi mathvariant="bold-italic">&psi;</mi></mrow><mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow>
</msup>
<mo>-</mo>
<msup><mrow><mi mathvariant="bold-italic">&psi;</mi></mrow><mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow>
</msup>
<mo>=</mo>
<mfrac><mrow><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow>
<mrow><mn>2</mn></mrow>
</mfrac>
<mi mathvariant="bold">M</mi>
<msup><mrow><mi mathvariant="bold-italic">&psi;</mi></mrow><mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow>
</msup>
<mo>+</mo>
<mfrac><mrow><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow>
<mrow><mn>2</mn></mrow>
</mfrac>
<mi mathvariant="bold">M</mi>
<msup><mrow><mi mathvariant="bold-italic">&psi;</mi></mrow><mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow>
</msup>
<mo>,</mo></mrow>
    </mstyle></math></td><td width="1">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>23</mn><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>


which on rearrangement becomes
<a id="wk5eq7">
</a><br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow>
<msup><mrow><mi mathvariant="bold-italic">&psi;</mi></mrow><mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow>
</msup>
<mo>=</mo><mo stretchy="false">(</mo><mi mathvariant="bold">I</mi><mo>-</mo>
<mfrac><mrow><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow>
<mrow><mn>2</mn></mrow>
</mfrac>
<mi mathvariant="bold">M</mi>
<msup><mrow><mo stretchy="false">)</mo></mrow><mrow><mo>-</mo><mn>1</mn></mrow>
</msup>
<mo stretchy="false">(</mo><mi mathvariant="bold">I</mi><mo>+</mo>
<mfrac><mrow><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow>
<mrow><mn>2</mn></mrow>
</mfrac>
<mi mathvariant="bold">M</mi><mo stretchy="false">)</mo>
<msup><mrow><mi mathvariant="bold-italic">&psi;</mi></mrow><mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow>
</msup>
<mo>.</mo></mrow>
    </mstyle></math></td><td width="1">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mn>5</mn><mo>.</mo><mn>24</mn><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>



<div class="p"><!----></div>

<h2>Exercise 5. Diffusion and Parabolic Equations.</h2>

<div class="p"><!----></div>
<br /><br /> 1. Write a computer code to solve the diffusive equation
<br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow>
<mfrac><mrow><mo>&part;</mo><mi mathvariant="italic">&psi;</mi></mrow>
<mrow><mo>&part;</mo><mi>t</mi></mrow>
</mfrac>
<mo>=</mo><mi>D</mi>
<mfrac><mrow>
<msup><mrow><mo>&part;</mo></mrow><mrow><mn>2</mn></mrow>
</msup>
<mi mathvariant="italic">&psi;</mi></mrow>
<mrow><mo>&part;</mo>
<msup><mrow><mi>x</mi></mrow><mrow><mn>2</mn></mrow>
</msup>
</mrow>
</mfrac>
<mo>+</mo><mi>s</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow>
    </mstyle></math>
</td></tr></table>
<br />
 For constant, uniform diffusivity <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>D</mi></mrow></math> and constant
specified source <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>s</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow></math>. Use a uniform <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>x</mi></mrow></math>-mesh with <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi>N</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
</mrow></math> nodes.
Consider boundary conditions to be <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&psi;</mi></mrow></math> fixed, equal to <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mn>1</mn></mrow>
</msub>
</mrow></math>,
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mn>2</mn></mrow>
</msub>
</mrow></math> at the domain boundaries, <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>x</mi><mo>=</mo><mo>-</mo><mn>1</mn><mo>,</mo><mn>1</mn></mrow></math>, and the initial condition
to be <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&psi;</mi><mo>=</mo><mn>0</mn></mrow></math> at <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>t</mi><mo>=</mo><mn>0</mn></mrow></math>. 

<div class="p"><!----></div>
Construct a matrix <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="bold">G</mi><mo>=</mo>
<msub><mrow><mi>G</mi></mrow><mrow><mi mathvariant="italic">ij</mi></mrow>
</msub>
</mrow></math> such that <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="bold">G</mi><mi mathvariant="bold-italic">&psi;</mi><mo>=</mo>
<msup><mrow><mo>&nabla;</mo></mrow><mrow><mn>2</mn></mrow>
</msup>
<mi mathvariant="bold-italic">&psi;</mi></mrow></math>. Use it to implement the FTCS scheme 
<br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow>
<msup><mrow><mi mathvariant="bold-italic">&psi;</mi></mrow><mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow>
</msup>
<mo>=</mo><mo stretchy="false">(</mo><mi mathvariant="bold">I</mi><mo>+</mo><mi mathvariant="italic">&Delta;</mi><mi>t</mi><mi mathvariant="bold">G</mi><mo stretchy="false">)</mo>
<msup><mrow><mi mathvariant="bold-italic">&psi;</mi></mrow><mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow>
</msup>
<mo>+</mo><mi mathvariant="italic">&Delta;</mi><mi>t</mi><mi>&ensp;</mi><mi mathvariant="bold">s</mi><mo>,</mo></mrow>
    </mstyle></math>
</td></tr></table>
<br />

paying special attention to the boundary conditions.

<div class="p"><!----></div>
Solve the time-dependent problem for <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>D</mi><mo>=</mo><mn>1</mn></mrow></math>, <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>s</mi><mo>=</mo><mn>1</mn></mrow></math>, <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi>N</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
<mo>=</mo><mn>30</mn></mrow></math>,
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mn>1</mn></mrow>
</msub>
<mo>=</mo>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mn>2</mn></mrow>
</msub>
<mo>=</mo><mn>0</mn></mrow></math>, <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi>t</mi><mo>=</mo><mn>0</mn><mo>&rarr;</mo><mn>1</mn></mrow></math>, storing your results in a matrix <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&psi;</mi><mo stretchy="false">(</mo><mi>x</mi><mo>,</mo><mi>t</mi><mo stretchy="false">)</mo><mo>=</mo>
<msub><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow>
<msub><mrow><mi>j</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
<mo>,</mo>
<msub><mrow><mi>j</mi></mrow><mrow><mi>t</mi></mrow>
</msub>
</mrow>
</msub>
</mrow></math>, and
plotting that matrix at the end of the solution, for examination.

<div class="p"><!----></div>
Experiment with various <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow></math> to establish the dependence of the
accuracy and stability of your solution on <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow></math>. In particular,
<em>without finding an "exact" solution of the equation by any
  other method</em>,

<div class="p"><!----></div>
(i) Find experimentally the value of <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow></math> above which the scheme
becomes unstable.

<div class="p"><!----></div>
(ii) Estimate experimentally the fractional error arising from finite
time step duration in <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&psi;</mi><mo stretchy="false">(</mo><mi>t</mi><mo>=</mo><mn>1</mn><mo>,</mo><mi>x</mi><mo>=</mo><mn>0</mn><mo stretchy="false">)</mo></mrow></math> when using a <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow></math>
approximately equal to the maximum stable value.

<div class="p"><!----></div>
(iii) By varying <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi>N</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
</mrow></math>, estimate experimentally the fractional error
at <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msub><mrow><mi>N</mi></mrow><mrow><mi>x</mi></mrow>
</msub>
<mo>=</mo><mn>30</mn></mrow></math> arising from finite spatial differences. Which is more
significant, time or space difference error?

<div class="p"><!----></div>
<br /><br />2. Develop a modified version of your code to implement the
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&theta;</mi></mrow></math>-implicit scheme:
<br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow><mo stretchy="false">(</mo><mi mathvariant="bold">I</mi><mo>-</mo><mi mathvariant="italic">&Delta;</mi><mi>t</mi><mi mathvariant="italic">&theta;</mi><mi mathvariant="bold">G</mi><mo stretchy="false">)</mo>
<msup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow>
</msup>
<mo>=</mo><mo stretchy="false">(</mo><mi mathvariant="bold">I</mi><mo>+</mo><mi mathvariant="italic">&Delta;</mi><mi>t</mi><mo stretchy="false">(</mo><mn>1</mn><mo>-</mo><mi mathvariant="italic">&theta;</mi><mo stretchy="false">)</mo><mi mathvariant="bold">G</mi><mo stretchy="false">)</mo>
<msup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow>
</msup>
<mo>+</mo><mi mathvariant="italic">&Delta;</mi><mi>t</mi><mi>&ensp;</mi><mi>s</mi><mo>,</mo></mrow>
    </mstyle></math>
</td></tr></table>
<br />

in the form
<br />
<table width="100%"><tr><td align="center">
    <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mstyle displaystyle="true"><mrow>
<msup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow>
</msup>
<mo>=</mo>
<msup><mrow><mi mathvariant="bold">B</mi></mrow><mrow><mo>-</mo><mn>1</mn></mrow>
</msup>
<mi mathvariant="bold">C</mi>
<msup><mrow><mi mathvariant="italic">&psi;</mi></mrow><mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow>
</msup>
<mo>+</mo>
<msup><mrow><mi mathvariant="bold">B</mi></mrow><mrow><mo>-</mo><mn>1</mn></mrow>
</msup>
<mi mathvariant="italic">&Delta;</mi><mi>t</mi><mi>&ensp;&ensp;</mi><mi>s</mi></mrow>
    </mstyle></math>
</td></tr></table>
<br />


<div class="p"><!----></div>
(i) Experiment with different <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow></math> and <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&theta;</mi></mrow></math> values, for the same
time-dependent problem and find experimentally the value of <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&theta;</mi></mrow></math>
for which instability disappears for all <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow></math>. 

<div class="p"><!----></div>
(ii) Suppose we are limited to only 50 timesteps to solve over the time
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mn>0</mn><mo>&lt;</mo><mi>t</mi><mo>&le;</mo><mn>1</mn></mrow></math> so <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi><mi>t</mi><mo>=</mo><mn>0</mn><mo>.</mo><mn>02</mn></mrow></math>. Find experimentally the optimum value
of <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&theta;</mi></mrow></math> which produces the most accurate results.

<div class="p"><!----></div>
<br /><br />Submit the following as your solution for each part:

<ol type="1">
<li> Your code in a computer format that is capable of being
  executed, citing the language it is written in.
<div class="p"><!----></div>
</li>

<li> The requested experimental <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&Delta;</mi><mi>t</mi></mrow></math> and/or <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mi mathvariant="italic">&theta;</mi></mrow></math> values.
<div class="p"><!----></div>
</li>

<li> A plot of your solution for at least one of the cases.
<div class="p"><!----></div>
</li>

<li> A brief description of how you determined the accuracy of the result.
<div class="p"><!----></div>
</li>
</ol>

<div class="p"><!----></div>


<hr /><table width="100%"><tr><td>
 <a href="index.xml">HEAD</a></td><td align="right">
<a href="chap6.xml">NEXT
</a></td></tr></table>
</div></body></html>
