Signing you in…

Vectors: geometry, norms (L1/L2) and dot product

A vector is an arrow, not a list of numbers

When people say “vector,” most beginners think “array of numbers.” That intuition is wrong. A vector is an arrow in space: it has direction and length. Imagine standing in the center of a city. “Three blocks north and two east” is a vector. In ML, every object (customer, photo, word) becomes such an arrow in a high-dimensional feature space, and the model learns to tell these arrows apart.

Vectors: intuition and math

Mathematically, a vector is an ordered list of numbers, e.g. [3.0, -1.5, 0.8]. Each number is a coordinate along one dimension. In ML, an object's features (height, weight, age) are coordinates, and the object lives in feature space. Nearby objects are similar objects.
A vector specifies a point's position in high-dimensional feature space
Two vectors 'close' → two similar objects. That's what k-NN builds on
A vector's direction matters more than its length — cosine similarity uses this
Word2Vec, BERT, CLIP — all turn objects (words, images) into vectors
L1 and L2: how to measure an arrow's length

The norm of a vector is its “length.” But length can be measured in different ways. L2 (Euclidean) is the straight line from the tail to the tip: x2+y2\sqrt{x^2 + y^2}. L1 (Manhattan) is moving on a grid, only along axes: x+y|x|+|y|. Click each metric below to see the difference visually.

Click a metric to highlight the corresponding path
2Д ВЕКТОРНОЕ ПРОСТРАНСТВО
0(3, 4)
Dot product: how much two arrows align

The dot product ab=a1b1+a2b2\mathbf{a}\cdot\mathbf{b}=a_1b_1+a_2b_2 measures how much two vectors point in the same direction. If the angle between them is small, the product is large and positive. If they are perpendicular — zero. If they point opposite ways — negative. Drag vector B with the mouse and watch how the result changes.

Drag the tip of vector B and watch the angle and “similarity” change
СКАЛЯРНОЕ ПРОИЗВЕДЕНИЕ · Object A · Object B
Object AObject B
cos(θ) = directional similarity
cos(θ) = 0.857similarity +
Object A · Object B = 15.00 = |Object A|·|Object B|·cos(θ) = 4.12 · 4.24 · 0.85715.00
In a neural net, every neuron is a dot product

Each neuron does exactly one thing: it computes the dot product of the input vector with the weight vector. Then the activation decides whether the neuron “fires.” That's why understanding vectors isn't abstract math — it's the basis for how any neural network works.

Click a line to see what it does ▼
python
1
import numpy as np
2
a = np.array([1.0, 2.0, 3.0])
3
b = np.array([4.0, 5.0, 6.0])
4
dot = np.dot(a, b)  # 1*4 + 2*5 + 3*6 = 32
5
l2 = np.linalg.norm(a)  # √14 ≈ 3.74
6
l1 = np.linalg.norm(a, ord=1)  # 6.0
7
cos_sim = dot / (np.linalg.norm(a) * np.linalg.norm(b))
ℹ️In recommender systems (Spotify, Netflix), every user and every song is a vector. Recommendations are nearest-neighbor search in that space. That's why vector math isn't an abstraction — it's the core of real products.