The formula
|v| = √(v₁² + v₂² + … + vₙ²)
What it means
The magnitude is Pythagoras generalised: square every component, add them, take the root. It works in two dimensions, in three, and in three hundred, which is why the same formula turns up in machine learning as in geometry.
How to do it by hand
- Square each component
- Add all the squares
- Take the square root
- For the unit vector, divide each component by that magnitude
What is worth knowing
The unit vector is the direction stripped of the length, and it is what lets you compare orientations regardless of scale. Dividing by the magnitude is called normalising, and it fails for exactly one vector: the zero vector, which has no direction to extract. The angles with the axes are the direction cosines, and they satisfy a neat identity — their squares always add to 1, which is the same Pythagorean statement wearing a different hat. In three dimensions those three angles pin the direction down completely.