matrix operations
A matrix is an array, or a rectangular grid, of numbers. An $m\times n$ matrix is one which has $m$ rows and $n$ columns. Examples of matrices include:

•
The $2\times 3$ matrix
$$A=\left(\begin{array}{ccc}\hfill 1\hfill & \hfill 2\hfill & \hfill 2\hfill \\ \hfill 1\hfill & \hfill 0\hfill & \hfill 2\hfill \end{array}\right)$$ 
•
The $3\times 3$ matrix
$$B=\left(\begin{array}{ccc}\hfill 1\hfill & \hfill 0\hfill & \hfill 1\hfill \\ \hfill 3\hfill & \hfill 1\hfill & \hfill 5\hfill \\ \hfill 4\hfill & \hfill 2\hfill & \hfill 0\hfill \end{array}\right)$$ 
•
The $3\times 1$ matrix
$$C=\left(\begin{array}{c}\hfill 7\hfill \\ \hfill 7\hfill \\ \hfill 2\hfill \end{array}\right)$$ 
•
The $1\times 2$ matrix
$$D=\left(\begin{array}{cc}\hfill \frac{1}{2}\hfill & \hfill 2\hfill \end{array}\right)$$
All of our example matrices (except the last one) have entries which are integers. In general, matrices are allowed to have their entries taken from any ring $R$. The set of all $m\times n$ matrices with entries in a ring $R$ is denoted ${M}_{m\times n}(R)$. If a matrix has exactly as many rows as it has columns, we say it is a square matrix^{}.
Addition^{} of two matrices is allowed provided that both matrices have the same number of rows and the same number of columns. The sum of two such matrices is obtained by adding their respective entries. For example,
$$\left(\begin{array}{c}\hfill 7\hfill \\ \hfill 7\hfill \\ \hfill 2\hfill \end{array}\right)+\left(\begin{array}{c}\hfill 1\hfill \\ \hfill 4.5\hfill \\ \hfill 0\hfill \end{array}\right)=\left(\begin{array}{c}\hfill 7+(1)\hfill \\ \hfill 7+4.5\hfill \\ \hfill 2+0\hfill \end{array}\right)=\left(\begin{array}{c}\hfill 6\hfill \\ \hfill 11.5\hfill \\ \hfill 2\hfill \end{array}\right)$$ 
Multiplication of two matrices is allowed provided that the number of columns of the first matrix equals the number of rows of the second matrix. (For example, multiplication of a $2\times 3$ matrix with a $3\times 3$ is allowed, but multiplication of a $3\times 3$ matrix with a $2\times 3$ matrix is not allowed, since the first matrix has 3 columns, and the second matrix has 2 rows, and 3 doesn’t equal 2.) In this case the matrix multiplication^{} is defined by
$${(AB)}_{ij}=\sum _{k}{(A)}_{ik}{(B)}_{kj}.$$ 
We will describe how matrix multiplication works is with an example. Let
$$A=\left(\begin{array}{ccc}\hfill 1\hfill & \hfill 2\hfill & \hfill 2\hfill \\ \hfill 1\hfill & \hfill 0\hfill & \hfill 2\hfill \end{array}\right),B=\left(\begin{array}{ccc}\hfill 1\hfill & \hfill 0\hfill & \hfill 1\hfill \\ \hfill 3\hfill & \hfill 1\hfill & \hfill 5\hfill \\ \hfill 4\hfill & \hfill 2\hfill & \hfill 0\hfill \end{array}\right)$$ 
be the two matrices that we used above as our very first two examples of matrices. Since $A$ is a $2\times 3$ matrix, and $B$ is a $3\times 3$ matrix, it is legal to multiply $A$ and $B$, but it is not legal to multiply $B$ and $A$. The method for computing the product $AB$ is to place $A$ below and to the left of $B$, as follows:
$$\begin{array}{cc}\hfill \hfill & \hfill \left(\begin{array}{ccc}\hfill 1\hfill & \hfill 0\hfill & \hfill 1\hfill \\ \hfill 3\hfill & \hfill 1\hfill & \hfill 5\hfill \\ \hfill 4\hfill & \hfill 2\hfill & \hfill 0\hfill \end{array}\right)\hfill \\ \hfill \left(\begin{array}{ccc}\hfill 1\hfill & \hfill 2\hfill & \hfill 2\hfill \\ \hfill 1\hfill & \hfill 0\hfill & \hfill 2\hfill \end{array}\right)\hfill & \hfill \left(\begin{array}{ccc}\hfill X\hfill & \hfill Y\hfill & \hfill \hfill \\ \hfill \hfill & \hfill \hfill & \hfill \hfill \end{array}\right)\hfill \end{array}$$ 
$A$ is always in the bottom left corner, $B$ is in the top right corner, and the product, $AB$, is always in the bottom right corner. We see from the picture that $AB$ will be a $2\times 3$ matrix. (In general, $AB$ has as many rows as $A$, and as many columns as $B$.)
Let us compute the top left entry of $AB$, denoted by $X$ in the above picture. The way to calculate this entry of $AB$ (or any other entry) is to take the dot product^{} of the stuff above it [which is $(1,3,4)$] and the stuff to the left of it [which is $(1,2,2)$]. In this case, we have
$$X=1\cdot 1+3\cdot (2)+4\cdot 2=3.$$ 
Similarly, the top middle entry of $AB$ (where the $Y$ is in the above picture) is gotten by taking the dot product of the stuff above it: $(0,1,2)$, and the stuff to the left of it: $(1,2,2)$, which gives
$$Y=0\cdot 1+(1)\cdot (2)+2\cdot 2=6$$ 
Continuing in this way, we can compute every entry of $AB$ one by one to get
$$\begin{array}{cc}\hfill \hfill & \hfill \left(\begin{array}{ccc}\hfill 1\hfill & \hfill 0\hfill & \hfill 1\hfill \\ \hfill 3\hfill & \hfill 1\hfill & \hfill 5\hfill \\ \hfill 4\hfill & \hfill 2\hfill & \hfill 0\hfill \end{array}\right)\hfill \\ \hfill \left(\begin{array}{ccc}\hfill 1\hfill & \hfill 2\hfill & \hfill 2\hfill \\ \hfill 1\hfill & \hfill 0\hfill & \hfill 2\hfill \end{array}\right)\hfill & \hfill \left(\begin{array}{ccc}\hfill 3\hfill & \hfill 6\hfill & \hfill 9\hfill \\ \hfill 9\hfill & \hfill 4\hfill & \hfill 1\hfill \end{array}\right)\hfill \end{array}$$ 
and so
$$AB=\left(\begin{array}{ccc}\hfill 3\hfill & \hfill 6\hfill & \hfill 9\hfill \\ \hfill 9\hfill & \hfill 4\hfill & \hfill 1\hfill \end{array}\right).$$ 
If one tries to compute the illegal product $BA$ using this procedure, one winds up with
$$\begin{array}{cc}\hfill \hfill & \hfill \left(\begin{array}{ccc}\hfill 1\hfill & \hfill 2\hfill & \hfill 2\hfill \\ \hfill 1\hfill & \hfill 0\hfill & \hfill 2\hfill \end{array}\right)\hfill \\ \hfill \left(\begin{array}{ccc}\hfill 1\hfill & \hfill 0\hfill & \hfill 1\hfill \\ \hfill 3\hfill & \hfill 1\hfill & \hfill 5\hfill \\ \hfill 4\hfill & \hfill 2\hfill & \hfill 0\hfill \end{array}\right)\hfill & \hfill \left(\begin{array}{ccc}\hfill \mathrm{?}\hfill & \hfill \hfill & \hfill \hfill \\ \hfill \hfill & \hfill \hfill & \hfill \hfill \\ \hfill \hfill & \hfill \hfill & \hfill \hfill \end{array}\right)\hfill \end{array}$$ 
The top left entry of this illegal product (marked with a $\mathrm{?}$ above) would have to be the dot product of the stuff above it: $(1,1)$, and the stuff to the left of it: $(1,0,1)$, but these vectors do not have the same length, so it is impossible to take their dot product, and consequently it is impossible to take the product of the matrices $BA$.
Under the correspondence of matrices and linear transformations, one can show that matrix multiplication is equivalent^{} to composition^{} of linear transformations, which explains why matrix multiplication is defined in a manner which is so odd at first sight, and why this strange manner of multiplication is so useful in mathematics.
Title  matrix operations 

Canonical name  MatrixOperations 
Date of creation  20130322 13:57:54 
Last modified on  20130322 13:57:54 
Owner  djao (24) 
Last modified by  djao (24) 
Numerical id  6 
Author  djao (24) 
Entry type  Definition 
Classification  msc 1500 
Defines  matrix addition 
Defines  matrix multiplication 
Defines  matrix product 
Defines  standard matrix multiplication 