Home / Maths for AI / Symbols / Vectors and matrices

Dot product

Say it: "a dot b"

What it means

Multiply matching entries and add: a⋅b=∑iaibi\mathbf{a} \cdot \mathbf{b} = \sum_i a_i b_i. Also written a⊤b\mathbf{a}^\top \mathbf{b} or ⟨a,b⟩\langle \mathbf{a}, \mathbf{b} \rangle.

Example

(1,2,3)⋅(4,5,6)=4+10+18=32(1, 2, 3) \cdot (4, 5, 6) = 4 + 10 + 18 = 32

A single number.

In code

import numpy as np
print(np.dot([1, 2, 3], [4, 5, 6]), np.array([1, 2, 3]) @ np.array([4, 5, 6]))

Output

32 32

Where it appears in machine learning

A neuron computes a dot product of inputs and weights; similarity search compares embeddings with dot products.

Related symbols

Learn it properly in the free lesson Vectors, Norms & the Dot Product, with practice questions that check your answers.