Compute the scalar (dot) product of two 2D vectors, magnitudes, angle between them, scalar projection, and orthogonality test. Visualize vectors a and b from origin with dynamic scaling.
The dot product (or scalar product) is a fundamental operation in linear algebra that combines two vectors to produce a scalar. For 2D vectors a = (ax, ay) and b = (bx, by), the algebraic definition is a·b = axbx + ayby. Geometrically, the dot product equals the product of the magnitudes and the cosine of the angle between them: a·b = |a||b| cos θ. This duality bridges algebra and geometry, enabling angle calculation, orthogonality tests, and projection formulas.
a · b = ‖a‖ ‖b‖ cos θ ⟺ cos θ = (a·b) / (‖a‖ ‖b‖)
If a·b = 0 → vectors are orthogonal (perpendicular). If a·b > 0 → acute angle; a·b < 0 → obtuse angle.
| Property | Formula | Description |
|---|---|---|
| Commutative | a·b = b·a | Order does not affect the scalar result. |
| Distributive | a·(b+c) = a·b + a·c | Dot product distributes over vector addition. |
| Scalar multiplication | (c a)·b = c (a·b) | Scaling a vector scales the dot product linearly. |
| Relation to norm | a·a = ‖a‖² | Dot product of a vector with itself equals squared magnitude. |
In information retrieval, documents are represented as high‑dimensional term‑frequency vectors. The dot product combined with vector magnitudes yields the cosine similarity, measuring orientation rather than magnitude. Two documents with similar content produce a high dot product after normalization. Our 2D example abstracts this principle: when vectors point in similar directions (small angle), dot product is large relative to magnitudes. This core concept powers search engines and AI embeddings.
The tool follows these exact analytical steps:
All results are computed with double precision. Edge cases (zero vectors) generate descriptive warnings to avoid division by zero.