HomeVideos

Visualize Different Matrices part1 | SEE Matrix, Chapter 1

Now Playing

Visualize Different Matrices part1 | SEE Matrix, Chapter 1

Transcript

304 segments

0:02

What exactly is a matrix?

0:05

Some say it's just a box of numbers, a

0:08

collection of vectors,

0:10

mathematical object, linear

0:12

transformation,

0:14

a function.

0:16

Perhaps, no one knows the answer.

0:19

But, we do know how to multiply a matrix

0:23

and a vector. For example, multiplying

0:25

this matrix with vector 1 2, what we get

0:29

is a vector 5 2.

0:32

And it turns out there's actually a

0:34

natural way to visualize this.

0:37

Firstly, we represent a vector as a

0:40

physical arrow sitting in the

0:41

two-dimensional space. And as a vector

0:44

gets multiplied by the matrix, the tip

0:46

of the arrow moves from the coordinate 1

0:49

2 to the coordinate 5 2.

0:53

So, that was a visualization for one

0:55

vector. How about we try to do this with

0:57

more vectors?

1:00

Once again, we can represent the vectors

1:02

as six physical arrows and observe their

1:05

movements as they get multiplied by the

1:07

matrix.

1:10

But, the original goal was to visualize

1:12

a matrix, so we should think what

1:14

happens to all vectors as each every one

1:17

of them gets multiplied.

1:21

Our computer tries its best to add many,

1:24

many arrows on the screen to create the

1:27

illusion of every vector

1:29

and the multiplication.

1:34

Well, that was a visualization of matrix

1:37

I asked for, but it's just a horrible

1:39

visualization. There are too many

1:41

vectors moving at the same time, too

1:42

much information for my tiny brain to

1:44

process, and we need to improve this.

1:48

So, to improve the quality, we're going

1:50

to apply two tricks. Firstly, let's

1:53

squint our eyes and focus on a smaller

1:56

region of vectors.

2:01

The second trick we do is to represent a

2:02

vector as a dot instead. Consider our

2:05

old friend vector 1 2. Now it's a dot

2:08

sitting over there. The matrix

2:09

multiplication would move this dot

2:12

to the coordinate 5 2.

2:17

And we can replace all the vectors

2:19

within our focus region with many, many

2:22

dots instead.

2:25

And then we observe the matrix

2:27

multiplication.

2:29

This is much better.

2:33

We have essentially built an engine

2:35

which creates a visualization for any 2

2:37

by 2 matrix.

2:39

The very natural thing to do next is to

2:41

just plug in a bunch of different

2:42

matrices in there and watch the

2:44

transformation of the dots on the

2:46

screen.

2:47

And very soon interesting patterns start

2:50

to emerge.

2:54

The goal for the next part of the video

2:57

is to illustrate the famous matrices

2:59

whose transformation are so visually

3:01

geometrical that we can even use English

3:04

to describe them.

3:07

And welcome to the matrix got talent

3:09

show. The first matrix on stage is the

3:12

identity matrix, which is a square

3:15

matrix that has a ones on the diagonal

3:18

and zeros everywhere else.

3:25

So, tell me about your transformation on

3:27

vectors.

3:29

Wait.

3:30

There There was no transformation?

3:32

Nothing at all? Huh.

3:35

That's kind of boring start.

3:37

But this actually makes sense. If you

3:40

multiply any vector with the identity

3:42

matrix, you get the same vector back.

3:44

So, there will be no movements of the

3:46

dots at all.

3:49

If we try to label every matrix with a

3:52

tag. What would be the tag for identity

3:54

matrix? Well, I say it would be no

3:57

transformation or does nothing, boring.

4:03

The next one is a scalar matrix. The

4:05

numbers on the diagonal line are the

4:07

same and zeros everywhere else.

4:10

So, it's not saying that there is only

4:12

one matrix that is the scalar matrix,

4:14

but any matrix that satisfies this form

4:17

is regarded as a scalar matrix.

4:20

Let's try this matrix here.

4:27

Wow. That was pretty cool.

4:29

Our rectangle got bigger.

4:31

And the notable thing is there wasn't

4:33

any sense of distortion, but rather like

4:36

every single dot moved uniformly.

4:39

Let's try one more.

4:44

Oh.

4:45

This one seems to be moving our dots

4:47

even more aggressively outwards.

4:49

So, zooming now.

4:51

And we still see the contour of the

4:52

rectangle and the ratio of width versus

4:55

height still remains the same. How about

4:58

when the numbers on the diagonal line is

5:00

less than one?

5:04

We see our dots moving inwards and the

5:07

border of the dots still forms a

5:08

rectangle.

5:11

It seems this kind of matrix has ability

5:13

to scale things uniformly.

5:15

For K greater than one, the matrix is

5:17

stretching all the vectors outwards. For

5:19

K less than one, the vectors are

5:21

stretched inwards. For K equal to one,

5:24

nothing moves because this is the

5:26

identity matrix.

5:29

What interesting thing can we do about

5:31

this?

5:33

If you really ponder upon idea of a

5:35

shape on 2D space,

5:37

then it's really just an infinite number

5:39

of dots sitting closely together.

5:41

And guess what? If matrix can move dots,

5:44

then matrix can transform shape.

5:47

And here, we apply the scalar matrix to

5:49

the triangle.

6:01

To take this idea one step further, a

6:04

picture is basically a bunch of pixels

6:06

or colored dots.

6:09

Then, we can transform pictures well.

6:12

Let's apply a scalar matrix to the Mario

6:14

here.

6:23

Oh, question.

6:24

Three dimension?

6:25

That is a good question.

6:28

A vector in R3 can be represented as

6:30

three-dimensional arrow or likewise

6:33

three-dimensional dot.

6:37

And if you ponder on this again, a

6:39

three-dimensional object is just like an

6:41

infinite number of dots sitting very

6:43

close together, which means we can use a

6:46

3 by 3 scalar matrix to transform

6:49

three-dimensional objects.

7:02

The next one is not famous enough to

7:04

have its own name.

7:05

But, the idea is you take the identity

7:07

matrix and modify exactly one number on

7:10

the diagonal line.

7:12

And let's call this the off one matrix.

7:19

Dots were moving along the Y axis, while

7:22

the X coordinate is unchanged. How about

7:24

a different one?

7:28

Dots are moving along the X axis, while

7:30

the Y coordinate is unchanged.

7:35

If we keep playing with the visual

7:37

engine we have, the pattern starts to

7:39

become clear.

7:40

For whichever entry on the diagonal line

7:42

that is not one, but K, it scales

7:45

everything along the axis by a factor of

7:47

K. While the other axis is not changed.

7:49

And this really has to do with our way

7:52

of representing vector as dot.

7:54

We let the first entry be X and the

7:56

second entry be Y.

8:07

of one matrix behaves very predictably

8:09

in three dimension. It's a scaling of

8:12

just the X axis,

8:16

just the Y axis,

8:19

or

8:20

just the Z axis.

8:35

Hey, you're back. Do you want to get

8:37

scale along the Y axis?

8:39

I've got a question.

8:41

Negative entries.

8:43

We did forget to talk about that.

8:45

Let's take a look at the simplest case

8:47

first. When you change one or more

8:49

number on the diagonal to be negative

8:51

one for the identity matrix,

9:00

seems there's a reflection by the Y axis

9:04

and nothing is scale out of proportion.

9:07

This one?

9:13

A reflection by the X axis.

9:17

So, why is this matrix producing some

9:20

form of reflection behavior? What's the

9:22

intuition here? Let's use the Y

9:24

reflection matrix as an example.

9:27

If we consider the matrix vector

9:28

multiplication, we first know that the

9:30

magnitude of vector did not change. So,

9:33

nothing is scale,

9:35

but the sign of the first entry is

9:36

flipped.

9:38

Visually, this means arrows from the

9:40

first quadrant move to the second

9:42

quadrant.

9:45

And dots from the third quadrant move to

9:48

the fourth quadrant.

9:52

And the exact logic of reasoning also

9:54

holds for the X reflection matrix, in

9:56

which the sign of the Y coordinate is

9:58

being flipped.

10:02

But what about when both entries are

10:04

negative? Is it a reflection by the X

10:07

and Y axis?

10:09

And you will be exactly right. The sign

10:11

of both the X and the Y coordinates are

10:13

flipped. Dots from every quadrant would

10:16

be going to the opposite quadrant.

10:18

And this translates to a reflection

10:20

around the origin.

10:24

And as always, it's cool to let matrix

10:26

transform images.

10:32

In three dimension, there is one more

10:34

entry that can be flipped, the Z

10:36

coordinate.

10:37

We will not go into the details of

10:39

different cases here, but the overall

10:41

spirit of reflections still holds.

10:55

Next, enters the diagonal matrix, which

10:58

is another square matrix that can have

11:00

any numbers on the diagonal line, but

11:03

zeros everywhere else.

11:05

And the understanding of this matrix

11:06

actually ties closely to the reflection

11:08

matrix and off one matrix we visualized

11:11

earlier.

11:12

Before me presenting you with a

11:14

visualization, we can even try to guess

11:16

what it might look like. But firstly,

11:18

allow me to say something very

11:20

important.

11:21

Matrix to matrix multiplication is

11:23

really not multiplication at all. When

11:26

someone say, "I want to multiply matrix

11:28

B and A to get matrix C."

11:31

Okay. What that person really saying is

11:33

I just want one matrix, which is matrix

11:36

C, which can compose the overall

11:38

transformation if first apply A and then

11:41

B, but in just one transformation.

11:45

For example, we can multiply or compose

11:49

these two off-one matrices on the left

11:51

to get a diagonal matrix on the right.

11:53

And we already know exactly what kind of

11:55

visual transformation those two matrices

11:57

would have since we have labeled them

11:59

earlier.

12:00

So, what do you think the diagonal

12:02

matrix would do?

12:11

Exactly like what you guessed, the

12:13

vectors all move along the Y axis by a

12:15

factor of two and also along the X axis

12:18

by a factor of three.

12:20

How about this diagonal matrix here? You

12:23

can pause the video and show it's just a

12:25

composition of the three matrices on the

12:27

right, which we know a lot about

12:29

already.

12:30

And therefore, we can conclude that the

12:32

diagonal matrix must be the overall

12:34

transformation of sequentially applying

12:36

the three matrices on the right.

12:39

Let's use this image as an example.

12:42

Firstly, we scale the X axis by 2.5.

12:46

Secondly, the Y axis by 0.6.

12:49

And thirdly, a reflection.

12:55

And this diagonal matrix, which is a

12:57

composition of the three matrices on the

12:59

right, will just encapsulate the three

13:01

transformations but in one go.

13:09

Whenever there's a diagonal matrix, you

13:11

can always decompose it into a sequence

13:14

of the off-one matrix. In case you have

13:16

negative numbers on the diagonal, you

13:18

can also explicitly factor it out to

13:21

include a reflection matrix at the end.

13:25

For this 3 by 3 diagonal matrix, we know

13:27

it would just be a composition of three

13:29

different offline matrices

13:31

and we can directly read the numbers

13:33

from its diagonal line. So, it will

13:35

scale the x-axis by three, y-axis by

13:38

two, and z by 0.5.

14:02

The next one is a zero matrix, which is

14:05

square and everything is zero.

14:09

So, regardless of which vector you

14:11

multiply with a zero matrix, it becomes

14:14

the zero vector.

14:17

And visually, it would mean no matter

14:20

where the vector starts,

14:21

it would move towards and end up in the

14:23

origin.

Interactive Summary

This video explores how to visualize matrices through linear transformations by representing vectors as points in space. It breaks down various types of matrices, including the identity, scalar, off-one, diagonal, and zero matrices, showing how each one uniquely affects coordinates and geometric shapes, effectively serving as an engine for composing complex transformations.

Suggested questions

3 ready-made prompts