Matrices are central objects in linear algebra. They provide a compact way to store coefficients, represent linear maps, solve systems of equations, and describe geometric transformations.
What Is a Matrix?
A matrix is a rectangular table of numbers with \(n\) rows and \(m\) columns. We write \(A\in\mathbb{R}^{n\times m}\) and denote its entries by \(a_{ij}\), where \(i\) is the row index and \(j\) is the column index:
\[ A=\begin{bmatrix} a_{11} & a_{12} & \dots & a_{1m}\\ a_{21} & a_{22} & \dots & a_{2m}\\ \vdots & \vdots & \ddots & \vdots\\ a_{n1} & a_{n2} & \dots & a_{nm} \end{bmatrix}. \]
A matrix can be understood as a collection of row vectors or column vectors. Given vectors \(\mathbf{a}\) and \(\mathbf{b}\), one may form
\[ M=\begin{bmatrix} a_1 & a_2 & \dots\\ b_1 & b_2 & \dots \end{bmatrix} \quad\text{(rows stacked)}, \]
or
\[ M=\begin{bmatrix} a_1 & b_1 & \dots\\ a_2 & b_2 & \dots \end{bmatrix} \quad\text{(columns placed side by side)}. \]
Transpose
The transpose \(M^{\mathsf T}\) swaps rows and columns. Entrywise, \((M^{\mathsf T})_{ij}=m_{ji}\).
For a \(2\times2\) matrix:
\[ \begin{bmatrix} a_{11} & a_{12}\\ a_{21} & a_{22} \end{bmatrix}^{\mathsf T} = \begin{bmatrix} a_{11} & a_{21}\\ a_{12} & a_{22} \end{bmatrix}. \]
Important transpose rules:
\[ (A+B)^{\mathsf T}=A^{\mathsf T}+B^{\mathsf T},\qquad (kA)^{\mathsf T}=kA^{\mathsf T},\qquad (AB)^{\mathsf T}=B^{\mathsf T}A^{\mathsf T}. \]
Addition, Subtraction, and Scalar Multiplication
Matrices can be added or subtracted only when they have the same size. If \(A,B\in\mathbb{R}^{n\times m}\), then componentwise:
\[ (A\pm B)_{ij}=a_{ij}\pm b_{ij}. \]
Scalar multiplication with \(k\in\mathbb{R}\) is also componentwise:
\[ (kA)_{ij}=k\,a_{ij}. \]
These operations satisfy the same linearity patterns as vectors.
Matrix-Vector and Matrix-Matrix Multiplication
Matrix multiplication is the key operation and is not elementwise. It extends the dot-product idea.
The elementwise product is a different operation called the Hadamard product, and is not the matrix product discussed here.
Matrix-Vector Multiplication
For \(A\in\mathbb{R}^{n\times m}\) and \(\mathbf{x}\in\mathbb{R}^m\), the product \(A\mathbf{x}\in\mathbb{R}^n\) is defined entrywise by
\[ (A\mathbf{x})_i=\sum_{j=1}^m a_{ij}x_j. \]
In the column picture, if \(A=[\mathbf{c}_1\ \mathbf{c}_2\ \dots\ \mathbf{c}_m]\), then
\[ A\mathbf{x}=x_1\mathbf{c}_1+x_2\mathbf{c}_2+\dots+x_m\mathbf{c}_m. \]
So matrix-vector multiplication forms a linear combination of the columns of \(A\).
Dimension Rule
If \(A\in\mathbb{R}^{n_A\times m_A}\) and \(B\in\mathbb{R}^{n_B\times m_B}\), the product \(AB\) exists exactly when
\[ m_A=n_B. \]
The result then has size
\[ AB\in\mathbb{R}^{n_A\times m_B}. \]
Entry Formula
The \((i,j)\)-entry of \(C=AB\) is the dot product of row \(i\) of \(A\) with column \(j\) of \(B\):
\[ c_{ij}=\sum_{k=1}^{m_A}a_{ik}b_{kj}. \]
In row-column block form, with row vectors \(\mathbf{a}_i\) and column vectors \(\mathbf{b}_j\):
\[ \begin{bmatrix} \mathbf{a}_1\\ \mathbf{a}_2\\ \vdots\\ \mathbf{a}_{n_A} \end{bmatrix} \begin{bmatrix} \mathbf{b}_1 & \mathbf{b}_2 & \dots & \mathbf{b}_{m_B} \end{bmatrix} = \begin{bmatrix} \mathbf{a}_1\cdot\mathbf{b}_1 & \mathbf{a}_1\cdot\mathbf{b}_2 & \dots & \mathbf{a}_1\cdot\mathbf{b}_{m_B}\\ \mathbf{a}_2\cdot\mathbf{b}_1 & \mathbf{a}_2\cdot\mathbf{b}_2 & \dots & \mathbf{a}_2\cdot\mathbf{b}_{m_B}\\ \vdots & \vdots & \ddots & \vdots\\ \mathbf{a}_{n_A}\cdot\mathbf{b}_1 & \mathbf{a}_{n_A}\cdot\mathbf{b}_2 & \dots & \mathbf{a}_{n_A}\cdot\mathbf{b}_{m_B} \end{bmatrix}. \]
Worked Example
\[ \begin{bmatrix} 1 & 2\\ 3 & 4 \end{bmatrix} \begin{bmatrix} 5 & 6\\ 7 & 8 \end{bmatrix} = \begin{bmatrix} 1\cdot5+2\cdot7 & 1\cdot6+2\cdot8\\ 3\cdot5+4\cdot7 & 3\cdot6+4\cdot8 \end{bmatrix} = \begin{bmatrix} 19 & 22\\ 43 & 50 \end{bmatrix}. \]
Structural Properties
\[ A(BC)=(AB)C,\qquad A(B+C)=AB+AC,\qquad (A+B)C=AC+BC. \]
In general,
\[ AB\ne BA. \]
Matrix multiplication is typically not commutative.
Special Matrices
The zero matrix has all entries zero. The identity matrix \(I\in\mathbb{R}^{n\times n}\) has ones on the diagonal and zeros elsewhere, and satisfies
\[ AI=A,\qquad IA=A. \]
Diagonal matrices keep only diagonal entries nonzero and are useful for scaling along coordinate axes.
Determinant
For square matrices, the determinant \(\det A\) is a scalar that measures signed area scaling in 2D or signed volume scaling in 3D. A zero determinant means the map collapses dimension and is not invertible.
Determinant in 2D
For \(A=\begin{bmatrix}a_1&a_2\\b_1&b_2\end{bmatrix}\):
\[ \det A = \begin{vmatrix} a_1 & a_2\\ b_1 & b_2 \end{vmatrix} =a_1b_2-a_2b_1. \]
Geometrically, \(|\det A|\) is the area of the parallelogram spanned by \(\mathbf{a}=\langle a_1,a_2\rangle\) and \(\mathbf{b}=\langle b_1,b_2\rangle\), and the sign encodes orientation (winding order).
Determinant in 3D
For \(A=\begin{bmatrix}a_1&a_2&a_3\\b_1&b_2&b_3\\c_1&c_2&c_3\end{bmatrix}\), Laplace expansion along the first row gives:
\[ \det A= a_1\begin{vmatrix}b_2&b_3\\c_2&c_3\end{vmatrix} -a_2\begin{vmatrix}b_1&b_3\\c_1&c_3\end{vmatrix} +a_3\begin{vmatrix}b_1&b_2\\c_1&c_2\end{vmatrix}. \]
Geometrically, \(|\det A|\) is the volume of the spanned parallelepiped; the sign indicates orientation.
For general \(n\times n\) matrices, determinants can be defined by Laplace expansion or by permutation formulas.
Inverse Matrix
For a square matrix \(A\), the inverse \(A^{-1}\) is defined by
\[ AA^{-1}=A^{-1}A=I. \]
A square matrix is invertible exactly when
\[ \det A\ne 0. \]
For \(A=\begin{bmatrix}a_1&a_2\\b_1&b_2\end{bmatrix}\):
\[ A^{-1}=\frac{1}{\det A} \begin{bmatrix} b_2 & -a_2\\ -b_1 & a_1 \end{bmatrix}. \]
In computations, solving systems via elimination is usually preferred over explicitly forming \(A^{-1}\).
Application: Linear Systems
A system of linear equations can be written as
\[ A\mathbf{x}=\mathbf{b}. \]
Example:
\[ \begin{bmatrix} 4 & 7\\ 2 & 3 \end{bmatrix} \begin{bmatrix} x\\ y \end{bmatrix} = \begin{bmatrix} 3\\ 7 \end{bmatrix}. \]
Let \(A=\begin{bmatrix}4&7\\2&3\end{bmatrix}\), \(\mathbf{x}=\begin{bmatrix}x\\y\end{bmatrix}\), \(\mathbf{b}=\begin{bmatrix}3\\7\end{bmatrix}\). Since \(\det A=4\cdot3-2\cdot7=-2\ne0\), the system has a unique solution.
\[ A^{-1}=-\frac{1}{2} \begin{bmatrix} 3 & -7\\ -2 & 4 \end{bmatrix}. \]
Therefore
\[ \mathbf{x}=A^{-1}\mathbf{b} =-\frac{1}{2} \begin{bmatrix} 3 & -7\\ -2 & 4 \end{bmatrix} \begin{bmatrix} 3\\ 7 \end{bmatrix} = \begin{bmatrix} 20\\ -11 \end{bmatrix}. \]
Hence \(x=20\) and \(y=-11\).
Application: Homogeneous Transformation Matrices
In computer graphics, homogeneous coordinates allow translation, rotation, scaling, and shear to be represented uniformly as matrix multiplication.
A 2D point \(\mathbf{p}=\langle x,y\rangle\) is embedded as \(\tilde{\mathbf{p}}=\langle x,y,1\rangle\).
Analogously in 3D, a Cartesian point \(\mathbf{p}=\langle x,y,z\rangle\) is embedded as \(\tilde{\mathbf{p}}=\langle x,y,z,1\rangle\).
Translation
\[ T(t_x,t_y)= \begin{bmatrix} 1 & 0 & t_x\\ 0 & 1 & t_y\\ 0 & 0 & 1 \end{bmatrix}. \]
CSS shorthand: transform: translate(10px, 10px)
Rotation
\[ R(\theta)= \begin{bmatrix} \cos\theta & -\sin\theta & 0\\ \sin\theta & \cos\theta & 0\\ 0 & 0 & 1 \end{bmatrix}. \]
CSS shorthand: transform: rotate(15deg)
Scaling
\[ S(s_x,s_y)= \begin{bmatrix} s_x & 0 & 0\\ 0 & s_y & 0\\ 0 & 0 & 1 \end{bmatrix}. \]
CSS shorthand: transform: scale(1.2)
Shear
\[ H(\alpha,\beta)= \begin{bmatrix} 1 & \alpha & 0\\ \beta & 1 & 0\\ 0 & 0 & 1 \end{bmatrix}. \]
Transformations can be composed by multiplication. Because multiplication is not commutative, order matters.
If vectors are multiplied on the right (column-vector convention), the rightmost matrix acts first. To rotate first, then translate, then scale, one writes:
\[ S(0.7)\,T(10,10)\,R\left(\frac{\pi}{2}\right). \]
Common Pitfalls
- Dimension mismatch: always verify inner dimensions before multiplying.
- Assuming commutativity: usually \(AB\ne BA\).
- Confusing elementwise multiplication with matrix multiplication.
- Trying to invert singular matrices with \(\det A=0\).
- Using the wrong order for composed geometric transformations.
Connections
This toolkit is used throughout linear algebra, especially in matrix multiplication, matrix inversion, decompositions, and least-squares models.