4.5.26Linear Algebra (Full)

LU decomposition — algorithm, applications

1,618 words7 min readdifficulty · medium6 backlinks

WHAT is it?

The entries of UU are exactly the pivots of Gaussian elimination, and the entries of LL are exactly the multipliers you used to eliminate below each pivot.


HOW: deriving the algorithm from scratch

Gaussian elimination clears the column below each pivot by row operations. A row operation "subtract mm times row kk from row ii" is itself a matrix multiplication on the left.

The multiplier matrix

To eliminate entry aika_{ik} using pivot akka_{kk}, the multiplier is mik=aikakk(after previous steps).m_{ik} = \frac{a_{ik}}{a_{kk}} \quad(\text{after previous steps}). The elementary matrix that does "rowi_i \leftarrow rowimik_i - m_{ik}\,rowk_k" is the identity with mik-m_{ik} in position (i,k)(i,k).

Figure — LU decomposition — algorithm, applications

Worked Example 1 — basic factorisation

Factor A=(2347).A=\begin{pmatrix} 2 & 3 \\ 4 & 7 \end{pmatrix}.

Step 1. Pivot =2=2. Multiplier m21=42=2m_{21}=\dfrac{4}{2}=2. Why this step? We need to kill the 44 below the first pivot; m21=a21/a11m_{21}=a_{21}/a_{11}.

Step 2. Row2_2 \leftarrow Row22_2 - 2\cdotRow1_1: (4,7)(4,6)=(0,1)(4,7)-(4,6)=(0,1). So U=(2301)U=\begin{pmatrix}2&3\\0&1\end{pmatrix}. Why? This produces the upper-triangular UU with pivots on its diagonal.

Step 3. Put the multiplier into LL: L=(1021)L=\begin{pmatrix}1&0\\2&1\end{pmatrix}. Why? LL records how we got to UU, with +m21+m_{21}.

Check: LU=(1021)(2301)=(2347)=A.LU=\begin{pmatrix}1&0\\2&1\end{pmatrix}\begin{pmatrix}2&3\\0&1\end{pmatrix}=\begin{pmatrix}2&3\\4&7\end{pmatrix}=A.


Worked Example 2 — using LU to solve Ax=bA\mathbf{x}=\mathbf{b}

Solve Ax=bA\mathbf{x}=\mathbf{b} with the AA above and b=(818)\mathbf{b}=\begin{pmatrix}8\\18\end{pmatrix}.

Forward: Ly=bL\mathbf{y}=\mathbf{b}: y1=8,2y1+y2=18y2=1816=2.y_1=8,\qquad 2y_1+y_2=18\Rightarrow y_2=18-16=2. Why? Row 1 gives y1y_1 instantly; substitute into row 2.

Back: Ux=yU\mathbf{x}=\mathbf{y}: 2x1+3x2=8,x2=22x1=86x1=1.2x_1+3x_2=8,\quad x_2=2 \Rightarrow 2x_1=8-6\Rightarrow x_1=1. Answer: x=(1,2)\mathbf{x}=(1,2)^\top. Why fast? No new elimination — just substitution.


Worked Example 3 — a 3×33\times3 and the pivot warning

A=(111235468).A=\begin{pmatrix}1&1&1\\2&3&5\\4&6&8\end{pmatrix}.

  • m21=2, m31=4m_{21}=2,\ m_{31}=4. After clearing column 1: (111013024).\begin{pmatrix}1&1&1\\0&1&3\\0&2&4\end{pmatrix}.
  • New pivot =1=1 (row 2). m32=2m_{32}=2. Clear: row32_3-2\cdotrow2=(0,0,2)_2=(0,0,-2). U=(111013002),L=(100210421).U=\begin{pmatrix}1&1&1\\0&1&3\\0&0&-2\end{pmatrix},\quad L=\begin{pmatrix}1&0&0\\2&1&0\\4&2&1\end{pmatrix}.

Applications (the 80/20 payoff)


Cost (the WHY-it-matters number)


Recall Feynman: explain to a 12-year-old

Imagine a tall messy stack of LEGO instructions. Solving the puzzle once is slow. But if you write down the steps you used (that's LL) and keep the half-built model (that's UU), then next time someone gives you a slightly different goal, you don't start over — you just replay your saved steps backwards and forwards. LU = "save your homework so you never redo it."


What is the LU decomposition of a matrix A?
A factorisation A=LUA=LU with LL unit lower triangular (1's on diagonal) and UU upper triangular.
What do the entries of U represent in Gaussian elimination?
The pivots.
What do the off-diagonal entries of L represent?
The multipliers mik=aik/akkm_{ik}=a_{ik}/a_{kk} used to eliminate below each pivot.
Why is the diagonal of L all ones?
Because L is the product of inverse elementary elimination matrices, each leaving diagonal entries equal to 1.
To solve Ax=b via LU, what are the two steps?
Forward-solve Ly=bL\mathbf{y}=\mathbf{b}, then back-solve Ux=yU\mathbf{x}=\mathbf{y}.
How do you compute det(A) from LU?
detA=iuii\det A=\prod_i u_{ii} (product of pivots), times (1)(-1) per row swap if pivoting used.
When does plain A=LU fail and what's the fix?
When a pivot is zero/tiny; use partial pivoting giving PA=LUPA=LU with permutation matrix P.
Cost of LU factorisation vs one triangular solve?
Factorisation 23n3\approx \tfrac{2}{3}n^3 flops; each solve n2\approx n^2.
Main advantage of LU over plain Gaussian elimination?
Reuse L,U for many right-hand sides at O(n2)O(n^2) each instead of redoing O(n3)O(n^3) elimination.

Connections

  • Gaussian Elimination — LU is elimination with the steps remembered.
  • Permutation Matrices — used in PA=LUPA=LU for pivoting.
  • Determinants — product of pivots.
  • Matrix Inverse — solve against identity columns.
  • Cholesky Decomposition — symmetric positive-definite special case A=LLA=LL^\top.
  • Triangular Systems & Substitution — the cheap solves.

Concept Map

produces

records

factored into

contains

contains

stored in

form diagonal of

composed then inverted give

each step is

added when row swaps needed

enables

allows

Gaussian elimination

Matrix A

L unit lower triangular

U upper triangular

Factorisation A = LU

Elementary matrices Ei

Multipliers m_ik = a_ik / a_kk

Pivots

Permutation matrix P

Two triangular solves

Reuse for many b vectors

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, LU decomposition ka funda simple hai: jab tum Gaussian elimination karte ho na, tab tum bahut mehnat karte ho rows ko zero karne mein — par answer milne ke baad woh saari mehnat waste ho jaati hai. LU bolta hai "ruk, apna kaam save kar le!" Matrix AA ko hum do pieces mein todte hain: LL (lower triangular, diagonal pe 1) aur UU (upper triangular). UU mein tumhare pivots baithte hain, aur LL mein woh multipliers (mik=aik/akkm_{ik}=a_{ik}/a_{kk}) jo tumne elimination ke time use kiye the.

Iska sabse bada faayda kab? Jab same matrix AA ke saath bahut saare alag-alag b\mathbf{b} solve karne ho. Ek baar L,UL,U nikaal lo (cost 23n3\approx \frac{2}{3}n^3), phir har b\mathbf{b} ke liye sirf do easy substitution karo: pehle Ly=bL\mathbf{y}=\mathbf{b} (forward substitution), phir Ux=yU\mathbf{x}=\mathbf{y} (back substitution) — dono O(n2)O(n^2) mein. Matlab kaam ek baar, fayda baar-baar.

Determinant bhi free mein mil jaata hai: detA=u11u22unn\det A = u_{11}u_{22}\cdots u_{nn}, yaani pivots ka product. Inverse chahiye? Ax=eiA\mathbf{x}=\mathbf{e}_i solve karo har identity column ke liye, wahi L,UL,U reuse karke.

Ek warning yaad rakhna: agar koi pivot zero ya bahut chhota aa jaaye, toh seedha A=LUA=LU fail ho jaata hai (divide by zero / rounding blast). Tab hum rows swap karte hain — isko partial pivoting kehte hain, aur factorisation ban jaata hai PA=LUPA=LU jahan PP ek permutation matrix hai. Bas yeh dhyaan rakho aur LU tumhara dost hai exam mein bhi aur real engineering mein bhi.

Go deeper — visual, from zero

Test yourself — Linear Algebra (Full)

Connections