# 6: More Matrices: Inverse, powers, and projection

This lecture we are going to finish of some of the things we started in the last lecture. We will also look at an application of matrix multiplication that involves taking powers of matrices, and we will look at the projection map in more detail.

## The inverse of a matrix

We started this topic in lecture 5, so see there for what we'll be talking about.
Remember, although we'll define the inverse algabraically, it has a concrete geometric meaning---what is the transformation you have to do to undo the one you did? This is important to remember.
For insight into the algebraic side, think about what do we mean when we write 1/3? We mean "a number that when you take three of it, you get 1". 1/3 is the "inverse" of 3. Can a matrix have an inverse? What does this mean? What would the inverse be?

## The identity matrix

Remember what multiplication of matrices means? If you do the transformation A, and then B, we write
BA

And for the transformation that does nothing, we write I, which means the identity. For R2, it looks like this: Or in some other dimensions: The identity just gives you back what you put in, so it tells you the identity of something:
Some things to notice about the identity:
It's square
---Because you are sending a point in Rn to the same point, also in Rn
It has 1s down the diagonal, and zeros elsewhere
---Because the first column is the image of (1,0,0,...0), the second column is the image of (0,1,0,0,...,0), the third column is the image of (0,0,1,0,...,0), and so on. Each of these vectors just gets mapped to itself, so the images are what you start with.

## Inverse matrices

If a transformation T is a dilation of factor two, it is represented by a matrix (lets call the matrix A), given by
 / 2 0 \ \ 0 2 /

If a transformation R is a contraction of factor half, it is represented by a matrix (lets call the matrix B), given by
 / 1/2 0 \ \ 0 1/2 /
What happens if you expand by two and then contract by half? The overall effect is nothing, that is, the overall effect is described by the identity matrix. And the algebra looks like:
 / 1/2 0 \ / 2 0 \ = / 1 1 \ \ 0 1/2 / \ 0 2 / \ 0 1 /
So, A is the inverse of B. If I have a matrix C, the inverse is what ever you multiply the matrix by to get back to I. So, the inverse is a matrix D, with
DC=I

We also get
CD=I

Ie, if you stretch and then shrink, it's the same as if you shrink and then stretch - ie, nothing over all.
Note, for most matrices, when you multiply them together in a different order, you get different results.
Another important note: some matrices do not have inverses. We'll look at one later - projections.
We will describe in class how to find the inverse of a matrix. The method is described on page 113, section 3.1 of the text book.
We'll compare this to the work we did for seeing if some vectors could span the whole of R3.

## Population movement

This application is described in section 2.7 of the text book. We'll do this in class, and it will give a good idea of a powerful application of linear algebra - and motivate the next topic, which is about taking powers of matrices.
In class we went over this example, and showed how that to find the populations of the city and suburbs after 20 years, you have to find M20x0, where M is the matrix that told you how to get from the populations for one year to that for the next year, and x0 is a vector, x0=(r0,s0)=(city population in year zero, suburbs population in year zero.)
If you want to find the populations after 200 years, you'd have to find M200x0.
We can guess what might happen in the long run...Does all the population end up in the suburbs? What we will get is some stabilization - but when will that occur? We can use MatLab to quickly find the answer. I thought it was really fun to type in the matrix and find it's 300th power! The following are the MatLab commands I typed, so you can copy them and try similar calculations yourself:
First enter the matrix M, and the population in year zero (which was 1990, according to the text book):
```M=[ .95 .03 .05 .97 ] x0=[ 600000 400000 ] ```
MatLab tells you what you typed for M and x0. Next find the population after one generation and after two generations:
```x1=M*x0 x1 = 582000 418000 x2=M*x1 x2 = 565440 434560 ```
We can find x2 from x1, as above, or from M2x0 as below:
```M*M*x0 ans = 1.0e+005 * 5.6544 4.3456 ```
When MatLab says "1.0e+005 *", it means "move the decimal point 5 places to the right."
We also can find M2 before multiplying it by x0:
```M*M ans = 0.9040 0.0576 0.0960 0.9424 M^2 ans = 0.9040 0.0576 0.0960 0.9424 » (M*M)*x0 ans = 1.0e+005 * 5.6544 4.3456 ```
Next, find the population after more years:
```M^20 ans = 0.4929 0.3042 0.5071 0.6958 M^20*x0 ans = 1.0e+005 * 4.1746 5.8254 M^200*x0 ans = 1.0e+005 * 3.7500 6.2500 M^300*x0 ans = 1.0e+005 * 3.7500 6.2500 ```
So, it looks like the population is stabilizing at 375000 in the city and 625000 in the suburbs... Of course, this model is not going to be very accurate, as more people will arrive from somewhere else. We could get round that by adding another vector each time as well. Anyway, this kind of thing is a very good model in some situations. So now we know why taking powers of matrices is such a good thing to do.
Note, finding the stable vector by just multiplying x0 by a large power of M is not really a rigorous mathematical way of doing things. In the section of the text book on Markov chains, a way that is guaranteed to work is explained.

## Fun with Matrix Multiplication

Make sure you remember matrix multiplication:
 / a b \ / e f \ = / ae+bg af+bh \ \ c d / \ g h / \ ce+dg cf+dh /

How does matrix multiplication compare with ordinary multiplication?
what are the roles of these matrices?
 / 1 0 \ and / 0 0 \ \ 0 1 / \ 0 0 /

### Powers of matrices

If we take a number and keep multiplying it by itself, what can happen?
We have that the limit of 2^n as n tends to infinity is infinity.
What other kinds of things can happen?
What about for matrices? If you keep multiplying a matrix by itself, will it get bigger and bigger?
Try some examples, what happens for the following matrices?
 / 1 1 \ / 1/2 0 \ / 0 1 \ / 1/2 -root(3)/2 \ \ 0 1 / \ 0 1/2 / \ 0 1 / \ root(3)/2 1/2 /

Apart from being interesting abstractly, taking powers of matrices is useful in an application called Markov chains, which we'll see soon. Geometrically, taking powers of a matrix means finding what a transformation does when it is repeated.

#### Important note:

Notice that multiplying diagonal matrices is much easier? (Diagonal means it's zeros, except on the diagonal (and it could be zero there too).
Wouldn't it be nice if all matrices were diagonal? Well, for a lot of matrices, there is a method of making them think they are diagonal. Then you can multiply them together really fast, and solve the kinds of problems that need that very fast.

### Roots of matrices

Numbers have square roots. Do matrices? What would this mean geometrically? Can you find the square roots of some matrices? Try the following:
 / 4 0 \ / 1 0 \ / 0 1 \ / 1/2 -root(3)/2 \ \ 0 4 / \ 0 -1 / \ 0 1 / \ root(3)/2 1/2 /

A number can have two square roots, eg, the square root of 25 is 5 or -5. How many square roots can a matrix have? Do all matrices have square roots? For numbers, the square root of 1 is 1. For matrices, can we have the square root of a matrix being the original matrix? What would this mean geometrically?

### Addition, subtraction, multiplication by scalars

Mustn't forget to mention these - they work in exactly the same way as they do for vectors. See text book for the rule.
In fact, just about anything you might do with numbers, you can do with matrices too - you can even find the exponential! (eA) But we won't be doing that. Just bear in mind - matrices are like a kind of generalization of numbers. You might say numbers are just a special case of matrices; a number is just a one by one matrix.
We will look into these ideas in class. We also will see the transpose of a matrix.

## Projection

The projection map is a bit different from most of the others we've looked at. It is not so nice in some ways, because it squashes things, and looses information, and I might not want to get squashed. But these things happen, so we have to have matrices to describe them.
I'm also going to talk about how this is related to the inner product, and to the outer product.
I wrote about this in the notes for lecture 5 too, though we didn't get on it then.

## Transformations in R3

We're going to give the matrix to describe a few transformations in three dimensional space. It's the same idea as for two dimensional space. We represent the transformation by a three by three matrix. The first column of the matrix is the image of (1,0,0), the second column is the image of (0,1,0), and the third is the image of (0,0,1).
We'll also give examples of matrices that do not map to the same dimensional space as where the vectors start.

Lecture 5 Back to the Linear Algebra Notes Index. Lecture 7