Current time:0:00Total duration:16:32

0 energy points

# Matrices to solve a system of equations

Video transcript

We've done a lot of work
on multiplying, adding, subtracting and inverting
matrices. So now let's delve a little
into what a matrix is actually good for. And remember, all a matrix
is is, a way of representing data. And all of those rules we
learned, you can kind of view them as human-created rules. There's no fundamental thing in
nature that says matrices have to be multiplied
the way we learned. But I think you'll see as we
progress into applications, that the way that matrix
operations have been defined are actually quite useful. So let's go back to our Algebra
1 or Algebra 2. I forget when you tend
to learn it. But let's go back to
linear equations. So what were linear equations? Systems of linear equations. Well you had two lines, and you
essentially had to figure out where the two lines
intersected. So you might have had something
like-- let me think of something-- 3x plus 2y. Is equal to 7. And then you might have, minus
6x plus 6y is equal to-- I need to do this in my head just
to make sure that I get numbers that work out
well-- equal to 6. I think this will
work out well. And what was this problem
essentially? Well this is a line,
and this is a line. So you had to figure out
where they intersected. And if you were to draw
those two lines-- Actually let's draw them. Just because this is all about
getting intuition, and seeing how it maps over into
the matrix world. And the word 'matrix world'
has a whole new meaning after 1999. Let's see, so if that's my
coordinate axes, what is this? I always have to put everything
into y equals mx plus b form for me to-- So
this equation is what? It's y is equal to
3/2 x plus 7/2. So 7/2 is what? It's like 3 1/2 or something? So if that's 7/2, that's going
to have a slope of 3 1/2. So it's a little bit steeper
than a slope of 1. So it's going to look
something like that. That's that line. And then this line is going
to look like what? I'll do a different color. It's going to look like-- It's
the same thing is as-- Oh, you know what? I did that wrong. Because that line, I just
realized, is equal to minus 3x plus 7/2. Because when you take this to
the other side, it becomes minus 3x divided by 2, so
it's actually going to be downward sloping. So it will look something
like this. It's going to be a little bit
steeper than something that has a slope of negative 1, so
I'm just approximating. So that line will look
something like that. And this line, this will be y--
I'm just rewriting this-- y is equal to x plus
1, if I'm right. Yeah. Because this go to
the other side. Divide everything by 6. y is equal to x plus 1, so its
y intercept will be-- We said this was 3 and 1/2, so
maybe if this is 1. And it has a slope of 1. Then it'll just look like
something like this. And so when you solve a system
of equations, you're essentially looking for the x
and the y values that satisfy both of these equations. This magenta line shows us all
the x and y values that satisfy this first
linear equation. And this green line shows all
of the x's and y's that satisfy the second equation. And of course where they
intersect shows us the particular x and y that
satisfies both equations. So that's what we did
in Algebra 1. We'd solve both of these
equations for that. And we'd either do it by
substitution, or we'd scale them and add them together,
et cetera, et cetera. As you'll see, that's
essentially just what we learned in the Gauss-Jordan
elimination. It's the exact same thing. It's just when we did the
Gauss-Jordan elimination, we just represented it a
little different. But I think you know
this much. But let's now do it in
the matrix world. So how can we represent this
problem as a matrix? We could write it like this,
and we'll take out a little time to prove to you that
it really is the same representation. If you define matrices the way
we have defined them in their multiplication. You can define this problem
as 3, minus 6, 2, 6. I just took the coefficients,
3, minus 6, 2, 6. And if I were to multiply
that by soon. column vector matrix xy. And if I were to set that equal
to another column vector matrix, 7, 6. Now you might want to pause it
and actually just try to multiply this out, the way
that we have learned to multiply matrices. And you will see that you
get the same thing. But I will do it now,
in case you don't want to do it yourself. So let's just multiply
these two matrices. Let's multiply this matrix
out and see what happens. So what do you do? You get your row information
from the first matrix, column information from the
second matrix. And this is of course
the product matrix. So this is saying, 3 times x
plus 2 times y is equal to 7. Well that's exactly what
we wrote up here. 3 times x plus 2 times
y is equal to 7. And similarly when you multiply
the bottom row, you get minus 6 times x plus 6
times y is equal to 6. So if that was a little
confusing to you, go review how we multiply matrices. But if you just multiply this
out, you'll get these exact same equations. So hopefully you understand that
this is just another way of representing this problem. Although we've gotten rid
of the plus signs and the equals signs. But of course you have to
know the representation. But why is this useful? Why is this representation
useful? Well let's call this matrix a. Let's call this vector x. It's not a variable. It's a vector. So maybe we'll bold it, or we'll
put a little vector sign there or something. Whatever. But you'll see it in
your textbook. It's bolded real heavy. And then we call
this vector b. And the general notation-- if
I remember it correctly-- is that anything that's a matrix
or a vector is bolded. And matrices that are not
vectors, that have more than one dimension in either
of the dimensions, they're capital letters. While lower-case letters
represent vectors. So these are matrices, but
they're also vectors. So that's why they got the
lowercase letters. And that's why this one got
the uppercase letters. That's just convention. So this equation has the form
ax equals b, where a is this matrix, x is this vector-- or
this matrix, same thing-- and b is this column vector. So what does that do for us? Well, what happens if
we knew a inverse? Well actually, let me
take a step back. If these were numbers,
what would we do? If I just gave you an algebra
equation, ax is equal to b. How do you solve that? Well you would divide both sides
of this equation by a. Or another way of saying it, you
would multiply both sides of this equation by
the inverse of a. So you would essentially say,
1/a times ax is equal to 1/a times b. And then these would cancel out,
and you would get x is equal to b/a. That's how we would do
it in a traditional simple, linear equation. So how would you do it here? Well what's the matrix
analogy to division? And I'm going to give
you the answer now. What's the analogy to
multiplying by your inverse? Well, it's multiplying
by your inverse. So what if we knew the
matrix a inverse? We could just multiply
both sides of this equation by a inverse. And remember, order matters. So it's not like when you're
doing a linear equation you could multiply 1/a
on this side. But then you can do it on
the right side here. But no. Notice, I put it in front of
the numbers in both cases. So you have to do it in front of
the numbers in both cases. But if we know a inverse, and
if a inverse exists, then we can multiply both sides-- you
can say the left side of both sides of this equation
by a inverse. a inverse times a, times the
vector x is equal to a inverse times b. All I did is I took this
expression, and I multiplied both sides by a inverse. And what's a inverse times a? Well that's just the
identity matrix. That's the identity matrix,
times x is equal to a inverse b. And of course that's just x. The identity matrix times
any other matrix is just that matrix. So that's just the matrix
x, or the vector x times a inverse b. So, if you're given a linear
equation, and if you know the inverse of this matrix, to solve
for x and y, we just have to multiply this number
times the inverse. And you might say, Sal,
that's such a pain. Because this is such a simple
linear equation to solve. Why would I go through all the
trouble of getting an inverse, and then multiplying the inverse
times this number. And I would agree with
you to some degree. That for a 2 by 2 system of
equations, it is easier to solve it the way that you did it
in Algebra 1 or Algebra 2. But if you're doing it for a 3
by 3, well, finding a matrix is still pretty difficult
for a 3 by 3, so it's still difficult. But as you get to larger and
larger numbers, it's sometimes-- well, finding a
matrix can be difficult too-- But actually the real place
where it you really, really pays off is, let's say that
you have a bunch of linear equations to solve. And the left hand side
stays the same. But you keep changing
the right hand side. So let's say you have
ax equals b. And then you have another one
that says, ax equals c, and ax equals d. And these numbers
keep changing. And these numbers
are the same. Then it really pays off to
solve for the inverse. And then every time you need
to find a new solution, you just multiply your new
right-hand side times your inverse, and you just
get the answer. And that'll really pay
off when we view this in another way. But anyway, I wanted
to show you that this is the same thing. And so let's solve
it using what our knowledge is of matrices. Let me erase this here, and I
know I'm running over time, but hopefully I'm not completely
boring you. So I'm going to keep that there,
just because I think it's nice to have that
visual representation of what we're doing. Always to remember
what's going on. So, what's a inverse? So first of all, the a inverse
is equal to 1 over the determinant of a times the
adjoint of this matrix. I don't want to get fancy with
terminology and all that, but what was that? 2 by 2 is fairly easy. You swap these two terms.
You get a 6 and a 3. And then you make these
two terms negative. So a minus 6 becomes a 6. And a 2 becomes a minus 2. And what's the determinant
of a? The determinant of a is equal to
this times this minus this times this. So 3 times 6. 3 times 6 is 18 minus
this times this. So 6 times 2 is 12. That's a minus 6. That's minus 12. So minus minus 12. It's equal to plus. So 18 plus 12 is equal to 30. So what does a inverse equal? 1 over 30 times this thing. So a inverse is equal to-- we
could even keep the 1/30 on the outside. That might simplify things. Well actually I'll put it-- So a inverse is equal to what? This divided by 30. So that's 1/5, minus-- Actually
I do want to keep it on the outside, because that's
going to make the later multiplications easier. So anyway, a is equal to 1/30
times 6, minus 2, 6, 3. That's a inverse. So now let's solve
for x and y. So we said x and y is equal
to a inverse times b. So we could say x-- another way
to write x is like this. x is just this vector. x and y. Not to get confused, this x is
different than that x, even though I've written
them the same. If I was a typographer, I would
make this really bold, so that you know that
this is a vector. Maybe I should put a
vector notation. I don't know. You could do a bunch
of things with it. It's equal to a inverse
times this. So that's 1/30. I did that just for the
matrix addition. I didn't divide everything
by 30, just so the matrix multiplication's a
little easier. Minus 2, 3, times 7/6. And so what is this equal to? It's equal to 1/30 times-- I
know I'm crowding this down here-- let's see. 6 times 7 minus 2 times 6. So 6 times 7 is 42. Minus 2 times 6, so minus 12. So that's equal to the 30. And then 6 times 7
plus 2 times 6. So 6 times 7, once
again is 42. Plus 2 times 6. So 42 plus 12 is 50. Is that right? 6 times 7-- oh I'm sorry. This is a 3. That's why I was getting
confused. See, it's important to
have good penmanship. So it's 6 times 7 is
42, plus 3 times 6. So it's 42 plus 18,
which is 60. And of course you divide
both of them by 30. So you get the final xy. I'll write it here. I don't want to erase
anything. So we get xy is equal to--
divide both of those by 30-- is equal to 1 and 2. And so that tells us that these
two linear equations intersect at the point x is
equal to 1, y is equal to 2. That might seem a little bit
like a lot of work, but that's just because I took the time
to explain it and all that. But if you just immediately took
that, represented it this way, found the inverse, and
multiplied, it wouldn't have taken you that much time. And I encourage you to do
that as an exercise. Anyway, I'll see you
in the next video. And in the next video, we're
going to do this exact same problem, but we're going to see
that this data represents a different problem. See