Unit Vector Calculator (and Vector Magnitude)

  • Free
  • No sign-up
  • Works on phones
  • Shows the working
Vectors & Matrices#60

Unit Vector & Magnitude

\(|v|\) in simplest radical form and the unit vector \(\hat{u} = v / |v|\), exactly.

This unit vector calculator finds the length (magnitude) of a vector and the unit vector that points the same way. Results are exact where possible: ( |v| ) in simplest radical form and each component of the unit vector as a fraction or radical, with decimals alongside. For 2D and 3D vectors it also gives the direction angles.

It’s free and needs no sign-up.

Unit Vector Calculator (and Vector Magnitude): The unit vector û = ⟨3/5, 4/5⟩ points the same way as v = ⟨3, 4⟩ but has…
The unit vector û = ⟨3/5, 4/5⟩ points the same way as v = ⟨3, 4⟩ but has length 1, ending on the unit circle.

How to use it

  1. Enter the vector’s components separated by commas, for example 3, 4 or 2, -1, 2. Up to six components are accepted.
  2. Press Calculate.

Formulas

The magnitude of ( v = langle v_1, v_2, ldots, v_n rangle ) comes from the Pythagorean theorem:

$$|v| = sqrt{v_1^2 + v_2^2 + cdots + v_n^2}$$

The unit vector divides every component by that length:

$$hat{u} = frac{v}{|v|} = leftlangle frac{v_1}{|v|}, frac{v_2}{|v|}, ldots, frac{v_n}{|v|} rightrangle$$

It has length 1 and the same direction as v. Finding it is called normalizing the vector.

Worked example: ⟨3, 4⟩

As loaded above: ( |v| = sqrt{3^2 + 4^2} = sqrt{25} = 5 ), so

$$hat{u} = leftlangle frac{3}{5}, frac{4}{5} rightrangle = langle 0.6, 0.8 rangle$$

Check: ( 0.6^2 + 0.8^2 = 0.36 + 0.64 = 1 ).

Worked example: ⟨2, −1, 2⟩

( |v| = sqrt{4 + 1 + 4} = sqrt{9} = 3 ), so ( hat{u} = leftlangle frac{2}{3}, -frac{1}{3}, frac{2}{3} rightrangle ).

Worked example: ⟨1, 1, 1⟩

( |v| = sqrt{3} ), so each component is ( frac{1}{sqrt{3}} ). Rationalizing the denominator gives

$$hat{u} = leftlangle frac{sqrt{3}}{3}, frac{sqrt{3}}{3}, frac{sqrt{3}}{3} rightrangle approx langle 0.577, 0.577, 0.577 rangle$$

The calculator writes exact answers in this rationalized form.

Direction angles

The angles ( alpha, beta, gamma ) that v makes with the x-, y- and z-axes satisfy ( cosalpha = frac{v_1}{|v|} ), ( cosbeta = frac{v_2}{|v|} ), ( cosgamma = frac{v_3}{|v|} ). In other words, the components of the unit vector are the direction cosines. For ( langle 3, 4 rangle ), ( alpha approx 53.13^circ ) and ( beta approx 36.87^circ ).

Notebooks, protractor, compass, and pencil on a white surface.

Why a unit vector calculator is helpful

  • Directional derivatives need a unit direction: ( D_{hat{u}} f = nabla f cdot hat{u} ). Using a non-unit vector scales the answer by mistake (see gradient and directional derivative).
  • Physics splits a force into magnitude × direction: ( F = |F|,hat{u} ).
  • Graphics and data normalize vectors so only direction matters.

To make a vector of any length L in the same direction, multiply the unit vector by L. For example, a vector of length 10 in the direction of ( langle 3, 4 rangle ) is ( 10 cdot langle 0.6, 0.8 rangle = langle 6, 8 rangle ).

Common mistakes

  • Forgetting to square negative components. ( (-1)^2 = 1 ), so negative entries still add to the length.
  • Dividing only some components by the length. Every component is divided.
  • The zero vector. ( langle 0, 0 rangle ) has no direction and no unit vector.

Step-by-step method

  1. Square each component.
  2. Add the squares and take the square root: that is ( |v| ).
  3. Divide every component by ( |v| ).
  4. Simplify or rationalize, and check that the squares of the new components add to 1.

Worked example: ⟨−5, 12⟩

( |v| = sqrt{25 + 144} = sqrt{169} = 13 ), so ( hat{u} = leftlangle -frac{5}{13}, frac{12}{13} rightrangle ). The negative component stays negative: the unit vector points into the same quadrant as v.

Worked example: the direction from one point to another

The unit vector pointing from ( A(1, 2) ) to ( B(4, 6) ): first ( vec{AB} = langle 4 – 1, 6 – 2 rangle = langle 3, 4 rangle ), whose length is 5, so the direction is ( langle 0.6, 0.8 rangle ). Also, the length of ( vec{AB} ) is the distance between the points; see the distance formula.

A hand pointing to the left, indicating direction.

Worked example: a velocity

A drone flies with velocity ( langle 6, 8, 0 rangle ) m/s. Its speed is ( |v| = 10 ) m/s and its direction is ( langle 0.6, 0.8, 0 rangle ). To fly the same direction at 25 m/s, use ( 25langle 0.6, 0.8, 0 rangle = langle 15, 20, 0 rangle ) m/s. Splitting a vector into speed × direction like this is used throughout physics.

Unit vector notation

Vectors are often written with ( mathbf{i}, mathbf{j}, mathbf{k} ): ( langle 3, 4 rangle = 3mathbf{i} + 4mathbf{j} ). Its unit vector is ( frac{3}{5}mathbf{i} + frac{4}{5}mathbf{j} ). Also, a hat (( hat{u} )) marks a unit vector.

Normal vectors

A unit normal vector is perpendicular to a line or surface and has length 1. The line ( 3x + 4y = 12 ) has normal ( langle 3, 4 rangle ), so its unit normal is ( langle 0.6, 0.8 rangle ). For a plane through three points, find the normal with the cross product and then normalize it here.

Practice problems

  1. ( langle 6, 8 rangle ).
  2. ( langle 1, 2, 2 rangle ).
  3. ( langle 0, -7 rangle ).

Answers: 1. Length 10, unit vector ( langle 0.6, 0.8 rangle ). 2. Length 3, unit vector ( leftlangle frac13, frac23, frac23 rightrangle ). 3. Length 7, unit vector ( langle 0, -1 rangle = -mathbf{j} ).

A unit vector from an angle

In 2D, the unit vector making an angle θ with the positive x-axis is ( langle costheta, sintheta rangle ). For ( theta = 30^circ ) it is ( leftlangle frac{sqrt{3}}{2}, frac12 rightrangle ). This is the point at angle θ on the unit circle, which is why the circle has radius 1.

The direction of a line

The line ( y = 2x + 1 ) rises 2 for every 1 across, so it has direction vector ( langle 1, 2 rangle ) and unit direction

$$leftlangle frac{1}{sqrt{5}}, frac{2}{sqrt{5}} rightrangle = leftlangle frac{sqrt{5}}{5}, frac{2sqrt{5}}{5} rightrangle$$

Higher dimensions

The same formula works in any number of dimensions. ( langle 1, 1, 1, 1 rangle ) has length ( sqrt{4} = 2 ), so its unit vector is ( leftlangle frac12, frac12, frac12, frac12 rightrangle ). In data science, normalizing long vectors like this lets you compare directions (patterns) regardless of size.

Earth from space with sun rising, showing continents and stars.

Checking your answer

A correct unit vector always passes two quick tests: its components’ squares add to 1, and each component has the same sign as the original vector’s component. For ( langle 2, -1, 2 rangle ), the answer ( leftlangle frac23, -frac13, frac23 rightrangle ) passes both: ( frac49 + frac19 + frac49 = 1 ), and the middle component is still negative.

Related guides

Further reading

FAQ

What is a unit vector?

A vector with length 1. It shows a direction without any size.

How do you find a unit vector?

Divide the vector by its magnitude: ( hat{u} = frac{v}{|v|} ).

How do you find the magnitude of a vector?

Square each component, add them and take the square root: ( |v| = sqrt{v_1^2 + v_2^2 + v_3^2} ).

What are i, j and k?

The unit vectors along the x-, y- and z-axes: ( mathbf{i} = langle 1, 0, 0 rangle ), ( mathbf{j} = langle 0, 1, 0 rangle ), ( mathbf{k} = langle 0, 0, 1 rangle ).

Is the magnitude ever negative?

No. A length is always zero or positive. Only the zero vector has magnitude 0.

How do I find a vector of a given length in a given direction?

Multiply the unit vector in that direction by the length you want.

Embed this calculator on your website

Teachers, tutors and bloggers are welcome to use this calculator for free. Copy the code below and paste it into any page (in WordPress, use a "Custom HTML" block). The small script makes the calculator grow to fit its answer; if your site removes scripts, it still works at a fixed height. Please keep the credit link.

More calculators

See all calculators