Gradient
Lesson 3.1Math~50 min

Vectors: arrows & lists

A list of numbers is an arrow in space. Add them, stretch them, measure them — in 2D and 3D.

Module 3 · 0/7 done

A list of numbers is an arrow

A vector is simply a list of numbers, like [3,2][3, 2]. But here’s the trick that makes it powerful: you can also see it as an arrow starting at 0 and ending at the point (3,2)(3, 2) — three steps along x, two up y. Same thing, two pictures.

Fig 3.1Drag the tip of the arrow. Its two numbers (components) are how far it goes along each axis.

In machine learning, everything becomes a vector. A house is [size,rooms,age][\text{size}, \text{rooms}, \text{age}]. A pixel is [red,green,blue][\text{red}, \text{green}, \text{blue}]. A word is a list of a few hundred numbers. Once something is a vector, all the math in this module works on it.

Try itThings as vectors
// In machine learning, every example becomes a vector: a list of numbers.
// A house: [size in m², bedrooms, age in years]
const house = [120, 3, 15]

// A colour: [red, green, blue], each 0–255
const tomato = [255, 99, 71]

// A (tiny) word embedding — you'll meet these in Module 8:
const cat = [0.8, -0.2, 0.45, 0.1]

console.log(house.length, "numbers describe the house")
console.log(cat.length, "numbers describe 'cat'")
Press Run (⌘/Ctrl + Enter) to see output here.