how to multiply matrices

3 hours ago 2
Nature

To multiply two matrices, follow these key steps:

  1. Check dimensions:
    The number of columns in the first matrix must be equal to the number of rows in the second matrix. If the first matrix is of size m×nm\times nm×n and the second is n×pn\times pn×p, then multiplication is possible, and the result will be an m×pm\times pm×p matrix
  1. Calculate each element of the product matrix:
    Each element in the resulting matrix is found by taking the dot product of a row from the first matrix and a column from the second matrix. This means:

    • Multiply corresponding elements from the row and column.
    • Sum all those products to get a single number for that position in the product matrix
  1. Repeat for all rows and columns:
    Perform this dot product for every row of the first matrix with every column of the second matrix to fill out the entire product matrix

Example

If you have matrices:

A=123456A=\begin{bmatrix}1&2&3\\4&5&6\end{bmatrix}\quad (2\times 3)A=14​25​36​

B=789101112B=\begin{bmatrix}7&8\\9&10\\11&12\end{bmatrix}\quad (3\times 2)B=​7911​81012​​(3×2)

The product ABABAB will be a 2×22\times 22×2 matrix:

  • Element at row 1, column 1: 1×7+2×9+3×11=581\times 7+2\times 9+3\times 11=581×7+2×9+3×11=58
  • Element at row 1, column 2: 1×8+2×10+3×12=641\times 8+2\times 10+3\times 12=641×8+2×10+3×12=64
  • Element at row 2, column 1: 4×7+5×9+6×11=1394\times 7+5\times 9+6\times 11=1394×7+5×9+6×11=139
  • Element at row 2, column 2: 4×8+5×10+6×12=1544\times 8+5\times 10+6\times 12=1544×8+5×10+6×12=154

So,

AB=[5864139154]AB=\begin{bmatrix}58&64\\139&154\end{bmatrix}AB=[58139​64154​]

This method generalizes to any compatible matrices

. In summary, matrix multiplication involves multiplying rows by columns, summing the products, and requires compatible dimensions where the first matrix's columns match the second matrix's rows. The resulting matrix dimensions come from the outer dimensions of the multiplied matrices.