Multiplying Vectors to Get a Number
The dot product takes two vectors and returns a single number (a scalar). For and : Multiply matching components and add. This simple operation encodes a surprising amount of geometry.
Its geometric meaning is the key: , where is the angle between the vectors. So the dot product measures how aligned two vectors are:
- Positive — the vectors point in broadly the same direction ().
- Zero — the vectors are orthogonal (perpendicular, ).
- Negative — they point in broadly opposite directions ().
The orthogonality test is the most-used consequence: two nonzero vectors are perpendicular exactly when their dot product is zero. No angle computation needed — just check if . This is how graphics code tests perpendicularity and how projections are computed.
The dot product also recovers length () and lets you find the angle between vectors via . In machine learning, the closely related cosine similarity uses exactly this to measure how similar two feature vectors are — the backbone of search and recommendation.
Common pitfall: confusing the dot product (which returns a number) with scaling or componentwise multiplication that returns a vector, and forgetting that orthogonal means dot product zero. is a single scalar , not a vector. And perpendicular vectors have — a positive or negative dot product means the angle is acute or obtuse, never a right angle.