gives the nn identity matrix.

Details and Options


open allclose all

Basic Examples  (1)

Construct a 3×3 identity matrix:

Scope  (5)

A square identity matrix:

Non-square identity matrix:

The determinant of a square identity matrix is always 1:

Compute the rank of an identity matrix:

Construct a sparse identity matrix:

The sparse representation saves a significant amount of memory for larger matrices:

Options  (1)

WorkingPrecision  (1)

Create a machine-precision identity matrix:

Properties & Relations  (3)

Use DiagonalMatrix for general diagonal matrices:

The KroneckerProduct of a matrix with the identity matrix is a block diagonal matrix:

The WorkingPrecision option is equivalent to creating the matrix, then applying N:

Possible Issues  (1)

IdentityMatrix gives a matrix with dense storage. SparseArray is more compact:

The SparseArray representation uses a fraction of the memory:

For matrix and arithmetic operations they are effectively equal:

Wolfram Research (1988), IdentityMatrix, Wolfram Language function, (updated 2008).


Wolfram Research (1988), IdentityMatrix, Wolfram Language function, (updated 2008).


@misc{reference.wolfram_2021_identitymatrix, author="Wolfram Research", title="{IdentityMatrix}", year="2008", howpublished="\url{}", note=[Accessed: 29-November-2021 ]}


@online{reference.wolfram_2021_identitymatrix, organization={Wolfram Research}, title={IdentityMatrix}, year={2008}, url={}, note=[Accessed: 29-November-2021 ]}


Wolfram Language. 1988. "IdentityMatrix." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2008.


Wolfram Language. (1988). IdentityMatrix. Wolfram Language & System Documentation Center. Retrieved from