Algebra • Vector Operations

Dot Product Calculator

The universal vector dot product calculator for calculating scalar products in 2D and 3D space, finding the exact angle (θ) between vectors, testing perpendicular orthogonality, and computing vector projections.

|
Last Updated: September 2026
|
Verified Accurate: Euclidean Vector Spaces & Linear Algebra
Vector a (First Vector) ⟨ax, ay, az⟩
Vector b (Second Vector) ⟨bx, by, bz⟩
Preset Examples:
Dot Product Output Acute Angle
Scalar Dot Product (a · b)
5
(3 × 1) + (4 × -2) + (2 × 5) = 3 − 8 + 10 = 5
||a|| 5.385
||b|| 5.477
Angle (θ) 80.24°
cos(θ) 0.170
Vector & Scalar Projections:
Scalar Proj (compba): 0.913
Vector Proj (projba): ⟨0.167, -0.333, 0.833⟩

2D Plane Vector & Angle Projection

(xy-plane projection)
+x +y
Vector a
Vector b
Angle θ

Step-by-Step Mathematical Derivation Algebraic & Geometric Steps

Direct Answer & Overview
Verified Educational Guide

How to Calculate the Vector Dot Product

To calculate the dot product of two vectors a and b, multiply their matching coordinates and sum the resulting products: a · b = (a_x * b_x) + (a_y * b_y) in 2D, or (a_x * b_x) + (a_y * b_y) + (a_z * b_z) in 3D. The result is always a single real scalar number. Geometrically, the dot product equals the product of their Euclidean lengths multiplied by the cosine of the angle between them: a · b = ||a|| ||b|| cos(θ). If the dot product is positive, the angle is acute (< 90°); if zero, the vectors are exactly orthogonal (90°); and if negative, the angle is obtuse (> 90°).

Primary Mathematical Formula Algebraic Component-Wise & Geometric Cosine Formulations
Standard Equation
ƒ(x)
Q.E.D.
a⋅b=∑i=1naibi=∥a∥∥b∥cos⁡(θ)\mathbf{a} \cdot \mathbf{b} = \sum_{i=1}^{n} a_i b_i = \|\mathbf{a}\| \|\mathbf{b}\| \cos(\theta)
Both vectors must share the exact same number of dimensions. The dot product yields a scalar, not a vector.
Exact Formula
Input Parameters
Required
1
Vector a: Coordinates in 2D (x, y) or 3D (x, y, z).
2
Vector b: Coordinates in 2D (x, y) or 3D (x, y, z).
Expected Outputs
Calculated
Scalar Dot Product (a · b): Numerical scalar magnitude.
Angle (θ): Exact angular separation in both degrees and radians.
Vector Projections: Scalar projection comp_b(a) and vector projection proj_b(a).
Worked Numerical Example
Instant Verification
Compute the dot product of a = <3, 4> and b = <2, -1>
→ Multiply components: (3 * 2) + (4 * -1) = 6 - 4 = 2. Magnitudes: ||a|| = 5, ||b|| = √5 ≈ 2.236. cos(θ) = 2 / (5 * √5) ≈ 0.1789. θ = arccos(0.1789) ≈ 79.7°.
a · b = 2 (Positive scalar, acute angle θ ≈ 79.7°).

Anatomy of the Dot Product: Algebraic vs Geometric Forms

The dot product (frequently termed the scalar product or inner product) is one of the foundational algebraic operations in vector mathematics and physics. While vector addition and subtraction produce new vectors pointing in new directions, and the Cross Product Calculator computes a perpendicular vector in three dimensions, the dot product condenses two vectors into a single real scalar number.

The dot product can be defined through two equivalent perspectives that bridge analytic coordinate geometry with pure trigonometric intuition:

1. The Algebraic Formulation

In Cartesian coordinates, multiply corresponding components and sum the products:

a · b = a_x b_x + a_y b_y + a_z b_z

Effortless to evaluate numerically across any number of dimensions.

2. The Geometric Formulation

Multiply the Euclidean lengths of both vectors by the cosine of the angle between them:

a · b = ||a|| × ||b|| × cos(θ)

Provides geometric meaning: directional alignment and physical work.

Because both equations yield identical scalar results, equating them creates an indispensable mathematical bridge that allows you to calculate the physical angle between vectors without measuring tools.

Angle Between Vectors & The Orthogonality Test

Solving the geometric formulation for cos(θ) produces the universal angle formula between two vectors, bridging vector geometry with classical trigonometry (compare with our Angle from Sides Calculator and Coterminal Angles Explorer):

θ = arccos [ (a · b) / (||a|| × ||b||) ]

where θ is restricted to the principal range 0° ≤ θ ≤ 180° (0 to π radians).

Because the magnitudes ||a|| and ||b|| are always positive for non-zero vectors, the arithmetic sign of a · b depends entirely on cos(θ), categorizing the relationship into three distinct angular regimes:

a · b > 0 (Positive)

Acute Angle (θ < 90°)

Both vectors point generally in the same direction. The cosine of an acute angle is positive.

a · b = 0 (Zero)

Orthogonal (θ = 90°)

The vectors are strictly perpendicular. Because cos(90°) = 0, their scalar product vanishes completely.

a · b < 0 (Negative)

Obtuse Angle (θ > 90°)

The vectors point in opposing directions. The cosine of an obtuse angle is negative.

The Cauchy-Schwarz Inequality & Fundamental Properties

The dot product satisfies several vital algebraic laws that make vector spaces mathematically rigorous:

Commutativity: a · b = b · a
Distributivity: a · (b + c) = (a · b) + (a · c)
Scalar Multiplication: (ca) · b = c(a · b)
Magnitude Relation: a · a = ||a||² ≥ 0

Connecting these properties leads to one of the most celebrated theorems in all of mathematics: the Cauchy-Schwarz Inequality:

|a · b| ≤ ||a|| × ||b||

Equality holds if and only if vectors a and b are linearly dependent (parallel or anti-parallel).

Scalar & Vector Projections in Physics and 3D Space

A fundamental application of the dot product is computing the "shadow" or component of one vector cast onto another (for dedicated step-by-step orthogonal decompositions, explore our Vector Projection Calculator):

Scalar Projection (Component)

The signed length of vector a in the direction of vector b:

comp_b(a) = (a · b) / ||b||

Outputs a scalar number representing magnitude along line b.

Vector Projection

The actual vector pointing along b with length equal to the scalar projection:

proj_b(a) = [ (a · b) / ||b||² ] × b

Outputs a vector collinear with vector b.

Cosine Similarity in Machine Learning & Embeddings

In contemporary artificial intelligence, large language models (LLMs) and neural networks map words, code, and documents into high-dimensional vector spaces (frequently 768 to 3,072 dimensions).

To determine whether two passages of text share similar semantic meaning, engineers evaluate the Cosine Similarity between their embedding vectors using the normalized dot product:

Cosine Similarity(u, v) = (u · v) / (||u|| × ||v||)

Returns +1 for identical direction (identical meaning), 0 for orthogonal (unrelated), and -1 for opposing direction.

Because modern AI vector databases (such as Vectorize or Pinecone) store unit-normalized vectors (||u|| = 1), calculating cosine similarity reduces to a pure hardware-accelerated dot product: Similarity = u · v. When computing similarity across thousands of candidate document vectors simultaneously, this operation corresponds directly to row-column inner products implemented in our Matrix Multiplication Calculator and general Matrix Calculator.

Engineering Applications: Lighting, Mechanics & Graphics

3D Computer Graphics

Lambertian diffuse shading computes N · L (surface normal dot light direction) for billions of pixels every second in video games to shade 3D polygons realistically.

Classical Physics

Mechanical work is defined as W = F · d. If force is exerted perpendicular to motion (such as centripetal force in planetary orbits), no mechanical work is performed.

Aerospace Navigation

Inertial navigation platforms and flight guidance systems take dot products between attitude sensors and Earth's gravitational vector to calculate pitch, roll, and course deviation.

Step-by-Step Worked Examples in 2D and 3D

Example 1: 2D Perpendicular Verification Difficulty: Fundamental

Calculate the dot product of a = ⟨3, 4⟩ and b = ⟨-4, 3⟩.

1. Multiply x-components: 3 × (-4) = -12.
2. Multiply y-components: 4 × 3 = 12.
3. Sum products: -12 + 12 = 0.
Result: a · b = 0 → The vectors are exactly orthogonal (90° perpendicular).
Example 2: 3D Angle and Projection Calculation Difficulty: Intermediate

Given a = ⟨1, 2, 3⟩ and b = ⟨4, -1, 2⟩, find a · b and the angle θ.

1. Dot product: (1 × 4) + (2 × -1) + (3 × 2) = 4 - 2 + 6 = 8.
2. Magnitudes: ||a|| = √(1 + 4 + 9) = √14 ≈ 3.742; ||b|| = √(16 + 1 + 4) = √21 ≈ 4.583.
3. Cosine of angle: cos(θ) = 8 / (√14 × √21) = 8 / √294 ≈ 8 / 17.146 ≈ 0.4666.
4. Angle θ: arccos(0.4666) ≈ 62.19° (1.085 radians).
Result: a · b = 8 (Acute angle θ = 62.19°).

Common Calculation Pitfalls & Cross Product Confusion

Expecting a Vector Output

The dot product is a scalar, not a vector. The answer is a single number (e.g. 5), never a tuple like ⟨3, -8, 10⟩. For a vector output perpendicular to both 3D vectors, use our Cross Product Calculator.

Dimensional Incompatibility

You cannot take the dot product of a 2D vector with a 3D vector directly. Either embed the 2D vector into 3D by setting z = 0 or restrict computation to 2 dimensions.

Orthogonal Eigenspaces

In linear algebra and spectral analysis, symmetric transformation matrices produce mutually orthogonal eigenvectors (v_1 · v_2 = 0). To explore these bases, visit our comprehensive Eigenvalue & Eigenvector Calculator.

Assuming Scalar Associativity

Writing (a · b) · c is mathematically meaningless because a · b is a scalar, and you cannot take the dot product of a scalar with a vector c.

Fact-Checked & Verified • Computational Accuracy Standards
Updated September 2026 • Editorial Policy
Authored By
Sanjay Samanta

Lead Developer & Founder of Basic Math Tools. Specializes in browser-native computational algorithms and applied mathematics.

Reviewed & Verified By
Academic Review Board

Mathematics & curriculum specialists. Audited against standard algebraic and arithmetic principles.

Found an error or have an improvement suggestion? Report a calculation issue

Frequently Asked Questions

What is the dot product (scalar product) of two vectors?
The dot product (also known as the scalar product) is an algebraic operation that takes two equal-length coordinate vectors and returns a single scalar number. It measures the extent to which two vectors point in the same direction, combining their magnitudes and the cosine of the angle between them.
What are the two ways to calculate the dot product (algebraic vs geometric)?
1) Algebraic Form (Component-Wise): a · b = (a_x × b_x) + (a_y × b_y) + (a_z × b_z). 2) Geometric Form: a · b = ||a|| × ||b|| × cos(θ), where ||a|| and ||b|| are the Euclidean vector lengths and θ is the angle between them (0° ≤ θ ≤ 180°).
How do you find the angle θ between two vectors using the dot product?
Rearrange the geometric dot product formula to solve for cos(θ): cos(θ) = (a · b) / (||a|| × ||b||). Taking the inverse cosine yields θ = arccos[(a · b) / (||a|| × ||b||)].
What does it mean if the dot product of two non-zero vectors is zero?
If a · b = 0 for non-zero vectors, the vectors are orthogonal (perpendicular), meaning the angle between them is exactly 90° (π/2 radians) because cos(90°) = 0.
What is the difference between the dot product and the cross product?
The dot product (a · b) produces a scalar number (a magnitude with no direction) and applies to vectors of any dimension (2D, 3D, n-D). The cross product (a × b) produces a new 3D vector perpendicular to both input vectors, whose magnitude equals the area of the parallelogram formed by the two vectors.
How is the dot product used in machine learning and cosine similarity?
In modern AI, high-dimensional vector embeddings represent words, sentences, or concepts. Cosine similarity—calculated by dividing the dot product of two embedding vectors by the product of their magnitudes—measures their semantic closeness on a scale from -1 to 1.