Diagonal
Diagonal[m]
gives the list of elements on the leading diagonal of the matrix m.
Diagonal[m,k]
gives the elements on the k diagonal of m.
Examples
open allclose allBasic Examples (4)
Scope (12)
Basic Uses (7)
Find the diagonal of a machine-precision matrix:
The superdiagonal of a complex matrix:
Diagonal of an arbitrary-precision matrix:
The diagonal of a symbolic matrix that is two below the main diagonal:
Diagonal accepts non-square matrices:
Special Matrices (5)
The diagonal of a sparse matrix is returned as a sparse list:
Convert the result to an ordinary list:
Get all the diagonals of the sparse array:
Convert the results to an ordinary list:
The diagonals of structured matrices:
IdentityMatrix has a diagonal of all ones:
Diagonal of HilbertMatrix:
Applications (3)
Express a matrix as the sum of its diagonal and off-diagonal parts:
Construct the diagonal as the difference between the original matrix and its diagonal part:
Confirm that two matrices have the desired properties:
Determine if the matrix is diagonalizable using its Jordan decomposition:
The superdiagonal of the Jordan form does not consist solely of zeros, so is not diagonalizable:
Confirm with a direct call to DiagonalizableMatrixQ:
Find the eigenvalues of the matrix using its Jordan decomposition:
The diagonal of the Jordan form gives the eigenvalues:
Confirm with a direct call to Eigenvalues:
Properties & Relations (7)
For square m, DiagonalMatrix[Diagonal[m]]==m iff DiagonalMatrixQ[m] is True:
For a matrix m, Tr[m] can be expressed as a combination of Diagonal and Total:
Diagonal[m,k] for an n×n matrix gives non-empty results for 1-n<=k<=n-1:
Diagonal[m,k] gives the lowest nonzero diagonal of UpperTriangularize[m,k]:
Similarly, Diagonal[m,k] gives the highest nonzero diagonal of LowerTriangularize[m,k]:
A matrix can be reconstructed from its diagonals using Band:
For a matrix m, Diagonal[m] is equivalent to Tr[m,List]:
For a square matrix m, Diagonal[m] is equivalent to Transpose[m,{1,1}]:
Text
Wolfram Research (2007), Diagonal, Wolfram Language function, https://reference.wolfram.com/language/ref/Diagonal.html.
CMS
Wolfram Language. 2007. "Diagonal." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Diagonal.html.
APA
Wolfram Language. (2007). Diagonal. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Diagonal.html