Inverse of a Matrix using Gauss-Jordan Elimination

by M. Bourne

In this section we see how Gauss-Jordan Elimination works using examples.

You can re-load this page as many times as you like and get a new set of numbers each time. You can also choose a different size matrix.

(If you need some background first, go back to the Introduction to Matrices).

Example

Find the inverse of the matrix A using Gauss-Jordan elimination.

A =   2 10 3  
4 6 5
7 8 9

Our Procedure

We write matrix A on the left and the Identity matrix I on its right as follows. The result is called an augmented matrix.

We include row numbers to make it clearer.

  2 10 3
4 6 5
7 8 9
1 0 0   Row[1]
0 1 0 Row[2]
0 0 1 Row[3]

Next we do several row operations on the 2 matrices and our aim is to end up with the identity matrix on the left, like this:

  1 0 0
0 1 0
0 0 1
? ? ?   Row[1]
? ? ? Row[2]
? ? ? Row[3]

(Technically, we are reducing matrix A to reduced row echelon form (also called row canonical form).

The resulting matrix on the right will be the inverse matrix of A.

Our row operations procedure is as follows:

  1. We get a "1" in the top left corner by dividing the first row
  2. Then we get "0" in the rest of the first column
  3. Then we need to get "1" in the second row, second column
  4. Then we make all the other entries in the second column "0".

We keep going like this until we are left with the identity matrix on the left.

Let's now go ahead and find the inverse.

Solution

We start with:

  2 10 3
4 6 5
7 8 9
1 0 0   Row[1]
0 1 0 Row[2]
0 0 1 Row[3]

New Row [1]

Divide Row [1] by 2 (to give us a "1" in the desired position):

This gives us:

  1 5 1.5
4 6 5
7 8 9
0.5 0 0   Row[1]
0 1 0 Row[2]
0 0 1 Row[3]

New Row [2]

Row[2] − 4 × Row[1] (to give us 0 in the desired position):

4 − 4 × 1 = 0
6 − 4 × 5 = -14
5 − 4 × 1.5 = -1
0 − 4 × 0.5 = -2
1 − 4 × 0 = 1
0 − 4 × 0 = 0

This gives us our new Row [2]:

  1 5 1.5
0 -14 -1
7 8 9
0.5 0 0   Row[1]
-2 1 0 Row[2]
0 0 1 Row[3]

New Row [3]

Row[3] − 7 × Row[1] (to give us 0 in the desired position):

7 − 7 × 1 = 0
8 − 7 × 5 = -27
9 − 7 × 1.5 = -1.5
0 − 7 × 0.5 = -3.5
0 − 7 × 0 = 0
1 − 7 × 0 = 1

This gives us our new Row [3]:

  1 5 1.5
0 -14 -1
0 -27 -1.5
0.5 0 0   Row[1]
-2 1 0 Row[2]
-3.5 0 1 Row[3]

New Row [2]

Divide Row [2] by -14 (to give us a "1" in the desired position):

This gives us:

  1 5 1.5
0 1 0.0714
0 -27 -1.5
0.5 0 0   Row[1]
0.1429 -0.0714 0 Row[2]
-3.5 0 1 Row[3]

New Row [1]

Row[1] − 5 × Row[2] (to give us 0 in the desired position):

1 − 5 × 0 = 1
5 − 5 × 1 = 0
1.5 − 5 × 0.0714 = 1.1429
0.5 − 5 × 0.1429 = -0.2143
0 − 5 × -0.0714 = 0.3571
0 − 5 × 0 = 0

This gives us our new Row [1]:

  1 0 1.1429
0 1 0.0714
0 -27 -1.5
-0.2143 0.3571 0   Row[1]
0.1429 -0.0714 0 Row[2]
-3.5 0 1 Row[3]

New Row [3]

Row[3] − -27 × Row[2] (to give us 0 in the desired position):

0 − -27 × 0 = 0
-27 − -27 × 1 = 0
-1.5 − -27 × 0.0714 = 0.4286
-3.5 − -27 × 0.1429 = 0.3571
0 − -27 × -0.0714 = -1.9286
1 − -27 × 0 = 1

This gives us our new Row [3]:

  1 0 1.1429
0 1 0.0714
0 0 0.4286
-0.2143 0.3571 0   Row[1]
0.1429 -0.0714 0 Row[2]
0.3571 -1.9286 1 Row[3]

New Row [3]

Divide Row [3] by 0.4286 (to give us a "1" in the desired position):

This gives us:

  1 0 1.1429
0 1 0.0714
0 0 1
-0.2143 0.3571 0   Row[1]
0.1429 -0.0714 0 Row[2]
0.8333 -4.5 2.3333 Row[3]

New Row [1]

Row[1] − 1.1429 × Row[3] (to give us 0 in the desired position):

1 − 1.1429 × 0 = 1
0 − 1.1429 × 0 = 0
1.1429 − 1.1429 × 1 = 0
-0.2143 − 1.1429 × 0.8333 = -1.1667
0.3571 − 1.1429 × -4.5 = 5.5
0 − 1.1429 × 2.3333 = -2.6667

This gives us our new Row [1]:

  1 0 0
0 1 0.0714
0 0 1
-1.1667 5.5 -2.6667   Row[1]
0.1429 -0.0714 0 Row[2]
0.8333 -4.5 2.3333 Row[3]

New Row [2]

Row[2] − 0.0714 × Row[3] (to give us 0 in the desired position):

0 − 0.0714 × 0 = 0
1 − 0.0714 × 0 = 1
0.0714 − 0.0714 × 1 = 0
0.1429 − 0.0714 × 0.8333 = 0.0833
-0.0714 − 0.0714 × -4.5 = 0.25
0 − 0.0714 × 2.3333 = -0.1667

This gives us our new Row [2]:

  1 0 0
0 1 0
0 0 1
-1.1667 5.5 -2.6667   Row[1]
0.0833 0.25 -0.1667 Row[2]
0.8333 -4.5 2.3333 Row[3]

We have achieved our goal of producing the Identity matrix on the left. So we can conclude the inverse of the matrix A is the right hand portion of the augmented matrix:

A−1 =   -1.1667 5.5 -2.6667  
0.0833 0.25 -0.1667
0.8333 -4.5 2.3333

Things to Note

  1. The above explanation shows all steps. A human can usually take a few shortcuts. Also, sometimes there is already a "1" or a "0" in the correct position, and in those cases, we would not need to do anything for that step.
  2. Always write down what you are doing in each step - it is very easy to get lost!
  3. I have shown results correct to 4 decimal place, but best possible accuracy was used throughout. Be aware that small errors from rounding will accumulate throughout the problem. Always use full calculator accuracy! (Make full use of your calculator's memory.)
  4. Very occasionally there are strange results because of the computer's internal representation of numbers. That is, it may store "1" as 0.999999999872.

See another?

Choose the matrix size you are interested in and then click the button.

Matrix A:

2×2 matrix
3×3 matrix
4×4 matrix
5×5 matrix

Didn't find what you are looking for on this page? Try search:

Online Algebra Solver

This algebra solver can solve a wide range of math problems. (Please be patient while it loads.)

Ready for a break?

shadow factory game

Play a math game.

(Well, not really a math game, but each game was made using math...)

The IntMath Newsletter

Sign up for the free IntMath Newsletter. Get math study tips, information, news and updates each fortnight. Join thousands of satisfied students, teachers and parents!

Given name: * required

Family name:

email: * required

See the Interactive Mathematics spam guarantee.

Share IntMath!

Short URL for this Page

Save typing! You can use this URL to reach this page:

intmath.com/gaussjordan

Algebra Lessons on DVD

get MathTutorDVDs

Easy to understand algebra lessons on DVD. See samples before you commit.

More info: Algebra videos

 

axs