Skip to content
Justice Tech School

Dot Product and Matrix Product

dot and @ multiply matrices. For 1D arrays they give the inner product.

Example
a = np.array([[1, 2], [3, 4]])
b = np.array([[5, 6], [7, 8]])
print(a @ b)
print(np.dot([1, 2, 3], [4, 5, 6]))
print(a * b)

Result

[[19 22]
 [43 50]]
32
[[ 5 12]
 [21 32]]

Exercise

Matrix multiply.

a  b

Quiz Test

What does a * b do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.