Free preview
67 lessons
Essential Linear Algebra for ML
Free preview
Essential Linear Algebra for ML · 67 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
Geometric meaning of projection in dimensions
The scalar projection of a vector onto another vector tells us how much of points in the direction of , measured as a signed length.
Definition
The scalar projection is defined as:
where is the angle between and . The line defined by must pass through the origin, since projection formulas assume both vectors are positioned with their tails at the origin.
Geometrically, to find the scalar projection, we drop a perpendicular from the tip of to the line defined by (which extends infinitely in both directions). The point where this perpendicular meets the line is the "shadow" of , and the distance from the origin to this point - measured along the line - is the scalar projection.
We denote this projection as .
Have a play with the interactive visualisation below and see how the scalar projection changes as is moved around.
In the example above, points in the direction of the -axis, but in general, and can point in any direction. If and point in roughly opposite directions, the scalar projection will be negative.
To see this, suppose and makes an angle of with . Then we have:
Have a play with the interactive visualisation below where both and are now draggable.
Notice how we drop a perpendicular from the tip of to the line defined by . The right angle is formed where this perpendicular meets the line, which may be "behind" the origin relative to if the angle is greater than . This is why the scalar projection can be negative.
Tip
A negative scalar projection means that points at least partially in the opposite direction to . The projection only considers movement along , so if "moves backward" along , the result is negative.
Key Point
Let be a vector with .
Let be a vector that makes an angle of with .
Calculate .
Solution
To calculate the projection of onto , we use the formula:
Practice questions
3 questions
Let be a vector with .
Let be a vector that makes an angle of with .
Calculate .
Select the correct answer:
+ 2 more questions
Scalar and vector projection in dimensions
Now that we’ve understood the scalar projection as the signed length of the shadow of on the direction of , let’s connect this idea to the dot product. This will also set us up to properly describe what that blue arrow in our visualisations has actually been representing all along.
The scalar projection of onto is the signed length of the "shadow" of in the direction of .
Also recall the dot product formula:
Dividing both sides by isolates , which is the scalar projection:
Written in the projection notation, this is the formula we use from here on.
Theorem
Let and be non-zero vectors. The scalar projection of onto is
This formula is especially useful because it works in any dimension and doesn’t require us to find the angle. The dot product measures how much two vectors "align", and dividing by ensures the result is independent of the length of .
So far we’ve only measured the length of the shadow. But in our diagrams above we also drew the blue arrow lying along , and strictly speaking that arrow isn’t the scalar projection at all.
Definition
Let and be non-zero vectors. The vector projection of onto , written , is the vector lying on the line defined by whose signed length is the scalar projection of onto .
So the scalar projection tells us how long the shadow is, a number, while the vector projection is the blue arrow itself.
Theorem
The vector projection is given by:
In words: the vector projection is simply the scalar projection multiplied by the unit vector in the direction of .
Details
Both quantities describe the same shadow, so their sizes must agree.
Theorem
For non-zero vectors and , the norm (length) of the vector projection is always the absolute value of the scalar projection:
Since the scalar projection measures the signed length of the shadow of along , and the vector projection points in the correct direction, taking the norm of the vector projection simply gives the (unsigned) length of that shadow.
This is a useful way to check our calculations - if we take the norm of the vector projection, it should match the absolute value of the scalar projection.
Key Point
Let and .
Calculate both the scalar projection and the vector projection of onto .
Solution
First, we compute the dot product:
Next, we find the norm of :
The scalar projection is then:
For the vector projection, we use the formula (noting that ):
Practice questions
4 questions
Suppose and are non-zero vectors in .
Consider the following statements about the scalar and vector projection of onto :
A. The scalar projection of onto can be negative, zero, or positive depending on the angle between the vectors.
B. The vector projection of onto is always a scalar multiple of .
C. If the scalar projection is zero, the vector projection is the zero vector.
D. The norm (length) of the vector projection is always equal to the scalar projection.
E. The vector projection of onto always points in the same direction as .
Which of the above statements are true?
Select the correct answer:
+ 3 more questions
Generalisation to dimensional vectors
So far, we’ve focused on projections in two dimensions, but the same ideas and formulas apply in any number of dimensions. The dot product and norm work exactly the same way for -dimensional vectors, so the projection formulas generalise directly.
Theorem
Let and be vectors in with non-zero. The scalar projection of onto is
and the vector projection of in the direction of is
These formulas work for any non-zero direction vector in any dimension - we do not need to normalise first, as the formulas automatically account for its length.
Let and .
Calculate both the scalar projection and the vector projection of onto .
Solution
First, we compute the dot product:
Next, we find the norm of :
The scalar projection is then:
For the vector projection, we use the formula (noting that ):
Practice questions
3 questions
Let and .
What is the scalar projection of onto ?
Select the correct answer:
+ 2 more questions