Step by step
The question
Question: find the unit vector in the direction of (1, 2, 2, 4).
v = [1; 2; 2; 4]
A unit vector has length 1.
To get one in the same direction, we divide v by its length.
unit vector: length 1, same direction
u = v ÷ ‖v‖
1 Find the length
The length: every entry squared, added, then the square root.
‖v‖ = √12 + 22 + 22 + 42
‖v‖ = √1 + 4 + 4 + 16
‖v‖ = √25
25 is 5 squared.
So the length is 5.
‖v‖ = 5
2 Divide every entry
Every entry divided by 5.
u = [1 over 5; 2 over 5; 2 over 5; 4 over 5]
Careful!
Every entry is divided by the length, not only the first one.
Careful: divide EVERY entry by the length
3 Check
Let's check: the length of u must be 1.
Its entries squared add up to 1, and the root of 1 is 1.
So the answer is right!
(15)2 + (25)2 + (25)2 + (45)2
= 125 + 425 + 425 + 1625 = 2525 = 1
Let's look back.
First: find the length.
Then: divide every entry.
Last: check.
Answer
Careful: divide EVERY entry by the length