Matrices

15th-century printers cast a mirror image of each letter in metal and arranged them, letter by letter, in frames that printed one page at a time. A frame was called a matrix; several were matrices. In mathematics a matrix is a rectangular frame holding numbers or variables. The size of a matrix is called its order (rows × columns).

Matrices are written with capital letters; their elements with lowercase letters subscripted row then column:

$A=\begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix}$

Addition and Subtraction

You can add or subtract matrices of the same order by adding or subtracting corresponding elements.

Example 1: with $A=\begin{bmatrix} 1 & 3 \\ -5 & 2 \end{bmatrix}$ and $B=\begin{bmatrix} -2 & 4 \\ 3 & 1 \end{bmatrix}$:

$A+B=\begin{bmatrix} 1+(-2) & 3+4 \\ -5+3 & 2+1 \end{bmatrix}=\begin{bmatrix} -1 & 7 \\ -2 & 3 \end{bmatrix}$

$A-B=\begin{bmatrix} 1-(-2) & 3-4 \\ -5-3 & 2-1 \end{bmatrix}=\begin{bmatrix} 3 & -1 \\ -8 & 1 \end{bmatrix}$

Multiplication by a Scalar

To multiply a matrix by a scalar $c$, multiply every element by $c$.

Example 3: with $A=\begin{bmatrix} 1 & 3 \\ -5 & 2 \end{bmatrix}$ and $c=3$:   $cA=\begin{bmatrix} 3 & 9 \\ -15 & 6 \end{bmatrix}$.

Multiplication by another Matrix

You can multiply $A$ by $B$ iff the number of columns of $A$ equals the number of rows of $B$. Each element of the product is a row of $A$ multiplied term-by-term with a column of $B$ and summed.

$\begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix}\begin{bmatrix} b_{11} & b_{12} \\ b_{21} & b_{22} \end{bmatrix}=\begin{bmatrix} a_{11}b_{11}+a_{12}b_{21} & a_{11}b_{12}+a_{12}b_{22} \\ a_{21}b_{11}+a_{22}b_{21} & a_{21}b_{12}+a_{22}b_{22} \end{bmatrix}$

Example 4: $\begin{bmatrix} 1 & 3 \\ -5 & 2 \end{bmatrix}\begin{bmatrix} -2 & 4 \\ 3 & 1 \end{bmatrix}=\begin{bmatrix} 1(-2)+3(3) & 1(4)+3(1) \\ -5(-2)+2(3) & -5(4)+2(1) \end{bmatrix}=\begin{bmatrix} 7 & 7 \\ 16 & -18 \end{bmatrix}$

Note: matrix multiplication is not commutative — in general $AB \ne BA$.

Division (Inverses)

Matrix division does not exist. To find $X$ in $AX=C$, use the inverse $A^{-1}$, where $A\,A^{-1}=I$ (the identity matrix, with $1$s on the main diagonal and $0$s elsewhere):

$AX=C \;\Rightarrow\; A^{-1}AX=A^{-1}C \;\Rightarrow\; X=A^{-1}C$

For a $3\times3$ matrix, $I=\begin{bmatrix} 1&0&0 \\ 0&1&0 \\ 0&0&1 \end{bmatrix}$.

2×2 Determinants

The determinant measures the "magnitude" of a square matrix. For $A=\begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix}$ it is $a_{11}a_{22}-a_{12}a_{21}$.

Example 5: $|A|$ for $\begin{bmatrix} 1 & 3 \\ -5 & 2 \end{bmatrix}$ is $1\times2 - 3\times(-5) = 17$.

3×3 Determinants

Take each term of the top row in turn. Ignore the row and column containing it; what remains is a $2\times2$ matrix whose determinant you can evaluate.

3x3 determinant: striking out a row and column

The signs on the top row alternate $+,\,-,\,+$:

alternating signs on the top row

$|A| = a_{11}(a_{22}a_{33}-a_{23}a_{32}) - a_{12}(a_{21}a_{33}-a_{23}a_{31}) + a_{13}(a_{21}a_{32}-a_{22}a_{31})$

Where Do We Use Matrices?

Matrices are everywhere in engineering and computing: solving systems of simultaneous equations, transforming and rotating graphics, structural analysis, and modelling physical systems (for example, gravitational interactions between many bodies).

Gravitational interactions modelled with matrices