Skip to content
Glacius
Linear algebraConcept reference

Dot products

A dot product pairs equal numbers of coordinates, multiplies corresponding entries, and sums the products into one scalar.

On this page 7 sections
  1. Overview
  2. A dot product multiplies matching coordinates, then adds the products
  3. The two vectors need the same number of entries
  4. A supplied scoring rule can be a dot product
  5. Key takeaway
  6. Sources & further reading
  7. Concept connections

01A dot product multiplies matching coordinates, then adds the products#

A dot product multiplies matching coordinates, then adds the products. For u=(2,1)u=(2,-1) and v=(3,4)v=(3,4), the result is one number, called a scalar.

For u=(2,−1) and v=(3,4), matching products are 6 and −4. Bars share a zero baseline and signed scale. Their sum, the dot product, is 2.For u=(2,−1) and v=(3,4), matching products are 6 and −4. Bars share a zero baseline and signed scale. Their sum, the dot product, is 2.
Figure 1For u=(2,−1) and v=(3,4), matching products are 6 and −4. Bars share a zero baseline and signed scale. Their sum, the dot product, is 2.
Link to this figure ↗Download SVGDownload PNG

For u=(1,2,3)u=(1,-2,3) and v=(4,1,2)v=(4,1,2), match entries by position. The products are 4, −2, and 6; all three enter the sum.

uv=42+6=8u\cdot v=4-2+6=8
Check your reasoning

Compute (3,2)(2,1)(3,-2)\cdot(2,1).

Show answer and explanation
4

Multiply matching entries and add: 3(2)2(1)=43(2)-2(1)=4.

02The two vectors need the same number of entries#

The two vectors need the same number of entries. A two-entry vector has no third entry to pair with a three-entry vector. After pairing, add every product; a dot product returns one scalar.

Check your reasoning

For (1,2)(3,4)(1,2)\cdot(3,4), the products are 3 and 8. Finish the dot product.

  1. A(3,8)(3,8)
  2. B1111
  3. C2424
Show answer and explanation
1111

Add the products: 3+8=113+8=11.

03A supplied scoring rule can be a dot product#

A supplied scoring rule can be a dot product. If each feature has a weight, multiply every feature by its matching weight and add. The feature order and weight order must agree.

Check your reasoning

A score weights hits by 3 and misses by −2, then adds. With 2 hits and 1 miss, what is the score?

Show answer and explanation
4

The contributions are 6 and −2, so the score is 4.

Key takeaway

Multiply matching coordinates, then add every product into one scalar.

  • Compute the dot product of two equal-length vectors.

Sources & further reading

  1. [1]
  2. [2]
    MIT 18.022: Lecture 2, Dot productMIT OpenCourseWare · Book

Reference this concept

Link to this page, a section, or an individual figure.

Glacius. “Dot products.” Math behind ML. /learn/la-dot