Tutorials › Linear Algebra › Gaussian Elimination as Matrix Factorization

LU Factorization and Numerical Considerations · Tutorial 901 of 1000

Gaussian Elimination as Matrix Factorization

Trace elimination multipliers into a lower triangular factor, form the upper triangular factor, and verify the resulting matrix product.

Intermediate 9 min read

What You'll Learn

  • Identify elimination multipliers from row operations.
  • Distinguish the elimination matrix from the lower triangular factor.
  • Build triangular factors from a completed three-by-three elimination.
  • Verify a proposed factorization by multiplying the factors.
  • Use the factors to solve a system and check the solution.

From Row Operations to Two Factors

Gaussian elimination transforms a matrix into a simpler one by subtracting multiples of pivot rows from rows below them. Those multiples are not temporary bookkeeping: they record how the original rows are reconstructed from the eliminated rows. Collecting that information gives a lower triangular matrix, while the result of elimination is upper triangular. Together these matrices express the original matrix as a product.

We work over \(\mathbb{R}\). A square matrix is lower triangular if every entry above its main diagonal is zero, and upper triangular if every entry below its main diagonal is zero. In the factorization considered here, the diagonal entries of the lower triangular factor are all \(1\). The tutorial focuses on elimination without row exchanges; the pivots used in the examples are nonzero.

Definition: An LU factorization of a square matrix \(\mathbf{A}\) is a product \(\mathbf{A}=\mathbf{L}\mathbf{U}\), where \(\mathbf{L}\) is lower triangular and \(\mathbf{U}\) is upper triangular. In the factorizations built from elimination without row exchanges, \(\mathbf{L}\) has \(1\)s on its diagonal. Each elimination multiplier is the scalar used to subtract a pivot-row multiple from a lower row; for example, \(R_2\to R_2-m_{21}R_1\) uses multiplier \(m_{21}\).

There is a sign distinction to keep straight. The row operation subtracts the multiplier times the pivot row. The corresponding entry in \(\mathbf{L}\) is the multiplier itself, not its negative. One way to explain this is through an elimination matrix. For example, the matrix that performs \(R_2\to R_2-mR_1\) when multiplied on the left is \(\begin{bmatrix}1&0\\-m&1\end{bmatrix}\). Its inverse is \(\begin{bmatrix}1&0\\m&1\end{bmatrix}\), which restores the eliminated row and records \(m\) in the lower triangular factor.

Worked Example: One Elimination Step in Two Dimensions

Factor \(\mathbf{A}=\begin{bmatrix}3&2\\6&5\end{bmatrix}\) by eliminating the entry below the first pivot. The multiplier is \(m_{21}=6/3=2\), so apply \(R_2\to R_2-2R_1\):

$$ \begin{bmatrix}3&2\\6&5\end{bmatrix} \sim \begin{bmatrix}3&2\\0&1\end{bmatrix} =\mathbf{U}. $$

Record the multiplier below the diagonal of \(\mathbf{L}\), and put \(1\)s on its diagonal: \(\mathbf{L}=\begin{bmatrix}1&0\\2&1\end{bmatrix}\). Thus the proposed factorization is

$$ \mathbf{A}=\mathbf{L}\mathbf{U} = \begin{bmatrix}1&0\\2&1\end{bmatrix} \begin{bmatrix}3&2\\0&1\end{bmatrix} = \begin{bmatrix}3&2\\6&5\end{bmatrix}. $$

Check: The first row of the product is \((3,2)\); the second row is \(2(3,2)+(0,1)=(6,5)\). The product is the original matrix.

How the Multipliers Build the Lower Factor

For a three-by-three matrix, suppose the first pivot is \(a\ne0\), and after eliminating the first column the second pivot is \(p\ne0\). Write the original matrix as \(\begin{bmatrix}a&b&c\\d&e&f\\g&h&i\end{bmatrix}\). The first two multipliers are \(m_{21}=d/a\) and \(m_{31}=g/a\). After the first-column eliminations, the second entry in row 2 is \(p=e-m_{21}b\), and the second entry in row 3 is \(h-m_{31}b\). Hence the next multiplier is \(m_{32}=(h-m_{31}b)/p\).

Proposition: Let \(\mathbf{A}=\begin{bmatrix}a&b&c\\d&e&f\\g&h&i\end{bmatrix}\) be a real three-by-three matrix. If \(a\ne0\) and \(p=e-(d/a)b\ne0\), elimination without row exchanges gives multipliers \(m_{21}=d/a\), \(m_{31}=g/a\), and \(m_{32}=(h-m_{31}b)/p\). The resulting upper triangular matrix \(\mathbf{U}\) and lower triangular matrix \(\mathbf{L}\) satisfy \(\mathbf{A}=\mathbf{L}\mathbf{U}\), where \(\mathbf{L}=\begin{bmatrix}1&0&0\\m_{21}&1&0\\m_{31}&m_{32}&1\end{bmatrix}\).

Proof. The condition \(a\ne0\) allows the first-column row operations \(R_2\to R_2-m_{21}R_1\) and \(R_3\to R_3-m_{31}R_1\). They give rows \((0,p,f-m_{21}c)\) and \((0,h-m_{31}b,i-m_{31}c)\), respectively. Since \(p\ne0\), the next operation subtracts \(m_{32}\) times the new second row from the new third row. It produces a zero in position \((3,2)\), so the resulting matrix \(\mathbf{U}\) is upper triangular. Write its rows as \(\mathbf{u}_1,\mathbf{u}_2,\mathbf{u}_3\). Reversing the operations expresses the original rows as \(\mathbf{u}_1\), \(m_{21}\mathbf{u}_1+\mathbf{u}_2\), and \(m_{31}\mathbf{u}_1+m_{32}\mathbf{u}_2+\mathbf{u}_3\). Those are exactly the rows of \(\mathbf{L}\mathbf{U}\) for the displayed \(\mathbf{L}\). Therefore \(\mathbf{A}=\mathbf{L}\mathbf{U}\). \(\square\)

The proposition makes the order of the multipliers explicit. The multiplier \(m_{32}\) is calculated after the first elimination has changed row 3, but it is recorded in position \((3,2)\) of \(\mathbf{L}\); \(m_{31}\), recorded in position \((3,1)\), is not replaced by a later value. The product \(\mathbf{L}\mathbf{U}\) checks that the entire sequence has been recorded consistently.

A Three-by-Three Factorization and a System

Worked Example: Factor, Solve, and Check

Factor \(\mathbf{A}=\begin{bmatrix}2&1&1\\4&5&2\\-2&8&3\end{bmatrix}\), then solve \(\mathbf{A}\mathbf{x}=\mathbf{b}\) for \(\mathbf{b}=\begin{bmatrix}3\\3\\-4\end{bmatrix}\).

First-column elimination uses \(m_{21}=4/2=2\) and \(m_{31}=-2/2=-1\). Apply \(R_2\to R_2-2R_1\) and \(R_3\to R_3-(-1)R_1\):

$$ \begin{bmatrix}2&1&1\\4&5&2\\-2&8&3\end{bmatrix} \sim \begin{bmatrix}2&1&1\\0&3&0\\0&9&4\end{bmatrix}. $$

The second pivot is \(3\), so \(m_{32}=9/3=3\). Apply \(R_3\to R_3-3R_2\):

$$ \begin{bmatrix}2&1&1\\0&3&0\\0&9&4\end{bmatrix} \sim \begin{bmatrix}2&1&1\\0&3&0\\0&0&4\end{bmatrix} =\mathbf{U}. $$

Place the three multipliers in the lower-triangular positions to form \(\mathbf{L}=\begin{bmatrix}1&0&0\\2&1&0\\-1&3&1\end{bmatrix}\). Multiply to verify the factorization row by row:

$$ \mathbf{L}\mathbf{U} = \begin{bmatrix} 2&1&1\\ 2(2,1,1)+(0,3,0)\\ -(2,1,1)+3(0,3,0)+(0,0,4) \end{bmatrix} = \begin{bmatrix}2&1&1\\4&5&2\\-2&8&3\end{bmatrix} =\mathbf{A}. $$

To solve the system using the factors, first solve \(\mathbf{L}\mathbf{y}=\mathbf{b}\), then \(\mathbf{U}\mathbf{x}=\mathbf{y}\). The first equation gives \(y_1=3\); the second gives \(2y_1+y_2=3\), so \(y_2=-3\); the third gives \(-y_1+3y_2+y_3=-4\), so \(-3-9+y_3=-4\) and \(y_3=8\). Thus \(\mathbf{y}=\begin{bmatrix}3\\-3\\8\end{bmatrix}\).

Now solve from the last equation of \(\mathbf{U}\mathbf{x}=\mathbf{y}\) upward. We obtain \(4x_3=8\), hence \(x_3=2\); \(3x_2=-3\), hence \(x_2=-1\); and \(2x_1+x_2+x_3=3\), hence \(2x_1-1+2=3\) and \(x_1=1\). Therefore \(\mathbf{x}=\begin{bmatrix}1\\-1\\2\end{bmatrix}\).

Check: \(\mathbf{A}\mathbf{x}=\begin{bmatrix}2-1+2\\4-5+4\\-2-8+6\end{bmatrix}=\begin{bmatrix}3\\3\\-4\end{bmatrix}=\mathbf{b}\). The factor product and the solution both check.

Elimination Matrices Explain the Sign

The same reasoning can be stated using matrices for row operations. Left multiplication by a matrix performs the corresponding row operation. For example, in the first step of the preceding example, the matrix for \(R_2\to R_2-2R_1\) is \(\begin{bmatrix}1&0&0\\-2&1&0\\0&0&1\end{bmatrix}\). Its inverse has \(+2\) in position \((2,1)\), because adding \(2R_1\) reverses the subtraction. Thus, if an elimination step is represented by \(\mathbf{E}\), the original matrix is recovered by multiplying by \(\mathbf{E}^{-1}\) on the left.

Result: For the row operation \(R_i\to R_i-mR_j\), with \(i\ne j\), the left-multiplying matrix is \(\mathbf{E}=\mathbf{I}-m\mathbf{e}_i\mathbf{e}_j^{\top}\), and its inverse is \(\mathbf{E}^{-1}=\mathbf{I}+m\mathbf{e}_i\mathbf{e}_j^{\top}\).

Proof. The matrix \(\mathbf{e}_i\mathbf{e}_j^{\top}\) has a \(1\) in position \((i,j)\) and zeros elsewhere, so \(\mathbf{E}\) changes row \(i\) by subtracting \(m\) times row \(j\) and leaves the other rows unchanged. Let \(\mathbf{N}=\mathbf{e}_i\mathbf{e}_j^{\top}\). Since \(i\ne j\), \(\mathbf{N}^2=\mathbf{e}_i(\mathbf{e}_j^{\top}\mathbf{e}_i)\mathbf{e}_j^{\top}=\mathbf{O}\), because \(\mathbf{e}_j^{\top}\mathbf{e}_i=0\). Consequently, \((\mathbf{I}-m\mathbf{N})(\mathbf{I}+m\mathbf{N})=\mathbf{I}-m^2\mathbf{N}^2=\mathbf{I}\), and reversing the factors gives the same identity. Therefore \(\mathbf{E}^{-1}=\mathbf{I}+m\mathbf{N}\). \(\square\)

With multiple elimination steps, the row-operation matrices act in sequence on the left, so their order matters. Reversing those operations recovers the original matrix. The three-by-three proposition gives a direct way to carry out that recovery: retain each multiplier in its corresponding position in \(\mathbf{L}\), then verify the result by multiplication.

Worked Example: A Zero Multiplier and a Fraction

Factor \(\mathbf{A}=\begin{bmatrix}2&1&0\\0&3&1\\4&3&5\end{bmatrix}\). The multiplier below the first pivot in row 2 is \(m_{21}=0/2=0\), while \(m_{31}=4/2=2\). The first-column elimination leaves row 2 unchanged and changes row 3 by subtracting \(2R_1\):

$$ \begin{bmatrix}2&1&0\\0&3&1\\4&3&5\end{bmatrix} \sim \begin{bmatrix}2&1&0\\0&3&1\\0&1&5\end{bmatrix}. $$

The second multiplier is \(m_{32}=1/3\). Subtract \(\tfrac13 R_2\) from row 3:

$$ \begin{bmatrix}2&1&0\\0&3&1\\0&1&5\end{bmatrix} \sim \begin{bmatrix}2&1&0\\0&3&1\\0&0&\tfrac{14}{3}\end{bmatrix} =\mathbf{U}. $$

Record the multipliers in \(\mathbf{L}=\begin{bmatrix}1&0&0\\0&1&0\\2&\tfrac13&1\end{bmatrix}\). Multiplication gives first row \((2,1,0)\), second row \((0,3,1)\), and third row \(2(2,1,0)+\tfrac13(0,3,1)+(0,0,\tfrac{14}{3})=(4,3,5)\). Thus \(\mathbf{L}\mathbf{U}=\begin{bmatrix}2&1&0\\0&3&1\\4&3&5\end{bmatrix}=\mathbf{A}\). A zero multiplier is simply recorded as zero; it does not change the reconstruction.

Common Pitfall: Recording the Wrong Sign

A frequent error is to copy the coefficient as it appears in the row operation, including its subtraction sign. In the two-by-two example, the operation was \(R_2\to R_2-2R_1\). Putting \(-2\) in \(\mathbf{L}\) would give the incorrect product \(\begin{bmatrix}1&0\\-2&1\end{bmatrix}\begin{bmatrix}3&2\\0&1\end{bmatrix}=\begin{bmatrix}3&2\\-6&-3\end{bmatrix}\), which is not \(\mathbf{A}\). The correction is to record the multiplier \(2\), so the lower row of \(\mathbf{L}\mathbf{U}\) is \(2(3,2)+(0,1)=(6,5)\). The subtraction sign belongs to the row operation; reversing the operation to recover the original matrix puts the positive multiplier into \(\mathbf{L}\).

Always check \(\mathbf{L}\mathbf{U}=\mathbf{A}\) by multiplication, rather than relying only on the appearance of the factors. The check detects sign errors and misplaced multipliers. It also reinforces the meaning of the factorization: each row of \(\mathbf{A}\) is assembled from rows of \(\mathbf{U}\) using the coefficients in the corresponding row of \(\mathbf{L}\).

Check Your Understanding

For each proposed factorization, identify the elimination multipliers and verify the product.

  1. Eliminate the entry below the first pivot in \(\begin{bmatrix}4&1\\8&3\end{bmatrix}\). What are \(\mathbf{L}\) and \(\mathbf{U}\)?
  2. For \(\begin{bmatrix}1&1&0\\2&4&1\\3&7&5\end{bmatrix}\), find the three multipliers and form the corresponding factors.
  3. Explain why the entry in position \((3,2)\) of \(\mathbf{L}\) records the multiplier used after the first-column eliminations.
  4. For \(R_3\to R_3-\tfrac12R_1\), write the corresponding elimination matrix and its inverse.
  5. Given \(\mathbf{A}=\mathbf{L}\mathbf{U}\) and \(\mathbf{b}\), state the two triangular systems used to solve \(\mathbf{A}\mathbf{x}=\mathbf{b}\).

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon