Lesson 3.4 · Stage 03: The maths behind machine learning

Maths chapter 2: Vectors: lists of numbers

A vector is an ordered list of numbers. In ML, every data item becomes a vector.

Published 27 November 2026

A vector is an ordered list of numbers. In ML, every data item becomes a vector.

2.1 Two ways to see a vector

  1. As a list. A house with area 1200 sq ft, 3 bedrooms and age 10 years is the vector (1200, 3, 10). Each number is a component. This vector has 3 components, so it lives in 3 dimensions.
  2. As an arrow. The vector (3, 4) is an arrow from the origin (0, 0) that goes 3 steps right and 4 steps up.

We usually write vectors in bold, like a, or stand them up as a column.

2.2 Adding and subtracting

Add the matching components.

(3,4)+(1,2)=(3+1,  4+2)=(4,6)(3, 4) + (1, 2) = (3+1,\; 4+2) = (4, 6)

As arrows: walk along the first arrow, then the second. Subtraction works the same way: (5, 7) − (2, 3) = (3, 4).

2.3 Multiplying by a number (scaling)

Multiply every component by the number. The number is called a scalar, because it scales the arrow.

2×(3,4)=(6,8)2 \times (3, 4) = (6, 8)

Multiplying by 2 doubles the length. Multiplying by −1 flips the arrow to point the opposite way.

2.4 Length of a vector

The length comes from Pythagoras’ theorem (class 7–8 geometry). For a = (3, 4):

∥a∥=32+42=9+16=25=5\lVert \mathbf{a} \rVert = \sqrt{3^2 + 4^2} = \sqrt{9 + 16} = \sqrt{25} = 5

The double bars ‖ ‖ mean “length”. It also works for more components: the length of (1, 2, 2) is √(1 + 4 + 4) = √9 = 3.

2.5 The dot product

The dot product of two vectors multiplies matching components and adds the results. The answer is a single number.

(1,2,3)⋅(4,5,6)=1×4+2×5+3×6=4+10+18=32(1, 2, 3) \cdot (4, 5, 6) = 1 \times 4 + 2 \times 5 + 3 \times 6 = 4 + 10 + 18 = 32

What it tells you:

  • Large positive: the arrows point roughly the same way.
  • Zero: they are at right angles (90°).
  • Negative: they point in roughly opposite directions.

Worked example: a shopping bill. You buy 2 pens, 3 notebooks and 1 eraser. Prices are ₹10, ₹40 and ₹5. The bill is the dot product (2, 3, 1) · (10, 40, 5) = 20 + 120 + 5 = ₹145.

Why ML needs it: a simple model computes “weights · inputs”, which is exactly this shopping bill. Search engines and Oracle AI Vector Search compare meanings with dot products.

Try it

  1. Work out (2, −1) + (3, 5).
  2. Work out 3 × (1, −2, 4).
  3. Find the length of (6, 8).
  4. Find the dot product (2, 3) · (4, −1).
  5. Find (1, 2) · (2, −1). Chapter 4 explains what this answer means.