Compute the unit vector (normalization) of any vector from 2D to 6D. Verify ‖û‖ = 1, see direction angles, component contributions, scaling, and compare original vs unit vector visually.
A unit vector (often written with a hat: û) is a vector whose magnitude is exactly 1. To find the unit vector in the direction of any nonzero vector v, simply divide v by its magnitude: û = v / ‖v‖. This operation — called normalization — preserves the direction of the original vector but rescales its length to unity.
Unit vectors are the backbone of coordinate systems (the standard basis vectors ê₁, ê₂, ê₃ are all unit vectors), orientation representations, and directional queries. When you compute the dot product of two unit vectors, the result is precisely the cosine of the angle between them — this is the foundation of cosine similarity in machine learning and information retrieval.
This calculator handles vectors from 2D up to 6D. Enter the components of your vector, and it will compute the unit vector, verify that ‖û‖ = 1, show direction angles for each axis, break down how much each component contributes to the total magnitude, and compare original vs. unit vector magnitudes side by side with dual bar charts. You can also multiply the unit vector by any scalar k to create a vector of length |k| in the same direction — useful for setting a desired speed, force, or step size.
Six presets cover common cases, from the Pythagorean triple (3, 4) to higher-dimensional uniform vectors. The component breakdown table lists each axis's contribution percentage, and a properties reference summarizes key facts about unit vectors, including their role in orthonormal bases and cosine similarity.
Normalization appears in physics (unit direction of a force), computer graphics (surface normals must be unit length for correct lighting), game development (movement direction), data science (feature normalization), and numerical methods (Gram-Schmidt process produces orthonormal vectors).
Normalizing a vector requires computing the magnitude (a square root of summed squares) and dividing each component — easy to get wrong in higher dimensions where the sum has many terms. This calculator handles 2D through 6D vectors, computes the unit vector, verifies ‖û‖ = 1, reports direction angles and component contribution percentages, supports optional rescaling by a factor k, and includes a comparison bar chart of original vs. unit magnitudes. Normalization is the essential first step in any direction-based computation.
û = v / ‖v‖ = (v₁/‖v‖, v₂/‖v‖, …, vₙ/‖v‖); ‖û‖ = 1
Result: û = (3/13, 4/13, 12/13) ≈ (0.2308, 0.3077, 0.9231)
‖v‖ = √(9 + 16 + 144) = √169 = 13. Divide each component by 13: û = (0.2308, 0.3077, 0.9231). ‖û‖ = 1 ✓.
Given a vector v = (v₁, v₂, …, vₙ), the unit vector is û = v / ‖v‖ where ‖v‖ = √(v₁² + v₂² + … + vₙ²). Each component is divided by the same scalar, so the direction is preserved but the magnitude becomes exactly 1. The operation is undefined for the **zero vector** (‖v‖ = 0) because there is no unique direction to preserve. Normalization is also called **L2 normalization** in machine learning contexts, distinguishing it from L1 normalization (dividing by the sum of absolute values).
The components of the unit vector are exactly the **direction cosines**: ûᵢ = cos θᵢ, where θᵢ is the angle between v and the iᵗʰ coordinate axis. The identity cos²θ₁ + cos²θ₂ + … + cos²θₙ = 1 follows directly from ‖û‖ = 1. For 3D, the three direction angles α, β, γ give a complete orientation description. For 2D, the single polar angle θ = atan2(y, x) is often more practical. These angles connect algebraic vector representations to geometric interpretations.
In **computer graphics**, surface normals must be unit length for correct lighting calculations (the diffuse shader computes n̂ · l̂). In **game development**, a movement direction is normalized before multiplying by speed to produce a velocity vector of the correct magnitude. In **machine learning**, feature normalization ensures that no single dimension dominates distance calculations in k-NN or clustering. The **Gram-Schmidt** process depends on normalization at each step to produce orthonormal bases. Normalization is the bridge between "which direction" and "how far" in virtually every quantitative field.
A unit vector is a vector with magnitude 1. It represents pure direction with no magnitude information.
Divide the vector by its magnitude: û = v / ‖v‖. Each component is scaled by 1/‖v‖.
No. Division by zero is undefined, so the zero vector (0, 0, …) has no unit vector. You must check ‖v‖ ≠ 0 before normalizing.
Direction cosines are the cosines of the angles between the vector and each coordinate axis. They are numerically equal to the components of the unit vector.
Normalizing feature vectors ensures that distance and similarity metrics are not dominated by features with large magnitudes. Cosine similarity requires unit vectors to work as intended.
The standard basis of ℝⁿ consists of n unit vectors each pointing along one coordinate axis: ê₁ = (1,0,…,0), ê₂ = (0,1,…,0), etc. Use this as a practical reminder before finalizing the result.