Multiply matrices

Compute A•B where A and B are matrices defined as:

    ┌       ┐
    │ -1  8 │
A = │  1  4 │
    │ -1  1 │
    └       ┘
    ┌            ┐
    │ 1  2  5  1 │
B = │ 7  5  4  6 │
    └            ┘

How to solve this problem?

The matrix C obtained by multiplying the matrices A and B, in that order, is defined if the number of columns of A is equal to the number of rows of B, and in that case the matrix C will have as many rows as A and as many columns as B. To find the entry associated to row i and column j: Cij, multiply the entries of the i-th row of A by the corresponding entries in the j-th column of B and then add up the resulting products.

Step 1: Multiply each row of the matrix A by each column of the matrix B (To multiply a row by a column just multiply the corresponding entries and then add up the resulting products). The first index in C indicates the row index in A and the second one indicates the column index in B.

C11 = (-1)•1 + 8•7 = 55
C12 = (-1)•2 + 8•5 = 38
C13 = (-1)•5 + 8•4 = 27
C14 = (-1)•1 + 8•6 = 47

C21 = 1•1 + 4•7 = 29
C22 = 1•2 + 4•5 = 22
C23 = 1•5 + 4•4 = 21
C24 = 1•1 + 4•6 = 25

C31 = (-1)•1 + 1•7 = 6
C32 = (-1)•2 + 1•5 = 3
C33 = (-1)•5 + 1•4 = -1
C34 = (-1)•1 + 1•6 = 5
Step 2: Final solution.
      ┌                ┐
      │ 55  38  27  47 │
A•B = │ 29  22  21  25 │
      │  6   3  -1   5 │
      └                ┘