Matrix multiplication

How do you multiply two matrices? In linear algebra, matrix multiplication is done through row-by-column multiplication, meaning each row in the first matrix is multiplied by each column in the second matrix.

row-by-column product

For a real matrix Amxn and a real matrix Bnxp, their product is a real matrix Cmxp. Each element cik in C is the sum of the products of corresponding elements from row i of A and column k of B.

matrix product formula

Matrix multiplication is defined only if the number of columns in the first matrix matches the number of rows in the second matrix.

example of matrix multiplication

Note: Simply put, for matrix multiplication to be possible, each row in matrix A must contain the same number of elements as each column in matrix B. Un esempio pratico.

An Example of Matrix Multiplication

For example, let’s calculate the product of matrices A and B.

Matrix A is a 4x2 matrix, while matrix B is a 2x4 matrix.
example

Since the number of columns in A matches the number of rows in B, we can proceed with the multiplication.

Note: The resulting matrix is a 4x4 matrix, created by multiplying the four rows of A (i=4) by the four columns of B (k=4).
determining matrix dimensions

We start by multiplying each row of matrix A by the first column of matrix B, resulting in the first column of the product matrix.

first column computation

Next, we multiply the rows of A by the second column of B to form the second column of the resulting matrix.

second column computation

This process continues with the third column, where rows of A are multiplied by the third column of B.

third column computation

Finally, we multiply the rows of A by the fourth column of B to obtain the last column of the product matrix.

completed product matrix

At this point, we have the final product matrix A·B.

Properties of Matrix Multiplication

Matrix multiplication has several important properties:

  1. Associative Property: For any matrices A∈Mmn, B∈Mnp, and C∈Mpq, the product A(BC) is the same as (AB)C.
    associative property
  2. Right Distributive Property: For matrices A∈Mmn, B∈Mnp, and C∈Mnp, the product A(B+C) is equal to AB + AC.
    right distributive property
  3. Left Distributive Property: For matrices A∈Mmn, B∈Mnp, and C∈Mnp, (A+B)C equals AC + BC.
    left distributive property
  4. Scalar Multiplication: For any real number α∈R and matrices A∈Mmn and B∈Mnp, α(AB) is the same as (αA)B or A(αB).
    scalar multiplication
  5. Transpose Property: For matrices A∈Mmn and B∈Mnp, the transpose of (AB)T is BTAT.
    transpose property

    Note: When transposing a matrix product, the order of matrices reverses; A is first in AB, but BT is first in BTAT.

Key Differences Between Matrices and Real Numbers

Matrix Multiplication is Not Commutative

In general, A·B does not equal B·A.

This non-commutativity is due to the fact that switching the order of multiplication often produces matrices with different dimensions.

non-commutative example

Note: While it’s rare, A·B can equal B·A if, for instance, one matrix is an identity matrix. However, this is the exception, not the rule.

In some cases, the reverse product doesn’t exist at all.

For example, matrix A may have the same number of columns as the rows of matrix B, but B may have more columns than A has rows.

incompatible dimensions example

In this case, A·B is defined, but B·A is not.

Matrix Multiplication Lacks the Cancellation Property

In matrix multiplication, you cannot cancel out matrices as you would with real numbers.

If A is multiplied by a zero matrix B, the result is a zero matrix.

zero product example

Interestingly, multiplying two non-zero matrices can also produce a zero matrix.

zero product from non-zero matrices

Thus, matrix multiplication does not obey the cancellation rule.

Matrices and the Multiplicative Inverse

In the realm of real numbers, any non-zero number x has a reciprocal, 1/x, such that x * (1/x) = 1.

inverse example in real numbers

Matrices, however, do not always have this property. Only certain matrices, called invertible matrices, have an inverse, denoted A-1, such that A * A-1 equals the identity matrix I.

Note: Only invertible matrices have an inverse that, when multiplied by the original matrix, produces the identity matrix.
invertible matrix example

 
 

Please feel free to point out any errors or typos, or share suggestions to improve these notes. English isn't my first language, so if you notice any mistakes, let me know, and I'll be sure to fix them.

FacebookTwitterLinkedinLinkedin
knowledge base

Matrices (linear algebra)