Working with matrices
A matrix of size m × n is a rectangular table of numbers arranged in m rows and n columns. The element a_ij sits at the intersection of the i-th row and the j-th column. Addition, scalar multiplication, matrix multiplication and transposition are defined on matrices.
In plain words:
A matrix is a rectangular table of numbers. The size m×n means m rows (horizontal lines) and n columns (vertical ones). The element aij is the number at the intersection of the i-th row and the j-th column.
Example:
- A (student grades in the register) = (544534)
- The size m×n=2×3 means 2 rows and 3 columns
- a12 (1st row, 2nd column) = 4
Main rule:
The index reads as "row, then column": in aij the first digit is the row number, the second the column number.
In plain words:
We add the elements standing in the same positions: the number in a cell of the first matrix plus the number in the same cell of the second. Only matrices of the same size can be added.
Example:
- A (family expenses on Monday, rub.) = (100305080)
- B (expenses on Tuesday) = (20604010)
- A+B (expenses for two days) = (120909090)
Main rule:
Elements are added "by position" — with the same row and column number, so the matrices must have the same size.
In plain words:
To multiply a matrix by a number, multiply each of its elements by that number separately. The size of the matrix (rows and columns) does not change.
Example:
- A (price of pizza toppings, rub.) = (1008050120)
- c=2 (prices doubled)
- 2A (new prices) = (200160100240)
Main rule:
The number "enters" every cell of the table: c(A+B)=cA+cB.
In plain words:
We multiply "row by column": take a row of the first matrix and a column of the second, multiply the numbers pairwise and add the results. The resulting sum lands at their intersection.
Example:
- A=(1324), B=(0110)
- (AB)11=1⋅0+2⋅1=2 (1st row of A and 1st column of B)
- AB=(2413)
Main rule:
You can multiply only when the number of columns of the first matrix equals the number of rows of the second: the "inner" sizes must match.
In plain words:
Transposition is "flipping" the table: rows become columns and columns become rows. Mentally rotate the matrix about the main diagonal (from the top-left corner to the bottom-right).
Example:
- A (schedule: rows are days, columns are hours) = (1324)
- AT (now rows are hours) = (1234)
Main rule:
Double transposition restores the original matrix: (AT)T=A.
In plain words:
The trace is the sum of the numbers on the main diagonal (from the top-left corner to the bottom-right). It is defined only for square matrices, where there are as many rows as columns.
Example:
- A=(2−157)
- Main diagonal: a11=2 and a22=7
- tr(A)=2+7=9
Main rule:
The trace does not change under transposition: tr(A)=tr(AT).
In plain words:
The identity matrix is a "reference" square matrix: ones on the main diagonal and zeros everywhere else. Multiplying by it changes nothing, just like multiplying a number by 1.
Example:
- A=(3012) — any matrix
- AE=(3012)(1001)
- AE=EA=A — the matrix did not change
Main rule:
The identity matrix is the neutral element of multiplication: AE=EA=A for any matrix A of a suitable size.
In plain words:
The order of matrix multiplication matters: AB and BA usually give different results. Unlike ordinary numbers, the factors cannot be swapped.
Example:
- A=(1324), B=(0110)
- AB=(2413), while BA=(3142)
- The results differ: AB=BA
Main rule:
Non-commutativity means: always keep an eye on the order of the factors, since AB=BA in the general case.