What the Dot Product Measures
The dot product (also called the scalar product) combines two vectors and returns a single number. The simplest way to understand it is as an alignment score. When two vectors point in the same general direction, the dot product is positive and often large. When they point in opposite directions, the dot product is negative. When they are perpendicular, the dot product is zero (as long as neither vector is the zero vector).
Dot products appear in geometry, physics, computer graphics, and data science because they connect direction, magnitude, and angle in one compact operation. The Dot Product Calculator computes A·B, the cosine of the angle, the angle itself, and projection components for both 2D and 3D vectors.
Dot Product Formula in 2D and 3D
If A = ⟨a₁, a₂⟩ and B = ⟨b₁, b₂⟩ in 2D, then A·B = a₁b₁ + a₂b₂. In 3D, if A = ⟨a₁, a₂, a₃⟩ and B = ⟨b₁, b₂, b₃⟩, the dot product extends naturally: A·B = a₁b₁ + a₂b₂ + a₃b₃.
A · B = a₁b₁ + a₂b₂ (+ a₃b₃ in 3D)
This definition is component-based and easy to compute. But the dot product also has a powerful geometric meaning through the angle relationship, which explains why it is so widely used.
Angle Relationship and Cosine Similarity
The dot product connects directly to the angle θ between vectors: A · B = |A||B|cos(θ). Rearranging gives cos(θ) = (A·B)/(|A||B|). This ratio is often called cosine similarity because it measures similarity of direction while ignoring scale. It ranges from −1 to 1:
- cos(θ) ≈ 1 means vectors are strongly aligned (same direction)
- cos(θ) ≈ 0 means vectors are roughly perpendicular (no directional alignment)
- cos(θ) ≈ −1 means vectors are opposed (opposite direction)
cos(θ) = (A·B) / (|A||B|), θ = arccos(cos(θ))
The calculator returns both cos(θ) and θ. If either vector has magnitude zero, the angle is undefined because direction is not defined for the zero vector.
Orthogonality Test: When A·B = 0
One of the most practical uses of the dot product is checking perpendicularity. If A·B = 0 and both vectors are nonzero, then A and B are orthogonal. This is a common technique in coordinate geometry to confirm right angles, verify perpendicular lines, and validate normal vectors.
In numeric problems, rounding may produce values very close to zero rather than exactly zero. This calculator reports a practical orthogonality note using a small tolerance instead of requiring perfect equality.
Work in Physics: Force · Displacement
In physics, work is defined as W = F · d, where F is a force vector and d is a displacement vector. This formula reveals a key interpretation: only the component of force in the direction of motion contributes to work. If the force is perpendicular to the displacement, the dot product is zero and no work is done (for example, a centripetal force in uniform circular motion does no work on the object’s speed).
This same idea generalizes to many fields: whenever you want the “effective component” of one vector along another, dot products are the natural tool.
Scalar Projection: How Much of A Lies Along B
The scalar projection of A onto B is the signed length of A in the direction of B. It is also called the component of A along B and is written compB(A). You compute it using: compB(A) = (A·B)/|B|, assuming B is nonzero.
compB(A) = (A·B) / |B|
The sign is important. If A points generally in the direction of B, the scalar projection is positive. If A points generally opposite B, it becomes negative. This is why scalar projection is useful for signed component analysis.
Vector Projection and Decomposition
The vector projection projB(A) is a vector that lies along B and represents the parallel component of A in the B direction. A standard formula is: projB(A) = ((A·B)/(B·B))B, assuming B is nonzero.
projB(A) = ((A·B)/(B·B)) B
Once you have the projection, you can split A into a parallel part and a perpendicular part: A = projB(A) + (A − projB(A)). The term A − projB(A) is the perpendicular component. This decomposition is used in geometry, engineering, and algorithms such as Gram–Schmidt orthogonalization.
Dot Tables: Studying Scaling and Similarity
The Dot Table tab is designed for exploration. It builds a table of dot products for scaled versions of vectors: (kA)·(mB) across a range of k values. This helps you see how dot products scale and how cosine similarity behaves under scaling. In particular:
- Dot products scale with magnitude: (kA)·(mB) = km(A·B)
- Cosine similarity does not depend on scalar scale (when both vectors remain nonzero)
Export the table to CSV if you want to graph values, compare scenarios, or include results in reports and homework.
Input Tips and Common Mistakes
Use 2D mode for ⟨x,y⟩ vectors and 3D mode for ⟨x,y,z⟩ vectors. If you switch to 2D, z is treated as 0. Keep units consistent. For example, do not mix meters and centimeters without converting. Remember that angles are undefined if either vector is the zero vector. Projections are undefined if the target vector (the one you project onto) is the zero vector.
If you are using the dot product to check orthogonality, do not rely on exact equality in floating-point problems. Treat values that are extremely close to zero as effectively perpendicular, especially when inputs were rounded.
FAQ
Dot Product Calculator – Frequently Asked Questions
Answers about dot products, cosine similarity, angles, orthogonality, projections, and exporting dot tables.
The dot product (also called the scalar product) multiplies two vectors to produce a single number: A·B = a1b1 + a2b2 (+ a3b3 in 3D). It measures alignment between vectors.
If A·B = 0 (and both vectors are nonzero), the vectors are perpendicular (orthogonal). This is a common test for right angles in geometry and physics.
Use cos(θ) = (A·B)/(|A||B|). Then θ = arccos(cos(θ)). The calculator returns θ in degrees and radians.
Cosine similarity is the dot product of normalized vectors. It equals cos(θ) and ranges from −1 to 1, showing how similar directions are regardless of magnitude.
The scalar projection is the signed length of A in the direction of B: comp_B(A) = (A·B)/|B|, when B is nonzero.
The vector projection is the actual vector component of A along B: proj_B(A) = ((A·B)/(B·B))B, when B is nonzero.
It is used to compute work (force · displacement), find angles, determine orthogonality, project vectors onto directions, and measure similarity in graphics and machine learning.
Yes. Switch between 2D and 3D modes. In 2D mode, z is treated as 0 automatically.
Yes. You can generate a table of dot products across scalar combinations and export it as CSV for spreadsheet analysis or plotting.