Beruflich Dokumente
Kultur Dokumente
The above matrix may be denoted by [aij ]1im (or just by [aij ]).
1jn
The number aij is called the (i, j) entry. It lies in the i th row and j th
column.
Two matrices are equal if and only if they have the same size and the
corresponding entries are all equal.
For each m and n in IN, we use Mm,n for the set of all m n matrices.
The m n matrix whose entries are all zero is called the m n zero
matrix and is denoted 0m,n or simply 0.
1 2 1 0 3 2 1 1 3
For example, + = .
4 3 0 5 4 1 9 1 1
Note: We can only add two matrices if they are of the same size.
For example
2
2 1 3 5 = 2(2) + (1)5 + 3(3) = 4 5 + 9 = 0.
3
The (i, j) entry of AB is the inner product of the i th row of A with the j th
column of B.
1 3 2 1
2 0 1
Example: Let A = and B = 0 4 2 1 . Then A M2,3
3 1 1
2 0 2 3
and B M3,4 implies AB M2,4 and
1 3 2 1
2 0 1 0 6 2 1
AB = 0 4 2 1 =
3 1 1 5 5 10 7
2 0 2 3
while
5 6 1 2 23 34
BA = = 6 AB.
=
7 8 3 4 31 46
A matrix A = [aij ] is said tobe in echelon form if aij = 0 for i > j. For
1 2 2 3
example, 0 2 3 17 is in echelon form. A square matrix in
0 0 5 1
echelon form is called upper triangular.
3 Move to the second column. We want all the entries below a22 , that
is a32 , a42 , etc., to be zero. If necessary, interchange two rows (not
the first row) so that a22 6= 0.
4 Add multiples of the second row to ensure a32 , a42 , . . . , am2 are all
zero.
5 Move along the columns in this way until the matrix is in echelon
form.
0 1 2
Convert the matrix 3 1 3 to echelon form.
2 9 4
ax = b
a1 x1 + a2 x2 + + an xn = b
x2 + 2x3 = 3
x1 + 2x2 + 3x3 = 2
x1 2x2 2x3 = 0
x1 2x2 2x3 = 4
(i) 3x1 x2 x3 = 7
6x1 +x2 +x3 = 5.
x1 +x2 +x3 x4 =0
3x1 x2 x3 +2x4 =0
(ii)
4x1 +5x2 +x3 x4 =0
9x1 +6x2 +2x3 x4 =0
Exercise: Using Gaussian elimination and back substitution show that the
exact solution is x1 = 1, x2 = 7 and x3 = 1.
Remarks:
and so on.
Dana Mackey (DIT) Numerical Methods 19 / 56
The next step of the Gaussian elimination gives
x3 = 1.000 (exact)
x2 = 3.000 (relative error=57%)
and x1 = 2.715 (relative error=200%)!
The large errors obtained in the previous example were obtained because of
a cancellation (or loss of significance) error which occurred while working
on the first column. This introduced a small pivot, 0.0001, in the second
column which amplified the error. We cannot always avoid cancellation
errors but at least we can try to avoid the use of very small pivots.
and let i0 be the smallest value of i (i > j) for which this maximum is
achieved. Then interchange rows j and i0 .
In other words, while working on column j, look for the entry with the
largest absolute value below the pivot (Aij with i j). If this largest entry
appears in more than one row, take the one closest to the pivot row, i0 ,
and swap it with the current pivot row, j.
3x1 + x2 + 4x3 x4 = 7
2x1 2x2 x3 + 2x4 = 1
5x1 + 7x2 + 14x3 8x4 = 20
x1 + 3x2 + 2x3 + 4x4 = 4
and let j0 be the smallest j for which this maximum occurs. If j0 > i then
we interchange rows i and j0 .
Note: The scale vector S does not change during the Gaussian
elimination process.
3x1 + x2 + 4x3 x4 = 7
2x1 2x2 x3 + 2x4 = 1
5x1 + 7x2 + 14x3 8x4 = 20
x1 + 3x2 + 2x3 + 4x4 = 4
Recall that the exact solution of this system is (1,-1,1,-1). Calculate the
solution using Gaussian elimination with scaled partial pivoting and
compare the errors with those obtained using (simple) partial pivoting.
AX = B (5)
a11 a12 a13 1 0 0 u11 u12 u13
A = a21 a22 a23 = L U = l21 1 0 0 u22 u23
a31 a32 a33 l31 l32 1 0 0 u33
and solving this system for the entries lij and uij .
LUX = B
(1) LY = B; (2) UX = Y .
Each of these two systems is easy to solve since the matrix of coefficients
is either upper or lower triangular.
x1 + x2 x3 = 1
x1 + 2x2 2x3 = 5
2x1 + x2 + x3 = 10
L0 = LD and U 0 = D 1 U
A = L1 U1 = L2 U2
L1 = L2 D and U2 = DU1
R2 R2 4R1
R3 R3 5R1 R3 R3 3R2
Gaussian elimination:
1 0 0 0 4 12 8 4
0 1 0 0 1 7 18 9
L= 0 0 1 0
U =2 9 20 20
0 0 0 1 3 11 15 14
1 0 0 0 4 12 8 4
1/4 1 0 0 0 4 16 8 R2 14 R1
L= U =
1/2 0 1 0 0 3 16 18 R3 21 R1
3/4 0 0 1 0 2 9 11 R4 43 R1
Exercise 2 Calculate the inverse matrices M11 , M21 and the product
M11 M21 .
Example:
1 2 1 0 R2 R2 3R1 1 2 1 0 R1 R1 +R2 1 0 2 1
3 4 0 1 0 2 3 1 0 2 3 1
1
R2 2 R2 1 0 2 1
.
0 1 2 12
3
1 2 2 1
Hence the inverse of is 3 .
3 4 2 21
Note: A square matrix is invertible if and only if it does not contain a zero
on the main diagonal after it has been reduced to echelon form by
elementary row operations.
1 2 3
For example, the matrix A = 3 1 5 has no inverse!
2 3 2
The inverse of a matrix gives a new method for solving a system of linear
equations:
If AX = B then X = A1 B
provided A is invertible.
Exercise:
Solve the following system of equations by inverting the matrix of
coefficients.
x + 2y + 3z = 1
x y + 4z = 4
2x 2y + z = 8
Basic Idea:
AX = B (6)
X = TX + C
for some (new) n n matrix T , called the iteration matrix, and n-vector
C.
X (k+1) = TX (k) + C , k = 1, 2, . . .
This algorithm is terminated when two successive vectors X (k) and X (k+1)
are close enough in a sense which remains to be defined.
MX = NX + B or X = M 1 NX + M 1 B = TX + C
A = D (L + U)
where D is the diagonal part of A, while L and U are the strictly lower
and upper triangular parts of A, respectively. (So, according to the
definition above, we have M = D and N = L + U.)
Note that L and U in this context are not related at all to the matrices L,
U we would get from a LU-decomposition of A.
X (k+1) = TX (k) + C
where T = D 1 (L + U) and C = D 1 B.
A = (D L) U
We have obtained the same order of accuracy after only 6 steps therefore
the Gauss-Seidel method is faster than the Jacobi method.
A matrix is called strictly diagonally dominant if, for each row, the
absolute value of the diagonal element is strictly larger than the sum
of absolute values of the other elements.
If A is strictly diagonally dominant then both the Jacobi and
Gauss-Seidel algorithms will converge for any choice of the initial
vector approximation!
Note that strict diagonal dominance is a sufficient condition: it does
guarantee convergence but convergence might still occur even if the
condition is not satisfied.