Lect 8
Lect 8
Rafikul Alam
Department of Mathematics
IIT Guwahati
Theorem (GEPP): Let A be an n × n matrix. Then there is a permutation matrix P such that
PA = LU
Here P2 is the permutation matrix that interchanges second row with n-th row of L−1
1 A.
R. Alam, IIT Guwahati (July-Nov 2023) MA423 MC
Gaussian elimination with partial pivoting
(1) (1)
For L2 := I + `2 e2> with `i2 := ai2 /an2 , i = 3 : n, we have
a11 a12 a13 · · · a1n
0 a(1) a(1) · · · (1)
ann
n2 n3
(2) (2)
−1 −1 0 a33 · · · a3n , aij(2) = aij(1) − `i2 a2j
(1)
. Cost: 2(n − 2)2 flops.
L2 P2 L1 P1 A = 0
.. .. .. ..
. . . .
(2) (2)
0 0 an3 · · · ann
where L is unit lower triangular, L̂j ’s are obtained from Lj ’s by permutating their multipliers
and P := Pn−1 Pn−2 · · · P2 P1 .
R. Alam, IIT Guwahati (July-Nov 2023) MA423 MC
Gaussian Elimination with Partial Pivoting (GEPP):
function [L, U, p] = GEPP(A);
% [L U, p] = GEPP(A) produces a unit
% lower triangular matrix L, an upper
% triangular matrix U and a permutation
% vector p, so that A(p,:)= LU.
[n, n] = size(A);
p = (1:n)’;
for k = 1:n-1
% find largest element in A(k:n,k)
[r, m] = max( abs( A(k:n,k) ) );
m = m+k-1;
if (m ∼=k) % swap rows
A([k m],:) = A([m k],:);
p([k m]) = p([m k]);
end
if (A(k,k) ∼= 0)
% compute multipliers for k-th step
A(k+1:n,k) = A(k+1:n,k)/A(k,k);
% update A(k+1:n,k+1:n)
j = k+1:n;
A(j,j) = A(j,j)-A(j,k)*A(k,j);
end
end
% strict lower triangle of A, plus I
L = eye(n,n)+ tril(A,-1);
U = triu(A); % upper triangle of A
The search for the largest entry in each column guarantees that the denominator A(k,k) in the
entries L(k+1:n,k) = A(k+1:n,k)/A(k,k) is at least as large as the numerators.
This ensures that |L(i, j)| ≤ 1 for all i, j. This is crucial for stability.
Theorem: Set L(`k ) := Lk . Then Pm L(`k ) = L(Pm `k )Pm for m > k. Hence
Proof: Note that the first m − 1 rows of Pm (Pm is used at the m-th step of
elimination) are the same as the first m − 1 rows of In . Hence ek> Pm = ek> for
k = 1 : m − 1.
R. Alam, IIT Guwahati (July-Nov 2023) MA423 MC
Permutated LU decomposition (PA = LU)
Since ek> Pm = ek> for m > k, we have
Pm L(`k ) = Pm (I + `k ek> ) = Pm + Pm `k ek> = Pm + Pm `k ek> Pm = L(Pm `k )Pm .
2n3
Total Cost: 3 flops.
GEPP is the standard method used in practice for solving a linear system. GEPP is a default
method in matlab for solution of a linear system. The command x = A\b solves Ax = b
using GEPP. The command [L, U, P] = lu(A) computes PA = LU.
• Examples exist for which GECP does much better than GEPP.
• Sparsity of A can be exploited by clever choice of row and column
interchanges (at possible detriment to stability).
• We still do not fully understand why GEPP and GECP work so well in the
presence of roundoff.
***