Linear algebra
Dot product
| vectors of the same length n | |
| the i-th entry of a | |
| number of entries |
- 1
Multiply matching entries
- 2
Evaluate each product
- 3
Add them up
Result
A weighted sum: each entry of a is scaled by the matching weight in b. Geometrically it equals ‖a‖‖b‖cos θ = 2.5 × 123.6932 × cos θ, so its sign tells you whether the vectors point the same way.
Common mistakes
- Mixing up the dot product (one number) with element-wise multiplication (a vector).
- Forgetting that lengths must match. In code, a shape error here usually means a transposed matrix upstream.