Dot Product Calculator

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.

Vector a = (ax, ay)
Vector b = (bx, by)
Examples:
? Orthogonal: a=(3,0), b=(0,2)
? Acute (60°): a=(4,0), b=(2,3.464)
⛛ Obtuse: a=(5,0), b=(-3,2)
⚡ Parallel: a=(2,1), b=(4,2)
? Unit vectors: a=(1,0), b=(0.707,0.707)
100% client‑side: All vector math and graphics run locally in your browser. No data is transmitted or stored.

What is the Dot Product? Geometric & Algebraic Meaning

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.

Key Properties & Algebraic Rules

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.

Real‑world Applications & Domain Expertise

  • Physics (Work & Force): Work done by a constant force is W = F·d (dot product of force and displacement vectors).
  • Machine Learning (Cosine Similarity): Dot product normalized by magnitudes gives cosine similarity, used in text mining, recommendation systems, and LLM embeddings.
  • Computer Graphics: Lighting computations (Lambertian reflectance) use dot product between surface normal and light direction.
  • Navigation & Robotics: Projection of velocity vectors, obstacle avoidance via perpendicularity.
Case Study: Cosine Similarity in Document Retrieval

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.

Step‑by‑Step Derivation & Computation

The tool follows these exact analytical steps:

  1. Algebraic dot product: dot = ax·bx + ay·by.
  2. Magnitudes: |a| = √(ax² + ay²), |b| = √(bx² + by²).
  3. Angle θ: θ = arccos( dot / (|a||b|) ), provided both magnitudes non‑zero.
  4. Scalar projection of a onto b: compb a = (a·b) / |b| (gives signed length of a's shadow along b).
  5. Orthogonality: If dot ≈ 0 within tolerance, vectors are orthogonal.

All results are computed with double precision. Edge cases (zero vectors) generate descriptive warnings to avoid division by zero.

Frequently Asked Questions

A negative dot product means the angle between vectors exceeds 90° (obtuse). In physics, negative work indicates force opposing displacement.

If either vector has zero magnitude, angle is undefined; the tool displays a warning. The dot product itself is still valid (zero if one is zero).

This version focuses on 2D with interactive graph. The same algebraic principle extends to 3D (a·b = aₓbₓ + aᵧbᵧ + a₂b₂). A dedicated 3D tool is coming soon.

Computations use IEEE 754 double precision (≈15 decimal digits). Trigonometric functions are accurate to machine epsilon, suitable for academic and engineering needs.

Expert validation: This dot product calculator implements principles from standard linear algebra textbooks (Strang, 2016; Lay, 2018). The interactive graph uses Cartesian coordinate transformations verified against numerical examples. Reviewed by the GetZenQuery tech team, June 2026. References: Wolfram MathWorld – Dot Product; Gilbert Strang, "Introduction to Linear Algebra".