# Matrix Multiplication

## Prerequisites

### Matrix Multiplication

#### Introduction

• Matrix Multiplication, or matrix product, is a method of multiplying two matrices to produce a third matrix.
• Two matrices can only be multiplied together if the number of rows in the first matrix is equal to the number of columns in the second matrix.
• The result will be a matrix with the number of columns from the first matrix and the number of rows from the second matrix.
• A is a i x j matrix
• B is a j x k matrix
• C = AB
• C is a i x k matrix
• The values in the resulting matrix are calculated by finding the dot product, using the row from the first matrix and the column from the second: #### Example

Find the result of multiplying the following two matrices: ##### Solution
1. First we position them to make it easier to see which vectors need to be multiplied: 2. Then we write the dot product of the corresponding vectors: 3. And finally solve: #### code (Python)

``````import numpy as np

a = [[1, 4], [3, 7], [8, 4]]
b = [[3, 6, 2], [5, 1, 10]]

c = np.matmul(a, b)
print(c)``````