Gaussian Elimination

The Master Algorithm

We've framed our central problem, Ax=bAx = b. We understand it from both the row and column perspectives. Now, we need a systematic, foolproof method for finding the solution vector xx. That method is Gaussian Elimination.

This isn't about clever tricks or lucky guesses. This is an algorithm—a step-by-step mechanical process that will work on any system of linear equations, no matter how large. It is the computational backbone of linear algebra. The goal of Gaussian Elimination is simple: to make an intimidating system of equations progressively easier until the solution is obvious.

We do this by transforming our system into an upper triangular form. An upper triangular system is one where all the coefficients below the main diagonal are zero. Why? Because it's incredibly easy to solve.

Intimidating System
{2x+y+z=54x6y=22x+7y+2z=9\begin{cases} 2x + y + z = 5 \\ 4x - 6y = -2 \\ -2x + 7y + 2z = 9 \end{cases}
Easy (Upper Triangular) System
{2x+y+z=58y2z=12z=2\begin{cases} 2x + y + z = 5 \\ \quad -8y - 2z = -12 \\ \quad \quad \quad z = 2 \end{cases}

Look at that second system. You can see the solution just by looking at it! If z=2z=2, you can plug that into the second equation to find yy, and then plug both yy and zz into the first equation to find xx. This easy, final step is called back substitution.

The Tools: Elementary Row Operations
The algorithm works by applying a set of three simple, "legal" moves called elementary row operations. These moves are guaranteed not to change the underlying solution of the system.
  1. Swapping: You can swap any two rows. (This is like reordering your equations).
  2. Scaling: You can multiply any row by a non-zero constant. (This is like multiplying both sides of an equation by a number).
  3. Replacement: You can replace one row by adding to it a multiple of another row. (This is the workhorse of elimination).
The Augmented Matrix: A More Compact Notation
Writing out the x,y,zx, y, z variables at every step is tedious. To make our work cleaner and more suitable for computers, we use a shorthand called an augmented matrix.

We simply take the coefficient matrix AA and the result vector bb and combine them, separated by a vertical line.

{2x+y+z=54x6y=22x+7y+2z=9\begin{cases} 2x + y + z = 5 \\ 4x - 6y = -2 \\ -2x + 7y + 2z = 9 \end{cases}
[211546022729]\left[\begin{array}{ccc|c} 2 & 1 & 1 & 5 \\ 4 & -6 & 0 & -2 \\ -2 & 7 & 2 & 9 \end{array}\right]

Our goal is to use the row operations to turn the left side of this matrix into an upper triangular form.

The Algorithm in Action: Step-by-Step
Let's solve our system. Our strategy is to eliminate coefficients column by column, from top to bottom.

Our Starting Matrix:

[211546022729]\left[\begin{array}{ccc|c} 2 & 1 & 1 & 5 \\ 4 & -6 & 0 & -2 \\ -2 & 7 & 2 & 9 \end{array}\right]

The first non-zero entry in the first row is called the pivot. Here, our first pivot is the `2` in the top-left corner. We will use this pivot to eliminate all the entries below it in the first column.

Step 1: Eliminate the `4` in Row 2.

Operation: R2R22R1R_2 \rightarrow R_2 - 2 \cdot R_1.

[2115082122729]\left[\begin{array}{ccc|c} 2 & 1 & 1 & 5 \\ 0 & -8 & -2 & -12 \\ -2 & 7 & 2 & 9 \end{array}\right]

Step 2: Eliminate the `-2` in Row 3.

Operation: R3R3+R1R_3 \rightarrow R_3 + R_1.

[21150821208314]\left[\begin{array}{ccc|c} 2 & 1 & 1 & 5 \\ 0 & -8 & -2 & -12 \\ 0 & 8 & 3 & 14 \end{array}\right]

Step 3: Eliminate the `8` in Row 3.

We have cleared the first column. Now we move to the next pivot, the `-8` in Row 2, and use it to eliminate everything below it.

Operation: R3R3+R2R_3 \rightarrow R_3 + R_2.

[2115082120012]\left[\begin{array}{ccc|c} 2 & 1 & 1 & 5 \\ 0 & -8 & -2 & -12 \\ 0 & 0 & 1 & 2 \end{array}\right]

Our final matrix is in row echelon form. The left side is upper triangular. We have achieved our goal.

The Payoff: Back Substitution

Now we translate this matrix back into equations and solve from the bottom up:

{2x+y+z=58y2z=12z=2\begin{cases} 2x + y + z = 5 \\ \quad -8y - 2z = -12 \\ \quad \quad \quad z = 2 \end{cases}
  1. We know z=2z = 2.
  2. Plug z=2z=2 into the second equation: 8y2(2)=128y=8y=1-8y - 2(2) = -12 \Rightarrow -8y = -8 \Rightarrow y = 1.
  3. Plug y=1y=1 and z=2z=2 into the first equation: 2x+(1)+(2)=52x=2x=12x + (1) + (2) = 5 \Rightarrow 2x = 2 \Rightarrow x = 1.

The solution is x=1,y=1,z=2x=1, y=1, z=2. Our solution vector is x=[1,1,2]x = [1, 1, 2]. We have conquered the system.

Summary: The Universal Solver
  1. Setup: Write the system as an augmented matrix.
  2. Goal: Use row operations to transform the matrix into row echelon form (upper triangular).
  3. Strategy: Use the pivot in each row to eliminate the entries below it, column by column.
  4. Solve: Use back substitution on the simplified system.

This process will always work, and it lays the groundwork for understanding the deep structure of matrices, which we'll explore in the coming lessons.

Up Next: What happens when things don't go so smoothly? We will use Gaussian Elimination to analyze systems that have **no solution** or **infinitely many solutions**, and understand what these outcomes mean both algebraically and geometrically.