Lelifi·tools

Unit Vector Calculator

The unit vector of (3, 4) is (0.6000, 0.8000). The magnitude is 5, and dividing each component by it gives a vector of length 1 that points the same way. For (2, -3, 6) the magnitude is 7 and the unit vector is (0.2857, -0.4286, 0.8571).

Enter a 2D or 3D vector and get its magnitude, the unit vector with length 1, the angles from each axis, and a clear message when the vector is zero.

By the Lelifi editors ·

Key takeaways

Turning (3, 4) into a unit vectorv = (3, 4)3 x 3 gives 9 and 4 x 4 gives 169 + 16 = 25, so the magnitude is 5u = (3 / 5, 4 / 5)= (0.6000, 0.8000), length 1.0000
The vector (3, 4) has magnitude 5, so dividing each component by 5 gives the unit vector (0.6000, 0.8000).
The length check: 0.36 + 0.64 = 10.36000.6400x component squared (0.3600)y component squared (0.6400)
Squaring the components of the unit vector (0.6000, 0.8000) gives 0.36 and 0.64, which add to 1.
On this page
  1. What a unit vector is
  2. The formula with numbers: the vector (3, 4)
  3. A 3D example: the vector (2, -3, 6)
  4. The zero vector has no unit vector
  5. Direction cosines: the angles that come free
  6. Where unit vectors get used
  7. Rounding, checking and the mistakes that survive

What a unit vector is

A unit vector keeps the direction of a vector and drops its length to exactly 1. Written with a hat, u = v / ||v||: take every component of v and divide it by the vector's magnitude. The result points the same way as v, so it answers the question where, while v answers both where and how far.

Unit vectors matter because direction is often the only part anyone needs. A light source in a 3D scene, a wind direction, a heading on a GPS unit, a surface normal: all of these are directions, and storing them as unit vectors keeps every later calculation free of a stray magnitude. Textbooks write the standard ones as i, j and k, the unit vectors along the x, y and z axes, and the OpenStax University Physics chapter on coordinate systems builds every other vector out of them as multiples.

The recipe is identical in 2D and 3D. In 2D you divide x and y by the magnitude. In 3D you divide x, y and z, and the z slot is the one people forget. A unit vector is not unique per direction: (0.6, 0.8) and its negative (-0.6, -0.8) are both unit vectors, pointing in opposite directions, so check the sign of your components before you normalize.

These are the vectors used as examples on this page, each one with its magnitude and the unit vector it normalizes to. The components carry four decimal places, which is the rounding the calculator shows.

Vector vMagnitudeUnit vector u
(3, 4)5(0.6000, 0.8000)
(5, 12)13(0.3846, 0.9231)
(1, 1)1.4142(0.7071, 0.7071)
(1, 2, 2)3(0.3333, 0.6667, 0.6667)
(2, -3, 6)7(0.2857, -0.4286, 0.8571)
(-4, 0, 3)5(-0.8000, 0.0000, 0.6000)

Two rows in that table are Pythagorean triples, (3, 4) and (5, 12), so their magnitudes are whole numbers and the length check is easy to do by hand. The (1, 1) row has a magnitude that is not a whole number, 1.4142, and normalizing it returns (0.7071, 0.7071), which is still a vector of length 1 once the rounding is allowed for.

The formula with numbers: the vector (3, 4)

Take v = (3, 4). The magnitude is the square root of the sum of squared components: ||v|| = sqrt(3^2 + 4^2) = sqrt(25) = 5. Divide each component by 5 and the unit vector is u = (0.6000, 0.8000).

StepWorkingResult
Square the components3 x 3 gives 9 and 4 x 4 gives 169 and 16
Sum and take the rootsqrt(9 + 16) = sqrt(25)||v|| = 5
Divide x3 / 50.6000
Divide y4 / 50.8000
Check the lengthsqrt(0.36 + 0.64)1.0000

The last row is the check that catches most errors: a correct unit vector always has components whose squares add to 1. Here 0.36 + 0.64 = 1 exactly. Scale back up by multiplying by the magnitude again: 0.6000 x 5 = 3 and 0.8000 x 5 = 4, which returns the original vector. A related case worth knowing is (5, 12), a Pythagorean triple: the magnitude is 13 and the unit vector is (0.3846, 0.9231). Triples give whole number magnitudes, which makes them handy for checking work by hand.

A 3D example: the vector (2, -3, 6)

Three dimensions add one square and one division. For v = (2, -3, 6), the magnitude is sqrt(4 + 9 + 36) = sqrt(49) = 7. The unit vector is u = (0.2857, -0.4286, 0.8571), obtained by dividing 2, -3 and 6 each by 7.

Two details in that answer carry information. First, the signs: the y component stayed negative, so the unit vector dips below the x-y plane exactly where v does. Second, the size of the components: z carries 0.8571 of the length, more than x and y combined, because 6 was the largest component. Squaring and adding gives 0.0816 + 0.1837 + 0.7347 = 1.0000 within rounding, the same check as in 2D.

The angles fall out for free and section five reads them off the components. For this vector the angle from the +x axis is 73.3985 degrees, from +y it is 115.3769 degrees, and from +z it is 31.0027 degrees. The y angle is past 90 degrees because the y component is negative.

The zero vector has no unit vector

Take v = (0, 0, 0). The magnitude is 0, and the formula asks for a division by 0, which has no answer. The honest reading is that the zero vector has no direction, so there is nothing for a unit vector to preserve. The calculator above reports the case instead of printing a number, because any output at all would be a lie about direction.

Near zero is a different trap. A vector like (0.0000001, 0) does have a unit vector, (1.0000, 0.0000), but normalizing it amplifies measurement noise: the original length carried real information, and dividing it away treats a rounding error as a bearing. In practice, code that normalizes tiny vectors usually checks the magnitude against a threshold first and skips or flags the vector below it. Sensor fusion and physics engines both do this, because a force of 0.0001 newtons is not a meaningful direction.

One more boundary case: vectors that are already unit vectors come back unchanged. Feeding (0.6000, 0.8000) into the formula gives magnitude 1.0000 and the same components out. That is expected, not a bug, and it is a quick way to test whether a vector you were handed has already been normalized.

Direction cosines: the angles that come free

Each component of a unit vector is the cosine of the angle between the vector and one axis. cos alpha = ux, cos beta = uy, cos gamma = uz, where alpha, beta and gamma are measured from the +x, +y and +z axes. These are the direction cosines, and taking arccos of each component turns the unit vector into three angles.

For u = (0.3333, 0.6667, 0.6667), which comes from normalizing (1, 2, 2) by its magnitude of 3, the angles are 70.5288 degrees from +x and 48.1897 degrees from both +y and +z. The symmetry between y and z is no accident: the original components were equal, so the angles must match. The identity cos^2 alpha + cos^2 beta + cos^2 gamma = 1 holds by construction, and here it reads 0.1111 + 0.4444 + 0.4444 = 1.0000 within rounding.

A negative component always produces an angle past 90 degrees. For (-4, 0, 3), normalized to (-0.8000, 0.0000, 0.6000), the angle from +x is 143.1301 degrees, from +y exactly 90 degrees since the y component is 0, and from +z 53.1301 degrees. In 2D the angle from +x alone fixes the direction: (0.3846, 0.9231) sits 67.3801 degrees counterclockwise from the x axis, and (0.7071, 0.7071) sits exactly 45 degrees out.

The same vectors read as angles from the axes, one row per example:

Vector vAngle from +xAngle from +yAngle from +z
(3, 4)53.1301 degrees36.8699 degrees90.0000 degrees
(5, 12)67.3801 degrees22.6199 degrees90.0000 degrees
(1, 2, 2)70.5288 degrees48.1897 degrees48.1897 degrees
(2, -3, 6)73.3985 degrees115.3769 degrees31.0027 degrees
(-4, 0, 3)143.1301 degrees90.0000 degrees53.1301 degrees

Each angle is the arccos of the matching component of the unit vector, so this table and the earlier one carry the same information in two forms. A 90 degree entry appears wherever a component is 0, and an entry past 90 degrees appears wherever a component is negative.

Where unit vectors get used

Computer graphics is the heaviest user. Lighting models multiply a surface normal by the direction to the light, and both inputs must be unit vectors or the brightness changes with distance for no physical reason. A camera's view direction, an object's velocity heading, a ray cast through a pixel: each starts as a normalized direction that later steps get scaled by speed, distance or intensity.

Physics keeps directions and sizes apart the same way. A force of 40 newtons along (3, 4) is written as 40 x (0.6000, 0.8000) = (24, 32), which separates the magnitude from the direction cleanly. MathWorld's unit vector entry works the same decomposition, and the MIT linear algebra course uses normalization as the first step in projections, where the component of one vector along another is a dot product with a unit vector.

Machine learning and search use unit vectors for comparison. Two documents turned into unit vectors can be compared with a plain dot product, which then equals the cosine of the angle between them, a number from -1 to 1 that ignores document length. Navigation works the same way: a bearing of 67.3801 degrees converts to the unit vector (0.3846, 0.9231), and multiplying by distance gives the displacement. The NIST DLMF reference on vectors collects the underlying identities used across all of these fields.

Rounding, checking and the mistakes that survive

Frequently asked questions

What is the unit vector of (3, 4)?

(0.6000, 0.8000). The magnitude of (3, 4) is 5, and dividing each component by 5 gives a vector of length 1 pointing the same way.

How do you find a unit vector in 3D?

Compute the magnitude with sqrt(x^2 + y^2 + z^2), then divide all three components by it. For (2, -3, 6) the magnitude is 7 and the unit vector is (0.2857, -0.4286, 0.8571).

Why does the zero vector have no unit vector?

Its magnitude is 0, and the formula divides by the magnitude, so the step is division by zero. A vector with no length has no direction to preserve, so the honest answer is undefined.

What is the unit vector of (1, 2, 2)?

(0.3333, 0.6667, 0.6667). The magnitude is sqrt(1 + 4 + 4) = 3, and dividing each component by 3 gives the answer, whose components square and sum to 1.

What does a unit vector of (0.6, 0.8) mean?

It is the direction of (3, 4) with the length stripped out. The angle from the +x axis is 53.1301 degrees, and multiplying by any length s gives a vector of length s in that direction.

How do I check that my unit vector is correct?

Square each component and add them: the total must be 1. For (0.2857, -0.4286, 0.8571) that is 0.0816 + 0.1837 + 0.7347 = 1.0000 within rounding.

What are direction cosines?

The components of the unit vector. cos alpha = ux, cos beta = uy and cos gamma = uz, where the angles are measured from the +x, +y and +z axes. For (1, 2, 2) the angles are 70.5288, 48.1897 and 48.1897 degrees.

What is the unit vector of (-4, 0, 3)?

(-0.8000, 0.0000, 0.6000). The magnitude is 5, the negative x component keeps its sign, and the y component is 0 because it was 0 to begin with.

Is (0.7071, 0.7071) a unit vector?

Yes. Its length is sqrt(0.5 + 0.5) = 1.0000, and it is the normalized form of (1, 1), pointing 45 degrees from the +x axis.

Can a unit vector have components bigger than 1?

No single component can exceed 1, because each component is a cosine of some angle. A component can equal 1 only when the vector lies along that axis, such as (0.0000, 1.0000).

Does normalizing change what the vector points at?

No. Dividing by a positive magnitude rescales every component by the same factor, so the direction is untouched. Only the length changes, from ||v|| to exactly 1.

What is the unit vector of (5, 12)?

(0.3846, 0.9231). The magnitude is 13, one of the Pythagorean triples, which is why the check works out so cleanly by hand.

How do I turn a unit vector back into the original vector?

Multiply by the magnitude. The unit vector (0.6000, 0.8000) times 5 gives (3.0000, 4.0000), and a unit vector times a speed gives a velocity in that direction.

Spotted a wrong number or a broken result?

More Math tools

See all Math tools

Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.