Vector Magnitude Calculator
Compute the Euclidean magnitude (length) of a 3D vector as √(x² + y² + z²). Use it to normalise a vector, measure distance, or check the size of a direction vector.
Last updated: May 2026
Compare with similar
About this calculator
The magnitude (also called length or Euclidean norm) of a vector v = (x, y, z) is |v| = √(x² + y² + z²), a direct application of the 3D Pythagorean theorem. It generalises naturally to any dimension as |v| = √(Σ vᵢ²), and it represents the straight-line distance from the origin to the point with coordinates (x, y, z). Special cases: a zero vector (0, 0, 0) has magnitude zero — the only vector with this property; a unit vector has magnitude exactly 1, and any nonzero vector can be normalised to a unit vector by dividing by its magnitude (v̂ = v / |v|). The squared magnitude |v|² = x² + y² + z² equals the dot product v·v, which is computationally cheaper to evaluate (no square root) — use it when comparing distances rather than reporting them. Edge cases: very large or very small components can cause overflow or underflow in the squared sum even when the true magnitude is representable as a normal floating-point number; robust implementations scale the components to avoid this (e.g., compute |v| as max(|x|, |y|, |z|) · √((x/max)² + (y/max)² + (z/max)²)). For 2D vectors, set z = 0; the formula handles it correctly. The Euclidean norm is the standard L² norm — other norms (L¹ = sum of absolute values, L^∞ = max of absolute values) measure 'length' differently and are useful in different contexts.
How to use
Example 1 — classic 3-4-5 pythagorean triple in 3D. v = (3, 4, 0). Inputs: x = 3, y = 4, z = 0. Step 1: x² = 9. Step 2: y² = 16. Step 3: z² = 0. Step 4: sum = 25. Step 5: √25 = 5. Verify: the 2D vector (3, 4) has length 5 by the 3-4-5 Pythagorean triple; setting z = 0 confirms the 3D formula reduces correctly to 2D in that case ✓. Example 2 — true 3D vector with all components. v = (1, 2, 2). Inputs: x = 1, y = 2, z = 2. Step 1: x² = 1. Step 2: y² = 4. Step 3: z² = 4. Step 4: sum = 9. Step 5: √9 = 3. Verify: the magnitude is exactly 3 (another nice Pythagorean triple in 3D). Normalising: v̂ = (1/3, 2/3, 2/3), and |v̂| = √((1/9) + (4/9) + (4/9)) = √(9/9) = 1 ✓ — a unit vector by construction.
Frequently asked questions
How do I normalise a vector to unit length?
Divide every component by the vector's magnitude: v̂ = v / |v| = (x/|v|, y/|v|, z/|v|). The result is a unit vector pointing in the same direction as the original but with length exactly 1. This is useful whenever you want to separate 'direction' from 'magnitude' — for example, when applying a force of arbitrary strength in a given direction, computing surface normals in graphics, building basis vectors, or scaling input vectors before feeding them to a neural network. Edge case: if v is the zero vector, normalisation divides by zero and is undefined; you must handle this case separately (typically returning the zero vector or raising an error, depending on context). Numerical caveat: for nearly-zero vectors, normalisation amplifies floating-point noise dramatically — if |v| is, say, 10⁻¹⁵, the resulting unit vector is dominated by round-off error in the original components. In such cases, treating the vector as zero (or skipping it) is usually safer than producing an unreliable unit vector.
What's the difference between magnitude and squared magnitude?
Magnitude is |v| = √(x² + y² + z²); squared magnitude is |v|² = x² + y² + z². The squared form avoids the square root, which is computationally expensive on some platforms and can introduce floating-point inaccuracy. When you only need to compare magnitudes (e.g., 'is this point closer to A or to B?') or test whether a magnitude exceeds a threshold, use squared magnitudes — the comparison is equivalent (a > b iff a² > b² for non-negative a, b). This is a standard optimisation in graphics, collision detection, and nearest-neighbour search. The dot product v·v always equals |v|², so a single dot-product call computes squared magnitude directly. Only compute the square root when you actually need the length as a number — for plotting, reporting, or when normalising (you need 1/|v| as a scaling factor).
Why is the magnitude defined as √(sum of squares) and not, say, sum of absolute values?
The square-root-of-sum-of-squares definition is the L² (Euclidean) norm, derived from the geometric Pythagorean theorem and the requirement that the distance metric be rotation-invariant — rotating the coordinate axes shouldn't change distances. Other valid norms exist: L¹ (sum of absolute values, 'Manhattan distance' or 'taxicab norm'), L^∞ (maximum of absolute values, 'Chebyshev distance'), and general L^p (p-th root of sum of p-th powers). Each measures 'size' differently and is appropriate in different contexts: L² is the natural one for Euclidean geometry and physics; L¹ is preferred when sparsity matters (e.g., LASSO regression in statistics, taxicab routing problems); L^∞ is used in optimisation and approximation theory. For most physical, geometric, and 'common-sense' applications, L² (the magnitude this calculator computes) is correct because it matches our intuition for distance in flat space.
What are the common mistakes when computing magnitudes?
The biggest mistake is forgetting to square: writing √(x + y + z) instead of √(x² + y² + z²) is a frequent slip especially for new students. The second is forgetting the square root and reporting x² + y² + z² (the squared magnitude) when the magnitude was asked for. The third is sign confusion — magnitude is always non-negative, but if you compute it from differences (like distance between points), you might mistakenly take √((x1−x2)² ...) and worry about the sign of the differences; squaring makes the sign irrelevant. For very large or very small vectors, floating-point overflow or underflow in x² + y² + z² can produce nonsense answers even when the true magnitude fits in a double; robust implementations scale by the maximum component first. People also conflate magnitude with the norm of a matrix or the magnitude of a complex number, which have similar but distinct formulas. Finally, the magnitude of the zero vector is zero — but normalising the zero vector is undefined; don't divide by zero.
When should I not use this calculator?
Do not use it for vectors in dimensions other than 3 — set z = 0 for 2D, but for 4D and higher use a general n-dimensional norm calculator (or compute Σ vᵢ² and take the square root directly). It is not appropriate for non-Euclidean norms: L¹, L^∞, and weighted norms have different formulas and require their own tools or hand computation. Do not use it for the magnitude of a complex number (which is |a + bi| = √(a² + b²)) — though the formula looks similar, a complex number is conceptually a 2D vector and dedicated complex-number tools handle other operations you typically need alongside the magnitude. It is not the right tool for the determinant or norm of a matrix, which have separate definitions. Avoid it for very large or small vectors without scaling, where floating-point overflow/underflow can corrupt the result. Finally, for distance between two points use the dedicated distance calculator (|p1 − p2|), or compute the vector difference first and then the magnitude — both approaches give the same answer.