Systems of linear equations · Lecture 13

LU, Cholesky and Tridiagonal Systems

Elimination done once and reused: LU factorisation (Doolittle and Crout) for many right-hand sides, Cholesky for symmetric positive definite matrices at half the cost, and the Thomas algorithm that solves tridiagonal systems in linear time.

Md Mahbub E Noor · Assistant Professor
CSE-3107 Numerical Methods · B.Sc. 3rd Year 1st Semester
Department of CSE, University of Barishal

Why this lecture

The problem: same plate, a new temperature every minute

The top edge of the plate from Lecture 12 is heated and cooled during the day. The matrix AA never changes; only the right-hand side b\mathbf{b} does.

  • One reading per minute for a day: 1440 right-hand sides, one matrix
  • Gaussian elimination repeats the 23n3\tfrac23 n^3 elimination every time, although AA is the same
  • A realistic model with n=1000n = 1000 unknowns: 1440×0.671440 \times 0.67 s = 16 minutes
  • Can we do the expensive part once and reuse it?
top edgeT1T_1T2T_2T3T_3T4T_4
100°43.7556.2518.7531.25
80°????
60°????
Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
2 / 25

Today's goals

  • Explain why Gaussian elimination is a factorisation A=LUA = LU
  • Compute LL and UU by Doolittle and Crout, and solve with forward and back substitution
  • Recognise symmetric positive definite matrices and factor them by Cholesky, A=LLTA = LL^T
  • Solve tridiagonal systems with the Thomas algorithm in O(n)O(n) operations
  • Choose the cheapest safe solver for a given matrix
Last time

Gaussian elimination with partial pivoting: 23n3\tfrac23 n^3 for each system.


Today

Factor once, solve many times; exploit symmetry and zeros.

Systems of linear equations · you are hereBuilds on: L12
Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
3 / 25
Start here

The idea in one picture

A (full)=L (lower)×U (upper)done once(the costly part)bsolve L y = bysolve U x = yxfor every new right-hand side b: two easy triangular solvesnew b? reuse L and U
A full matrix is hard to solve with.Split it once into a lower triangle L times an upper triangle U.Now take a right-hand side b.Triangle 1: solve L y = b from the top down (easy).Triangle 2: solve U x = y from the bottom up (easy).Another b? Skip the splitting: L and U are reused.
In plain words
  • Elimination does the same work every time, even if only b changes
  • Do the hard part once: split A into two triangles L and U
  • Every new b then needs only two quick triangular solves
New words today
factorisation
writing a matrix as a product of simpler ones
L, U
lower and upper triangular factors
forward substitution
solving from the top down
positive definite (SPD)
symmetric, and xᵀAx > 0 for every x ≠ 0
tridiagonal
non-zeros only on three diagonals
Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
4 / 25

The idea: elimination is a factorisation

Keep the multipliers in L; the eliminated matrix is U(211433879)⏟A=(100210431)⏟L (multipliers)(211011002)⏟U\underbrace{\begin{pmatrix} 2 & 1 & 1 \\ 4 & 3 & 3 \\ 8 & 7 & 9\end{pmatrix}}_{A} = \underbrace{\begin{pmatrix} 1 & 0 & 0 \\ 2 & 1 & 0 \\ 4 & 3 & 1\end{pmatrix}}_{L \text{ (multipliers)}}\underbrace{\begin{pmatrix} 2 & 1 & 1 \\ 0 & 1 & 1 \\ 0 & 0 & 2\end{pmatrix}}_{U}
Then Ax = b splits into two triangular solvesLy=b    (forward),Ux=y    (backward)L\mathbf{y} = \mathbf{b} \;\;(\text{forward}), \qquad U\mathbf{x} = \mathbf{y} \;\;(\text{backward})
  • lik=mikl_{ik} = m_{ik}: exactly the multipliers of Lecture 12
  • Factor once: 23n3\tfrac23 n^3 operations
  • Each new b\mathbf{b}: two triangular solves, 2n22n^2 operations
  • n=1000n = 1000: 2 ms per right-hand side instead of 0.67 s
Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
5 / 25
The method, step by step

Doolittle's LU method, step by step

Doolittle: LL has ones on its diagonal. Compute row ii of UU, then column ii of LL, for i=1,2,…,ni = 1, 2, \dots, n.

  1. Row ii of UU:   uij=aij−∑k<ilikukj\;u_{ij} = a_{ij} - \sum_{k<i} l_{ik}u_{kj} for j≥ij \ge i
  2. Column ii of LL:   lji=(aji−∑k<iljkuki)/uii\;l_{ji} = \big(a_{ji} - \sum_{k<i} l_{jk}u_{ki}\big)/u_{ii} for j>ij > i (needs uii≠0u_{ii} \ne 0)
  3. Forward: yi=bi−∑k<ilikyky_i = b_i - \sum_{k<i} l_{ik}y_k
  4. Backward: xi=(yi−∑k>iuikxk)/uiix_i = \big(y_i - \sum_{k>i} u_{ik}x_k\big)/u_{ii}
  5. For another b\mathbf{b}, repeat only steps 3 and 4

Same operations as elimination, organised so that each entry of LL and UU is computed once.

Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
6 / 25

Problem 1: Doolittle LU, then solve

Factor A=(211433879)A = \begin{pmatrix} 2 & 1 & 1 \\ 4 & 3 & 3 \\ 8 & 7 & 9\end{pmatrix} as LULU and solve Ax=(3,7,19)TA\mathbf{x} = (3, 7, 19)^T.
1
Row 1 of UU: (2,1,1)(2, 1, 1). Column 1 of LL: l21=4/2=2l_{21} = 4/2 = 2, l31=8/2=4l_{31} = 8/2 = 4
2
u22=3−2(1)=1u_{22} = 3 - 2(1) = 1, u23=3−2(1)=1u_{23} = 3 - 2(1) = 1;   l32=(7−4(1))/1=3\;l_{32} = (7 - 4(1))/1 = 3;   u33=9−4(1)−3(1)=2\;u_{33} = 9 - 4(1) - 3(1) = 2
3
Forward Ly=bL\mathbf{y} = \mathbf{b}: y1=3y_1 = 3, y2=7−2(3)=1y_2 = 7 - 2(3) = 1, y3=19−4(3)−3(1)=4y_3 = 19 - 4(3) - 3(1) = 4
4
Backward Ux=yU\mathbf{x} = \mathbf{y}: x3=4/2=2x_3 = 4/2 = 2, x2=1−2=−1x_2 = 1 - 2 = -1, x1=(3−(−1)−2)/2=1x_1 = (3 - (-1) - 2)/2 = 1
L=(100210431)L = \begin{pmatrix} 1 & 0 & 0 \\ 2 & 1 & 0 \\ 4 & 3 & 1\end{pmatrix}, U=(211011002)U = \begin{pmatrix} 2 & 1 & 1 \\ 0 & 1 & 1 \\ 0 & 0 & 2\end{pmatrix}, x=(1,−1,2)\mathbf{x} = (1, -1, 2).
Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
7 / 25

Doolittle or Crout? Where the ones go

Ones on the diagonal of L

Doolittle: lii=1l_{ii} = 1

  • UU = the matrix left by Gaussian elimination
  • Rows of UU first, then columns of LL
(100210431)(211011002)\begin{pmatrix} 1 & 0 & 0 \\ 2 & 1 & 0 \\ 4 & 3 & 1\end{pmatrix}\begin{pmatrix} 2 & 1 & 1 \\ 0 & 1 & 1 \\ 0 & 0 & 2\end{pmatrix}
Ones on the diagonal of U

Crout: uii=1u_{ii} = 1

  • lij=aij−∑k<jlikukjl_{ij} = a_{ij} - \sum_{k<j} l_{ik}u_{kj} (column of LL first)
  • uij=(aij−∑k<ilikukj)/liiu_{ij} = (a_{ij} - \sum_{k<i} l_{ik}u_{kj})/l_{ii} (then row of UU)
(200410832)(10.50.5011001)\begin{pmatrix} 2 & 0 & 0 \\ 4 & 1 & 0 \\ 8 & 3 & 2\end{pmatrix}\begin{pmatrix} 1 & 0.5 & 0.5 \\ 0 & 1 & 1 \\ 0 & 0 & 1\end{pmatrix}

Both cost the same and solve the same way. Crout's LL is Doolittle's LL with each column multiplied by the pivot; Crout's UU is Doolittle's UU with each row divided by it. A problem that names a method expects that placement of the ones.

Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
8 / 25

Symmetric positive definite matrices and Cholesky

Symmetric positive definite (SPD)A=ATandxTAx>0   for every x≠0A = A^T \quad\text{and}\quad \mathbf{x}^T A\mathbf{x} > 0 \;\text{ for every } \mathbf{x} \ne \mathbf{0}
Then A has a "square root" factorisationA=LLT:ljj=ajj−∑k<jljk2,lij=aij−∑k<jlikljkljjA = LL^T: \quad l_{jj} = \sqrt{a_{jj} - \sum_{k<j} l_{jk}^2}, \quad l_{ij} = \frac{a_{ij} - \sum_{k<j} l_{ik}l_{jk}}{l_{jj}}
  • Where SPD matrices come from: energies, covariance matrices, least squares ATAA^TA (Lecture 23), the plate and circuit matrices
  • Quick test: symmetric, positive diagonal, all pivots (or all ljj2l_{jj}^2) positive
  • Only one triangle is computed: 13n3\tfrac13 n^3 operations, half of LU
  • No pivoting needed: the square roots are of positive numbers and stay well-behaved
Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
9 / 25
The method, step by step

Cholesky, step by step

  1. Check A=ATA = A^T
  2. For column j=1,…,nj = 1, \dots, n:   ljj=ajj−∑k<jljk2\;l_{jj} = \sqrt{a_{jj} - \sum_{k<j} l_{jk}^2}; if the number under the root is ≤0\le 0, stop: not SPD
  3. Below it: lij=(aij−∑k<jlikljk)/ljjl_{ij} = \big(a_{ij} - \sum_{k<j} l_{ik}l_{jk}\big)/l_{jj} for i>ji > j
  4. Forward: Ly=bL\mathbf{y} = \mathbf{b}
  5. Backward: LTx=yL^T\mathbf{x} = \mathbf{y}

nn square roots, about 13n3\tfrac13 n^3 other operations.

Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
10 / 25

Problem 2: Cholesky factorisation

Factor A=(42−22102−226)A = \begin{pmatrix} 4 & 2 & -2 \\ 2 & 10 & 2 \\ -2 & 2 & 6\end{pmatrix} as LLTLL^T and solve Ax=(−2,−4,8)TA\mathbf{x} = (-2, -4, 8)^T.
1
AA is symmetric. Column 1: l11=4=2l_{11} = \sqrt4 = 2, l21=2/2=1l_{21} = 2/2 = 1, l31=−2/2=−1l_{31} = -2/2 = -1
2
Column 2: l22=10−12=3l_{22} = \sqrt{10 - 1^2} = 3, l32=(2−(−1)(1))/3=1l_{32} = (2 - (-1)(1))/3 = 1;   \;column 3: l33=6−1−1=2l_{33} = \sqrt{6 - 1 - 1} = 2
3
Forward Ly=bL\mathbf{y} = \mathbf{b}: y1=−2/2=−1y_1 = -2/2 = -1, y2=(−4−1(−1))/3=−1y_2 = (-4 - 1(-1))/3 = -1, y3=(8−(−1)(−1)−1(−1))/2=4y_3 = (8 - (-1)(-1) - 1(-1))/2 = 4
4
Backward LTx=yL^T\mathbf{x} = \mathbf{y}: x3=4/2=2x_3 = 4/2 = 2, x2=(−1−1(2))/3=−1x_2 = (-1 - 1(2))/3 = -1, x1=(−1−1(−1)−(−1)(2))/2=1x_1 = (-1 - 1(-1) - (-1)(2))/2 = 1
x=(1,−1,2)\mathbf{x} = (1, -1, 2). Every square root was of a positive number, so AA is SPD.
Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
11 / 25

Tridiagonal systems

Only three diagonals are nonzero(b1c1a2b2c2⋱⋱⋱anbn)(x1x2⋮xn)=(d1d2⋮dn)\begin{pmatrix} b_1 & c_1 & & \\ a_2 & b_2 & c_2 & \\ & \ddots & \ddots & \ddots \\ & & a_n & b_n\end{pmatrix}\begin{pmatrix} x_1 \\ x_2 \\ \vdots \\ x_n\end{pmatrix} = \begin{pmatrix} d_1 \\ d_2 \\ \vdots \\ d_n\end{pmatrix}
Elimination touches only one entry per row (Thomas algorithm)c1′=c1b1,d1′=d1b1ci′=cibi−aici−1′,di′=di−aidi−1′bi−aici−1′xn=dn′,xi=di′−ci′ xi+1\begin{aligned} c'_1 &= \frac{c_1}{b_1}, & d'_1 &= \frac{d_1}{b_1} \\ c'_i &= \frac{c_i}{b_i - a_i c'_{i-1}}, & d'_i &= \frac{d_i - a_i d'_{i-1}}{b_i - a_i c'_{i-1}} \\ x_n &= d'_n, & x_i &= d'_i - c'_i\,x_{i+1} \end{aligned}
  • Where they come from: heat in a rod, cubic splines (Lecture 18), implicit ODE methods
  • Store three vectors, not n2n^2 numbers
  • Cost 8n−78n - 7 operations instead of 23n3\tfrac23 n^3
  • Safe without pivoting when ∣bi∣>∣ai∣+∣ci∣|b_i| > |a_i| + |c_i| (diagonally dominant)
Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
12 / 25
The method, step by step

The Thomas algorithm, step by step

  1. Store the sub-, main and super-diagonals aia_i, bib_i, cic_i and the right side did_i
  2. Start: c1′=c1/b1c'_1 = c_1/b_1, d1′=d1/b1d'_1 = d_1/b_1
  3. Sweep down i=2,…,ni = 2, \dots, n:   w=bi−aici−1′\;w = b_i - a_i c'_{i-1},   ci′=ci/w\;c'_i = c_i/w,   di′=(di−aidi−1′)/w\;d'_i = (d_i - a_i d'_{i-1})/w
  4. Sweep up: xn=dn′x_n = d'_n, then xi=di′−ci′xi+1x_i = d'_i - c'_i x_{i+1} for i=n−1,…,1i = n-1, \dots, 1
  5. Check one equation

Two loops, no nested loop: the work grows like nn.

Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
13 / 25

Problem 3: heat in a rod by the Thomas algorithm

A rod has ends at 100° and 0°; four interior points satisfy −Ti−1+2Ti−Ti+1=0-T_{i-1} + 2T_i - T_{i+1} = 0. So 2T1−T2=1002T_1 - T_2 = 100, −T1+2T2−T3=0-T_1 + 2T_2 - T_3 = 0, −T2+2T3−T4=0-T_2 + 2T_3 - T_4 = 0, −T3+2T4=0-T_3 + 2T_4 = 0.
iiaia_ibib_icic_idid_iw=bi−aici−1′w = b_i - a_ic'_{i-1}ci′c'_idi′d'_iTiT_i
1—2−11002−0.55080
2−12−101.5−0.66666733.33333360
3−12−101.333333−0.752540
4−12—01.25—2020

Down sweep fills c′c' and d′d'; up sweep: T4=20T_4 = 20, T3=25+0.75(20)=40T_3 = 25 + 0.75(20) = 40, T2=33.33+0.6667(40)=60T_2 = 33.33 + 0.6667(40) = 60, T1=50+0.5(60)=80T_1 = 50 + 0.5(60) = 80. A straight line from 100° to 0°, as physics predicts.

Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
14 / 25
Classical vs numerical

Same problems, two approaches

Formula

Classical (inverse matrix)

  • Compute A−1A^{-1} once (2n32n^3), then x=A−1b\mathbf{x} = A^{-1}\mathbf{b} (2n22n^2) per reading
  • Plate, 3 readings: same temperatures
  • Tridiagonal AA: A−1A^{-1} is full, so the zeros are lost
vs
Algorithm

Numerical (LU, Thomas)

  • Factor once (23n3\tfrac23 n^3), then 2n22n^2 per reading: three times cheaper, more accurate
  • Plate, 3 readings: one factorisation, three pairs of substitutions
  • Tridiagonal AA: Thomas keeps the zeros, 8n8n operations
When the classical approach cannot work

A rod with a million grid points

A full matrix of 106×10610^6 \times 10^6 doubles needs 8 TB of memory, and dense elimination 6.7×10176.7\times10^{17} operations (21 years at 10910^9 per second). The Thomas algorithm: 8×1068\times10^6 operations (8 ms) and four vectors (32 MB).

Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
15 / 25

LU once, many right-hand sides

  • Doolittle factorisation of the plate matrix (4×44\times4)
  • Then three right-hand sides: top edge 100°, 80°, 60°
  • Each solve is a forward and a backward substitution
  • The factorisation loop runs once
Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
16 / 25

The Thomas algorithm in Python and C

  • Three diagonals and dd stored as vectors
  • Down sweep: c′c' and d′d'; up sweep: xx
  • Change nn to 9 or 99: the code is unchanged
  • Lab: add a heat source (nonzero did_i)
Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
17 / 25
When the factorisations break

Limitations shown failing

  • LU without pivoting: (0111)\begin{pmatrix} 0 & 1 \\ 1 & 1\end{pmatrix} has no LULU at all (u11=0u_{11} = 0); with row swaps PA=LUPA = LU works
  • Cholesky on (1221)\begin{pmatrix} 1 & 2 \\ 2 & 1\end{pmatrix}: l22=1−4l_{22} = \sqrt{1 - 4}, not SPD
  • Thomas without diagonal dominance can meet w=0w = 0, just like a zero pivot
  • None of them helps when AA is ill-conditioned: the factors inherit κ(A)\kappa(A)
Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
18 / 25
Practice

Practice problem

Problem 4"Factorise A=(11143−1353)A = \begin{pmatrix} 1 & 1 & 1 \\ 4 & 3 & -1 \\ 3 & 5 & 3\end{pmatrix} as LULU by Doolittle's method and solve Ax=(1,6,4)TA\mathbf{x} = (1, 6, 4)^T."
How to write a complete answer
  • State the form: LL unit lower triangular, UU upper triangular
  • Row 1 of UU = (1,1,1)(1, 1, 1); l21=4l_{21} = 4, l31=3l_{31} = 3; then u22=−1u_{22} = -1, u23=−5u_{23} = -5, l32=−2l_{32} = -2, u33=−10u_{33} = -10
  • Forward: y=(1,2,5)\mathbf{y} = (1, 2, 5); backward: x3=−12x_3 = -\tfrac12, x2=12x_2 = \tfrac12, x1=1x_1 = 1
  • Verify LU=ALU = A (one row is enough) and substitute x\mathbf{x} into one equation
Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
19 / 25
When to use it

LU, Cholesky and Thomas: method profile

Best case
  • LU: one matrix, many right-hand sides (time steps, load cases, Newton with a frozen Jacobian)
  • Cholesky: SPD matrices, half the work and no pivoting
  • Thomas: tridiagonal systems in O(n)O(n), millions of unknowns in milliseconds
Worst case
  • LU without pivoting: zero or tiny uiiu_{ii}
  • Cholesky on a matrix that is not SPD: a negative number under the root
  • Sparse matrices that are not tridiagonal: LU fills the zeros in ("fill-in")
Best suited for
  • Implicit time stepping (the same AA every step)
  • Statistics and ML: covariance matrices, least squares, Gaussian processes (Cholesky)
  • Splines and 1-D heat or diffusion problems (Thomas)
Avoid when
  • Just one system (plain elimination is equally good)
  • Huge 2-D or 3-D grids: fill-in makes LU too big; use iterative methods (Lecture 14)
  • Forming A−1A^{-1} "to save time": LU does the same job better

Rule of thumb: tridiagonal → Thomas; SPD → Cholesky; many right-hand sides → LU once; otherwise Gaussian elimination with pivoting.

Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
20 / 25

Comparative analysis: direct solvers

MethodNeedsFactorEach new b\mathbf{b}Memoryn=1000n = 1000, 1440 b's
Gauss each timeany nonsingular AA—23n3\tfrac23 n^3n2n^216 min
Inverse, then multiplyany nonsingular AA2n32n^32n22n^2n2n^24.9 s
LU (with pivoting)any nonsingular AA23n3\tfrac23 n^32n22n^2n2n^23.5 s
CholeskySPD13n3\tfrac13 n^32n22n^212n2\tfrac12 n^23.2 s
Thomastridiagonal, diag. dominant≈3n\approx 3n≈5n\approx 5n4n4n7 ms (if tridiagonal)

Times at 10910^9 operations per second. The inverse row is slower and less accurate than LU for the same job.

Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
21 / 25
Roadmap

Limitations, and where we fix them

Direct factorisations are fast for dense, banded and tridiagonal matrices. Some problems are still out of reach:

What it does well (keep this)
  • Factor once, solve many times
  • Cholesky for SPD: half the work, no pivoting
  • Thomas: O(n)O(n) for tridiagonal systems
  • Exact up to rounding, in a known number of steps
LimitationHow it is overcomeWhere
2-D and 3-D grids: fill-in, memory grows like n1.5n^{1.5} or worse
→
Iterative methods: only the nonzeros are stored
Lecture 14 →
Splines need a tridiagonal solve
→
Thomas, used directly
Lecture 18 →
Least squares gives SPD normal equations ATAx=ATyA^TA\mathbf{x} = A^T\mathbf{y}
→
Cholesky (and QR for better conditioning)
Lecture 23 →
Implicit ODE methods solve a system every step
→
Factor once, reuse each step
Lecture 22 →
Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
22 / 25
Applications

Where this method runs in the real world

Click a card to see where the factorisation happens in a real computation.

Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
23 / 25

Checkpoint

Checkpoint · think, then discuss with your neighbourDoolittle LU of A=(2168)A = \begin{pmatrix} 2 & 1 \\ 6 & 8\end{pmatrix}. What are l21l_{21} and u22u_{22}?
Al21=3l_{21} = 3, u22=5u_{22} = 5
Bl21=3l_{21} = 3, u22=8u_{22} = 8
Cl21=13l_{21} = \tfrac13, u22=5u_{22} = 5
Dl21=6l_{21} = 6, u22=2u_{22} = 2
A. l21=a21/u11=6/2=3l_{21} = a_{21}/u_{11} = 6/2 = 3; u22=a22−l21u12=8−3(1)=5u_{22} = a_{22} - l_{21}u_{12} = 8 - 3(1) = 5. Check: (1031)(2105)=A\begin{pmatrix} 1 & 0 \\ 3 & 1\end{pmatrix}\begin{pmatrix} 2 & 1 \\ 0 & 5\end{pmatrix} = A.
Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
24 / 25

Summary

Key points
  • Gaussian elimination is A=LUA = LU: LL holds the multipliers, UU the eliminated matrix
  • Factor once (23n3\tfrac23 n^3), then Ly=bL\mathbf{y} = \mathbf{b}, Ux=yU\mathbf{x} = \mathbf{y} (2n22n^2) per right-hand side
  • SPD matrices: Cholesky A=LLTA = LL^T, half the cost, no pivoting, and a test for positive definiteness
  • Tridiagonal: the Thomas algorithm, 8n−78n - 7 operations
Opening problem: solved

One LU of the plate matrix, then three solves: top 100° gives (43.75,56.25,18.75,31.25)(43.75, 56.25, 18.75, 31.25); 80° gives (36.25,48.75,16.25,28.75)(36.25, 48.75, 16.25, 28.75); 60° gives (28.75,41.25,13.75,26.25)(28.75, 41.25, 13.75, 26.25). For n=1000n = 1000 and 1440 readings: 3.5 s instead of 16 minutes.

Homework
  1. Factor (3216639106)\begin{pmatrix} 3 & 2 & 1 \\ 6 & 6 & 3 \\ 9 & 10 & 6\end{pmatrix} by Doolittle's method and solve with b=(6,15,25)\mathbf{b} = (6, 15, 25). Then repeat with Crout's method.
  2. Find the Cholesky factor of (4−20−25−20−25)\begin{pmatrix} 4 & -2 & 0 \\ -2 & 5 & -2 \\ 0 & -2 & 5\end{pmatrix}.
  3. Solve 2x1−x2=12x_1 - x_2 = 1, −xi−1+2xi−xi+1=0-x_{i-1} + 2x_i - x_{i+1} = 0 (i=2,3i = 2, 3), −x3+2x4=1-x_3 + 2x_4 = 1 by the Thomas algorithm.
  4. A model has n=2000n = 2000 and 500 right-hand sides. Compare the time of Gaussian elimination for each with one LU factorisation.
Next lecture

Iterative methods: Jacobi, Gauss–Seidel and SOR. When the matrix is huge and sparse, stop factoring and start iterating, just like fixed-point iteration in Lecture 8.

Md Mahbub E Noor
Lecture 13: LU, Cholesky and Tridiagonal Systems
University of Barishal
25 / 25