Exercises
These exercises check whether you can compute with vectors and explain what the operations mean.
Try each prompt before opening the hint or solution.
Fluency
If , what is the second coordinate?
Compute it first, then check your number.
HintUse order
The first coordinate is -3. The second coordinate is the next entry.
SolutionCoordinate order
Coordinates are read in order from left to right. In , -3
is the first coordinate and 6 is the second coordinate, so the answer is
6.
If and , what is the first coordinate of ?
Compute it first, then check your number.
HintAdd matching entries
Use the first coordinate of a and the first coordinate of b.
SolutionFirst coordinate
Vector addition keeps coordinate positions separate. The first coordinate
of the sum uses only the first coordinates of the inputs, so it is
2 + 5 = 7.
If , what is the first coordinate of ?
Compute it first, then check your number.
HintMultiply each coordinate
Scalar multiplication multiplies every coordinate by the scalar.
SolutionScale coordinate-wise
Scaling by 3 multiplies every coordinate by 3. The first coordinate is
therefore 3 x 4 = 12. The second coordinate changes too, but the question
asks only for the first coordinate.
If and , compute .
Compute it first, then check your number.
HintProducts first
Compute .
SolutionTwo products
A dot product multiplies matching entries, then adds the products:
The result is one scalar, not another vector.
Measurement
If and , what is the distance between them?
Compute it first, then check your number.
HintSubtract first
First compute , then find the length of that difference.
SolutionDistance as norm of a difference
Distance is the length of the change from one point to the other:
The difference vector is a 3-4-5 right triangle, so the distance is 5.
What is the cosine similarity between and ?
Compute it first, then check your number.
HintUnit perpendicular vectors
The dot product is 0, and each vector has length 1.
SolutionCosine calculation
The vectors are unit vectors, so their lengths are both 1. Their dot
product is zero:
A cosine similarity of 0 means the two nonzero vectors are perpendicular.
If and , what is ?
Compute it first, then check your number.
HintHorizontal projection
The direction is the horizontal axis.
SolutionProjected vector
Projection onto keeps the horizontal part and removes the vertical part:
The -2 is not lost by accident. It is the part not explained by the
horizontal direction.
Interpretation
Enter 1 if the dot product returns a scalar, or 2 if it returns a vector.
Compute it first, then check your number.
HintThink collapse
The final step of a dot product is addition into one number.
SolutionScalar result
Enter 1. A dot product returns one scalar, often used as a score.
Enter 1 for the safer statement:
Each embedding coordinate always has a simple human label.
Enter 2 for:
Embeddings are learned coordinates whose directions and relationships can be useful.
Compute it first, then check your number.
HintAvoid overreading
Learned representations can be useful without being a simple dictionary.
SolutionCareful embedding language
Enter 2. Embeddings are learned representations. Some directions may be
interpretable, but each coordinate is not guaranteed to have a simple human
label.
You want to compare the direction of two nonzero document embeddings while
reducing the direct effect of length. Enter 1 for cosine similarity, 2 for
vector addition.
Compute it first, then check your number.
HintDirection comparison
Look for the operation that divides by both vector lengths.
SolutionCosine similarity
Enter 1. Cosine similarity is:
It compares direction after accounting for length.
That is why it is a natural first choice when two document embeddings may have different lengths but we mainly care whether they point in similar directions.
A vector [4, 9] means [rooms, distance_km] in one dataset. Another vector
[4, 9] means [age_years, height_cm] in another dataset.
Enter 1 if adding these vectors directly is a bad idea.
Compute it first, then check your number.
HintShape is not enough
Both vectors have two entries, but the coordinate systems are different.
SolutionMeaning must match
Enter 1. Vector operations combine matching coordinates. Here, the first
coordinate would mix rooms with age, and the second would mix distance with
height. The arithmetic is possible, but the interpretation is not sound.
Let . Its projection onto is .
What residual is left after the projection?
Compute it first, then check your number.
HintSubtract the projection
Compute .
SolutionProjection plus leftover
The projection explains the horizontal part. The residual is the vertical leftover.
After these exercises, use the solutions page if you want the same reasoning in one linear review.