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โ ๐ What happens if we add some noise to ๐ ?
โ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
Example: Backward-substitution for upper triangular systems ๐ฆ ! 2 8 4 2 2 ๐ฆ " 0 4 4 3 4 = ๐ฆ $ 0 0 6 2 4 ๐ฆ % 1 0 0 0 2 ๐ฆ # = 1 2 4 โ 2 1 = 1 2 ๐ฆ & = 6 2 4 โ 4 1 2 โ 3 1 = 1/2 = 1 2 ๐ฆ % = 4 4 8 2 โ 8 1 8 โ 4 1 2 โ 2 1 = โ2 2 ๐ฆ $ = 2 = โ1 2
LU Factorization 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
LU Factorization (with pivoting) ๐ฉ = ๐ธ๐ด๐ฝ Factorize: ๐ธ๐ด๐ฝ ๐ = ๐ ๐ ๐ด ๐ = ๐ธ ๐ผ ๐ (Solve for ๐ ) Forward-substitution ๐ฝ ๐ = ๐ (Solve for ๐ ) Backward-substitution
Example Assume the ๐ฉ = ๐ด๐ฝ factorization is known, yielding: 1 0 0 0 2 8 4 1 0.5 1 0 0 0 โ2 1 2.5 ๐ด = ๐ฝ = 0.5 1 1 0 0 0 3 โ1 2 0.5 1 0.5 0.5 0 0 0 0.75 2 Determine the solution ๐ that satisfies ๐ฉ๐ = ๐ , when ๐ = 1 4 ๐ด ๐ฝ๐ = ๐ ๐ First, solve the lower-triangular Then, solve the upper-triangular system ๐ด ๐ = ๐ for the variable ๐ system ๐ฝ ๐ = ๐ for the variable ๐ 1 0 0 0 2 2 8 4 1 2 0.5 1 0 0 0 โ2 1 2.5 2 1 ๐ = ๐ = 0.5 1 1 0 1 0 0 3 โ1 โ1 0.5 0.5 0.5 1 4 0 0 0 0.75 3
Methods to solve linear system of equations ๐ฉ ๐ = ๐ โข LU โข Cholesky โข Sparse
LU Factorization - Algorithm
2x2 LU Factorization (simple example) ๐ต !! ๐ต !" ๐ !! ๐ !" 1 0 = ๐ "! 1 ๐ต "! ๐ต "" 0 ๐ "" ๐ต !! ๐ต !" ๐ !! ๐ !" = ๐ต "! ๐ต "" ๐ "! ๐ !! ๐ "! ๐ !" + ๐ ""
๐ $$ : scalar LU Factorization ๐ $% : row vector (1ร(๐ โ 1)) ๐ %$ : column vector (๐ โ 1)ร1 ๐ $$ ๐ $% ๐ฉ %% : matrix (๐ โ 1)ร(๐ โ 1) ๐ต !! ๐ต !" โฆ ๐ต !# ๐ !! ๐ !" ๐ฃ !! ๐ !" ๐ต "! ๐ต "" โฆ ๐ต "# 1 ๐ = = ๐ "! ๐ฉ "" ๐ ๐ฝ "" ๐ "! ๐ด "" โฎ โฎ โฑ โฎ ๐ต #! ๐ต #" โฆ ๐ต ## ๐ %$ ๐ฉ %% ๐ !! ๐ !" ๐ฃ !! ๐ !" = ๐ "! ๐ฉ "" ๐ฃ !! ๐ "! ๐ "! ๐ !" + ๐ด "" ๐ฝ ""
๐ $$ : 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 8 4 1 3 3 1 2 2) First column of ๐ด is the first column of ๐ฉ / ๐ฃ == ๐ต = 1 2 6 2 3) ๐ด "" ๐ฝ "" = ๐ฉ "" โ ๐ "! ๐ !" 1 3 4 2 1 0 0 0 2 8 4 1 0.5 0 0 0 0 0 0 0 ๐ด = ๐ฝ = 0.5 0 0 0 0 0 0 0 0.5 0 0 0 0 0 0 0 2 3 3 4 2 0.5 2 6 2 4 ๐ด %% ๐ฝ %% = ๐ฉ %% โ ๐ %$ ๐ $% = โ 2 0.5 3 4 2 4 2 0.5 2 8 4 1 1 โ2 1 2.5 ๐ต = 1 โ2 4 1.5 1 โ1 2 1.5
2 8 4 1 1 โ2 1 2.5 ๐ต = 1 โ2 4 1.5 1 โ1 2 1.5 1 0 0 0 2 8 4 1 0.5 1 0 0 0 โ2 1 2.5 ๐ด = ๐ฝ = 0 0 0 0 0 0 0.5 1 0.5 0.5 0 0 0 0 0 0 ๐ด %% ๐ฝ %% = ๐ฉ %% โ ๐ %$ ๐ $% = 4 1.5 1 2.5 1.5 โ 2 0.5 1.25 2 8 4 1 1 โ2 1 2.5 ๐ต = 3 โ1 1 โ2 1 โ1 1.5 0.25
2 8 4 1 1 2.5 1 โ2 ๐ต = 1 โ2 3 โ1 1 โ1 1.5 0.25 1 0 0 0 2 8 4 1 0.5 1 0 0 0 โ2 1 2.5 ๐ด = ๐ฝ = 0.5 1 1 0 0 0 3 โ1 0.5 0 0.5 0.5 0 0 0 0 ๐ด %% ๐ฝ %% = ๐ฉ %% โ ๐ %$ ๐ $% = 0.25 โ โ0.5 = 0.75 1 0 0 0 2 8 4 1 0.5 1 0 0 0 โ2 1 2.5 ๐ด = ๐ฝ = 0.5 1 1 0 0 0 3 โ1 0.5 1 0.5 0.5 0 0 0 0.75
๐ $$ : 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!
Cost of solving linear system of equations
Cost of solving triangular systems * ๐ & โ โ '(&)! ๐ &' ๐ฆ ' ๐ฆ * = ๐ * /๐ ** ๐ฆ & = , ๐ = ๐ โ 1, ๐ โ 2, โฆ , 1 ๐ &&
Recommend
More recommend