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

MATH-C02-C-001Exercise: Read coordinates

If v=[3,6]v = [-3, 6], 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 v=[3,6]v = [-3, 6], -3 is the first coordinate and 6 is the second coordinate, so the answer is 6.

MATH-C02-C-002Exercise: Add vectors

If a=[2,1]a = [2, -1] and b=[5,4]b = [5, 4], what is the first coordinate of a+ba+b?

Compute it first, then check your number.

HintAdd matching entries

Use the first coordinate of a and the first coordinate of b.

SolutionFirst coordinate
a+b=[2+5,1+4]=[7,3]a + b = [2 + 5, -1 + 4] = [7, 3]

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.

MATH-C02-C-003Exercise: Scale a vector

If v=[4,2]v = [4, -2], what is the first coordinate of 3v3v?

Compute it first, then check your number.

HintMultiply each coordinate

Scalar multiplication multiplies every coordinate by the scalar.

SolutionScale coordinate-wise
3[4,2]=[12,6]3[4, -2] = [12, -6]

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.

MATH-C02-C-004Exercise: Compute a dot product

If a=[1,3]a = [1, 3] and b=[2,5]b = [2, 5], compute aba \cdot b.

Compute it first, then check your number.

HintProducts first

Compute (1×2)+(3×5)(1 \times 2) + (3 \times 5).

SolutionTwo products

A dot product multiplies matching entries, then adds the products:

ab=(1×2)+(3×5)=2+15=17a \cdot b = (1 \times 2) + (3 \times 5) = 2 + 15 = 17

The result is one scalar, not another vector.

Measurement

MATH-C02-C-005Exercise: Compute a distance

If a=[1,1]a = [1, 1] and b=[4,5]b = [4, 5], what is the distance between them?

Compute it first, then check your number.

HintSubtract first

First compute bab-a, 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:

ba=[41,51]=[3,4]b - a = [4 - 1, 5 - 1] = [3, 4]ba=32+42=5\|b-a\| = \sqrt{3^2 + 4^2} = 5

The difference vector is a 3-4-5 right triangle, so the distance is 5.

MATH-C02-C-006Exercise: Compute cosine similarity

What is the cosine similarity between a=[1,0]a=[1,0] and b=[0,1]b=[0,1]?

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:

[1,0][0,1][1,0][0,1]=01×1=0\frac{[1,0]\cdot[0,1]}{\|[1,0]\|\|[0,1]\|} = \frac{0}{1\times1} = 0

A cosine similarity of 0 means the two nonzero vectors are perpendicular.

MATH-C02-C-007Exercise: Project onto an axis

If a=[7,2]a = [7, -2] and b=[1,0]b = [1,0], what is projb(a)\text{proj}_b(a)?

Compute it first, then check your number.

HintHorizontal projection

The direction [1,0][1,0] is the horizontal axis.

SolutionProjected vector

Projection onto [1,0][1,0] keeps the horizontal part and removes the vertical part:

proj[1,0]([7,2])=[7,0]\text{proj}_{[1,0]}([7,-2]) = [7,0]

The -2 is not lost by accident. It is the part not explained by the horizontal direction.

Interpretation

MATH-C02-C-008Exercise: Choose the output type

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.

MATH-C02-C-009Exercise: Identify the safer embedding claim

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.

MATH-C02-C-010Exercise: Pick the operation

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:

abab\frac{a\cdot b}{\|a\|\|b\|}

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.

MATH-C02-C-011Exercise: Do the coordinate meanings match?

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.

MATH-C02-C-012Exercise: Separate projection from residual

Let a=[6,4]a = [6, 4]. Its projection onto b=[1,0]b = [1,0] is [6,0][6,0].

What residual is left after the projection?

Compute it first, then check your number.

HintSubtract the projection

Compute [6,4][6,0][6,4] - [6,0].

SolutionProjection plus leftover
[6,4][6,0]=[0,4][6,4] - [6,0] = [0,4]

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.