Projection
Projection asks a simple question:
How much of one vector lies
along another direction?
Suppose:
a = [3, 2]
b = [1, 0]
The vector b points along the horizontal axis. The part of a that lies
along b is its horizontal part, which is 3.
Projection gives a precise way to compute that idea.
Another useful reading is this:
projection
= part explained by a direction
residual
= what is left over
If a vector is projected onto a line, the projected vector lies on that line. The difference between the original vector and the projection is the leftover part not explained by that line.
Scalar Component
When is not zero, the signed scalar component of along the direction of is:
This gives a number. It says how far reaches along the direction of .
For and :
If and , what is the scalar component of along ?
Compute it first, then check your number.
HintUse the easy direction
The direction measures the horizontal part.
SolutionHorizontal component
The vector is a unit vector along the horizontal axis:
The scalar component is just the signed amount of in that direction.
Here the horizontal component is 5.
Projected Vector
If we want the projected vector itself, we use:
Do not rush the projected-vector formula. Read it as:
measure the part of a
in the direction of b
then return the vector
that lies on the line of b
For:
a = [3, 2]
b = [1, 0]
we get:
and:
So:
The projection keeps the horizontal part and removes the vertical part.
For and , the leftover part is:
The original vector splits into the part along and the part left over.
If and , what is ?
Compute it first, then check your number.
HintVector result
The scalar component is 5, but the projected vector must still have two
coordinates.
SolutionHorizontal projection
First compute the scale factor:
So:
The result is a vector on the horizontal axis. It keeps the explained horizontal part of and removes the vertical part.
If and , what residual is left after subtracting the projection from ?
Compute it first, then check your number.
HintSubtract the explained part
Residual means original minus projection.
SolutionLeftover component
The projection keeps the horizontal part. The residual keeps the vertical leftover.
Why Divide by b Dot b?
If is not a unit vector, its length affects the dot product.
For example:
a = [6, 2]
b = [2, 0]
The dot product is:
But the projection should still land at [6,0], because a reaches six units
along the horizontal axis.
The denominator corrects for the length of :
so:
Let and . What is ?
Compute it first, then check your number.
HintNormalize through the formula
Compute , then , then multiply the ratio by .
SolutionNon-unit projection
Because is not a unit vector, we must divide by :
The projection still lands at the horizontal part of . The denominator removes the extra length introduced by using as the direction vector.
Projection Is Not Always Positive
The scalar component can be negative.
If a vector points partly opposite to the direction , the dot product is negative, and the projection lands on the opposite side.
If and , what is ?
Compute it first, then check your number.
HintKeep the sign
The horizontal coordinate is negative.
SolutionSigned component
The projection keeps the signed horizontal component. Since the first
coordinate is -3, the projected vector lies three units in the negative
horizontal direction.
Next, we connect vectors to embeddings: the representation spaces used by modern models.