Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Big Idea

Gaussian elimination transforms a general matrix into upper triangular form using row operations. Combined with back substitution, this solves any invertible linear system.

Elementary Row Operations

Three operations that preserve the solution of a linear system:

  1. Multiply a row by a nonzero scalar: cRiRicR_i \to R_i

  2. Add a multiple of one row to another: RicRjRiR_i - c R_j \to R_i

  3. Interchange two rows: RiRjR_i \leftrightarrow R_j

The Algorithm

Transform the augmented matrix [Ab][\mathcal{A} | \mathbf{b}] to upper triangular form [Ub~][\mathcal{U} | \tilde{\mathbf{b}}] by eliminating entries below the diagonal, column by column.

Algorithm 1 (Gaussian Elimination)

Input: ARn×n\mathcal{A} \in \mathbb{R}^{n \times n}, bRn\mathbf{b} \in \mathbb{R}^n

Output: Upper triangular U\mathcal{U}, modified b~\tilde{\mathbf{b}}

  1. for k=1,2,,n1k = 1, 2, \ldots, n-1:

  2. \qquad for i=k+1,,ni = k+1, \ldots, n:

  3. \qquad\qquad likaik/akkl_{ik} \gets a_{ik} / a_{kk} (multiplier)

  4. \qquad\qquad for j=k+1,,nj = k+1, \ldots, n:

  5. \qquad\qquad\qquad aijaijlikakja_{ij} \gets a_{ij} - l_{ik} \cdot a_{kj}

  6. \qquad\qquad bibilikbkb_i \gets b_i - l_{ik} \cdot b_k

Example 1 (Gaussian Elimination by Hand)

Solve:

2x1+x2+3x3=14x1+4x2+7x3=12x1+5x2+9x3=3\begin{aligned} 2x_1 + x_2 + 3x_3 &= 1 \\ 4x_1 + 4x_2 + 7x_3 &= 1 \\ 2x_1 + 5x_2 + 9x_3 &= 3 \end{aligned}

Step 1: Form augmented matrix

[213144712593]\left[\begin{array}{ccc|c} 2 & 1 & 3 & 1 \\ 4 & 4 & 7 & 1 \\ 2 & 5 & 9 & 3 \end{array}\right]

Step 2: Eliminate below first pivot (R22R1R_2 - 2R_1, R3R1R_3 - R_1)

[213102110462]\left[\begin{array}{ccc|c} 2 & 1 & 3 & 1 \\ 0 & 2 & 1 & -1 \\ 0 & 4 & 6 & 2 \end{array}\right]

Step 3: Eliminate below second pivot (R32R2R_3 - 2R_2)

[213102110044]\left[\begin{array}{ccc|c} 2 & 1 & 3 & 1 \\ 0 & 2 & 1 & -1 \\ 0 & 0 & 4 & 4 \end{array}\right]

Step 4: Back substitution gives x=(1/2,1,1)T\mathbf{x} = (-1/2, -1, 1)^T.

Computational Cost

At step kk, the elimination updates a (nk)×(nk)(n-k) \times (n-k) submatrix. The total cost is:

k=1n12(nk)2=23n3+O(n2)\sum_{k=1}^{n-1} 2(n-k)^2 = \frac{2}{3}n^3 + \mathcal{O}(n^2)

Gaussian elimination is O(n3)\mathcal{O}(n^3): cubic in the matrix size. The subsequent back substitution is only O(n2)\mathcal{O}(n^2), so the elimination dominates.

See Also

Gaussian Elimination and LU Decomposition: implementation of GE, elementary matrices, the connection to LU, and visualization of structured LU factors.