A matrix is a rectangular table of numbers. Matrices store data, transform graphics, solve equations and power machine learning.

Order and types

A matrix with m rows and n columns has order m × n. The entry in row i and column j is aᵢⱼ.

Type Meaning
Row / column matrix One row / one column
Square matrix m = n
Zero matrix All entries 0
Diagonal matrix Square; non-zero only on the main diagonal
Identity matrix I Diagonal with 1s; A·I = I·A = A
Upper / lower triangular Zeros below / above the diagonal
Symmetric A = Aᵀ
Skew-symmetric Aᵀ = −A (so diagonal entries are 0)
Orthogonal A·Aᵀ = I

The transpose Aᵀ swaps rows and columns.

Addition and subtraction

Matrices of the same order are added or subtracted entry by entry.

[1 2]   [5 6]   [ 6  8]
[3 4] + [7 8] = [10 12]

Scalar multiplication

Multiply every entry by the number: 2 × [1 2; 3 4] = [2 4; 6 8].

Matrix multiplication

A (m × n) times B (n × p) is defined when the number of columns of A equals the number of rows of B, and gives an m × p matrix. The entry in row i, column j is the sum of products of row i of A with column j of B.

[1 2]   [0 1]   [1·0+2·1  1·1+2·0]   [2 1]
[3 4] × [1 0] = [3·0+4·1  3·1+4·0] = [4 3]

Multiplication is not commutative: here B × A = [3 4; 1 2], which differs from A × B. It is associative: (AB)C = A(BC). Also (AB)ᵀ = BᵀAᵀ.

Symmetric and skew-symmetric parts

Any square matrix A can be written as A = ½(A + Aᵀ) + ½(A − Aᵀ), a symmetric part plus a skew-symmetric part.

Orthogonal matrix example

R = [0 −1; 1 0] gives R·Rᵀ = [0 −1; 1 0] × [0 1; −1 0] = [1 0; 0 1] = I, so R is orthogonal. It rotates points by 90 degrees.

Common mistakes

  • Multiplying matrices whose sizes do not match.
  • Assuming AB = BA.
  • Forgetting that a skew-symmetric matrix has a zero diagonal.

Practice questions

  1. Write one example each of a symmetric and a skew-symmetric matrix.
  2. Find AB for A = [1 0; 2 1] and B = [3 1; 0 2].
  3. If A is 2 × 3 and B is 3 × 4, what is the order of AB?
  4. Define an orthogonal matrix.
  5. Find the transpose of [1 2 3; 4 5 6].

Answers to the practice questions

  1. Symmetric [1 2; 2 3]; skew-symmetric [0 5; −5 0].
  2. AB = [3 1; 6 4].
  3. 2 × 4.
  4. A square matrix with A·Aᵀ = I.
  5. [1 4; 2 5; 3 6].

Sources

  • Official BCA syllabus Mathematics Foundations to Computer Science I, course code CC101, Unit IV
  • Kolman, Busby and Ross, Discrete Mathematical Structures, 6th edition, Pearson