Like much mathematics, finding the inverse of a matrix is more difficult to describe than it is to actually do, so this will effectively be a worked example. Note that only square matrices can have an inverse, and that not all square matrices actually do have an inverse (specifically, if a matrix has a determinant of 0, it is said to be singular and has no inverse. This is because the inverse involves dividing by the determinant, and dividing by 0 causes all sorts of problems)

For a 2X2 matrix, many people simply use an identity for the inverse- if the matrix is

a b
c d

Then the inverse is 1/(ad-cb) * d -b
				-c a

i.e., you switch a and d, and invert the signs on b and c. However, it is not obvious how to generalise this to larger matrices, even the next highest matrix , a 3X3.

Instead, a more systematic approach needs to be employed. Finding the inverse of a 3X3 matrix will be shown; and then it will be illustrated how this generates the same result as the above identity for a 2X2. With a bit more number crunching the inverse of a 4X4 can be found by essentially the same techniques.

To find the inverse we begin by constructing the matrix of minors. Take each element of the matrix and replace it with the determinant of what remains when both the row and column of that element are erased.

In the case of a 3X3 matrix this means finding the determinant of 9 different 2X2 matrices- use the fact that
det a b
    c d  = ad-bc


for now- this will be explained later. For a 4X4 you are faced with finding the determinant of 16 3X3 matrices- which is why i'm using a 3X3 example. As part of finding the inverse of a 3X3 involves finding the determinant, you will find everything you need to know for solving the 4X4 from the example of a 3X3.

To make things a bit clearer, let us consider an example.

   2 -1  2
A= 1 -1  1
   2  1 -3


There would be brackets but plain text is restrictive, hopefully you get the idea.

To construct the matrix of minors, we need the minors! For the top left entry in the matrix of minors, we will want the determinant of

-1 1
1 -3

as this is the matrix left when the top row and left column are erased from A. This is (-1)(-3) - (1)(1) = 3-1 =2.

Then to get the top row, middle entry we this time erase the top row, middle column, leaving

1 1
2 -3

which gives us a determinant of (1)(-3) - (1)(2) = -5.

In this way we build up a matrix of minors as follows:

2 -5 3
1 -10 4
1 0 -1

It is now necessary to create the matrix of cofactors. For this we apply the alternating law of signs:

+ - +
- + -
+ - +

In other words, the top left value remains unchanged, the sign on the top row, middle column entry is inverted, the top row, right column remains unchanged etc. Note that you are not trying to create an alternating pattern, just inverting the signs of every other entry.

Hence for our example we get

 2   5   3
-1 -10  -4
 1   0  -1


We now need the transpose of this matrix: switching rows for columns to get
2  -1  1
5 -10  0
3  -4 -1


This is the matrix part of the inverse: all that remains is to find the determinant and divide by this to get the inverse of A.

There are two approaches here. If you are a mathematician, the best route is to multiply the matrix you have found by A. This should give a matrix which is a multiple of I, the identity matrix and so the determinant is 1 over this multiple. The advantage of this route is that it checks the matrix you have found is indeed correct- if you don't get something that looks like n lots of the identity matrix, you have gone wrong. Whilst I won't go into the details of matrix multiplication here, for our example we have:

2 -1   2     2  -1  1       5 0 0
1 -1   1  x  5 -10  0   =   0 5 0
2  1  -3     3  -4 -1       0 0 5


Hence we want to divide by 5 to get the Identity matrix, and thus the determinant of A, our original matrix, is 5. Note that although matrix multiplication is non-commutative, the order in this particular case doesn't matter. For our example, this gives us an inverse of A ( A-1) of:
1    2  -1  1
- x  5 -10  0
5    3  -4 -1

The alternative approach is if you don't want to have to do the multiplication- for example, if you want to write a computer program to find the inverse and thus can trust the calculations of the matrix of minors and cofactors- which you'll have to, as there is no actual check that A*A^-1 actually gives I by this method. It is also the way in which you'll want to find the determinant when building the matrix of minors for a 4X4 matrix, and it illustrates why the determinant of a 2X2 is ad- bc.

Basically, you multiply the values found in the top row elements of the matrix by the determinant of the corresponding minor- ie, by the corresponding value in the matrix of minors. You then take the first, subtract the second, and add the third. (note that for larger matrices you continue this process of addition and subtraction, ie subtract the fourth, add the fifth etc.) This process is applied to the top row only, not the whole matrix.

For our example, we get (2)(2) - (-1)(-5) + (2)(3) = 4 -5 + 6 = 5 as before.

Having shown this for the 3X3, hopefully you get the idea for the 4X4 and higher- construct a matrix of minors by finding the determinants of the minors, apply the alternating rule of signs to get the matrix of cofactors, take the transpose, then find the determinant by multiplying with the original (which also provides a check) or by using the top row elements (which doesn't but is quicker and easier).

All that remains to be shown is that the claimed value of the inverse and determinant of a 2X2 still hold true when this method is used rather than just recalling the identity.

By constructing our matrix of minors we get

d c
b a

As the determinant of a 1X1 matrix is the value of the only element, and by erasing the row and column containing an element in a 2X2 we are left with a minor that is just a 1X1 matrix.

Next, the matrix of cofactors is

d -c
-b a

Then the transpose is

d -b
-c a

Then, to find the determinant we use the second technique: (d)(a) - (-b)(-c) which is ad-bc as stated.




 					       a b c
In general, the inverse matrix of a 3X3 matrix d e f
					       g h i

is 

	    1                       (ei-fh)   (ch-bi)   (bf-ce)
-----------------------------   x   (fg-di)   (ai-cg)   (cd-af)
a(ei-fh) - b(di-fg) + c(dh-eg)      (dh-eg)   (bg-ah)   (ae-bd)


As the following writeups explain, this is far from the optimum way to find the inverse in practice. It is however, the way in which it is defined- working from this definition we can then introduce the concepts such as row operations that allow us to find the inverse of big matrices before the heat death of the universe. Whilst an appreciation of this approach is needed to start out with matrix mathematics in the first place (it's probably all you would see at A-level) and to understand subsequent work, chances are you'd never use it to invert anything bigger than 3*3!

There is another simpler (simple as in easier to remember, it is quite slow for big matrices and if you aren't very fast performing linear operations) to invert matrices. If you are familiar with solving linear equations using matricial notation, maybe you'll find this method easy.

The method:

1. Put an NxN identity matrix next to your NxN matrix, so you get an Nx2N matrix.
2. Use elemental row transforms to turn the original part of the matrix into an identity matrix.
3. The part of the matrix that started as an identity matrix is now the inverse of your matrix.

Say we've got a square matrix like this one:

+ 3 2 1 +
| 2 1 0 |
+ 0 2 2 +

Now we'll put next to it an identity matrix:

+ 3 2 1 | 1 0 0 +
| 2 1 0 | 0 1 0 |
+ 0 2 2 | 0 0 1 +

Our task now is to turn the left part of this matrix (that is, the matrix we are trying to invert) into an identity matrix, using linear row operations.

As a first step, we will divide the first row by three so we have a one in the left hand corner:

+ 1 2/3 1/3 | 1/3 0 0 +
| 2  1   0  |  0  1 0 |
+ 0  2   2  |  0  0 1 +

Now we substract the first row multiplied by two to the second row:

+ 1  2/3  1/3 |  1/3 0 0 +
| 0 -1/3 -2/3 | -2/3 1 0 |
+ 0   2    2  |   0  0 1 +

We multiply the second row by -3 to get a one

+ 1  2/3  1/3 |  1/3  0 0 +
| 0   1    2  |   2  -3 0 |
+ 0   2    2  |   0   0 1 +

Now we substract the second row doubled to the third

+ 1  2/3  1/3 |  1/3  0 0 +
| 0   1    2  |   2  -3 0 |
+ 0   0   -2  |  -4   6 1 +

We divide the last row by -2 to obtain our traditional one

+ 1  2/3  1/3 |  1/3  0   0  +
| 0   1    2  |   2  -3   0  |
+ 0   0    1  |   2  -3 -1/2 +

Now we substract from the first row one third of the last and from the second one, double the last.

+ 1  2/3   0  | -1/3  1  1/6 +
| 0   1    0  |  -2   3   1  |
+ 0   0    1  |   2  -3 -1/2 +

And we only have to substract 2/3 of the second to the first to end:

+ 1   0    0  |   1  -1 -1/2 +
| 0   1    0  |  -2   3   1  |
+ 0   0    1  |   2  -3 -1/2 +

Let's check the result:

+ 3 2 1 +   +  1 -1 -1/2 +   + 1 0 0 +
| 2 1 0 | x | -2  3   1  | = | 0 1 0 | 
+ 0 2 2 +   +  2 -3 -1/2 +   + 0 0 1 +

Thank god! I have made no mistakes!!

As an exercise to the reader, you can apply the method to general matrices like these:

          + a b c +
+ a b +   | d e f |
+ c d + , + g h i + , ...

Doing this will (hopefully) give you the formulas shown on Wntrmute's writeup (I have never had patience to do a 3x3 general matrix, let alone anything bigger, but the 2x2 case is not very complicated).

The proof of the method outlined by koala is quite simple. The method claims that if a sequence L of row operations turns a square matrix A into the identity then applying that same sequence L to the identity yields A-1.

To prove this, we are first going to consider the matrices Lij(λ), which are such that:
lij = λ
if p=q then lpq=1
else lpq=0

so for example, if we are dealing with 3 x 3 matrices, then

       /1 0 4\
L13(4)=|0 1 0 |
       \0 0 1/
Let us now consider the product B=Lij(λ)A.
We know our summation convention:
bpq=lpkakq
  • if we have i=j then :
    • if p = i then biq=li kakq
      li k = 0 if i ≠ k, therefore biq = liiaiq=λaiq
    • if p ≠ i then the above remains true, except that lpp = 1, therefore bpq = apq
    From this it is clear that multiplying A by Lii(λ) multiplies the ith row of A by λ and leaving the other rows untouched.
  • if i ≠ j then we can see that if p = i then biq=likakq =liiaiq + lijajq=aiq + λajq
    multiplying A by Lij(λ) is adding λ times the jth row of A to the ith row, leaving the rest untouched.
Thus we can perform any of the row operations ""multiply a row by λ" and "add λ times a row to another row" by multiplying A by some matrix Lij(λ). Note also that for all the row operations used in this method the Lij(λ) are triangular with non zero terms on the diagonal : they are invertible.

We need one more type of matrix : one that will allow us to swap the ith and jth row. Fortunately, this is not too difficult. we simply have Sij(with i ≠ j) which is such that :
sij = 1
sji = 1
sii = 0
sjj = 0
and all the other terms on the diagonal are 1. You may wish to check for yourself that this matrix does what I claim, and that it is invertible.

We can now perform all the row operations needed by multiplying by an invertible matrix. So what our method is actually doing is finding a series of m invertible matrices such that Lm...L2L1A= I
Lm...L2L1 represents our sequence of row operations. Multiplying on the right side by A-1 yields Lm...L2L1I= A-1, which is what we wanted : performing our sequence of row operations on the identity gives us A-1.

You may also be interested in knowing what happens if this method is applied to a singular matrix. What will happen is that eventually you will have a row with nothing but zeros, it will not be possible to transform the matrix into the identity.

From a pedagogical point of view, examples of matrix inversion are invariably coupled with the use of the determinant and 3x3 matrices.

From a numerical analysis point of view, it is almost never desirable to actually compute the inverse of a matrix. On a practical level, the inverse of a matrix is almost never what you want to compute for "real" matrices. The reasons are as follows:
  • The determinant will overflow IEEE754 doubles for "real" sized matrices
  • The inversion of a matrix takes O(n3) operations. One typically wants to solve for a vector x=A-1b or matrix C=A-1B. In this case, multiplying by the inverse is far more computationally expensive than performing an LU factorisation, followed by right hand solves.
There are instances where a generalized matrix inversion is unavoidable. In this case, one should still avoid the use of the determinant. As suggested by koala's post, one can perform a factorisation (LU or Cholesky, for example), and employ the columns of the identity matrix as multiple right hand sides.

Log in or register to write something here or to contact authors.