Euler Hall — free maths guides

Compute the length of a vector

Take the square root of the dot product with itself. The idea in plain words, a worked example, and a check with the answers shown — part of the free Linear Algebra guides.

The whole skill in one line

∥u∥=u⋅u=u12+u22+⋯+un2.\|u\| = \sqrt{u\cdot u} = \sqrt{u_1^2+u_2^2+\cdots+u_n^2}.

The dot product of a vector with itself is the squared length, so one square root is still owed.

In the plane this is Pythagoras with the two entries as the legs: foru=(3,−4)u=(3,-4),

∥u∥=9+16=25=5.\|u\|=\sqrt{9+16}=\sqrt{25}=5.

Never negative, because it is a square root of a sum of squares.

Why lengths never add, and what a distance really is

Two facts worth internalising, because they cost marks repeatedly.

Lengths do not add.∥u+w∥\|u+w\| is not∥u∥+∥w∥\|u\|+\|w\| in general. Expanding:∥u+w∥2=∥u∥2+2u⋅w+∥w∥2\|u+w\|^2=\|u\|^2+2u\cdot w+\|w\|^2, so the cross term decides. Foru=(3,0)u=(3,0) andw=(0,4)w=(0,4) the lengths are33 and44, and∥u+w∥=5\|u+w\|=5 — not77. Lengths add only when the vectors point the same way.

A distance is the length of a difference. The distance betweenuu andww is∥u−w∥\|u-w\|, and computing it means differencing first, then taking the length of the result. Subtracting the two lengths gives∥u∥−∥w∥\|u\|-\|w\|, which can be negative and which measures something else entirely: how much longer one vector is, not how far apart their tips are.

Both facts come from the same place — the length is a square root, and square roots do not distribute over sums.

Three worked examples

Two dimensions.u=(3,−4)u=(3,-4):∥u∥=9+16=5\|u\|=\sqrt{9+16}=5. The classic334455.

Four dimensions.u=(1,5,5,7)u=(1,5,5,7):∥u∥2=1+25+25+49=100\|u\|^2=1+25+25+49=100, so∥u∥=10\|u\|=10. Note how much larger the squared length is than the length — it is easy to report100100 by accident, and100100 is the wrong answer by a factor of1010.

A distance.u=(1,2)u=(1,2) andw=(4,6)w=(4,6):u−w=(−3,−4)u-w=(-3,-4), so∥u−w∥=9+16=5\|u-w\|=\sqrt{9+16}=5. Same arithmetic as the first example, after one subtraction first. Subtracting lengths instead would give5−52\sqrt5-\sqrt{52}, which is negative — impossible for a distance.

By the end you can
  • Take the square root of the dot product with itself
  • Keep the squared length and the length apart
  • Compute a distance by differencing first and taking the length second
  • Bound a distance between two vectors using the triangle inequality
Check yourself

(a)∥(5,12)∥\|(5,12)\|?

(b)u⋅u=49u\cdot u=49. What is∥u∥\|u\|?

(c)u=(1,0)u=(1,0) andw=(0,1)w=(0,1). Compute∥u+w∥\|u+w\| and∥u∥+∥w∥\|u\|+\|w\| and compare.

Answers

(a)25+144=169=13\sqrt{25+144}=\sqrt{169}=13.

(b)77. One square root.

(c)u+w=(1,1)u+w=(1,1), so∥u+w∥=2≈1.414\|u+w\|=\sqrt2\approx1.414; while∥u∥+∥w∥=1+1=2\|u\|+\|w\|=1+1=2. They differ, which is the general case — lengths add only when the vectors point the same way. The gap is the cross term:∥u+w∥2=2\|u+w\|^2=2 against(∥u∥+∥w∥)2=4(\|u\|+\|w\|)^2=4.

Work out where to start — free, no accountAnswer six real questions — free, no account