Mehmet Emre Tiryaki
Back to Notes

Linear Systems and LU

Matrix Facts

Aej=ajAe_j = a_j is the jj-th column, eiTAe_i^T A the ii-th row, eiTAej=Aije_i^T A e_j = A_{ij}. Column operations act from the right, e.g. A[e1+2e3    e2    e3    e4    e5]A[e_1 + 2e_3 \;\; e_2 \;\; e_3 \;\; e_4 \;\; e_5] adds twice the third column to the first in place, and row operations act from the left. (AB)T=BTAT(AB)^T = B^T A^T, (AB)−1=B−1A−1(AB)^{-1} = B^{-1}A^{-1}.

Triangular Systems

Forward substitution for lower triangular Lx=bLx = b,

x1=b1L11,x2=b2−L21x1L22,xi=bi−∑j<iLijxjLiix_1 = \frac{b_1}{L_{11}}, \qquad x_2 = \frac{b_2 - L_{21}x_1}{L_{22}}, \qquad x_i = \frac{b_i - \sum_{j < i} L_{ij}x_j}{L_{ii}}

and back substitution for upper triangular Ux=bUx = b from the last row up. A triangular matrix is singular iff some diagonal entry is 0. Cost ∑i=1n(2i−1)∼n2\sum_{i=1}^n (2i - 1) \sim n^2 flops.

LU Factorization

Adding aa times row jj to row ii is left multiplication by the unit lower triangular elementary matrix

Lij=I+aeiejT,Lij−1=I−aeiejTL_{ij} = I + a e_i e_j^T, \qquad L_{ij}^{-1} = I - a e_i e_j^T

Gaussian elimination (for 4×44 \times 4) gives U=L43L42L32L41L31L21AU = L_{43}L_{42}L_{32}L_{41}L_{31}L_{21}A, so A=LUA = LU with L=L21−1L31−1L41−1L32−1⋯L = L_{21}^{-1}L_{31}^{-1}L_{41}^{-1}L_{32}^{-1} \cdots unit lower triangular, its entries the row multipliers. To solve Ax=bAx = b:

  1. factor LU=ALU = A,
  2. forward substitution Lz=bLz = b,
  3. back substitution Ux=zUx = z.

Cost f=O(g)f = O(g) if lim⁡n→∞f(n)/g(n)<∞\lim_{n \to \infty} f(n)/g(n) < \infty, f∼gf \sim g if the limit is 1. A flop is one of +,−,×,÷,⋅+, -, \times, \div, \sqrt{\cdot}. Using ∑k=1nkp∼np+1p+1\sum_{k=1}^n k^p \sim \frac{n^{p+1}}{p+1},

∑j=1n−1(n−j)[2(n−j)+3]=∑k=1n−1k(2k+3)∼23n3\sum_{j=1}^{n-1} (n - j)[2(n - j) + 3] = \sum_{k=1}^{n-1} k(2k + 3) \sim \frac{2}{3}n^3

for LU, against ∼n2\sim n^2 per triangular solve. If the run time is t=Cnpt = Cn^p, then log⁡t=plog⁡n+log⁡C\log t = p \log n + \log C, so pp is the slope on a log-log plot.

Pivoting

Not every matrix has an LU factorization (a 0 pivot), and small pivots give large multipliers and subtractive cancellation. Partial pivoting swaps the row with the largest entry in absolute value into the pivot position at each step, giving

PA=LU,A=PTLU,Ax=b  ⟺  LUx=PbPA = LU, \qquad A = P^T LU, \qquad Ax = b \iff LUx = Pb

with all entries of LL bounded by 1 in absolute value. P=ei1e1T+⋯+einenTP = e_{i_1}e_1^T + \cdots + e_{i_n}e_n^T is a permutation matrix and P−1=PTP^{-1} = P^T. The pivot search is O(n−k)O(n - k) at step kk, O(n2)O(n^2) in total.

Matrix Structure

  • Strictly diagonally dominant ∣Aii∣>∑j≠i∣Aij∣|A_{ii}| > \sum_{j \neq i} |A_{ij}| for all ii: nonsingular, and LU exists without pivoting.
  • Banded Upper bandwidth bub_u if Aij=0A_{ij} = 0 for j−i>buj - i > b_u, lower bandwidth blb_l if Aij=0A_{ij} = 0 for i−j>bli - j > b_l, total bandwidth bu+bl+1b_u + b_l + 1 (bu=bl=1b_u = b_l = 1 is tridiagonal). Without pivoting LL and UU keep the bandwidths, the zeros are predictable, and LU costs O(bubln)O(b_u b_l n).
  • Symmetric AT=AA^T = A. LL and UU are not transposes, but A=LDLTA = LDL^T with DD diagonal, and using the symmetry it costs ∼13n3\sim \frac{1}{3}n^3 flops. In general it still needs (symmetric) pivoting.
  • Symmetric positive definite xTAx=∑i∑jAijxixj>0x^T A x = \sum_i \sum_j A_{ij}x_i x_j > 0 for all x≠0x \neq 0, all eigenvalues positive.

For SPD A=LDLTA = LDL^T, taking x=L−Tekx = L^{-T}e_k gives 0<xTAx=ekTDek=Dkk0 < x^T A x = e_k^T D e_k = D_{kk}, so D=(D1/2)2D = (D^{1/2})^2 with D1/2D^{1/2} the elementwise square root, and

A=LD1/2D1/2LT=RTR,R=D1/2LT upper triangularA = LD^{1/2}D^{1/2}L^T = R^T R, \qquad R = D^{1/2}L^T \text{ upper triangular}

(Cholesky). No pivoting is needed, ∼13n3\sim \frac{1}{3}n^3 flops.

Conditioning of Linear Systems

For vector and matrix norms, with induced norms, ∥A∥∞\|A\|_\infty the max row sum and ∥A∥1\|A\|_1 the max column sum. Perturb Ax=bAx = b to A(x+h)=b+dA(x + h) = b + d. Then ∥h∥≤∥A−1∥∥d∥\|h\| \le \|A^{-1}\|\|d\| and

∥h∥/∥x∥∥d∥/∥b∥≤∥A−1∥⋅∥A∥=κ(A)\frac{\|h\| / \|x\|}{\|d\| / \|b\|} \le \|A^{-1}\| \cdot \|A\| = \kappa(A)

The same κ(A)\kappa(A) bounds perturbations of AA, and κ(A)≥∥AA−1∥=∥I∥=1\kappa(A) \ge \|AA^{-1}\| = \|I\| = 1. If κ(A)=10t\kappa(A) = 10^t, about tt digits are lost. The residual r=b−Ax~r = b - A\tilde{x} is a backward error, and

∥x−x~∥∥x∥≤κ(A)∥r∥∥b∥\frac{\|x - \tilde{x}\|}{\|x\|} \le \kappa(A) \frac{\|r\|}{\|b\|}