Last modified: May 28, 2022

This article is written in: 🇺🇸

Gaussian Elimination

Gaussian elimination is a fundamental algorithmic procedure in linear algebra used to solve systems of linear equations, find matrix inverses, and determine the rank of matrices. The procedure systematically applies elementary row operations to transform a given matrix into an upper-triangular form (row echelon form), from which the solution to the system (if it exists and is unique) can be readily determined by back substitution.

From a conceptual viewpoint, Gaussian elimination provides a structured approach to eliminating unknowns step-by-step. Geometrically, each linear equation represents a hyperplane in n-dimensional space, and the solution of the system corresponds to the intersection point(s) of these hyperplanes. Gaussian elimination successively "clears out" the variables, enabling a direct path to the solution (or revealing inconsistencies or infinite solution sets if they exist).

gaussian_elimination

Mathematical Formulation

Consider a system of n linear equations with n unknowns:

Ax=b, where

A=[a11a12⋯a1na21a22⋯a2n⋮⋮⋱⋮an1an2⋯ann]

x=[x1 x2 â‹¯ xn]

b=[b1 b2 â‹¯ bn]

We form the augmented matrix [A|b]:

[A|b]=[a11a12⋯a1nb1a21a22⋯a2nb2⋮⋮⋱⋮⋮an1an2⋯annbn]

The goal of Gaussian elimination is to perform a series of row operations to transform [A|b] into an upper-triangular form:

[U|c]=[u11u12⋯u1nc10u22⋯u2nc2⋮⋮⋱⋮⋮00⋯unncn]

where U is an upper-triangular matrix. Once in this form, the solution x can be found by back substitution.

Derivation

The derivation of Gaussian elimination closely mirrors the logic of systematic elimination of variables from a set of equations:

I. Elimination of x1 from equations 2 through n:

Suppose the first pivot (the leading element in the first row) is a11. By using row operations, we can eliminate the x1-term from all equations below the first. This is achieved by subtracting suitable multiples of the first row from subsequent rows.

II. Elimination of x2 from equations 3 through n:

After the first step, the second row now has a leading coefficient (pivot) in the second column. Using this pivot, we eliminate the x2-term from all equations below the second.

III. Continue this process until the last pivot ann (in the n-th row) is in place. If at any stage a pivot is zero, we interchange rows (partial pivoting) to bring a nonzero pivot into the pivot position.

The end result is an upper-triangular system that can be solved starting from the last equation and moving upward (back substitution).

Algorithm Steps

Input: An augmented matrix [A|b] representing the system Ax=b.

Output: A solution vector x if it exists, or detection of no solution or infinitely many solutions.

Step-by-Step Procedure:

I. Form the augmented matrix:

[A|b]=[a11a12⋯a1nb1a21a22⋯a2nb2⋮⋮⋱⋮⋮an1an2⋯annbn]

II. Forward Elimination (to reach upper-triangular form):

For i=1 to n:

I. Partial Pivoting (if desired): Find the row (pivotRow) below (and including) the current row i that has the largest absolute value in column i. Swap the current row i with pivotRow to reduce numerical instability.

II. Pivot Normalization: Divide the entire i-th row by aii (the pivot) to make the pivot element equal to 1.

III. Elimination: For each row j>i, subtract aji times the i-th row from the j-th row to make the elements below the pivot zero.

After these steps, the matrix is in row echelon form:

[U|c]=[1∗⋯∗∗01⋯∗∗⋮⋮⋱⋮⋮00⋯1∗]

where ∗ represents arbitrary numbers obtained during the process.

III. Back Substitution:

Starting from the last equation:

For i=n down to 1:

xi=ci−∑k=i+1nuikxk.

Since uii=1 after normalization, xi can be directly computed. (If not normalized, divide by uii.)

This process yields the solution vector x.

Example

Given System:

2x+y−z=8,−3x−y+2z=−11,−2x+y+2z=−3.

I. Augmented Matrix:

[A|b]=[21−18−3−12−11−212−3]

II. Forward Elimination:

[10.5−0.54−3−12−11−212−3]

(−3)R1+R2→R2⟹R2=[00.50.51]

(2)R1+R3→R3⟹R3=[0215]

Now the matrix is:

[10.5−0.5400.50.510215]

[10.5−0.5401120215]

For row 3: subtract 2 times row 2 from row 3:

R3−2R2⟹R3=[00−11]

Now the matrix is in upper-triangular form:

[U|c]=[10.5−0.54011200−11]

III. Back Substitution:

y+1(−1)=2⟹y=3.

x+0.5(3)−0.5(−1)=4⟹x+1.5+0.5=4⟹x=2.

The solution is x=(2,3,−1)⊤.

Advantages

Limitations

Table of Contents

    Gaussian Elimination
    1. Mathematical Formulation
    2. Derivation
    3. Algorithm Steps
    4. Example
    5. Advantages
    6. Limitations