Lec05 Systems
Lec05 Systems
5-1
x1
6
2 4 4
2x1 + 4x2 + 4x3 = 6
x1 + 5x2 + 6x3 = 4 or 1 5 6 x2 = 4
x + 3x + x = 8
x3
8
1 3 1
1
2
3
xi = det(Ai)/ det(A)
Ai = matrix obtained by replacing i-th column by b.
Note: This formula is useless in practice beyond n = 3
or n = 4.
Three situations:
1. The matrix A is nonsingular. There is a unique solution
given by x = A1b.
2. The matrix A is singular and b Ran(A). There are
infinitely many solutions.
3. The matrix A is singular and b
/ Ran(A). There are no
solutions.
5-3
Example:
(1) Let A =
2 0
0 4
b =
!
0.5
.
2
1
. A is non8
!
1
Example: (3) Let A same as above, but b =
.
1
Example:
0
0
4 4
x1
2
5 2 x2 = 1
0 2
x3
4
x3 = 2
x3 is known we can now solve the 2nd equation:
x2 = 1
ALGORITHM : 1
Back-Substitution algorithm
For i = n : 1 : 1 do:
t := bi
For j = i + 1 : n do
t := t (ai,i+1:n, xi+1:n)
t := t aij xj
= t an inner product
End
xi = t/aii
End
We must require that each aii 6= 0
Operation count?
Round-off error (use previous results for (, ))?
5-6
perturbed system.
Backward error not large in general. It is said that
triangular solve is backward stable.
5-7
systems.
5-8
x + 5x + 6x = 6
1
2
3
5-9
2
1
1
4
3
5
4 2
1 1
6 6
Example:
2
1
1
4
3
5
4 2
1 1
6 6
2
0
1
4
4 2
1 1 0
5
6 6
1
12
0
0
1
0
0
2
0 1
1
1
4
3
5
4 2
2
1 1 = 0
6 6
1
4
4 2
1 1 0
5
6 6
0
M = I veT1 with v = 12
0
5-10
4
3
5
4 2
x
1 1 into: 0
6 6
0
5-11
4
1
5
4 2
1 0
6 6
x
x
x
x x
x x
x x
4
1
3
4 2
1 0
4 7
Equivalent to
1
12
12
0
1
0
0
2
0 1
1
1
4
3
5
4 2
2
1 1 = 0
6 6
0
4
4 2
1 1 0
3
4 7
0
1
= 2
1
2
2
0
0
4
1
3
4 2
x
1 0 into: 0
4 7
0
x
x
0
x x
x x
x x
2
0
0
4
4 2
1 1 0
0
7 7
4
4 2
2
1 1 0 = 0
3
4 7
0
4
4 2
1 1 0
0
7 7
1
0
0
1
0 3
0
2
0 0
1
0
0
= 0
3
Pivot
Row k
Ak =
5-14
Gaussian Elimination
ALGORITHM : 2
1. For k = 1 : n 1 Do:
2.
For i = k + 1 : n Do:
3.
piv := aik /akk
4.
For j := k + 1 : n + 1 Do :
5.
aij := aij piv akj
6.
End
6.
End
7. End
Operation count:
T =
n1
X
n
X
[1 +
k=1 i=k+1
n+1
X
j=k+1
2] =
n1
X
n
X
(2(n k) + 3) = ...
k=1 i=k+1
The LU factorization
Now ignore the right-hand side from the transformations.
A M1 A 0 = A 1 M2 A 1 = A 2 M3 A 2 = A 3
Mn1An2 = An1 U
Last Ak U is an upper triangular matrix.
5-16
A0 =
=
=
=
=
M11A1
M11M21A2
M11M21M31A3
...
1
M11M21M31 Mn1
An1
1
L = M11M21M31 Mn1
5-17
How to get L?
1
L = M11M21M31 Mn1
Note Mk
5-19
for
k = 1, , n 1.
5-20
2 4
and different
6?
1
5-21
Gauss-Jordan Elimination
Principle of the method: We will now transform the
system into one that is even easier to solve than triangular
systems, namely a diagonal system. The method is very
similar to Gaussian Elimination. It is just a bit more
expensive.
Back to original system. Step 1 must transform:
2
1
1
5-22
4
3
5
4 2
x
1 1 into: 0
6 6
0
x
x
x
x x
x x
x x
4
1
5
4 2
1 0
6 6
2
Step 2: 0
0
4
1
3
2
0
0
4 2
x
1 0 into: 0
4 7
0
5-23
0
1
3
4
1
3
8 2
1 0
4 7
4 2
1 0
4 7
0
x
0
x x
x x
x x
0
1
0
8 2
1 0
7 7
0
1
0
0
1
0
0 10
1 0
7 7
8 2
x
1 0 into: 0
7 7
0
0
x
0
0 x
0 x
x x
row2 := row2 1
row3:
7
2
0
0
0
1
0
0 10
0 1
7 7
Solution: x3 = 1; x2 = 1; x1 = 5
5-24
ALGORITHM : 3
Gauss-Jordan elimination
1. For k = 1 : n Do:
2.
For i = 1 : n and if i! = k Do :
3.
piv := aik /akk
4.
For j := k + 1 : n + 1 Do :
5.
aij := aij piv akj
6.
End
6.
End
7. End
Operation count:
T =
n n1
X
X
k=1 i=1
[1 +
n+1
X
j=k+1
2] =
n1
X n1
X
k=1
(2(n k) + 3) =
i=1
5-25
5-26
2 2 4 2
2x1 + 2x2 + 4x3 = 2
x1 + x2 + x3 = 1 Or: 1 1 1 1
x + 4x + 6x = 5
1 4 6 5
1
2
3
row2 := row2 21 row1:
2
0
1
2
0
4
4 2
1 0
6 5
2
0
3
4 2
1 0
4 6
2
0
0
5-27
2
3
0
4 2
4 6
1 0
GvL 3.{1,3,5}; Heath 2; TB 7,20-21 Systems
ow
s
Row k
rm
Pe
Largest a ik
ut
er
Partial Pivoting
kk
General situation:
obtain
0
1
P =
0
0
0
0
0
1
1
0
0
0
0
0
1
0
0
1
P =
0
0
0
0
0
1
1
0
0
0
1
0
5
0
A=
9
1
3
0
2
6
0
4
3
7
1
5
4
8
?
2
6
5-31
0
1
P =
0
0
0
0
0
1
1
0
0
0
0
0
>> A = [ 1 2 3 4; 5 6 7 8; 9
0 -1 2 ; -3 4 -5 6]
5-32
Mk+1Ek+1Ak = Ak+1
where Ek+1 encodes a swap of row k+1 with row l > k+1.
1
Notes: (1) Ei
Mj
5-33
Result:
A0 =
=
=
=
=
=
E1M11A1
1M 1A2
E1M11E2M21A2 = E1E2M
1
2
1M 1E3M 1A3
E1E2M
1
2
3
1M
1M 1A3
E1E2E3M
1
2
3
...
1M
1M
1 M
1 An1
E1 En1 M
1
2
3
n1
In the end
P A = LU with P = En1 E1
5-34
Error Analysis
If no zero pivots are encountered during Gaussian elimi and U
5-35
and |U
| are not known in advance they can be
|L|
large.
What if partial pivoting is used?
Permutations introduce no errors. Equivalent to stan-
5-36