LINEAR ALGEBRA / 1. VECTORS & OPERATIONS
Vectors & Vector Operations
Arrows in space — the building block of everything
EXPLANATION
A vector is an ordered list of numbers. Geometrically, it's an arrow pointing from the origin to a point in n-dimensional space. 3Blue1Brown's key insight: think of vectors as transformations, not just lists of numbers. Adding two vectors = following one arrow then the other. Scaling = stretching or flipping. Basic operations: • Addition: [a,b] + [c,d] = [a+c, b+d] (tip-to-tail of arrows) • Scalar multiplication: k·[a,b] = [ka, kb] (stretch by k) • Dot product: a·b = Σaᵢbᵢ = ||a||·||b||·cos(θ) Dot product is the most important operation: • Measures alignment between vectors • a·b > 0 → point in same general direction • a·b = 0 → perpendicular (orthogonal) • a·b < 0 → point in opposite directions • Normalized: cos(θ) = (a·b) / (||a||·||b||) → cosine similarity Norms measure vector length: • L1: ||x||₁ = Σ|xᵢ| • L2: ||x||₂ = √(Σxᵢ²) ← most common, Euclidean distance • L∞: ||x||∞ = max|xᵢ|
DIAGRAM
Vector addition: a + b = c a = [2, 1] b = [1, 3] c = [3, 4] Visualized as arrows: ↑ (0,4) *c | / | / | b / | / | * / | |/ |/*a ──────────→ x Dot product intuition: a·b = ||a||·||b||·cos(θ) θ=0°: a·b = max (parallel, same direction) θ=90°: a·b = 0 (perpendicular) θ=180°:a·b = min (anti-parallel) In neural networks: attention score = q·k (dot product)
CODE