∥x∥2\|\mathbf{x}\|_2

Norm — the length of a vector

Read "the norm of x". Double bars mean the length of a vector: square each entry, add them up, and take the square root.

∥x∥2=∑ixi2\|\mathbf{x}\|_2 = \sqrt{\sum_i x_i^2}. This is Pythagoras' theorem with dd sides instead of two. The small subscript says which kind of length:

  • ∥⋅∥2\|\cdot\|_2: ordinary (Euclidean) length, the default
  • ∥⋅∥F\|\cdot\|_F: the Frobenius norm, the same formula applied to every entry of a matrix
  • ∥⋅∥1\|\cdot\|_1: the sum of the absolute values of the entries

Dividing a vector by its norm gives a vector of length 1 (a unit vector). Cosine similarity does this to both vectors before taking their dot product.

Example

∥[3,4]∥2=9+16=5\|[3, 4]\|_2 = \sqrt{9 + 16} = 5

The 3–4–5 right triangle: the vector's length is the hypotenuse.

Where the course uses it

Related terms