In math, a matrix is a function that maps between two vector spaces. A matrix can also be thought of as a shorthand way to write a system of linear equations. For example, the matrix shown below takes in a vector of size 3 as input and produces a vector of size 2 as output.

Note, the variables represent the coefficients that define the function. The number of columns of the matrix corresponds with the size of the input vector and the number of rows corresponds with the size of the output vector. The same matrix can be written as a system of linear equations.

To express the input and output of the matrix the input vector is placed to the right of the matrix and then the output vector is the result of applying the matrix to .

Matrix multiplication is the process of composing two matrices together. Multiplying two matrices together is analogous to composing two functions together. This is why the number of rows in the left matrix must be equal to the number of columns in the second matrix; the output of the first matrix feeds into the second matrix as input.