3
$\begingroup$

While watching a video about dot products (https://www.youtube.com/watch?v=WDdR5s0C4cY), the following formula is presented for finding the angle between two vectors:

For vectors $a$, and $b$, $$\cos( \theta ) = \frac{(a, b)}{ \| a \| \| b \| }$$ where $(a,b)$ is the dot product of $a$ and $b$.

How is this formula derived?

$\endgroup$
7
$\begingroup$

There are several derivations of this online. Here's where you can start.

Define two vectors $\textbf{a}$ and $\textbf{b}$. Then $ \textbf{a} - \textbf{b}$ is the vector that connects their endpoints and makes a triangle.

Therefore, we have a triangle with side lengths $|\textbf{a}|$, $|\textbf{b}|$, and $|\textbf{a} - \textbf{b}|$. Let the angle between the two vectors be $\theta$. By the Law of Cosines, we have

$$|\textbf{a} - \textbf{b}|^2 = |\textbf{a}|^2 + |\textbf{b}|^2 - 2 |\textbf{a}| |\textbf{b}| \cos (\theta)$$

Now, use the fact that $$ \begin{align*} |\textbf{a}- \textbf{b}|^2 &= (\textbf{a}- \textbf{b}) \cdot (\textbf{a}- \textbf{b})\\ &= \textbf{a} \cdot \textbf{a} - 2 (\textbf{a} \cdot \textbf{b}) + \textbf{b} \cdot \textbf{b} \\ &= |\textbf{a}|^2 - 2 (\textbf{a} \cdot \textbf{b}) + |\textbf{b}|^2 \end{align*} $$

Simplify this equation, and you will get the desired formula.

$\endgroup$
  • $\begingroup$ Interesting way of looking at it, I like it. $\endgroup$ – FundThmCalculus Jul 29 '15 at 15:30
  • $\begingroup$ How do you do the last three steps without using some definition for dot ptoduct, and in which case what is your definition? Eg why is it commutative, and why is $a.a=|a|^2$? $\endgroup$ – David Quinn Jul 29 '15 at 17:13
  • $\begingroup$ I'm using the definition that dot product of the two vectors is the sum of the product of corresponding components. If we have $\textbf{a} = \langle a_1, a_2, \dots a_n \rangle$. Then, by the definition of dot product, we have $$\textbf{a} \cdot \textbf{a} = a_1^2 + a_2^2 + \dots + a_n^2$$ which is equal to $|\textbf{a}|^2$. $\endgroup$ – Ashkay Jul 29 '15 at 17:19
6
$\begingroup$

Since $(a,b)$ is independent of the basis, just choose a basis where $a$ lies along the $x$ axis: $a=(|a|,0)$, so that: $$ {(a,b)\over|a||b|}={b_x\over|b|}=\cos(\theta), $$ where $\theta$ is the angle between $b$ and $x$ axis (as you may recall from trigonometry), which is the same as the angle between $a$ and $b$.

$\endgroup$
  • $\begingroup$ just so you know, you can make standard math functions such as $\sin$ and $\cos$ appear in non-italics by putting a \ in front of the word: \cos. $\endgroup$ – FundThmCalculus Jul 29 '15 at 15:32
  • $\begingroup$ Yes, I forgot that. Thanks! $\endgroup$ – Aretino Jul 29 '15 at 15:35
1
$\begingroup$

I think Augustin was answering a much more general question. In two dimensions, where we have "cosine" already defined, from trigonometry, one can show that the "dot product", defined in some other way, is equal to the lengths of the two vectors times the cosine of the angle between them.

But in higher dimension spaces, $\mathbb{R}^n$, we can use that formula to define the angle between two lines.

$\endgroup$
1
$\begingroup$

It's a trig identity, really.

Two vectors determine a plane. Without loss of generality, we'll take that to be the $xy$-plane. Now, let $A$ and $B$ be the angles that $\overrightarrow{a}$ and $\overrightarrow{b}$ make with the (positive) $x$-axis; and let $r$ and $s$ be the respective magnitudes. Then, the $xy$-coordinates of the vectors can be written as

$$\overrightarrow{a}= r\,(\cos A, \sin A) \qquad\text{and}\qquad \overrightarrow{b} = s \,(\cos B, \sin B )$$ so that

$$\overrightarrow{a}\cdot\overrightarrow{b} = r s \cos A \cos B + r s\sin A \sin B = r s \cos(A-B)$$

$\endgroup$
0
$\begingroup$

This is a part of the geometric definition, but originally comes from the algebraic definition (see here)

In Euclidean space, you have to define a vector. With that vector, following the algebraic definition

$\vec{a} \cdot \vec{b} = \sum_i a_i b_i$

Imagine at the origin you have two vectors, pointing from $O$ to $A = (a_i)_{i=1}^n$ and to $B = (b_i)_{i=1}^n$. You can pick $n=2,3$ for the sake of imagination.

Now drop a perpendicular line from $B = (b_i)_{i=1}^n$ onto $OA$, crossing $OA$ at a point, called $H$. Let $\theta$ be the angle $(OA,OB)$. After a long calculation, the length of $OH$ is $\frac{\sum_i a_i b_i}{||a||} $.

Observe that $\cos \theta = \frac{|OH|}{|OB|}$, you now arrive at the formula

$\cos \theta = \frac{\vec{a}\cdot \vec{b}} {||a|| \cdot ||b||}$

$\endgroup$
0
$\begingroup$

By the law of cosines, $$\tag 1 \left\Vert{\mathbf a - \mathbf b}\right\Vert^2 = \left\Vert{\mathbf a}\right\Vert^2 + \left\Vert{\mathbf b}\right\Vert^2 - 2 \left\Vert{\mathbf a}\right\Vert \left\Vert{\mathbf b}\right\Vert \cos \theta$$ whereas, using the definition of the dot product, $$\tag 2 \left \| \mathbf a-\mathbf b \right \|^{2}=(\mathbf a-\mathbf b)\cdot (\mathbf a-\mathbf b)=\left \| \mathbf a \right \|^{2}+\left \| \mathbf b \right \|^{2}-2(\mathbf a \cdot \mathbf b)$$ Now combine $(1)$ and $(2)$

$\endgroup$
0
$\begingroup$

I use projection to remember this formula. Let $\vec a$ and $\vec b$ be two vectors. Then, projection of $\vec a$ over $\vec b$ is defined as:

$$proj_{\vec b}(\vec a)=\left( \frac{\vec a \cdot \vec b}{\vec b \cdot \vec b} \right) \vec b$$

Then we can form the following equality:

$$\begin{aligned} ||\vec a||\cos \theta &= ||proj_{\vec b}(\vec a)|| \\ &=\left( \frac{\vec a \cdot \vec b}{\vec b \cdot \vec b} \right) ||\vec b|| \\ &=\frac{(\vec a \cdot \vec b)}{||\vec b||^2} ||\vec b|| \end{aligned} $$

Rearranging both sides, we get

$$\vec a \cdot \vec b=||\vec a|| ||\vec b|| \cos \theta$$

The derivation of the formula for projection is here.

$\endgroup$
-2
$\begingroup$

Dot product of two vectors is defined as the product of the magnitude of the two vectors together with the cosine of the angle between the two vectors. Mathematically,
a.b=|a||b|cos§

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.