WEBVTT

00:00:06.454 --> 00:00:07.870
ANA RITA PIRES:
In lecture, you've

00:00:07.870 --> 00:00:10.260
learned about Gram-Schmidt
orthogonalization,

00:00:10.260 --> 00:00:12.600
and that's what today's
problem is about.

00:00:12.600 --> 00:00:17.790
We have a matrix A, and its
columns are a, b, and c.

00:00:17.790 --> 00:00:21.000
And I want you to find
orthonormal vectors

00:00:21.000 --> 00:00:24.360
q_1, q_2, and q_3 from
those three columns.

00:00:24.360 --> 00:00:28.890
Then I want you to write A
as a-- it's QR decomposition

00:00:28.890 --> 00:00:32.240
where Q is an orthogonal matrix,
and R is an upper triangular

00:00:32.240 --> 00:00:33.270
matrix.

00:00:33.270 --> 00:00:36.730
Remember, an orthogonal matrix
is a matrix whose columns

00:00:36.730 --> 00:00:39.480
are orthonormal vectors.

00:00:39.480 --> 00:00:41.169
Work on it for a
little while, hit

00:00:41.169 --> 00:00:42.960
pause, and when you're
ready I'll come back

00:00:42.960 --> 00:00:44.001
and we'll do it together.

00:00:52.170 --> 00:00:55.160
Did you manage to
solve that all right?

00:00:55.160 --> 00:00:58.490
Well let's start
solving it together.

00:00:58.490 --> 00:01:00.850
So Gram-Schmidt
orthogonalization,

00:01:00.850 --> 00:01:04.250
as you should
remember from lecture,

00:01:04.250 --> 00:01:06.210
consists of the following.

00:01:06.210 --> 00:01:10.540
At each step, you find
your orthonormal vector

00:01:10.540 --> 00:01:15.000
by taking the vector that
you started with, a, b, or c

00:01:15.000 --> 00:01:18.420
in this case, and
making it orthonormal

00:01:18.420 --> 00:01:22.430
to the previous ones.

00:01:22.430 --> 00:01:25.780
Let's actually do it.

00:01:25.780 --> 00:01:27.920
We want to find q_1.

00:01:27.920 --> 00:01:30.780
Well, to find q_1,
start with a, and make

00:01:30.780 --> 00:01:32.890
it orthonormal to
the previous one.

00:01:32.890 --> 00:01:35.020
There's no previous one,
so that's very easy.

00:01:35.020 --> 00:01:37.390
The direction of a
is fine and you just

00:01:37.390 --> 00:01:40.950
need to ensure that your
vector has length 1.

00:01:40.950 --> 00:01:44.790
Well, a is the vector [1, 0, 0].

00:01:44.790 --> 00:01:46.520
So you should divide
it by its length,

00:01:46.520 --> 00:01:54.240
but its length is 1, so
this is simply [1, 0, 0].

00:01:54.240 --> 00:01:55.280
q_1 is done.

00:01:55.280 --> 00:01:56.360
Now let's do q_2.

00:01:59.000 --> 00:02:03.560
So with q_2, I will
start with my vector b.

00:02:03.560 --> 00:02:05.520
And then I want to
make it, well first

00:02:05.520 --> 00:02:09.210
of all, orthogonal to what I
already have, which is q_1.

00:02:09.210 --> 00:02:14.070
For that, I'm going to subtract
off from b the projection of b

00:02:14.070 --> 00:02:16.290
onto q_1.

00:02:16.290 --> 00:02:21.970
Minus b dot q_1 times q_1.

00:02:21.970 --> 00:02:25.010
Usually, when you're doing the
projection of a vector onto

00:02:25.010 --> 00:02:27.630
another vector, you have
to divide it by the length

00:02:27.630 --> 00:02:29.600
of, in this case, q1_.

00:02:29.600 --> 00:02:34.700
But because q_1 has length
1, you don't need to do that.

00:02:34.700 --> 00:02:36.260
So what will it be here?

00:02:36.260 --> 00:02:46.770
Well b dot q_1 is going
to be-- b is [2, 0, 3],

00:02:46.770 --> 00:02:53.360
minus, b dot q_1 will
be 2, and [1, 0, 0].

00:02:53.360 --> 00:02:59.870
So this will be [0, 0, 3].

00:02:59.870 --> 00:03:02.320
This vector is
orthogonal to this one,

00:03:02.320 --> 00:03:04.440
and you can check by
doing your dot product.

00:03:04.440 --> 00:03:07.250
It should be 0, and it is.

00:03:07.250 --> 00:03:11.780
We need it also to be length
1, because we want these two

00:03:11.780 --> 00:03:13.920
vectors to be orthonormal.

00:03:13.920 --> 00:03:15.810
So this is not actually q_2.

00:03:15.810 --> 00:03:20.200
Let's call this one
q_2 prime, and set q_2

00:03:20.200 --> 00:03:25.520
equals to q_2 prime divided by
its length, which in this case

00:03:25.520 --> 00:03:26.755
is 3.

00:03:29.580 --> 00:03:32.890
[0, 0, 1].

00:03:32.890 --> 00:03:35.140
That's my vector q_2.

00:03:35.140 --> 00:03:40.960
Let's go on to the
third one, q_3.

00:03:40.960 --> 00:03:45.220
Well again, I start
with my third vector, c.

00:03:45.220 --> 00:03:49.370
And then I want to subtract
the projection of c

00:03:49.370 --> 00:03:52.620
onto q_1 and onto q_2,
and that will give me

00:03:52.620 --> 00:03:56.830
a q_3 that is orthogonal
to both q_1 and q_2.

00:03:56.830 --> 00:04:09.270
c minus c dot q_1 times q_1
minus c dot q_2 dot q_2.

00:04:09.270 --> 00:04:17.910
This will be c, [4, 5, 6]
minus, q_1 was [1 0 0],

00:04:17.910 --> 00:04:28.590
so 4, times [1, 0, 0],
minus-- q2-- 6 [0, 0, 1].

00:04:28.590 --> 00:04:34.930
So this vector
will be [0, 5,  0].

00:04:34.930 --> 00:04:39.990
And once again, this one is
orthogonal to q_1 and q_2,

00:04:39.990 --> 00:04:42.270
but it is not norm 1 yet.

00:04:42.270 --> 00:04:47.350
So q_3-- I'll call
that one q_3 prime,

00:04:47.350 --> 00:04:51.630
and I'll set q_3 equal
to q_3 prime divided

00:04:51.630 --> 00:04:55.770
by its length which is 5.

00:04:55.770 --> 00:04:59.480
q_3 is the vector [0, 1, 0].

00:05:04.310 --> 00:05:05.720
One thing that I
want you to note

00:05:05.720 --> 00:05:10.410
is that my vectors q_1, q_2,
q_3 are very nice in this case.

00:05:10.410 --> 00:05:13.230
Usually, when you perform
Gram-Schmidt orthogonalization,

00:05:13.230 --> 00:05:14.930
you end up with
lots of square roots

00:05:14.930 --> 00:05:17.100
because you're
dividing by the length.

00:05:17.100 --> 00:05:22.190
In this case, we have
everything is integers,

00:05:22.190 --> 00:05:25.550
which is, well, very lucky.

00:05:25.550 --> 00:05:28.440
Next part of the problem
is we want to write the QR

00:05:28.440 --> 00:05:37.210
decomposition of the matrix A. A
equals Q*R. Well, the matrix A,

00:05:37.210 --> 00:05:38.660
you already know what it is.

00:05:38.660 --> 00:05:50.450
It is the matrix
[1, 2, 4; 0, 0,  5; 0, 3, 6].

00:05:50.450 --> 00:05:54.620
And Q you want to be
an orthogonal matrix.

00:05:54.620 --> 00:05:56.680
Like I said before,
an orthogonal matrix

00:05:56.680 --> 00:06:00.130
has orthonormal vectors
for its columns.

00:06:00.130 --> 00:06:02.590
And we already
have such a matrix.

00:06:02.590 --> 00:06:06.160
It's the matrix that has q_1,
q_2, and q_3 as its column

00:06:06.160 --> 00:06:07.640
vectors.

00:06:07.640 --> 00:06:15.250
1, 0, 0; 0, 0, 1; and 0, 1, 0.

00:06:15.250 --> 00:06:18.400
Now, we need an upper
triangular matrix

00:06:18.400 --> 00:06:21.450
that makes this equality true.

00:06:21.450 --> 00:06:23.120
Take a moment to
look at your matrix

00:06:23.120 --> 00:06:27.020
Q. It is simply a
permutation matrix,

00:06:27.020 --> 00:06:29.290
so it's very easy to come
up with a matrix that

00:06:29.290 --> 00:06:30.850
should fit here.

00:06:30.850 --> 00:06:34.220
What this permutation
matrix does is it

00:06:34.220 --> 00:06:39.310
exchanges rows two and three
from my matrix R to give you A.

00:06:39.310 --> 00:06:40.970
So you know what R must be.

00:06:40.970 --> 00:06:47.910
It must be 1, 2, 4; 0, 3, 6--
that's the third row of A--

00:06:47.910 --> 00:06:52.420
and then 0, 0, 5, which
is the second row of A.

00:06:52.420 --> 00:06:56.420
And indeed, R is
upper triangular.

00:06:56.420 --> 00:07:00.810
This is your QR decomposition of
the matrix A. Q is orthogonal,

00:07:00.810 --> 00:07:04.059
R is upper triangular.

00:07:04.059 --> 00:07:06.100
But let's see where these
numbers in the matrix R

00:07:06.100 --> 00:07:08.360
are coming from.

00:07:08.360 --> 00:07:15.990
Let me label these columns for
you, a, b, c and q_1, q_2, q_3.

00:07:15.990 --> 00:07:18.385
And then I have my matrix R.

00:07:18.385 --> 00:07:21.900
You know from the way that
matrix multiplication works

00:07:21.900 --> 00:07:27.800
that A is going
to be this matrix

00:07:27.800 --> 00:07:30.906
Q times the first
column of R. So you

00:07:30.906 --> 00:07:34.370
can regard that as these
numbers in the first column of R

00:07:34.370 --> 00:07:37.400
are giving you the linear
coefficients in which you

00:07:37.400 --> 00:07:40.730
need to take these
vectors to add up

00:07:40.730 --> 00:07:43.130
to A. Let me write that down.

00:07:43.130 --> 00:07:50.550
A is going to be 1 times q_1
plus 0 times q_2 plus 0 times

00:07:50.550 --> 00:07:51.980
q_3.

00:07:51.980 --> 00:07:53.380
Let's do it for b.

00:07:53.380 --> 00:07:57.740
The second column of this matrix
will be Q times this column.

00:07:57.740 --> 00:08:08.140
So it will be 2 times q_1 plus
3 times q_2 plus 0 times q_3.

00:08:08.140 --> 00:08:14.500
And finally, for c I will have
c is equal to this matrix times

00:08:14.500 --> 00:08:23.910
this vector, 4*q_1
plus 6*q_2 plus 5*q_3.

00:08:23.910 --> 00:08:26.800
Now let's go back and see where
these numbers are showing up.

00:08:30.100 --> 00:08:34.320
I wanted to have A
equals 1 times q_1.

00:08:34.320 --> 00:08:35.340
Well that's very easy.

00:08:35.340 --> 00:08:39.039
It comes from here,
a equals 1 times q_1.

00:08:42.830 --> 00:08:44.320
Let's try the second one.

00:08:44.320 --> 00:08:49.640
b equals 2*q_1 plus 3*q_2.

00:08:49.640 --> 00:08:52.650
Well q_2, let's see.

00:08:52.650 --> 00:08:54.960
q_2 prime is equal
to 3 times q_2,

00:08:54.960 --> 00:08:57.430
so let me write
this here to help.

00:08:57.430 --> 00:08:59.900
3*q_2.

00:08:59.900 --> 00:09:05.460
Now let me remind you that
b dot q_1 was equal to 2.

00:09:05.460 --> 00:09:06.600
Now look at this equation.

00:09:06.600 --> 00:09:12.690
You we have b is equal
to 2*q_1 plus 3*q_2,

00:09:12.690 --> 00:09:14.570
which is what we wanted.

00:09:14.570 --> 00:09:15.680
Let's check q_3.

00:09:18.720 --> 00:09:25.450
q_3 prime is equal to 5*q_3 so
let me write that here, 5*q_3.

00:09:25.450 --> 00:09:32.545
And now I have c is equal
to-- this number was 4,

00:09:32.545 --> 00:09:40.320
and this number was 6-- c is
equal to 4*q_1 plus 6*q_2 plus

00:09:40.320 --> 00:09:45.250
5*q_3, which indeed,
is what we wanted.

00:09:45.250 --> 00:09:47.280
So this is where these
numbers from the matrix R

00:09:47.280 --> 00:09:49.780
are coming from.

00:09:49.780 --> 00:09:52.380
And that finishes this problem.

00:09:52.380 --> 00:09:56.920
I hope you have a better grasp
of the QR decomposition now.

00:09:56.920 --> 00:09:57.420
Bye.

00:09:57.420 --> 00:09:59.414
See you next time.