This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
 BUILT-IN MATHEMATICA SYMBOL Tutorials »| See Also »| More About »

# DiagonalMatrix

 DiagonalMatrix[list]gives a matrix with the elements of list on the leading diagonal, and elsewhere. DiagonalMatrixgives a matrix with the elements of list on the k diagonal. DiagonalMatrixpads with s to create an n×n matrix.
• DiagonalMatrix fills the k diagonal of a square matrix with the elements from list. Different values of k lead to different matrix dimensions.
• DiagonalMatrix always creates an n×n matrix, even if this requires dropping elements of list. »
Construct a diagonal matrix:
A superdiagonal matrix:
A subdiagonal matrix:
Construct a diagonal matrix:
 Out[1]//MatrixForm=
A superdiagonal matrix:
 Out[2]//MatrixForm=
A subdiagonal matrix:
 Out[3]//MatrixForm=
 Scope   (4)
The elements in DiagonalMatrix are chosen to match the elements of the vector:
Exact number entries:
Machine-number entries:
Arbitrary-precision number entries:
When the vector is a SparseArray object, DiagonalMatrix will give a SparseArray object:
Pad with zeros to make a larger square matrix:
Make a square matrix with the specified dimension:
Rectangular diagonal matrices:
 Applications   (4)
Express a matrix as the sum of its diagonal and off-diagonal parts:
Verify the similarity of a matrix to the diagonal matrix of its eigenvalues:
Define a Jordan matrix:
Construct a 5×5 tridiagonal matrix:
This can also be done using Band:
IdentityMatrix is a special case of DiagonalMatrix:
Several simple properties hold for diagonal matrices:
Det and Tr have commuting relations:
Diagonal of DiagonalMatrix gives the original vector:
This is true even if the vector is a SparseArray object:
Matrices with only subdiagonals or superdiagonals are always nilpotent:
The size of the matrix generated by DiagonalMatrix equals Length[list]+Abs[k]:
Band can be used to construct diagonals equivalent to DiagonalMatrix:
They will be SameQ if the vector is a SparseArray:
New in 1 | Last modified in 7