Matrix Operations, Algebraic Properties and Special Matrix Classes
A matrix is a rectangular array of numbers; matrices of the same size are added entrywise, a matrix is multiplied by a number entrywise, and the product AB of an m × n matrix by an n × p matrix is the m × p matrix whose entry in row i and column j is the dot product of row i of A with column j of B. In brief: with A = [[1, 2], [3, 4]] and B = [[0, 1], [1, 0]], AB = [[2, 1], [4, 3]] but BA = [[3, 4], [1, 2]], so matrix multiplication is generally not commutative. Transposing reverses the order: (AB)T = BTAT.
Matrices organize linear data: systems of equations, transformations, networks and tables. This guide defines the basic operations, lists their algebraic properties (and the ones that fail), and describes the special classes of square matrices: diagonal, triangular, symmetric, skew-symmetric, orthogonal, idempotent, nilpotent and involutory, with worked examples and a table. Matrices are written row by row, so [[1, 2], [3, 4]] has the rows (1, 2) and (3, 4).
How do you add and scale matrices?
An m × n matrix has m rows and n columns; its entry aij is in row i, column j. Two matrices of the same size are added entrywise, and a number k multiplies every entry. The zero matrix O has all entries 0, and −A = (−1)A.
Example 1: sum and scalar multiple
A = [[1, 2], [3, 4]], B = [[0, 1], [1, 0]]: A + B = [[1, 3], [4, 4]], 3A = [[3, 6], [9, 12]], A − 2B = [[1, 0], [1, 4]].
How do you multiply matrices?
The product AB exists only when the number of columns of A equals the number of rows of B. The entry (AB)ij = ai1b1j + ai2b2j + … + ainbnj, the dot product of row i with column j. An m × n matrix times an n × p matrix gives m × p.
Example 2: a 2 × 3 times a 3 × 2
C = [[1, 0, 2], [−1, 3, 1]], D = [[3, 1], [2, 1], [1, 0]]. CD has the first row (1 · 3 + 0 · 2 + 2 · 1, 1 · 1 + 0 · 1 + 2 · 0) = (5, 1) and the second row (−3 + 6 + 1, −1 + 3 + 0) = (4, 2). So CD = [[5, 1], [4, 2]]. The product DC is a 3 × 3 matrix, so CD and DC cannot be equal.
Example 3: noncommutativity
AB = [[1 · 0 + 2 · 1, 1 · 1 + 2 · 0], [3 · 0 + 4 · 1, 3 · 1 + 4 · 0]] = [[2, 1], [4, 3]], while BA = [[3, 4], [1, 2]]. Multiplying by B on the right swaps the columns of A; on the left it swaps the rows.
Example 4: powers
A2 = AA = [[1 + 6, 2 + 8], [3 + 12, 6 + 16]] = [[7, 10], [15, 22]]. A0 = I by convention. Powers of the same matrix always commute: AmAn = Am+n.
Which algebraic laws hold?
For matrices of compatible sizes and numbers k:
- A + B = B + A and (A + B) + C = A + (B + C).
- (AB)C = A(BC): multiplication is associative.
- A(B + C) = AB + AC and (A + B)C = AC + BC: distributivity.
- k(AB) = (kA)B = A(kB).
- AI = IA = A for the identity matrix I (ones on the diagonal, zeros elsewhere).
Several familiar laws fail: AB ≠ BA in general; AB = O does not imply A = O or B = O; and AB = AC does not imply B = C. Consequently (A + B)2 = A2 + AB + BA + B2, not A2 + 2AB + B2.
Example 5: zero divisors
[[1, 0], [0, 0]] · [[0, 0], [0, 1]] = [[0, 0], [0, 0]], although neither factor is zero.
Example 6: the binomial formula fails
For A and B above, A + B = [[1, 3], [4, 4]] and (A + B)2 = [[13, 15], [20, 28]]. But A2 + 2AB + B2 = [[7, 10], [15, 22]] + [[4, 2], [8, 6]] + [[1, 0], [0, 1]] = [[12, 12], [23, 29]], which is different. The correct expansion A2 + AB + BA + B2 = [[7 + 2 + 3 + 1, 10 + 1 + 4 + 0], [15 + 4 + 1 + 0, 22 + 3 + 2 + 1]] = [[13, 15], [20, 28]] ✓.
What are the transpose and the trace?
The transpose AT swaps rows and columns: (AT)ij = aji. Rules: (A + B)T = AT + BT, (kA)T = kAT, (AT)T = A and (AB)T = BTAT. The trace of a square matrix, tr A, is the sum of the diagonal entries; it satisfies tr(A + B) = tr A + tr B and tr(AB) = tr(BA).
Example 7: transpose of a product
For A and B above, (AB)T = [[2, 4], [1, 3]]. And BTAT = [[0, 1], [1, 0]] · [[1, 3], [2, 4]] = [[2, 4], [1, 3]] ✓. By contrast, ATBT = [[1, 3], [2, 4]] · [[0, 1], [1, 0]] = [[3, 1], [4, 2]], not equal.
Example 8: the trace identity
tr(AB) = 2 + 3 = 5 and tr(BA) = 3 + 2 = 5, although AB ≠ BA.
Which special matrix classes are important?
- Diagonal: all off-diagonal entries are 0; powers are computed entrywise: diag(2, 3)n = diag(2n, 3n).
- Upper (lower) triangular: all entries below (above) the diagonal vanish; products of triangular matrices are triangular.
- Symmetric: AT = A. Skew-symmetric: AT = −A (the diagonal is 0). Any square matrix is the sum of a symmetric part (A + AT)/2 and a skew-symmetric part (A − AT)/2.
- Orthogonal: ATA = I, so the columns are orthonormal; it preserves lengths and angles.
- Idempotent: A2 = A (projections). Nilpotent: Ak = O for some k. Involutory: A2 = I.
Example 9: decomposing a matrix
A = [[1, 2], [3, 4]]: the symmetric part is [[1, 2.5], [2.5, 4]] and the skew-symmetric part is [[0, −0.5], [0.5, 0]]. Their sum is A ✓.
Example 10: recognizing classes
R = [[0, −1], [1, 0]] is orthogonal: RTR = [[0, 1], [−1, 0]] · [[0, −1], [1, 0]] = I. N = [[0, 1], [0, 0]] is nilpotent: N2 = O. P = [[1/2, 1/2], [1/2, 1/2]] is idempotent: P2 = [[1/2, 1/2], [1/2, 1/2]] = P; it projects onto the line y = x. J = [[0, 1], [1, 0]] is involutory: J2 = I.
Table of special classes
| Class | Condition | Example |
|---|---|---|
| symmetric | AT = A | [[1, 2], [2, 5]] |
| skew-symmetric | AT = −A | [[0, 3], [−3, 0]] |
| orthogonal | ATA = I | [[0, −1], [1, 0]] |
| idempotent | A2 = A | [[1/2, 1/2], [1/2, 1/2]] |
| nilpotent | Ak = O | [[0, 1], [0, 0]] |
| involutory | A2 = I | [[0, 1], [1, 0]] |
Where do matrices come from?
Arrays of coefficients were used to solve systems of equations in ancient China (the text Nine Chapters on the Mathematical Art, which describes a procedure equivalent to elimination). The word “matrix” was introduced by James Joseph Sylvester in 1850, and Arthur Cayley developed the algebra of matrices in 1858, including the multiplication rule, which he motivated by the composition of linear substitutions. Matrix mechanics in physics (Heisenberg, Born and Jordan, 1925) gave matrices a central role in quantum theory.
Where are matrices used?
Matrices represent systems of equations, geometric transformations in graphics, adjacency of networks, transition probabilities of Markov chains and the data tables of statistics and machine learning. The determinant of a square matrix, studied, detects whether the matrix is invertible.
Which mistakes are common?
Multiplying entrywise
The matrix product is not the entrywise product. Use rows times columns.
Assuming commutativity
AB and BA can differ in value or even in size. Keep the order, and expand (A + B)2 with four terms.
Cancelling a matrix factor
From AB = AC you cannot conclude B = C unless A is invertible.
Wrong order after transposing
(AB)T = BTAT; the order reverses.