Lelifi·tools

Vector Magnitude Calculator

The magnitude of a vector is the square root of the sum of its squared components. For (2, 3, 6) that is the square root of 4 + 9 + 36, which is 7. The vector (3, 4, 0) has magnitude 5, and its unit vector is (0.6, 0.8, 0).

Enter the x, y and z components of a vector and read its length, the unit vector pointing the same way, and the angle it makes with each axis.

By the Lelifi editors ·

Key takeaways

(3, 4) is a 3 by 4 right triangle with a hypotenuse of 5x = 3y = 4length 59 + 16 = 25square root of 25 is 5magnitude 5angle 53.13 deg
The magnitude is the hypotenuse of a right triangle whose legs are the components, so (3, 4) measures 5 units.
The vector (2, 3, 6) has a length of 7x 2y 3z 674 + 9 + 36 = 49square root of 49 is 7magnitude 7unit vector 0.2857, 0.4286, 0.8571
Each component is squared before the sum, so the negative half of an axis costs nothing in length.
On this page
  1. What the magnitude of a vector measures
  2. The formula, component by component
  3. Worked example: the vector (2, 3, 6)
  4. Two dimensions and the distance between two points
  5. The unit vector: same direction, length one
  6. Direction angles and direction cosines
  7. Mistakes that change the answer
  8. Where magnitude shows up, and which page to use

What the magnitude of a vector measures

A vector carries two pieces of information: how much, and which way. The magnitude is the how much part, a single non-negative number that says how long the arrow is. A velocity of 3 m/s east and a velocity of 3 m/s north have the same magnitude and different directions, and the magnitude of a velocity is what a speedometer shows.

In two or three dimensions the magnitude is the straight-line length from the tail of the vector to its tip. It does not depend on where the vector is drawn, only on its components, so the vector from (0, 0) to (3, 4) and the vector from (10, 10) to (13, 14) are the same vector and both have magnitude 5.

The NASA Glenn Research Center describes vectors as arrows with length and direction and notes that the length is found from the components, which is the rule used here. The same convention runs through the vector chapter of Paul Dawkins' calculus notes at Lamar University, where magnitude is written with two vertical bars around the vector name.

Magnitude is never negative. A component can be, a direction angle can be, but a length cannot. If a calculation returns a negative magnitude, the sign belongs to a component or a direction, and the magnitude should be taken as the positive root.

The formula, component by component

The rule is Pythagoras applied once per dimension. For a vector with components x, y and z, square each component, add the squares, then take the square root of the total. In two dimensions the z term drops out and the formula reduces to the familiar right-triangle result.

The order of the steps matters for reading the result. Squaring first removes the signs, which is why (-3, 4) and (3, 4) share a magnitude of 5. Adding first and squaring afterwards gives a different and wrong answer: a vector of (2, 3, 6) would come out at 11 instead of 7.

VectorSquared componentsSumMagnitude
(3, 4, 0)9 + 16 + 0 = 25255
(2, 3, 6)4 + 9 + 36 = 49497
(1, 2, 2)1 + 4 + 4 = 993
(1, 1, 1)1 + 1 + 1 = 331.7321
(5, -12, 0)25 + 144 + 0 = 16916913

The last row is the one people get wrong by hand. The minus sign disappears in the square, so the answer is 13 and not 7, which is what 5 minus 12 would suggest.

Worked example: the vector (2, 3, 6)

Take a vector that points 2 units along x, 3 along y and 6 along z. Square each: 4, 9 and 36. The sum is 49, and the square root of 49 is exactly 7, so the arrow is 7 units long.

The same answer comes out of the component view. The point (2, 3, 0) sits 3.6056 units from the origin in the flat plane, since 4 + 9 = 13. Rising 6 units from there makes a right triangle with legs 3.6056 and 6, and the hypotenuse works out to 7. Handling the third dimension in one step, rather than two, is the reason the formula squares all three components at once.

Scaling shows the relationship between components and length. Doubling every component to (4, 6, 12) gives 16 + 36 + 144 = 196, and the square root of 196 is 14, exactly twice the original. Halving gives (1, 1.5, 3), whose magnitude is 3.5. A vector scaled by a factor k has a magnitude scaled by the absolute value of k, so reversing a vector to (-2, -3, -6) leaves the length at 7.

A table makes the same point across a few vectors, and the pattern is that length grows more slowly than the components. Going from (2, 3, 6) to (4, 6, 12) doubles each component but only doubles the length, while adding a modest 1 to the largest component moves the length by less than 0.1.

Two dimensions and the distance between two points

The most common use of a magnitude is not a vector drawn from the origin but the gap between two points. Subtract the coordinates, and the difference is a vector whose magnitude is the distance. The points (1, 2) and (4, 6) differ by (3, 4), so the distance between them is 5.

This is the same calculation the Pythagorean theorem calculator performs for a right triangle, with the two legs being the horizontal and vertical separations. In three dimensions the same subtraction applies to the z coordinates and the distance picks up the third square.

FromToDifferenceDistance
(0, 0)(3, 4)(3, 4)5
(1, 2)(4, 6)(3, 4)5
(0, 0, 0)(2, 3, 6)(2, 3, 6)7
(1, 1, 1)(3, 4, 7)(2, 3, 6)7
(10, 10)(15, 22)(5, 12)13

Because the components are squared, the order of subtraction does not matter: (1, 2) to (4, 6) and (4, 6) to (1, 2) both give 5. That property is why distance is a metric and direction is not.

The unit vector: same direction, length one

Dividing each component by the magnitude produces a vector of length 1 that points the same way. For (3, 4, 0) the magnitude is 5, so the unit vector is (0.6, 0.8, 0). For (2, 3, 6) it is (0.2857, 0.4286, 0.8571), and the squares of those three numbers add back to 1.000.

A unit vector is the standard way to separate direction from size. In graphics it is the normal that sets a surface angle, in physics it is the direction of a force with the magnitude factored out, and in machine learning it is the direction used in cosine similarity. The dot product calculator relies on the same normalization, since the cosine of the angle between two vectors is their dot product divided by both magnitudes.

The one case with no answer is the zero vector. (0, 0, 0) has magnitude 0, and dividing by zero is undefined, so there is no direction to report. A calculation that returns a unit vector of NaN or Infinity has hit this case, and the fix is to check the magnitude before dividing.

VectorMagnitudeUnit vectorLength check
(3, 4, 0)5(0.6, 0.8, 0)0.36 + 0.64 = 1
(2, 3, 6)7(0.2857, 0.4286, 0.8571)0.0816 + 0.1837 + 0.7347 = 1.000
(1, 2, 2)3(0.3333, 0.6667, 0.6667)0.1111 + 0.4444 + 0.4444 = 1.000
(6, 8, 0)10(0.6, 0.8, 0)0.36 + 0.64 = 1

Direction angles and direction cosines

Once the magnitude is known, each component can be turned into an angle. The direction cosine for the x axis is x divided by the magnitude, and the angle is the inverse cosine of that value. The three angles are usually labelled alpha, beta and gamma, and they run from 0 to 180 degrees.

For (2, 3, 6) the direction cosines are 0.2857, 0.4286 and 0.8571. The inverse cosines are 73.40, 64.62 and 31.00 degrees. The largest component gives the smallest angle, which is the sanity check to apply: the vector leans most toward the z axis because 6 is the biggest number.

AxisComponentDirection cosineAngle
x20.285773.40 deg
y30.428664.62 deg
z60.857131.00 deg

The three cosines are not independent. Their squares always sum to 1 for any non-zero vector, as the table above shows, which means that knowing two of the angles fixes the third. A vector lying along an axis has one angle of 0 degrees and two of 90 degrees, and a vector on the diagonal (1, 1, 1) has three equal angles of 54.74 degrees.

Two dimensions use a single angle instead. That angle is the inverse tangent of y over x, and the trigonometry calculator covers the quadrant corrections, since inverse tangent alone only returns values between -90 and 90 degrees.

Mistakes that change the answer

The first mistake is adding the components instead of the squares. For (2, 3, 6) the sum of the components is 11, while the length is 7. The triangle inequality explains the gap: the straight path is never longer than the route along the axes, and it is shorter whenever more than one component is non-zero.

The second is dropping a component. Leaving out the z value of (2, 3, 6) gives the square root of 13, which is 3.6056, less than half the right answer of 7. In three dimensions all three terms are needed even when one component looks small, because a component of 1 still adds 1 to the sum.

The third is a unit mix. Adding inches to millimetres, or mixing a component in metres with one in centimetres, produces a number that has no physical meaning. Convert to one unit before squaring, and note that the result carries that unit, so a vector in metres has a magnitude in metres.

The fourth is rounding too early. Rounding 0.4286 to 0.43 before squaring changes the length check in the third decimal place, and in a chain of rotations those small errors accumulate. Keep full precision through the calculation and round only the number that gets displayed.

A fifth error is expecting a negative magnitude to mean a reversed vector. Direction lives in the components, not in the length, so a vector pointing backwards has negative components and a positive magnitude.

Where magnitude shows up, and which page to use

Speed is the magnitude of velocity, and that is why a car going around a curve at a steady 30 mph has a changing velocity and a constant speed. Force vectors use the same rule: a 3 N push along x and a 4 N push along y combine to a 5 N push at 53.13 degrees. In statistics, the magnitude of a deviation vector is the quantity that standard deviation scales down, which is why the standard deviation calculator and this page share the same sum of squares.

The vector addition calculator answers the neighbouring question: it takes vectors as magnitudes and angles, converts them to components, and adds two or three of them. This page starts where that one ends, taking the components as input and reporting the length, the unit vector and the direction angles.

Use this page when the components are known, for example from a dataset with x, y and z columns, a CAD model, or a sensor that reports three axes. Use the addition page when the inputs arrive as compass bearings and speeds. Both pages report direction, but only the addition page produces a new vector from several.

One practical check before trusting any of these numbers: the magnitude must be at least as large as the biggest single component and no larger than the sum of the absolute values. For (2, 3, 6) that means a value between 6 and 11, and 7 falls inside the window.

Frequently asked questions

What is the magnitude of a vector?

It is the length of the arrow, found as the square root of the sum of the squared components. For (3, 4, 0) the squares are 9 and 16, the sum is 25, and the magnitude is 5.

How do I find the magnitude of a 3D vector?

Square all three components, add them, then take the square root. The vector (2, 3, 6) gives 4 + 9 + 36 = 49, so the magnitude is 7.

Can a vector magnitude be negative?

No. Squaring removes the signs before the sum, so the result is zero or positive. A negative component such as -12 in (5, -12, 0) still produces a magnitude of 13.

What is a unit vector?

A vector of length 1 pointing in the same direction, made by dividing each component by the magnitude. For (3, 4, 0) the unit vector is (0.6, 0.8, 0).

Why does the zero vector have no unit vector?

Its magnitude is 0, and dividing a component by 0 is undefined, so no direction can be assigned. Check the magnitude before normalizing to avoid a NaN result.

What are direction cosines?

They are the components divided by the magnitude, one per axis, and their inverse cosines are the direction angles. For (2, 3, 6) they are 0.2857, 0.4286 and 0.8571, giving angles of 73.40, 64.62 and 31.00 degrees.

Do direction cosines always add up to 1?

Their squares do, not the cosines themselves. The three squares of (2, 3, 6) direction cosines give 0.0816 + 0.1837 + 0.7347 = 1.000, and that holds for any non-zero vector.

How is magnitude different from the sum of the components?

The magnitude is shorter unless the vector lies on a single axis. For (2, 3, 6) the components add to 11 while the length is 7, a gap set by the triangle inequality.

Does doubling a vector double its magnitude?

Yes, and any positive scale factor works the same way. Doubling (2, 3, 6) to (4, 6, 12) gives 196 as the sum of squares, and the square root of 196 is 14, which is twice 7.

How do I find the distance between two points?

Subtract the coordinates to get the component differences, then take the magnitude of that difference. The points (1, 2) and (4, 6) differ by (3, 4), so the distance is 5.

What is the magnitude of (1, 1, 1)?

It is the square root of 3, or 1.7321, and all three direction angles are 54.74 degrees. The diagonal of a unit cube is that same length.

Why is the magnitude of a velocity called speed?

Speed is the scalar length of the velocity vector, with the direction dropped. A velocity of (3, 4) m/s has a speed of 5 m/s at an angle of 53.13 degrees.

Does the sign of a component affect the magnitude?

No, because each component is squared. The vectors (3, 4) and (-3, 4) both have magnitude 5, though their direction angles differ, at 53.13 and 126.87 degrees.

Which page should I use for adding vectors?

Use the vector addition calculator when the inputs are magnitudes and angles, since it builds the components and sums them. Use this page when the components are already known and only the length is needed.

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.