cosθ = (u→{\displaystyle {\overrightarrow {u}}} • v→{\displaystyle {\overrightarrow {v}}}) / (||u→{\displaystyle {\overrightarrow {u}}}|| ||v→{\displaystyle {\overrightarrow {v}}}||) ||u→{\displaystyle {\overrightarrow {u}}}|| means “the length of vector u→{\displaystyle {\overrightarrow {u}}}. " u→{\displaystyle {\overrightarrow {u}}} • v→{\displaystyle {\overrightarrow {v}}} is the dot product (scalar product) of the two vectors, explained below.
Example: The two-dimensional vector u→{\displaystyle {\overrightarrow {u}}} = (2,2). Vector v→{\displaystyle {\overrightarrow {v}}} = (0,3). These can also be written as u→{\displaystyle {\overrightarrow {u}}} = 2i + 2j and v→{\displaystyle {\overrightarrow {v}}} = 0i + 3j = 3j. While our example uses two-dimensional vectors, the instructions below cover vectors with any number of components.
||u||2 = u12 + u22. If a vector has more than two components, simply continue adding +u32 + u42 + . . . Therefore, for a two-dimensional vector, ||u|| = √(u12 + u22). In our example, ||u→{\displaystyle {\overrightarrow {u}}}|| = √(22 + 22) = √(8) = 2√2. ||v→{\displaystyle {\overrightarrow {v}}}|| = √(02 + 32) = √(9) = 3.
The examples below use two-dimensional vectors because these are the most intuitive to use. Vectors with three or more components have properties defined with the very similar, general case formula.
||(a - b)||2 = ||a||2 + ||b||2 - 2||a|| ||b||cos(θ)
(a→{\displaystyle {\overrightarrow {a}}} - b→{\displaystyle {\overrightarrow {b}}}) • (a→{\displaystyle {\overrightarrow {a}}} - b→{\displaystyle {\overrightarrow {b}}}) = a→{\displaystyle {\overrightarrow {a}}} • a→{\displaystyle {\overrightarrow {a}}} + b→{\displaystyle {\overrightarrow {b}}} • b→{\displaystyle {\overrightarrow {b}}} - 2||a|| ||b||cos(θ)
a→{\displaystyle {\overrightarrow {a}}} • a→{\displaystyle {\overrightarrow {a}}} - a→{\displaystyle {\overrightarrow {a}}} • b→{\displaystyle {\overrightarrow {b}}} - b→{\displaystyle {\overrightarrow {b}}} • a→{\displaystyle {\overrightarrow {a}}} + b→{\displaystyle {\overrightarrow {b}}} • b→{\displaystyle {\overrightarrow {b}}} = a→{\displaystyle {\overrightarrow {a}}} • a→{\displaystyle {\overrightarrow {a}}} + b→{\displaystyle {\overrightarrow {b}}} • b→{\displaystyle {\overrightarrow {b}}} - 2||a|| ||b||cos(θ) - a→{\displaystyle {\overrightarrow {a}}} • b→{\displaystyle {\overrightarrow {b}}} - b→{\displaystyle {\overrightarrow {b}}} • a→{\displaystyle {\overrightarrow {a}}} = -2||a|| ||b||cos(θ) -2(a→{\displaystyle {\overrightarrow {a}}} • b→{\displaystyle {\overrightarrow {b}}}) = -2||a|| ||b||cos(θ) a→{\displaystyle {\overrightarrow {a}}} • b→{\displaystyle {\overrightarrow {b}}} = ||a|| ||b||cos(θ)