Home/Math/Dot Product Calculator
Math

Dot Product Calculator

Vector A
Separate values with commas or spaces
Vector B
About this tool

Multiply two vectors element by element

The Dot Product Calculator computes the scalar (inner) product of two vectors: multiply each pair of corresponding components, then add the results. It's a fundamental operation in linear algebra, physics, computer graphics, and machine learning — from projecting forces to computing neural network activations.

Unlike the cross product, the dot product returns a single number, not a vector. Its sign tells you about direction: positive means the vectors point broadly the same way, zero means they are perpendicular, and negative means they oppose each other.

Formula

A · B = a₁b₁ + a₂b₂ + … + aₙbₙ
Equivalently, A · B = |A| × |B| × cos(θ), where θ is the angle between the vectors.

This calculator also returns both magnitudes, the angle between the vectors, and the cosine similarity — the normalised version of the dot product used throughout machine learning and NLP.

Example

Vector A: [1, 2, 3] — Vector B: [4, 5, 6].

A · B = (1×4) + (2×5) + (3×6) = 4 + 10 + 18 = 32.

Since 32 > 0, the vectors point in a broadly similar direction. The angle between them is ≈ 12.93°.

FAQ

Frequently Asked Questions

What is a dot product?

The dot product (also called scalar product or inner product) multiplies two vectors component by component and sums the results, producing a single number. For A = [1, 2] and B = [3, 4]: A · B = 1×3 + 2×4 = 11.

What is the formula for the dot product?

A · B = a₁b₁ + a₂b₂ + … + aₙbₙ. Geometrically, it also equals |A| × |B| × cos(θ), where |A| and |B| are the vector magnitudes and θ is the angle between them.

What does a dot product of zero mean?

The vectors are orthogonal (perpendicular) — they share no directional component at all. This is why the dot product is used to test perpendicularity: if A · B = 0 and neither vector is zero, the angle between them is exactly 90°.

Can a dot product be negative?

Yes. A negative dot product means the angle between the vectors is greater than 90° — they point in broadly opposing directions. The minimum occurs at 180°, when the vectors are exactly opposite.

What is the difference between dot product and cross product?

The dot product returns a scalar (a single number) and measures how aligned two vectors are. The cross product returns a new vector perpendicular to both inputs and only exists in 3D (and 7D). Use dot for projections and angles, cross for normals and torque.

How do I find the angle between two vectors using the dot product?

Rearrange the geometric formula: θ = arccos( (A · B) / (|A| × |B|) ). Compute the dot product, divide by the product of the magnitudes, then take the inverse cosine. This calculator does that automatically.

What is the dot product used for in machine learning?

Almost everything: a neuron's pre-activation is the dot product of weights and inputs; attention scores in transformers are scaled dot products of query and key vectors; and similarity search compares embeddings via dot products or their normalised form, cosine similarity.

How is the dot product related to cosine similarity?

Cosine similarity is the dot product divided by the product of both magnitudes: cos(θ) = (A · B) / (|A| × |B|). If both vectors are unit length, the dot product IS the cosine similarity. See our cosine similarity calculator for the normalised version.

Do both vectors need the same number of components?

Yes. The dot product is only defined for vectors of equal dimension — each component of A must have a partner in B. This calculator will warn you if the two vectors have different lengths.

What is the dot product of a vector with itself?

A · A = |A|², the squared magnitude (length) of the vector. This is why the Euclidean norm is defined as |A| = √(A · A) — take the dot product with itself and square-root it.

What is the dot product in physics?

Work is the classic example: W = F · d, the dot product of force and displacement. Only the component of force along the direction of motion does work — which is exactly what the dot product extracts. Power (F · v) works the same way.

How do I calculate the dot product of 3D vectors?

Same rule, three terms: [a₁, a₂, a₃] · [b₁, b₂, b₃] = a₁b₁ + a₂b₂ + a₃b₃. For example [2, 0, 1] · [1, 3, 4] = 2 + 0 + 4 = 6. Enter the components above separated by commas.