Visual Math Toolkit Guide 1 of 6 · tap to switch
Vectors, Norms & Dot Products
See every ML data row and embedding as an arrow in space, add and scale vectors visually, and feel why Dot Products measure alignment.
Imagine texting a friend walking directions from a coffee shop to a park: “Walk 4 blocks East, then 3 blocks North.” You can write those directions as a tiny list of two numbers, [4, 3], or you can draw a straight arrow on a city map pointing from the coffee shop right to the park.
Those two pictures describe the exact same object. Mathematicians call it a vector: a list of numbers that is also a geometric arrow with a direction and a length (also called its magnitude). How long is that straight crow-flies arrow from [0, 0] to [4, 3]? By the classic right-triangle rule (Pythagoras), square each step, add them together, and take the square root: sqrt(4^2 + 3^2) = sqrt(25) = 5 blocks. (In math books, people often write the length of arrow v using double bars: ||v||.)
Why does this matter for machine learning? Computers cannot “see” a house, a song, or a movie review directly, so every ML system turns each item into a numbered list (a vector) like [size, bedrooms] or [action_score, comedy_score]. Once data becomes arrows on a map, simple geometry unlocks almost everything models do.
Slide the East/West and North/South steps below (try negative numbers to walk West or South!) and watch the list of numbers, the map arrow, and its straight-line length move together.
Adding arrows & flipping direction
Once information lives as arrows on a map, two everyday moves build most of the math inside machine learning:
- Adding two trips (
u + v), called Vector Addition: Suppose you first walk along tripu([3, 2]), and from where you land, you walk along a second tripv([2, -3]). Putting the tail of the second arrow onto the tip of the first (“tip-to-tail”) lands you at the exact same spot as adding matching slots:[3 + 2, 2 + (-3)] = [5, -1]. - Stretching, shrinking, or flipping (
c · u), called Scalar Multiplication: In vector math, a plain single number like2,0.5, or-1is called a scalar (because it scales an arrow). Multiply an arrow by2to double its length, or by0.5to cut it in half. Multiply by a negative scalar like-0.5or-1, and the minus sign flips the arrow 180 degrees to point in the exact opposite direction!
That negative-scalar flip shows up constantly when models learn: in a training loop called Gradient Descent, a model multiplies an uphill direction arrow by a small negative scalar (like -0.1) to take a smooth step in the opposite, downhill direction.
Try both modes below. First move the second trip v in Add Two Trips mode to see the combined green shortcut update live. Then switch to Stretch or Flip mode and drag the scalar c smoothly across zero!
The Dot Product: the single most important operation in AI
Suppose your movie taste is scored on two traits, [Action, Comedy], giving you the taste arrow u = [4, 0] (pure Action fan). When a recommendation system inspects a new movie’s arrow v, how does it score whether the movie matches your taste?
It uses the Dot Product (written u · v): multiply the matching slots of both lists and add them up, (u1 × v1) + (u2 × v2).
Here is the geometric magic behind that tiny arithmetic recipe: multiplying matching slots and adding them up ALWAYS equals (length of u) × (length of v) × cos(angle). Think of cos(angle) (the cosine of the angle between the two arrows) as a simple alignment dial running from -1 to +1:
cos(0°) = +1when both arrows point the exact same way, producing the biggest positive score.cos(90°) = 0when they meet at a clean right angle, producing exact0.cos(180°) = -1when they point in opposite directions, producing the biggest negative score.
Geometrically, multiplying the length of v by cos(angle) tells you how far v casts a shadow along u. Rotate arrow v through a full 360° circle below and watch the slot-by-slot arithmetic stay locked to the colored shadow!
Notice 90°, which mathematicians call perpendicular (or orthogonal): whenever two non-zero arrows meet at a right angle, cos(90°) = 0, so their Dot Product equals exact 0.0. They share zero directional alignment, which is why neural networks and Self-Attention heads rely on dot products to test whether two patterns agree, oppose each other, or are completely unrelated.
Measuring vector length in ML: L1 vs. L2 vs. Unit Vectors
In math and machine learning, any ruler for measuring the size of a vector is called a norm. Depending on the task, you choose one of three simple rulers:
- Straight-Line Length (
L2norm, also called Euclidean length): The direct crow-flies distance from our map example. Square every coordinate, add them up, and take the square root. Because squaring turns negative steps positive, the arrow[3, -4](3 blocks East, 4 blocks South) has straight-line lengthsqrt(3^2 + (-4)^2) = sqrt(9 + 16) = 5.0. - City-Block Length (
L1norm, also called Manhattan length): Imagine a taxi that must follow the street grid instead of cutting diagonally through buildings. You add up the absolute value of each step (dropping minus signs, since walking 4 blocks South is still 4 blocks walked!). For[3, -4], the city-block distance is|3| + |-4| = 3 + 4 = 7.0. - Unit Vector (shrinking any arrow to length
1.0): Sometimes you only care about which way an arrow points, not how long it is (for example, matching a short product review to a long article on the exact same topic). Dividing every coordinate of a vector by itsL2straight-line length keeps its exact same direction while setting its length to1.0. Forv = [3, 4](whoseL2length is5.0), dividing each slot by5.0gives the unit vector[0.6, 0.8]. Better still: when two arrows are both unit vectors of length1.0, their Dot Product becomes1 × 1 × cos(angle) = cos(angle), a pure direction score called Cosine Similarity.
Pick a vector below (be sure to test [3, -4]!) and click through all three rulers to see the straight diagonal, the city-block L-path, and the length-1 unit circle side by side.
See Algebraic & Geometric Dot Product Equivalence, Cauchy-Schwarz & Lp NormsThesis / Reference
1. Algebraic vs. Geometric Dot Product: For any separated by angle , the Law of Cosines proves exact equivalence between the coordinate sum and the projection shadow:
By the Cauchy-Schwarz inequality, , guaranteeing Cosine Similarity .
2. Vector Norms: The general family unifies Manhattan (), Euclidean (), and Chebyshev max-norm ().
See Vector Norms & Dot Products in NumPyOptional Code
import numpy as np
u = np.array([4.0, 0.0])
v = np.array([2.83, 2.83])
dot = np.dot(u, v) # 11.32
l2_v = np.linalg.norm(v, ord=2) # 4.00
l1_v = np.linalg.norm(v, ord=1) # 5.66
cos_sim = dot / (np.linalg.norm(u) * l2_v) # 0.71 (cos 45 deg)Where can two arrows take you?
Now that you know how to add and scale two arrows, ask a geometric question: if you combine a · u + b · v for every possible pair of numbers a, b, can you reach every point on the 2D map, or do two look-alike arrows trap you on a skinny 1D rail?
Next up: Vector Spaces, Span & Basis.
Quick Intuition Check
Four quick real-world scenarios. No scores, just test your intuition.
Two non-zero vectors u and v have a Dot Product of exactly 0.0. What does that tell you geometrically?
What happens to an arrow v = [3, 4] when you divide every coordinate by its Straight-Line (L2) length of 5.0?
Multiplying a vector by a negative scalar (such as -0.1 during Gradient Descent) shrinks or stretches the arrow and flips it 180 degrees in the opposite direction.
What are the Straight-Line (L2 / Euclidean) and City-Block (L1 / Manhattan) norms of the vector v = [3, -4]?
Common Questions
What is a vector in machine learning?
What does the Dot Product measure intuitively?
What is the difference between L1 Norm and L2 Norm?
What does normalizing a vector to unit length mean?
Related Visual Guides
Euclidean Distance & Cosine Similarity
How recommenders, search engines, and AI embeddings measure closeness, and why high dimensions distort everyday geometry.
Self-Attention & the Attention Mechanism
Understand the exact spotlight powering modern AI: Query, Key, Value dot products, sqrt(d_k) scaling, Multi-Head Attention, and Causal Masks.
Vector Spaces, Span & Basis
See how two basis arrows tile an entire 2D plane, watch dependent columns collapse into a 1D rail, and rotate rulers like PCA.
Written & illustrated by Muhammad Aashir Irshad · Updated December 2026 · Free open-access reference
Cite this guide in a paper, thesis, or course (BibTeX & APA)
@misc{irshad2026vectorsdotproducts,
author = {Irshad, Muhammad Aashir},
title = {Vectors, Norms & Dot Products: Interactive Visual Guide},
howpublished = {SeeingML},
year = {2026},
month = {dec},
url = {https://seeingml.com/learn/vectors-dot-products/},
note = {Interactive visual guide}
} Irshad, M. A. (2026). Vectors, Norms & Dot Products: Interactive Visual Guide. SeeingML. https://seeingml.com/learn/vectors-dot-products/