pivoting
Consider the linear system Ax = b using arithmetic with 4 digits:
−4
3.1 · 10 1 −3 −4.001246...
A= , b= , xexact =
1 1 −7 −2.99875...
Then l21 = 1/(3.1 · 10−4) ≈ 3.226 · 103 and thus
−4
1 0 3.1 · 10 1
L= , U = ,
3.226 · 103 1 0 −3.225 · 104
−3
y = L−1b = ,
9.671 · 103
1
(−3 − (−2.999)) −3.226
x = U −1y = 3.1·10−4 =
−2.999 −2.999
Observation:
during the back substition step all digits of x1 were lost due to cancellation
intuitive explanation:
the small pivot a11 leads to large intermediate results. The final result is of
moderate size, which is obtained by the subtraction of two numbers of similar size.
1
row pivoting
−4
3.1 · 10 1 −3 −4.001246...
A= , b= , xexakt =
1 1 −7 −2.99875...
interchanging first and second row of A yields:
1 1 −7
Aper = , bper = ,
3.1 · 10−4 1 −3
and thus
1 0 1 1
Lper = −4 , Uper = ,
3.1 · 10 1 0 1 − l21 = 0.9997
−7 −4.001
y = L−1 b
per per = , x = U −1
per y =
−2.998 −2.999
=⇒ correct result up to rounding errors
0 1
note: Lper Uper = P A for the permutation matrix P = . 2
1 0
example of an LU -factorization with row pivoting
0.5 2 8.75 11.25
A = A(1) = 1 2 3 , b(1) = 6 sol.: (1, 1, 1)>
0.5 5 6.5 12
seek pivot in the first column: =⇒ interchange 1st and 2nd row:
1 2 3 6
e(1)
A = 0.5 2 8.75 , eb(1) = 11.25
0.5 5 6.5 12
elimination step: l21 = 0.5, l31 = 0.5 and thus
1 2 3 6
!
1
A(2) = 0 1 7.25 , b(2) = 8.25 , L(1) = −0.5 1 ,
0 4 5 9 −0.5 1
3
example of an LU -factorization with row pivoting
1 2 3 6
!
1
(2) (2) (1)
A = 0 1 7.25 , b = 8.25 , L = −0.5 1 ,
0 4 5 9 −0.5 1
(2) (2)
seek pivot in 2nd column: compare merely a22 und a32 .
(2) (2)
Since |a32 | > |a22 | interchange the 2nd and 3rd row:
1 2 3 6
e(2)
A = 0 4 5 , eb(2) = 9 ,
0 1 7.25 8.25
elimination step: l32 = 41 . We obtain the final matrix U and L as:
1 2 3 6 1 0 0
U = A(3) = 0 4 5 , b(3) = 9 L = 0.5 1 0
0 0 6 6 0.5 0.25 1
4
computation of the permutation matrix P , such that P A = LU
track the row permutations: We expect that we have computed an
1. step: π = (1, 2, 3) LU -factorization of the following matrix:
2. step: π = (2, 1, 3) A2,:
Ae := A3,:
3. step: π = (2, 3, 1) A1,:
0 0 1 0 1 0
Pπ = 1 0 0 =⇒ P := Pπ−1 = Pπ> = 0 0 1
0 1 0 1 0 0
one checks that P A = A
e and
1 0 0 1 2 3 0 1 0 0.5 2 8.75
LU= 0.5 1 0 · 0 4 5 = 0 0 1 · 1 2 3 =P A
0.5 0.25 1 0 0 6 1 0 0 0.5 5 6.5
5
Gaussina eliminiation with (partial) pivoting
Input: invertible A ∈ Rn×n
Output: factorization PA = LU, where A is overwritten by U:
uij = aπ(i),j and P = P−1 >
π = Pπ is implicitly given by the vector π
π := (1, 2, . . . , n)
for k = 1 : (n − 1) do
seek p ∈ {k, . . . , n} s.t. |apk | ≥ |aik | ∀i ≥ k
interchange k-th and p-th entry of vector π
for i = (k + 1) : n do
a
lπ(i),k := a π(i),k
π(k),k
for j = (k + 1) : n do
aπ(i),j := aπ(i),j − lπ(i),k aπ(k),j
end for
end for
end for