A7 Differential equations 581
In the Crank–Nicholson and in the implicit scheme we need to solve a tridiagonal
matrix equation. This is rather straightforward using back-substitution, and you may
want to use a library routine for this purpose. However, when periodic boundaries
are used, the matrix is no longer tridiagonal, but has elements in the upper right and
lower left corner:
H=
a 1 b 0 ... 0 b
ba 2 b ... 00
..
.
..
.
..
.
... ..
.
..
.
000 ... aN− 1 b
b 00 ... baN
, (A.78)
whereakandbare complex numbers. In order to solve this equation we use the
Sherman–Morrisonformula. This is a formula which gives the inverse of a matrix
of the form (in Dirac notation):
A+|u〉〈v|. (A.79)
Applied to our problem, the Sherman–Morrison formula leads to a prescription for
finding the solution of:
H|ψ〉=(A+|u〉〈v|)|ψ〉=|b〉. (A.80)
In fact we should find solutions to the two following problems:
A|φ〉=|b〉; (A.81a)
A|χ〉=|u〉. (A.81b)
It is then easily shown that
|ψ〉=|φ〉−
(
〈v|φ〉
1 +〈v|χ〉
)
|χ〉 (A.82)
gives the correct solution.
In order to apply this recipe to our problem, we take
|u〉=
−a 1
0
..
.
0
b
; |v〉=
1
0
..
.
0
(−b/a 1 )∗
. (A.83)
The complex conjugate in the last element of|v〉should not be forgotten! The matrix
Ais identical to the matrixHexcept for the upper left and lower right diagonal
elements. The first should be replaced bya′ 1 = 2 a 1 and the last bya′N=αN+b^2 /aN.
It can easily be checked that these values yield the correct matrix to appear in the