Dot Product Calculator

Calculate the scalar product of two vectors in 2D, 3D or any matching dimension. See magnitudes, angle, cosine similarity, orthogonality, scalar projection, vector projection and the exact component-by-component sum.

Vector A

Vector B

Vector A

Vector B

Vector A components

Vector B components

Vector magnitudes

Included angle

Dot product result

Magnitude |A|0
Magnitude |B|0
Angle θ
Dot product A · B0

Enter two vectors with matching dimensions. The dot product is a scalar: multiply corresponding components and add the products.

Calculation breakdown

Vector A0
Vector B0
Component products0
Cosine similarity0
Relationship0
Scalar projection of A onto B0
Vector projection of A onto B0

Transparent formula

A · B = Σ aᵢbᵢ

0

projᵦ(A) = (A·B / |B|²)B

2D vector sketch

Visual aid only. The numeric calculation is authoritative.

What is a dot product?

The dot product, also called the scalar product, combines two vectors of the same dimension and returns one number. Algebraically, you multiply matching components and add the results. Geometrically, the same number connects the vectors' lengths with the cosine of the angle between them.

A · B = Σ aᵢbᵢ = |A||B|cos(θ)

That dual interpretation is why the dot product is so useful. It can answer an arithmetic question, reveal whether vectors are perpendicular, recover the angle between directions, measure directional alignment and build vector projections.

Dot product formula in 2D

For A = ⟨a₁,a₂⟩ and B = ⟨b₁,b₂⟩:

A · B = a₁b₁ + a₂b₂

For A = ⟨3,4⟩ and B = ⟨5,2⟩, the component products are 3×5 = 15 and 4×2 = 8. Add them:

A · B = 15 + 8 = 23

The answer is 23, a scalar—not another two-dimensional vector.

Dot product formula in 3D

For A = ⟨a₁,a₂,a₃⟩ and B = ⟨b₁,b₂,b₃⟩:

A · B = a₁b₁ + a₂b₂ + a₃b₃

Example: A = ⟨1,2,3⟩ and B = ⟨4,−1,2⟩:

A · B = 1(4) + 2(−1) + 3(2) = 4 − 2 + 6 = 8

Dot product in n dimensions

The definition does not stop at three dimensions. If two real vectors each contain n components, their Euclidean dot product is the sum of n matching products:

A · B = a₁b₁ + a₂b₂ + … + aₙbₙ

This calculator's n-dimensional mode accepts comma-separated vectors, provided both vectors contain the same number of finite real components.

Why the vectors must have the same dimension

The ordinary coordinate dot product pairs every component of A with the corresponding component of B. If one vector has four components and the other has three, there is no one-to-one matching across all positions. The calculator therefore rejects mismatched dimensions instead of silently dropping data.

Geometric formula and the angle between vectors

The dot product also satisfies:

A · B = |A||B|cos(θ)

For nonzero vectors, rearrange to find the angle:

θ = cos⁻¹((A · B)/(|A||B|))

The standard angle between real nonzero vectors is taken from 0° to 180°. The calculator reports that principal angle.

Worked angle example

Suppose A = ⟨1,0⟩ and B = ⟨1,1⟩. Their dot product is 1. The magnitudes are |A| = 1 and |B| = √2, so:

cos(θ) = 1/√2 ≈ 0.7071

Taking inverse cosine gives θ = 45°. This matches the geometry: the second vector lies halfway between the positive x- and y-directions.

What does the sign of a dot product mean?

Dot productAngle for nonzero vectorsGeometric interpretation
A · B > 0Less than 90°Acute angle; directions are generally aligned
A · B = 090°Orthogonal/perpendicular
A · B < 0Greater than 90°Obtuse angle; directions are generally opposed

The sign says something about directional relationship, but the raw dot-product size also depends on vector magnitudes. That is why a normalized quantity such as cosine similarity is useful when direction alone matters.

Orthogonal vectors and zero dot product

Two nonzero vectors are orthogonal if their dot product is zero. For example:

⟨2,3⟩ · ⟨−3,2⟩ = 2(−3) + 3(2) = −6 + 6 = 0

So the vectors are perpendicular. In numerical computation, values extremely close to zero can occur because of floating-point rounding, so software normally uses a small tolerance when classifying approximate orthogonality.

The zero-vector exception

The zero vector has magnitude zero. Its dot product with every vector is zero, but the angle between the zero vector and another vector is undefined because the angle formula would divide by |A||B| = 0.

Important: “dot product equals zero” implies a 90° angle only when both vectors are nonzero. If either vector is zero, the calculator leaves the angle and normalized directional quantities undefined rather than showing a misleading 90°.

Vector magnitude

The Euclidean magnitude of A = ⟨a₁,…,aₙ⟩ is:

|A| = √(a₁² + a₂² + … + aₙ²)

Magnitude matters because the dot product blends both length and direction. Doubling A while leaving B unchanged doubles A · B.

Cosine similarity

For nonzero vectors, the normalized dot product is:

cosine similarity = (A · B)/(|A||B|)

Its value lies between −1 and 1 for real Euclidean vectors. A value near 1 indicates similar direction, 0 indicates orthogonality, and a value near −1 indicates opposite direction.

Unlike the raw dot product, cosine similarity removes vector magnitude. This makes it useful when orientation or pattern is more important than absolute scale.

Scalar projection of A onto B

The scalar projection, sometimes called the scalar component of A along B, is:

compᵦ(A) = (A · B)/|B|

It is a signed scalar. A positive value points along B's direction, while a negative value means A has a component opposite B's direction. The scalar projection is undefined if B is the zero vector.

Vector projection of A onto B

The vector projection is the actual vector lying along B:

projᵦ(A) = ((A · B)/|B|²)B

For A = ⟨3,4⟩ and B = ⟨1,0⟩, A · B = 3 and |B|² = 1, giving:

projᵦ(A) = 3⟨1,0⟩ = ⟨3,0⟩

This is the “shadow” of A on the line spanned by B.

Projection direction matters

Projecting A onto B is generally not the same as projecting B onto A. The target vector determines the line onto which the other vector is projected:

projᵦ(A) = ((A·B)/|B|²)B projₐ(B) = ((A·B)/|A|²)A

The dot product itself is symmetric—A · B = B · A—but projection is not.

Dot product from magnitudes and angle

If the vector components are unknown but the two magnitudes and included angle are known, use the geometric definition directly:

A · B = |A||B|cos(θ)

For |A| = 6, |B| = 8 and θ = 60°:

A · B = 6 × 8 × cos(60°) = 48 × 0.5 = 24

This mode does not determine the unique vector components or projections, because many different vector pairs can share the same magnitudes and angle.

Parallel and opposite vectors

For nonzero vectors pointing in exactly the same direction, θ = 0° and cos θ = 1, so:

A · B = |A||B|

For exactly opposite directions, θ = 180° and cos θ = −1:

A · B = −|A||B|

Those are the maximum positive and minimum negative dot products possible for fixed vector magnitudes.

Cauchy–Schwarz and why cosine stays between −1 and 1

The Cauchy–Schwarz inequality states:

|A · B| ≤ |A||B|

For nonzero vectors, divide by |A||B| to obtain:

−1 ≤ (A · B)/(|A||B|) ≤ 1

This guarantees that the ratio used by the angle formula belongs to the cosine range. In floating-point arithmetic, tiny rounding can produce a value such as 1.0000000000000002, so robust software clamps the ratio to [−1,1] before applying arccos.

Dot product and work in physics

For a constant force F acting through displacement d, mechanical work is:

W = F · d = |F||d|cos(θ)

Only the component of force along the displacement contributes to work. A force perpendicular to the displacement contributes zero work in this idealized constant-force dot-product model.

Dot product in computer graphics

Graphics calculations use dot products for lighting, visibility, orientation and projection. For unit vectors, the dot product equals cos θ directly. A surface normal and a light direction with a larger positive dot product are more closely aligned under simple diffuse-lighting models.

Practical graphics systems may use additional conventions such as normalized vectors, handedness and clamping. The underlying dot-product arithmetic remains the same.

Dot product in data science and machine learning

High-dimensional feature vectors often use dot products inside similarity, linear models and matrix multiplication. Cosine similarity normalizes the dot product by vector lengths, separating direction from magnitude.

Interpretation still depends on feature construction. A mathematically high cosine similarity does not automatically imply semantic similarity unless the vector representation is designed so that geometric proximity carries that meaning.

Dot product versus cross product

The dot product returns a scalar and is defined for same-length coordinate vectors in any finite dimension. The familiar three-dimensional cross product returns a vector perpendicular to both inputs and is a different operation.

Do not confuse the symbols or expected output. If your problem asks for a single scalar, an angle, orthogonality or projection, the dot product is often the relevant operation.

Dot product versus component-wise multiplication

Component-wise multiplication of ⟨a₁,a₂⟩ and ⟨b₁,b₂⟩ produces ⟨a₁b₁,a₂b₂⟩. The dot product goes one step further and sums those component products:

⟨a₁b₁,a₂b₂⟩ → a₁b₁ + a₂b₂

This distinction is essential in programming and data work, where both operations may exist.

Can dot products have units?

Yes. The units multiply. If force is measured in newtons and displacement in metres, F · d has units of newton-metres, which correspond to joules for mechanical work. If both vectors are abstract dimensionless coordinates, the result may be dimensionless.

The calculator does not impose a unit system because vectors can represent many kinds of quantities. Use internally consistent units appropriate to the problem.

Common dot-product mistakes

How to verify a dot-product calculation

For coordinate input, multiply each matching pair and inspect the component products before adding them. Then independently compare the geometric identity A · B = |A||B|cos θ if you have the angle.

Special cases are also useful checks: perpendicular nonzero vectors should produce zero, equal-direction unit vectors should produce one, and a vector dotted with itself should equal the square of its magnitude:

A · A = |A|² ≥ 0

Frequently asked questions

What is the dot product formula?

For coordinates, A · B = Σaᵢbᵢ. Geometrically, A · B = |A||B|cos θ.

Is a dot product a vector?

No. The ordinary Euclidean dot product returns a scalar.

How do I know if two vectors are perpendicular?

If both vectors are nonzero and their dot product is zero, they are orthogonal.

Can I calculate a dot product in more than three dimensions?

Yes. The same sum-of-component-products definition applies to equal-length real vectors in n dimensions.

How do I find the angle between vectors?

For nonzero vectors, θ = arccos((A · B)/(|A||B|)).

What happens if one vector is zero?

The dot product is still zero, but the angle, cosine similarity and any projection onto the zero vector are undefined.

What is cosine similarity?

It is the normalized dot product (A · B)/(|A||B|), which compares direction while removing magnitude.

What is the projection of A onto B?

projᵦ(A) = ((A · B)/|B|²)B, provided B is nonzero.

Can I use negative and decimal components?

Yes. The calculator accepts finite signed real values.

Why does the calculator show an undefined angle?

That occurs when at least one input vector has zero magnitude, so the angle formula would divide by zero.

Final note: the dot product is simple to compute but rich in meaning. For coordinate vectors, inspect the component products and their sum first; then use magnitudes and angle, cosine similarity, orthogonality and projections only when their denominators are defined. This calculator keeps those distinctions visible so a special case cannot quietly turn into a misleading result.