208 6 Linear Algebra
derive the following equation for potentialVd^2 V
dx^2=
V√^3 /^2
x,
withV( 0 ) = 1.
In our case we will rewrite Poisson’s equation in terms of dimensionless variables. We can
then rewrite the equation as−u′′(x) =f(x), x∈( 0 , 1 ), u( 0 ) =u( 1 ) = 0.and we define the discretized approximation touasviwith grid pointsxi=ihin the interval
fromx 0 = 0 toxn+ 1 = 1. The step length or spacing is defined ash= 1 /(n+ 1 ). We have then
the boundary conditionsv 0 =vn+ 1 = 0. We approximate the second derivative ofuwith−
vi+ 1 +vi− 1 − 2 vi
h^2
=fi fori= 1 ,...,n,wherefi=f(xi). Show that you can rewrite this equation as a linear set of equations of the
form
Av=b ̃,
whereAis ann×ntridiagonal matrix which we rewrite asA=
2 −1 0 ... ... 0
−1 2 −1 0 ... ...
0 −1 2 −1 0 ...
... ... ... ... ...
0 ... −1 2 − 1
0 ... 0 −1 2
andb ̃i=h^2 fi.
In our case we will assume thatf(x) = ( 3 x+x^2 )ex, and keep the same interval and boundary
conditions. Then the above differential equation has an analytic solution given byu(x) =
x( 1 −x)ex(convince yourself that this is correct by inserting the solution in the Poisson
equation). We will compare our numerical solution with thisanalytic result in the next
exercise.- We can rewrite our matrixAin terms of one-dimensional vectorsa,b,cof length1 :n. Our
linear equation reads
A=
b 1 c 1 0 ... ... ...
a 2 b 2 c 2 ... ... ...
a 3 b 3 c 3 ... ...
... ... ... ... ...
an− 2 bn− 1 cn− 1
an bn
v 1
v 2
...
...
...
vn
=
b ̃ 1
b ̃ 2
...
...
...
b ̃n
.
A tridiagonal matrix is a special form of banded matrix whereall the elements are zero
except for those on and immediately above and below the leading diagonal. The above
tridiagonal system can be written asaivi− 1 +bivi+civi+ 1 =b ̃i,