Skip to main content
Search IntMath
Close

Inverse of a matrix by Gauss-Jordan elimination

By Murray Bourne, 11 Jan 2011

Matrices are very important in mathematics, since they are a convenient way to represent large systems that involve many variables. Matrices are used in cryptography, economics, statics, climate modelling, probability, suspension systems and electronics. Even Google's search engine uses matrices!

Most students struggle with so-called "elementary row operations" when solving systems of equations and when finding the inverse of a matrix.

Why? Because there are many choices (do I multiply this line, or subtract this line from that line...?) and many places to get lost - and worse - many places to make mistakes).

My strong feeling is that we should let computers do such mundane things. However, many math courses still require students to do it by hand (usually only up to 3×3, but even that can have enough complications). Also, someone needs to know how to find inverses of matrices from scratch, otherwise how will the programmers of the future write code to solve problems like the ones listed above?

I added a new section to the Matrices chapter, Inverse of a matrix by Gauss-Jordan elimination.

You can see examples of how to find the inverse of 2×2, 3×3, and 4×4 matrices using a method which will always get you there.

Our method

We write the given matrix on the left and the Identity matrix on its right (forming an augmented matrix). Our aim is to do row operations to produce the identity matrix on the left. We proceed as follows:

  1. We divide the first row by the number in the top-left position, to produce a "1" in that position.
  2. Then we do row operations to get zeroes down the rest of the first column.
  3. Then we divide the second row by the number in the 2nd row, 2nd column, giving us a "1" in that position.
  4. Next, we get zeroes in the rest of that column.

We continue on like this until we get "1" in the diagonal and zeroes elsewhere - in other words, the identity matrix. Our required inverse matrix is what is left on the right.

You can see as many examples as you like by refreshing the page (when you get there).

The link again: Inverse of a matrix by Gauss-Jordan elimination

What do you think of this method? Does it make sense?

[For the technically-minded: I wrote the code for the page in PHP. The output uses text and tables, not images, making for quicker load times.]

See the 3 Comments below.

3 Comments on “Inverse of a matrix by Gauss-Jordan elimination”

  1. Pat Ballew says:

    Murray,
    I would think that the number of operations you have used to find the inverse of the matrix is as great or greater than the the number to solve the system by reduced row operations, and you still have to do the multiplication A' B to get the solution which may not be efficient at all if the system is large..John Cook at endeavor has some nice comments on this here.

    More importantly, What do you do if the system is not invertible. Assume the simplest idea of all, two planes intersect in a line. The inverse simply will not exist.
    I have commented on this problem here .

  2. Murray says:

    Thanks for your input, Pat!

    I'm always in a hurry to get posts out, and I forgot to mention that I produced the page for the (many) people who arrive on my site having searched on "find the inverse of a matrix" or similar. My aim here (and page title) was "find an inverse", not "solve a system of equations".

    I agree that finding the inverse is quite useless if you are doing it to solve a system of equations! (Actually, I intimated quite strongly I think doing most of this on paper is quite unnecessary these days). In fact, this is one topic that really needs an overhaul in most math courses, when it comes to what is included and what is left to computers.

    The next page I'll put up in the matrices chapter (when I get time to nail the programming side) will be on using reduced row echelon form to solve a system of equations.

    On the efficiency issue - I did mention a human should be able to spot short cuts. To keep the post a reasonable length, I didn't go into the cases where we need to swap rows and so on. In fact, depending on the random numbers generated on my page, it will go ahead and do a row operation to (say) get a zero when there is already a zero in that position. Hence again my statement about humans seeing short cuts.

    On the invertibility issue - yes, but this tends to "come out in the wash" - we very quickly get to a row operation that gives us all zeroes or whatever and this alerts us to the collinear and parallel cases. Actually, I think this issue is more important than the calculation side. What is going on when we can't find a solution is a crucial part of understanding what solving a system means, but alas, there is usually little time to talk about it because the students are lost in some row operations...

  3. Philip Petrov says:

    We must not only know how to use the tools, but also how these tools work. This is the only way to make quality progress. Elsewere we will be just users, not inventors/optimizers/researchers.

    The same applies to our students. Do we want to just teach them dogmatically "how to do this", or we want to give them a base for "upgrading this"? I beleive that our aim should be the second. The students must know how to inverse matrix before they really use the "electronic matrix inverse tool" in practice.

Leave a comment




Comment Preview

HTML: You can use simple tags like <b>, <a href="...">, etc.

To enter math, you can can either:

  1. Use simple calculator-like input in the following format (surround your math in backticks, or qq on tablet or phone):
    `a^2 = sqrt(b^2 + c^2)`
    (See more on ASCIIMath syntax); or
  2. Use simple LaTeX in the following format. Surround your math with \( and \).
    \( \int g dx = \sqrt{\frac{a}{b}} \)
    (This is standard simple LaTeX.)

NOTE: You can mix both types of math entry in your comment.

top

Tips, tricks, lessons, and tutoring to help reduce test anxiety and move to the top of the class.