Professional Documents
Culture Documents
T. Gambill
February ?, 2011
Forward Elimination
+ Backward substitution
= Naive Gaussian Elimination
Identify why our basic GE method is “naive”: identify where the errors
come from?
I division by zero, near-zero
Propose strategies to eliminate the errors
I partial pivoting, complete pivoting, scaled partial pivoting
Investigate the cost: does pivoting cost too much?
Try to answer “How accurately can we solve a system with or without
pivoting?”
I Analysis tools: norms, condition number, . . .
Example
0 2 3
A = 4 5 6
7 8 9
Example
1e − 10 2 3
A= 4 5 6
7 8 9
Solve:
2 4 −2 −2 −4
1 2 4 −3 5
A= b=
−3 −3 8 −2 7
−1 1 6 −3 7
Note that there is nothing ”wrong” with this system. A is full rank. The solution
exists and is unique.
Form the augmented system.
2 4 −2 −2 −4
1 2 4 −3 5
−3 −3 8 −2 7
−1 1 6 −3 7
Subtract 1/2 times the first row from the second row,
add 3/2 times the first row to the third row,
add 1/2 times the first row to the fourth row.
The result of these operations is:
2 4 −2 −2 −4
0 0 5 −2 7
0 3 5 −5 1
0 3 5 −4 5
The next stage of Gaussian elimination will not work because there is a zero
in the pivot location, ã22 .
Another zero has appear in the pivot position. Swap row 3 and row 4.
2 4 −2 −2 −4
0 3 5 −4 5
0 0 5 −2 7
0 0 0 −1 −4
Example
With Naive GE,
ε 1 x1 1
=
0 (1 − ε1 ) x2 2 − ε1
Solving for x1 and x2 using exact arithmetic we get
2 − 1/ε ε
x2 = =1+ ≈1−ε
1 − 1/ε ε−1
1 − x2 −1 ε
x1 = = =1− ≈1+ε
ε ε−1 ε−1
To avoid division by zero, swap the row having the zero pivot with one of the
rows below it.
Rows completed in
forward elimination.
To minimize the effect of roundoff, always choose the row that puts the largest
pivot element on the diagonal, i.e., find ip such that |aip ,i | = max(|ak,i |) for
k = i, . . . , n
2 4 −2 −2 −4
1 2 4 −3 5
A= b=
−3 −3 8 −2 7
−1 1 6 −3 7
Apply the elementary permutation matrix P1 to permute the first and third rows
of A.
0 0 1 0 2 4 −2 −2 −3 −3 8 −2
0 1 0 0 1 2 4 −3 1 2 4 −3
P1 ∗ A =
1
∗ =
0 0 0 −3 −3 8 −2 2 4 −2 −2
0 0 0 1 −1 1 6 −3 −1 1 6 −3
so we have,
P1 ∗ A ∗ x = P1 ∗ b
Apply the elementary permutation matrix P2 to permute the second and third
rows.
1 0 0 0 −3 −3 8 −2
0 0 1 0 0 1 20/3 −11/3
P2 ∗ M1 ∗ P1 ∗ A =
0 1 0 0∗ 0
2 10/3 −10/3
0 0 0 1 0 2 10/3 −7/3
−3 −3 8 −2
0 2 10/3 −10/3
=
0
1 20/3 −11/3
0 2 10/3 −7/3
so we have,
P2 ∗ M1 ∗ P1 ∗ A ∗ x = P2 ∗ M1 ∗ P1 ∗ b
M2 ∗ P2 ∗ M1 ∗ P1 ∗ A ∗ x = M2 ∗ P2 ∗ M1 ∗ P1 ∗ b
(M2 ∗ P2 ∗ M1 ∗ P1 ) ∗ A = U
or
A = P−1 −1 −1 −1
∗ U = L0 ∗ U
1 ∗ M1 ∗ P2 ∗ M2
0 0 0 1 0 0 0 1 0 0 0 1
then
P∗A = (P ∗ L 0 ) ∗ U
0 0 1 0 −2/3 1 0 0
1 0 0 0 −1/3 1/2 1 0
= ∗ ∗ U
0 1 0 0 1 0 0 0
0 0 0 1 1/3 1 0 1
1 0 0 0
−2/3 1 0 0∗U
=
−1/3 1/2 1 0
1/3 1 0 1
T. Gambill (UIUC) CS 357 February ?, 2011 18 / 55
Theorem LUP decomposition
Any non-singular matrix A may be decomposed as
L∗U =P∗A
Ax = b
LU = PA
5 L =
6
7 1.0000 0 0 0
8 -0.6667 1.0000 0 0
9 -0.3333 0.5000 1.0000 0
10 0.3333 1.0000 0.0000 1.0000
11
12 U =
13
19 P =
20
21 0 0 1 0
22 1 0 0 0
23 0 1 0 0
24 0 0 0 1
25
26 >> x=U\(L\(P*b))
27 x =
28 1.0000
29 2.0000
30 3.0000
31 4.0000
Rows completed in
forward elimination.
L∗U =P∗A∗Q
A ∗ x = ei i = 1, . . . , n
Ax1 = e1
Ax2 = e2
..
.
Axn = en
5 1.0000 0 0 0
6 0.7500 1.0000 0 0
7 0.5000 -0.2857 1.0000 0
8 0.2500 -0.4286 0.3333 1.0000
9 U =
10 8.0000 7.0000 9.0000 5.0000
11 0 1.7500 2.2500 4.2500
12 0 0 -0.8571 -0.2857
13 0 0 0 0.6667
14 P =
15 0 0 1 0
16 0 0 0 1
17 0 1 0 0
18 1 0 0 0
19 >> det(A)
20 ans =
21 8
det(L) = 1
y = −2x + 6
1
y= x+1
2
The matrix form of this equation is
2 1 x1 6
=
−1/2 1 x2 1
The equations for two parallel but not intersecting lines are
2 1 x1 6
=
2 1 x2 5
Here the coefficient matrix is singular (rank(A) = 1), and the system is
inconsistent
8 8
A and b are consistent A and b are inconsistent
6 A is nonsingular 6 A is singular
4 4
2 2
0 0
0 1 2 3 4 0 1 2 3 4
8 8
A and b are consistent A and b are consistent
6 A is singular 6 A is ill conditioned
4 4
2 2
0 0
0 1 2 3 4 0 1 2 3 4
Matrices:
kAxk
kAk = max = max kAuk
kxk
x,0 kuk=1
kAxkp
kAkp = max
x,0 kxkp
X m
kAk1 = max |aij |
16j6n
i=1
X n
kAk∞ = max |aij |
16i6m
j=1
T. Gambill (UIUC) CS 357 February ?, 2011 34 / 55
Properties of Vector Norms
Every vector norm must satisfy the following properties.
kxk > 0 for x , 0 (where 0 is the zero vector)
kαxk = |α|kxk for any scalar α ∈ R
kx + yk 6 kxk + kyk triangle inequality
The vector norm kxkp for p > 1, defined on the previous slide, satisfy the
following properties.
kxkq 6 kxkp for 1 6 p 6 q 6 +∞
and
√
kxk1 6 nkxk2
√
kxk2 6 nkxk∞
kxk1 6 nkxk∞
kAxk 6 kAkkxk
kABk 6 kAkkBk
kIk = 1 where I is the identity matrix
T. Gambill (UIUC) CS 357 February ?, 2011 36 / 55
Effect of Perturbations to b
kδxb k kδbk
6 kAkkA−1 k (1)
kxk kbk
kδxb k
1 only if kAkkA−1 k ∼ 1
kxk
Expand
Ax + Aδxb = b + δb
Subtract Ax from left side and b from right side since Ax = b
Aδxb = δb
1 kAk
6 (6)
kxk kbk
kδxb k kδbk
6 kAkkA−1 k (7)
kxk kbk
Summary:
If x + δxb is the exact solution to the perturbed system
A(x + δxb ) = b + δb
then
kδxb k kδbk
6 kAkkA−1 k
kxk kbk
Definition
The condition number of a matrix A is defined by κ(A) = ||A|| ∗ ||A−1 ||
(A + δA)(x + δxA ) = b
kδxA k
1 only if kAkkA−1 k ∼ 1
kx + δxA k
(A + δA)(x + δx) = b + δb
kAkkA−1 k
kδxk kδAk kδbk
6 +
kxk 1 − kAkkA−1 k kδAk
kAk
kAk kbk
kδxk
1 only if kAkkA−1 k ∼ 1
kx + δxk
1 6 κ(A) 6 ∞
so
kAxk
maxx,0 kxk
κ(A) = kAyk
miny,0 kyk
and thus the condition number κ measures the ratio of the largest stretching
to smallest stretching of any non-zero vector by the matrix.
T. Gambill (UIUC) CS 357 February ?, 2011 46 / 55
The Residual
r = b − Ax̂
kx̂ − xk krk
6 κ(A)
kxk kbk
An algorithm that gives the exact answer to a problem that is near to the
original problem is said to be backward stable. Algorithms that are not
backward stable will tend to amplify roundoff errors present in the original
data. As a result, the solution produced by an algorithm that is not backward
stable will not necessarily be the solution to a problem that is close to the
original problem.
Gaussian elimination without partial pivoting is not backward stable for
arbitrary A.
If A is symmetric and positive definite, then Gaussian elimination without
pivoting in backward stable.
exact
A - x = A−1 b
@
@
@
@
@
exact @
A+δA - x̂ = (A+δA)−1 b
R
@
r = b − Ax̂
||x̂ − x||∞ εm
. κ(A)
||x||∞ 2
≈ 16 − 10
≈6
r = b − Ax̂
5x = 20 =⇒ x = (5)−1 20
Ax = b =⇒ x = A−1 b