Content deleted Content added
rm most :-indents |
m Dating maintenance tags: {{More footnotes needed}} |
||
(32 intermediate revisions by 17 users not shown) | |||
Line 1:
{{Use American English|date = March 2019}}
{{Short description|Matrix whose only nonzero elements are on its main diagonal}}
{{More footnotes needed|date=June 2025}}
In [[linear algebra]], a '''diagonal matrix''' is a [[matrix (mathematics)|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 <math>\left[\begin{smallmatrix}
3 & 0 \\
Line 6 ⟶ 8:
\left[\begin{smallmatrix}
6 & 0 & 0 \\
0 &
0 & 0 &
\end{smallmatrix}\right]</math>. An [[identity matrix]] of any size, or any multiple of it
0.5 & 0 \\
0 & 0.5 \end{smallmatrix}\right]</math>.
==Definition==
As stated above, a diagonal matrix is a matrix in which all off-diagonal entries are zero. That is, the matrix {{math|1='''D''' = (''d''<sub>''i'',''j''</sub>)}} with
<math display="block">\forall i,j \in \{1, 2, \ldots, n\}, i \ne j \implies d_{i,j} = 0.</math>
However, the main diagonal entries are unrestricted.
The term ''diagonal matrix'' may sometimes refer to a '''{{visible anchor|rectangular diagonal matrix}}''', which is an
1 & 0 & 0\\
0 & 4 & 0\\
0 & 0 & -3\\
0 & 0 & 0\\
\end{bmatrix}
1 & 0 & 0 & 0 & 0\\
0 & 4 & 0& 0 & 0\\
0 & 0 & -3& 0 & 0
\end{bmatrix}</math>
Line 46 ⟶ 49:
==Vector-to-matrix diag operator==
A diagonal matrix
<math display="block">
\mathbf{D} = \operatorname{diag}(a_1, \dots, a_n). </math> This may be written more compactly as <math>\mathbf{D} = \operatorname{diag}(\mathbf{a})</math>.
The same operator is also used to represent [[Block matrix#Block diagonal matrices|block diagonal matrices]] as <math>
The
<math display="block">
\operatorname{diag}(\mathbf{a}) = \left(\mathbf{a} \mathbf{1}^\textsf{T}\right) \circ \mathbf{I}, </math> where <math>\circ</math> represents the [[Hadamard product (matrices)|Hadamard product]], and
==Matrix-to-vector diag operator==
The inverse matrix-to-vector
The following property holds:
<math display="block"
\operatorname{diag}(\mathbf{A}\mathbf{B}) = \sum_j \left(\mathbf{A} \circ \mathbf{B}^\textsf{T}\right)_{ij} = \left( \mathbf{A} \circ \mathbf{B}^\textsf{T} \right) \mathbf{1}.
</math>
== Scalar matrix ==
<!-- Linked from [[Scalar matrix]] and [[Scalar transformation]] -->
A diagonal matrix with equal diagonal entries is a '''scalar matrix'''; that is, a scalar multiple
<math display="block">
\begin{bmatrix}
Line 76 ⟶ 84:
</math>
The scalar matrices are the [[center of an algebra|center]] of the algebra of matrices: that is, they are precisely the matrices that [[commute (mathematics)|commute]] with all other square matrices of the same size.{{efn|Proof: given the [[elementary matrix]] <math>e_{ij}</math>, <math>Me_{ij}</math> is the matrix with only the ''i''-th row of ''M'' and <math>e_{ij}M</math> is the square matrix with only the ''M'' ''j''-th column, so the non-diagonal entries must be zero, and the ''i''th diagonal entry much equal the ''j''th diagonal entry.}} By contrast, over a [[field (mathematics)|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 <math>\mathbf{D} = \operatorname{diag}(a_1, \dots, a_n)</math> has <math>a_i \neq a_j,</math> then given a matrix
For an abstract vector space
== Vector operations ==
Multiplying a vector by a diagonal matrix multiplies each of the terms by the corresponding diagonal entry. Given a diagonal matrix <math>\mathbf{D} = \operatorname{diag}(a_1, \dots, a_n)</math> and a vector <math>\mathbf{v} = \begin{bmatrix} x_1 & \dotsm & x_n \end{bmatrix}^\textsf{T}</math>, the product is:
<math display="block">\mathbf{D}\mathbf{v} = \operatorname{diag}(a_1, \dots, a_n)\begin{bmatrix}x_1 \\ \vdots \\ x_n\end{bmatrix} =
\begin{bmatrix}
a_1 \\
Line 94 ⟶ 102:
This can be expressed more compactly by using a vector instead of a diagonal matrix, <math>\mathbf{d} = \begin{bmatrix} a_1 & \dotsm & a_n \end{bmatrix}^\textsf{T}</math>, and taking the [[Hadamard product (matrices)|Hadamard product]] of the vectors (entrywise product), denoted <math>\mathbf{d} \circ \mathbf{v}</math>:
<math display="block">\mathbf{D}\mathbf{v} = \mathbf{d} \circ \mathbf{v} =
\begin{bmatrix} a_1 \\ \vdots \\ a_n \end{bmatrix} \circ \begin{bmatrix} x_1 \\ \vdots \\ x_n \end{bmatrix} =
\begin{bmatrix} a_1 x_1 \\ \vdots \\ a_n x_n \end{bmatrix}.
</math>
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]],<ref>{{cite book |last=Sahami |first=Mehran |date=2009-06-15 |title=Text Mining: Classification, Clustering, and Applications |url=https://
== Matrix operations ==
The operations of matrix addition and [[matrix multiplication]] are especially simple for diagonal matrices. Write {{math|diag(''a''<sub>1</sub>, ..., ''a
<math display=block>
\operatorname{diag}(a_1,\, \ldots,\, a_n) + \operatorname{diag}(b_1,\, \ldots,\, b_n) = \operatorname{diag}(a_1 + b_1,\, \ldots,\, a_n + b_n)</math>
and for [[matrix multiplication]],
<math display=block>\operatorname{diag}(a_1,\, \ldots,\, a_n) \operatorname{diag}(b_1,\, \ldots,\, b_n) = \operatorname{diag}(a_1 b_1,\, \ldots,\, a_n b_n).</math>
The diagonal matrix {{math|diag(''a''<sub>1</sub>, ..., ''a
<math display=block>\operatorname{diag}(a_1,\, \ldots,\, a_n)^{-1} = \operatorname{diag}(a_1^{-1},\, \ldots,\, a_n^{-1}).</math>
In particular, the diagonal matrices form a [[subring]] of the ring of all
Multiplying an
== Operator matrix in eigenbasis ==
{{Main|Transformation matrix#Finding the matrix of a transformation|Eigenvalues and eigenvectors}}
As explained in [[transformation matrix#Finding the matrix of a transformation|determining coefficients of operator matrix]], there is a special basis, {{math|'''e'''<sub>1</sub>, ..., '''e'''<sub>''n''</sub>}}, for which the matrix
In other words, the [[eigenvalue]]s of {{math|diag(''λ''<sub>1</sub>, ..., ''λ''<sub>''n''</sub>)}} are {{math|''λ''<sub>1</sub>, ..., ''λ''<sub>''n''</sub>}} with associated [[eigenvectors]] of {{math|'''e'''<sub>1</sub>, ..., '''e'''<sub>''n''</sub>}}.
Line 133 ⟶ 142:
** A matrix is diagonal if and only if it is both [[triangular matrix|upper-]] and [[triangular matrix|lower-triangular]].
** A diagonal matrix is [[symmetric matrix|symmetric]].
* The [[identity matrix]] {{math|'''I'''<sub>''n''</sub>}} and [[zero matrix]] are diagonal.
* A 1×1 matrix is always diagonal.
* The square of a 2×2 matrix with zero [[trace (linear algebra)|trace]] 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 operator|linear map]] by a diagonal matrix.
In fact, a given
Over the [[field (mathematics)|field]] of [[real number|real]] or [[complex number|complex]] numbers, more is true. The [[spectral theorem]] says that every [[normal matrix]] is [[matrix similarity|unitarily similar]] to a diagonal matrix (if {{math|1='''AA'''<sup>∗</sup> = '''A'''<sup>∗</sup>'''A'''}} then there exists a [[unitary matrix]] {{
== Operator theory ==
|