Implicit Differentiation (part 2)

WEBVTT
Kind: captions
Language: en

00:00:00.660 --> 00:00:04.620
I've been requested to do some
more implicit differentiation

00:00:04.620 --> 00:00:08.630
or differentiation of implicit
functions by I believe his name

00:00:08.630 --> 00:00:11.170
is [? Akash ?], so I
will do some more.

00:00:11.170 --> 00:00:13.280
And these are actually the
problems that he sent to me and

00:00:13.280 --> 00:00:16.840
they looked good, so those
are the ones I'll do.

00:00:16.840 --> 00:00:23.170
The first problem he gave me,
and I'll do it in green, says y

00:00:23.170 --> 00:00:36.500
to the third power minus xy
squared plus cosine

00:00:36.500 --> 00:00:40.060
xy is equal to 2.

00:00:40.060 --> 00:00:43.180
So like all differentiation of
implicit functions-- and of

00:00:43.180 --> 00:00:45.660
course in these examples I'm
going to-- except for the last

00:00:45.660 --> 00:00:48.730
one-- I'm going to find
the derivative of y

00:00:48.730 --> 00:00:49.860
with respect to x.

00:00:49.860 --> 00:00:51.540
So in all of these I
want to figure out what

00:00:51.540 --> 00:00:55.890
dy/dx is equal to.

00:00:55.890 --> 00:00:59.130
Well to do that just like in
the previous video we just take

00:00:59.130 --> 00:01:01.780
the derivative with respect to
x on both sides of

00:01:01.780 --> 00:01:02.480
this equation.

00:01:02.480 --> 00:01:05.370
So we do the derivative
operator I guess

00:01:05.370 --> 00:01:05.910
we could call it.

00:01:05.910 --> 00:01:07.930
So we're going to take
it on this side.

00:01:07.930 --> 00:01:09.235
ddx.

00:01:09.235 --> 00:01:12.250
And we're going to take the
derivative of everything.

00:01:12.250 --> 00:01:13.990
Then we're going to take the
derivative on the right hand

00:01:13.990 --> 00:01:17.090
side, the derivative of 2,
which we know hopefully

00:01:17.090 --> 00:01:18.790
by this point is 0.

00:01:18.790 --> 00:01:21.780
And I'll do it a little bit
quicker than in last video, but

00:01:21.780 --> 00:01:25.140
anyway send me a note if you
think I did it too fast.

00:01:25.140 --> 00:01:28.240
So let's take the derivative
of each of these terms.

00:01:28.240 --> 00:01:33.360
So the derivative with
respect to x of y cubed.

00:01:33.360 --> 00:01:36.640
Well it's the derivative with
respect to y, we're just

00:01:36.640 --> 00:01:37.470
doing the chain rule.

00:01:37.470 --> 00:01:45.140
So it's 3y-- that's a y,
not a g-- 3y squared.

00:01:45.140 --> 00:01:47.990
So the derivative of this
function with respect to y

00:01:47.990 --> 00:01:51.120
times the derivative of
y with respect to x.

00:01:51.120 --> 00:01:52.950
dy/dx.

00:01:52.950 --> 00:01:55.820
That's just the chain rule.

00:01:55.820 --> 00:01:58.740
And then we have minus
the derivative of this

00:01:58.740 --> 00:01:59.840
with respect to x.

00:01:59.840 --> 00:02:01.920
Well this is a little
interesting, because here we

00:02:01.920 --> 00:02:05.810
have x times y squared, which
we're arguing is maybe a

00:02:05.810 --> 00:02:08.000
function of what's an
implicit function of x.

00:02:08.000 --> 00:02:09.530
So how do we do that?

00:02:09.530 --> 00:02:13.440
What we'll do-- let me put the
subtraction sign outside and

00:02:13.440 --> 00:02:15.330
then let's do the derivative
inside, and I'll do it

00:02:15.330 --> 00:02:17.620
inside some brackets.

00:02:17.620 --> 00:02:19.280
So let's do the
product rule here.

00:02:19.280 --> 00:02:21.510
We have x times y squared.

00:02:21.510 --> 00:02:24.870
The product rule says it's the
derivative of the first

00:02:24.870 --> 00:02:28.780
function times a second
function plus the derivative of

00:02:28.780 --> 00:02:30.780
the second function times
the first function.

00:02:30.780 --> 00:02:33.640
So the derivative of the first
function with respect to x--

00:02:33.640 --> 00:02:36.050
remember what we're taking the
derivative with respect to--

00:02:36.050 --> 00:02:40.070
well the derivative
of x is just 1.

00:02:40.070 --> 00:02:46.520
1 times y squared plus
the derivative of

00:02:46.520 --> 00:02:47.420
the second function.

00:02:47.420 --> 00:02:49.282
Well what's the derivative
of the second function?

00:02:49.282 --> 00:02:54.200
Well it's going to be 2y
dy/dx, and that just comes

00:02:54.200 --> 00:02:56.305
from the chain rule.

00:02:56.305 --> 00:02:59.690
The derivative with respect
to y times the derivative

00:02:59.690 --> 00:03:00.940
of y with respect to x.

00:03:00.940 --> 00:03:02.200
That's the chain rule.

00:03:02.200 --> 00:03:04.440
So that's the derivative of y
squared, and then we multiply

00:03:04.440 --> 00:03:07.200
that times the first
function, which is x.

00:03:07.200 --> 00:03:09.700
Times x.

00:03:09.700 --> 00:03:11.170
Hopefully that
didn't confuse you.

00:03:11.170 --> 00:03:14.310
Just took the derivative
of x times y squared.

00:03:14.310 --> 00:03:15.650
This is the product rule.

00:03:15.650 --> 00:03:17.830
Plus the derivative
of y squared, which

00:03:17.830 --> 00:03:20.930
was this times x.

00:03:20.930 --> 00:03:23.340
OK now we're ready to move on.

00:03:23.340 --> 00:03:25.010
OK.

00:03:25.010 --> 00:03:26.610
Now this is interesting.

00:03:26.610 --> 00:03:28.900
This is interesting.

00:03:28.900 --> 00:03:32.160
We have to take the
derivative of cosine of xy.

00:03:32.160 --> 00:03:35.840
Well once again we just
do the chain rule.

00:03:35.840 --> 00:03:37.740
And maybe I'll actually break
it up into a couple of steps

00:03:37.740 --> 00:03:39.910
here just so that you don't
get completely confused.

00:03:39.910 --> 00:03:42.850
So what does the chain rule say
if we have you know f of g

00:03:42.850 --> 00:03:44.330
of x of whatever whatever?

00:03:44.330 --> 00:03:47.460
We essentially have to take the
derivative of the inside

00:03:47.460 --> 00:03:50.430
function and multiply-- or well
I guess you could

00:03:50.430 --> 00:03:51.130
do it two ways.

00:03:51.130 --> 00:03:54.040
You could say we take the
entire derivative with respect

00:03:54.040 --> 00:03:56.660
to whatever this function is.

00:03:56.660 --> 00:04:00.770
You know if g was equal to xy
we could say the derivative of

00:04:00.770 --> 00:04:04.000
cosine of g with respect to g.

00:04:04.000 --> 00:04:07.460
And then we would multiply
that times the derivative

00:04:07.460 --> 00:04:10.280
of this with respect to x.

00:04:10.280 --> 00:04:12.690
If that confuses you, I think
it'll make more sense when

00:04:12.690 --> 00:04:13.680
I actually do the example.

00:04:16.210 --> 00:04:18.520
Actually let me write out like
just the way I said it, because

00:04:18.520 --> 00:04:21.650
I think that could maybe even
clear up some confusion

00:04:21.650 --> 00:04:22.360
over the chain rule.

00:04:22.360 --> 00:04:25.760
Or maybe it'll
confuse you further.

00:04:25.760 --> 00:04:26.580
So what are we doing?

00:04:26.580 --> 00:04:29.500
We're going to do the
derivative-- let me do this

00:04:29.500 --> 00:04:31.620
in a different color.

00:04:31.620 --> 00:04:36.020
So let's take derivative
of the outside function

00:04:36.020 --> 00:04:39.040
with respect to xy.

00:04:39.040 --> 00:04:39.680
So what is that?

00:04:39.680 --> 00:04:43.210
What's the derivative
of cosine of x?

00:04:43.210 --> 00:04:47.400
Or let's say if it was
g is equal to xy.

00:04:47.400 --> 00:04:50.300
If g is equal to xy, then
that expression there

00:04:50.300 --> 00:04:53.400
is cosine of g.

00:04:53.400 --> 00:04:57.900
So what's the derivative of
this with respect to g?

00:04:57.900 --> 00:05:00.060
Sorry, dg.

00:05:00.060 --> 00:05:03.040
Well that's just minus
sin of g, right?

00:05:03.040 --> 00:05:05.630
So let me do that in
a different color.

00:05:05.630 --> 00:05:11.690
So it's minus sin,
and g was just xy.

00:05:14.740 --> 00:05:16.755
So that's the derivative
of you can kind of say

00:05:16.755 --> 00:05:18.350
of the outside function.

00:05:18.350 --> 00:05:21.170
And then we go to the inside,
and we have to multiply this

00:05:21.170 --> 00:05:23.270
times the derivative of
this inside function.

00:05:23.270 --> 00:05:24.640
Let me just write
that like this.

00:05:24.640 --> 00:05:28.790
Times the derivative with
respect to x--that's what

00:05:28.790 --> 00:05:31.710
we're doing-- of xy.

00:05:31.710 --> 00:05:33.160
And I'm going to leave it
like that for now because

00:05:33.160 --> 00:05:35.050
that's going to take a
little bit of space.

00:05:35.050 --> 00:05:38.430
And then that equals
the derivative of 2

00:05:38.430 --> 00:05:39.340
with respect to x.

00:05:39.340 --> 00:05:40.850
Well 2 never changes, right?

00:05:40.850 --> 00:05:43.780
It's a constant, so
it's derivative is 0.

00:05:43.780 --> 00:05:48.730
Let's see if we can simplify
this a little bit, and

00:05:48.730 --> 00:05:51.010
we'll come back to that,
let's just write this.

00:05:51.010 --> 00:05:56.695
So we have 3g-- no I'm
confusing myself with

00:05:56.695 --> 00:05:58.760
my bad penmanship.

00:05:58.760 --> 00:06:05.670
3y-- all that talk of g
got me confused-- dy/dx.

00:06:05.670 --> 00:06:13.360
3y squared dy/dx minus y
squared minus-- I'm just

00:06:13.360 --> 00:06:27.460
distributing the minus--
xy minus 2xy dy/dx

00:06:27.460 --> 00:06:29.010
minus sin of xy.

00:06:34.750 --> 00:06:38.740
And then this whole thing
times the derivative of

00:06:38.740 --> 00:06:40.705
xy with respect to x.

00:06:40.705 --> 00:06:42.910
Well we can just do the
product rule here.

00:06:42.910 --> 00:06:46.210
What's the derivative of
xy with respect to x?

00:06:46.210 --> 00:06:50.750
Well the derivative of x
is 1, so it's 1 times y.

00:06:50.750 --> 00:06:53.920
Derivative of the first
times the second function.

00:06:53.920 --> 00:06:56.870
Plus the derivative of
the second function

00:06:56.870 --> 00:06:57.810
with respect to x.

00:06:57.810 --> 00:06:59.860
So what's the derivative
of y with respect to x?

00:06:59.860 --> 00:07:02.370
Well it's just dy/dx, right?

00:07:02.370 --> 00:07:05.630
dy/dx times the first function.

00:07:05.630 --> 00:07:06.600
That's just the product rule.

00:07:06.600 --> 00:07:09.350
Review of the product rule if
that was a little confusing.

00:07:09.350 --> 00:07:11.650
It's equal to 0.

00:07:11.650 --> 00:07:16.020
And now we can
attempt to simplify.

00:07:16.020 --> 00:07:17.170
So let's see if I can do it.

00:07:17.170 --> 00:07:30.400
So we have 3y squared
dy/dx minus y squared

00:07:30.400 --> 00:07:33.540
minus 2xy dy/dx.

00:07:36.760 --> 00:07:39.060
Now this one's interesting,
so let me distribute

00:07:39.060 --> 00:07:41.200
the sin of xy.

00:07:41.200 --> 00:08:01.470
This is just a 1, so it's minus
y sin of xy minus x dy/dx sin

00:08:01.470 --> 00:08:04.355
of xy-- I'm just simplifying,
this is just algebra.

00:08:04.355 --> 00:08:07.000
So y is equal to 0.

00:08:07.000 --> 00:08:10.040
Now let's group all of the
terms that have a dy/dx in them

00:08:10.040 --> 00:08:11.570
and distribute out the dy/dx.

00:08:11.570 --> 00:08:24.520
So this is equal to dy/dx times
this 3y squared minus two xy.

00:08:24.520 --> 00:08:28.580
I'm just undistributing where
I'm dividing out the dy/dx.

00:08:28.580 --> 00:08:30.480
So let me actually
show you the terms.

00:08:30.480 --> 00:08:33.590
So this has a dy/dx,
this has a dy/dx.

00:08:33.590 --> 00:08:34.805
And this is just algebra.

00:08:34.805 --> 00:08:38.500
This has a dy/dx, so let
me separate those out.

00:08:38.500 --> 00:08:53.870
So it's 3y squared minus
2xy minus x sin of xy.

00:08:57.850 --> 00:09:01.580
Well that's all of the ones
with the dy/dx on them.

00:09:01.580 --> 00:09:04.340
And then these terms-- and I'm
just skipping a couple of

00:09:04.340 --> 00:09:07.030
steps because this is
algebra right now.

00:09:07.030 --> 00:09:11.190
The non dy/dx terms-- that
term, and I guess there's only

00:09:11.190 --> 00:09:13.600
two of them-- I'm just going
to add to the other

00:09:13.600 --> 00:09:14.120
side of equation.

00:09:14.120 --> 00:09:17.420
So I'm just going to bring
them over to the other side.

00:09:17.420 --> 00:09:18.900
Hopefully that step
doesn't confuse you.

00:09:18.900 --> 00:09:23.020
This is just algebraic
simplification at this point.

00:09:23.020 --> 00:09:26.010
I could have written minus y
squared minus y sin xy and then

00:09:26.010 --> 00:09:28.250
added them on the other side,
but I'm about to run out of

00:09:28.250 --> 00:09:32.660
space and time, so I'm just
going to add these to both

00:09:32.660 --> 00:09:33.660
sides of the equation.

00:09:33.660 --> 00:09:45.170
So that equals y squared
plus y sin of xy.

00:09:45.170 --> 00:09:47.310
I think I've covered
all of the terms.

00:09:47.310 --> 00:09:50.720
And now since our goal is to
find the derivative of y with

00:09:50.720 --> 00:09:53.350
respect to x, we can divide
both sides of this equation by

00:09:53.350 --> 00:09:58.390
this term right here, and our
final answer is-- let me

00:09:58.390 --> 00:10:00.580
do it in a good color.

00:10:00.580 --> 00:10:02.760
dy/dx.

00:10:02.760 --> 00:10:06.360
The derivative of y with
respect to x is equal to that

00:10:06.360 --> 00:10:19.230
y squared plus y sin of xy
divided by this-- 3y squared

00:10:19.230 --> 00:10:26.700
minus 2xy minus x sin of xy.

00:10:26.700 --> 00:10:28.170
And there you have it.

00:10:28.170 --> 00:10:32.650
That was a good implicit
differentiation problem and if

00:10:32.650 --> 00:10:35.310
you understood how to do that,
you understand how to do

00:10:35.310 --> 00:10:37.040
implicit differentiation.

00:10:37.040 --> 00:10:39.280
And I hope I didn't make any
careless mistakes, and it's a

00:10:39.280 --> 00:10:42.010
good exercise for you to try
to do it again on your own.

00:10:42.010 --> 00:10:42.390
See you soon.


Classic video on inverting a 3x3 matrix part 2

WEBVTT
Kind: captions
Language: en

00:00:00.800 --> 00:00:04.100
I will now show you my preferred
way of finding an

00:00:04.100 --> 00:00:05.770
inverse of a 3 by 3 matrix.

00:00:05.770 --> 00:00:07.220
And I actually think it's
a lot more fun.

00:00:07.220 --> 00:00:09.150
And you're less likely to
make careless mistakes.

00:00:09.150 --> 00:00:11.020
But if I remember correctly from
Algebra 2, they didn't

00:00:11.020 --> 00:00:12.760
teach it this way
in Algebra 2.

00:00:12.760 --> 00:00:14.900
And that's why I taught the
other way initially.

00:00:14.900 --> 00:00:16.170
But let's go through this.

00:00:16.170 --> 00:00:20.140
And in a future video, I will
teach you why it works.

00:00:20.140 --> 00:00:21.310
Because that's always
important.

00:00:21.310 --> 00:00:23.780
But in linear algebra, this is
one of the few subjects where

00:00:23.780 --> 00:00:26.670
I think it's very important
learn how to do the operations

00:00:26.670 --> 00:00:28.790
first. And then later,
we'll learn the why.

00:00:28.790 --> 00:00:30.430
Because the how is
very mechanical.

00:00:30.430 --> 00:00:32.880
And it really just involves
some basic arithmetic

00:00:32.880 --> 00:00:34.380
for the most part.

00:00:34.380 --> 00:00:39.070
But the why tends to
be quite deep.

00:00:39.070 --> 00:00:41.170
So I'll leave that
to later videos.

00:00:41.170 --> 00:00:43.820
And you can often think about
the depth of things when you

00:00:43.820 --> 00:00:46.550
have confidence that you at
least understand the hows.

00:00:46.550 --> 00:00:49.730
So anyway, let's go back
to our original matrix.

00:00:49.730 --> 00:00:51.090
And what was that original
matrix that I

00:00:51.090 --> 00:00:52.280
did in the last video?

00:00:52.280 --> 00:01:03.850
It was 1, 0, 1, 0,
2, 1, 1, 1, 1.

00:01:03.850 --> 00:01:07.160
And we wanted to find the
inverse of this matrix.

00:01:07.160 --> 00:01:08.910
So this is what we're
going to do.

00:01:08.910 --> 00:01:12.710
It's called Gauss-Jordan
elimination, to find the

00:01:12.710 --> 00:01:13.720
inverse of the matrix.

00:01:13.720 --> 00:01:15.840
And the way you do it-- and it
might seem a little bit like

00:01:15.840 --> 00:01:18.860
magic, it might seem a little
bit like voodoo, but I think

00:01:18.860 --> 00:01:20.370
you'll see in future videos that
it makes a lot of sense.

00:01:20.370 --> 00:01:22.770
What we do is we augment
this matrix.

00:01:22.770 --> 00:01:23.560
What does augment mean?

00:01:23.560 --> 00:01:25.440
It means we just add
something to it.

00:01:25.440 --> 00:01:26.830
So I draw a dividing line.

00:01:26.830 --> 00:01:28.486
Some people don't.

00:01:28.486 --> 00:01:31.290
So if I put a dividing
line here.

00:01:31.290 --> 00:01:34.080
And what do I put on the other
side of the dividing line?

00:01:34.080 --> 00:01:37.640
I put the identity matrix
of the same size.

00:01:37.640 --> 00:01:41.140
This is 3 by 3, so I put a
3 by 3 identity matrix.

00:01:41.140 --> 00:01:51.600
So that's 1, 0, 0,
0, 1, 0, 0, 0, 1.

00:01:51.600 --> 00:01:54.870
All right, so what are
we going to do?

00:01:54.870 --> 00:01:58.670
What I'm going to do is perform
a series of elementary

00:01:58.670 --> 00:01:59.620
row operations.

00:01:59.620 --> 00:02:02.940
And I'm about to tell you what
are valid elementary row

00:02:02.940 --> 00:02:04.610
operations on this matrix.

00:02:04.610 --> 00:02:07.440
But whatever I do to any of
these rows here, I have to do

00:02:07.440 --> 00:02:09.360
to the corresponding
rows here.

00:02:09.360 --> 00:02:12.690
And my goal is essentially to
perform a bunch of operations

00:02:12.690 --> 00:02:14.150
on the left hand side.

00:02:14.150 --> 00:02:15.830
And of course, the same
operations will be applied to

00:02:15.830 --> 00:02:18.690
the right hand side, so that I
eventually end up with the

00:02:18.690 --> 00:02:21.320
identity matrix on the
left hand side.

00:02:21.320 --> 00:02:23.310
And then when I have the
identity matrix on the left

00:02:23.310 --> 00:02:26.400
hand side, what I have left on
the right hand side will be

00:02:26.400 --> 00:02:28.690
the inverse of this
original matrix.

00:02:28.690 --> 00:02:32.680
And when this becomes an
identity matrix, that's

00:02:32.680 --> 00:02:34.950
actually called reduced
row echelon form.

00:02:34.950 --> 00:02:36.320
And I'll talk more about that.

00:02:36.320 --> 00:02:39.200
There's a lot of names and
labels in linear algebra.

00:02:39.200 --> 00:02:41.480
But they're really just fairly
simple concepts.

00:02:41.480 --> 00:02:44.790
But anyway, let's get started
and this should become a

00:02:44.790 --> 00:02:45.180
little clear.

00:02:45.180 --> 00:02:47.290
At least the process
will become clear.

00:02:47.290 --> 00:02:49.460
Maybe not why it works.

00:02:49.460 --> 00:02:51.610
So first of all, I said I'm
going to perform a bunch of

00:02:51.610 --> 00:02:52.280
operations here.

00:02:52.280 --> 00:02:53.950
What are legitimate
operations?

00:02:53.950 --> 00:02:55.720
They're called elementary
row operations.

00:02:55.720 --> 00:02:57.920
So there's a couple
things I can do.

00:02:57.920 --> 00:03:01.970
I can replace any row
with that row

00:03:01.970 --> 00:03:03.680
multiplied by some number.

00:03:03.680 --> 00:03:04.960
So I could do that.

00:03:04.960 --> 00:03:08.260
I can swap any two rows.

00:03:08.260 --> 00:03:10.850
And of course if I swap say the
first and second row, I'd

00:03:10.850 --> 00:03:12.450
have to do it here as well.

00:03:12.450 --> 00:03:17.410
And I can add or subtract one
row from another row.

00:03:17.410 --> 00:03:20.590
So when I do that-- so for
example, I could take this row

00:03:20.590 --> 00:03:23.790
and replace it with this
row added to this row.

00:03:23.790 --> 00:03:25.520
And you'll see what I
mean in the second.

00:03:25.520 --> 00:03:27.500
And you know, if you combine it,
you could you could say,

00:03:27.500 --> 00:03:29.880
well I'm going to multiple this
row times negative 1, and

00:03:29.880 --> 00:03:32.580
add it to this row, and replace
this row with that.

00:03:32.580 --> 00:03:36.690
So if you start to feel like
this is something like what

00:03:36.690 --> 00:03:40.290
you learned when you learned
solving systems of linear

00:03:40.290 --> 00:03:42.510
equations, that's
no coincidence.

00:03:42.510 --> 00:03:45.990
Because matrices are actually
a very good way to represent

00:03:45.990 --> 00:03:48.130
that, and I will show
you that soon.

00:03:48.130 --> 00:03:51.430
But anyway, let's do some
elementary row operations to

00:03:51.430 --> 00:03:55.100
get this left hand side into
reduced row echelon form.

00:03:55.100 --> 00:03:57.780
Which is really just a fancy way
of saying, let's turn it

00:03:57.780 --> 00:03:59.610
into the identity matrix.

00:03:59.610 --> 00:04:00.660
So let's see what
we want to do.

00:04:00.660 --> 00:04:02.290
We want to have 1's
all across here.

00:04:02.290 --> 00:04:03.750
We want these to be 0's.

00:04:03.750 --> 00:04:07.870
Let's see how we can do
this efficiently.

00:04:07.870 --> 00:04:10.560
Let me draw the matrix again.

00:04:10.560 --> 00:04:16.350
So let's get a 0 here.

00:04:16.350 --> 00:04:17.445
That would be convenient.

00:04:17.445 --> 00:04:19.769
So I'm going to keep the
top two rows the same.

00:04:19.769 --> 00:04:21.209
1, 0, 1.

00:04:21.209 --> 00:04:23.000
I have my dividing line.

00:04:23.000 --> 00:04:24.370
1, 0, 0.

00:04:24.370 --> 00:04:25.450
I didn't do anything there.

00:04:25.450 --> 00:04:27.000
I'm not doing anything
to the second row.

00:04:27.000 --> 00:04:28.875
0, 2, 1.

00:04:33.460 --> 00:04:36.700
0, 1, 0.

00:04:36.700 --> 00:04:40.120
And what I'm going to do, I'm
going to replace this row--

00:04:40.120 --> 00:04:42.260
And just so you know my
motivation, my goal

00:04:42.260 --> 00:04:43.490
is to get a 0 here.

00:04:43.490 --> 00:04:46.540
So I'm a little bit closer
to having the

00:04:46.540 --> 00:04:48.200
identity matrix here.

00:04:48.200 --> 00:04:50.080
So how do I get a 0 here?

00:04:50.080 --> 00:04:55.750
What I could do is I can replace
this row with this row

00:04:55.750 --> 00:04:57.280
minus this row.

00:04:57.280 --> 00:05:00.000
So I can replace the third
row with the third row

00:05:00.000 --> 00:05:01.630
minus the first row.

00:05:01.630 --> 00:05:04.040
So what's the third row
minus the first row?

00:05:04.040 --> 00:05:07.340
1 minus 1 is 0.

00:05:07.340 --> 00:05:10.670
1 minus 0 is 1.

00:05:10.670 --> 00:05:13.860
1 minus 1 is 0.

00:05:13.860 --> 00:05:16.150
Well I did it on the left hand
side, so I have to do it on

00:05:16.150 --> 00:05:16.900
the right hand side.

00:05:16.900 --> 00:05:20.300
I have to replace this
with this minus this.

00:05:20.300 --> 00:05:24.010
So 0 minus 1 is minus 1.

00:05:24.010 --> 00:05:26.610
0 minus 0 is 0.

00:05:26.610 --> 00:05:29.810
And 1 minus 0 is 1.

00:05:29.810 --> 00:05:31.270
Fair enough.

00:05:31.270 --> 00:05:32.800
Now what can I do?

00:05:32.800 --> 00:05:37.830
Well this row right here, this
third row, it has 0 and 0-- it

00:05:37.830 --> 00:05:40.530
looks a lot like what I want
for my second row in the

00:05:40.530 --> 00:05:41.720
identity matrix.

00:05:41.720 --> 00:05:43.470
So why don't I just swap
these two rows?

00:05:43.470 --> 00:05:45.360
Why don't I just swap the
first and second rows?

00:05:45.360 --> 00:05:46.740
So let's do that.

00:05:46.740 --> 00:05:49.590
I'm going to swap the first
and second rows.

00:05:49.590 --> 00:05:50.950
So the first row
stays the same.

00:05:50.950 --> 00:05:54.790
1, 0, 1.

00:05:54.790 --> 00:05:57.760
And then the other side stays
the same as well.

00:05:57.760 --> 00:06:01.830
And I'm swapping the second
and third rows.

00:06:01.830 --> 00:06:05.020
So now my second row
is now 0, 1, 0.

00:06:05.020 --> 00:06:06.990
And I have to swap it on
the right hand side.

00:06:06.990 --> 00:06:09.520
So it's minus 1, 0, 1.

00:06:09.520 --> 00:06:12.540
I'm just swapping these two.

00:06:12.540 --> 00:06:14.450
So then my third row now
becomes what the

00:06:14.450 --> 00:06:15.450
second row was here.

00:06:15.450 --> 00:06:17.920
0, 2, 1.

00:06:17.920 --> 00:06:21.990
And 0, 1, 0.

00:06:21.990 --> 00:06:23.160
Fair enough.

00:06:23.160 --> 00:06:24.770
Now what do I want to do?

00:06:24.770 --> 00:06:26.910
Well it would be nice if
I had a 0 right here.

00:06:26.910 --> 00:06:30.070
That would get me that much
closer to the identity matrix.

00:06:30.070 --> 00:06:32.260
So how could I get as 0 here?

00:06:32.260 --> 00:06:37.390
Well what if I subtracted 2
times row two from row one?

00:06:37.390 --> 00:06:40.360
Because this would be,
1 times 2 is 2.

00:06:40.360 --> 00:06:44.920
And if I subtracted that from
this, I'll get a 0 here.

00:06:44.920 --> 00:06:47.140
So let's do that.

00:06:47.140 --> 00:06:50.250
So the first row has
been very lucky.

00:06:50.250 --> 00:06:51.260
It hasn't had to do anything.

00:06:51.260 --> 00:06:52.580
It's just sitting there.

00:06:52.580 --> 00:06:58.670
1, 0, 1, 1, 0, 0.

00:06:58.670 --> 00:07:02.120
And the second row's not
changing for now.

00:07:02.120 --> 00:07:05.430
Minus 1, 0, 1.

00:07:05.430 --> 00:07:07.110
Now what did I say I
was going to do?

00:07:07.110 --> 00:07:13.240
I'm going to subtract 2 times
row two from row three.

00:07:13.240 --> 00:07:18.960
So this is 0 minus
2 times 0 is 0.

00:07:18.960 --> 00:07:23.990
2 minus 2 times 1,
well that's 0.

00:07:23.990 --> 00:07:29.150
1 minus 2 times 0 is 1.

00:07:29.150 --> 00:07:38.210
0 minus 2 times negative 1 is--
so let's remember 0 minus

00:07:38.210 --> 00:07:39.880
2 times negative 1.

00:07:39.880 --> 00:07:44.520
So that's 0 minus negative
2, so that's positive 2.

00:07:44.520 --> 00:07:47.970
1 minus 2 times 0.

00:07:47.970 --> 00:07:49.810
Well that's just still 1.

00:07:49.810 --> 00:07:53.240
0 minus 2 times 1.

00:07:53.240 --> 00:07:54.490
So that's minus 2.

00:07:57.190 --> 00:07:58.130
Have I done that right?

00:07:58.130 --> 00:07:58.810
I just want to make sure.

00:07:58.810 --> 00:08:04.800
0 minus 2 times-- right, 2
times minus 1 is minus 2.

00:08:04.800 --> 00:08:06.910
And I'm subtracting
it, so it's plus.

00:08:06.910 --> 00:08:08.150
OK, so I'm close.

00:08:08.150 --> 00:08:11.140
This almost looks like the
identity matrix or reduced row

00:08:11.140 --> 00:08:11.680
echelon form.

00:08:11.680 --> 00:08:12.950
Except for this 1 right here.

00:08:12.950 --> 00:08:16.740
So I'm finally going to have
to touch the top row.

00:08:16.740 --> 00:08:18.450
And what can I do?

00:08:18.450 --> 00:08:23.170
well how about I replace the top
row with the top row minus

00:08:23.170 --> 00:08:24.060
the bottom row?

00:08:24.060 --> 00:08:25.480
Because if I subtract
this from that,

00:08:25.480 --> 00:08:26.550
this'll get a 0 there.

00:08:26.550 --> 00:08:27.790
So let's do that.

00:08:27.790 --> 00:08:29.720
So I'm replacing the top
row with the top row

00:08:29.720 --> 00:08:31.790
minus the third row.

00:08:31.790 --> 00:08:35.570
So 1 minus 0 is 1.

00:08:35.570 --> 00:08:38.659
0 minus 0 is 0.

00:08:38.659 --> 00:08:41.000
1 minus 1 is 0.

00:08:41.000 --> 00:08:43.559
That was our whole goal.

00:08:43.559 --> 00:08:48.000
And then 1 minus 2
is negative 1.

00:08:48.000 --> 00:08:53.490
0 minus 1 is negative 1.

00:08:53.490 --> 00:08:58.950
0 minus negative 2., well
that's positive 2.

00:08:58.950 --> 00:09:02.460
And then the other rows
stay the same.

00:09:02.460 --> 00:09:07.590
0, 1, 0, minus 1, 0, 1.

00:09:07.590 --> 00:09:15.550
And then 0, 0, 1, 2,
1, negative 2.

00:09:15.550 --> 00:09:16.640
And there you have it.

00:09:16.640 --> 00:09:18.650
We have performed a series
of operations on

00:09:18.650 --> 00:09:19.720
the left hand side.

00:09:19.720 --> 00:09:21.380
And we've performed the
same operations on

00:09:21.380 --> 00:09:22.960
the right hand side.

00:09:22.960 --> 00:09:25.670
This became the identity
matrix, or

00:09:25.670 --> 00:09:27.410
reduced row echelon form.

00:09:27.410 --> 00:09:30.530
And we did this using
Gauss-Jordan elimination.

00:09:30.530 --> 00:09:32.180
And what is this?

00:09:32.180 --> 00:09:36.570
Well this is the inverse of
this original matrix.

00:09:36.570 --> 00:09:38.960
This times this will equal
the identity matrix.

00:09:38.960 --> 00:09:46.750
So if this is a, than
this is a inverse.

00:09:46.750 --> 00:09:47.580
And that's all you have to do.

00:09:47.580 --> 00:09:49.700
And as you could see, this took
me half the amount of

00:09:49.700 --> 00:09:53.260
time, and required a lot less
hairy mathematics than when I

00:09:53.260 --> 00:09:56.310
did it using the adjoint and
the cofactors and the

00:09:56.310 --> 00:09:58.110
determinant.

00:09:58.110 --> 00:09:59.990
And if you think about it, I'll
give you a little hint of

00:09:59.990 --> 00:10:01.420
why this worked.

00:10:01.420 --> 00:10:06.910
Every one of these operations
I did on the left hand side,

00:10:06.910 --> 00:10:10.570
you could kind of view them as
multiplying-- you know, to get

00:10:10.570 --> 00:10:12.370
from here to here,
I multiplied.

00:10:12.370 --> 00:10:14.500
You can kind of say that
there's a matrix.

00:10:14.500 --> 00:10:16.240
That if I multiplied by that
matrix, it would have

00:10:16.240 --> 00:10:17.670
performed this operation.

00:10:17.670 --> 00:10:20.250
And then I would have had to
multiply by another matrix to

00:10:20.250 --> 00:10:21.550
do this operation.

00:10:21.550 --> 00:10:24.250
So essentially what we did is
we multiplied by a series of

00:10:24.250 --> 00:10:26.440
matrices to get here.

00:10:26.440 --> 00:10:28.500
And if you multiplied all
of those, what we call

00:10:28.500 --> 00:10:31.410
elimination matrices, together,
you essentially

00:10:31.410 --> 00:10:34.070
multiply this times
the inverse.

00:10:34.070 --> 00:10:35.590
So what am I saying?

00:10:35.590 --> 00:10:43.470
So if we have a, to go from
here to here, we have to

00:10:43.470 --> 00:10:47.300
multiply a times the
elimination matrix.

00:10:47.300 --> 00:10:49.630
And this might be completely
confusing for you, so ignore

00:10:49.630 --> 00:10:51.990
it if it is, but it might
be insightful.

00:10:51.990 --> 00:10:55.250
So what did we eliminate
in this?

00:10:55.250 --> 00:10:58.470
We eliminated 3, 1.

00:10:58.470 --> 00:11:01.120
We multiplied by the
elimination matrix

00:11:01.120 --> 00:11:03.670
3, 1, to get here.

00:11:03.670 --> 00:11:05.740
And then, to go from
here to here, we've

00:11:05.740 --> 00:11:07.220
multiplied by some matrix.

00:11:07.220 --> 00:11:07.970
And I'll tell you more.

00:11:07.970 --> 00:11:09.160
I'll show you how
we can construct

00:11:09.160 --> 00:11:10.940
these elimination matrices.

00:11:10.940 --> 00:11:12.830
We multiply by an elimination
matrix.

00:11:12.830 --> 00:11:16.150
Well actually, we had
a row swap here.

00:11:16.150 --> 00:11:17.070
I don't know what you
want to call that.

00:11:17.070 --> 00:11:21.240
You could call that
the swap matrix.

00:11:21.240 --> 00:11:24.730
We swapped row two for three.

00:11:24.730 --> 00:11:28.830
And then here, we multiplied
by elimination

00:11:28.830 --> 00:11:31.110
matrix-- what did we do?

00:11:31.110 --> 00:11:34.030
We eliminated this, so
this was row three,

00:11:34.030 --> 00:11:36.270
column two, 3, 2.

00:11:36.270 --> 00:11:39.320
And then finally, to get here,
we had to multiply by

00:11:39.320 --> 00:11:40.470
elimination matrix.

00:11:40.470 --> 00:11:41.740
We had to eliminate
this right here.

00:11:41.740 --> 00:11:44.220
So we eliminated row
one, column three.

00:11:47.200 --> 00:11:49.590
And I want you to know right
now that it's not important

00:11:49.590 --> 00:11:51.420
what these matrices are.

00:11:51.420 --> 00:11:53.210
I'll show you how we can
construct these matrices.

00:11:53.210 --> 00:11:55.530
But I just want you to have kind
of a leap of faith that

00:11:55.530 --> 00:11:58.600
each of these operations could
have been done by multiplying

00:11:58.600 --> 00:12:01.040
by some matrix.

00:12:01.040 --> 00:12:03.510
But what we do know is by
multiplying by all of these

00:12:03.510 --> 00:12:06.760
matrices, we essentially got
the identity matrix.

00:12:06.760 --> 00:12:07.930
Back here.

00:12:07.930 --> 00:12:11.450
So the combination of all of
these matrices, when you

00:12:11.450 --> 00:12:13.600
multiply them by each
other, this must

00:12:13.600 --> 00:12:15.370
be the inverse matrix.

00:12:15.370 --> 00:12:18.420
If I were to multiply each of
these elimination and row swap

00:12:18.420 --> 00:12:22.420
matrices, this must be the
inverse matrix of a.

00:12:22.420 --> 00:12:23.680
Because if you multiply
all them times

00:12:23.680 --> 00:12:26.130
a, you get the inverse.

00:12:26.130 --> 00:12:28.630
Well what happened?

00:12:28.630 --> 00:12:31.780
If these matrices are
collectively the inverse

00:12:31.780 --> 00:12:36.400
matrix, if I do them, if I
multiply the identity matrix

00:12:36.400 --> 00:12:40.620
times them-- the elimination
matrix, this one times that

00:12:40.620 --> 00:12:41.270
equals that.

00:12:41.270 --> 00:12:42.970
This one times that
equals that.

00:12:42.970 --> 00:12:44.510
This one times that
equals that.

00:12:44.510 --> 00:12:45.360
And so forth.

00:12:45.360 --> 00:12:48.870
I'm essentially multiplying--
when you combine all of

00:12:48.870 --> 00:12:53.050
these-- a inverse times
the identity matrix.

00:12:53.050 --> 00:12:55.520
So if you think about it just
very big picture-- and I don't

00:12:55.520 --> 00:12:56.470
want to confuse you.

00:12:56.470 --> 00:12:57.910
It's good enough at this
point if you just

00:12:57.910 --> 00:13:00.370
understood what I did.

00:13:00.370 --> 00:13:03.500
But what I'm doing from all of
these steps, I'm essentially

00:13:03.500 --> 00:13:07.800
multiplying both sides of this
augmented matrix, you could

00:13:07.800 --> 00:13:10.450
call it, by a inverse.

00:13:10.450 --> 00:13:13.080
So I multiplied this by a
inverse, to get to the

00:13:13.080 --> 00:13:14.300
identity matrix.

00:13:14.300 --> 00:13:16.740
But of course, if I multiplied
the inverse matrix times the

00:13:16.740 --> 00:13:19.130
identity matrix, I'll get
the inverse matrix.

00:13:19.130 --> 00:13:20.990
But anyway, I don't want
to confuse you.

00:13:20.990 --> 00:13:22.410
Hopefully that'll give you
a little intuition.

00:13:22.410 --> 00:13:25.130
I'll do this later with some
more concrete examples.

00:13:25.130 --> 00:13:27.850
But hopefully you see that this
is a lot less hairy than

00:13:27.850 --> 00:13:30.115
the way we did it with the
adjoint and the cofactors and

00:13:30.115 --> 00:13:32.540
the minor matrices and the
determinants, et cetera.

00:13:32.540 --> 00:13:35.290
Anyway, I'll see you
in the next video.


Classic video on inverting a 3x3 matrix part 1

WEBVTT
Kind: captions
Language: en

00:00:00.820 --> 00:00:05.690
We will now embark on what is
probably my least favorite

00:00:05.690 --> 00:00:08.300
exercise or computation in
mathematics-- and I think

00:00:08.300 --> 00:00:12.750
you'll see why-- where we will
invert a 3 by 3 matrix.

00:00:12.750 --> 00:00:16.200
And in my mind, the only thing
less pleasant than inverting a

00:00:16.200 --> 00:00:19.990
3 by 3 matrix is inverting
a 4 by 4 matrix.

00:00:19.990 --> 00:00:22.260
It very quickly becomes obvious
to you that it's

00:00:22.260 --> 00:00:24.240
probably better for a
computer to do this.

00:00:24.240 --> 00:00:26.020
But you need to learn
how to do it.

00:00:26.020 --> 00:00:28.020
And it's a good exercise
for me to do.

00:00:28.020 --> 00:00:31.040
And if I keep doing it my whole
life, it'll prevent my

00:00:31.040 --> 00:00:32.439
brain from degrading.

00:00:32.439 --> 00:00:35.310
But as you'll see, this is
almost an exercise in not

00:00:35.310 --> 00:00:36.870
making careless mistakes.

00:00:36.870 --> 00:00:39.160
So let's start with a
3 by 3 matrix and

00:00:39.160 --> 00:00:41.630
try to take the inverse.

00:00:41.630 --> 00:00:44.770
So let's say I have matrix a.

00:00:44.770 --> 00:00:46.570
I think I'm going to need a lot
of space here, so I'll try

00:00:46.570 --> 00:00:50.930
to do this small, without
being confusing.

00:00:50.930 --> 00:00:52.640
Matrix a.

00:00:52.640 --> 00:00:57.510
Let's say it's 1, 0-- and I'm
specifically choosing this

00:00:57.510 --> 00:01:04.640
matrix because the numbers are
reasonably non-hairy-- 0, 2,

00:01:04.640 --> 00:01:10.470
1, 1, 1, 1.

00:01:10.470 --> 00:01:13.443
So the first thing that I do
when I take an inverse of a 3

00:01:13.443 --> 00:01:16.780
by 3 matrix, I create what I
call-- or not what I call,

00:01:16.780 --> 00:01:19.270
what everyone calls--
a matrix of minors.

00:01:19.270 --> 00:01:21.450
So let me write that down.

00:01:21.450 --> 00:01:22.700
Matrix of minors.

00:01:33.180 --> 00:01:34.430
So what's a minor?

00:01:36.600 --> 00:01:38.750
Let me draw that out.

00:01:38.750 --> 00:01:42.310
So it's going to be another
3 by 3 matrix.

00:01:42.310 --> 00:01:44.570
And what it is, so this
element, this top left

00:01:44.570 --> 00:01:48.050
element, is essentially going
to be the determinant.

00:01:48.050 --> 00:01:52.180
If I were to take my original
matrix, and I were to cross

00:01:52.180 --> 00:01:57.240
out this position's
row and column.

00:01:57.240 --> 00:02:01.710
So for example, this 1, 1
position, row 1, column 1.

00:02:01.710 --> 00:02:04.500
I cross out row 1
and column 1.

00:02:04.500 --> 00:02:05.730
What numbers do I have left?

00:02:05.730 --> 00:02:07.190
I have this 2, 1, 1, 1.

00:02:07.190 --> 00:02:08.590
I have this right here.

00:02:08.590 --> 00:02:11.090
So it's the determinant
of 2, 1, 1, 1.

00:02:11.090 --> 00:02:13.320
And actually maybe I'll
write that down.

00:02:13.320 --> 00:02:15.210
So it's the determinant
of 2, 1, 1, 1.

00:02:15.210 --> 00:02:17.870
So I'm gonna run out
of space I'm sure.

00:02:17.870 --> 00:02:23.110
It's going to be 2, 1, 1, 1.

00:02:23.110 --> 00:02:24.120
The determinant.

00:02:24.120 --> 00:02:26.530
The absolute value sign says
it's the determinant.

00:02:26.530 --> 00:02:29.100
Remember, all I did is, I said,
OK, in position 1,1, let

00:02:29.100 --> 00:02:33.550
me cross out the column and
the row 1,1, and take the

00:02:33.550 --> 00:02:34.950
determinant of what's left.

00:02:34.950 --> 00:02:38.320
Or the minor of this matrix.

00:02:38.320 --> 00:02:40.650
And then I will take the
determinant-- so when I go to

00:02:40.650 --> 00:02:47.150
this position, I'm in
row 1, column 2.

00:02:47.150 --> 00:02:49.810
I'm essentially going to
take the determinant.

00:02:49.810 --> 00:02:54.615
If I were to cross out row
1 and column 2, what

00:02:54.615 --> 00:02:55.440
do I have left over?

00:02:55.440 --> 00:02:58.750
I have 0, 1, 1, 1.

00:03:02.402 --> 00:03:04.777
It might be confusing, but just
remember-- I wish I had

00:03:04.777 --> 00:03:06.070
something I could
cover this with.

00:03:06.070 --> 00:03:09.500
Unfortunately my fingers can't
show up on this video.

00:03:09.500 --> 00:03:12.015
But if you cross this row and
this column out, you're just

00:03:12.015 --> 00:03:15.170
left with this 0, this 1,
this 1, and this 1.

00:03:15.170 --> 00:03:17.670
And you take the determinant
of that minor.

00:03:17.670 --> 00:03:18.690
And we'll keep going.

00:03:18.690 --> 00:03:21.650
I'm probably going to run out of
space here, but I will try

00:03:21.650 --> 00:03:25.790
my best. And so when you go to
this position-- row 1, column

00:03:25.790 --> 00:03:26.950
3-- what do you do?

00:03:26.950 --> 00:03:29.610
Well you cross out
row 1, column 3.

00:03:29.610 --> 00:03:32.090
And then the determinant, or the
minor that you have to do,

00:03:32.090 --> 00:03:33.760
is 0, 2, 1, 1.

00:03:38.970 --> 00:03:44.070
So the determinant of that
two by two matrix.

00:03:44.070 --> 00:03:47.010
And then you keep doing that,
so forth and so on.

00:03:47.010 --> 00:03:48.200
And I'm going to run
out of space.

00:03:48.200 --> 00:03:49.250
But what I'm going to
do is I'm just going

00:03:49.250 --> 00:03:50.080
to calculate it.

00:03:50.080 --> 00:03:51.940
I think you understand
how to do it.

00:03:51.940 --> 00:03:53.400
Well you don't understand how to
do it, but I think when we

00:03:53.400 --> 00:03:54.940
calculate it it'll make
a little more sense.

00:03:54.940 --> 00:03:58.580
Let me actually just
calculate it out.

00:03:58.580 --> 00:04:00.920
Because if I were to write these
2 by 2 matrices, I would

00:04:00.920 --> 00:04:02.110
run out of space.

00:04:02.110 --> 00:04:05.260
But anyway, let's go back
to this position 1, 1.

00:04:05.260 --> 00:04:08.390
Cross out the first row, first
column, I want the determinant

00:04:08.390 --> 00:04:10.330
of this thing right here.

00:04:10.330 --> 00:04:11.810
So what's the determinant
of this 2 by 2?

00:04:11.810 --> 00:04:13.080
That's not too hard.

00:04:13.080 --> 00:04:18.510
It's 2 times 1, minus
1 times 1.

00:04:18.510 --> 00:04:20.890
So what's 2 times 1,
minus 1 times 1?

00:04:20.890 --> 00:04:23.740
Well it's just 1.

00:04:23.740 --> 00:04:28.230
Then when we go to row 1,
column 2, I want the

00:04:28.230 --> 00:04:31.610
determinant of 0, 1, 1, 1.

00:04:31.610 --> 00:04:35.770
So it's 0 times 1,
minus 1 times 1.

00:04:35.770 --> 00:04:40.290
So 0 times 1 is 0, minus
1 times 1 is minus 1.

00:04:40.290 --> 00:04:42.290
And that's just this determinant
right here.

00:04:42.290 --> 00:04:44.710
I'm just kind of reshowing you
how I visualize when I cross

00:04:44.710 --> 00:04:46.000
out the rows and columns.

00:04:46.000 --> 00:04:48.410
So it's 0 times 1,
minus 1 times 1.

00:04:48.410 --> 00:04:50.610
And in this position of course,
you cross out this

00:04:50.610 --> 00:04:55.690
row, this column, and 0 times
1 minus 1 times 2.

00:04:55.690 --> 00:04:57.170
So that's minus 2.

00:05:00.110 --> 00:05:01.890
Let's keep going.

00:05:01.890 --> 00:05:02.790
All right.

00:05:02.790 --> 00:05:07.740
So now, when we're in row 2,
column 1, we cross out row 2,

00:05:07.740 --> 00:05:09.820
cross out column 1.

00:05:09.820 --> 00:05:12.490
And we're left with this 0,
this 1, this 1 and this 1.

00:05:12.490 --> 00:05:16.170
So it's 0 times 1, which is 0.

00:05:16.170 --> 00:05:19.000
Minus 1 times 1.

00:05:19.000 --> 00:05:20.510
So we're at minus 1.

00:05:25.300 --> 00:05:29.030
Then when we get row 2, column
2, we cross those two out, and

00:05:29.030 --> 00:05:31.480
we take the matrix of the
minor that's left.

00:05:31.480 --> 00:05:36.600
So that's 1 times 1,
minus 1 times 1.

00:05:36.600 --> 00:05:37.850
So that's 0.

00:05:39.780 --> 00:05:41.620
Almost. We're halfway done.

00:05:41.620 --> 00:05:45.070
OK, so then we're in
row 2, column 3.

00:05:45.070 --> 00:05:47.680
So we cross out row
2, column 3.

00:05:47.680 --> 00:05:53.660
And what we have left is 1
times 1, minus 1 time 0.

00:05:53.660 --> 00:05:57.000
So that is just 1.

00:05:57.000 --> 00:05:58.120
Last row.

00:05:58.120 --> 00:06:00.290
OK, so we're in row
3, column 1.

00:06:00.290 --> 00:06:03.660
So we cross out row
3, column 1.

00:06:03.660 --> 00:06:06.980
You're left with
0 times 1 is 0.

00:06:06.980 --> 00:06:08.260
Minus 2 times 1.

00:06:08.260 --> 00:06:09.510
So that's minus 2.

00:06:13.850 --> 00:06:16.760
Then we're in row 3, column 2.

00:06:16.760 --> 00:06:20.110
So we cross out row
3, column 2.

00:06:20.110 --> 00:06:24.390
And you have 1 times
1, minus 0 times 1.

00:06:24.390 --> 00:06:27.110
So that's just 1.

00:06:27.110 --> 00:06:28.730
Last one.

00:06:28.730 --> 00:06:29.900
Row 3, column 3.

00:06:29.900 --> 00:06:32.440
So we cross out row 3, we
cross out column 3.

00:06:32.440 --> 00:06:35.680
And you're just left with 1
times 2, minus 0 times 0.

00:06:35.680 --> 00:06:38.080
So that is 2.

00:06:38.080 --> 00:06:40.450
And if I haven't made any
careless mistakes, that is our

00:06:40.450 --> 00:06:41.700
matrix of minors.

00:06:45.110 --> 00:06:48.270
Now we now have to convert
this to what we call the

00:06:48.270 --> 00:06:49.930
matrix of cofactors.

00:06:49.930 --> 00:06:52.480
And actually this step is
fairly straightforward.

00:06:52.480 --> 00:06:55.820
So to convert from a matrix
of minors to a matrix of

00:06:55.820 --> 00:06:59.170
cofactors, you just have to
remember this pattern.

00:06:59.170 --> 00:07:03.690
This pattern applies to
any 3 by 3 matrix.

00:07:03.690 --> 00:07:08.630
Plus, minus, plus, minus,
plus, minus,

00:07:08.630 --> 00:07:11.270
plus, minus, plus.

00:07:11.270 --> 00:07:13.050
And so you can kind of just
imagine this as kind of a

00:07:13.050 --> 00:07:14.960
checkerboard of pluses
and minuses.

00:07:14.960 --> 00:07:17.470
And you apply that to this.

00:07:17.470 --> 00:07:18.670
So what do I mean by that?

00:07:18.670 --> 00:07:21.530
Well that means, when you start,
it's a checkerboard,

00:07:21.530 --> 00:07:23.300
and you start with a plus
at the top left.

00:07:23.300 --> 00:07:25.800
And then you just keep
alternating plus, minus.

00:07:25.800 --> 00:07:28.470
So if you applied this
to this, you get

00:07:28.470 --> 00:07:31.020
the matrix of cofactors.

00:07:31.020 --> 00:07:32.270
Let me write that down.

00:07:43.040 --> 00:07:45.800
You can imagine this is a bit of
a marathon of computation.

00:07:45.800 --> 00:07:51.840
OK, so the matrix of cofactors
is essentially applying this

00:07:51.840 --> 00:07:54.880
pattern to the matrix
of minors.

00:07:54.880 --> 00:07:55.430
So what do you do?

00:07:55.430 --> 00:07:59.860
You say this plus
1 times 1 is 1.

00:07:59.860 --> 00:08:01.680
But now we have a minus.

00:08:01.680 --> 00:08:06.240
So that's minus times minus
1 is positive 1.

00:08:06.240 --> 00:08:09.812
Then you have plus times
minus 2 is minus 2.

00:08:09.812 --> 00:08:11.500
Then you have a minus here.

00:08:11.500 --> 00:08:14.990
Minus times minus
1 is positive 1.

00:08:14.990 --> 00:08:17.790
Plus times 0 is still 0.

00:08:17.790 --> 00:08:22.820
Minus times 1 is minus 1.

00:08:22.820 --> 00:08:27.200
Plus times minus 2 is minus 2.

00:08:27.200 --> 00:08:30.690
Minus applied to 1 is minus 1.

00:08:30.690 --> 00:08:33.460
And then plus applied
to 2 is just 2.

00:08:33.460 --> 00:08:36.510
And we have our matrix
of cofactors.

00:08:36.510 --> 00:08:38.299
And we are more than
halfway done with

00:08:38.299 --> 00:08:39.000
inverting this matrix.

00:08:39.000 --> 00:08:40.720
And I just want to
take a note here.

00:08:40.720 --> 00:08:44.200
What we're doing is kind of
just a magic formula.

00:08:44.200 --> 00:08:46.600
It might seem a little bit
like voodoo for you.

00:08:46.600 --> 00:08:49.740
But I just want you to keep in
mind that in future videos, I

00:08:49.740 --> 00:08:51.090
will show you where
this comes from.

00:08:51.090 --> 00:08:52.630
Although it will be quite
hairy to prove

00:08:52.630 --> 00:08:53.500
it for a 3 by 3.

00:08:53.500 --> 00:08:56.750
But I'll definitely show
it to you for a 2 by 2.

00:08:56.750 --> 00:08:59.030
And actually, I'll show you
other algorithms that might

00:08:59.030 --> 00:09:00.890
make a little bit more intuitive
sense for doing it

00:09:00.890 --> 00:09:02.040
for a 3 by 3.

00:09:02.040 --> 00:09:04.680
But I just wanted to show you
how to do it this way, so that

00:09:04.680 --> 00:09:07.530
at least when you see it on your
Algebra 2 exam-- because

00:09:07.530 --> 00:09:10.430
I think they actually teach this
in Algebra 2-- you could

00:09:10.430 --> 00:09:13.470
at least, if the teacher asks
you, solve for the matrix of

00:09:13.470 --> 00:09:15.730
minors or the cofactors or solve
for the determinant of

00:09:15.730 --> 00:09:17.740
the inverse, you can do it.

00:09:17.740 --> 00:09:19.430
And then we'll worry about
getting the intuition, which

00:09:19.430 --> 00:09:22.010
is not how I normally like
to teach things.

00:09:22.010 --> 00:09:23.630
But this is an exception.

00:09:23.630 --> 00:09:25.910
But anyway, back
to the problem.

00:09:25.910 --> 00:09:28.100
This is the matrix
of cofactors.

00:09:28.100 --> 00:09:34.410
Now from this, we take the
adjoint of matrix a-- or I

00:09:34.410 --> 00:09:36.570
learned from Wikipedia, the
correct term is the adjugate

00:09:36.570 --> 00:09:38.630
of matrix a.

00:09:38.630 --> 00:09:46.660
But this is determined the
notation is the adjugate of a.

00:09:46.660 --> 00:09:50.030
And all this is is
the transpose of

00:09:50.030 --> 00:09:51.510
the matrix of cofactors.

00:09:51.510 --> 00:09:53.970
And I know I'm throwing out a
lot of weird terminology here.

00:09:53.970 --> 00:09:58.300
But the transpose, all that
means is that you switch the

00:09:58.300 --> 00:09:59.550
rows and the columns.

00:10:02.210 --> 00:10:08.010
So this one right here is
in row 1, column 1.

00:10:08.010 --> 00:10:10.100
But you know, so the rows and
columns are the same, so that

00:10:10.100 --> 00:10:10.950
just stays the same.

00:10:10.950 --> 00:10:13.170
So actually anything on the
diagonal stays the same.

00:10:13.170 --> 00:10:14.260
Because this is row
2, column 2.

00:10:14.260 --> 00:10:15.910
This is row 3, column 3.

00:10:15.910 --> 00:10:19.480
So the diagonals
stay the same.

00:10:19.480 --> 00:10:20.880
And then you switch places.

00:10:20.880 --> 00:10:23.130
You kind of flip across
the diagonal.

00:10:23.130 --> 00:10:24.470
And what do I mean by that?

00:10:24.470 --> 00:10:29.880
Well this 1 was in
row 1, column 2.

00:10:33.510 --> 00:10:37.350
So it'll then be moved
to row 2, column 1.

00:10:37.350 --> 00:10:41.680
So this 1 right here
will go here.

00:10:41.680 --> 00:10:46.400
So you can kind of say that it
flipped over the diagonal.

00:10:46.400 --> 00:10:50.910
And similarly, this right here
is in row 1, column 3.

00:10:50.910 --> 00:10:54.840
It's going to be switched
to row 3, column 1.

00:10:54.840 --> 00:10:56.090
So it's going to go here.

00:10:59.960 --> 00:11:02.450
And you can kind of see that it
just flipped over that end.

00:11:02.450 --> 00:11:03.890
So this minus 2 isn't
this one.

00:11:03.890 --> 00:11:06.040
It's this one over here.

00:11:06.040 --> 00:11:08.400
And actually, we see that this
matrix is symmetric.

00:11:08.400 --> 00:11:10.330
When you flip it, you actually
get the same thing.

00:11:10.330 --> 00:11:11.490
So maybe it was a bad example.

00:11:11.490 --> 00:11:14.230
But I want you to understand
that the transpose is where--

00:11:14.230 --> 00:11:19.830
if something like this number,
if it's in a row 1, column 2,

00:11:19.830 --> 00:11:22.180
then it moves to row
2, column 1.

00:11:22.180 --> 00:11:24.080
So you're switching the
rows and columns.

00:11:24.080 --> 00:11:25.480
But anyway, we could
keep doing that.

00:11:25.480 --> 00:11:28.080
But essentially you're just
flipping over the diagonal.

00:11:28.080 --> 00:11:28.710
So let's see.

00:11:28.710 --> 00:11:32.040
So then this number will be
flipped to this position, so

00:11:32.040 --> 00:11:33.970
it goes there.

00:11:33.970 --> 00:11:36.340
This is in row 2, column 1.

00:11:36.340 --> 00:11:40.820
So it will go to column 2,
row 1, which is that.

00:11:40.820 --> 00:11:43.610
And then if we go here, that's
going to be flipped down here,

00:11:43.610 --> 00:11:44.870
flipped across the diagonal.

00:11:44.870 --> 00:11:48.060
So that's minus 1.

00:11:48.060 --> 00:11:49.870
This is going to be flipped
all the way up there.

00:11:49.870 --> 00:11:51.680
So that's minus 2.

00:11:51.680 --> 00:11:53.245
And then this will
be flipped there.

00:11:53.245 --> 00:11:54.730
This is minus 1.

00:11:54.730 --> 00:11:56.780
We are almost done.

00:11:56.780 --> 00:12:00.530
So this is the adjoint
of matrix a.

00:12:00.530 --> 00:12:03.630
So to get the inverse of a-- and
let me actually erase some

00:12:03.630 --> 00:12:05.880
of this, because we're going to
run out of space otherwise.

00:12:09.030 --> 00:12:13.520
And as you can see, I'll be very
impressed if I have not

00:12:13.520 --> 00:12:15.060
introduced a careless
mistake yet.

00:12:21.460 --> 00:12:26.111
So let me erase all of this.

00:12:26.111 --> 00:12:28.370
I'm building an appetite just
doing this problem.

00:12:28.370 --> 00:12:31.360
It's so taxing on me.

00:12:31.360 --> 00:12:39.020
So the inverse of matrix a
is equal to 1 over the

00:12:39.020 --> 00:12:44.320
determinant of a times
the adjugate, or

00:12:44.320 --> 00:12:48.590
adjoint, of matrix a.

00:12:48.590 --> 00:12:50.680
So we solved for this part.

00:12:50.680 --> 00:12:54.760
So now let's solve for
the determinant.

00:12:54.760 --> 00:12:57.640
So the determinant of a-- and I
kept the matrix of cofactors

00:12:57.640 --> 00:13:04.350
here for a reason-- the
determinant of a is-- if you

00:13:04.350 --> 00:13:06.740
go across-- you can actually go
across any row-- but just

00:13:06.740 --> 00:13:08.820
for simplicity, just remember
it this way.

00:13:08.820 --> 00:13:12.380
You go across the top row, and
you multiply each term times

00:13:12.380 --> 00:13:17.000
its corresponding cofactor,
and you add them.

00:13:17.000 --> 00:13:21.780
So in this case, it'll be 1
times its corresponding

00:13:21.780 --> 00:13:23.710
cofactor, which is 1.

00:13:23.710 --> 00:13:29.160
Plus 0 times its corresponding
cofactor, which is 1.

00:13:29.160 --> 00:13:34.030
Plus 1 times its corresponding
cofactor plus minus 2.

00:13:34.030 --> 00:13:40.070
So this is 1 plus 0 minus 2.

00:13:40.070 --> 00:13:41.550
It equals minus 1.

00:13:41.550 --> 00:13:44.740
And thank God it was a
relatively straightforward

00:13:44.740 --> 00:13:45.510
determinant.

00:13:45.510 --> 00:13:47.560
And if you didn't have this
matrix of cofactors, the other

00:13:47.560 --> 00:13:49.040
way you could think about it--
and this is good because it

00:13:49.040 --> 00:13:51.040
gives you an intuition of how
we even got to the matrix of

00:13:51.040 --> 00:14:00.150
cofactors-- you could view this
as the same thing as 1

00:14:00.150 --> 00:14:03.570
times the determinant
of its minor.

00:14:03.570 --> 00:14:06.060
So if you cross out the row
and the column, it's this

00:14:06.060 --> 00:14:06.640
determinant.

00:14:06.640 --> 00:14:11.640
So it's 2, 1, 1, 1.

00:14:11.640 --> 00:14:12.850
And remember there
was that pattern.

00:14:12.850 --> 00:14:14.700
You have plus, and then
you go minus.

00:14:14.700 --> 00:14:19.770
So minus 0 times the determinant
of its minor.

00:14:19.770 --> 00:14:22.280
So you cross out that
row, that column.

00:14:22.280 --> 00:14:23.890
So 0, 1, 1, 1.

00:14:26.900 --> 00:14:28.280
And then we switch again.

00:14:28.280 --> 00:14:29.570
We go back to plus.

00:14:29.570 --> 00:14:33.540
Plus 1 times the determinant
of its minor.

00:14:33.540 --> 00:14:35.310
So you cross out that
row, that column.

00:14:35.310 --> 00:14:36.560
You get 0, 2, 1, 1.

00:14:40.030 --> 00:14:41.160
And you could compute
this out.

00:14:41.160 --> 00:14:47.110
And this is this cofactor.

00:14:47.110 --> 00:14:51.080
This, with a minor sign,
this is just a minor.

00:14:51.080 --> 00:14:52.360
And then when you apply
the minus sign, it

00:14:52.360 --> 00:14:53.850
becomes this cofactor.

00:14:53.850 --> 00:14:55.380
And then this is that minor.

00:14:55.380 --> 00:14:57.980
And since it's a plus sign
there, that's that cofactor.

00:14:57.980 --> 00:14:59.875
But anyway, I just wanted to
explain that, and hopefully it

00:14:59.875 --> 00:15:00.450
hasn't confused you.

00:15:00.450 --> 00:15:03.720
But we're ready now to solve
the inverse of a.

00:15:03.720 --> 00:15:08.310
We know that the determinant
of a is equal to minus 1.

00:15:08.310 --> 00:15:11.260
We know that the adjugate of
a is this number here.

00:15:11.260 --> 00:15:13.810
So we now can solve
for the inverse.

00:15:13.810 --> 00:15:14.630
And let's do that.

00:15:14.630 --> 00:15:16.110
Let me erase all
of this stuff.

00:15:16.110 --> 00:15:18.300
Cause actually, after I solve
for the inverse, I want to

00:15:18.300 --> 00:15:21.670
prove to you that it is
the inverse-- maybe.

00:15:21.670 --> 00:15:22.760
If I have enough time.

00:15:22.760 --> 00:15:25.900
Because I just realized I'm
running pretty long.

00:15:25.900 --> 00:15:27.410
That might be a good
exercise for you.

00:15:30.090 --> 00:15:31.340
OK.

00:15:33.320 --> 00:15:39.900
So the inverse of a is equal
to 1 over the determinant.

00:15:39.900 --> 00:15:42.850
We figured out the determinant
is negative 1 times the

00:15:42.850 --> 00:15:45.640
adjugate of a.

00:15:45.640 --> 00:15:50.780
1, 1, minus 2.

00:15:50.780 --> 00:15:53.840
1, 0, minus 1.

00:15:53.840 --> 00:15:57.650
Minus 2, minus 1, 2.

00:15:57.650 --> 00:15:59.350
So this is just minus
1, right?

00:15:59.350 --> 00:16:02.250
So we just apply minus
1 times everything.

00:16:02.250 --> 00:16:05.270
So we get-- if I haven't made
any careless mistakes-- minus

00:16:05.270 --> 00:16:18.290
1, minus 1, plus 2, minus
1, 0, 1, 2, 1, minus 2.

00:16:18.290 --> 00:16:23.860
I think that I have-- let's see,
I just did a minus times

00:16:23.860 --> 00:16:25.610
everything.

00:16:25.610 --> 00:16:26.730
That looks right.

00:16:26.730 --> 00:16:28.140
And so that is a inverse.

00:16:28.140 --> 00:16:31.160
And it only took
us 17 minutes.

00:16:31.160 --> 00:16:33.050
And I will leave you there,
because it will probably take

00:16:33.050 --> 00:16:34.540
me another 5 or 10 minutes
to [? seed ?]

00:16:34.540 --> 00:16:35.460
and prove.

00:16:35.460 --> 00:16:36.800
But that might be a good
exercise for you.

00:16:36.800 --> 00:16:39.750
To multiply this matrix times
this matrix, and make sure

00:16:39.750 --> 00:16:41.840
that you get the identity
matrix.

00:16:41.840 --> 00:16:44.250
I will see you in
the next video.


Matrix multiplication (part 2)

WEBVTT
Kind: captions
Language: en

00:00:00.670 --> 00:00:02.920
Let's do some more matrix
multiplication examples,

00:00:02.920 --> 00:00:06.020
because I think it is all about
seeing as many examples

00:00:06.020 --> 00:00:07.220
as possible.

00:00:07.220 --> 00:00:11.040
So let's do what may seem to be
a more difficult problem,

00:00:11.040 --> 00:00:12.520
and it might not be even
clear that we can

00:00:12.520 --> 00:00:13.740
multiply these matrices.

00:00:13.740 --> 00:00:15.760
And maybe that's the first thing
we should think about.

00:00:15.760 --> 00:00:18.635
So let's say I wanted to
multiply the matrix-- I'll do

00:00:18.635 --> 00:00:22.670
it relatively small so we
don't run out of space.

00:00:22.670 --> 00:00:33.510
3, 1, 2, minus 2, 0, 5.

00:00:33.510 --> 00:00:43.320
Let's say I want to multiply
that times the matrix, minus

00:00:43.320 --> 00:00:51.900
1, 0, 2, 3, 5, 5.

00:00:51.900 --> 00:00:54.360
I'm just making up
these numbers.

00:00:54.360 --> 00:00:57.000
So the first thing you might
be wondering is, well can I

00:00:57.000 --> 00:00:58.500
even multiply these matrices?

00:00:58.500 --> 00:01:00.177
Because you know from the
first video we did on

00:01:00.177 --> 00:01:03.040
matrices, that you can't
add these two matrices.

00:01:03.040 --> 00:01:05.180
This term corresponds to this
one; this one corresponds to

00:01:05.180 --> 00:01:07.920
this one; but this term
corresponds to nothing over

00:01:07.920 --> 00:01:10.280
here so you couldn't add or
subtract these matrices.

00:01:10.280 --> 00:01:14.160
So the question is, can I
multiply these matrices?

00:01:14.160 --> 00:01:16.140
Well, what did we learn about
multiplying matrices?

00:01:16.140 --> 00:01:19.780
We know that, for example, if
this is going to result in

00:01:19.780 --> 00:01:23.360
some matrix--

00:01:23.360 --> 00:01:25.540
However we don't know even what
the dimensions are yet

00:01:25.540 --> 00:01:27.630
until we work through this
example, although there is a

00:01:27.630 --> 00:01:29.470
quick way for figuring it out.

00:01:29.470 --> 00:01:31.910
So this first term here, the
upper left term, where does it

00:01:31.910 --> 00:01:34.080
get its row information from
and where does it get its

00:01:34.080 --> 00:01:35.890
column information from?

00:01:35.890 --> 00:01:38.610
Well, it gets its row
information from here.

00:01:38.610 --> 00:01:45.280
So it is essentially this
row times which column?

00:01:45.280 --> 00:01:50.430
Times this column, right?

00:01:50.430 --> 00:01:54.210
And we can actually take the dot
product of this row vector

00:01:54.210 --> 00:01:57.060
and this column vector because
they have the same length.

00:01:57.060 --> 00:01:59.380
This is a column vector but it
has a length of 3, right?

00:01:59.380 --> 00:02:03.520
But it's a 3 by 1, it has
three elements in it.

00:02:03.520 --> 00:02:06.240
And this is a 1 by 3 row vector,
but it also has three

00:02:06.240 --> 00:02:06.730
elements in it.

00:02:06.730 --> 00:02:09.270
So we actually can take the
dot product or we can

00:02:09.270 --> 00:02:10.770
multiply these two.

00:02:10.770 --> 00:02:14.500
And similarly we can multiply
this times this whole thing to

00:02:14.500 --> 00:02:15.950
get this term right here.

00:02:15.950 --> 00:02:19.380
And we can multiply this thing
times this thing to get this

00:02:19.380 --> 00:02:21.730
term, and then this
thing times that

00:02:21.730 --> 00:02:23.350
term to get that term.

00:02:23.350 --> 00:02:26.100
So it actually turns out that
you can-- so what kind of a

00:02:26.100 --> 00:02:26.880
matrix is this?

00:02:26.880 --> 00:02:30.080
Let's call it that this is
matrix-- let me switch to

00:02:30.080 --> 00:02:30.920
[UNINTELLIGIBLE].

00:02:30.920 --> 00:02:32.830
So this is matrix A.

00:02:32.830 --> 00:02:35.640
And what are it's dimensions?

00:02:35.640 --> 00:02:38.640
It has 2 rows, 1, 2,
and 3 columns.

00:02:38.640 --> 00:02:40.130
So it's a 2 by 3 matrix.

00:02:45.530 --> 00:02:46.970
We're multiplying it times B.

00:02:50.980 --> 00:02:52.320
And what are B's dimensions?

00:02:52.320 --> 00:02:54.670
Well, it has 3 rows, 1, 2, 3.

00:02:54.670 --> 00:02:57.920
So it is a 3 by-- and how many
columns does it have?

00:02:57.920 --> 00:03:00.700
1, 2-- 2 matrix.

00:03:00.700 --> 00:03:04.160
So it turns out that we can
multiply two matrices.

00:03:04.160 --> 00:03:08.710
You can say that the number--
if, on the first matrix-- the

00:03:08.710 --> 00:03:12.750
number of columns is equal to
the number of rows in the

00:03:12.750 --> 00:03:14.360
second matrix.

00:03:14.360 --> 00:03:18.190
So here, 2 by 3 times 3
by 2, we can multiply.

00:03:18.190 --> 00:03:21.120
For example, we could
have multiplied, if

00:03:21.120 --> 00:03:23.840
this is matrix C.

00:03:23.840 --> 00:03:25.410
I don't know if I take
so much time to keep

00:03:25.410 --> 00:03:26.440
bolding these things.

00:03:26.440 --> 00:03:28.710
And I don't care how
many rows it has.

00:03:28.710 --> 00:03:34.580
It can have n rows,
n times a columns.

00:03:34.580 --> 00:03:39.380
I can multiply it times
matrix D, as long as

00:03:39.380 --> 00:03:42.990
matrix D has a rows.

00:03:42.990 --> 00:03:45.430
As long as you can say these
two inner numbers are the

00:03:45.430 --> 00:03:45.950
same, right?

00:03:45.950 --> 00:03:47.130
This 3 is the same as 3.

00:03:47.130 --> 00:03:49.250
And why does that matter,
what was the logic?

00:03:49.250 --> 00:03:52.490
Because this row will have 3
elements because there's 3

00:03:52.490 --> 00:03:55.470
columns, and each column
vector here will have 3

00:03:55.470 --> 00:03:57.050
elements, because
there's 3 rows.

00:03:57.050 --> 00:03:58.760
That's where intuition comes
from, but if you had to do it

00:03:58.760 --> 00:04:01.990
really quickly you say 2 by 3,
3 by 2, this number is equal

00:04:01.990 --> 00:04:04.160
to that number, I
can multiply.

00:04:04.160 --> 00:04:06.040
So let me clear up some
space and let's do the

00:04:06.040 --> 00:04:08.220
multiplication.

00:04:08.220 --> 00:04:09.470
Let's do some multiplication.

00:04:12.630 --> 00:04:14.920
I'm debating where I should do
it, actually I think I should

00:04:14.920 --> 00:04:18.550
do it down here maybe because
I'll have more space.

00:04:18.550 --> 00:04:19.500
So let me do it down there;
I don't have to

00:04:19.500 --> 00:04:21.529
erase anything else.

00:04:21.529 --> 00:04:24.700
So let me get some
space ready.

00:04:24.700 --> 00:04:28.250
OK, this will take up
a lot of space.

00:04:28.250 --> 00:04:32.150
So to get this row 1, column
1 element, what do I do?

00:04:32.150 --> 00:04:34.420
I multiply this vector
times this vector.

00:04:34.420 --> 00:04:36.040
I take the dot product, right?

00:04:36.040 --> 00:04:38.020
So it's 3 times negative 1-- I'm
just going to write it all

00:04:38.020 --> 00:04:47.600
-- 3 times minus 1, plus 1
times 0, plus 2 times 2.

00:04:51.090 --> 00:04:53.170
There, we got the first term.

00:04:53.170 --> 00:04:55.350
So the second term here,
what am I going to do?

00:04:55.350 --> 00:04:59.500
I'm going to multiply that
vector times that row vector

00:04:59.500 --> 00:05:01.200
times this column vector.

00:05:01.200 --> 00:05:03.830
And I think you're getting the
hang of this, and really the

00:05:03.830 --> 00:05:06.970
hardest part about this is
staying focused and not making

00:05:06.970 --> 00:05:08.290
a careless mistake.

00:05:08.290 --> 00:05:09.820
And not getting it confused
with rows and

00:05:09.820 --> 00:05:11.360
columns and all that.

00:05:11.360 --> 00:05:13.290
It just sends blood to your
brain, but it's not

00:05:13.290 --> 00:05:14.920
that hard, I think.

00:05:14.920 --> 00:05:15.440
So what do we do?

00:05:15.440 --> 00:05:18.880
We multiply this row vector
times this column vector to

00:05:18.880 --> 00:05:21.420
get row 1, column 2, right?

00:05:21.420 --> 00:05:25.030
Because this row,
row 1, column 2.

00:05:25.030 --> 00:05:36.030
3 times 3, plus 1 times 5,
plus 2 times 5, right.

00:05:36.030 --> 00:05:40.230
We're just multiplying the
corresponding terms, the third

00:05:40.230 --> 00:05:42.200
term times the third term, the
second term times the second

00:05:42.200 --> 00:05:43.620
term, the first term times
the first term.

00:05:43.620 --> 00:05:46.340
Although, in this case they're
going down, in this case

00:05:46.340 --> 00:05:47.830
they're going left and right.

00:05:47.830 --> 00:05:49.150
Oh, we add them all up.

00:05:49.150 --> 00:05:52.240
OK, so now we're in the second
row, and we get our row

00:05:52.240 --> 00:05:54.890
information from the first
vector-- and let me do a red

00:05:54.890 --> 00:05:57.630
that I never use because I think
it's kind of tacky, this

00:05:57.630 --> 00:05:58.320
red right here.

00:05:58.320 --> 00:05:59.720
So I'm going to multiply
this row vector

00:05:59.720 --> 00:06:00.790
times this column vector.

00:06:00.790 --> 00:06:11.530
So it's minus 2 times minus
1, plus 0 times 0,

00:06:11.530 --> 00:06:13.015
plus 5 times 2.

00:06:15.900 --> 00:06:17.900
We're almost done.

00:06:17.900 --> 00:06:20.550
Let me see-- I don't like this
color at all-- and now we're

00:06:20.550 --> 00:06:22.760
going to multiply this row,
because we're in this bottom

00:06:22.760 --> 00:06:27.390
row, we're in row 2, column
2, to row 2, column 2.

00:06:27.390 --> 00:06:42.720
So it's minus 2 times 3, plus
0 times 5, plus 5 times 5.

00:06:42.720 --> 00:06:47.310
And then if we simplify, let's
see, this is minus 3 plus 0,

00:06:47.310 --> 00:06:51.110
plus 4, so this-- if I have
my math correct--

00:06:51.110 --> 00:06:53.460
simplifies to 1.

00:06:53.460 --> 00:06:59.450
9 plus 5 is 14, plus 10 is 24.

00:06:59.450 --> 00:07:06.170
This is 1, 24, and then minus 2
times minus 1 is 2, plus 10,

00:07:06.170 --> 00:07:08.970
so this is 12.

00:07:08.970 --> 00:07:14.830
And then minus 2 times 3 is
minus 6, plus 10-- this is 0--

00:07:14.830 --> 00:07:17.290
so minus 6 plus 10 is 4.

00:07:17.290 --> 00:07:18.710
So that's interesting.

00:07:18.710 --> 00:07:22.070
When I multiplied a 2 by 3
vector times a 3 by 2 vector,

00:07:22.070 --> 00:07:23.090
what did I get?

00:07:23.090 --> 00:07:26.640
I got a 2 by 2 matrix.

00:07:26.640 --> 00:07:30.930
A 2 by 3 matrix, a 2 by 3 times
3 by 2 matrix, I got a 2

00:07:30.930 --> 00:07:32.180
by 2 matrix.

00:07:32.180 --> 00:07:34.160
And where do you see a 2 by 2?

00:07:34.160 --> 00:07:37.255
Well, it's like this got
multiplied with this, and what

00:07:37.255 --> 00:07:40.700
we have left over is
a 2 by 2 matrix.

00:07:40.700 --> 00:07:43.580
So in general-- well actually,
before I go into the general,

00:07:43.580 --> 00:07:44.610
let me ask you a question.

00:07:44.610 --> 00:07:47.060
Could I have multiplied the
matrices the other way?

00:07:47.060 --> 00:07:51.710
Could I have multiplied-- so
this right here that is A

00:07:51.710 --> 00:07:55.100
times B, or you can sometimes
write this AB, and we'd bold

00:07:55.100 --> 00:07:56.840
it all up so we know
it's matrices.

00:07:56.840 --> 00:08:00.300
So could we have multiplied
B times A?

00:08:00.300 --> 00:08:02.450
Let me clear this down
here and let's try.

00:08:02.450 --> 00:08:05.450
Let's see if we can multiply
B times A.

00:08:05.450 --> 00:08:08.150
I think you can already suspect
that, since I'm asking

00:08:08.150 --> 00:08:10.820
the question, maybe
you cannot.

00:08:10.820 --> 00:08:13.180
Let's clear up some space.

00:08:13.180 --> 00:08:16.470
Let's try to do it the other
way around, let's try to

00:08:16.470 --> 00:08:18.550
multiply B times A.

00:08:18.550 --> 00:08:28.000
So B is minus 1,
0, 2, 3, 5, 5.

00:08:28.000 --> 00:08:31.730
And A is-- I'm switching
the order-- 3, 1,

00:08:31.730 --> 00:08:34.130
2, minus 2, 0, 5.

00:08:34.130 --> 00:08:36.140
And I tend to put brackets
around my matrices.

00:08:36.140 --> 00:08:37.960
Some people have these
big parentheses.

00:08:37.960 --> 00:08:42.039
It's just all notation; there's
nothing particular

00:08:42.039 --> 00:08:43.590
about notation.

00:08:43.590 --> 00:08:45.510
So let's see if you can
multiply these.

00:08:45.510 --> 00:08:48.830
So we learned that you get the
row information from the first

00:08:48.830 --> 00:08:50.220
matrix and the column
information

00:08:50.220 --> 00:08:50.950
from the second one.

00:08:50.950 --> 00:08:57.530
So this term, in theory, should
be that row times what?

00:09:00.800 --> 00:09:03.730
Well, actually, it turns out
that you can multiply them.

00:09:03.730 --> 00:09:04.140
Why?

00:09:04.140 --> 00:09:09.470
Because this is a 3 by 2, and
this is a 2 by 3, right?

00:09:09.470 --> 00:09:12.360
So we're going to take that row
times what?-- times this

00:09:12.360 --> 00:09:16.010
column to get the first
term, right?

00:09:16.010 --> 00:09:16.820
So what is it going to be?

00:09:16.820 --> 00:09:18.310
It's going to be minus 1.

00:09:18.310 --> 00:09:20.540
So I actually thought I was
doing a counter example, but

00:09:20.540 --> 00:09:22.930
actually because this too is the
same as this, or when you

00:09:22.930 --> 00:09:27.400
switch the row this is
the same as this, you

00:09:27.400 --> 00:09:28.160
can multiply them.

00:09:28.160 --> 00:09:30.040
So I wanted to do a counter
example, but hey.

00:09:30.040 --> 00:09:32.290
Let's just work through this
because it never hurts to see

00:09:32.290 --> 00:09:33.020
another example.

00:09:33.020 --> 00:09:34.200
And you can see that I just
do this on the fly.

00:09:34.200 --> 00:09:34.910
So let's do this.

00:09:34.910 --> 00:09:38.380
And actually ahead of time, how
large will this matrix be?

00:09:38.380 --> 00:09:39.560
Well, this is interesting.

00:09:39.560 --> 00:09:42.100
It's actually going to
be a 3 by 3 matrix,

00:09:42.100 --> 00:09:43.030
a much bigger matrix.

00:09:43.030 --> 00:09:45.370
Let's work it all out, and maybe
you want to pause it and

00:09:45.370 --> 00:09:46.030
try it yourself.

00:09:46.030 --> 00:09:57.640
This row times this column, so
minus 1 times 3, it's minus 3,

00:09:57.640 --> 00:10:01.930
3 times minus 2 is minus 6.

00:10:01.930 --> 00:10:06.330
And then it's going to be this
row times this column.

00:10:06.330 --> 00:10:09.980
So it's minus 1 times 1 plus
3 times 0, so that's

00:10:09.980 --> 00:10:11.640
just minus 1, right?

00:10:11.640 --> 00:10:13.250
Because 3 times 0 is 0.

00:10:13.250 --> 00:10:17.100
And then, that was that one,
then there's the middle one,

00:10:17.100 --> 00:10:19.580
and now we get the
row 1, column 3.

00:10:19.580 --> 00:10:20.750
So row 1, column 3.

00:10:20.750 --> 00:10:23.750
So it's that row times
this column.

00:10:23.750 --> 00:10:27.670
You can tell, this is often
better done by a computer.

00:10:27.670 --> 00:10:32.140
Minus 1 times 2 is minus 2 plus
15-- 3 times 5-- so minus

00:10:32.140 --> 00:10:34.940
2 plus 5 is 13.

00:10:34.940 --> 00:10:36.330
Let's keep going.

00:10:36.330 --> 00:10:39.030
So now we're going to take--

00:10:39.030 --> 00:10:42.760
I'm sweating, this is so
computationally intensive--

00:10:42.760 --> 00:10:45.670
We're taking this row times
each of these columns.

00:10:45.670 --> 00:10:46.770
And actually we are going to
learn later that there are

00:10:46.770 --> 00:10:49.880
multiple ways of actually
thinking about how this

00:10:49.880 --> 00:10:52.130
multiplication happens, even
multiple ways by computer, but

00:10:52.130 --> 00:10:53.840
this is the traditional way.

00:10:53.840 --> 00:10:56.070
So this row times each of
these columns, right?

00:10:56.070 --> 00:11:01.830
So 0, 5, so 0 times 3 plus 5
times minus 2, that's minus

00:11:01.830 --> 00:11:06.830
10, and it's 0 times
1 plus 5 times 0.

00:11:06.830 --> 00:11:08.840
That's easy, that's 0.

00:11:08.840 --> 00:11:14.150
0 times 2 plus 5 times
5 is 25-- almost

00:11:14.150 --> 00:11:15.690
there, almost done.

00:11:15.690 --> 00:11:18.580
Now we're going to take this row
and multiply it times each

00:11:18.580 --> 00:11:19.320
of these columns.

00:11:19.320 --> 00:11:25.620
So 2 times 3, that's 6,
plus minus 10, so

00:11:25.620 --> 00:11:27.700
that's minus 4, right?

00:11:27.700 --> 00:11:30.330
2 times 3 plus 5
times minus 2.

00:11:30.330 --> 00:11:33.470
Yes, that's minus 4,
6 minus 10, right?

00:11:33.470 --> 00:11:36.670
We have 2 times 1 plus
5 times 0, that's 2.

00:11:36.670 --> 00:11:43.590
Then you have 2 times 2 plus 5
times 5, so 4 plus 25 is 29.

00:11:43.590 --> 00:11:48.180
And of course that first term,
minus 3 minus 6, so

00:11:48.180 --> 00:11:50.640
this is minus 9.

00:11:50.640 --> 00:11:51.840
So there you have it.

00:11:51.840 --> 00:11:55.160
We multiplied the 3 by 2 matrix
times a 2 by 3 matrix,

00:11:55.160 --> 00:11:56.960
and we got a 3 by 3 matrix.

00:11:56.960 --> 00:11:58.240
And where did that
3 by 3 come from?

00:11:58.240 --> 00:12:02.970
Because this 3 is the number of
rows in the first matrix,

00:12:02.970 --> 00:12:05.720
and this 3 is the number of
columns in the second matrix,

00:12:05.720 --> 00:12:08.130
which makes sense because we got
our row information from

00:12:08.130 --> 00:12:10.830
the first matrix and our column
information from the

00:12:10.830 --> 00:12:12.300
second matrix.

00:12:12.300 --> 00:12:14.610
Now let me actually show
you an example

00:12:14.610 --> 00:12:18.360
that you cannot multiply.

00:12:18.360 --> 00:12:22.120
So what if I wanted to multiply
a-- let me do a very

00:12:22.120 --> 00:12:26.680
simple example-- what if
I wanted to multiply

00:12:26.680 --> 00:12:30.850
the matrix, 2, 1.

00:12:30.850 --> 00:12:33.430
And really, all this is,
is a row vector.

00:12:33.430 --> 00:12:43.720
And let's say that I wanted to
multiply this times-- I don't

00:12:43.720 --> 00:12:48.160
know, so this is a 2 by 1.

00:12:48.160 --> 00:12:52.080
So then let me say I want to
multiply this times-- so let

00:12:52.080 --> 00:13:04.270
me think of something--
1, 2, 3, 4, 5, 6.

00:13:04.270 --> 00:13:06.860
Now, can I multiply this?

00:13:06.860 --> 00:13:07.450
Well, what do we have?

00:13:07.450 --> 00:13:10.950
This is a 3 by 2 matrix.

00:13:10.950 --> 00:13:13.560
Can I multiply these
two matrices?

00:13:13.560 --> 00:13:15.960
Well, what do we have to do?

00:13:15.960 --> 00:13:18.680
We get our row information
from here, and our column

00:13:18.680 --> 00:13:19.440
information from here--

00:13:19.440 --> 00:13:23.080
Oh sorry, this isn't 2 by 1,
this is 1 row, two columns.

00:13:23.080 --> 00:13:25.390
This is a 1 by 2, right?

00:13:25.390 --> 00:13:26.770
That's a 1 by 2 matrix.

00:13:26.770 --> 00:13:30.150
So can you multiply the 1 by
2 times a 3 by 2 matrix?

00:13:30.150 --> 00:13:33.545
So we get our row information
from here, so we essentially

00:13:33.545 --> 00:13:37.490
have to multiply this by this
times this column to get our

00:13:37.490 --> 00:13:39.360
first element, then this
times this column to

00:13:39.360 --> 00:13:40.260
get our second element.

00:13:40.260 --> 00:13:42.760
And I don't know what happens
from there, but let me-- well,

00:13:42.760 --> 00:13:44.110
can we multiply?

00:13:44.110 --> 00:13:46.700
Just the way we have defined our
multiplication, or the dot

00:13:46.700 --> 00:13:49.390
product, can we multiply?

00:13:49.390 --> 00:13:52.600
Let's see, 2 times
1 plus 1 times 2.

00:13:52.600 --> 00:13:54.440
Then we don't have anything
to do with the 3.

00:13:54.440 --> 00:13:57.470
So the way that we've defined
matrix multiplication, you

00:13:57.470 --> 00:13:59.110
cannot multiply these
two matrices.

00:13:59.110 --> 00:14:01.060
And you didn't have to go
through that exercise.

00:14:01.060 --> 00:14:03.930
You could've looked at the
dimensions, 1 by 2, and this

00:14:03.930 --> 00:14:06.780
is a 3 by 2.

00:14:06.780 --> 00:14:11.020
This 2 is not equal to this 3,
the number of columns in the

00:14:11.020 --> 00:14:14.080
first are not equal to the
number of rows in the second.

00:14:14.080 --> 00:14:17.250
So you can not multiply
those two matrices.

00:14:17.250 --> 00:14:19.270
So that's something interesting
to think about.

00:14:19.270 --> 00:14:22.050
And they're actually examples,
and it's a good exercise for

00:14:22.050 --> 00:14:26.100
you to think about it, where
you can multiply A times B,

00:14:26.100 --> 00:14:28.270
but you can't multiply
B times A.

00:14:28.270 --> 00:14:30.930
So I want you think about
examples where that happens.

00:14:30.930 --> 00:14:34.540
But anyway, I'm pushing 15
minutes, and I will see you in

00:14:34.540 --> 00:14:36.190
the next video.


Introduction to matrices

WEBVTT
Kind: captions
Language: en

00:00:00.850 --> 00:00:04.360
Let's learn about matrices.

00:00:04.360 --> 00:00:05.800
What do I mean when
I say matrices?

00:00:05.800 --> 00:00:09.430
Well, matrices is just the
plural for matrix, which is

00:00:09.430 --> 00:00:11.810
probably a word you're familiar
with more because of

00:00:11.810 --> 00:00:14.720
Hollywood than because
of mathematics.

00:00:14.720 --> 00:00:16.802
So what is a matrix?

00:00:16.802 --> 00:00:20.120
Well, it's actually a
pretty simple idea.

00:00:20.120 --> 00:00:23.250
It's just a table of numbers,
that's all a matrix is.

00:00:23.250 --> 00:00:25.740
So let me draw matrix for you.

00:00:25.740 --> 00:00:27.820
I don't like that
toothpaste-colored blue, so

00:00:27.820 --> 00:00:29.230
let me use another color.

00:00:29.230 --> 00:00:30.900
So this is an example
of a matrix.

00:00:34.420 --> 00:00:37.850
I'm going to pick some random
numbers out: 5, 1,

00:00:37.850 --> 00:00:43.490
2, 3, 0, minus 5.

00:00:43.490 --> 00:00:44.980
That is a matrix.

00:00:44.980 --> 00:00:46.830
And all it is is a
table of numbers.

00:00:46.830 --> 00:00:49.392
And often times if you wanted
to have a variable for a

00:00:49.392 --> 00:00:52.530
matrix, you'd use a capital
letter, so you could use a

00:00:52.530 --> 00:00:55.180
capital A, and sometimes in some
books, they make it extra

00:00:55.180 --> 00:00:58.650
bold, so like a bold A
would be a matrix.

00:00:58.650 --> 00:01:03.990
And just a little bit of
notation, so we would call

00:01:03.990 --> 00:01:06.640
this matrix, just by convention,
you would call

00:01:06.640 --> 00:01:08.950
this a 2-by-3 matrix.

00:01:08.950 --> 00:01:13.220
And sometimes they actually
write it, 2 by 3, below the

00:01:13.220 --> 00:01:15.440
bold letter they use to
represent the matrix.

00:01:15.440 --> 00:01:17.300
And what is 2 and what is 3?

00:01:17.300 --> 00:01:19.100
Well, 2 is the number of rows.

00:01:19.100 --> 00:01:20.380
We have one row, two
rows, right?

00:01:20.380 --> 00:01:21.080
This is a row.

00:01:21.080 --> 00:01:21.920
This is a row.

00:01:21.920 --> 00:01:25.310
And we have three columns:
one, two, three.

00:01:25.310 --> 00:01:28.890
So that's why it's called
a 2-by-3 matrix.

00:01:28.890 --> 00:01:36.250
If I said that B-- I'll do it
extra bold-- if B is a 5-by-2

00:01:36.250 --> 00:01:43.610
matrix, that means that B would
have--- I'll just type

00:01:43.610 --> 00:01:48.870
in numbers: 0, minus 5, 10.

00:01:48.870 --> 00:01:51.620
So it has five rows and it has
two columns, so it'll have

00:01:51.620 --> 00:01:52.420
another column here.

00:01:52.420 --> 00:01:56.030
So let's see, minus 10, 3, I'm
just putting in random numbers

00:01:56.030 --> 00:02:00.015
here-- 7, 2, pi.

00:02:02.930 --> 00:02:05.930
That is a 5-by-2 matrix.

00:02:05.930 --> 00:02:08.610
So I think you now have kind
of a convention that all a

00:02:08.610 --> 00:02:10.300
matrix is is a table
of numbers.

00:02:10.300 --> 00:02:12.780
You can represent it
when you're doing

00:02:12.780 --> 00:02:13.760
it in variable form.

00:02:13.760 --> 00:02:16.010
You represent it as a boldface
capital letter.

00:02:16.010 --> 00:02:18.910
Sometimes you'd write
a 2 by 3 there.

00:02:18.910 --> 00:02:20.290
And, you can actually
reference the

00:02:20.290 --> 00:02:21.900
terms of the matrix.

00:02:21.900 --> 00:02:24.230
So in this example, in the top
example where we have matrix

00:02:24.230 --> 00:02:29.780
A, if someone wanted to
reference this element of the

00:02:29.780 --> 00:02:32.380
matrix, so what is that?

00:02:32.380 --> 00:02:34.780
That is in the second row.

00:02:34.780 --> 00:02:37.900
It's in row 2 and it's
in column 2, right?

00:02:37.900 --> 00:02:39.910
This is column 1, this
is column 2.

00:02:39.910 --> 00:02:41.520
This is row 1, row 2.

00:02:41.520 --> 00:02:44.250
So it's in the second
row, second column.

00:02:44.250 --> 00:02:51.470
So sometimes people will write
that A, and they'll write 2

00:02:51.470 --> 00:02:57.500
comma 2 is equal to 0.

00:02:57.500 --> 00:03:03.180
Or sometimes they'll write it as
a lowercase A 2 comma 2 is

00:03:03.180 --> 00:03:04.430
equal to 0.

00:03:08.730 --> 00:03:10.660
These are just the same thing.

00:03:10.660 --> 00:03:13.250
I'm just doing this to expose
you to the notation, because a

00:03:13.250 --> 00:03:15.080
lot of this really
is just notation.

00:03:15.080 --> 00:03:20.710
So what is a 1 comma 3?

00:03:20.710 --> 00:03:23.620
Well, that means we're in the
first row, the third column.

00:03:23.620 --> 00:03:26.770
First row, one, two, three, it's
this value right here.

00:03:26.770 --> 00:03:28.230
So that equals 2.

00:03:28.230 --> 00:03:31.090
So this is just all notation
of what a matrix is.

00:03:31.090 --> 00:03:33.025
It's a table of numbers that
can be represented this way

00:03:33.025 --> 00:03:35.830
and we can represent it as
different elements that way.

00:03:35.830 --> 00:03:39.250
So you might be asking, Sal,
well, that's nice.

00:03:39.250 --> 00:03:42.040
A table of numbers with fancy
words and fancy notations, but

00:03:42.040 --> 00:03:43.150
what is it good for?

00:03:43.150 --> 00:03:45.250
And that's the interesting
point.

00:03:45.250 --> 00:03:48.120
A matrix is just a data
representation.

00:03:48.120 --> 00:03:50.550
It's just a way of writing
down data.

00:03:50.550 --> 00:03:51.230
That's all it is.

00:03:51.230 --> 00:03:54.890
it's a table of numbers, but it
can be used to represent a

00:03:54.890 --> 00:03:56.180
whole set of phenomenon.

00:03:56.180 --> 00:03:59.280
And if soon. you're doing this
in your Algebra I or your

00:03:59.280 --> 00:04:01.560
Algebra II class, you're
probably using it to represent

00:04:01.560 --> 00:04:02.620
linear equations.

00:04:02.620 --> 00:04:06.490
But we'll learn later-- and I'll
do a whole set of videos

00:04:06.490 --> 00:04:08.530
on applying matrices
to a whole bunch

00:04:08.530 --> 00:04:09.140
of different things.

00:04:09.140 --> 00:04:13.440
But it can represent-- it's very
powerful and if you're

00:04:13.440 --> 00:04:16.459
doing computer graphics on a
matrix, the elements can

00:04:16.459 --> 00:04:18.370
represent pixels
on your screen.

00:04:18.370 --> 00:04:20.490
They can represent points
in coordinate space.

00:04:20.490 --> 00:04:22.079
They can represent--
who knows?

00:04:22.079 --> 00:04:23.880
There's tons of things that
they can represent.

00:04:23.880 --> 00:04:27.700
But the important thing to
realize is that a matrix, it's

00:04:27.700 --> 00:04:29.400
not a natural phenomenon.

00:04:29.400 --> 00:04:33.100
It's not like a lot of the
mathematical concepts we've

00:04:33.100 --> 00:04:33.710
been looking at.

00:04:33.710 --> 00:04:37.570
It's a way to represent a
mathematical concept or a way

00:04:37.570 --> 00:04:40.360
of representing values, but
you kind of have to define

00:04:40.360 --> 00:04:41.920
what it's representing.

00:04:41.920 --> 00:04:43.980
But let's put that on the back
burner a little bit in terms

00:04:43.980 --> 00:04:47.380
of what it actually
represents.

00:04:47.380 --> 00:04:48.430
Oh, my wife is here.

00:04:48.430 --> 00:04:50.690
She's looking for our
filing cabinet.

00:04:50.690 --> 00:04:52.870
But anyway, back to
what I was doing.

00:04:52.870 --> 00:04:56.150
So let's put on the back
burner what a matrix is

00:04:56.150 --> 00:04:58.230
actually representing and let's
learn the convention.

00:04:58.230 --> 00:05:01.300
Because I think, at least
initially, that tends to be

00:05:01.300 --> 00:05:01.960
the hardest part.

00:05:01.960 --> 00:05:03.350
How do you add matrices?

00:05:03.350 --> 00:05:04.880
How do you multiply matrices?

00:05:04.880 --> 00:05:06.230
How do you invert matrices?

00:05:06.230 --> 00:05:08.070
How do you find the determinant
of matrices?

00:05:08.070 --> 00:05:10.430
All of those words might sound
unfamiliar unless you've

00:05:10.430 --> 00:05:12.790
already been confused by them
in your algebra class.

00:05:12.790 --> 00:05:15.140
I'm going to teach you all of
those things first, which are

00:05:15.140 --> 00:05:17.850
all just really human-defined
conventions, and then later

00:05:17.850 --> 00:05:21.450
on, I'll make a whole bunch of
videos on the intuition behind

00:05:21.450 --> 00:05:23.550
them and what they actually
represent.

00:05:23.550 --> 00:05:25.700
So let's get started.

00:05:25.700 --> 00:05:28.680
So let's say I wanted to
add these two matrices.

00:05:28.680 --> 00:05:32.920
Let's say the first one-- and
let me switch colors.

00:05:32.920 --> 00:05:36.740
I'll do relatively small ones,
just so as not to waste space.

00:05:36.740 --> 00:05:45.320
Say I have the matrix
3, negative 1, 2 0.

00:05:45.320 --> 00:05:49.170
Let's call that A, capital A.

00:05:49.170 --> 00:05:53.360
Let's say matrix B, and I'm
just making up numbers.

00:05:53.360 --> 00:06:05.330
Matrix B is equal to
minus 7, 2, 3, 5.

00:06:05.330 --> 00:06:14.010
So my question to you is what
is A-- so I'm doing it bold

00:06:14.010 --> 00:06:16.950
like they do in the textbooks--
plus matrix B?

00:06:16.950 --> 00:06:20.210
So I'm adding two matrices.

00:06:20.210 --> 00:06:22.310
And once again, this is
just human convention.

00:06:22.310 --> 00:06:24.770
Someone defined how
matrices add.

00:06:24.770 --> 00:06:26.530
They could've defined it some
other way, but they said we're

00:06:26.530 --> 00:06:29.120
going to make matrices add the
way I'm about to show you,

00:06:29.120 --> 00:06:31.460
because it's useful for a
whole set of phenomena.

00:06:31.460 --> 00:06:34.620
So when you add two matrices,
you essentially just add the

00:06:34.620 --> 00:06:36.060
corresponding elements.

00:06:36.060 --> 00:06:38.900
So how does that work?

00:06:38.900 --> 00:06:41.820
Well, you add the element that
is in row 1, column 1 to the

00:06:41.820 --> 00:06:43.940
elements in row 1,
column 1, right?

00:06:43.940 --> 00:06:45.700
So it's 3 plus minus 7.

00:06:49.460 --> 00:06:51.560
That'll be the 1, 1 element.

00:06:51.560 --> 00:06:54.230
Then the row 1, column
2 element will be

00:06:54.230 --> 00:06:57.930
minus 1 plus 2.

00:06:57.930 --> 00:07:00.380
Let me put parentheses around
them so you know these are

00:07:00.380 --> 00:07:02.270
separate elements.

00:07:02.270 --> 00:07:04.550
And you can guess how
this keeps going.

00:07:04.550 --> 00:07:12.950
This element will be 2 plus
3 and this last element

00:07:12.950 --> 00:07:14.200
will be 0 plus 5.

00:07:19.600 --> 00:07:23.640
So that equals 3 plus minus 7.

00:07:23.640 --> 00:07:25.196
That is minus 4.

00:07:25.196 --> 00:07:28.690
Minus 1 plus 2, that's 1.

00:07:28.690 --> 00:07:32.660
2 plus 3 is 5, and
0 plus 5 is 5.

00:07:32.660 --> 00:07:33.820
So there we have it.

00:07:33.820 --> 00:07:37.240
That is how we humans
have defined the

00:07:37.240 --> 00:07:38.860
addition of two matrices.

00:07:38.860 --> 00:07:41.170
And by this definition, you
could imagine that this is

00:07:41.170 --> 00:07:46.560
going to be the same thing
as B plus A, right?

00:07:46.560 --> 00:07:47.800
And remember, this is something
we have to think

00:07:47.800 --> 00:07:51.180
about because we're not adding
numbers anymore.

00:07:51.180 --> 00:07:53.550
You know 1 plus 2 is the same
thing you is 2 plus 1, or you

00:07:53.550 --> 00:07:55.710
know any two normal numbers, it
doesn't matter what order

00:07:55.710 --> 00:07:56.620
you add them in.

00:07:56.620 --> 00:07:58.790
But with matrices, it's not
completely obvious.

00:07:58.790 --> 00:08:01.070
But when you define it in this
way, it doesn't matter if we

00:08:01.070 --> 00:08:02.620
do A plus B or B
plus A, right?

00:08:02.620 --> 00:08:05.290
If we did B plus A, this would
just say negative 7 plus 3.

00:08:05.290 --> 00:08:06.640
This would say 2 plus
negative 1.

00:08:06.640 --> 00:08:09.270
But it would come out
to the same values.

00:08:09.270 --> 00:08:10.890
That is matrix addition.

00:08:10.890 --> 00:08:13.580
And you could imagine, matrix
subtraction, it's essentially

00:08:13.580 --> 00:08:14.530
the same thing.

00:08:14.530 --> 00:08:15.500
Well, actually let
me show you.

00:08:15.500 --> 00:08:16.750
What would be A minus B?

00:08:26.820 --> 00:08:31.670
Well, this is capital B with the
matrix, so I'm making it

00:08:31.670 --> 00:08:32.240
extra bold.

00:08:32.240 --> 00:08:39.370
Well, that's the same thing
as A plus minus 1 times B.

00:08:39.370 --> 00:08:40.510
And what's B?

00:08:40.510 --> 00:08:46.150
Well, B is minus 7, 2, 3, 5.

00:08:46.150 --> 00:08:48.010
When you multiply a scalar,
when you just multiply a

00:08:48.010 --> 00:08:50.260
number times a matrix, you just
multiply the number times

00:08:50.260 --> 00:08:51.610
every one of it's elements.

00:08:51.610 --> 00:08:57.160
So that equals A, matrix
A, plus the matrix.

00:08:57.160 --> 00:09:00.160
We just multiply this negative 1
times every element in here.

00:09:00.160 --> 00:09:06.330
So 7, minus 2, minus 3, and 5.

00:09:06.330 --> 00:09:08.530
And then we can do what
we did up there.

00:09:08.530 --> 00:09:13.870
And we know what A is, so this
would equal-- A is up here, so

00:09:13.870 --> 00:09:16.340
3 plus 7 is 10.

00:09:16.340 --> 00:09:21.940
Negative 1 plus negative 2 is
minus 3, 2 plus minus 3 is

00:09:21.940 --> 00:09:27.625
minus 1, and 0 plus 5 is 5.

00:09:27.625 --> 00:09:29.100
Now, you didn't even have
to go through this

00:09:29.100 --> 00:09:29.820
exercise right here.

00:09:29.820 --> 00:09:32.300
You could have literally just
subtracted these elements from

00:09:32.300 --> 00:09:34.150
these elements, and you would
have gotten the same value.

00:09:34.150 --> 00:09:37.780
I did this because I wanted to
show you also that multiplying

00:09:37.780 --> 00:09:41.220
a scalar or just a value or a
number times a matrix is just

00:09:41.220 --> 00:09:43.830
multiplying that number
times all of the

00:09:43.830 --> 00:09:45.410
elements of the matrix.

00:09:45.410 --> 00:09:48.350
And so by this definition
of matrix

00:09:48.350 --> 00:09:49.770
addition, what do we know?

00:09:49.770 --> 00:09:52.490
Well, we know that both matrices
have to be the same

00:09:52.490 --> 00:09:55.250
size by this definition,
the way we're adding.

00:09:55.250 --> 00:09:58.470
So, for example, you could
add these two matrices.

00:09:58.470 --> 00:10:09.090
You could add 1, 2, 3, 4, 5, 6,
7, 8, 9 to this matrix, to

00:10:09.090 --> 00:10:14.120
minus 10, minus 100, minus
1000-- I'm making up numbers--

00:10:14.120 --> 00:10:18.950
1, 0, 0, 1, 0, 1.

00:10:18.950 --> 00:10:20.660
You can add these two
matrices, right?

00:10:20.660 --> 00:10:22.980
Because they have the same
number of rows and same number

00:10:22.980 --> 00:10:23.930
of columns.

00:10:23.930 --> 00:10:27.040
So for example, if you were to
add them, the first term up

00:10:27.040 --> 00:10:30.950
here would be 1 plus minus 10,
so it would be minus 9.

00:10:30.950 --> 00:10:33.520
2 plus minus 100 is minus 98.

00:10:33.520 --> 00:10:34.740
I think you get the point.

00:10:34.740 --> 00:10:38.170
You would have exactly nine
elements and you would have

00:10:38.170 --> 00:10:40.190
three rows and three columns.

00:10:40.190 --> 00:10:42.550
But you could not add
these two matrices.

00:10:42.550 --> 00:10:45.700
You could not add-- Let me do
it in a different color just

00:10:45.700 --> 00:10:47.210
so it's different.

00:10:47.210 --> 00:10:49.380
You could not add this blue.

00:10:49.380 --> 00:11:02.220
You could not add this matrix:
minus 3, 2 to the matrix 9, 7.

00:11:02.220 --> 00:11:03.830
And why can you not add them?

00:11:03.830 --> 00:11:05.590
Well, they don't have
corresponding

00:11:05.590 --> 00:11:06.560
elements to add up.

00:11:06.560 --> 00:11:11.710
This is a one row by two column,
this is 1 by 2, and

00:11:11.710 --> 00:11:13.370
this is 2 by 1.

00:11:13.370 --> 00:11:15.860
So they don't have the same
dimensions so we can't add or

00:11:15.860 --> 00:11:17.700
subtract these matrices.

00:11:17.700 --> 00:11:21.330
And this is a side note, when a
matrix has-- when one of its

00:11:21.330 --> 00:11:25.850
dimensions is one-- so, for
example, here you have one row

00:11:25.850 --> 00:11:29.090
and multiple columns, this is
actually called a row vector.

00:11:29.090 --> 00:11:31.540
A vector is essentially a
one-dimensional matrix where

00:11:31.540 --> 00:11:33.190
one of the dimensions is one.

00:11:33.190 --> 00:11:35.270
So this is a row vector,
and similarly,

00:11:35.270 --> 00:11:36.700
this is a column vector.

00:11:36.700 --> 00:11:39.230
That's just a little extra
terminology you should know.

00:11:39.230 --> 00:11:41.820
If you take linear algebra and
calculus, your professor might

00:11:41.820 --> 00:11:43.810
use those terms and it's good
to be familiar with it.

00:11:43.810 --> 00:11:46.840
But anyway, I'm pushing 11
minutes, so I will continue

00:11:46.840 --> 00:11:48.080
this in the next video.

00:11:48.080 --> 00:11:49.330
See