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).
| Unit vector u | |
| Magnitude ||v|| | |
| u₁ (x) | |
| u₂ (y) | |
| u₃ (z) | |
| Check: |u| after rounding | |
| Angle from the +x axis | |
| Angle from the +y axis | |
| Angle from the +z axis | |
| Scaling back up | |
The unit vector points the same way as your vector with a length of 1: divide each component by the magnitude. A vector of all zeros has no direction, so it has no unit vector. Everything runs in your browser, and nothing you type is uploaded or stored.
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.
Key takeaways
- u = v / ||v||: divide every component by the magnitude, so (3, 4) becomes (0.6000, 0.8000)
- The check: the squares of a unit vector's components add to 1
- The zero vector has no direction, so it has no unit vector
- Direction cosines come free: each component is the cosine of the angle to its axis, and for (2, -3, 6) they are 73.3985, 115.3769 and 31.0027 degrees
- Divide by the magnitude, not its square: dividing (3, 4) by 25 gives a vector of length 0.2000
On this page
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 v | Magnitude | Unit 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).
| Step | Working | Result |
|---|---|---|
| Square the components | 3 x 3 gives 9 and 4 x 4 gives 16 | 9 and 16 |
| Sum and take the root | sqrt(9 + 16) = sqrt(25) | ||v|| = 5 |
| Divide x | 3 / 5 | 0.6000 |
| Divide y | 4 / 5 | 0.8000 |
| Check the length | sqrt(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 v | Angle from +x | Angle from +y | Angle from +z |
|---|---|---|---|
| (3, 4) | 53.1301 degrees | 36.8699 degrees | 90.0000 degrees |
| (5, 12) | 67.3801 degrees | 22.6199 degrees | 90.0000 degrees |
| (1, 2, 2) | 70.5288 degrees | 48.1897 degrees | 48.1897 degrees |
| (2, -3, 6) | 73.3985 degrees | 115.3769 degrees | 31.0027 degrees |
| (-4, 0, 3) | 143.1301 degrees | 90.0000 degrees | 53.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
- Dividing by the wrong magnitude. For (3, 4) the magnitude is 5, not 25. Dividing by 25 gives (0.1200, 0.1600), which has length 0.2000 and is not a unit vector at all. The check row, squares summing to 1, catches this in one line.
- Normalizing only some components. For (1, 2, 2), dividing x and y by 3 but leaving z at 2 gives (0.3333, 0.6667, 2.0000) with length 2.1344. Every component gets the same divisor.
- Losing the sign. (-4, 0, 3) normalizes to (-0.8000, 0.0000, 0.6000). Dropping the minus sign flips the direction 143.1301 degrees to 36.8699 degrees, and everything downstream points the wrong way.
- Trusting rounded components. Four decimal places keeps the length within about 0.0001 of 1, which is plenty for checking, but chain normalized vectors through many multiplications in code and the error compounds. Keep full precision internally and round only for display.
- Forgetting the third slot. A 2D vector entered as (3, 4) and a 3D vector entered as (3, 4, 0) behave identically here, but a 3D vector with a real z component will not normalize correctly if that component is left at 0.
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
Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.