Let’s learn how matrix multiplication in Numpy Python library works.

## Using a matmul function

To multiply matrices in Numpy you just need to know how to use matmul Numpy function.

This is example code on matrix multiplication in Python.

import numpy as np my_array = np.array([[1, 5], [5, 4]]) my_array2 = np.array([[7, 4], [4, 8]]) multiply_array = np.matmul(my_array, my_array2) print(f"Multiply matrices: \n {multiply_array}")

## Using an @

Alternatively for basic matrix multiplications you just need to use only an at.

import numpy as np my_array = np.array([[1, 5], [5, 4]]) my_array2 = np.array([[7, 4], [4, 8]]) multiply_array = my_array @ my_array2 print(f"Multiply matrices: \n {multiply_array}")

Results in these basic examples are exactly the same.

See also:

Matrix multiplication in Excel