Free preview
59 lessons
Essential Linear Algebra for ML
Free preview
Essential Linear Algebra for ML · 59 lessons
No surprise gaps
Actually remember it
Skip what you know
One subscription. All learning paths included.
Our content is best on a larger screen
What does a matrix do to a vector?
When we multiply a vector by a matrix, we are applying a linear transformation to that vector.
A linear transformation is a rule that takes a vector and produces a new one, in a way that is consistent for every vector. For a single vector, , this might change its length, its direction, or both.
For example:
Multiplying:
Here, the ‑coordinate has been doubled, while the ‑coordinate is unchanged. The arrow that pointed to now points to .
In this way, a matrix takes a vector and maps it to a new vector. The transformation preserves the fundamental structure of vector addition and scaling - this is what makes it linear.
The numbers in the matrix tell us exactly how to build each coordinate of the new vector from the coordinates of the original, in 2D:
The same intuition applies in any number of dimensions.
Think of each row as a recipe: take the old coordinates, multiply them by the numbers in the row, and add them up to get the new coordinate.
Have a play around with the interactive chart below. Notice how varying the entries of creates a new vector, .
Drag the blue vector to change
Given the matrix:
and the vector:
What is the effect of transforming with ?
Solution
Let's compute the resulting vector, :
Thus the resulting vector, , has increased its length and changed its direction.
We can visualise this as:
Practice questions
3 questions
Given the matrix:
and the vector:
What is the effect of transforming with ?
Select the correct answer:
+ 2 more questions
Recognising common transformation types
We have just seen that multiplying a vector by a matrix changes its length, its direction, or both.
Now we’ll put names to three of the most common types of changes we'll see.
1. Scaling
Scaling changes the length of a vector but not its direction.
Example:
The new vector points in the same direction as the original but is twice as long.
2. Rotation
Rotation changes the direction of a vector but keeps its length the same.
The amount of rotation is measured in degrees or radians, and the rotation is around the origin.
Example:
The vector has been rotated counterclockwise.
3. Reflection
Reflection flips a vector over a line through the origin.
The length stays the same, but the direction changes to its mirror image.
Example:
The vector has been reflected over the -axis.
We can summarise this as:
Have a play with the interactive visualisation below to get a feel for the types of transformations.
Drag the blue vector to change
Practice questions
3 questions
Look at the visualisation below, what sort of transformation does applying the matrix to correspond to?
Select the correct answer:
+ 2 more questions
Visualising transformations
Up to now, we’ve only looked at what happens when a matrix multiplies one vector.
But a matrix doesn’t have a special rule for each vector - it applies the same rule to any vector we give it.
That means if we could somehow see what happens to lots of different vectors at once, we’d get a much clearer picture of what the matrix is really doing.
Tip
Think of the plane as being filled with arrows (i.e. vectors) starting at the origin, each pointing to a different location.
When we apply a matrix, every arrow moves in a consistent way - stretched, rotated, flipped, or skewed according to the same pattern.
Looking at just one arrow is like looking at a single frame from a film - we get a hint of the story, but not the whole plot.
Seeing what happens to many arrows at once shows us the character of the transformation.
We can visualise this:
Edit the matrix
This diagram shows how a matrix (a linear transformation) changes vectors in the plane:
Key Point
Because the transformation is linear, the origin stays fixed, straight lines remain straight, and parallel lines stay parallel. The grid’s structure is preserved - only its shape, size, and orientation change.
Details
The unit square has corners at:
Given the matrix:
Solution
Step 1 - Apply to each corner
Step 2 - New coordinates
The transformed corners are:
Step 3 - Interpretation
Every point’s -coordinate has been doubled, while the -coordinate stayed the same.
The unit square has become a rectangle twice as wide - the whole grid is stretched horizontally.
We can visualise this as:
Practice questions
3 questions
The unit square has corners at:
Given the matrix:
Which option best describes what happens to the unit square after applying to it?
Select the correct answer:
+ 2 more questions