Skip to content
Math

Vector Magnitude Calculator

Enter a vector in 2D, 3D, 4D or 5D space to get its magnitude, the normalised unit vector, and the direction angles and cosines. The calculator shows every arithmetic step so you can follow the working exactly.

Your details

Choose how many components your vector has.
Reveals the normalised unit vector and the direction angles (degrees) for 3D vectors.
Magnitude |v|Non-zero vector
5
|v|² (sum of squares)25
Unit vector x-hat0.6
Unit vector y-hat0.8
Unit vector z-hat0
Direction angle alpha (x-axis)53.1301deg
Direction angle beta (y-axis)36.8699deg
Direction angle gamma (z-axis)90deg
Direction cosine cos(alpha)0.6
Direction cosine cos(beta)0.8
Direction cosine cos(gamma)0
x-hat0.6
y-hat0.8
z-hat0

The magnitude of this 3D vector is 5.

  • This 3D vector has magnitude 5, the straight-line distance from the origin to its tip.
  • Magnitude is always zero or positive because it captures size, not direction. Reversing every component sign leaves it unchanged.
  • The unit vector is (0.6, 0.8, 0), pointing the same way with length 1.
  • The direction angles are alpha = 53.13 deg (from x-axis), beta = 36.87 deg (from y-axis), gamma = 90 deg (from z-axis).

Next stepUse the unit vector components above to describe the direction without a length, or multiply them by any scalar to scale the vector.

Formula

v=i=1nvi2,v^=vv,cosα=xv|\mathbf{v}| = \sqrt{\sum_{i=1}^{n} v_i^2}, \quad \hat{v} = \frac{\mathbf{v}}{|\mathbf{v}|}, \quad \cos\alpha = \frac{x}{|\mathbf{v}|}

Worked example

For v = (3, 4, 0): |v| = sqrt(3^2 + 4^2 + 0^2) = sqrt(25) = 5. Unit vector = (0.6, 0.8, 0). Alpha = arccos(0.6) = 53.13 deg, beta = arccos(0.8) = 36.87 deg, gamma = arccos(0) = 90 deg.

What vector magnitude means

The magnitude of a vector, written |v| and also called its norm or Euclidean length, is the straight-line distance from the origin to the tip of the vector. It follows directly from the Pythagorean theorem: in two dimensions a vector with components x and y forms the legs of a right triangle whose hypotenuse has length sqrt(x^2 + y^2). Adding a third dimension simply adds z^2 under the same root, and the pattern extends without limit to four, five or any number of dimensions by summing the square of every component and taking one square root. The result is always zero or positive because it measures size alone and discards direction, which is why a vector and its exact reverse share the same magnitude.

How to compute magnitude step by step

Square every component. Add those squares together to get the squared magnitude, sometimes written |v|^2 or the dot product v * v. Take the positive square root of the sum. That three-step process works in any number of dimensions. The intermediate squared magnitude is useful on its own because many formulas in physics and statistics, such as kinetic energy (0.5 * m * |v|^2) or the variance of a displacement, operate on the squared length to avoid an unnecessary square root.

Unit vectors and normalisation

A unit vector is any vector whose magnitude is exactly 1. To normalise a non-zero vector, divide each of its components by the magnitude: x-hat = x / |v|, y-hat = y / |v|, z-hat = z / |v|. The result points in the same direction but has length 1. Unit vectors are the building blocks of orientation: surface normals in computer graphics, axis directions in robotics, feature directions in machine learning, and basis vectors in linear algebra are all unit vectors. The zero vector cannot be normalised because division by zero is undefined.

Direction angles and direction cosines

For a 3D vector, the direction angles alpha, beta and gamma are the angles the vector makes with the positive x, y and z axes respectively. They are found by taking the arccosine of each direction cosine. A direction cosine is simply the corresponding component of the unit vector: cos(alpha) = x / |v|, cos(beta) = y / |v|, cos(gamma) = z / |v|. A key identity ties them together: cos^2(alpha) + cos^2(beta) + cos^2(gamma) = 1, which is just the statement that the unit vector itself has magnitude 1. Direction cosines appear in structural engineering (load resolution), aerospace (attitude description), and computer graphics (lighting calculations).

Higher-dimensional vectors (4D and 5D)

The magnitude formula is identical in four or five dimensions: sum the squares of all components and take the square root. A 4D vector (x, y, z, w) has |v| = sqrt(x^2 + y^2 + z^2 + w^2). This comes up in physics (special relativity uses a four-vector combining three spatial coordinates and one time coordinate), machine learning (embedding vectors routinely have hundreds of dimensions), and signal processing. Direction angles lose their familiar geometric interpretation in dimensions above 3, but the unit vector, magnitude, and squared magnitude remain well-defined and useful.

Example vectors: magnitude, unit vector and direction angles (3D)

Vector (x, y, z)|v|Unit vector (x-hat, y-hat, z-hat)AlphaBetaGamma
(3, 4, 0)5(0.6, 0.8, 0)53.13 deg36.87 deg90 deg
(1, 0, 0)1(1, 0, 0)0 deg90 deg90 deg
(2, 3, 6)7(0.2857, 0.4286, 0.8571)73.40 deg64.62 deg31.00 deg
(1, 2, 2)3(0.333, 0.667, 0.667)70.53 deg48.19 deg48.19 deg
(5, 12, 0)13(0.3846, 0.9231, 0)67.38 deg22.62 deg90 deg
(1, 1, 1)1.732(0.577, 0.577, 0.577)54.74 deg54.74 deg54.74 deg

Magnitude = sqrt(x^2 + y^2 + z^2). Direction angles in degrees, rounded to two decimal places.

Frequently asked questions

Can vector magnitude be negative?

No. Magnitude is a length, so it is always zero or positive. It equals the positive square root of a sum of squares, and squares are never negative. Changing the sign of any component makes no difference because (-a)^2 = a^2.

How is a unit vector different from a regular vector?

A unit vector has magnitude exactly 1. To create one from any non-zero vector, divide each component by the magnitude (this is called normalisation). The unit vector keeps the same direction as the original but its length becomes 1. It is often written with a hat, for example v-hat. The zero vector cannot be normalised.

What are direction cosines and why do they matter?

Direction cosines are the cosines of the angles that a 3D vector makes with the positive x, y and z axes: cos(alpha) = x / |v|, cos(beta) = y / |v|, cos(gamma) = z / |v|. They are exactly the components of the unit vector. Their squares always sum to 1, a fact used in structural engineering to resolve forces along axes and in computer graphics to compute lighting angles.

How do I find the magnitude of a 4D or 5D vector?

Exactly the same way as 2D or 3D: square every component, add the squares, take the square root. For a 4D vector (x, y, z, w) this gives |v| = sqrt(x^2 + y^2 + z^2 + w^2). Select the "4D vector" or "5D vector" option at the top of this calculator and the extra component fields appear automatically.

What is the relationship between magnitude and the dot product?

The magnitude squared equals the dot product of the vector with itself: |v|^2 = v * v = x*x + y*y + z*z. This identity means the magnitude of any vector can be found by computing the self dot product and taking the square root. It also underpins the formula for the angle between two vectors: cos(theta) = (u * v) / (|u| * |v|).

How do I check that my normalisation is correct?

After dividing each component by the magnitude, compute the magnitude of the resulting unit vector. If the normalisation is correct it will equal exactly 1 (apart from rounding at the last decimal place). Equivalently, the sum of squares of the unit vector components should equal 1.

Sources

Written by Dr. Rajiv Menon, PhD Applied Mathematician · Bengaluru, India

Applied mathematician bridging algebraic theory and computational tools for students, engineers, and everyday problem-solvers.

Search 3,500+ calculators

Loading search…