Horizontal lines in a matrix are termed rows while vertical lines are termed columns. If a matrix has m rows and n columns, then it is called an m-by-n matrix.
The position of an entry or element in a matrix is usually indicated with two indices as shown for this 4-by-3 matrix:
/ a11 a12 a13 \ | a21 a22 a23 | | a31 a32 a33 | \ a41 a42 a43 /
As you see, in an expression aij the first index always denotes the row and the second index denotes the column of the element. If the matrix is called A, then the element in row i and column j is alse written as A[i, j], or in C notation, a[i][j]
.
If two m-by-n matrices A and B are given, we may define their sum A + B as an m-by-n matrix and compute it by adding corresponding elements, i.e., (A + B)[i, j] = A[i] + B[j] for all i and j. Furthermore, given any real number or complex number c, we define the matrix cA by multiplying every element of A by c, i.e., (cA)[i, j] = c A[i, j] for all i and j. These two operations turn the set M(m, n, R) of all m-by-n matrices with real entries into a real vector space of dimension mn.
Matrices may also be multiplied, but the operation is not as simple as matrix addition. If A is an m-by-n matrix and B is an n-by-p matrix, then their product AB is the m-by-p matrix given by (AB)[i, j] = A[i, 1] * B[1, j] + A[i, 2] * B[2, j] + ... + A[i, n] * B[n, j] for all i and j. For instance
/ 1 0 2 \ / 3 1 \ / 1*3+0*2+2*1 1*1+0*1+2*0 \ / 5 1 \ \ -1 3 1 / * | 2 1 | = \ -1*3+3*2+1*1 -1*1+3*1+1*0 / = \ 4 2 / \ 1 0 /
This multiplication has the following properties:
Matrices can conveniently represent linear transformations because matrix multiplication neatly corresponds to the composition of maps, as will be described next.
For every linear map f : Rn -> Rm there exists a unique m-by-n matrix A such that f(x) = Ax for all x in Rn. We say that the matrix A "represents" the linear map f. Here and in the sequel we identify Rn with the n-by-1 matrices. Now if k-by-m matrix B represents another linear map g : Rm -> Rk, then the linear map g o f is represented by BA. This follows from the above associativity.
The set M(n, R) of all square n-by-n matrices with real entries, together with matrix addition and matrix multiplication is a ring, in fact a real associative algebra. Unless n = 1, this ring is not commutative. The unit matrix In, with all elements on the main diagonal set to 1 and all other elements set to 0, gives the identity matrix. For example, if n = 3:
/ 1 0 0 \ I = | 0 1 0 | 3 \ 0 0 1 /
Invertible elements in this ring are called invertible matrices or non-singular matrices. Most square matrices are invertible, namely all the ones with non-zero determinant. To compute the inverse of a matrix, use [Gaussian elimination]? (also called [Gauss-Jordan elimination]?). The set Gl(n, R) of all invertible n-by-n matrices forms a group (specifically a Lie group) under matrix multiplication, the general linear group.
The transpose of an m-by-n matrix A is the n-by-m matrix Atr (also sometimes written as AT or tA) gotten by turning rows into columns and columns into rows, i.e. Atr[i, j] = A[j, i] for all indices i and j. We have (A + B)tr = Atr + Btr and (AB)tr = Btr * Atr. If A describes a linear map with respect to two bases, then the matrix Atr describes the transpose of the linear map with respect to the dual bases, see dual space.