Dot product of two vectors

Think about a triangle with sidelengths $|\textbf{a}|,|\textbf{b}|,|\textbf{c}|$. Then we can use the law of cosines.

$$ \begin{align} |\textbf{c}|^2&=|\textbf{a}|^2+|\textbf{b}|^2-2|\textbf{a}||\textbf{b}| \cos \theta \\ \implies 2|\textbf{a}||\textbf{b}| \cos \theta &= |\textbf{a}|^2+|\textbf{b}|^2-|\textbf{c}| = \textbf{a}\cdot \textbf{a} + \textbf{b} \cdot \textbf{b} - \textbf{c}\cdot \textbf{c} \end{align} $$

By the properties of the dot product and from the fact that $\textbf{c}=\textbf{b}-\textbf{a}$ we find that

$$ \begin{align} \textbf{c}\cdot \textbf{c} &=(\textbf{b}-\textbf{a}) \cdot (\textbf{b}-\textbf{a}) \\ &=(\textbf{b}-\textbf{a})\cdot \textbf{b} - (\textbf{b}-\textbf{a}) \cdot \textbf{a} \\ &= \textbf{b}\cdot \textbf{b} - \textbf{a}\cdot \textbf{b} - \textbf{b}\cdot \textbf{a} + \textbf{a}\cdot \textbf{a}. \end{align} $$

By substituting $\textbf{c}\cdot \textbf{c}$, we get $$ \begin{align} 2|\textbf{a}||\textbf{b}| \cos \theta &= \textbf{a}\cdot \textbf{a} + \textbf{b} \cdot \textbf{b} - (\textbf{b}\cdot \textbf{b} - \textbf{a}\cdot \textbf{b} - \textbf{b}\cdot \textbf{a} + \textbf{a}\cdot \textbf{a}) \\ &=2 \textbf{a}\cdot \textbf{b}. \end{align} $$


One way of showing this requires taking a Geometric look at stuff:

Think of $\vec{a},\vec{b}$ as the vertices of a triangle with one corner in the origin and sides of length $|\vec a|,|\vec b|,|\vec{a-b}|$. Now, use the Law of cosines, and inner product properties (over $\mathbb R$) to calculate $|\vec{a-b}|$:

The law of cosines gives you: $$|\vec{a-b}|^2=|\vec{a}|^2+|\vec{b}|^2-2|\vec{a}||\vec{b}|\cos\theta(a,b)$$

Inner product gives: $$|\vec{a-b}|^2=\langle\vec{a-b},\vec{a-b}\rangle=|\vec{a}|^2+|\vec{b}|^2-2\langle\vec{a},\vec{b}\rangle$$

from there on it's an easy proof (I left you the technical details).

Hope that helps