Skip to content
MasterMath

Dot Product Calculator

The dot product of two vectors, plus the angle between them. A dot product of zero means perpendicular, whatever the dimension.

Dot product

—

Dot product—
Angle between them—
Relationship—
Magnitude of A—
Magnitude of B—
Projection of A onto B—

How this was worked out

    The formula

    a · b = Σ aᵢbᵢ = |a||b|cos θ

    What it means

    The dot product has two equivalent definitions, and their equality is the useful fact. Component by component it is trivial to compute; geometrically it is the magnitudes times the cosine of the angle. Setting them equal is how you extract the angle.

    How to do it by hand

    1. Multiply the vectors component by component
    2. Add all the products: that is the dot product
    3. Divide by the two magnitudes to get the cosine of the angle
    4. Take the arccosine for the angle itself

    What is worth knowing

    The sign alone tells you a lot: positive means the vectors point broadly the same way, negative means broadly opposite, and zero means exactly perpendicular. That zero test works in any number of dimensions, which is why the dot product is the workhorse of similarity in machine learning — cosine similarity is nothing but this formula normalised. In physics it is how work is defined: force dotted with displacement, which is why pushing sideways on a moving object does no work at all.

    Frequently asked questions

    What does the dot product mean?

    How much two vectors point in the same direction, scaled by their magnitudes. Zero means perpendicular.

    How do I find the angle between two vectors?

    Divide the dot product by the product of the magnitudes, then take the arccosine.

    Does it work in more than three dimensions?

    Yes, in any number. The perpendicularity test is one of the few geometric ideas that survives intact into high dimensions.

    What is the projection?

    How much of one vector lies along the other. It is the dot product divided by the magnitude of the second.