If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Visualizing linear transformations

Multiplication as a transformation

The idea of a transformation can seem more complicated than it really is at first, so before diving into how 2, times, 2 matrices transform two-dimensional space, or how 3, times, 3 matrices transform three-dimensional space, let's go over how plain old numbers—a.k.a. 1, times, 1 matrices—can be considered transformations of one-dimensional space.
One-dimensional space is simply the number line.
Number Line
What happens when you multiply every number on the line by a particular value, like two? One way to visualize this is as follows:
Khan Academy video wrapper
We keep a copy of the original line for reference, then slide each number on the line to two times that number.
Similarly, multiplication by start fraction, 1, divided by, 2, end fraction could be visualized like this:
Khan Academy video wrapper
And, so the negative numbers don't feel neglected, here is multiplication by negative three:
Khan Academy video wrapper
For those of you fond of fancy terminology, these animated actions could be described as "linear transformations of one-dimensional space". The word transformation means the same thing as the word function: something which takes in a number and outputs a number, like f, left parenthesis, x, right parenthesis, equals, 2, x. However, while we typically visualize functions with graphs, people tend to use the word transformation to indicate that you should instead visualize some object moving, stretching, squishing, etc. So, the function f, left parenthesis, x, right parenthesis, equals, 2, x visualized as a transformation gives us the multiplication-by-two video above. It moves the point one on the number line to where two starts off, moves two to where four starts off, etc.
Before we move on to two-dimensional space, there's one simple but important fact we should keep in the back of our minds. Suppose you watch one of these transformations, knowing that it uses multiplication by some number but without knowing what that number is:
Khan Academy video wrapper
You can easily figure out which number is being multiplied into the line by following one. In this case, one lands where negative three started off, so you can tell that the animation represents multiplication by negative three.

What do linear transformations in two dimensions look like?

A two-dimensional linear transformation is a special kind of function which takes in a two-dimensional vector [xy]\left[ \begin{array}{c} x \\ y \end{array} \right] and outputs another two-dimensional vector. As before, our use of the word transformation indicates we should think about smooshing something around, which in this case is two-dimensional space.
Here are some examples:
Khan Academy video wrapper
For our purposes, what makes a transformation linear is the following geometric rule: The origin must remain fixed, and all lines must remain lines. So, all the transformations in the above animation are examples of linear transformations, but the following are not:
As in one dimension, what makes a two-dimensional transformation linear is that it satisfies two properties:
f, left parenthesis, start bold text, v, end bold text, plus, start bold text, w, end bold text, right parenthesis, equals, f, left parenthesis, start bold text, v, end bold text, right parenthesis, plus, f, left parenthesis, start bold text, w, end bold text, right parenthesis
f, left parenthesis, c, start bold text, v, end bold text, right parenthesis, equals, c, f, left parenthesis, start bold text, v, end bold text, right parenthesis
Only now, start bold text, v, end bold text and start bold text, w, end bold text are vectors instead of numbers. While in one-dimension, the first property was useless, it now plays a more important role because, in some sense, it determines how the two different dimensions play together during a transformation.
Khan Academy video wrapper
Khan Academy video wrapper

Following specific vectors during a transformation

Imagine you are watching one particular transformation, like this one:
Khan Academy video wrapper
How could you describe this transformation to a friend who is not watching the same animation? You can no longer describe it using a single number, the way we could just follow the number one in the one-dimensional case. To help keep track of everything, let's put a green arrow over the vector [10]\greenD{\left[ \begin{array}{c} 1 \\ 0 \end{array} \right]}, a red arrow over the vector [01]\redD{\left[\begin{array}{c} 0 \\ 1 \end{array} \right]}, and fix a copy of the grid in the background.
Khan Academy video wrapper
Now it's a lot easier to see where things land. Watch the animation again, and focus on the vector [11]\left[ \begin{array}{c} 1 \\ 1 \end{array} \right]. We can more easily follow it to see that it lands on the vector [42]\left[\begin{array}{c} 4 \\ -2 \end{array} \right].
We can represent this fact with the following notation:
[11][42]\left[ \begin{array}{c} 1 \\ 1 \end{array} \right] \rightarrow \left[ \begin{array}{c} 4 \\ -2 \end{array} \right]
Practice Problem: Where does the point at [10]\left[ \begin{array}{c} -1 \\ 0 \end{array}\right] end up after the plane has undergone the transformation in the above video?
Choose 1 answer:
Choose 1 answer:

Practice Problem Even though it has gone off screen, can you predict where the point [30]\left[ \begin{array}{c} 3 \\ 0 \end{array}\right] has landed?
Choose 1 answer:
Choose 1 answer:

Notice, a vector like [20]\left[ \begin{array}{c} 2 \\ 0 \end{array} \right], which starts off as 2 times the green arrow, continues to be 2 times the green arrow after the transformation. Since the green arrow lands on [12]\greenD{\left[ \begin{array}{c} 1 \\ -2 \end{array} \right]}, we can deduce that
[20]2[12]=[24]\left[ \begin{array}{c} 2 \\ 0 \end{array} \right] \rightarrow 2 \cdot \greenD{\left[ \begin{array}{c} 1 \\ -2 \end{array} \right]} = \left[ \begin{array}{c} 2 \\ -4 \end{array} \right].
And in general
[x0]=x[10]x[12]=[x2x]\begin{aligned} \left[ \begin{array}{c} x \\ 0 \end{array} \right] = x \cdot \greenD{\left[\begin{array}{c} 1 \\ 0 \end{array}\right]} &\rightarrow x \cdot \greenD{\left[ \begin{array}{c} 1 \\ -2 \end{array} \right]} = \left[ \begin{array}{c} x \\ -2x \end{array} \right] \\ \end{aligned}
Similarly, the destination of the entire y-axis is determined by where the red arrow [01]\redD{\left[ \begin{array}{c} 0 \\ 1 \end{array} \right]} lands, which for this transformation is [30]\redD{\left[ \begin{array}{c} 3 \\ 0 \end{array} \right]}.
Practice Problem: After the plane has undergone the transformation illustrated above, where does the general point [0y]\left[ \begin{array}{c} 0 \\ y \end{array}\right] on the y-axis land?
Choose 1 answer:
Choose 1 answer:

In fact, once we know where [10]\left[ \begin{array}{c} 1 \\ 0 \end{array} \right] and [01]\left[ \begin{array}{c} 0 \\ 1 \end{array} \right] land, we can deduce where every point on the plane must go. For example, let's follow the point [12]\left[ \begin{array}{c} -1 \\ 2 \end{array} \right] in our animation:
Khan Academy video wrapper
It starts at negative one times the green arrow plus two times the red arrow, but it also ends at negative one times the green arrow plus two times the red arrow, which after the transformation means
1[12]+2[30]=[52] -1 \cdot \greenD{\left[ \begin{array}{c} 1 \\ -2 \end{array} \right]} + 2 \cdot \redD{\left[ \begin{array}{c} 3 \\ 0 \end{array} \right]} = \left[ \begin{array}{c} 5 \\ 2 \end{array} \right]
This ability to break up a vector in terms of it components both before and after the transformation is what's so special about linear transformations.
Practice Problem: Use this same tactic to compute where the vector [11]\left[ \begin{array}{c} 1 \\ -1 \end{array}\right] lands.
Choose 1 answer:
Choose 1 answer:

Representing two dimensional linear transforms with matrices

In general, each vector [xy]\left[ \begin{array}{c} x \\ y \end{array} \right] can be broken down as follows:
[xy]=x[10]+y[01] \left[ \begin{array}{c} x \\ y \end{array} \right] = x\greenD{\left[ \begin{array}{c} 1 \\ 0 \end{array} \right]} + y\redD{\left[ \begin{array}{c} 0 \\ 1 \end{array} \right]}
So, if the green arrow [10]\greenD{\left[ \begin{array}{c} 1 \\ 0 \end{array} \right]} lands on some vector [ac]\greenD{\left[ \begin{array}{c} a \\ c \end{array} \right]} and the red arrow [01]\redD{\left[ \begin{array}{c} 0 \\ 1 \end{array} \right]} lands on some vector [bd]\redD{\left[ \begin{array}{c} b \\ d \end{array} \right]}, then the vector [xy]\left[ \begin{array}{c} x \\ y \end{array} \right] must land on
x[ac]+y[bd]=[ax+bycx+dy]. x \cdot \greenD{\left[ \begin{array}{c} a \\ c \end{array} \right]} + y \cdot \redD{\left[ \begin{array}{c} b \\ d \end{array} \right]} = \left[ \begin{array}{c} \greenD{a}x + \redD{b}y \\ \greenD{c}x + \redD{d}y \end{array} \right].
A really nice way to describe all this is to represent a given linear transform with the matrix below:
A=[abcd]\textbf{A} = \left[\begin{array}{cc} a & b \\ c & d \end{array} \right]
In this matrix, the first column tells us where [10]\greenD{\left[ \begin{array}{c} 1 \\ 0 \end{array} \right]} lands, and the second column tells us where [01]\redD{\left[ \begin{array}{c} 0 \\ 1 \end{array} \right]} lands. Now we can describe where any vector v=[xy]\textbf{v} = \left[ \begin{array}{c} x \\ y \end{array} \right] lands very compactly as the matrix-vector product
Av=[ax+bycx+dy]\textbf{Av} = \left[\begin{array}{c} ax + by \\ cx + dy \end{array}\right].
In fact, this is where the definition of a matrix-vector product comes from.
So in the same way that one-dimensional linear transformations can be described as multiplication by some number, namely whichever number one lands on top of, two-dimensional linear transformations can always be described by a 2, times, 2 matrix, namely the one whose first column indicates where [10]\left[ \begin{array}{c} 1 \\ 0 \end{array} \right] lands and whose second column indicates where [01]\left[ \begin{array}{c} 0 \\ 1 \end{array} \right] lands.

Want to join the conversation?

  • blobby green style avatar for user 127wexfordroad
    In the first video, the red arrow lands on 3 not 4. Not clear on how or why it is determined that 1 -> 4.

    I see how the green arrow lands on -2, but in neither case am I clear on why we are throwing away the X,Y coordinates.
    (18 votes)
    Default Khan Academy avatar avatar for user
  • aqualine ultimate style avatar for user Bonivasius Pradipta Retmana
    I rather struggle with visualizing the transformation in 2D, is there any tips for me?
    (6 votes)
    Default Khan Academy avatar avatar for user
    • aqualine ultimate style avatar for user Kyler Kathan
      Think of it like this: You have a square with a red dot in the middle. You can spin the square about the red dot, you can stretch/compress the square into a rectangle (or a bigger/smaller square), and you can change the angle of the corners so it becomes a parallelogram (the dot must stay perfectly centered). Doing any of those things (or all of them) is a linear transformation. You can't do things like bending a line segment into a curve. That would be a non-linear transformation.
      (28 votes)
  • blobby green style avatar for user MichaelRobertReinhard
    The question after the "Specific Two Dimensional Transformation with Background" is wrong. The explanation after the video talks about following the vector [1,1]. There is no vector [1,1] in the video, only [0,1] and [1,0]. Also, the practice problem makes no sense. The vector [-1,0] cannot end up at [-1, anything] because the whole space rotates by 90 degrees. What am I missing?
    (6 votes)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user Stefan Bonn
      The vector [1,1] is vector [1,0] + vector [0,1] so if [1,0] -> [1,-2] and [0,1]->[3,0] than [1,1]->[1,-2]+[3,0] which equals [4,-2]. Have to admit that it is much easier to just first read the 'Representing two dimensional linear transforms with matrices' section...
      (7 votes)
  • spunky sam blue style avatar for user Rick
    How were these visualizations done? is there any software/programming language/module that would allow me to mess around with transforming such a 2D grid of lines/vectors?
    (4 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Simon Bujowski
    If you want to develop a good intuition of what are the Linear transformations and stuff related to it, I created a mnemonic that might help you.

    Imagine a linear space is a formation of spaceships, each having its own unique coordinate. Linear operator (transformation) is the voyage near a black hole. Then the Kernel is all the ships that fell into the black hole and the image is the ships that survived, but now have their coordinates distorted by the black hole.

    If you haven't tackled something from here yet, keep the mnemonic in mind and go on for the next topics ;)
    (4 votes)
    Default Khan Academy avatar avatar for user
  • starky tree style avatar for user Adrianna
    In the video "Tricky Examples of Nonlinear 2D Transformations," the first example looks like it could be used in a video game, such as for creating a ceiling as a player moves through a hallway. If this isn't an example of linear algebra, what kind of math is used to make this transformation?
    (3 votes)
    Default Khan Academy avatar avatar for user
    • spunky sam red style avatar for user Bernard Field
      In your video game example, taking a fully general case, the computer is doing maths in 3D space. It stores the coordinates of game objects as members of R3. Linear transformations in R3 can be used to manipulate game objects. To represent what the player sees, you would have some kind of projection onto R2 which has points converging towards a point (where the player is) but sticking to some plane in front of the player (then putting that plane into R2).
      For more information, including the specific maths, you could read https://en.wikipedia.org/wiki/3D_projection

      The example in the video maps R2 to R2. In very constrained cases, you might be able to use this- for example, if you can't change the camera angle while travelling through the corridor, or perhaps if you don't have any 3D objects to render.
      (1 vote)
  • aqualine tree style avatar for user CodeLoader
    What's the reason I can see only the first image, and others are just black rectangles? The same happens in the next page.
    (2 votes)
    Default Khan Academy avatar avatar for user
  • duskpin tree style avatar for user Andrew
    If a straight line bends, isn't it still a line?
    To quote the lesson, "For our purposes, what makes a transformation linear is the following geometric rule: The origin must remain fixed, and all lines must remain lines."

    This makes me think that lines will become disjoint or discontinuous under a non-linear transform.
    But the first example of a non-linear transform shows that the straight lines become bendy lines, still lines.

    Would it be better to say, "... all straight lines must remain straight lines."

    What about corners?
    (2 votes)
    Default Khan Academy avatar avatar for user
    • mr pants teal style avatar for user Moon Bears
      No, because what is a straight line in cartesian coordinates isn't a straightline in polar coordinates - a straightline in polar coordinates holds the radius constant and sweeps through all possible angles making a circle (or an arc of a circle). This is due to the form f(x) = mx + b. Furthermore a straight line on the surface of a sphere forms the arc of a circle, since normal straight lines won't stay on the surface of the sphere. What is considered a "straight" line is all up to the coordinate systems that you choose!
      (3 votes)
  • blobby green style avatar for user ursclass07
    Re practice problem: where does vector [1,-1] end?

    The incorrect answer has a somewhat misleading equation:
    [1, -2] - [3, 0] = [2, -2], instead of [1,-2]- [3, 0] = [-2, -2].

    From the context it is clear what the correct answer is, but somehow I think one shouldn't put an = sign, where there is no equality. Maybe one could modify this a little? Admittedly, a very minor issue in an otherwise really, really good and helpful presentation. Thank you!
    (2 votes)
    Default Khan Academy avatar avatar for user
  • eggleston blue style avatar for user Lesen Liu
    If two vectors in a two-dimensional space are linearly independent, but the third vector and one of the vectors are linearly dependent, then how to deal with it in this case, then what is its corresponding geometric meaning?
    (1 vote)
    Default Khan Academy avatar avatar for user