# Diagonal matrix

In linear algebra, a diagonal matrix is a matrix in which the entries outside the main diagonal are all zero; the term usually refers to square matrices. An example of a 2-by-2 diagonal matrix is, while an example of a 3-by-3 diagonal matrix is. An identity matrix of any size, or any multiple of it, is a diagonal matrix.
A diagonal matrix is sometimes called a scaling matrix, since matrix multiplication with it results in changing scale. Its determinant is the product of its diagonal values.

## Definition

As stated above, a diagonal matrix is a matrix in which all off-diagonal entries are zero. That is, the matrix with n columns and n rows is diagonal if
However, the main diagonal entries are unrestricted.
The term diagonal matrix may sometimes refer to a ', which is an m-by-n matrix with all the entries not of the form di,i being zero. For example:
More often, however, diagonal matrix refers to square matrices, which can be specified explicitly as a
'. A square diagonal matrix is a symmetric matrix, so this can also be called a .
The following matrix is square diagonal matrix:
If the entries are real numbers or complex numbers, then it is a normal matrix as well.
In the remainder of this article we will consider only square diagonal matrices, and refer to them simply as "diagonal matrices".

## Scalar matrix

A diagonal matrix with all its main diagonal entries equal is a scalar matrix, that is, a scalar multiple λI of the identity matrix I. Its effect on a vector is scalar multiplication by λ. For example, a 3×3 scalar matrix has the form:
The scalar matrices are the center of the algebra of matrices: that is, they are precisely the matrices that commute with all other square matrices of the same size. By contrast, over a field, a diagonal matrix with all diagonal elements distinct only commutes with diagonal matrices. That is because if a diagonal matrix has then given a matrix with the term of the products are: and and , so they do not commute unless the off-diagonal terms are zero. Diagonal matrices where the diagonal entries are not all equal or all distinct have centralizers intermediate between the whole space and only diagonal matrices.
For an abstract vector space V, or more generally a module M over a ring R, with the endomorphism algebra End replacing the algebra of matrices, the analog of scalar matrices are scalar transformations. Formally, scalar multiplication is a linear map, inducing a map exhibiting End as a R-algebra. For vector spaces, or more generally free modules, for which the endomorphism algebra is isomorphic to a matrix algebra, the scalar transforms are exactly the center of the endomorphism algebra, and similarly invertible transforms are the center of the general linear group GL, where they are denoted by Z, follow the usual notation for the center.

## Vector operations

Multiplying a vector by a diagonal matrix multiplies each of the terms by the corresponding diagonal entry. Given a diagonal matrix and a vector, the product is:
This can be expressed more compactly by using a vector instead of a diagonal matrix,, and taking the Hadamard product of the vectors, denoted :
This is mathematically equivalent, but avoids storing all the zero terms of this sparse matrix. This product is thus used in computational mathematics, such as computing products of derivatives in backpropagation, since is these cases the entire diagonal matrix is not stored.

## Matrix operations

The operations of matrix addition and matrix multiplication are especially simple for diagonal matrices. Write for a diagonal matrix whose diagonal entries starting in the upper left corner are a1,..., an. Then, for addition, we have
and for matrix multiplication,
The diagonal matrix is invertible if and only if the entries a1,..., an are all non-zero. In this case, we have
In particular, the diagonal matrices form a subring of the ring of all n-by-n matrices.
Multiplying an n-by-n matrix A from the left with amounts to multiplying the ith row of A by ai for all i; multiplying the matrix A from the right with amounts to multiplying the ith column of A by ai for all i.

## Operator matrix in eigenbasis

As explained in determining coefficients of operator matrix, there is a special basis, e1,..., en, for which the matrix takes the diagonal form. Hence, in the defining equation, all coefficients with ij are zero, leaving only one term per sum. The surviving diagonal elements,, are known as eigenvalues and designated with in the equation, which reduces to. The resulting equation is known as eigenvalue equation and used to derive the characteristic polynomial and, further, eigenvalues and eigenvectors.
In other words, the eigenvalues of are λ1,..., λn with associated eigenvectors of e1,..., en.

## Properties

The determinant of is the product a1...an.
The adjugate of a diagonal matrix is again diagonal.
A square matrix is diagonal if and only if it is triangular and normal.
Any square diagonal matrix is also a symmetric matrix.
A symmetric diagonal matrix can be defined as a matrix that is both upper- and lower-triangular. The identity matrix In and any square zero matrix are diagonal. A one-dimensional matrix is always diagonal.

## Applications

Diagonal matrices occur in many areas of linear algebra. Because of the simple description of the matrix operation and eigenvalues/eigenvectors given above, it is typically desirable to represent a given matrix or linear map by a diagonal matrix.
In fact, a given n-by-n matrix A is similar to a diagonal matrix if and only if it has n linearly independent eigenvectors. Such matrices are said to be diagonalizable.
Over the field of real or complex numbers, more is true. The spectral theorem says that every normal matrix is unitarily similar to a diagonal matrix. Furthermore, the singular value decomposition implies that for any matrix A, there exist unitary matrices U and V such that UAV is diagonal with positive entries.

## Operator theory

In operator theory, particularly the study of PDEs, operators are particularly easy to understand and PDEs easy to solve if the operator is diagonal with respect to the basis with which one is working; this corresponds to a separable partial differential equation. Therefore, a key technique to understanding operators is a change of coordinates—in the language of operators, an integral transform—which changes the basis to an eigenbasis of eigenfunctions: which makes the equation separable. An important example of this is the Fourier transform, which diagonalizes constant coefficient differentiation operators, such as the Laplacian operator, say, in the heat equation.
Especially easy are multiplication operators, which are defined as multiplication by a fixed function–the values of the function at each point correspond to the diagonal entries of a matrix.