Find a course

Module 1: Vectors and Linear SystemsLesson 1 of 1213 min

Vectors and Vector Operations

Add and scale vectors, compute lengths and unit vectors, and build new vectors as linear combinations, both on paper and as arrows in the plane.

Step 1 of 12Learn

Arrows and lists

A video game character stands at the origin. Each frame, the game moves her by the velocity (3, 1): three units right, one unit up. A gust of wind pushes her by (−1, 2). Where does she end up after one frame? At (3, 1) + (−1, 2) = (2, 3).

That calculation is the heart of a vector: an ordered list of numbers that you can add and scale. Vectors have two faces, and linear algebra constantly switches between them.

  • Geometric: an arrow with a length and a direction. The vector (3, 1) points from the origin to the point (3, 1), but you can slide the arrow anywhere without changing it.
  • Algebraic: a list of numbers, called components or entries. In code it's an array; in data science it's one row of a spreadsheet, such as a house described by (square feet, bedrooms, age, price).

A vector with n entries lives in ℝⁿ, the set of all such lists. The plane is ℝ², space is ℝ³, and a customer described by 50 features is a point in ℝ⁵⁰. You can't picture 50 dimensions, but the algebra works exactly the same way, which is the secret power of the subject: build intuition in 2D and 3D, then trust the algebra in any dimension.

We usually write vectors as columns in textbooks, but in this course we'll write them in parentheses, like (3, 1), to save space. Single numbers, which stretch vectors, are called scalars.

Step 2 of 12Practice · Fill in the blanks

Fill in the blanks

If u = (3, 1) and v = (−1, 2), then u + v = (, ) and 2u − v = (, ).

Step 3 of 12Practice · Chart

The game character's move, as points

Picture arrows from the origin to each point. Walking along u and then along v (tip to tail) lands on u + v, the fourth corner of a parallelogram with sides u and v.

Tap the point you reach by walking u, then v.

Tap the point that answers the question, then press Check.

The game character's move, as pointsScatter plot with 4 points: Start (0, 0): x 0, y 0; u = (3, 1): x 3, y 1; v = (−1, 2): x -1, y 2; u + v = (2, 3): x 2, y 3.0123-2-101234yxStart (0, 0)u = (3, 1)v = (−1, 2)u + v = (2, 3)
The game character's move, as points
Pointxy
Start (0, 0)00
u = (3, 1)31
v = (−1, 2)-12
u + v = (2, 3)23

Step 4 of 12Learn

Adding, scaling and length

Addition adds matching entries: (1, 4, −2) + (3, 0, 5) = (4, 4, 3). Geometrically, place the second arrow's tail at the first arrow's tip; the sum goes from the first tail to the second tip. This is the tip-to-tail rule, and it's why the order doesn't matter: u + v = v + u, the two paths forming the sides of a parallelogram.

Scalar multiplication multiplies every entry: 3(1, −2) = (3, −6). Geometrically, it stretches the arrow by a factor of 3. A negative scalar flips the direction: −1·v points the opposite way, and u − v means u + (−1)v.

The length or norm of a vector comes from the Pythagorean theorem:

|v| = √(v₁² + v₂² + … + vₙ²).

For (3, 4), the length is √(9 + 16) = 5. For (1, 2, 2), it's √(1 + 4 + 4) = 3. Scaling multiplies the length by the absolute value of the scalar: |−2v| = 2|v|.

A unit vector has length 1. To turn any nonzero vector into a unit vector in the same direction, divide by its length: (3, 4)/5 = (0.6, 0.8). This is called normalizing, and you'll use it whenever only direction matters, such as the direction of a light ray in 3D graphics or the heading of a robot.

Distance between two points is the length of their difference: the distance from (1, 2) to (4, 6) is |(3, 4)| = 5.

Step 5 of 12Practice · Work it out

What is the length of the vector (3, 4, 12)?

Step 6 of 12Try the calculator

Length and unit vector in 3D

Enter a vector (x, y, z). The calculator gives its length and the unit vector in the same direction. Check that the unit vector's entries, squared and added, give 1.

Length |v|
3
Unit vector x-entry
0.6667
Unit vector y-entry
-0.3333
Unit vector z-entry
0.6667

Step 7 of 12Learn

Linear combinations

Almost everything in linear algebra is built from one operation: the linear combination. Given vectors v₁, v₂, …, vₖ and scalars c₁, c₂, …, cₖ, the vector

c₁v₁ + c₂v₂ + … + cₖvₖ

is a linear combination of them.

Example: mixing paint. Suppose a can of paint A contains (2, 1, 0) liters of red, yellow and blue, and a can of paint B contains (0, 1, 3). Mixing 3 cans of A with 2 cans of B gives 3(2, 1, 0) + 2(0, 1, 3) = (6, 5, 6) liters.

The reverse question is the interesting one: can you reach a target vector by combining the ones you have? Can you make exactly (4, 5, 9) liters from cans A and B? You need c₁(2, 1, 0) + c₂(0, 1, 3) = (4, 5, 9). The first entry forces c₁ = 2 and the third forces c₂ = 3, but then the middle entry is 2 + 3 = 5. It works.

Now try (4, 1, 9). Again c₁ = 2 and c₂ = 3 are forced, but the middle entry would be 5, not 1. No combination works.

Checking whether a target is a linear combination always comes down to solving a system of linear equations, one equation per entry. That's why the next big topic is solving systems efficiently. In two dimensions, combinations of two non-parallel vectors reach every point in the plane; in three dimensions, two vectors reach only a plane through the origin, which is why (4, 1, 9) was out of reach.

Step 8 of 12Try the calculator

Mix two vectors: c₁(2, 1) + c₂(−1, 1)

Try to reach (0, 3), then (5, 1). Because these two vectors point in different directions, some choice of c₁ and c₂ reaches every point in the plane.

x entry
0
y entry
3
Length of the result
3

Step 9 of 12Practice · Choose one

Which vector is a linear combination of a = (1, 0, 2) and b = (0, 1, −1)?

Step 10 of 12Note

Step 11 of 12Practice · True or false

If |u| = 3 and |v| = 4, then |u + v| must be 7.

Step 12 of 12Practice · Choose one

A drone flies with velocity (40, 30) km/h relative to the air, and the wind blows at (−10, 5) km/h. What is the drone's speed relative to the ground, to the nearest km/h?