(2 × 2) · (2 × 2) gives a (2 × 2) matrix: the columns of the first and the rows of the second match and disappear.
Press another entry of the result. In a product, the row of the first matrix and the column of the second are highlighted; they are multiplied in pairs and added up.
AB ≠ BA: for example, at c₁₁ one gives 2 and the other 3.
With numbers, 2 · 3 = 3 · 2. With matrices not always: the product is not commutative.
Sum of matrices
Two matrices are added by adding the entries in the same position. That is why only matrices of the same size can be added.
- 1Worked example. Both matrices are 2 × 3, so they can be added.
- 2Add each entry to the one in the same position: 1 + 2, 2 + 0, 0 + 5 in the first row and 3 + (−1), (−1) + 1, 4 + 2 in the second.
What it is for. Adding matrices is adding tables of data position by position: the sales of two shops, two images (grids of pixels) or two linear transformations at once.
Product by a scalar
A scalar is a number (here λ ∈ K). Multiplying a matrix by a scalar means multiplying all its entries by that number.
- 1Worked example: multiply the matrix A by 3.
- 2Each entry is multiplied by 3.
What it is for. It is used to change scale (raise every price by 10 %, brighten an image) and, together with the sum, to combine matrices: 2A − 3B is a combination of two matrices.
Properties of the sum and of the product by a scalar
Let λ, μ ∈ K be numbers and A, B, C matrices of the same size n × m. Since everything is done entry by entry, the same rules as for numbers hold.
What it is for. They guarantee that you can reorder, group and solve with matrices just as with numbers, as long as you only add and multiply by scalars. For example, from A + X = B you get X = B − A.
Multiplying matrices: row times column
Multiplying matrices is trickier than adding them. The basic piece is multiplying a row by a column with the same number of entries.
- 1Worked example. A is 2 × 3 and B is 3 × 2: the columns of A (3) match the rows of B (3), so they can be multiplied and the result is 2 × 2.
- 2c₁₁: row 1 of A times column 1 of B.
- 3c₁₂: row 1 of A times column 2 of B.
- 4c₂₁: row 2 of A times column 1 of B.
- 5c₂₂: row 2 of A times column 2 of B.
- 6Everything is put together in the product matrix.
Size of the product: (n × p)(p × m) = n × m
To multiply, the columns of A must match the rows of B; the result takes the rows of A and the columns of B.
See proofThe product of matrices: row times column
Each entry of AB is a row of A times a column of B: a sum of products.
See proofWhat it is for. The matrix product composes transformations (apply one and then another), computes totals (prices times quantities) and lets you write a system of equations as AX = b. That is why it is defined in such a particular way.
Properties of the matrix product
The product satisfies almost all the rules for numbers, with one very important exception: the order of the factors does matter.
Associative property: (AB)C = A(BC)
You can group the products however you like; the result is the same.
See proofDistributive property: (A + B)C = AC + BC
The product distributes over the sum, both on the right and on the left.
See proofThe identity matrix is the neutral element: IA = AI = A
Multiplying by the identity (on either side) leaves the matrix unchanged.
See proofThe product is not commutative: AB ≠ BA
In general, the order of the factors does change the product.
See proofWhat it is for. With these rules you expand and factor expressions, and change the grouping to save computations. Knowing what does not hold (commutativity) avoids the most typical mistakes.
Block multiplication
A big matrix can be split into rectangular pieces called blocks. If the partitions are compatible (the columns of A are cut in the same way as the rows of B), the blocks multiply as if they were numbers.
Block multiplication
If matrices are split into compatible blocks, the blocks multiply as if they were numbers.
See proof- 1The matrices A and B are split into 2 × 2 blocks, with the columns of A cut in the same way as the rows of B.
- 2Apply row times column, but with blocks. Each product of blocks is computed as an ordinary matrix product.
What it is for. It splits an enormous product into several small ones (computers do it to share out the work) and takes advantage of blocks of zeros or identities to save computations.
The trace
The trace of a square matrix is the sum of the entries on its main diagonal.
- 1Worked example. The diagonal of A is 1, 5, 9.
- 2The trace is the sum of the diagonal.
Properties
The trace is linear: tr(A + B) = tr A + tr B and tr(λA) = λ tr A
The trace of a sum is the sum of the traces, and scalars come out.
See prooftr(AB) = tr(BA)
The trace of a product does not depend on the order of the two factors, even though AB and BA are different.
See proofWhat it is for. It summarises a square matrix in a single number and has very handy properties for simplifying. It is used in statistics, physics and machine learning.