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:
Read it aloud:
add matching entries
Why This Works
In two dimensions, a vector can describe a movement.
If , it says:
move 2 units horizontally
move 4 units vertically
If , 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].
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.
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:
For longer vectors, the same rule continues:
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.
If and , what is ?
Compute it first, then check your number.
HintMatch positions
The first coordinate is . The second coordinate is .
SolutionCoordinate sum
Add each coordinate position separately:
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]
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]
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:
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.