Lesson 6 of 15

Triangular System Solvers

Triangular System Solvers

After LU decomposition, solving Ax=bAx = b reduces to two cheap triangular solves:

A=LU  LUx=bA = LU \ \Rightarrow \ LUx = b

  • Step 1: Ly=bLy = b (forward substitution)
  • Step 2: Ux=yUx = y (backward substitution)

Forward Substitution (Ly=bLy = b)

LL is lower triangular, so solve top-to-bottom:

y0=b0L00,yi=bij<iLijyjLiiy_{0} = \frac{b_{0}}{L_{00}}, \qquad y_{i} = \frac{b_{i} - \sum_{j < i} L_{ij}\, y_{j}}{L_{ii}}

Backward Substitution (Ux=yUx = y)

UU is upper triangular, so solve bottom-to-top:

xn1=yn1Un1,n1,xi=yij>iUijxjUiix_{n-1} = \frac{y_{n-1}}{U_{n-1,n-1}}, \qquad x_{i} = \frac{y_{i} - \sum_{j > i} U_{ij}\, x_{j}}{U_{ii}}

Example

L=(100210431),U=(211011002),b=(139)L = \begin{pmatrix} 1&0&0\\2&1&0\\4&3&1 \end{pmatrix}, \quad U = \begin{pmatrix} 2&1&1\\0&1&1\\0&0&2 \end{pmatrix}, \quad b = \begin{pmatrix} 1\\3\\9 \end{pmatrix}

Ly=b      y=(1.01.02.0),Ux=y      x=(0.00.01.0)Ly = b \;\ \Rightarrow \;\ y = \begin{pmatrix}1.0\\1.0\\2.0\end{pmatrix}, \qquad Ux = y \;\ \Rightarrow \;\ x = \begin{pmatrix}0.0\\0.0\\1.0\end{pmatrix}

Your Task

Implement forward_sub(L, b) and backward_sub(U, b), then combine them in solve_lu(L, U, b).

Python runtime loading...
Loading...
Click "Run" to execute your code.