Linear Algebra

Your Progress in this Chapter

0%

0 / 38 units completed

Chapter Overview

LU Facorization and FactorUpdate

Section 5.4 of 117 min2 code examples

1. LU Factorization: The Matrix Backbone

LU Factorization (Lower-Upper) is a method of decomposing a square matrix A into the product of two triangular matrices.

A=LUA = LU
  • L (Lower Triangular): Has 1s on the diagonal and non-zero elements below the diagonal. It stores the "elimination steps."
  • U (Upper Triangular): Has non-zero elements on and above the diagonal. It is the "reduced" form of the matrix.

Why use it? Instead of re-calculating the inverse of a matrix (which is computationally expensive), you solve Ly = b and Ux = y using forward and backward substitution.

Example 1C#

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Code is ready to run
OutputFrom the book
Matrix A:
 4   3   2 
 3   2   1 
 2   1   3 

Matrix L:
   1.0000    0.0000    0.0000
   0.5000    1.0000    0.0000
   0.7500    0.5000    1.0000

Matrix U:
   4.0000    3.0000    2.0000
   0.0000   -0.5000    2.0000
   0.0000    0.0000   -1.5000

Matrix P:0,	2,	1

2. Rank-1 Updates: Adjusting the Matrix

In many real-time systems (like structural engineering or machine learning), the matrix A changes slightly over time. A Rank-1 Update happens when we add the outer product of two vectors u and v to the original matrix:

A~=A+uvT\tilde{A} = A + uv^T

If we already have the LU factorization of A, it is wasteful to re-compute the LU factorization of \tilde{A} from scratch. Re-computing takes O(n^3) operations, while updating takes only O(n^2).

3. The Sherman-Morrison Formula

While LU handles the decomposition, the Sherman-Morrison formula tells us how the inverse changes after a Rank-1 update:

(A+uvT)1=A1A1uvTA11+vTA1u(A + uv^T)^{-1} = A^{-1} - \frac{A^{-1}uv^TA^{-1}}{1 + v^TA^{-1}u}

4. usage in SepalSolverPython

This script demonstrates a Rank-1 update and compares the result to the standard matrix addition.

Example 2C#

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Code is ready to run
OutputFrom the book
Matrix A:
 6   2   2 
 3   2   1 
 6  -1   3 

Matrix L:
   1.0000    0.0000    0.0000
   1.0000    1.0000    0.0000
   0.5000   -0.3333    1.0000

Matrix U:
   6.0000    2.0000    2.0000
   0.0000   -3.0000    1.0000
   0.0000    0.0000    0.3333

Matrix P:0,	2,	1
Updated Matrix A_tilde:
 6   2   2 
 3   2   1 
 6  -1   3 

Matrix L:
   1.0000    0.0000    0.0000
   1.0000    1.0000    0.0000
   0.5000   -0.3333    1.0000

Matrix U:
   6.0000    2.0000    2.0000
   0.0000   -3.0000    1.0000
   0.0000    0.0000    0.3333

Matrix P:0,	2,	1

5. Applications in Industry

  • Optimization (Quasi-Newton Methods): Used to update Hessian approximations (BFGS algorithm).
  • Power Systems: When a transmission line trips, the admittance matrix undergoes a Rank-1 or Rank-2 update.
  • Signal Processing: Adaptive filtering where the correlation matrix is updated with each new data point.