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. Elements of the main diagonal can either be zero or nonzero. An example of a 2×2 diagonal matrix is [3002], while an example of a 3×3 diagonal matrix is[600050004]. An identity matrix of any size, or any multiple of it is a diagonal matrix called a scalar matrix, for example, [0.5000.5]. In geometry, a diagonal matrix may be used as a scaling matrix, since matrix multiplication with it results in changing scale (size) and possibly also shape; only a scalar matrix results in uniform change in scale.
Definition As stated above, a diagonal matrix is a matrix in which all off-diagonal entries are zero. That is, the matrix D = (di,j) with n columns and n rows is diagonal if ∀i,j∈{1,2,…,n},i≠j⟹di,j=0. However, the main diagonal entries are unrestricted. The term diagonal matrix may sometimes refer to a rectangular diagonal matrix, which is an m-by-n matrix with all the entries not of the form di,i being zero. For example: [10004000−3000]or[100000400000−300] More often, however, diagonal matrix refers to square matrices, which can be specified explicitly as a square diagonal matrix. A square diagonal matrix is a symmetric matrix, so this can also be called a symmetric diagonal matrix. The following matrix is square diagonal matrix: [10004000−2] 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".
Vector-to-matrix diag operator A diagonal matrix D can be constructed from a vector 𝐚=[a1…an]𝖳 using the diag operator: 𝐃=diag(a1,…,an). This may be written more compactly as 𝐃=diag(𝐚). The same operator is also used to represent block diagonal matrices as 𝐀=diag(𝐀1,…,𝐀n) where each argument Ai is a matrix. The diag operator may be written as diag(𝐚)=(𝐚𝟏𝖳)∘𝐈, where ∘ represents the Hadamard product, and 1 is a constant vector with elements 1.
Matrix-to-vector diag operator The inverse matrix-to-vector diag operator is sometimes denoted by the identically named diag(𝐃)=[a1…an]𝖳, where the argument is now a matrix, and the result is a vector of its diagonal entries. The following property holds: diag(𝐀𝐁)=∑j(𝐀∘𝐁𝖳)ij=(𝐀∘𝐁𝖳)𝟏.
Scalar matrix A diagonal matrix with equal diagonal entries is a scalar matrix; that is, a scalar multiple λ of the identity matrix I. Its effect on a vector is scalar multiplication by λ. For example, a 3×3 scalar matrix has the form: [λ000λ000λ]≡λ𝑰3 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 (like the real numbers), a diagonal matrix with all diagonal elements distinct only commutes with diagonal matrices (its centralizer is the set of diagonal matrices). That is because if a diagonal matrix 𝐃=diag(a1,…,an) has ai≠aj, then given a matrix M with mij≠0, the (i, j) term of the products are: (𝐃𝐌)ij=aimij and (𝐌𝐃)ij=mijaj, and ajmij≠mijai (since one can divide by mij), 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 (rather than the concrete vector space Kn), the analog of scalar matrices are scalar transformations. This is true more generally for a module M over a ring R, with the endomorphism algebra End(M) (algebra of linear operators on M) replacing the algebra of matrices. Formally, scalar multiplication is a linear map, inducing a map R→End(M), (from a scalar λ to its corresponding scalar transformation, multiplication by λ) exhibiting End(M) as a R-algebra. For vector spaces, the scalar transforms are exactly the center of the endomorphism algebra, and, similarly, scalar invertible transforms are the center of the general linear group GL(V). The former is more generally true free modules M≅Rn, for which the endomorphism algebra is isomorphic to a matrix algebra.
Vector operations Multiplying a vector by a diagonal matrix multiplies each of the terms by the corresponding diagonal entry. Given a diagonal matrix 𝐃=diag(a1,…,an) and a vector 𝐯=[x1⋯xn]𝖳, the product is: 𝐃𝐯=diag(a1,…,an)[x1⋮xn]=[a1⋱an][x1⋮xn]=[a1x1⋮anxn]. This can be expressed more compactly by using a vector instead of a diagonal matrix, 𝐝=[a1⋯an]𝖳, and taking the Hadamard product of the vectors (entrywise product), denoted 𝐝∘𝐯: 𝐃𝐯=𝐝∘𝐯=[a1⋮an]∘[x1⋮xn]=[a1x1⋮anxn]. This is mathematically equivalent, but avoids storing all the zero terms of this sparse matrix. This product is thus used in machine learning, such as computing products of derivatives in backpropagation or multiplying IDF weights in TF-IDF, since some BLAS frameworks, which multiply matrices efficiently, do not include Hadamard product capability directly.
Matrix operations The operations of matrix addition and matrix multiplication are especially simple for diagonal matrices. Write diag(a1, ..., an) for a diagonal matrix whose diagonal entries starting in the upper left corner are a1, ..., an. Then, for addition, we have diag(a1,…,an)+diag(b1,…,bn)=diag(a1+b1,…,an+bn) and for matrix multiplication, diag(a1,…,an)diag(b1,…,bn)=diag(a1b1,…,anbn). The diagonal matrix diag(a1, ..., an) is invertible if and only if the entries a1, ..., an are all nonzero. In this case, we have diag(a1,…,an)−1=diag(a1−1,…,an−1). 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 diag(a1, ..., an) amounts to multiplying the i-th row of A by ai for all i; multiplying the matrix A from the right with diag(a1, ..., an) amounts to multiplying the i-th column of A by ai for all i.
Operator matrix in eigenbasis
… excerpt ends here. Continue reading the full article.