I have an intuitive understanding of why $a\dot{}b=|a||b|\cos{\theta}$ geometrically. The projection of one vector onto another makes sense to me when explaining the origin of this geometric definition.

What I don't understand is why $a\dot{}b=a_xb_x + a_yb_y = |a||b|\cos{\theta}$. How does the algebraic version of the dot product connect to the geometric version? Can you derive the algebraic definition from the geometric? I read the answers to this question, but the proofs seem to depend on the actual algebraic definition to arrive at it.

My main question is, why are the two definitions really equal?

  • $\begingroup$ Can you prove it in two dimensions? Also, some places this is taken as the definition of angles in higher dimensions. So it's not a matter of proving that this is the case, but rather that $\theta$ is defined so that it works. $\endgroup$
    – Arthur
    Commented Aug 2, 2017 at 16:19
  • $\begingroup$ You can find a proof of $a\cdot b=\|a\|\|b\|\cos\theta$, if that's helpful for you, here: proofwiki.org/wiki/Cosine_Formula_for_Dot_Product $\endgroup$
    – Edu
    Commented Aug 2, 2017 at 16:26
  • $\begingroup$ @Edu So the geometric version is derived from the algebraic, not the other way around? $\endgroup$
    – name
    Commented Aug 2, 2017 at 16:27
  • $\begingroup$ Geometrically, consider the triangle formed by the vectors $a$, $b$, and $a-b$ (where we think of $a$ and $b$ having a common origin, and the origin of $a-b$ placed at the end of $a$). This triangle has sides of length $\|a\| = a\cdot a$, $\|b\| = b\cdot b$, and $\|a-b\| = (a-b)\cdot (a-b) = a\cdot a - 2a\cdot b + b\cdot b$. Play with the Law of Cosines, and you should get what you want. $\endgroup$
    – Xander Henderson
    Commented Aug 2, 2017 at 16:30
  • $\begingroup$ Absolutely. The dot product is a particular case of an inner product. For the Euclidean dot product you have this formula, which is slightly different for complex vectors, for instance. $\endgroup$
    – Edu
    Commented Aug 2, 2017 at 16:32

4 Answers 4


Note that with $a$ and $b$ two sides of a triangle and $\theta$ the angle between them, the third side is $b-a$ and (cosine rule) $$|b-a|^2=|a|^2+|b|^2-2|a||b|\cos \theta$$ so that $$2|a||b|\cos\theta=\Sigma a_i^2+\Sigma b_i^2-\Sigma (b_i-a_i)^2=2\Sigma a_ib_i$$ so that $$|a||b|\cos\theta=\Sigma a_ib_i$$ and the two definitions coincide. You can work the calculations backwards if necessary.

  • $\begingroup$ You are missing the case in which $a$ and $b$ are scalar multiples. $\endgroup$
    – Edu
    Commented Aug 2, 2017 at 16:43
  • $\begingroup$ @Edu then $\cos \theta=1$ and everything works? The cosine rule applies to the degenerate triangle you get. $\endgroup$ Commented Aug 2, 2017 at 17:00
  • $\begingroup$ Of course, is a trivial case, no problems with your proof, not even close to think about downvoting or something. I just think is worth it mention what happens if $a=cb$, for some scalar $c$. $\endgroup$
    – Edu
    Commented Aug 2, 2017 at 17:03
  • $\begingroup$ Btw, $\cos\theta=\pm 1$ in that case, depending on the sign of $c$. $\endgroup$
    – Edu
    Commented Aug 2, 2017 at 17:07

First of all you can prove from the geometrical definition that distributive property holds for scalar product: $(\vec a+\vec b)\cdot\vec c=\vec a\cdot\vec c+\vec b\cdot\vec c$ (see diagram below for a sketch of the proof).

enter image description here

Then, you just have to decompose two vectors along an orthonormal coordinate system: $\vec a= a_x\vec i+a_y\vec j+a_z\vec k$,$\quad$ $\vec b= b_x\vec i+b_y\vec j+b_z\vec k$, and apply twice the distributive property, taking into account that $\vec i\cdot\vec i=\vec j\cdot\vec j=\vec k\cdot\vec k=1$ and $\vec i\cdot\vec j=\vec j\cdot\vec k=\vec k\cdot\vec i=0$: $$ \vec a\cdot\vec b= (a_x\vec i+a_y\vec j+a_z\vec k)\cdot(b_x\vec i+b_y\vec j+b_z\vec k)= a_xb_x+a_yb_y+a_zb_z. $$


Assuming $a\cdot b = |a||b|\cos( \theta)$

and that $|a| = \sqrt{(x_1)^2 + (y_1)^2}$

and that $|b| = \sqrt{(x_2)^2 + (y_2)^2}$

Let $\gamma -\theta = \alpha$

For $\theta$ is the angle between the two vectors, $a$ and $b$, and not necessarily the angle between the 'outermost' line and say the x-axis.

Thus $\gamma$ is the angle between the outermost vector and the x-axis, whilst $\alpha$ is the angle between the other line and the x-axis.

Thus $\theta=\gamma-\alpha$ and more importantly by the trig identity: $\cos(a+b) = \cos(a)\cos(b)-\sin(a)\sin(b)$

$$\begin{equation}\begin{aligned} a\cdot b &= |a||b|\cos(\theta)\\ &=|a||b|\cos(\gamma - \alpha)\\ &=|a||b|\biggl(\cos(\gamma)\cos(\alpha) - \sin(\gamma)\sin(\alpha)\biggl)\\ &=|a||b|\cos(\gamma)\cos(-\alpha) - |a||b|\sin(\gamma)\sin(-\alpha)\\ \end{aligned}\end{equation}\tag{1}$$

Then if $|a|$ was the outermost vector you realize that

$|a|\cos(\gamma) = (x_1)$, and that

$|a|\sin(\gamma) = (y_1)$

Making $|b|$ the innermost line, and that

$|b|\cos(-\alpha) = |b|\cos(\alpha) = (x_2)$, and that

$|b|\sin(-\alpha) = -|b|\sin(\alpha) = (-y_1)$

Because $\cos(-a) = \cos(a)$ and $\sin(-a) = -\sin(a)$

Plugging all that into 1 you get that $a\cdot b = (x_1)(x_2) - (y_1)(-y_2)$

And you finally get $a\cdot b = (x_1)(x_2) + (y_1)(y_2)$


Define A, B, C is vector, and a, b and c scale value (distance) of A,B,C
define C=A-B, so A, B and C become a triangle

based on Law of cosines, c² = a² + b² - 2abcos(θ)

because c.c=C²
C.C=A.A + B.B - 2abcos(θ)
because C = A - B
C·C => (A -B)·(A - B) => (A·A - 2A·B + B·B)
so A·A - 2A·B + B·B=A.A + B.B - 2abcos(θ)
because A.A=A.A and B.B=B.B
=> - 2A·B B=- 2abcos(θ)
=> A.B=abcos(θ)

  • 1
    $\begingroup$ Try to use math formatting for better readability. See notation help. $\endgroup$ Commented Aug 2, 2017 at 17:36
  • $\begingroup$ Thanks I just joined this community, I will try to use the math formatting next time $\endgroup$
    – ben
    Commented Aug 2, 2017 at 20:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .