In mathematics, a **matrix** (plural **matrices**) is a rectangular *array*^{[1]} (see irregular matrix) of numbers, symbols, or expressions, arranged in *rows* and *columns*.^{[2]}^{[3]} For example, the dimension of the matrix below is 2 × 3 (read "two by three"), because there are two rows and three columns:

Provided that they have the same size (each matrix has the same number of rows and the same number of columns as the other), two matrices can be added or subtracted element by element (see conformable matrix). The rule for matrix multiplication, however, is that *two matrices can be multiplied only when the number of columns in the first equals the number of rows in the second* (i.e., the inner dimensions are the same, * n* for an (

The individual items in an *m*×*n* matrix **A**, often denoted by *a*_{i,j}, where *i* and *j* usually vary from 1 to *m* and *n*, respectively, are called its *elements* or *entries*.^{[4]} For conveniently expressing an element of the results of matrix operations the indices of the element are often attached to the parenthesized or bracketed matrix expression; e.g., (**AB**)_{i,j} refers to an element of a matrix product. In the context of abstract index notation this ambiguously refers also to the whole matrix product.

A major application of matrices is to represent linear transformations, that is, generalizations of linear functions such as *f*(*x*) = 4*x*. For example, the rotation of vectors in three-dimensional space is a linear transformation, which can be represented by a rotation matrix **R**: if **v** is a column vector (a matrix with only one column) describing the position of a point in space, the product **Rv** is a column vector describing the position of that point after a rotation. The product of two transformation matrices is a matrix that represents the composition of two transformations. Another application of matrices is in the solution of systems of linear equations. If the matrix is square, it is possible to deduce some of its properties by computing its determinant. For example, a square matrix has an inverse if and only if its determinant is not zero. Insight into the geometry of a linear transformation is obtainable (along with other information) from the matrix's eigenvalues and eigenvectors.

Applications of matrices are found in most scientific fields. In every branch of physics, including classical mechanics, optics, electromagnetism, quantum mechanics, and quantum electrodynamics, they are used to study physical phenomena, such as the motion of rigid bodies. In computer graphics, they are used to manipulate 3D models and project them onto a 2-dimensional screen. In probability theory and statistics, stochastic matrices are used to describe sets of probabilities; for instance, they are used within the PageRank algorithm that ranks the pages in a Google search.^{[5]} Matrix calculus generalizes classical analytical notions such as derivatives and exponentials to higher dimensions. Matrices are used in economics to describe systems of economic relationships.

A major branch of numerical analysis is devoted to the development of efficient algorithms for matrix computations, a subject that is centuries old and is today an expanding area of research. Matrix decomposition methods simplify computations, both theoretically and practically. Algorithms that are tailored to particular matrix structures, such as sparse matrices and near-diagonal matrices, expedite computations in finite element method and other computations. Infinite matrices occur in planetary theory and in atomic theory. A simple example of an infinite matrix is the matrix representing the derivative operator, which acts on the Taylor series of a function.

A *matrix* is a rectangular array of numbers or other mathematical objects for which operations such as addition and multiplication are defined.^{[6]} Most commonly, a matrix over a field *F* is a rectangular array of scalars each of which is a member of *F*.^{[7]}^{[8]} Most of this article focuses on *real* and *complex matrices*, that is, matrices whose elements are real numbers or complex numbers, respectively. More general types of entries are discussed below. For instance, this is a real matrix:

The numbers, symbols, or expressions in the matrix are called its *entries* or its *elements*. The horizontal and vertical lines of entries in a matrix are called *rows* and *columns*, respectively.

The size of a matrix is defined by the number of rows and columns that it contains. A matrix with *m* rows and *n* columns is called an *m* × *n* matrix or *m*-by-*n* matrix, while *m* and *n* are called its *dimensions*. For example, the matrix **A** above is a 3 × 2 matrix.

Matrices with a single row are called *row vectors*, and those with a single column are called *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*.

Name | Size | Example | Description |
---|---|---|---|

Row vector | 1 × n |
A matrix with one row, sometimes used to represent a vector | |

Column vector | n × 1 |
A matrix with one column, sometimes used to represent a vector | |

Square matrix | n × n |
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. |

Matrices are commonly written in box brackets or parentheses:

The specifics of symbolic matrix notation vary widely, with some prevailing trends. Matrices are usually symbolized using upper-case letters (such as **A** in the examples above), while the corresponding lower-case letters, with two subscript indices (for example, *a*_{11}, or *a*_{1,1}), represent the entries. In addition to using upper-case letters to symbolize matrices, many authors use a special typographical style, commonly boldface upright (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, (for example, ).

The entry in the *i*-th row and *j*-th column of a matrix **A** is sometimes referred to as the *i*,*j*, (*i*,*j*), or (*i*,*j*)th entry of the matrix, and most commonly denoted as *a*_{i,j}, or *a _{ij}*. Alternative notations for that entry are

Sometimes, the entries of a matrix can be defined by a formula such as *a*_{i,j} = *f*(*i*, *j*). For example, each of the entries of the following matrix **A** is determined by *a _{ij}* =

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 **A** = [*i*−*j*], or **A** = ((*i*−*j*)). If matrix size is *m* × *n*, the above-mentioned formula *f*(*i*, *j*) is valid for any *i* = 1, ..., *m* and any *j* = 1, ..., *n*. This can be either specified separately, or using *m* × *n* as a subscript. For instance, the matrix **A** above is 3 × 4 and can be defined as **A** = [*i* − *j*] (*i* = 1, 2, 3; *j* = 1, ..., 4), or **A** = [*i* − *j*]_{3×4}.

Some programming languages utilize doubly subscripted arrays (or arrays of arrays) to represent an *m*-×-*n* matrix. Some programming languages start the numbering of array indexes at zero, in which case the entries of an *m*-by-*n* matrix are indexed by 0 ≤ *i* ≤ *m* − 1 and 0 ≤ *j* ≤ *n* − 1.^{[9]} This article follows the more common convention in mathematical writing where enumeration starts from 1.

An asterisk is occasionally used to refer to whole rows or columns in a matrix. For example, *a*_{i,∗} refers to the i^{th} row of **A**, and *a*_{∗,j} refers to the j^{th} column of **A**. The set of all *m*-by-*n* matrices is denoted