StatGardenREF. DESK
Calculators/Maths/Vector magnitude & unit vector
Maths

Vector magnitude & unit vector calculator

Length of a 3D vector and the unit vector pointing the same way.

Published 6 August 2026 · Updated 23 September 2026

What this calculator does

A vector's magnitude is its length, found by extending Pythagoras into three dimensions: square the components, add them, take the root. The familiar 3, 4, 5 triangle appears immediately, since the vector (3, 4, 0) has a magnitude of exactly 5.000.

The unit vector strips out the length and keeps only the direction. Dividing (3, 4, 0) by its magnitude gives (0.6000, 0.8000, 0), and any vector pointing the same way produces the identical unit vector.

The formula

Formula|v| = √(x² + y² + z²); unit vector û = v / |v|

The magnitude is the square root of the sum of the squared components. Dividing each component by that magnitude gives the unit vector.

TermMeaning
MagnitudeThe length of the vector, always non-negative.
Unit vectorA vector of length 1 in the same direction, carrying direction only.
Direction cosinesThe angles the vector makes with each coordinate axis.

The inputs explained

FieldWhat to enter
xThe x component.
yThe y component.
zThe z component. Enter zero for a 2D vector.

When to use it

Normalising a vector

Graphics and physics constantly need direction without magnitude.

Finding a distance in 3D

The magnitude of a displacement vector is the distance travelled.

Checking a calculation

A unit vector should always have magnitude 1, which is a useful sanity check.

Worked examples

Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.

How does scaling change magnitude and direction?

Three vectors, two of which point identically.

Vectors along the same direction
x component (y = 4)Magnitude |v|Unit vector
(3, 4, 0)5.000(0.6000, 0.8000, 0)
(6, 4, 0)7.211(0.8321, 0.5547, 0)
(0, 4, 0)4.000(0, 1.000, 0)
The vector (3, 4, 0) has a magnitude of exactly 5.000 and a unit vector of (0.6000, 0.8000, 0). Raising x to 6 lifts the magnitude to 7.211 and swings the direction, and dropping x to 0 leaves 4.000 pointing straight along the y axis.

Questions

Why is this just Pythagoras?

Because it is. The magnitude of a 3D vector is the diagonal of a rectangular box with those side lengths, and applying Pythagoras twice, once in the base plane and once vertically, gives the square root of the sum of squares.

What is a unit vector for?

For carrying direction without magnitude. Anywhere you need to know which way something points but not how far, a unit vector is the natural object, which is why graphics and physics use them constantly.

Can the zero vector be normalised?

No. It has magnitude zero and no direction, so dividing by its magnitude is undefined. The calculator reports that rather than producing a spurious answer.

What are direction cosines?

The cosines of the angles between the vector and each axis, which are exactly the components of the unit vector. They satisfy a neat identity: their squares always sum to 1.

For the angle between two vectors, see the dot product calculator. For distance between 3D points, see the 3D distance and midpoint calculator.