Vector Addition

Vector addition combines matching coordinates.

If two vectors have the same length, we add the first coordinates together, then the second coordinates together, and so on.

a = [2, 4]
b = [3, 1]

Their sum is:

a+b=[2+3,4+1]=[5,5]a + b = [2 + 3, 4 + 1] = [5, 5]

Read it aloud:

add matching entries

Why This Works

In two dimensions, a vector can describe a movement.

If a=[2,4]a = [2, 4], it says:

move 2 units horizontally
move 4 units vertically

If b=[3,1]b = [3, 1], it says:

move 3 units horizontally
move 1 unit vertically

Doing both movements, one after the other, gives:

move 5 units horizontally
move 5 units vertically

That is the vector [5, 5].

-6-4-2246-4-2246a = [2, 4]b = [3, 1]a + b = [5, 5]0
a + b = [2 + 3, 4 + 1] = [5, 5]Drag either endpoint. Drag the plane to pan.

The diagram shows the two input vectors and their sum. Drag the endpoints and keep reading the coordinates. The rule does not change: matching coordinates combine.

MATH-C02-T04-001Exercise: Add matching coordinates

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

Compute it first, then check your number.

HintUse the first entries

The first coordinate of the sum uses the first coordinate of a and the first coordinate of b.

SolutionAdd coordinate by coordinate

The first coordinates are 2 and 3, so the first coordinate of a + b is 2 + 3 = 5. The full sum is [5, 5].

Formula

For two-dimensional vectors:

[a1,a2]+[b1,b2]=[a1+b1,a2+b2][a_1, a_2] + [b_1, b_2] = [a_1 + b_1, a_2 + b_2]

For longer vectors, the same rule continues:

[a1,a2,,an]+[b1,b2,,bn]=[a1+b1,a2+b2,,an+bn][a_1, a_2, \ldots, a_n] + [b_1, b_2, \ldots, b_n] = [a_1+b_1, a_2+b_2, \ldots, a_n+b_n]

The vectors must have matching shapes. A two-coordinate vector and a three-coordinate vector do not describe the same kind of object, so they cannot be added coordinate by coordinate.

MATH-C02-T04-002Exercise: Add the full vector

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

Compute it first, then check your number.

HintMatch positions

The first coordinate is 1+41 + 4. The second coordinate is 2+5-2 + 5.

SolutionCoordinate sum

Add each coordinate position separately:

[1,2]+[4,5]=[1+4,2+5]=[5,3][1, -2] + [4, 5] = [1 + 4, -2 + 5] = [5, 3]

The first output coordinate comes from the first inputs. The second output coordinate comes from the second inputs. The result keeps the same vector shape.

Common Trap: Adding All Numbers

Do not add all numbers into one total.

This is wrong:

[2, 4] + [3, 1] = 10

That loses the coordinate structure. Vector addition should return another vector with the same shape:

[2, 4] + [3, 1] = [5, 5]
MATH-C02-T04-003Exercise: Keep the shape

Enter 1 if adding two two-coordinate vectors should produce another two-coordinate vector.

Compute it first, then check your number.

HintOutput type

Ask whether the result should be one number or another vector.

SolutionShape preserved

Enter 1. Adding two two-coordinate vectors gives a two-coordinate vector. Each output coordinate comes from the matching input coordinates.

Code Mirror

In NumPy, vector addition mirrors the formula:

import numpy as np

a = np.array([2, 4])
b = np.array([3, 1])

print(a + b)

The output is:

[5 5]
MATH-C02-T04-004Exercise: Trace vector addition in code

What is the second coordinate of this output?

a = np.array([2, 4])
b = np.array([3, 1])
print(a + b)

Compute it first, then check your number.

HintSecond entries

Use the second entry of each vector.

SolutionCode mirrors formula

The code computes:

[2,4]+[3,1]=[5,5][2, 4] + [3, 1] = [5, 5]

NumPy applies the same coordinate-wise rule, so the second coordinate is 4 + 1 = 5.

Next, we will subtract vectors and scale them with single numbers.