Why are the two dot product definitions equal?

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?

Solutions Collecting From Web of "Why are the two dot product definitions equal?"

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)=

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.

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(θ)