Textbook
For real vectors $v,w\in\mathbb R^d$, the dot product is $v^{\mathsf T}w=\sum_{i=1}^d v_iw_i$. Their dimensions must agree. The result is a single real number. Another notation is $\langle v,w\rangle$.
With $v=(3,-4)^{\mathsf T}$ and $w=(1,2)^{\mathsf T}$, the result is $3\cdot1+(-4)\cdot2=-5$. Negative contributions are neither discarded nor replaced by absolute values. Unlike an elementwise product, the coordinate products are then added, changing the resultβs type.
Swapping the two vectors preserves the result because $v_iw_i=w_iv_i$ in each coordinate. Also, $v^{\mathsf T}v=\sum_i v_i^2\ge0$, with equality for real coordinates only when the vector is zero. A zero dot product of two different vectors does not imply either is zero; signed contributions can cancel. Matching list lengths is necessary, but a consistent coordinate order is required as well.
Definitions and further reading: Mathematics for Machine Learning.
In plain language
A dot product resembles a bill total: each itemβs quantity is multiplied by its price, and the contributions are added. Positions must match, or the bill pays for an unusual assortment. Mathematical weights may be negative, like discounts or deductions, so signs are preserved. The result is one number; a remaining list means the cashier has not totaled the bill.
Example
The original illustrative vectors are $(3,-4)^{\mathsf T}$ and $(1,2)^{\mathsf T}$. The two contributions are computed and added with their signs intact.
Dot Products: Two Vectors Become One Number
First coordinate
The product of 3 and 1 contributes 3.
Step 1 of 3: First coordinate
Read all steps
First coordinate
The product of 3 and 1 contributes 3.
- State
- 3 Γ 1current3current
Second coordinate
Multiplying β4 and 2 gives contribution β8.
- State
- β4 Γ 2currentβ8current
One total
The contributions sum to β5; the result is a scalar.
- State
- 3currentβ8currentβ5current
The first step accumulates 3; adding β8 then reduces the total to β5. Its absolute value 5 cannot replace the answer, because the sign carries information about the signed contributions. Reordering only the second vector would give $3\cdot2+(-4)\cdot1=2$, a different calculation. Both rows must preserve the same feature order throughout all steps of the dot product.
Related concepts: Elementwise products.