Dot Product — Formula, Projection, Angle, Examples
Dot Product — Formula, Projection, Angle, Examples
TL;DR
The dot product of two vectors multiplies them into a single number, defined two equivalent ways:
(\vec{a} \cdot \vec{b} = |\vec{a}| |\vec{b}| \cos \theta ) (geometric) and (\vec{a}\cdot\vec{b} = a_1 b_1 + a_2 b_2 + a_3 b_3 ) (component). This article covers both formulas, the projection of one vector onto another, the angle between two vectors, every key property, and six worked examples.
BT
Last updated on June 10, 2026
9 min read
What Is the Dot Product?
The dot product of two vectors (\vec{a}) and (\vec{b}) is a scalar — a single number — equal to the product of their magnitudes and the cosine of the angle between them. It is also called the scalar product, precisely because the answer is a scalar and not a vector. It is written with a centred dot, (\vec{a} \cdot \vec{b}), which is where the name comes from.
Unlike adding or subtracting vectors, the dot product does not give you back a vector. It gives a number that measures direction-agreement: positive when the vectors point broadly the same way, negative when they point apart, and exactly zero when they meet at a right angle. The dot product is one of the two ways to take a product of vectors — the other being the cross product, which returns a vector instead.
What Is the Dot Product Formula?
There are two formulas, and they always give the same answer. Which one you use depends on what the problem hands you.
Geometric form — use it when you know the magnitudes and the angle:
[\vec{a} \cdot \vec{b} = |\vec{a}| |\vec{b}| \cos \theta ]
where (|\vec{a}|) and (|\vec{b}|) are the magnitudes (lengths) of the vectors and (\theta) is the angle between them.
Component form — use it when you know the coordinates. For (\vec{a}=(a_1,a_2,a_3)) and (\vec{b}=(b_1,b_2,b_3)):
[\vec{a} \cdot \vec{b} = a_1 b_1 + a_2 b_2 + a_3 b_3.]
Multiply matching components, add the results. In two dimensions you simply drop the third term. The two formulas are connected by the law of cosines, which is also why the dot product quietly proves the Pythagorean theorem when the vectors are perpendicular.
Why is there a cosine in the dot product?
Because cosine is the function that measures agreement. At 0° (same direction) (\cos\theta=1), the largest value — full agreement. At 90° (perpendicular) (\cos\theta=0) — no agreement. At 180° (opposite) (\cos\theta=-1) — full disagreement. The cosine slides smoothly from +1 down to −1 as the vectors swing apart, so (|\vec{a}| |\vec{b}| \cos\theta) reads off exactly how aligned they are, scaled by their lengths.
How Do You Find the Angle Between Two Vectors?
Rearrange the geometric formula to solve for the angle. Since (\vec{a} \cdot \vec{b} = |\vec{a}| |\vec{b}| \cos \theta), dividing both sides by the magnitudes isolates the cosine: [\cos\theta = \frac{\vec{a}\cdot\vec{b}}{|\vec{a}||\vec{b}|}, \qquad \theta = \arccos\left(\frac{\vec{a}\cdot\vec{b}}{|\vec{a}||\vec{b}|}\right).] Compute the dot product from components, compute each magnitude, divide, and take the inverse cosine. This single relationship is why the dot product is the standard tool for "find the angle between" problems.
What Is Vector Projection?
The projection of (\vec{a}) onto (\vec{b}) is the shadow (\vec{a}) casts along the direction of (\vec{b}) — how much of (\vec{a}) points the way (\vec{b}) does. It comes in two flavors.
Scalar projection (the length of the shadow):
[\text{comp}_{\vec{b}}\vec{a} = \frac{\vec{a}\cdot\vec{b}}{|\vec{b}|}.]Vector projection (the shadow as an actual vector):
[\text{proj}_{\vec{b}}\vec{a} = \left(\frac{\vec{a}\cdot\vec{b}}{|\vec{b}|^2}\right)\vec{b}.]
The work example from the hook is a projection in disguise: the part of the force that does work is the projection of the force onto the direction of motion. Projection is where the dot product stops being a definition and starts being a workhorse — it powers everything from physics work calculations to the cosine similarity behind search and recommendation systems.
What Are the Properties of the Dot Product?
The dot product obeys a short, clean list of rules. Each one is worth knowing because it lets you rearrange expressions without recomputing from scratch.
- Commutative:
(\vec{a}\cdot\vec{b} = \vec{b}\cdot\vec{a}). Order doesn't matter. - Distributive over addition:
(\vec{a}\cdot(\vec{b}+\vec{c}) = \vec{a}\cdot\vec{b} + \vec{a}\cdot\vec{c}). - Scalar multiplication:
((k\vec{a})\cdot\vec{b} = k(\vec{a}\cdot\vec{b})) for any scalar (k). - Self-dot gives magnitude squared:
(\vec{a}\cdot\vec{a} = |\vec{a}|^2). This is how the dot product computes lengths. - Zero for perpendicular vectors:
(\vec{a}\cdot\vec{b} = 0) when (\vec{a}) and (\vec{b}) are orthogonal. - Unit vectors:
(\hat{i}\cdot\hat{i} = \hat{j}\cdot\hat{j} = \hat{k}\cdot\hat{k} = 1), while (\hat{i}\cdot\hat{j} = \hat{j}\cdot\hat{k} = \hat{i}\cdot\hat{k} = 0). These six facts are what the component formula is built from.
Examples of Dot Product
Example 1
Find the dot product of (\vec{a}=(2,3,1)) and (\vec{b}=(4,-1,5)).
Multiply matching components and add:
[\vec{a}\cdot\vec{b} = (2)(4)+(3)(-1)+(1)(5) = 8 - 3 + 5 = 10.]
Final answer: (\vec{a}\cdot\vec{b} = 10).
Positive, so the two vectors point broadly the same way.
Example 2
Find (\vec{a}\cdot\vec{b}) for (\vec{a}=(3,-2)) and (\vec{b}=(-1,4)).
Wrong attempt. A student multiplies the components but drops the sign on the second term:
[(3)(-1) + (2)(4) = -3 + 8 = 5.]
Test it against meaning.
Correct. Keep every sign:
[\vec{a}\cdot\vec{b} = (3)(-1) + (-2)(4) = -3 - 8 = -11.]
Final answer: (\vec{a}\cdot\vec{b} = -11).
The negative sign says the vectors point more apart than together.
Example 3
Are (\vec{a}=(2,-1,3)) and (\vec{b}=(1,5,1)) perpendicular?
A zero dot product means perpendicular. Compute it:
[\vec{a}\cdot\vec{b} = (2)(1) + (-1)(5) + (3)(1) = 2 - 5 + 3 = 0.]
Final answer: the dot product is 0, so yes — the vectors are perpendicular.
Example 4
Find the angle between (\vec{a}=(1,2,2)) and (\vec{b}=(2,0,1)).
Dot product:
[\vec{a}\cdot\vec{b} = (1)(2) + (2)(0) + (2)(1) = 4.]
Magnitudes:
(|\vec{a}| = \sqrt{1^2 + 2^2 + 2^2} = 3)
and (|\vec{b}| = \sqrt{2^2 + 0^2 + 1^2} = \sqrt{5}).
Then:
[\cos\theta = \frac{4}{3\sqrt{5}} \approx 0.596, \qquad \theta = \arccos(0.596) \approx 53.4°.]
Final answer: (\theta \approx 53.4°).
Example 5
Find the scalar and vector projection of (\vec{a}=(4,3)) onto (\vec{b}=(2,0)).
Dot product:
[\vec{a}\cdot\vec{b} = (4)(2)+(3)(0) = 8.]
Magnitude of (\vec{b}): (|\vec{b}| = 2), so (|\vec{b}|^2=4).
Scalar projection:
[\text{comp}_{\vec{b}}\vec{a} = \frac{8}{2} = 4.]
Vector projection:
[\text{proj}_{\vec{b}}\vec{a} = \frac{8}{4}(2, 0) = 2(2, 0) = (4, 0).]
Final answer: scalar projection 4, vector projection (4,0).
Example 6
A force (\vec{F}=(12,5)) moves an object along displacement (\vec{d}=(3,0)). Find the work done.
Work is force dotted with displacement:
[W = \vec{F} \cdot \vec{d} = (12)(3) + (5)(0) = 36 + 0 = 36 J.]
Final answer: 36 joules.
Why the Dot Product Earns Its Place
"How much of this effort actually moves the load?"
The dot product was distilled from the quaternions that William Rowan Hamilton built in 1843. By the 1880s Josiah Willard Gibbs had separated out the clean scalar product we use now, because physics kept needing the same single number — how much one quantity acts along another.
Where it does real work today:
- Physics — work and energy. Work is the dot product of force and displacement.
- Computer graphics and lighting. A surface looks bright when its normal vector points toward the light.
- Machine learning and search. Cosine similarity — the dot product of two normalized vectors — measures how alike two documents, images, or word-embeddings are.
Where Students Trip Up on the Dot Product
Mistake 1: Expecting a vector instead of a scalar
Where it slips in: A student finishes a dot product and writes the answer as a vector instead of summing to a single number. Correct: Add the three products into a single number: 8−3+5=10.
Mistake 2: Dropping a negative sign
Where it slips in: Multiplying components when one or more is negative, the rusher writes ((3)(-1)+(2)(4)) instead of ((3)(-1)+(-2)(4)).
Correct: Carry every sign through.
(\vec{a}\cdot\vec{b} = (3)(-1) + (-2)(4) = -11.)
Mistake 3: Confusing perpendicular and parallel conditions
Where it slips in: Reasoning that a zero dot product means the vectors are parallel. Correct: A zero dot product means perpendicular (cos 90° = 0).
Key Takeaways
- The dot product of two vectors is a scalar:
(\vec{a}\cdot\vec{b} = |\vec{a}| |\vec{b}| \cos \theta = a_1 b_1 + a_2 b_2 + a_3 b_3.) - Use the geometric form when you have magnitudes and an angle; use the component form when you have coordinates.
- A zero dot product means the vectors are perpendicular.
- Rearranging the formula gives the angle between two vectors via (\cos\theta = \frac{\vec{a}\cdot\vec{b}}{|\vec{a}| |\vec{b}|}).
- Vector projection is built directly on the dot product.
Practice These Before Moving On
- Find the dot product of (\vec{a}=(1,-3,2)) and (\vec{b}=(4,1,-2)).
- Find the angle between (\vec{a}=(1,0)) and (\vec{b}=(1,3)).
- Find the vector projection of (\vec{a}=(5,2)) onto (\vec{b}=(0,4)).