Solving Linear System of Equations
The โUndoโ button for Linear Operations Matrix-vector multiplication: given the data ๐ and the operator ๐ฉ , we can find ๐ such that ๐ = ๐ฉ ๐ ๐ฉ ๐ ๐ transformation What if we know ๐ but not ๐ ? How can we โundoโ the transformation? ๐ฉ !๐ ๐ ๐ Solve ๐ฉ ๐ = ๐ for ๐ ?
Image Blurring Example โข Image is stored as a 2D array of real numbers between 0 and 1 (0 represents a white pixel, 1 represents a black pixel) โข ๐๐๐๐ has 40 rows of pixels and 100 columns of pixels โข Flatten the 2D array as a 1D array โข ๐ contains the 1D data with dimension 4000, โข Apply blurring operation to data ๐, i.e. ๐ = ๐ฉ ๐ where ๐ฉ is the blur operator and ๐ is the blurred image
Blur operator ๐ Blur operator ๐ฉ blurred "originalโ Blur operator ๐ image image (4000,4000) (4000,) (4000,) ๐ = ๐ฉ ๐
โUndoโ Blur to recover original image ๐ Assumptions: 1. we know the blur operator ๐ฉ Solve 2. the data set ๐ does not ๐ฉ ๐ = ๐ have any noise (โclean for ๐ dataโ ๐
โUndoโ Blur to recover original image ๐ + ๐ โ 10 !" (๐ โ 0,1 ) ๐ + ๐ โ 10 !# (๐ โ 0,1 ) Solve ๐ฉ ๐ = ๐ for ๐ How much noise can we add and still be able to recover meaningful information from the original image? At which point this inverse transformation fails? We will talk about sensitivity of the โundoโ operation later.
Linear System of Equations How do we actually solve ๐ฉ ๐ = ๐ ? We can start with an โeasierโ system of equationsโฆ Letโs consider triangular matrices (lower and upper): ๐ฆ ! ๐ !! 0 ๐ โฆ 0 ๐ฆ " ๐ "! ๐ "" ๐ " โฆ 0 = โฎ โฎ โฎ โฑ โฎ โฎ ๐ฆ # ๐ #! ๐ #" โฆ ๐ ## ๐ # ๐ฆ ! ๐ !! ๐ !" โฆ ๐ !# ๐ ๐ฆ " 0 ๐ "" โฆ ๐ "# ๐ " = โฎ โฑ โฎ โฎ โฎ โฎ ๐ฆ # โฆ ๐ ## ๐ # 0 0
Example: Forward-substitution for lower triangular systems ๐ฆ ! 2 0 0 0 2 ๐ฆ " 3 2 0 0 2 = ๐ฆ # 1 2 6 0 6 ๐ฆ $ 1 3 4 2 4 2 ๐ฆ $ = 2 โ ๐ฆ $ = 1 3 ๐ฆ $ + 2 ๐ฆ % = 2 โ ๐ฆ % = 2 โ 3 = โ0.5 2 1 ๐ฆ $ + 2 ๐ฆ % + 6 ๐ฆ & = 6 โ ๐ฆ & = 6 โ 1 + 1 = 1.0 6 1 ๐ฆ $ + 3 ๐ฆ % + 4 ๐ฆ & + 2 ๐ฆ # = 4 โ ๐ฆ & = 4 โ 1 + 1.5 โ 4 = 0.25 ๐ฆ ! 1 2 ๐ฆ " โ0.5 = ๐ฆ # 1.0 ๐ฆ $ 0.25
Triangular Matrices ๐ฆ ! ๐ !! ๐ !" โฆ ๐ !# ๐ ๐ฆ " โฆ ๐ "# 0 ๐ "" ๐ " = โฎ โฑ โฎ โฎ โฎ โฎ ๐ฆ # โฆ ๐ ## ๐ # 0 0 Recall that we can also write ๐ฝ ๐ = ๐ as a linear combination of the columns of ๐ฝ ๐ฆ ! ๐ : , 1 + ๐ฆ " ๐ : , 2 + โฏ + ๐ฆ % ๐ : , ๐ = ๐ Hence we can write the solution as ๐ '' ๐ฆ ' = ๐ ' ๐ฆ $ ๐ : , 1 + โฏ + ๐ฆ '!$ ๐ : , ๐ โ 1 = ๐ โ๐ฆ ' ๐ : , ๐ โ ๐ '!$,'!$ ๐ฆ '!$ = ๐ '!$ โ ๐ '!$,' ๐ฆ ' ๐ฆ $ ๐ : , 1 + โฏ + ๐ฆ '!% ๐ : , ๐ โ 2 = ๐ โ๐ฆ ' ๐ : , ๐ โ ๐ฆ '!$ ๐ : , ๐ โ 1 Or in general (backward-substitution for upper triangular systems): % ๐ & โ โ '(&)! ๐ &' ๐ฆ ' ๐ฆ % = ๐ % /๐ %% ๐ฆ & = , ๐ = ๐ โ 1, ๐ โ 2, โฆ , 1 ๐ &&
Triangular Matrices Forward-substitution for lower-triangular systems: ๐ฆ ! ๐ !! 0 ๐ โฆ 0 ๐ฆ " ๐ "! ๐ "" ๐ " โฆ 0 = โฎ โฎ โฎ โฑ โฎ โฎ ๐ฆ # ๐ #! ๐ #" โฆ ๐ ## ๐ # &*! ๐ &' ๐ฆ ' ๐ & โ โ '(! ๐ฆ ! = ๐ ! /๐ !! ๐ฆ & = , ๐ = 2,3, โฆ , ๐ ๐ &&
Cost of solving triangular systems % ๐ & โ โ '(&)! ๐ &' ๐ฆ ' ๐ฆ % = ๐ % /๐ %% ๐ฆ & = , ๐ = ๐ โ 1, ๐ โ 2, โฆ , 1 ๐ && ๐ divisions Computational complexity is ๐(๐ " ) ๐ ๐ โ 1 /2 subtractions/additions ๐ ๐ โ 1 /2 multiplications &*! ๐ &' ๐ฆ ' ๐ & โ โ '(! ๐ฆ ! = ๐ ! /๐ !! ๐ฆ & = , ๐ = 2,3, โฆ , ๐ ๐ && ๐ divisions Computational complexity is ๐(๐ " ) ๐ ๐ โ 1 /2 subtractions/additions ๐ ๐ โ 1 /2 multiplications
Linear System of Equations How do we solve ๐ฉ ๐ = ๐ when ๐ฉ is a non-triangular matrix? We can perform LU factorization: given a ๐ร๐ matrix ๐ฉ , obtain lower triangular matrix ๐ด and upper triangular matrix ๐ฝ such that ๐ฉ = ๐ด๐ฝ where we set the diagonal entries of ๐ด to be equal to 1. 1 0 ๐ !! ๐ !" โฆ ๐ !# ๐ต !! ๐ต !" โฆ ๐ต !# โฆ 0 ๐ "! 1 0 ๐ "" โฆ ๐ "# ๐ต "! ๐ต "" โฆ ๐ต "# โฆ 0 = โฎ โฎ โฑ โฎ โฎ โฎ โฑ โฎ โฑ โฎ โฎ โฎ ๐ #! ๐ #" โฆ ๐ ## ๐ต #! ๐ต #" โฆ ๐ต ## โฆ 1 0 0
LU Factorization โฆ ๐ !# โฆ ๐ต !# 1 0 ๐ !! ๐ !" ๐ต !! ๐ต !" โฆ 0 ๐ "! 1 0 ๐ "" โฆ ๐ "# ๐ต "! ๐ต "" โฆ ๐ต "# โฆ 0 = โฎ โฎ โฑ โฎ โฎ โฎ โฑ โฎ โฑ โฎ โฎ โฎ ๐ #! ๐ #" โฆ ๐ ## ๐ต #! ๐ต #" โฆ ๐ต ## โฆ 1 0 0 Assuming the LU factorization is know, we can solve the general system ๐ด๐ฝ ๐ = ๐ By solving two triangular systems: Solve for ๐ ๐ด ๐ = ๐ Forward-substitution with complexity ๐(๐ " ) Solve for ๐ ๐ฝ ๐ = ๐ Backward-substitution with complexity ๐(๐ " ) But what is the cost of the LU factorization? Is it beneficial?
2x2 LU Factorization (simple example) ๐ต !! ๐ต !" ๐ !! ๐ !" 1 0 = ๐ "! 1 ๐ต "! ๐ต "" 0 ๐ "" ๐ >> = ๐ต => /๐ >> ๐ต !! ๐ต !" ๐ !! ๐ !" = ๐ต "! ๐ต "" ๐ "! ๐ !! ๐ "! ๐ !" + ๐ "" 3) ๐ == = ๐ต == โ ๐ => ๐ >= 2) ๐ => = ๐ต => /๐ >> Seems quite simple! Can we generalize this for a ๐ร๐ matrix ๐ฉ ?
๐ $$ : scalar LU Factorization ๐ $% : row vector (1ร(๐ โ 1)) ๐ %$ : column vector (๐ โ 1)ร1 ๐ $$ ๐ $% ๐ฉ %% : matrix (๐ โ 1)ร(๐ โ 1) ๐ต !! ๐ต !" โฆ ๐ต !# ๐ !! ๐ !" ๐ฃ !! ๐ !" ๐ต "! ๐ต "" โฆ ๐ต "# 1 ๐ = = ๐ "! ๐ฉ "" ๐ ๐ฝ "" ๐ "! ๐ด "" โฎ โฎ โฑ โฎ ๐ต #! ๐ต #" โฆ ๐ต ## ๐ %$ 1) First row of ๐ฝ is ๐ฉ %% the first row of ๐ฉ ๐ !! ๐ !" ๐ฃ !! ๐ !" = ๐ "! ๐ฉ "" ๐ฃ !! ๐ "! ๐ "! ๐ !" + ๐ด "" ๐ฝ "" ๐ => = > ๐ฉ "" = ๐ "! ๐ !" + ๐ด "" ๐ฝ "" + !! ๐ => Known! 2) First column of ๐ด is the 3) ๐ด "" ๐ฝ "" = ๐ฉ "" โ ๐ "! ๐ !" first column of ๐ฉ / ๐ฃ >> Need another factorization!
๐ $$ : scalar LU Factorization ๐ $% : row vector (1ร(๐ โ 1)) ๐ %$ : column vector (๐ โ 1)ร1 ๐ $$ ๐ $% ๐ฉ %% : matrix (๐ โ 1)ร(๐ โ 1) ๐ต !! ๐ต !" โฆ ๐ต !# ๐ !! ๐ !" ๐ฃ !! ๐ !" ๐ต "! ๐ต "" โฆ ๐ต "# 1 ๐ = = ๐ "! ๐ฉ "" ๐ ๐ฝ "" ๐ "! ๐ด "" โฎ โฎ โฑ โฎ ๐ต #! ๐ต #" โฆ ๐ต ## ๐ %$ 1) First row of ๐ฝ is ๐ฉ %% the first row of ๐ฉ ๐ !! ๐ !" ๐ฃ !! ๐ !" = ๐ "! ๐ฉ "" ๐ฃ !! ๐ "! ๐ "! ๐ !" + ๐ด "" ๐ฝ "" 2) ๐ => = > Known! + !! ๐ => 3) ๐ต = ๐ด "" ๐ฝ "" = ๐ฉ "" โ ๐ "! ๐ !" First column of ๐ด is the first column of ๐ฉ / ๐ฃ >> Need another factorization!
Example 1) First row of ๐ฝ is the first row of ๐ฉ 2) First column of ๐ด is the first column of ๐ฉ / ๐ฃ >> 2 8 4 1 3) ๐ด "" ๐ฝ "" = ๐ฉ "" โ ๐ "! ๐ !" 3 3 1 2 ๐ต = 1 2 6 2 1 3 4 2
Example 2 8 4 1 1 0 0 0 2 8 4 1 3 3 0.5 0 0 0 0 0 0 0 1 2 ๐ต = ๐ด = ๐ฝ = 1 2 6 2 0 0 0 0 0 0 0.5 0 1 3 4 2 0.5 0 0 0 0 0 0 0 2 8 4 1 1 0 0 0 2 8 4 1 1 โ2 1 2.5 0.5 1 0 0 0 โ2 1 2.5 ๐ต = ๐ด = ๐ฝ = 1 โ2 0 0 0 0 0 0 4 1.5 0.5 1 1 โ1 2 1.5 0.5 0.5 0 0 0 0 0 0 1 0 0 0 2 8 4 1 2 8 4 1 0.5 1 0 0 1 โ2 1 2.5 0 โ2 1 2.5 ๐ด = ๐ต = ๐ฝ = 0.5 1 1 0 1 โ2 3 โ1 0 0 3 โ1 1 โ1 1.5 0.25 0.5 0.5 0.5 0 0 0 0 0 2 8 4 1 1 0 0 0 4 1 2 8 0 โ2 1 2.5 0.5 1 0 0 1 โ2 1 2.5 ๐ฝ = ๐ด = ๐ต = 0 0 3 โ1 0.5 1 1 0 1 โ2 3 โ1 0 0 0 0.75 0.5 0.5 0.5 1 1 โ1 1.5 0.75
Algorithm: LU Factorization of matrix A
Side note: Cost of LU factorization % ๐ = 1 $ 2 ๐ ๐ + 1 "#$ % ๐ & = 1 $ 6 ๐ ๐ + 1 2๐ + 1 "#$
Recommend
More recommend