The Length of a Vector

How long is a vector? Its two components form the legs of a right triangle, and the arrow is the hypotenuse — so the length is exactly what Pythagoras says it is. The magnitude (or length, or norm) of \vec{v} = \begin{bmatrix} v_x \\ v_y \end{bmatrix} is

\lVert \vec{v} \rVert = \sqrt{v_x^2 + v_y^2}.

For instance \left\lVert \begin{bmatrix} 3 \\ 4 \end{bmatrix} \right\rVert = \sqrt{9 + 16} = \sqrt{25} = 5. The bars say "size of", and the answer is never negative — a length can't be.

The hypotenuse

Steer the vector and watch the right triangle. The two dashed legs are the components; the bold arrow is the hypotenuse, and its length is read off live below. When you reach (3, 4) or (6, 8) you'll get a whole number — those are the famous Pythagorean triples hiding in plain sight.

Distance is the length of a difference

Length quietly gives us distance. The gap between two points A and B is just the magnitude of the displacement between them:

\text{distance}(A, B) = \lVert \vec{B} - \vec{A} \rVert.

That's the everyday distance formula, dressed in vector clothes — and the same quantity a machine-learning model uses to decide which data points are "near" one another.