AI & Data Science
Class 10+

Dot Product

ab=i=1naibi=abcosθ\mathbf{a} \cdot \mathbf{b} = \sum_{i=1}^{n} a_i b_i = ||\mathbf{a}|| \, ||\mathbf{b}|| \cos\theta

What is this? (Explained Simply)

Think of two arrows. The dot product tells you how much they agree in direction. If both arrows point right, dot product is large (they agree). If one points right and the other points up (perpendicular), dot product is 0 (no agreement). If they point in opposite directions, it is negative (they disagree). AI uses this everywhere to measure 'how similar are these two things?'

0246−6−4−20246
a · b = Sum(a_i * b_i) = ||a|| * ||b|| * cos(θ)

Adjust Variables

Vector a magnitude
a_mag =
0.55
Vector b magnitude
b_mag =
0.55

The dot product measures how similar two vectors are in direction. It is the single most important operation in all of AI — every neural network layer, every attention head, every embedding lookup is fundamentally a dot product. When two vectors point the same way, the dot product is large and positive. When perpendicular, it is zero. When opposite, it is negative.

Real-World Applications

Transformer attention — Every attention score in GPT-4 is a dot product between query and key vectors. Trillions of dot products per inference.

Neural network layers — A dense layer computes output = dot(input, weights) + bias. Each neuron is one dot product.

Search engines — Google ranks documents by computing dot products between the query embedding and document embeddings.

Recommendation engines — Spotify suggests songs by computing dot products between your taste vector and every songs feature vector.

Image recognition — Convolutional filters detect features by computing dot products between the filter and local image patches.

Word similarity — Word2Vec measures word similarity via dot product: king·queen is high, king·banana is low.

Game physics — Dot product determines if objects face each other: if dot(direction_to_enemy, facing_direction) > 0, the enemy is in front.

Lighting in 3D graphics — Brightness = dot(surface_normal, light_direction). This single calculation powers all real-time game lighting.

What would an intelligent skeptic say?

The dot product is scale-dependent — longer vectors always produce larger dot products regardless of direction. This is why cosine similarity (which normalizes by magnitude) is often preferred. In very high dimensions (d=1000+), dot products between random vectors concentrate around zero, making similarity less meaningful without careful normalization.

Community Explanations

No community explanations yet. Be the first to share yours!

to write your own explanation

Community Aha! Moments

to share your insights

No insights yet. Be the first to share!

Related Formulas