Unit Vector Calculator
Result
x component of the unit vector
- y component of the unit vector
- 0.8000
- z component of the unit vector
- 0.0000
- Magnitude of the vector
- 5.0000
A unit vector calculator turns a vector into the vector of length 1 that points the same way, and prints the length it divided by. Type the components separated by spaces or commas — 3 4 for a two-dimensional vector, 2 3 6 for a three-dimensional one — and the page does the rest. Two or three components are accepted, and only those two counts: the panel has three component rows, and a one-dimensional vector is really a signed number rather than a direction. The arithmetic is a single division. Measure the length of the vector, which is the square root of the sum of the squares of its components, and divide every component by it. The result has length 1 by construction, points along exactly the same line as the input, and is called the unit vector in that direction. What the answer is for is separating direction from size. Two vectors that differ only in length have the same unit vector, which makes it the natural way to compare directions when the magnitudes are not comparable — a wind speed against a compass bearing, or a measured slope against a reference one. It is also how a direction gets carried into a formula that assumes a normalised input, which is most of the formulas in geometry and graphics. Two details are worth knowing before you use the output. The sign of the answer follows the input: the unit vector of 3 4 is 0.6 and 0.8, and the unit vector of -3 4 is -0.6 and 0.8. Dividing by a positive length cannot flip a direction, and a vector pointing left or down is a perfectly ordinary input. And the length printed alongside is the length of the vector you typed, not of the answer — the answer's length is 1 by definition and would say nothing. Seeing the input's length is what makes the division visible: the numbers on the panel are that length divided out of the numbers in the box. The one input refused is the zero vector, whose length is zero, which leaves nothing to divide by and, more to the point, no direction to preserve.
Vectors and their unit vectors
| Vector | Magnitude of the vector | x component of the unit vector | y component of the unit vector | z component of the unit vector |
|---|---|---|---|---|
| 3 4 | 5 | 0.6 | 0.8 | 0 |
| 1 0 | 1 | 1 | 0 | 0 |
| 1 1 | 1.4142 | 0.7071 | 0.7071 | 0 |
| 0 5 | 5 | 0 | 1 | 0 |
| -3 4 | 5 | -0.6 | 0.8 | 0 |
| 2 3 6 | 7 | 0.2857 | 0.4286 | 0.8571 |
| 1 1 1 | 1.7321 | 0.5774 | 0.5774 | 0.5774 |
| 3 4 -5 | 7.0711 | 0.4243 | 0.5657 | -0.7071 |
Eight vectors and their unit vectors, and the second column is the one that makes the table worth reading: it holds the divisor, not the constant 1 that comes out at the end. The first row is the one the page loads with, and it comes out exactly on both sides, a 3-4-5 triangle giving a length of 5 and two decimal components that are exact. The second and fourth rows are vectors already lying along an axis, so the unit vector is the axis direction itself, and the fourth of those has a length of 5 rather than 1 — the clearest place to see that the column holds the input's length and not the answer's. The third row is the equal-component case in the plane, giving two components of 0.7071 and a length of √2. The fifth row is the first row with the sign changed on one of the numbers, and the unit vector's sign follows: −0.6 and 0.8. Nothing about normalising turns a vector round, and this row is the proof. The sixth and seventh rows are three-dimensional: one with an integer length of 7 and no exact components, one with a length of √3 and three equal components. The eighth has a negative third component and gives the only unit vector in the table with a negative z. There is no row for the zero vector, deliberately: it has no direction and the page refuses it. Every figure is recomputed when the page is built, and the spaces in the first column are the separators, not part of the numbers.
Formula
û = u ÷ |u| |u| = √(u₁² + u₂² + … + uₙ²) |û| = 1
- Vector u
- The vector to normalise: two or three numbers separated by spaces or commas, such as 3 4. Two components is a vector in the plane and three is a vector in space; there is no count field to fill in, and the length of the list is what says which you meant
- |u|
- The length of the input vector: the square root of the sum of the squares of its components. This is the number everything is divided by, and it is the fourth output on the panel — the length of the vector you typed, not of the unit vector, whose length is always 1
- û
- The unit vector: each component of the input divided by its length. It points along exactly the same line as the input and has length 1, so the two differ in size and not in direction. The hat is the standard way of writing it
- x component
- The first component of the answer: the first component of the input divided by the length. Its sign is the input's sign — dividing by a positive length cannot flip a direction, so a vector pointing left gives a unit vector pointing left
- y component
- The second component, divided the same way. With the x component it fixes the direction in the plane, whatever the length of the original
- z component
- The third component, divided the same way, and 0 for a two-component input. That zero is not padding: a two-dimensional vector lies in the flat plane, and the same direction written in three coordinates has a third component of exactly 0
- |û| = 1
- The property the answer was built to have, and the reason it is not printed as a fifth row. The length of a unit vector is 1 in every case, so a panel row reading 1.0000 would be a constant dressed up as a result
- Four decimal places
- How wide the outputs are written. Exact only when the input's length comes out as a whole number or a short root — 3 4 gives 5, and thirds and roots generally do not come out even
Use this page when you want the direction on its own, without the size attached. The clearest case is comparing two directions whose magnitudes are on different scales: two vectors that differ only in length have the same unit vector, so normalising strips off the part you were not asking about. The other common case is preparing an input for a formula that assumes a vector of length 1 — reflections, projections and lighting calculations all do, and feeding them a vector of length 5 quietly scales the answer by 5. The length printed alongside is what makes the division checkable: 3 4 gives 0.6 and 0.8, and you can see the 5 coming out of both. Two things worth remembering. The output carries the input's signs, so a vector pointing left or down gives a unit vector pointing left or down — normalising changes how long a vector is and nothing else. And the length of the output is 1 whatever you typed, which is why the page prints the input's length instead; that is the number with information in it. A two-component vector is fine and comes back with a third component of 0, because that is what the same direction looks like written in three coordinates. The zero vector is the one input refused, since it has no direction to normalise.
Worked examples
3 4
- Length: √(9 + 16) = √25 = 5
- x component: 3 ÷ 5 = 0.6
- y component: 4 ÷ 5 = 0.8
- z component: 0 ÷ 5 = 0, since a two-component vector lies in the flat plane
The input the page loads with, and the cleanest case there is: a 3-4-5 triangle makes the length a whole number, so both components come out exactly. This is the row that shows what the fourth output is for — the 5 on the panel is the length that 3 and 4 were each divided by, and reading 0.6 and 0.8 next to it is the whole calculation. Check it by squaring: 0.36 + 0.64 = 1.
2 3 6
- Length: √(4 + 9 + 36) = √49 = 7
- x component: 2 ÷ 7 = 0.285714
- y component: 3 ÷ 7 = 0.428571
- z component: 6 ÷ 7 = 0.857143
A three-dimensional case whose length also comes out as a whole number, 7, while none of the three components does: all three are repeating decimals rounded to four places. That combination is the ordinary case rather than a quirk — an integer length is common enough, integer components of the unit vector are not. The direction is the same as 2 3 6, and the length has been divided out of it.
-3 4
- Length: √(9 + 16) = √25 = 5, the same as for 3 4
- x component: −3 ÷ 5 = −0.6
- y component: 4 ÷ 5 = 0.8
- z component: 0 ÷ 5 = 0
The first example with the first component negated, and the unit vector keeps the sign: −0.6 and 0.8. Dividing by a positive length cannot turn a vector round, and this is the row where that becomes visible. A vector pointing left and up is a perfectly ordinary input, and its unit vector points left and up too. The length is 5 either way, since negating a component does not change it.
0 5
- Length: √(0 + 25) = 5
- x component: 0 ÷ 5 = 0
- y component: 5 ÷ 5 = 1
- z component: 0 ÷ 5 = 0
A vector already lying along one of the axes, so its unit vector is the axis direction itself: 0, 1, 0. The fourth output is the row to look at here — it reads 5, not 1. A vector of length 5 pointing straight up has a unit vector of length 1, and the panel says so by printing the length that was divided out rather than the constant 1 that came out.
1 1 1
- Length: √(1 + 1 + 1) = √3 = 1.732051
- Each component: 1 ÷ 1.732051 = 0.577350
The diagonal of a cube, and the three components come out equal — as they must, since the input's three components were equal and dividing them all by the same number cannot break the tie. The length is a square root rather than a whole number, so nothing is exact here. Check the result the way the page's own definition says to: 0.5774 squared is 0.3334, and three of those add to 1 within the rounding.
Limitations
Two or three components are accepted, and only those: one number is a signed quantity rather than a direction, and four or more do not fit the three component rows on the panel. A two-component vector is not padded to three in any meaningful sense — it lies in the flat plane, and the 0 in the third row is what that same direction looks like in three coordinates, which is why the page does not need to ask you which kind you meant. The zero vector is refused entirely: its length is zero, so there would be nothing to divide by, and it has no direction for the answer to preserve. Components are read as ordinary numbers: a comma followed by a space separates components, a comma with no space after it is read as a decimal point (1,5 is one and a half), and a thousands grouping is refused rather than guessed at — write 1500, not 1,500. Four decimal places is a display width, not a precision claim, and the components are computed from the unrounded length, so the printed figures may not square and add to exactly 1. The length printed on the panel is the input's, not the answer's; the answer's length is 1 by definition, and printing it would be printing a constant. Nothing on this page knows what the components were measured in — a unit vector has no unit, which is the point of it, and the length carries whatever unit the input did. There is one arithmetic subtlety worth stating: the sign of every component follows the input, so a vector pointing left gives a unit vector pointing left. If you were expecting a positive answer, you were expecting a different vector.
Frequently asked questions
- What is a unit vector?
- A vector of length 1 pointing in a given direction. It is what you get by dividing a vector by its own length, and it carries the direction without the size. Two vectors that differ only in how long they are have the same unit vector, which is what makes it the way to compare directions on different scales.
- Why does the fourth row show the input's length and not 1?
- Because a unit vector's length is 1 in every single case, and a row reading 1.0000 forever would be a constant rather than a result. The input's length is the number that was divided out, so printing it makes the division visible: type 3 4, see 5, and read off that 0.6 and 0.8 are each of those over 5.
- Can I enter a vector with just two components?
- Yes, and the third component comes back as 0. That is not padding — a two-dimensional vector lies in the flat plane, and 0 is what its third component is when the same direction is written in three coordinates. The panel has three component rows, so two-component and three-component inputs share one layout.
- Why does the answer keep the minus sign?
- Because dividing by a length cannot turn a vector round. The length is a positive number, so every component keeps its sign: the unit vector of −3 4 is −0.6 and 0.8. If you were expecting the answer to come back positive, that would be a different direction, not the same one normalised.
- Why is a vector of all zeros refused?
- Because normalising it means dividing by its length, and its length is zero. Beyond the division there is a second reason: the zero vector has no direction at all, so there is nothing for the answer to preserve. Both the pages on angles and dot products refuse it too, while the cross product page accepts it — there it genuinely produces the zero vector.
- What is normalising a vector used for?
- Separating a direction from a size. Formulas for reflections, projections and lighting assume the vector you hand them has length 1, and passing one of length 5 instead scales the answer by 5 without any warning. Comparing two directions measured on different scales is the other use: normalise both and the sizes stop interfering.
References
- Unit vector — the vector of length 1 pointing in a given direction, which is what this page returns, and the normalisation-by-division that produces it — Wolfram MathWorld (United States)
- Vector — the object being normalised, and the definition of its length as the square root of the sum of the squares of its components — Wolfram MathWorld (United States)
- Norm — the general name for the length of a vector, of which the square-root-of-sum-of-squares is the ordinary Euclidean case used here — Wolfram MathWorld (United States)
- 教育部关于印发义务教育课程方案和课程标准(2022 年版)的通知——The fifth item in the annex list of this notice is the Mathematics Curriculum Standards for Compulsory Education (2022 edition); plane vectors and their linear operations do not fall in the compulsory-education grade bands, and the wording of the standards and the grade-band breakdown are governed by that annex — 中华人民共和国教育部