Systems of Linear Equations: A X X X X A X X X X A X X X X
Systems of Linear Equations: A X X X X A X X X X A X X X X
Matrix representation:
Ax = b
a11 a12 a1n b1
a21 a22 a2n b2
A= b=
an1 an 2 ann bn
a11 0 0 x1 b1
a21 a22 0 x 2 b2
=
an1 an 2 ann x n bn
a11 x1 = b1 x1 = b1 /a11
b a21b1
2 a11
a21 x1 + a22 x 2 = b2 x2 =
a22
Goal of ‘Gaussian elimination’ method is to bring A into this form.
A(2) = L2 A(1) = L2 L1 A
1 0
0 1
L2 = 0 l32 1 where li2 = a (1)
i2 /a (1)
22
0 0
0 ln 2 0 0 1
1
l21 1 0
1 1 1
L = L1 L2 Ln 1 = l31 l32 1
l43
ln1 ln 2 lnn 1 1
Winter Semester 2006/7 Computational Physics I Lecture 8 8
Gauss Elimination Method
i.e., the matrix A has been decomposed (LU decomposition) into
an upper triangular and a lower triangular matrix. The solution is
now easy.
Ax = LUx = b First solve Ly = b, then Ux = y so
y1 = b1
y 2 = b2 l21 y1
then going from the bottom
yn
xn =
unn
y n 1 x n un 1,n
x n 1 =
un 1,n 1
a1 j
a1 j a1 j = j = 1,2,3,4
a11
Now we move on and make the second column look like the unit
matrix, and so on.
Winter Semester 2006/7 Computational Physics I Lecture 8 14
Gauss-Jordan Elimination
a2 j
1. a2 j = a22
a2 j
2. aij = aij ai2
a22 i = 1,3,4
b2
3. bi= bi ai2
a22 i = 1,3,4
= 0 a = 0
a21
22
a
= ai1
ai1 ai2
21 a = ai1 0 a = ai1
ai2 i = 1,3,4
22 22
1 a14
0 a13 x1 b1
0 x 2 b2
1 a23 a24
=
0 0 a33 a34
x 3 b3
0 x 4 b4
0 a43 a44
Test matrices:
1 1 1 1
1
4 1 1 1 1 1
2 3 4
1 1 1 1 1
1 1
A2 = 2 5
4 1 3 4
A1 = b1 = b2 =
1 1 1 1
1
1 1 4 1 1 3 4 5 6
1 1 1 1 1
1 1 1 4 1 4 5 6 7
AA 1 = E
now suppose the transformation of A to E consists
of the following steps :
T4 T3T2T1 A = E
Apply to the equation above
T4 T3T2T1 AA 1 = T4 T3T2T1 E
or
EA 1 = A 1 = T4 T3T2T1 E
Try different size square matrices. Should give us our initial vector
b. Find that start into mumerical problems with n=m=10.
Looks pretty good. However, there are cases where this simple
Gauss-Jordan technique does not work so well.
Winter Semester 2006/7 Computational Physics I Lecture 8 23
Pivoting
Partial pivoting - exchange rows in the region which have not yet
been transformed to the unit matrix.