# Diagonal matrix

A **diagonal matrix** is a square matrix in which every entry off the main diagonal is zero, so it has the form \( D = \mathrm{diag}(\lambda_1, \lambda_2, \ldots, \lambda_n) \) with the numbers \( \lambda_i \) running down the diagonal and zeros everywhere else.<sup>[1](https://math.libretexts.org/Bookshelves/Linear_Algebra/Linear_Algebra_with_Applications_%28Nicholson%29/03%253A_Determinants_and_Diagonalization/3.04%253A_Diagonalization)</sup> Diagonal matrices matter because they are the simplest square matrices to compute with: addition, multiplication, powers, determinants, and inverses all reduce to arithmetic on individual diagonal entries.<sup>[2](https://www.mathwords.com/d/diagonal_matrix.htm)</sup>

| Key fact | Detail |
|---|---|
| Definition | An \( n \times n \) matrix \( D \) is diagonal if all entries off the main diagonal are zero; written \( D = \mathrm{diag}(\lambda_1, \ldots, \lambda_n) \)<sup>[1](https://math.libretexts.org/Bookshelves/Linear_Algebra/Linear_Algebra_with_Applications_%28Nicholson%29/03%253A_Determinants_and_Diagonalization/3.04%253A_Diagonalization)</sup> |
| Sum and product | For diagonal \( D = \mathrm{diag}(\lambda_i) \) and \( E = \mathrm{diag}(\mu_i) \), \( D + E = \mathrm{diag}(\lambda_1 + \mu_1, \ldots, \lambda_n + \mu_n) \) and \( DE = \mathrm{diag}(\lambda_1\mu_1, \ldots, \lambda_n\mu_n) \)<sup>[1](https://math.libretexts.org/Bookshelves/Linear_Algebra/Linear_Algebra_with_Applications_%28Nicholson%29/03%253A_Determinants_and_Diagonalization/3.04%253A_Diagonalization)</sup> |
| Determinant | \( \mathrm{det}(A) = \prod_{k=1}^{n} a_{k,k} \), the product of the diagonal entries<sup>[3](https://ece.uwaterloo.ca/~dwharder/Determiants_and_inverses/)</sup> |
| Inverse | A diagonal matrix is invertible if and only if all diagonal entries are nonzero; the inverse is diagonal with each entry the reciprocal of the corresponding entry<sup>[3](https://ece.uwaterloo.ca/~dwharder/Determiants_and_inverses/)</sup> |
| Eigenstructure | The eigenvalues of \( D = \mathrm{diag}(d_1, \ldots, d_n) \) are the diagonal entries \( d_1, \ldots, d_n \), and the eigenvectors are the columns of the identity matrix<sup>[4](https://sites.science.oregonstate.edu/coursewikis/LinAlgBook/book/linalg/diag)</sup><sup> • </sup><sup>[5](https://www.cs.toronto.edu/~mbrubake/teaching/C11/Handouts/linalg.pdf)</sup> |
| Powers | Powers of a diagonal matrix are computed entrywise: \( D^k = \mathrm{diag}(\lambda_1^k, \ldots, \lambda_n^k) \)<sup>[6](https://www.math.purdue.edu/~xu1121/Sec5.3)</sup> |
| Special cases | A scalar matrix has all diagonal entries equal; a scalar matrix with entries equal to 1 is the identity matrix \( I \)<sup>[7](https://homepage.ntu.edu.tw/~luohm/intro_2005f/matrix1.pdf)</sup><sup> • </sup><sup>[8](https://www.sciencedirect.com/topics/computer-science/diagonal-matrix)</sup> |

## Algebraic properties

**Operations stay inside the class.** If \( D = \mathrm{diag}(\lambda_1, \ldots, \lambda_n) \) and \( E = \mathrm{diag}(\mu_1, \ldots, \mu_n) \) are diagonal matrices, their sum and product are again diagonal, obtained by applying the operation to corresponding diagonal elements:<sup>[1](https://math.libretexts.org/Bookshelves/Linear_Algebra/Linear_Algebra_with_Applications_%28Nicholson%29/03%253A_Determinants_and_Diagonalization/3.04%253A_Diagonalization)</sup>

\[ DE = \mathrm{diag}(\lambda_1 \mu_1, \lambda_2 \mu_2, \ldots, \lambda_n \mu_n), \qquad D + E = \mathrm{diag}(\lambda_1 + \mu_1, \lambda_2 + \mu_2, \ldots, \lambda_n + \mu_n). \]

Because diagonal matrices of the same size commute under multiplication (the products \( \lambda_i \mu_i \) and \( \mu_i \lambda_i \) agree), they form an unusually well-behaved family within the generally noncommutative algebra of square matrices.

**Determinant, inverse, and invertibility.** The determinant of a diagonal matrix is the product of its diagonal entries, \( \mathrm{det}(A) = \prod_{k=1}^{n} a_{k,k} \); the same formula holds for upper- and lower-triangular matrices, of which diagonal matrices are a special case.<sup>[3](https://ece.uwaterloo.ca/~dwharder/Determiants_and_inverses/)</sup> A diagonal matrix is invertible if and only if all diagonal entries are nonzero, and its inverse is the diagonal matrix of reciprocals.<sup>[3](https://ece.uwaterloo.ca/~dwharder/Determiants_and_inverses/)</sup> This replaces the cofactor expansion or row reduction needed for a general matrix with \( n \) divisions.<sup>[2](https://www.mathwords.com/d/diagonal_matrix.htm)</sup>

**Eigenvalues and eigenvectors.** For a diagonal matrix the eigenvalue problem is immediate. The eigenvalues of \( D = \mathrm{diag}(d_1, \ldots, d_n) \) are just the diagonal entries \( d_1, \ldots, d_n \),<sup>[5](https://www.cs.toronto.edu/~mbrubake/teaching/C11/Handouts/linalg.pdf)</sup> and the corresponding eigenvectors are the standard basis vectors: multiplying \( D \) by \( (1, 0, \ldots, 0)^{T} \) returns the first diagonal entry times that vector.<sup>[4](https://sites.science.oregonstate.edu/coursewikis/LinAlgBook/book/linalg/diag)</sup> The characteristic polynomial factors completely as \( \mathrm{det}(\lambda I - A) = \prod_{k=1}^{n} (\lambda - a_{k,k}) \).<sup>[3](https://ece.uwaterloo.ca/~dwharder/Determiants_and_inverses/)</sup>

## Diagonalization

**The target of diagonalization.** A square matrix \( A \) is called diagonalizable if it is similar to a diagonal matrix, that is, if \( A = PDP^{-1} \) for some invertible matrix \( P \) and diagonal matrix \( D \).<sup>[6](https://www.math.purdue.edu/~xu1121/Sec5.3)</sup> The Diagonalization Theorem states that an \( n \times n \) matrix is diagonalizable if and only if it has \( n \) linearly independent eigenvectors; in that case the columns of \( P \) are those eigenvectors and the diagonal entries of \( D \) are the corresponding eigenvalues.<sup>[6](https://www.math.purdue.edu/~xu1121/Sec5.3)</sup> A sufficient condition is having \( n \) distinct eigenvalues, though distinct eigenvalues are not necessary.<sup>[6](https://www.math.purdue.edu/~xu1121/Sec5.3)</sup>

Diagonalizability and invertibility are independent properties: \( \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix} \) is invertible but not diagonalizable, while \( \begin{bmatrix} 1 & 0 \\ 0 & 0 \end{bmatrix} \) is diagonalizable but not invertible.<sup>[6](https://www.math.purdue.edu/~xu1121/Sec5.3)</sup>

**Why it pays.** Once a matrix is in diagonal form, hard operations become easy. Powers follow entrywise, \( D^k = \mathrm{diag}(\lambda_1^k, \ldots, \lambda_n^k) \),<sup>[6](https://www.math.purdue.edu/~xu1121/Sec5.3)</sup> and the same holds for the matrix exponential: if \( A = SDS^{-1} \) with \( D = \mathrm{diag}(\lambda_1, \ldots, \lambda_n) \), then

\[ e^{A} = S\, e^{D}\, S^{-1}, \qquad e^{D} = \mathrm{diag}(e^{\lambda_1}, \ldots, e^{\lambda_n}). \]

This formula is the standard technique for solving linear systems of differential equations, where \( e^{tA} \) describes the time evolution of the system.<sup>[9](https://math.mit.edu/~dyatlov/18.03/lectures/Section8-3.pdf)</sup> In the eigenbasis, multiplying by \( A \) is merely scaling each coordinate by the corresponding eigenvalue, so repeated multiplication \( A^k x \) reduces to scaling each coordinate by \( \lambda_i^k \).<sup>[10](https://cs229.stanford.edu/notes2022fall/linalg.pdf)</sup>

**History.** [Augustin-Louis Cauchy](https://www.edgepedia.org/augustin-louis-cauchy), in 1826, found eigenvalues and gave results on the diagonalization of a matrix in the context of converting a quadratic form to a sum of squares; he also introduced the idea of similar matrices and showed that similar matrices share the same characteristic equation.<sup>[11](https://mathshistory.st-andrews.ac.uk/HistTopics/Matrices_and_determinants/)</sup> The general matrix concept into which diagonalization fits was fixed later, in [Arthur Cayley](https://www.edgepedia.org/arthur-cayley)'s 1858 *Memoir on the theory of matrices*, the first abstract definition of a matrix.<sup>[11](https://mathshistory.st-andrews.ac.uk/HistTopics/Matrices_and_determinants/)</sup>

## Occurrences and uses

**Statistics.** The variance-covariance matrix of uncorrelated variables is diagonal, with the variances of the individual variables on the main diagonal and zeros elsewhere.<sup>[12](https://online.stat.psu.edu/stat505/Lesson04)</sup> For jointly Gaussian random variables the converse holds as well: \( X_1, \ldots, X_d \) are independent if and only if the covariance matrix \( C \) is diagonal, meaning \( C_{ij} = 0 \) whenever \( i \neq j \).<sup>[13](https://vkaarnioja.github.io/s4ds/week4.pdf)</sup> This is why multivariate Gaussian models with diagonal covariance, whose density factorizes into a product of one-dimensional terms, appear so often in machine learning.<sup>[13](https://vkaarnioja.github.io/s4ds/week4.pdf)</sup>

**Numerical linear algebra.** Diagonal matrices serve as scaling factors in balancing, a preprocessing step for eigenvalue computations: LAPACK's balancing replaces a matrix \( A \) by \( D A D^{-1} \), with \( D \) diagonal, to make the rows and columns more nearly equal in norm and reduce the inaccuracy contributed by roundoff.<sup>[14](https://netlib.org/lapack/lug/node94.html)</sup> Two-sided diagonal scaling \( A^{(\mathrm{scaled})} = RAC \), with \( R = \mathrm{diag}(r_i) \) and \( C = \mathrm{diag}(c_i) \), is used to equilibrate linear systems before factorization.<sup>[15](https://www.netlib.org/utk/people/JackDongarra/PAPERS/icl-utk-1330-2020.pdf)</sup>

**Software.** Because a diagonal matrix stores only \( n \) meaningful numbers, numerical libraries treat it as a special sparse structure. SciPy's `scipy.sparse.diags` constructs a sparse matrix from one or more diagonals at specified offsets \( k \), where \( k = 0 \) is the main diagonal, \( k > 0 \) the \( k \)th upper diagonal, and \( k < 0 \) the \( k \)th lower diagonal.<sup>[16](https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.diags.html)</sup>

## Related forms

A diagonal matrix is the special case of a triangular matrix in which even one side of the diagonal is zero; the determinant formula \( \prod_k a_{k,k} \) and the eigenvalue-equals-diagonal-entry fact carry over from diagonal to upper- and lower-triangular matrices.<sup>[3](https://ece.uwaterloo.ca/~dwharder/Determiants_and_inverses/)</sup> A block-diagonal matrix, whose nonzero blocks sit on the main diagonal, has a determinant equal to the product of the determinants of its blocks and an inverse formed from the inverses of the blocks.<sup>[3](https://ece.uwaterloo.ca/~dwharder/Determiants_and_inverses/)</sup> Not every matrix can be brought to diagonal form; every square matrix can be brought to triangular form, with each eigenvalue repeated down the diagonal according to its algebraic multiplicity, which is the more general canonical theory.<sup>[17](https://sites.ualberta.ca/~jsylvest/books/DLA1/section-diagonalization-theory.html)</sup>

## References

1. [Diagonalization, Section 3.4, Linear Algebra with Applications (Nicholson), Mathematics LibreTexts](https://math.libretexts.org/Bookshelves/Linear_Algebra/Linear_Algebra_with_Applications_%28Nicholson%29/03%253A_Determinants_and_Diagonalization/3.04%253A_Diagonalization)
2. [Diagonal Matrix: Definition, Examples & Properties, Mathwords](https://www.mathwords.com/d/diagonal_matrix.htm)
3. [Formulas for the determinant, characteristic polynomial and inverses, D. W. Harder, University of Waterloo](https://ece.uwaterloo.ca/~dwharder/Determiants_and_inverses/)
4. [Diagonal Matrices, The Geometry of Linear Algebra, Oregon State University](https://sites.science.oregonstate.edu/coursewikis/LinAlgBook/book/linalg/diag)
5. [Linear Algebra Review and Reference, M. Brubaker, University of Toronto](https://www.cs.toronto.edu/~mbrubake/teaching/C11/Handouts/linalg.pdf)
6. [Section 5.3 Diagonalization, Purdue University](https://www.math.purdue.edu/~xu1121/Sec5.3)
7. [Matrix Algebra, M. Luo, National Taiwan University](https://homepage.ntu.edu.tw/~luohm/intro_2005f/matrix1.pdf)
8. [Diagonal Matrix: an overview, ScienceDirect Topics](https://www.sciencedirect.com/topics/computer-science/diagonal-matrix)
9. [Section 8.3: Exponential of a matrix, 18.03 Lecture Notes, MIT](https://math.mit.edu/~dyatlov/18.03/lectures/Section8-3.pdf)
10. [CS229 Section: Linear Algebra, Stanford University](https://cs229.stanford.edu/notes2022fall/linalg.pdf)
11. [Matrices and determinants, MacTutor History of Mathematics, University of St Andrews](https://mathshistory.st-andrews.ac.uk/HistTopics/Matrices_and_determinants/)
12. [Lesson 4: Multivariate Normal Distribution, STAT 505, Penn State](https://online.stat.psu.edu/stat505/Lesson04)
13. [Statistics for Data Science, Week 4, V. Kaarnioja](https://vkaarnioja.github.io/s4ds/week4.pdf)
14. [Balancing and Conditioning, LAPACK Users' Guide, Netlib](https://netlib.org/lapack/lug/node94.html)
15. [Two-Sided Diagonal Scaling, J. Dongarra, University of Tennessee](https://www.netlib.org/utk/people/JackDongarra/PAPERS/icl-utk-1330-2020.pdf)
16. [scipy.sparse.diags, SciPy v1.18.0 Manual](https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.diags.html)
17. [DLA Theory: Diagonalization, J. Sylvester, University of Alberta](https://sites.ualberta.ca/~jsylvest/books/DLA1/section-diagonalization-theory.html)

---
*Topic: Encyclopedia › Physical world and mathematics › Mathematics and statistics › Numbers and algebra › Linear and multilinear algebra › Matrix theory › Structured and special matrix classes*

*Initially written Sep 17, 2026 · Reviewed: Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

*Copyright 2026 EdgeChat AI, a subsidiary of Biostate AI.*

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license
