Linear transformations and matrices | Essence of linear algebra, chapter 3

Unfortunately, no one can be told, what the
Matrix is. You have to see it for yourself.
– Morpheus Surprisingly apt words on the importance of
understanding matrix operations visually Hey everyone! If I had to choose just one topic that makes all of the others in linear algebra start to click and which too often goes unlearned the first
time a student takes linear algebra, it would be this one:
the idea of a linear transformation and its relation to matrices. For this video, I’m just going to focus on
what these transformations look like in the case of two dimensions and how they relate to the idea of matrix-vector
multiplication. In particular, I want to show you a way to
think about matrix-vector multiplication that doesn’t rely on memorization. To start, let’s just parse this term “linear
transformation”. “Transformation” is essentially a fancy
word for “function”. It’s something that takes in inputs and spits
out an output for each one. Specifically in the context of linear algebra,
we like to think about transformations that take in some vector and spit out another vector. So why use the word “transformation” instead
of “function” if they mean the same thing? Well, it’s to be suggestive of a certain way to
visualize this input-output relation. You see, a great way to understand functions
of vectors is to use movement. If a transformation takes some input vector
to some output vector, we imagine that input vector moving over to
the output vector. Then to understand the transformation as a
whole, we might imagine watching every possible input
vector move over to its corresponding output vector. It gets really crowded to think about all
of the vectors all at once, each one is an arrow, So, as I mentioned last video, a nice trick
is to conceptualize each vector, not as an arrow, but as a single point: the point where its
tip sits. That way to think about a transformation taking
every possible input vector to some output vector, we watch every point in space moving to some
other point. In the case of transformations in two dimensions, to get a better feel for the whole “shape”
of the transformation, I like to do this with all of the points on
an infinite grid. I also sometimes like to keep a copy of the
grid in the background, just to help keep track of where everything
ends up relative to where it starts. The effect for various transformations, moving
around all of the points in space, is, you’ve got to admit, beautiful. It gives the feeling of squishing and morphing
space itself. As you can imagine, though arbitrary transformations
can look pretty complicated, but luckily linear algebra limits itself to
a special type of transformation, ones that are easier to understand, called
“linear” transformations. Visually speaking, a transformation is linear
if it has two properties: all lines must remain lines, without getting
curved, and the origin must remain fixed in place. For example, this right here would not be
a linear transformation since the lines get all curvy and this one right here, although it keeps
the line straight, is not a linear transformation because it
moves the origin. This one here fixes the origin and it might
look like it keeps line straight, but that’s just because I’m only showing the
horizontal and vertical grid lines, when you see what it does to a diagonal line,
it becomes clear that it’s not at all linear since it turns that line all curvy. In general, you should think of linear transformations
as keeping grid lines parallel and evenly spaced. Some linear transformations are simple to
think about, like rotations about the origin. Others are a little trickier to describe with
words. So how do you think you could describe these
transformations numerically? If you were, say, programming some animations
to make a video teaching the topic what formula do you give the computer so that
if you give it the coordinates of a vector, it can give you the coordinates of where that
vector lands? It turns out that you only need to record where the two basis vectors, i-hat and j-hat, each land. and everything else will follow from that. For example, consider the vector v with coordinates
(-1,2), meaning that it equals -1 times i-hat + 2
times j-hat. If we play some transformation and follow
where all three of these vectors go the property that grid lines remain parallel
and evenly spaced has a really important consequence: the place where v lands will be -1 times the
vector where i-hat landed plus 2 times the vector where j-hat landed. In other words, it started off as a certain
linear combination of i-hat and j-hat and it ends up is that same linear combination
of where those two vectors landed. This means you can deduce where v must go
based only on where i-hat and j-hat each land. This is why I like keeping a copy of the original
grid in the background; for the transformation shown here we can read
off that i-hat lands on the coordinates (1,-2). and j-hat lands on the x-axis over at the
coordinates (3, 0). This means that the vector represented by
(-1) i-hat + 2 times j-hat ends up at (-1) times the vector (1, -2) +
2 times the vector (3, 0). Adding that all together, you can deduce that
it has to land on the vector (5, 2). This is a good point to pause and ponder,
because it’s pretty important. Now, given that I’m actually showing you the full transformation, you could have just looked to see the v has
the coordinates (5, 2), but the cool part here is that this gives
us a technique to deduce where any vectors land, so long as we have a record of where i-hat
and j-hat each land, without needing to watch the transformation
itself. Write the vector with more general coordinates
x and y, and it will land on x times the vector where
i-hat lands (1, -2), plus y times the vector where j-hat lands
(3, 0). Carrying out that sum, you see that it lands
at (1x+3y, -2x+0y). I give you any vector, and you can tell me
where that vector lands using this formula what all of this is saying is that a two dimensional
linear transformation is completely described by just four numbers: the two coordinates for where i-hat lands and the two coordinates for where j-hat lands. Isn’t that cool? it’s common to package these coordinates into a two-by-two grid of numbers, called a two-by-two matrix, where you can interpret the columns as the two special vectors where i-hat and j-hat each land. If you’re given a two-by-two matrix describing
a linear transformation and some specific vector and you want to know where that linear transformation
takes that vector, you can take the coordinates of the vector multiply them by the corresponding columns
of the matrix, then add together what you get. This corresponds with the idea of adding the
scaled versions of our new basis vectors. Let’s see what this looks like in the most
general case where your matrix has entries a, b, c, d and remember, this matrix is just a way of
packaging the information needed to describe a linear transformation. Always remember to interpret that first column,
(a, c), as the place where the first basis vector
lands and that second column, (b, d), is the place
where the second basis vector lands. When we apply this transformation to some
vector (x, y), what do you get? Well, it’ll be x times (a, c) plus y times (b, d). Putting this together, you get a vector (ax+by,
cx+dy). You can even define this as matrix-vector
multiplication when you put the matrix on the left of the
vector like it’s a function. Then, you could make high schoolers memorize
this, without showing them the crucial part that
makes it feel intuitive. But, isn’t it more fun to think about these columns as the transformed versions of your basis
vectors and to think about the results as the appropriate linear combination of those
vectors? Let’s practice describing a few linear transformations
with matrices. For example, if we rotate all of space 90° counterclockwise then i-hat lands on the coordinates (0, 1) and j-hat lands on the coordinates (-1, 0). So the matrix we end up with has columns
(0, 1), (-1, 0). To figure out what happens to any vector after
90° rotation, you could just multiply its coordinates by
this matrix. Here’s a fun transformation with a special
name, called a “shear”. In it, i-hat remains fixed so the first column of the matrix is (1, 0), but j-hat moves over to the coordinates (1,1) which become the second column of the matrix. And, at the risk of being redundant here, figuring out how a shear transforms a given
vector comes down to multiplying this matrix by that
vector. Let’s say we want to go the other way around, starting with the matrix, say with columns
(1, 2) and (3, 1), and we want to deduce what its transformation
looks like. Pause and take a moment to see if you can
imagine it. One way to do this is to first move i-hat to (1, 2). Then, move j-hat to (3, 1). Always moving the rest of space in such a
way that keeps grid lines parallel and evenly
spaced. If the vectors that i-hat and j-hat land on
are linearly dependent which, if you recall from last video, means that one is a scaled version of the
other. It means that the linear transformation squishes
all of 2D space on to the line where those two vectors sit, also known as the one-dimensional span of those two linearly dependent vectors. To sum up, linear transformations are a way to move around space such that the grid lines remain parallel and
evenly spaced and such that the origin remains fixed. Delightfully, these transformations can be described using
only a handful of numbers. The coordinates of where each basis vector
lands. Matrices give us a language to describe these
transformations where the columns represent those coordinates and matrix-vector multiplication is just a
way to compute what that transformation does to a given vector. The important take-away here is that, every time you see a matrix, you can interpret it as a certain transformation
of space. Once you really digest this idea, you’re in a great position to understand linear
algebra deeply. Almost all of the topics coming up, from matrix multiplication to determinant, change of basis, eigenvalues, … all of these will become easier to understand once you start thinking about matrices as
transformations of space. Most immediately, in the next video I’ll be talking about multiplying two matrices together. See you then!


  1. Incredible. I am a junior high school student and you've given me the ability to invent the 2D Rotation matrix (which already has existed for a while now). Thank you giving me the foundation of basis vectors.

  2. I got the real awesome of matrix… Even completing the degree I felt intuitively I've missed something.. Thank you dude so much ❤😍❤

  3. 4:20 Can someone explain exactly what he did here? I don't follow at all. was this transformation just some arbritary one, or did it have a connection with the matrix [-1, 2]. I thought i-hat and j-hat always only had an x-component and y-component respectively that's equal to some number, and then the other component is just 0, so they're always parallel to the x- or y-axis, but now they're not? How come i-hat suddenly has a y-component and j-hat has an x-component? where did they come from? What's going on here?

  4. this has completely blown my mind, I am overwhelmed ahahh, thank you so much for such a brilliant and deep explanation, you've cleared up so many questions I didnt even know I had.

    I'm just wondering what is the geometrical (space) interpretation of non square matrices?

  5. Grant, your videos are a delight to watch and are wonderfully insightful into the world of mathematics that has too often been ruined by poor, unoriginal, and disinterested teachers. I am a sophomore in college studying applied math and your videos are an absolute gift. Please continue what you're doing. I can't thank you enough.

  6. Imo this is the most important video of the whole series. Once you realise what a matrix is, linear algebra becomes a piece of cake for breakfast

  7. When he told me to think about it, I thought about it for a while, and determined the following! A linear transformation will flip the basis vectors/space (such that i hat will now be "to the left of" j hat) iff the 2nd coordinate of i hat and the 1st one of j hat (that left-right bottom-top diagonal) are both strictly greater than at least one of the other 2 remaining coordinates (the right-left-top-bottom diagonal). You can even define a flip that way in case you get confused by the visual. Try it out with all the examples, and use it to explain to yourself why the shear example didn't result in a flip: it's because the 2nd coordinate of i hat ofc can't overtake the 1st one, since neither change and it was 0 (which is < 1) to begin with, and then it can't overtake the 2nd coordinate of j hat either so long as j hat stays within the positive (1st) quadrant, since that coordinate will just keep growing; and even if it goes to 0, it won't be strictly less than i-hat's 2nd coordinate until it goes into the 4th quadrant, at which point the basis vectors will flip in this example as long as the 1st coordinate of j hat stays positive (specifically, in this example, stays greater than the 2nd). Anyway, it's easier to just take the rule and apply it to the visuals yourself! And thinking about things yourself in this way instead of trying to interpret a wall of text is a much better way of internalizing these things. Anyway, this video series is the greatest thing ever!

  8. when Grant said "Then, you can make high-schoolers memorize it, and hide the most crucial part that makes it intuitive." i felt that

  9. Dude, gotta say Im doin some transformations in quantum chemistry and you are just making everything beautiful! We can feel u are doing this because u love it. And we love you for that!

  10. 8:15

    should the vectors rotate independently of plane? what dictates coordinates for rotated i-hat, j-hat unit vectors?

  11. 想要用 3Blue1Brown 風格動畫來了解線性變換跟神經網路之間關係的人可以參考:

  12. I know how to solve linear equation systems using matrices, but I never knew what that actually hast to do with vectors and coordinate systems. Now i just realized that solving a linear equation system is basically just searching the inital vector, given the transformation of space and where the inital vector landed after the transformation. That really revolutionised my view on mathematic.

  13. So rather than bang our heads on our desks for a couple of months in high school because they insisted on teaching us matrices purely from a mathematical perspective, our teachers could have shown us the beauty of using matrices in the first place, thereby having given us a conceptual basis (and interest) in working with the figures in the matrices. It all seemed so arcane and arbitrary back then; but here it all seems so obvious. We could have learned mathematics so much better and faster with more visuals, more concrete examples. I took Physics 1 and Calculus A and B simultaneously and it made all the difference in the world for both classes. I kept getting hung up on the BS way we were introduced to the Fundamental Theorem of Calculus, because it was obviously not a real proof, but that's another issue. XD

  14. Hi and thx for the brilliant videos. Should we understand that any linear transformation in the 2D plane can be described as composed of shears and rotations about the origin only ?

  15. Very nice and helpful u make this very interesting which gives me a imagination of mathematical problem i use this to solve maths problems

  16. I am halfway through the semester in Linear Algebra, and I have been spending hours upon hours studying linear algebra out of my text book. I felt like I must be studying the wrong things, because I got my first test back and I failed (which has never happened to me in a math class ever)… After watching a few of his videos, I totally get why I failed the test, I couldn’t conceptualize what these numbers were telling me at all even though I was doing computing the numbers correctly on the homework.
    I’m at university and my teacher has failed to ever really present a graph in lecture. I don’t understand why, this is such an important part to understanding this shit…
    Especially linear transformations!! This made it seem so much easier to understand! Even my textbook said “linear transformations are hard for most students to conceptualize”. Well thanks!! I bought a few hundred dollar book and this free YouTube video cleared my confusion!

    Thank you soooo much for what you do!

  17. this was so beautiful. I always struggle to visualise these things and now I know why. Im never given a chance to fully appreciate the beauty of these concepts

  18. Is it my video game mind, or is that how moving a character in a 3d game is done.
    It looks like you are looking at the plane from a different location.

  19. 3Blue1Brown: "you can make high schoolers memorize this…"
    me, studying for my master degree in engineering: *looks away in shame*

  20. I can not express my gratitude for your explanation! I have never seen a person with such a fine sense for visualizing math and teaching it to others.

  21. After watching this great video which makes me angry at my math teacher, a few questions come up: if we can represent the transformation of a plane using a square matrix of size 2, what would a matrix of unequal sides (2 by 3, 4 by 1, 5 by 3, …) represent in terms of the transformation of a plane? Would adding more columns mean adding more dimensions? What would adding more rows mean?

  22. When I learn new mathematical concepts I do try to visualize them in my head, but that can get really difficult when you have not already seen the visualization beforehand. To see these visualizations empowers my own visualizations. Thank you!

  23. I've never understood linear transformations like this
    the clouds parted and the entire world is now clear and beautiful

  24. Probably stupid question. But: on 2:01 he is transforming space, however before he was transforming vectors on this space? How this happened? I didn’t understand the explanation “for the convenience of it”, can someone help?)

  25. why there are dislikes on this video? In the scale of the American talents show this channel deserves a golden button!

  26. 4:18 I don't understand how the transformation works. Did I miss the formula? I mean, sure, you can understand where v ends up based on i and j, but what actually happened there? Nothing more detailed as "some transformation"?

  27. SIR! You have just changed my life! I am studying computer science and have always struggled a bit with linear algebra because it felt too theoretical to me and I was never able to grasp the concept logically. It was all memorization.

    Now, finally, for the first time I truly understand what it all mean! Bless your heart for taking the time to safe this poor confused student and making them love math again!

  28. Thank you for this explanation. I was one of those poor saps who got through linear algebra by just memorizing the formulas. This video makes understanding linear transformations easier to grasp especially with all of these visuals. I will try applying this mentality while I implement Principal Component Analysis for my machine learning project. I especially liked the comment where you said that it is more fun to think of the transformation matrix columns as the transformed basis vectors and the output of the transformation as linear combinations of those transformed basis vectors.

  29. You are awesome, im a mechanical engineering student in italy, my course is only based on theory and these animations help me to visualize and understand in dept the basic concepts of linear algebra and calculus

  30. This is really an amazing way to give intuition what linear transformation look like … how easily and beautifully u explained … thank you so much for making this vedio!!

  31. … because you didn't come here to make the choice, you've already made it. you're here to try to understand why you made it
    – the oracle

  32. I always hated matrices, i thought it was the devil's concept of representing numbers in square blocks.
    But now, seeing as to how beautiful they are, i realized that it's not so bad after all, and i can actually understand all of this.
    We need some serious questioning about our current method of education and teaching kids about Mathematics and Sciences.
    I mean come on, all it takes is one good teacher to completely change your mind and concept about something,
    and most teachers i've had were all horrible.
    I believe the future of education should be the internet, where the passionate few who love to teach are making creative online visual explanations of complex topics, and millions of people all over the world can tune in at any time and learn at their own pace.

  33. You should continue these videos all the way into Hilbert Space as it relates to Quantum Mechanics' formalism. Please consider. You'd be doing humanity a great service (not that you are not already doing that). Thank you.

  34. I am so confused at around 5:40 because of the symbology of x and y. Are we changing the fundamental underlying coordinate system by applying a linear transformation to i-hat and j-hat? The only reason I understand vector addition and scaling is because the original basis vectors are (1,0) and (0,1) and are conceptually orthoganal. When you apply a linear transformation to the basis vectors, now all of a sudden you have basis vectors that contain both x and y components. This is where I'm getting really confused.

Leave a Reply

Your email address will not be published. Required fields are marked *