This site is supported by donations to The OEIS Foundation.

# Matrices

(Redirected from Matrix)

A matrix (plural matrices) is a rectangular array of numbers, symbols, or expressions, arranged in rows and columns. (A matrix is a tensor of rank 2.) The individual items in a matrix are called its elements or entries.

An
 m  × n
matrix
 A
is commonly written using box brackets (an alternative notation uses large parentheses instead)
${\displaystyle \mathbf {A} ={\begin{bmatrix}{\begin{array}{cccccc}a_{11}&a_{12}&\cdots &a_{1n}\\a_{21}&a_{22}&\cdots &a_{2n}\\\vdots &\vdots &\ddots &\vdots \\a_{m1}&a_{m2}&\cdots &a_{mn}\end{array}}\end{bmatrix}}=\left({\begin{matrix}{\begin{array}{cccccc}a_{11}&a_{12}&\cdots &a_{1n}\\a_{21}&a_{22}&\cdots &a_{2n}\\\vdots &\vdots &\ddots &\vdots \\a_{m1}&a_{m2}&\cdots &a_{mn}\end{array}}\end{matrix}}\right).}$

An example of a matrix with 3 rows and 5 columns is

${\displaystyle {\begin{bmatrix}{\begin{array}{rrrrr}-1&0&7&0&7\\34&-3&-67&0&-7\\9&-5&7&1&19\end{array}}\end{bmatrix}}=\left({\begin{matrix}{\begin{array}{rrrrr}-1&0&7&0&7\\34&-3&-67&0&-7\\9&-5&7&1&19\end{array}}\end{matrix}}\right).}$

## Matrix operations

### Unary matrix operations

#### Transpose

The transpose of an
 m  × n
matrix
 A
is the
 n  ×  m
matrix
 AT
formed by interchanging the rows and columns of
 A
, i.e.
${\displaystyle (\mathbf {A} ^{\rm {T}})_{ij}:=\mathbf {A} _{ji},\quad 1\leq i\leq m,\ 1\leq j\leq n.}$

### Binary matrix operations

#### Scalar multiplication

The left scalar multiplication
 c​A
of a scalar
 c
and a matrix
 A
is defined as
${\displaystyle (c\mathbf {A} )_{ij}:=c\cdot \mathbf {A} _{ij},\quad 1\leq i\leq m,\ 1\leq j\leq n,}$
and the right scalar multiplication
 A c
of a matrix
 A
and a scalar
 c
is defined as
${\displaystyle (\mathbf {A} c)_{ij}:=\mathbf {A} _{ij}\cdot c,\quad 1\leq i\leq m,\ 1\leq j\leq n.}$

The sum
 A + B
of two
 m  × n
matrices
 A
and
 B
is calculated entrywise, i.e.
${\displaystyle (\mathbf {A} +\mathbf {B} )_{ij}:=\mathbf {A} _{ij}+\mathbf {B} _{ij},\quad 1\leq i\leq m,\ 1\leq j\leq n.}$

The commutativity of the elements entails the commutativity of matrix addition, i.e.

${\displaystyle \mathbf {A} _{ij}+\mathbf {B} _{ij}=\mathbf {B} _{ij}+\mathbf {A} _{ij},\quad 1\leq i\leq m,\ 1\leq j\leq n,}$
${\displaystyle \implies }$
${\displaystyle (\mathbf {A} +\mathbf {B} )_{ij}=(\mathbf {B} +\mathbf {A} )_{ij},\quad 1\leq i\leq m,\ 1\leq j\leq n.}$

#### Matrix multiplication

The matrix multiplication of an
 r  × s
matrix
 A
and an
 s  × t
matrix
 B
is defined as
${\displaystyle (\mathbf {A} \mathbf {B} )_{ik}:=\sum _{j=1}^{s}\mathbf {A} _{ij}\mathbf {B} _{jk},\quad 1\leq i\leq r,\,1\leq k\leq t,}$
where the product matrix
 A B
is an
 r  × t
matrix.

Note that matrix multiplication is noncommutative, i.e.

${\displaystyle \mathbf {A} \mathbf {B} \neq \mathbf {B} \mathbf {A} .}$

## Square matrices

A square matrix is an
 n  × n
matrix
${\displaystyle {\begin{bmatrix}{\begin{array}{cccccc}a_{11}&a_{12}&\cdots &a_{1n}\\a_{21}&a_{22}&\cdots &a_{2n}\\\vdots &\vdots &\ddots &\vdots \\a_{n1}&a_{n2}&\cdots &a_{nn}\end{array}}\end{bmatrix}},}$
where the entries
 ai i , 1   ≤   i   ≤   n,
constitute the main diagonal of
 A
.

### The identity matrix

The
 n  × n
identity matrix
 In
is a square matrix that has 1’s along the main diagonal and 0’s for all other entries. This matrix is often written simply as
 I
, and is special in that it acts like 1 in matrix multiplication.

Examples:

I1  =
 1
, I2  =
 1 0 0 1
, I3  =
 1 0 0 0 1 0 0 0 1
, I4  =
 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
, I5  =
 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1
, ...

### Trace

Main article page: Trace

The trace of an
 n  × n
square matrix is defined as the sum of the elements on the main diagonal (the diagonal from the upper-left to the lower-right), i.e.
tr (A)  :=
 n ∑ i  = 1

ai  i  =  a1​1 + a2 2 + + an  n .

### Determinant

Main article page: Determinant

The determinant of an
 n  × n
square matrix is denoted
 | A |
or
 det A
. The determinant of a
 1 × 1
matrix (a scalar) is defined as (here we avoid the notation
 | a |
due to confusion with absolute value)
${\displaystyle \det {\begin{bmatrix}a_{}\end{bmatrix}}:=a_{}.}$
The determinant of a
 2 × 2
matrix is defined as
${\displaystyle \left|{\begin{matrix}a_{11}&a_{12}\\a_{21}&a_{22}\end{matrix}}\right|:=\det {\begin{bmatrix}a_{11}&a_{12}\\a_{21}&a_{22}\end{bmatrix}}:=a_{11}a_{22}-a_{12}a_{21}.}$
The determinant of an
 n  × n
square matrix is defined as
${\displaystyle \left|{\begin{matrix}{\begin{array}{cccccc}a_{11}&a_{12}&\cdots &a_{1n}\\a_{21}&a_{22}&\cdots &a_{2n}\\\vdots &\vdots &\ddots &\vdots \\a_{n1}&a_{n2}&\cdots &a_{nn}\end{array}}\end{matrix}}\right|:=\det {\begin{bmatrix}{\begin{array}{cccccc}a_{11}&a_{12}&\cdots &a_{1n}\\a_{21}&a_{22}&\cdots &a_{2n}\\\vdots &\vdots &\ddots &\vdots \\a_{n1}&a_{n2}&\cdots &a_{nn}\end{array}}\end{bmatrix}}:=\sum _{j=1}^{n}(-1)^{i+j}\,a_{ij}\,M_{ij}=\sum _{i=1}^{n}(-1)^{i+j}\,a_{ij}\,M_{ij},}$
where the minor
 M i j
is defined to be the determinant of the
 (n  −  1) × (n  −  1)
matrix obtained from
 A
by removing the
 i
th row and the
 j
th column. The expression
 ( − 1) i + j M i j
is known as the cofactor of
 ai j
.

 n  × n
square matrix
 A
is the transpose of the cofactor matrix
 C
of
 A
, i.e.
where
 Ci j
is the cofactor of
 ai j
.
 C i j  :=  (−1) i  +  j M i j , 1 ≤ i ≤ n, 1 ≤   j ≤ n,
and where
 M i j
is the minor of
 ai j
.

### Inverse

The inverse of an
 n  × n
square matrix
 A
is an
 n  × n
square matrix
 A  − 1
defined implicitly as
 A A  − 1  =  A  − 1 A  =  I n

where

${\displaystyle \mathbf {I} _{n}:={\begin{bmatrix}{\begin{array}{cccccc}1&0&\cdots &0\\0&1&\cdots &0\\\vdots &\vdots &\ddots &\vdots \\0&0&\cdots &1\end{array}}\end{bmatrix}}}$
is the
 n  × n
identity matrix (the main diagonal entries being 1, all other entries being 0).

A matrix is invertible (regular) if and only if its determinant is nonzero, otherwise the matrix is noninvertible (singular). Laplace’s formula for the inverse matrix is

A  − 1  =
, det (A) ≠ 0,
where
 A
.

### Eigenvectors and eigenvalues

Main article page: Eigenvectors and eigenvalues

A nonzero scalar
 λ
and a nonzero vector
 v
satisfying
 A v  =  λ v
are called an eigenvalue and an eigenvector of
 A
, respectively. The nonzero scalar
 λ
is an eigenvalue of an
 n  × n
matrix
 A
if and only if
 A  −  λ I n
is not invertible, which is equivalent to
 det (A − λ I n )  =  0.