SlideShare a Scribd company logo
1 of 8
Download to read offline
EE103 (Spring 2004-05)


                       6. The LU factorization



• LU factorization without pivoting

• LU factorization with row pivoting

• effect of rounding error

• sparse LU factorization




                                                                             6–1




                          Matrix factorizations

LU factorization without pivoting

                                 A = LU

• L unit lower triangular, U upper triangular
• does not always exist (even if A is nonsingular)


LU factorization (with row pivoting)

                                 A = P LU

• P permutation matrix, L unit lower triangular, U upper triangular
• exists for all nonsingular A


The LU factorization                                                         6–2
Example

LU factorization (without pivoting) of
                                              
                                         8 2 9
                                     A= 4 9 4 
                                         6 7 9


write as A = LU with L unit lower triangular, U upper triangular
                                                   
                   8 2 9        1   0 0     u11 u12 u13
             A =  4 9 4  =  l21 1 0   0 u22 u23 
                   6 7 9       l31 l32 1     0   0 u33




The LU factorization                                                  6–3




• first row of U ,          first column of L:
                                                        
              8             2 9           1  0 0     8 2  9
             4             9 4  =  1/2 1 0   0 u22 u23 
              6             7 9         3/4 l32 1    0 0 u33

• second row of U , second column of L:
              9 4              1/2               1     0   u22 u23
                           −         2 9   =
              7 9              3/4               l32   1    0 u33
                                 8  −1/2           1   0     8 −1/2
                                           =
                               11/2  9/4         11/16 1     0 u33

• third row of U : u33 = 9/4 + 11/32 = 83/32

conclusion:
                                                  
                 8 2 9        1    0   0     8 2   9
           A =  4 9 4  =  1/2   1   0   0 8 −1/2 
                 6 7 9       3/4 11/16 1     0 0 83/32


The LU factorization                                                  6–4
Algorithm for LU factorization without pivoting

partition A, L, U as block matrices:

                a11 A12                   1   0                   u11 U12
   A=                          ,    L=              ,      U=
                A21 A22                  L21 L22                   0 U22

• a11 ∈ R, u11 ∈ R (other dimensions follow from block matrix notation)
• L22 unit lower-triangular, U22 upper triangular

determine L and U from A = LU , i.e.,

                       a11 A12            1   0         u11 U12
                                    =
                       A21 A22           L21 L22         0 U22
                                          u11         U12
                                    =
                                         u11L21 L21U12 + L22U22


The LU factorization                                                        6–5




recursive algorithm:

• determine first row of U and first column of L

                       u11 = a11,   U12 = A12,     L21 = (1/a11)A21


• factor the (n − 1) × (n − 1)-matrix

                  L22U22 = A22 − L21U12      (= A22 − (1/a11)A21A12)




cost: (2/3)n3 flops (no proof)




The LU factorization                                                        6–6
Not every nonsingular A can be factored as A = LU

                       
                                                  
               1 0  0        1   0 0     u11 u12 u13
           A= 0 0  2  =  l21 1 0   0 u22 u23 
               0 1 −1       l31 l32 1     0   0 u33

• first row of U ,             first column of L:
                                                            
               1               0     0        1 0 0      1 0   0
             0                0     2  =  0 1 0   0 u22 u23 
               0               1 −1           0 l32 1    0 0 u33

• second row of U , second column of L:

                                0  2        1     0   u22 u23
                                        =
                                1 −1        l32   1    0 u33

    u22 = 0, u23 = 2, l32 · 0 = 1 ?

The LU factorization                                                       6–7




                           LU factorization (with row pivoting)

if A ∈ Rn×n is nonsingular, then it can be factored as

                                         A = P LU

P is a permutation matrix, L is unit lower triangular, U is upper triangular

• not unique; in general there are several possible choices for P , L, U
• interpretation: applying P T re-orders or permutes the rows of A so that
  the re-ordered matrix has a factorization P T A = LU
• also known as Gaussian elimination with partial pivoting (GEPP)
• cost: 2n3/3 flops
• basis of standard method for solving Ax = b

we’ll skip the details of calculating P , L, U

The LU factorization                                                       6–8
example
                                              
  0 5 5       0 0 1      1   0   0     6   8     8
 2 9 0  =  0 1 0   1/3  1   0   0 19/3 −8/3 
  6 8 8       1 0 0      0 15/19 1     0   0  135/19

the factorization is not unique; we can factor the same matrix as
                                           
         0 5 5       0 1 0    1   0   0    2 9 0
        2 9 0  =  1 0 0  0   1   0  0 5 5 
         6 8 8       0 0 1    3 −19/5 1    0 0 27




The LU factorization                                                       6–9




                        Effect of rounding error

example
                             10−5 1    x1         1
                                             =
                               1  1    x2         0

• exact solution: x1 = −1/(1 − 10−5), x2 = 1/(1 − 10−5)
• A is a well-conditioned matrix (κ(A) = 2.6)

let us solve using LU factorization, rounding intermediate results to 4
significant decimal digits

we will do this for the two possible permutation matrices:

                              1 0                 0 1
                       P =            or    P =
                              0 1                 1 0



The LU factorization                                                      6–10
first choice of P : P = I (no pivoting)

                         10−5 1                  1 0              10−5    1
                                        =
                           1  1                 105 1               0  1 − 105

L, U rounded to 4 decimal significant digits

                                  1 0                             10−5  1
                         L=                     ,           U=
                                 105 1                              0  −105

forward substitution
                   1 0            z1                1
                                            =                =⇒       z1 = 1, z2 = −105
                  105 1           z2                0

backward substitution
             10−5  1                   x1                1
                                                =                     =⇒   x1 = 0, x2 = 1
               0  −105                 x2               −105

error in x1 is 100%

The LU factorization                                                                        6–11




second choice of P : interchange rows

                            1   1                     1   0        1     1
                                         =
                          10 −5
                                1                   10 −5
                                                          1        0 1 − 10−5

L, U rounded to 4 decimal significant digits

                                         1   0                          1 1
                             L=                         ,        U=
                                       10 −5
                                             1                          0 1

forward substitution
                         1   0         z1               0
                                                =                =⇒     z1 = 0, z2 = 1
                       10 −5
                             1         z2               1

backward substitution
                       1 1        x1                0
                                            =               =⇒        x1 = −1, x2 = 1
                       0 1        x2                1

error in x1, x2 is about 10−5

The LU factorization                                                                        6–12
conclusion:

• for some choices of P , small rounding errors in the algorithm cause very
  large errors in the solution

• this is called numerical instability: for the first choice of P , the
  algorithm is unstable; for the second choice of P , it is stable

• from numerical analysis: there is a simple rule for selecting a good
  (stable) permutation (we’ll skip the details, since we skipped the details
  of the factorization algorithm)

• in the example, the second permutation is better because it permutes
  the largest element (in absolute value) of the first column of A to the
  (1,1)-position




The LU factorization                                                     6–13




                       Sparse linear equations

if A is sparse (most elements are zero), it is usually factored as

                                A = P1LU P2

P1 and P2 are permutation matrices

• interpretation: we permute the rows and columns of A so that
   ˜     T     T                   ˜
  A = P1 AP2 has a factorization A = LU
• usually L and U are sparse: factorization and forward/backward
  substitution can be carried more efficiently
• choice of P1 and P2 greatly affects the sparsity of L and U : many
  heuristic methods for selecting good permutation matrices P1 and P2
• in practice: #flops   (2/3)n3; exact value is a complicated function of
  n, number of nonzero elements, sparsity pattern


The LU factorization                                                     6–14
Summary

different levels of understanding how linear equation solvers work

1. highest level: x=Ab costs (2/3)n3; more efficient than x=inv(A)*b
2. intermediate level: factorization step A = P LU ((2/3)n3 flops)
   followed by solve step (2n2 flops)
3. lowest level: details of factorization A = P LU



• for most applications level 1 is sufficient
• in some important applications (for example, multiple righthand sides)
  level 2 is useful
• level 3 is important for experts who write numerical libraries



The LU factorization                                                   6–15

More Related Content

What's hot

Unit i
Unit i Unit i
Unit i sunmo
 
Vectors and Matrices: basis and dimension
Vectors and Matrices: basis and dimensionVectors and Matrices: basis and dimension
Vectors and Matrices: basis and dimensionMarry Chriselle Rañola
 
M1 Prsolutions08
M1 Prsolutions08M1 Prsolutions08
M1 Prsolutions08guest91c200
 
Chapter 4: Vector Spaces - Part 2/Slides By Pearson
Chapter 4: Vector Spaces - Part 2/Slides By PearsonChapter 4: Vector Spaces - Part 2/Slides By Pearson
Chapter 4: Vector Spaces - Part 2/Slides By PearsonChaimae Baroudi
 
Eigenvalues and Eigenvectors (Tacoma Narrows Bridge video included)
Eigenvalues and Eigenvectors (Tacoma Narrows Bridge video included)Eigenvalues and Eigenvectors (Tacoma Narrows Bridge video included)
Eigenvalues and Eigenvectors (Tacoma Narrows Bridge video included)Prasanth George
 
Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...
Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...
Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...Kasun Ranga Wijeweera
 
Semana 22 funciones ii álgebra uni ccesa007
Semana 22 funciones ii  álgebra uni ccesa007Semana 22 funciones ii  álgebra uni ccesa007
Semana 22 funciones ii álgebra uni ccesa007Demetrio Ccesa Rayme
 
X2 T04 01 curve sketching - basic features/ calculus
X2 T04 01 curve sketching - basic features/ calculusX2 T04 01 curve sketching - basic features/ calculus
X2 T04 01 curve sketching - basic features/ calculusNigel Simmons
 
Folleto de matematicas, primero bgu, proyecto ebja. ing luis panimboza
Folleto de matematicas, primero bgu, proyecto ebja. ing luis panimbozaFolleto de matematicas, primero bgu, proyecto ebja. ing luis panimboza
Folleto de matematicas, primero bgu, proyecto ebja. ing luis panimbozaluisdin2729
 
Graph theoretic approach to solve measurement placement problem for power system
Graph theoretic approach to solve measurement placement problem for power systemGraph theoretic approach to solve measurement placement problem for power system
Graph theoretic approach to solve measurement placement problem for power systemIAEME Publication
 

What's hot (18)

Unit i
Unit i Unit i
Unit i
 
Unit ii
Unit iiUnit ii
Unit ii
 
Chapter 12
Chapter 12Chapter 12
Chapter 12
 
Vectors and Matrices: basis and dimension
Vectors and Matrices: basis and dimensionVectors and Matrices: basis and dimension
Vectors and Matrices: basis and dimension
 
Linear Algebra
Linear AlgebraLinear Algebra
Linear Algebra
 
M1 Prsolutions08
M1 Prsolutions08M1 Prsolutions08
M1 Prsolutions08
 
Chapter 4: Vector Spaces - Part 2/Slides By Pearson
Chapter 4: Vector Spaces - Part 2/Slides By PearsonChapter 4: Vector Spaces - Part 2/Slides By Pearson
Chapter 4: Vector Spaces - Part 2/Slides By Pearson
 
Eigenvalues and Eigenvectors (Tacoma Narrows Bridge video included)
Eigenvalues and Eigenvectors (Tacoma Narrows Bridge video included)Eigenvalues and Eigenvectors (Tacoma Narrows Bridge video included)
Eigenvalues and Eigenvectors (Tacoma Narrows Bridge video included)
 
Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...
Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...
Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...
 
Plano cartesiano
Plano cartesianoPlano cartesiano
Plano cartesiano
 
Linear (in)dependence
Linear (in)dependenceLinear (in)dependence
Linear (in)dependence
 
Semana 22 funciones ii álgebra uni ccesa007
Semana 22 funciones ii  álgebra uni ccesa007Semana 22 funciones ii  álgebra uni ccesa007
Semana 22 funciones ii álgebra uni ccesa007
 
Rpra1
Rpra1Rpra1
Rpra1
 
X2 T04 01 curve sketching - basic features/ calculus
X2 T04 01 curve sketching - basic features/ calculusX2 T04 01 curve sketching - basic features/ calculus
X2 T04 01 curve sketching - basic features/ calculus
 
Folleto de matematicas, primero bgu, proyecto ebja. ing luis panimboza
Folleto de matematicas, primero bgu, proyecto ebja. ing luis panimbozaFolleto de matematicas, primero bgu, proyecto ebja. ing luis panimboza
Folleto de matematicas, primero bgu, proyecto ebja. ing luis panimboza
 
Graph theoretic approach to solve measurement placement problem for power system
Graph theoretic approach to solve measurement placement problem for power systemGraph theoretic approach to solve measurement placement problem for power system
Graph theoretic approach to solve measurement placement problem for power system
 
ICAR-IFPRI- Instrumental Variable Regression- Devesh Roy, IFPRI
ICAR-IFPRI- Instrumental Variable Regression- Devesh Roy, IFPRIICAR-IFPRI- Instrumental Variable Regression- Devesh Roy, IFPRI
ICAR-IFPRI- Instrumental Variable Regression- Devesh Roy, IFPRI
 
ICAR-IFPRI - regression lecture 6 - Devesh Roy
ICAR-IFPRI - regression lecture 6 - Devesh RoyICAR-IFPRI - regression lecture 6 - Devesh Roy
ICAR-IFPRI - regression lecture 6 - Devesh Roy
 

Viewers also liked

Lu decomposition
Lu decompositionLu decomposition
Lu decompositiongilandio
 
Cholesky method and Thomas
Cholesky method and ThomasCholesky method and Thomas
Cholesky method and Thomasjorgeduardooo
 
BBC News: Responsive Web Design and Mustard
BBC News: Responsive Web Design and MustardBBC News: Responsive Web Design and Mustard
BBC News: Responsive Web Design and MustardKaelig Deloumeau-Prigent
 
Problem-based Based Learning Meets Web 2.0
Problem-based Based Learning Meets Web 2.0Problem-based Based Learning Meets Web 2.0
Problem-based Based Learning Meets Web 2.0annielibrarian
 
Darwinismo digital nova era do windows - ufv
Darwinismo digital   nova era do windows - ufvDarwinismo digital   nova era do windows - ufv
Darwinismo digital nova era do windows - ufvAndré Paulovich
 
Desenvolvendo para Windows Phone InfoTech 2013
Desenvolvendo para Windows Phone InfoTech 2013Desenvolvendo para Windows Phone InfoTech 2013
Desenvolvendo para Windows Phone InfoTech 2013André Paulovich
 
Presentation 'Employing a children's worker'
Presentation 'Employing a children's worker'Presentation 'Employing a children's worker'
Presentation 'Employing a children's worker'Katherine Lyddon
 
Violacion
ViolacionViolacion
Violacionbymafe
 
National ArithmetEQ Challenge Rules 2010
National ArithmetEQ Challenge Rules 2010National ArithmetEQ Challenge Rules 2010
National ArithmetEQ Challenge Rules 2010guest1b4853
 
England
EnglandEngland
Englanda n
 
شهاب الدين تكليف بور بوينت
شهاب الدين تكليف بور بوينتشهاب الدين تكليف بور بوينت
شهاب الدين تكليف بور بوينتguest89198655
 
什麼是貧窮
什麼是貧窮  什麼是貧窮
什麼是貧窮 Birgit Lin
 
Welcome to Community Church Toddlers
Welcome to Community Church ToddlersWelcome to Community Church Toddlers
Welcome to Community Church ToddlersKatherine Lyddon
 
水深之處福音網站介紹
水深之處福音網站介紹水深之處福音網站介紹
水深之處福音網站介紹tpech009
 

Viewers also liked (20)

Lu decomposition
Lu decompositionLu decomposition
Lu decomposition
 
Cholesky method and Thomas
Cholesky method and ThomasCholesky method and Thomas
Cholesky method and Thomas
 
BBC News: Responsive Web Design and Mustard
BBC News: Responsive Web Design and MustardBBC News: Responsive Web Design and Mustard
BBC News: Responsive Web Design and Mustard
 
18cm
18cm18cm
18cm
 
Problem-based Based Learning Meets Web 2.0
Problem-based Based Learning Meets Web 2.0Problem-based Based Learning Meets Web 2.0
Problem-based Based Learning Meets Web 2.0
 
Listening to Children
Listening to Children Listening to Children
Listening to Children
 
Darwinismo digital nova era do windows - ufv
Darwinismo digital   nova era do windows - ufvDarwinismo digital   nova era do windows - ufv
Darwinismo digital nova era do windows - ufv
 
Desenvolvendo para Windows Phone InfoTech 2013
Desenvolvendo para Windows Phone InfoTech 2013Desenvolvendo para Windows Phone InfoTech 2013
Desenvolvendo para Windows Phone InfoTech 2013
 
Children's voices
Children's voicesChildren's voices
Children's voices
 
Kimia1981
Kimia1981Kimia1981
Kimia1981
 
Presentation 'Employing a children's worker'
Presentation 'Employing a children's worker'Presentation 'Employing a children's worker'
Presentation 'Employing a children's worker'
 
Violacion
ViolacionViolacion
Violacion
 
National ArithmetEQ Challenge Rules 2010
National ArithmetEQ Challenge Rules 2010National ArithmetEQ Challenge Rules 2010
National ArithmetEQ Challenge Rules 2010
 
England
EnglandEngland
England
 
شهاب الدين تكليف بور بوينت
شهاب الدين تكليف بور بوينتشهاب الدين تكليف بور بوينت
شهاب الدين تكليف بور بوينت
 
什麼是貧窮
什麼是貧窮  什麼是貧窮
什麼是貧窮
 
Sfm – session 1
Sfm – session 1Sfm – session 1
Sfm – session 1
 
Social networking leaflet
Social networking leafletSocial networking leaflet
Social networking leaflet
 
Welcome to Community Church Toddlers
Welcome to Community Church ToddlersWelcome to Community Church Toddlers
Welcome to Community Church Toddlers
 
水深之處福音網站介紹
水深之處福音網站介紹水深之處福音網站介紹
水深之處福音網站介紹
 

Similar to LU Factorization Explained

Jif 315 lesson 1 Laplace and fourier transform
Jif 315 lesson 1 Laplace and fourier transformJif 315 lesson 1 Laplace and fourier transform
Jif 315 lesson 1 Laplace and fourier transformKurenai Ryu
 
presentation_laplace_transform_1553598871_41306.pptx
presentation_laplace_transform_1553598871_41306.pptxpresentation_laplace_transform_1553598871_41306.pptx
presentation_laplace_transform_1553598871_41306.pptxAmmarShr1
 
Laplace Transformation.ppt
Laplace Transformation.pptLaplace Transformation.ppt
Laplace Transformation.pptkhan_yu
 
MMAC presentation 16_09_20_20_41.pptx
MMAC presentation 16_09_20_20_41.pptxMMAC presentation 16_09_20_20_41.pptx
MMAC presentation 16_09_20_20_41.pptxJuber33
 
Laplace transform and its application
Laplace transform and its applicationLaplace transform and its application
Laplace transform and its applicationmayur1347
 
Algorithms of graph
Algorithms of graphAlgorithms of graph
Algorithms of graphgetacew
 
95414579 flip-flop
95414579 flip-flop95414579 flip-flop
95414579 flip-flopKyawthu Koko
 
Cpt 5 synthesis of linkages
Cpt 5 synthesis of linkagesCpt 5 synthesis of linkages
Cpt 5 synthesis of linkagesMohit Jain
 

Similar to LU Factorization Explained (17)

Jif 315 lesson 1 Laplace and fourier transform
Jif 315 lesson 1 Laplace and fourier transformJif 315 lesson 1 Laplace and fourier transform
Jif 315 lesson 1 Laplace and fourier transform
 
presentation_laplace_transform_1553598871_41306.pptx
presentation_laplace_transform_1553598871_41306.pptxpresentation_laplace_transform_1553598871_41306.pptx
presentation_laplace_transform_1553598871_41306.pptx
 
Laplace Transformation.ppt
Laplace Transformation.pptLaplace Transformation.ppt
Laplace Transformation.ppt
 
Laplace_Transform.ppt
Laplace_Transform.pptLaplace_Transform.ppt
Laplace_Transform.ppt
 
Laplace_Transform.ppt
Laplace_Transform.pptLaplace_Transform.ppt
Laplace_Transform.ppt
 
Unit5
Unit5Unit5
Unit5
 
MMAC presentation 16_09_20_20_41.pptx
MMAC presentation 16_09_20_20_41.pptxMMAC presentation 16_09_20_20_41.pptx
MMAC presentation 16_09_20_20_41.pptx
 
Theory of conformal optics
Theory of conformal opticsTheory of conformal optics
Theory of conformal optics
 
Laplace transform and its application
Laplace transform and its applicationLaplace transform and its application
Laplace transform and its application
 
Algorithms of graph
Algorithms of graphAlgorithms of graph
Algorithms of graph
 
95414579 flip-flop
95414579 flip-flop95414579 flip-flop
95414579 flip-flop
 
Cpt 5 synthesis of linkages
Cpt 5 synthesis of linkagesCpt 5 synthesis of linkages
Cpt 5 synthesis of linkages
 
IMT, col space again
IMT, col space againIMT, col space again
IMT, col space again
 
Week4
Week4Week4
Week4
 
Graph
GraphGraph
Graph
 
Graph
GraphGraph
Graph
 
Exercises with DFT+U
Exercises with DFT+UExercises with DFT+U
Exercises with DFT+U
 

More from oscar

Matrices and determinants
Matrices and determinantsMatrices and determinants
Matrices and determinantsoscar
 
Matrices and determinants
Matrices and determinantsMatrices and determinants
Matrices and determinantsoscar
 
Calculations of roots
Calculations of rootsCalculations of roots
Calculations of rootsoscar
 
Calculations of roots
Calculations of rootsCalculations of roots
Calculations of rootsoscar
 
Roots equations
Roots equationsRoots equations
Roots equationsoscar
 
Roots equations
Roots equationsRoots equations
Roots equationsoscar
 
Darcy´s law
Darcy´s lawDarcy´s law
Darcy´s lawoscar
 

More from oscar (8)

Lu
LuLu
Lu
 
Matrices and determinants
Matrices and determinantsMatrices and determinants
Matrices and determinants
 
Matrices and determinants
Matrices and determinantsMatrices and determinants
Matrices and determinants
 
Calculations of roots
Calculations of rootsCalculations of roots
Calculations of roots
 
Calculations of roots
Calculations of rootsCalculations of roots
Calculations of roots
 
Roots equations
Roots equationsRoots equations
Roots equations
 
Roots equations
Roots equationsRoots equations
Roots equations
 
Darcy´s law
Darcy´s lawDarcy´s law
Darcy´s law
 

LU Factorization Explained

  • 1. EE103 (Spring 2004-05) 6. The LU factorization • LU factorization without pivoting • LU factorization with row pivoting • effect of rounding error • sparse LU factorization 6–1 Matrix factorizations LU factorization without pivoting A = LU • L unit lower triangular, U upper triangular • does not always exist (even if A is nonsingular) LU factorization (with row pivoting) A = P LU • P permutation matrix, L unit lower triangular, U upper triangular • exists for all nonsingular A The LU factorization 6–2
  • 2. Example LU factorization (without pivoting) of   8 2 9 A= 4 9 4  6 7 9 write as A = LU with L unit lower triangular, U upper triangular      8 2 9 1 0 0 u11 u12 u13 A =  4 9 4  =  l21 1 0   0 u22 u23  6 7 9 l31 l32 1 0 0 u33 The LU factorization 6–3 • first row of U , first column of L:      8 2 9 1 0 0 8 2 9  4 9 4  =  1/2 1 0   0 u22 u23  6 7 9 3/4 l32 1 0 0 u33 • second row of U , second column of L: 9 4 1/2 1 0 u22 u23 − 2 9 = 7 9 3/4 l32 1 0 u33 8 −1/2 1 0 8 −1/2 = 11/2 9/4 11/16 1 0 u33 • third row of U : u33 = 9/4 + 11/32 = 83/32 conclusion:      8 2 9 1 0 0 8 2 9 A =  4 9 4  =  1/2 1 0   0 8 −1/2  6 7 9 3/4 11/16 1 0 0 83/32 The LU factorization 6–4
  • 3. Algorithm for LU factorization without pivoting partition A, L, U as block matrices: a11 A12 1 0 u11 U12 A= , L= , U= A21 A22 L21 L22 0 U22 • a11 ∈ R, u11 ∈ R (other dimensions follow from block matrix notation) • L22 unit lower-triangular, U22 upper triangular determine L and U from A = LU , i.e., a11 A12 1 0 u11 U12 = A21 A22 L21 L22 0 U22 u11 U12 = u11L21 L21U12 + L22U22 The LU factorization 6–5 recursive algorithm: • determine first row of U and first column of L u11 = a11, U12 = A12, L21 = (1/a11)A21 • factor the (n − 1) × (n − 1)-matrix L22U22 = A22 − L21U12 (= A22 − (1/a11)A21A12) cost: (2/3)n3 flops (no proof) The LU factorization 6–6
  • 4. Not every nonsingular A can be factored as A = LU      1 0 0 1 0 0 u11 u12 u13 A= 0 0 2  =  l21 1 0   0 u22 u23  0 1 −1 l31 l32 1 0 0 u33 • first row of U , first column of L:      1 0 0 1 0 0 1 0 0  0 0 2  =  0 1 0   0 u22 u23  0 1 −1 0 l32 1 0 0 u33 • second row of U , second column of L: 0 2 1 0 u22 u23 = 1 −1 l32 1 0 u33 u22 = 0, u23 = 2, l32 · 0 = 1 ? The LU factorization 6–7 LU factorization (with row pivoting) if A ∈ Rn×n is nonsingular, then it can be factored as A = P LU P is a permutation matrix, L is unit lower triangular, U is upper triangular • not unique; in general there are several possible choices for P , L, U • interpretation: applying P T re-orders or permutes the rows of A so that the re-ordered matrix has a factorization P T A = LU • also known as Gaussian elimination with partial pivoting (GEPP) • cost: 2n3/3 flops • basis of standard method for solving Ax = b we’ll skip the details of calculating P , L, U The LU factorization 6–8
  • 5. example       0 5 5 0 0 1 1 0 0 6 8 8  2 9 0  =  0 1 0   1/3 1 0   0 19/3 −8/3  6 8 8 1 0 0 0 15/19 1 0 0 135/19 the factorization is not unique; we can factor the same matrix as       0 5 5 0 1 0 1 0 0 2 9 0  2 9 0  =  1 0 0  0 1 0  0 5 5  6 8 8 0 0 1 3 −19/5 1 0 0 27 The LU factorization 6–9 Effect of rounding error example 10−5 1 x1 1 = 1 1 x2 0 • exact solution: x1 = −1/(1 − 10−5), x2 = 1/(1 − 10−5) • A is a well-conditioned matrix (κ(A) = 2.6) let us solve using LU factorization, rounding intermediate results to 4 significant decimal digits we will do this for the two possible permutation matrices: 1 0 0 1 P = or P = 0 1 1 0 The LU factorization 6–10
  • 6. first choice of P : P = I (no pivoting) 10−5 1 1 0 10−5 1 = 1 1 105 1 0 1 − 105 L, U rounded to 4 decimal significant digits 1 0 10−5 1 L= , U= 105 1 0 −105 forward substitution 1 0 z1 1 = =⇒ z1 = 1, z2 = −105 105 1 z2 0 backward substitution 10−5 1 x1 1 = =⇒ x1 = 0, x2 = 1 0 −105 x2 −105 error in x1 is 100% The LU factorization 6–11 second choice of P : interchange rows 1 1 1 0 1 1 = 10 −5 1 10 −5 1 0 1 − 10−5 L, U rounded to 4 decimal significant digits 1 0 1 1 L= , U= 10 −5 1 0 1 forward substitution 1 0 z1 0 = =⇒ z1 = 0, z2 = 1 10 −5 1 z2 1 backward substitution 1 1 x1 0 = =⇒ x1 = −1, x2 = 1 0 1 x2 1 error in x1, x2 is about 10−5 The LU factorization 6–12
  • 7. conclusion: • for some choices of P , small rounding errors in the algorithm cause very large errors in the solution • this is called numerical instability: for the first choice of P , the algorithm is unstable; for the second choice of P , it is stable • from numerical analysis: there is a simple rule for selecting a good (stable) permutation (we’ll skip the details, since we skipped the details of the factorization algorithm) • in the example, the second permutation is better because it permutes the largest element (in absolute value) of the first column of A to the (1,1)-position The LU factorization 6–13 Sparse linear equations if A is sparse (most elements are zero), it is usually factored as A = P1LU P2 P1 and P2 are permutation matrices • interpretation: we permute the rows and columns of A so that ˜ T T ˜ A = P1 AP2 has a factorization A = LU • usually L and U are sparse: factorization and forward/backward substitution can be carried more efficiently • choice of P1 and P2 greatly affects the sparsity of L and U : many heuristic methods for selecting good permutation matrices P1 and P2 • in practice: #flops (2/3)n3; exact value is a complicated function of n, number of nonzero elements, sparsity pattern The LU factorization 6–14
  • 8. Summary different levels of understanding how linear equation solvers work 1. highest level: x=Ab costs (2/3)n3; more efficient than x=inv(A)*b 2. intermediate level: factorization step A = P LU ((2/3)n3 flops) followed by solve step (2n2 flops) 3. lowest level: details of factorization A = P LU • for most applications level 1 is sufficient • in some important applications (for example, multiple righthand sides) level 2 is useful • level 3 is important for experts who write numerical libraries The LU factorization 6–15