In mathematics, a matrix (: matrices) is a rectangular array of numbers or other mathematical objects with elements or entries arranged in rows and columns, usually satisfying certain properties of addition and multiplication.

For example,

denotes a matrix with two rows and three columns. This is often referred to as a "two-by-three matrix", a matrix, or a matrix of dimension .

In linear algebra, matrices are used as linear maps. In geometry, matrices are used for geometric transformations (for example rotations) and coordinate changes. In numerical analysis, many computational problems are solved by reducing them to a matrix computation, and this often involves computing with matrices of huge dimensions. Matrices are used in most areas of mathematics and scientific fields, either directly, or through their use in geometry and numerical analysis.

Square matrices, matrices with the same number of rows and columns, play a major role in matrix theory. The determinant of a square matrix is a number associated with the matrix, which is fundamental for the study of a square matrix. For example, a square matrix is invertible if and only if it has a nonzero determinant. Also, the eigenvalues of a square matrix are the roots of its characteristic polynomial, .

Matrix theory is the branch of mathematics that focuses on the study of matrices. It was initially a sub-branch of linear algebra, but soon grew to include subjects related to graph theory, algebra, combinatorics and statistics.

Definition A matrix is a rectangular array of numbers (or other mathematical objects), called the "entries" of the matrix. Matrices are subject to standard operations such as addition and multiplication. Most commonly, a matrix over a field is a rectangular array of elements of . A real matrix and a complex matrix are matrices whose entries are respectively real numbers or complex numbers. More general types of entries are discussed below. For instance, this is a real matrix:

The numbers (or other objects) in the matrix are called its entries or its elements. The horizontal and vertical lines of entries in a matrix are respectively called rows and columns.

Size The size of a matrix is defined by the number of rows and columns it contains. There is no limit to the number of rows and columns that a matrix (in the usual sense) can have as long as they are positive integers. A matrix with rows and columns is called an matrix, or -by- matrix, where and are called its . For example, the matrix above is a matrix.

Matrices with a single row are called row matrices or row vectors, and those with a single column are called column matrices or column vectors. A matrix with the same number of rows and columns is called a square matrix. A matrix with an infinite number of rows or columns (or both) is called an infinite matrix. In some contexts, such as computer algebra programs, it is useful to consider a matrix with no rows or no columns, called an empty matrix.

+Overview of a matrix size Name Size Example Description Row matrix or row vector A matrix with one row and more than one column, sometimes used to represent a vector Column matrix or column vector A matrix with one column and more than one row, sometimes used to represent a vector Square matrix A matrix with the same number of rows and columns, sometimes used to represent a linear transformation from a vector space to itself, such as reflection, rotation, or shearing.

Notation The specifics of symbolic matrix notation vary widely, with some prevailing trends. Matrices are commonly written in square brackets or parentheses, so that an matrix is represented as

This may be abbreviated by writing only a single generic term, possibly along with indices, as in

or in the case that .

Matrices are usually symbolized using upper-case letters (such as in the examples above), while the corresponding lower-case letters, with two subscript indices (e.g., , or ), represent the entries. In addition to using upper-case letters to symbolize matrices, many authors use a special typographical style, commonly boldface roman (non-italic), to further distinguish matrices from other mathematical objects. An alternative notation involves the use of a double-underline with the variable name, with or without boldface style, as in .

The entry in the th row and th column of a matrix is sometimes referred to as the or entry of the matrix, and commonly denoted by or . Alternative notations for that entry are and . For example, the entry of the following matrix is (also denoted , , or ):

Sometimes, the entries of a matrix can be defined by a formula such as . For example, each of the entries of the following matrix is determined by the formula .

In this case, the matrix itself is sometimes defined by that formula, within square brackets or double parentheses. For example, the matrix above is defined as or . If matrix size is , the above-mentioned formula is valid for any and any . This can be specified separately or indicated using as a subscript. For instance, the matrix above is , and can be defined as or .

Some programming languages utilize doubly subscripted arrays (or arrays of arrays) to represent an {-by- matrix. Some programming languages start the numbering of array indexes at zero, in which case the entries of an matrix are indexed by and . This article follows the more common convention in mathematical writing where enumeration starts from .

The set of all -by- real matrices is often denoted , or . The set of all matrices over another field, or over a ring , is similarly denoted , or . If , such as in the case of square matrices, one does not repeat the dimension: , or . Often, , or , is used in place of .For example, for , see , p. 48; for , see , p. 50.

Basic operations Several basic operations can be applied to matrices. Some, such as transposition and submatrix do not depend on the nature of the entries. Others, such as matrix addition, scalar multiplication, matrix multiplication, and row operations involve operations on matrix entries and therefore require that matrix entries are numbers or belong to a field or a ring.

In this section, it is supposed that matrix entries belong to a fixed ring, which is typically a field of numbers.

Addition

Matrix addition and subtraction require matrices of a consistent size, and are calculated entrywise. The sum and the difference of two matrices are:

For example,

Familiar properties of numbers extend to these operations on matrices: for example, addition is commutative, that is, the matrix sum does not depend on the order of the summands: .

Scalar multiplication

The product of a number (also called a scalar in this context) and a matrix is computed by multiplying each entry of by :

This operation is called scalar multiplication, but its result is not named "scalar product" to avoid confusion, since "scalar product" is often used as a synonym for "inner product". For example:

Matrix subtraction is consistent with composition of matrix addition with scalar multiplication by :

Transpose

The transpose of an matrix is the matrix (also denoted or ) formed by turning rows into columns and vice versa:

For example:

The transpose is compatible with addition and scalar multiplication, as expressed by and . Finally, .

Matrix multiplication

Multiplication of two matrices corresponds to the composition of linear transformations represented by each matrix. It is defined if and only if the number of columns of the left matrix is the same as the number of rows of the right matrix. If is an matrix and is an matrix, then their matrix product is the matrix whose entries are given by the dot product of the corresponding row of and the corresponding column of :

where and . For example, the underlined entry 2340 in the product is calculated as

Matrix multiplication satisfies the rules (associativity), and as well as (left and right distributivity), whenever the size of the matrices is such that the various products are defined. The product may be defined without being defined, namely if and are and matrices, respectively, and Even if both products are defined, they generally need not be equal, that is:

In other words, matrix multiplication is not commutative, in marked contrast to (rational, real, or complex) numbers, whose product is independent of the order of the factors. An example of two matrices not commuting with each other is:

whereas

Besides the ordinary matrix multiplication just described, other less frequently used operations on matrices that can be considered forms of multiplication also exist, such as the Hadamard product and the Kronecker product. They arise in solving matrix equations such as the Sylvester equation.

Row operations

There are three types of row operations: row addition, that is, adding a row to another. row multiplication, that is, multiplying all entries of a row by a non-zero constant; row switching, that is, interchanging two rows of a matrix; These operations are used in several ways, including solving linear equations and finding matrix inverses with Gauss elimination and Gauss–Jordan elimination, respectively.

Submatrix A submatrix of a matrix is a matrix obtained by deleting any collection of rows or columns or both. For example, from the following matrix, we can construct a submatrix by removing row 3 and column 2:

The minors and cofactors of a matrix are found by computing the determinant of certain submatrices.

A principal submatrix is a square submatrix obtained by removing certain rows and columns. The definition varies from author to author. According to some authors, a principal submatrix is a submatrix in which the set of row indices that remain is the same as the set of column indices that remain. Other authors define a principal submatrix as one in which the first rows and columns, for some number , are the ones that remain; this type of submatrix has also been called a leading principal submatrix..

Linear equations

Matrices can be used to compactly write and work with multiple linear equations, that is, systems of linear equations. For example, if is an matrix, designates a column vector (that is, matrix) of variables and is an column vector, then the matrix equation

is equivalent to the system of linear equations

Using matrices, this can be solved more compactly than would be possible by writing out all the equations separately. If and the equations are independent, then this can be done by writing

where is the inverse matrix of . If has no inverse, solutions—if any—can be found using its generalized inverse.

Linear transformations

Matrices and matrix multiplication reveal their essential features when related to linear transformations, also known as linear maps. A real -by- matrix gives rise to a linear transformation mapping each vector in to the (matrix) product , which is a vector in Conversely, each linear transformation arises from a unique -by- matrix : explicitly, the -entry of is the th coordinate of , where is the unit vector with in the th position and elsewhere. The matrix is said to represent the linear map , and is called the transformation matrix of .

For example, the matrix

can be viewed as the transform of the unit square into a parallelogram with vertices at , , , and . The parallelogram pictured at the right is obtained by multiplying with each of the column vectors , , , and in turn. These vectors define the vertices of the unit square. The following table shows several real matrices with the associated linear maps of . The original is mapped to the grid and shapes. The origin is marked with a black point. Horizontal shearwith m = 1.25. Reflection through the vertical axis Squeeze mappingwith r = 3/2 Scalingby a factor of 3/2Rotationby /6 = 30°