Objective
Learning objectives
- Explain a dimension, informally, as one coordinate in a point's description
- Recognize that distance and the ideas from this phase apply unchanged regardless of coordinate count
- Run a generalized distance function on points with 5 and hundreds of coordinates
- Compute the distance between two 5-number points by hand-checkable steps
Hook
Back in Lesson 01, an AI embedding was mentioned as a list of 768 numbers representing a word — and the promise was that "distance between two points" would end up meaning the same thing there as it does for two dots on paper. Nobody can actually picture a 768-dimensional space, and that's fine, because it turns out you never needed to.
See it
A dimension, informally, is just one coordinate — one independent number describing where a point is. A 2D point needs 2 numbers to pin it down; a 3D point needs 3; a 768-dimensional embedding needs 768. That's the entire jump from "a point on paper" to "a point in embedding space" — more numbers in the list, nothing conceptually new about what a "point" or a "distance" means.
The formula was already general — you just hadn't stress-tested it yet
Lesson 01's distance() function was already written to handle any number of coordinates — sum((b - a)**2 for a, b in zip(p1, p2)) doesn't know or care whether it's summing 2 terms or 768. "Geometry in high dimensions" isn't a harder kind of math bolted onto ordinary geometry; it's ordinary geometry's own formulas, which never actually depended on staying small.
Name it
Dimensionality is just the count of coordinates a point has. It's tempting to expect "high-dimensional" to mean "a fundamentally different kind of geometry," but the distance formula, and the cos θ similarity idea from Lesson 03, don't change shape as dimension count grows — they just have more terms to add up. (A fuller, more careful treatment of vector spaces themselves — what changes and what provably doesn't as dimensions grow — is Math for AI & ML's job; the informal version here is enough to stop "768-dimensional" from sounding intimidating.)
Code it
import math
def distance(p1, p2):
return math.sqrt(sum((b - a)**2 for a, b in zip(p1, p2)))
p2d = ((0, 0), (3, 4))
p5d = ((1, 0, 2, -1, 3), (4, 1, 2, 1, 0))
print(distance(*p2d))
print(distance(*p5d))
5.0
4.795831523312719
Same function, zero modifications, called on a 2-number pair and a 5-number pair. Now push it somewhere a human genuinely can't hand-check — two 768-number vectors, standing in for a real embedding pair:
import random
random.seed(42)
v1 = [random.uniform(-1, 1) for _ in range(768)]
v2 = [random.uniform(-1, 1) for _ in range(768)]
print(len(v1), len(v2))
print(round(distance(v1, v2), 4))
768 768
22.2978
distance() produced a single sensible number without complaint, without special-casing, and without a single line changed from the 2D version. That's the whole lesson made concrete: nothing about "high-dimensional" broke the formula, because the formula never actually assumed a dimension count in the first place.
p_a = (0, 0, 0, 0, 0)
p_b = (1, 1, 1, 1, 1)
print(round(distance(p_a, p_b), 4))
Every one of the 5 coordinate pairs contributes the same squared difference: (1-0)² = 1, five times, summing to 5. √5 ≈ 2.2361. Notice this is exactly the same step-by-step process as the 3-4-5 triangle from Lesson 01 — square each difference, sum them, take the square root — just with 5 terms instead of 2.