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 (at the bottom of the page).
(If you need some background first, go back to the Introduction to Matrices).
Choose the matrix size you are interested in and then click the button.
Matrix A:
The randomly-generated example appears below.
Phone users
NOTE: If you're on a phone, you can scroll any wide matrices on this page to the right or left to see the whole expression.
Example (3 × 3)
Find the inverse of the matrix A using Gauss-Jordan elimination.
A = | 9 | 2 | 10 | ||
11 | 6 | 4 | |||
5 | 13 | 7 |
Our Procedure
We write matrix A on the left and the Identity matrix I on its right separated with a dotted line, as follows. The result is called an augmented matrix.
We include row numbers to make it clearer.
9 | 2 | 10 | |
11 | 6 | 4 | |
5 | 13 | 7 |
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:
- We get a "1" in the top left corner by dividing the first row
- Then we get "0" in the rest of the first column
- Then we need to get "1" in the second row, second column
- 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:
9 | 2 | 10 | |
11 | 6 | 4 | |
5 | 13 | 7 |
1 | 0 | 0 | Row[1] | |
0 | 1 | 0 | Row[2] | |
0 | 0 | 1 | Row[3] |
New Row [1]
Divide Row [1] by 9 (to give us a "1" in the desired position):
This gives us:
1 | 0.2222 | 1.1111 | |
11 | 6 | 4 | |
5 | 13 | 7 |
0.1111 | 0 | 0 | Row[1] | |
0 | 1 | 0 | Row[2] | |
0 | 0 | 1 | Row[3] |
New Row [2]
Row[2] − 11 × Row[1] (to give us 0 in the desired position):
11 − 11 × 1 = 0
6 − 11 × 0.2222 = 3.5556
4 − 11 × 1.1111 = -8.2222
0 − 11 × 0.1111 = -1.2222
1 − 11 × 0 = 1
0 − 11 × 0 = 0
This gives us our new Row [2]:
1 | 0.2222 | 1.1111 | |
0 | 3.5556 | -8.2222 | |
5 | 13 | 7 |
0.1111 | 0 | 0 | Row[1] | |
-1.2222 | 1 | 0 | Row[2] | |
0 | 0 | 1 | Row[3] |
New Row [3]
Row[3] − 5 × Row[1] (to give us 0 in the desired position):
5 − 5 × 1 = 0
13 − 5 × 0.2222 = 11.889
7 − 5 × 1.1111 = 1.4444
0 − 5 × 0.1111 = -0.5556
0 − 5 × 0 = 0
1 − 5 × 0 = 1
This gives us our new Row [3]:
1 | 0.2222 | 1.1111 | |
0 | 3.5556 | -8.2222 | |
0 | 11.889 | 1.4444 |
0.1111 | 0 | 0 | Row[1] | |
-1.2222 | 1 | 0 | Row[2] | |
-0.5556 | 0 | 1 | Row[3] |
New Row [2]
Divide Row [2] by 3.5556 (to give us a "1" in the desired position):
This gives us:
1 | 0.2222 | 1.1111 | |
0 | 1 | -2.3125 | |
0 | 11.889 | 1.4444 |
0.1111 | 0 | 0 | Row[1] | |
-0.3438 | 0.2813 | 0 | Row[2] | |
-0.5556 | 0 | 1 | Row[3] |
New Row [1]
Row[1] − 0.2222 × Row[2] (to give us 0 in the desired position):
1 − 0.2222 × 0 = 1
0.2222 − 0.2222 × 1 = 0
1.1111 − 0.2222 × -2.3125 = 1.625
0.1111 − 0.2222 × -0.3438 = 0.1875
0 − 0.2222 × 0.2813 = -0.0625
0 − 0.2222 × 0 = 0
This gives us our new Row [1]:
1 | 0 | 1.625 | |
0 | 1 | -2.3125 | |
0 | 11.889 | 1.4444 |
0.1875 | -0.0625 | 0 | Row[1] | |
-0.3438 | 0.2813 | 0 | Row[2] | |
-0.5556 | 0 | 1 | Row[3] |
New Row [3]
Row[3] − 11.889 × Row[2] (to give us 0 in the desired position):
0 − 11.889 × 0 = 0
11.889 − 11.889 × 1 = 0
1.4444 − 11.889 × -2.3125 = 28.938
-0.5556 − 11.889 × -0.3438 = 3.5313
0 − 11.889 × 0.2813 = -3.3438
1 − 11.889 × 0 = 1
This gives us our new Row [3]:
1 | 0 | 1.625 | |
0 | 1 | -2.3125 | |
0 | 0 | 28.938 |
0.1875 | -0.0625 | 0 | Row[1] | |
-0.3438 | 0.2813 | 0 | Row[2] | |
3.5313 | -3.3438 | 1 | Row[3] |
New Row [3]
Divide Row [3] by 28.938 (to give us a "1" in the desired position):
This gives us:
1 | 0 | 1.625 | |
0 | 1 | -2.3125 | |
0 | 0 | 1 |
0.1875 | -0.0625 | 0 | Row[1] | |
-0.3438 | 0.2813 | 0 | Row[2] | |
0.122 | -0.1156 | 0.0346 | Row[3] |
New Row [1]
Row[1] − 1.625 × Row[3] (to give us 0 in the desired position):
1 − 1.625 × 0 = 1
0 − 1.625 × 0 = 0
1.625 − 1.625 × 1 = 0
0.1875 − 1.625 × 0.122 = -0.0108
-0.0625 − 1.625 × -0.1156 = 0.1253
0 − 1.625 × 0.0346 = -0.0562
This gives us our new Row [1]:
1 | 0 | 0 | |
0 | 1 | -2.3125 | |
0 | 0 | 1 |
-0.0108 | 0.1253 | -0.0562 | Row[1] | |
-0.3438 | 0.2813 | 0 | Row[2] | |
0.122 | -0.1156 | 0.0346 | Row[3] |
New Row [2]
Row[2] − -2.3125 × Row[3] (to give us 0 in the desired position):
0 − -2.3125 × 0 = 0
1 − -2.3125 × 0 = 1
-2.3125 − -2.3125 × 1 = 0
-0.3438 − -2.3125 × 0.122 = -0.0616
0.2813 − -2.3125 × -0.1156 = 0.014
0 − -2.3125 × 0.0346 = 0.0799
This gives us our new Row [2]:
1 | 0 | 0 | |
0 | 1 | 0 | |
0 | 0 | 1 |
-0.0108 | 0.1253 | -0.0562 | Row[1] | |
-0.0616 | 0.014 | 0.0799 | Row[2] | |
0.122 | -0.1156 | 0.0346 | 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 = | -0.0108 | 0.1253 | -0.0562 | ||
-0.0616 | 0.014 | 0.0799 | |||
0.122 | -0.1156 | 0.0346 |
Things to Note
- 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.
- Always write down what you are doing in each step - it is very easy to get lost!
- 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.)
- 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?
You can go back up to the top of the page and choose another example.