Skip to content
ML to LLMs

Math Lab

Change the inputs and every intermediate step recomputes. Use it to check your hand calculations from the worked examples.

Linear algebra

Dot product

a⋅b=∑i=1naibia \cdot b = \sum_{i=1}^{n} a_i b_i
Symbols
a,ba, bvectors of the same length n
aia_ithe i-th entry of a
nnnumber of entries
Inputs
  1. 1

    Multiply matching entries

    2×30+1.5×1202 \times 30 + 1.5 \times 120
  2. 2

    Evaluate each product

    60+18060 + 180
  3. 3

    Add them up

    =240= 240

Result

a⋅b=240a \cdot b = 240

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.

Related lesson: Vectors and matrices