HomeVideos

Visualize Different Matrices part2 | SEE Matrix, Chapter 1

Now Playing

Visualize Different Matrices part2 | SEE Matrix, Chapter 1

Transcript

297 segments

0:02

Continued from part one, we have the

0:04

shear matrix,

0:05

which is a matrix that produces a shear

0:07

transformation.

0:09

But, what is a shear transformation?

0:11

Turns out, it's not the easiest to

0:12

describe verbally, so you have to see it

0:15

for yourself.

0:16

The matrix 1101 is a shear matrix.

0:19

And this is what it does.

0:22

What we see is all the vectors above the

0:24

origin were moving towards the right.

0:27

And all the vectors below the origin

0:28

were moving towards the left. And the

0:30

way they move was actually parallel to

0:32

the x-axis.

0:34

So, overall, the rectangle was slanted

0:36

into parallelogram.

0:38

In 2D, there are four directions we can

0:40

apply a shear transformation.

0:42

Two different ways we can shear in

0:44

parallel to the x-axis,

0:46

and two ways in the y-axis.

0:51

It's also notable to mention a property

0:53

shear matrix have,

0:55

which the transformation preserve the

0:57

area of the object, despite changing the

0:59

shape.

1:00

Which forms a distinction with the

1:02

scalar matrix from earlier, which

1:04

preserve the shape, but changes the

1:06

area.

1:08

A three-dimensional shear is kind of

1:09

hard to describe. Personally, I'd like

1:12

to imagine there's a plane slicing

1:14

through the origin, and there's a

1:15

direction associated with this plane.

1:18

All vector are moving parallel to the

1:20

plane, while slanting towards the

1:22

direction.

1:25

Mhm, maybe that was not the best angle

1:27

to observe a shear transformation in 3D.

1:30

So, let me change the orientation of my

1:32

camera a little bit.

1:38

And for every combination of this plane

1:41

and direction,

1:42

it would have its own corresponding

1:44

shear transformation matrix.

1:57

Next, the orthogonal matrix. This one is

2:01

very important for chapter two and

2:03

three. It's a square matrix. Every

2:05

column vector is a unit vector, and

2:07

they're all orthogonal to each other.

2:10

Let's dissect the definition a little

2:12

bit.

2:12

So, what is a column vector? Basically,

2:15

if we vertically slice through the

2:17

matrix into columns, each column is a

2:20

vector. This is the reason why some

2:22

people say matrix is a collection of

2:24

vectors.

2:25

For a column vector to be a unit vector,

2:27

it means the magnitude is one. In our

2:29

case, the length of the arrow is one.

2:33

For a counterexample, the red arrows on

2:35

the screen are not unit vectors because

2:37

they're too long.

2:38

How about orthogonal?

2:40

So, the formal definition for orthogonal

2:43

is when you take the dot product between

2:45

two vectors, the number you get is zero.

2:49

And when the dot product is zero,

2:50

visually, it actually translates to the

2:53

two vectors being perpendicular to each

2:55

other.

2:58

This one is orthogonal matrix. We can

3:01

quickly verify the two column vectors

3:03

are unit and orthogonal.

3:06

What kind of transformation does it

3:07

have?

3:09

Wow.

3:11

A perfect rotation.

3:13

No scaling, no stretching, no shearing,

3:16

no reflection, but a pristine rotation.

3:20

You might say, "Come on, it's just

3:21

rotation. There's nothing special." But

3:24

it turns out finding the correct

3:25

direction to rotate is a gateway to

3:27

unlock all complexity with linear

3:30

transformation.

3:32

And it just happens the transformation

3:34

an orthogonal matrix produce is always a

3:37

rotation to some degree.

3:40

Inductively, a 3 by 3 orthogonal matrix

3:43

produces a rotation in three dimension,

3:46

and you can also rotate around the Z

3:48

axis now.

3:50

Actually, now's a really good time for

3:52

me to once again emphasize the idea that

3:55

matrix to matrix multiplication is

3:57

nothing but a composition of sequential

3:59

transformations.

4:01

Suppose I tell you orthogonal matrix A

4:04

produce a rotation around the x-axis by

4:07

60°.

4:08

And matrix B produce rotation around the

4:10

z-axis by 45°.

4:13

If I multiply those two matrices

4:15

together to get a matrix C,

4:17

what do you think C is going to do?

4:19

Well, let's see. Firstly, around X

4:24

and immediately around Z.

4:27

Since our matrix C is a composition of

4:30

the two, like you guessed it, it

4:32

encapsulates the two sequential

4:33

transformation but in just one rotation.

4:38

If you had noticed, I really tried to

4:41

punctuate the word sequential just now

4:43

because suppose we reverse the sequence

4:46

of the two rotation, namely Z first then

4:49

X.

4:50

We actually get something different than

4:51

the original composition.

4:53

Look at the position of the orange cube.

4:56

It's different.

4:57

This is actually an example to prove

5:00

matrix composition or matrix

5:03

multiplication is not commutative.

5:06

Which is saying matrix B times A is not

5:09

always equal to A times B.

5:20

Projection matrix.

5:22

Actually, before defining a projection

5:24

matrix, we need to understand what is a

5:26

subspace.

5:28

And just like all other definitions in

5:30

linear algebra, the definition for

5:32

subspace is pretty abstract. At the

5:34

moment, allow me to just provide you

5:36

with some examples. In 2D, a line

5:38

crossing through the origin is a

5:40

subspace of R2.

5:42

And this line is infinitely long.

5:45

In 3D, a plane crossing through the

5:48

origin is a subspace of R3.

5:51

I'm only showing you a small region of

5:53

the subspace here, but in reality, you

5:55

should imagine the subspace actually

5:57

spread to infinity.

5:59

For every subspace that exist, our

6:01

computer can calculate its corresponding

6:03

projection matrix, which would move

6:06

every vector outside the subspace onto

6:08

the subspace.

6:10

Let's take a look at the projection

6:11

matrix of this blue line here.

6:15

After the projection transformation,

6:17

every single dot has been compressed

6:19

onto the line.

6:21

How about the projection matrix of this

6:22

plane in 3D?

6:26

Yet another very similar vibe of

6:29

compression.

6:30

The reason why this is called projection

6:32

is because every vector always moved to

6:34

its closest point on the subspace.

6:38

For example, the vector 2 1 is currently

6:40

outside the blue line, and its closest

6:42

point would be here.

6:45

Applying the projection matrix would

6:47

move our vector 2 1 exactly over there.

6:52

And this is true for every single vector

6:54

outside the subspace.

6:55

As targets of projection matrix, they

6:58

all move towards their closest landing

7:00

spot.

7:03

And the fun fact, if some alien

7:06

civilization destroy our solar galaxy by

7:08

compressing us into a lower dimension,

7:11

this kind of transformation is similar

7:13

to a projection matrix.

7:30

The very last, but not the least, we

7:32

talk about the idea of inverse.

7:35

So far, we have seen a lot of different

7:36

matrices, and therefore many different

7:38

transformations. All those

7:40

transformations were moving our vectors

7:42

to new coordinates.

7:43

But what if I don't like a particular

7:45

transformation I had? Maybe it distorted

7:48

my image a little bit. I just want every

7:50

vector to go back where they originally

7:52

came from.

7:53

Is there one matrix that can untransform

7:56

the previous transformation for me?

7:58

Unfortunately, the short answer would be

8:00

no.

8:01

There isn't one matrix that does the

8:03

universal untransformation.

8:06

But for every matrix you're interested

8:08

in, our computer can calculate its

8:10

inverse, which is another matrix that is

8:13

capable of that particular

8:15

untransformation.

8:17

For example, the matrix which scale,

8:21

its inverse matrix unscale.

8:24

The matrix which reflects, its inverse

8:27

reflects back.

8:29

The matrix which rotates, its inverse

8:32

rotates back.

8:34

The matrix which shears,

8:36

its inverse unshears.

8:40

Or this matrix here, not sure what it

8:42

did, but its inverse matrix restores all

8:46

vector back to the original.

8:49

Notice, when you apply a matrix and then

8:52

you apply its inverse, it's like nothing

8:54

happened.

8:55

Just like the identity matrix. This is

8:58

the reason when you multiply a matrix

9:00

and its inverse, you always get the

9:02

identity matrix. When you compose the

9:04

two transformations together, you get a

9:06

transformation of no transformation.

9:09

However, some matrix cannot be inverted.

9:12

The zero matrix and projection matrix

9:14

from earlier cannot be untransformed.

9:17

It actually kind of makes sense visually

9:20

because a vector has been squashed from

9:22

a higher dimension down to a lower

9:23

dimension. There is a loss of

9:25

information.

9:34

After a long journey, we have went

9:36

through all those cool matrices. So,

9:39

what exactly is a matrix?

9:45

Does matrix intrinsically carry a visual

9:47

value?

9:48

Frankly, not at all.

9:50

Everything I did was only a very

9:52

artificial attempt to make sense of

9:54

matrices. You could say matrix

9:56

visualization is just another human

9:58

construct.

10:00

This moment, I'd like to reference a

10:02

quote from my favorite author. He was

10:04

asked whether his readers could

10:06

interpret the symbolism in his novel the

10:08

way he intended to convey. He answered,

10:11

"The books belong to the readers now,

10:13

which is a great thing because the books

10:15

are more powerful in the hands of my

10:16

readers."

10:18

I think this is true for matrix as well.

10:20

The interpretation of matrix belongs to

10:23

whoever is using it.

10:25

For a student who studies circuit,

10:27

matrix is just a tool to solve system of

10:29

equation. Personally, I still have some

10:32

PTSD from Gaussian elimination.

10:34

For probability student, matrix is a

10:37

best representation of a Markovian

10:39

process.

10:40

For data scientist, a matrix is just a

10:42

manifestation of a table, which

10:44

facilitates data analysis.

10:46

And for the deep learning folks, matrix

10:49

is just another Python function, which

10:51

takes a vector as input and returns a

10:53

vector as output.

10:56

And this list really goes on.

10:59

Perhaps,

11:00

there isn't the definition of matrix,

11:03

but only interpretations of matrices.

11:09

Then, what is so good of the visual

11:12

interpretation?

11:13

Firstly, I think it provides us with

11:15

intuition about matrix transformation on

11:17

vector.

11:18

And secondly, computer graphic is a

11:20

direct extension of this.

11:22

Thirdly, the one I like to elaborate on

11:24

personally, which is a very important

11:27

topic of matrix decomposition.

11:31

There are matrices out there whose

11:34

transformation so perplexing I cannot

11:36

easily articulate.

11:38

And there are matrices taking vector

11:40

from higher space to a lower space.

11:42

Is there a possibility we can re-express

11:44

those complicated transformation into a

11:47

sequence of simple transformation such

11:49

as rotation or scaling?

11:52

And that's where we're heading towards

11:54

next chapter two. What Professor Gilbert

11:56

Strang calls the king of all matrices.

11:59

And let you and me go spectate the

12:00

spectacular spectral decomposition.

12:03

See you there.

Interactive Summary

This video provides a conceptual and visual exploration of various types of linear transformation matrices, including shear, orthogonal, and projection matrices. It explains their geometric effects on vectors, emphasizes that matrix multiplication represents sequential composition—which is non-commutative—and introduces the concept of inverse matrices and their limitations regarding information loss. Finally, the video discusses how the interpretation of a matrix depends on the user's field, highlighting the value of geometric intuition as a precursor to understanding complex topics like matrix decomposition.

Suggested questions

4 ready-made prompts