# Dot Product
**The sum of the products of corresponding entries of two equal dimension [[Vector|vectors]].**
> [!NOTE] Dot Product
> The *dot product* or *scalar product* of two vectors $\mathbf{a}=[a_{1}, a_{2},\dots, a_{n}]$ and $\mathbf{b}=[b_{1}, b_{2},\dots, b_{n}]$ is
> $\mathbf{a}\cdot\mathbf{b}=\sum_{i=1}^{n}a_{i}b_{i}=a_{1}b_{1}+a_{2}b_{2}+\cdots+a_{n}b_{n}$
Algebraically, the dot product can be defined for any two equal length sequence of numbers, though these are most commonly vectors. The term "scalar product" derives from that fact that it is an operation on two vectors which outputs a scalar.
The dot product can also be defined geometrically and the two definitions are equivalent if the numbers are [[Cartesian Coordinate System|Cartesian coordinates]].
## Geometric definition
![[DotProductGeometric.svg|300]]
> [!NOTE] Geometric definition of the dot product
> The *dot product* of two vectors $\mathbf{a}=[a_{1}, a_{2},\dots, a_{n}]$ and $\mathbf{b}=[b_{1}, b_{2},\dots, b_{n}]$ is
> $\mathbf{a}\cdot\mathbf{b}=\|\mathbf{a}\|\;\|\mathbf{b}\|\cos\theta$
> - $\|\mathbf{a}\|$, $\|\mathbf{b}\|$ - the *magnitudes* of $\mathbf{a}$ and $\mathbf{b}$
> - $\theta$ - the *angle* between $\mathbf{a}$ and $\mathbf{b}$.
The geometric definition of the dot product can be used to calculate the [[scalar projection]] of one vector onto another if the angle between them is not known.
The geometric definition also implies that if two vectors are *orthogonal*, that is perpendicular to each other, then the dot product between them is *zero*.
> [!NOTE]- Proof of definition equivalence
> A proof that the two definitions of the dot product are equivalent uses triangles and the [[cosine rule]].
>
> Suppose the dot product of the vectors $\mathbf{a}$ and $\mathbf{b}$ is to be found. A third vector $\mathbf{c}$ can be drawn from the head of $\mathbf{b}$ to the head of $\mathbf{a}$, thus forming a triangle.
>
> ![[DotProductProof.svg|300]]
>
> The vector $\mathbf{c}$ is equivalent to the [[Vector#Subtraction|vector subtraction]] of the other two vectors, and thus
> $\mathbf{c}=\mathbf{a-b}=(a_{1}-b_{1}, a_{2}-b_{2},\dots, a_{n}-b_{n})$
> $\|\mathbf{c}\|=\sqrt{(a_{1}-b_{2})^{2}+(a_{2}-b_{2})^{2}+\dots+(a_{n}-b_{2})^{2}}$
> To substitute the magnitude into the cosine rule, it must be squared. Thus,
> $\begin{align}
> \|\mathbf{c}\|^{2}&=(a_{1}-b_{1})^{2}+(a_{2}-b_{2})^{2}+\cdots+(a_{n}-b_{n})^{2} \\
> &=(a_{1}^{2}+a_{2}^{2}+\cdots+a_{n}^{2})+(b_{1}^{2}+b_{2}^{2}+\cdots+b_{n}^{2})-2(a_{1}b_{1}+a_{2}b_{2}+\cdots+a_{n}b_{n}) \\
> &=\|\mathbf{a}\|^{2}+\|\mathbf{b}\|^{2}-2(a_{1}b_{1}+a_{2}b_{2}+\cdots+a_{n}b_{n})
> \end{align}$
> The cosine rule states that
> $\|\mathbf{c}\|^{2}=\|\mathbf{a}\|^{2}+\|\mathbf{b}\|^{2}-2\|\mathbf{a}\|\;\|\mathbf{b}\|\cos\theta$
> Combining the two expressions thus gives
> $\begin{align}
> \|\mathbf{a}\|^{2}+\|\mathbf{b}\|^{2}-2(a_{1}b_{1}+a_{2}b_{2}+\cdots+a_{n}b_{n})&=\|\mathbf{a}\|^{2}+\|\mathbf{b}\|^{2}-2\|\mathbf{a}\|\;\|\mathbf{b}\|\cos\theta \\
> a_{1}b_{1}+a_{2}b_{2}+\cdots+a_{n}b_{n}&=\|\mathbf{a}\|\;\|\mathbf{b}\|\cos\theta \\
> \therefore \mathbf{a}\cdot\mathbf{b}&=\|\mathbf{a}\|\;\|\mathbf{b}\|\cos\theta
> \end{align}$
## Properties
| Property | Description |
|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------:|
| $\mathbf{a}\cdot\mathbf{b}=\mathbf{b}\cdot\mathbf{a}$ | Commutative |
| $\mathbf{a}\cdot(\mathbf{b}+\mathbf{c})=\mathbf{a\cdot\mathbf{b}+\mathbf{a}\cdot\mathbf{c}}$| Distributive |
| $k\mathbf{a}\cdot\mathbf{b}=\mathbf{a}\cdot k\mathbf{b}=k(\mathbf{a}\cdot\mathbf{b})$ | Associative under scalar multiplication |
| $\mathbf{a}\cdot\mathbf{b}=\mathbf{a}\cdot\mathbf{c}$ and $\mathbf{a}\neq 0$ does *not* imply $\mathbf{b}=\mathbf{c}$ | Not cancellative |