Skip to content
MasterMath

Vector Magnitude Calculator

The magnitude of a vector, its unit vector and the angles it makes with each axis. Works in any number of dimensions.

Magnitude

—

Magnitude—
Dimension—
Unit vector—
Angles with the axes—

How this was worked out

    The formula

    |v| = √(v₁² + v₂² + … + vₙ²)

    What it means

    The magnitude is Pythagoras generalised: square every component, add them, take the root. It works in two dimensions, in three, and in three hundred, which is why the same formula turns up in machine learning as in geometry.

    How to do it by hand

    1. Square each component
    2. Add all the squares
    3. Take the square root
    4. For the unit vector, divide each component by that magnitude

    What is worth knowing

    The unit vector is the direction stripped of the length, and it is what lets you compare orientations regardless of scale. Dividing by the magnitude is called normalising, and it fails for exactly one vector: the zero vector, which has no direction to extract. The angles with the axes are the direction cosines, and they satisfy a neat identity — their squares always add to 1, which is the same Pythagorean statement wearing a different hat. In three dimensions those three angles pin the direction down completely.

    Frequently asked questions

    How do you find the magnitude of a vector?

    Square each component, add them all, and take the square root. It is Pythagoras extended to any dimension.

    What is a unit vector?

    A vector of magnitude 1 pointing the same way. Divide each component by the magnitude to get it.

    Can the zero vector be normalised?

    No. It has magnitude zero and no direction, so dividing by it is undefined.

    What are direction cosines?

    The cosines of the angles with each axis. They are the components of the unit vector, and their squares add to 1.