The number 1 functions as a multiplicative identity in regular multiplication. Multiplying any number by 1 returns the same number. For example, and . This property makes 1 the multiplicative identity for scalar numbers.
Linear algebra has a similar concept for matrix multiplication. There's a special matrix that acts like the number 1. When you multiply another matrix by this special matrix, the original matrix remains unchanged. This special matrix is called the identity matrix, usually denoted by .
The identity matrix is always a square matrix, meaning it has the same number of rows and columns. It has a very specific structure:
Here are a few examples:
The identity matrix, sometimes written as :
The identity matrix, :
And so on for larger square matrices. The subscript (like the '2' in ) indicates the size () of the square matrix. Often, the size is clear from the context of the matrix multiplication, so we might simply write .
The fundamental property of the identity matrix is that for any matrix , provided the multiplication is defined (the dimensions are compatible), the following holds true:
and
Let's look at a quick example. Consider the matrix :
Now, let's multiply by the identity matrix :
If we perform the matrix multiplication step-by-step:
The resulting matrix is:
You can perform the multiplication in the other order, , and verify that it also yields . The identity matrix serves as the neutral element for matrix multiplication, much like the number 1 does for scalar multiplication.
Let's revisit a simple scalar equation, for instance, . How do you solve for ? You multiply both sides by the multiplicative inverse (or reciprocal) of 5, which is :
This simplifies because :
And since is just :
The critical step was multiplying by the inverse to turn the coefficient of into 1 (the multiplicative identity), which isolated .
The identity matrix plays an analogous role when we want to solve matrix equations of the form . The goal is often to isolate the vector . If we could find a special matrix, which we'll call (read as "A inverse"), that has the property , then we could multiply both sides of the equation by this matrix (from the left):
Using the associative property of matrix multiplication, we can regroup the left side:
Now, since we chose such that :
Finally, just as , multiplying the identity matrix by a vector leaves the vector unchanged ():
This algebraic manipulation shows that if we can find this "inverse" matrix , we have a way to find the solution vector . The identity matrix is the foundation of this concept, representing the state where the original matrix 's effect has been neutralized, leaving isolated. We will examine this inverse matrix in the next section.
NumPy makes creating identity matrices straightforward with the numpy.eye(n) function, which generates an identity matrix.
import numpy as np
# Create a 2x2 identity matrix
I2 = np.eye(2)
print("2x2 Identity Matrix:")
print(I2)
# Create a 4x4 identity matrix
I4 = np.eye(4)
print("\n4x4 Identity Matrix:")
print(I4)
# Create a 3x3 identity matrix with integer type
I3_int = np.eye(3, dtype=int)
print("\n3x3 Integer Identity Matrix:")
print(I3_int)
Executing this code will output:
2x2 Identity Matrix:
[[1. 0.]
[0. 1.]]
4x4 Identity Matrix:
[[1. 0. 0. 0.]
[0. 1. 0. 0.]
[0. 0. 1. 0.]
[0. 0. 0. 1.]]
3x3 Integer Identity Matrix:
[[1 0 0]
[0 1 0]
[0 0 1]]
Note that NumPy often uses floating-point numbers by default (e.g., 1. and 0.). You can specify the data type using the dtype argument, as shown in the third example, if you specifically need integers or another type.
With this understanding of the identity matrix and its role analogous to the number 1, we are prepared to explore the matrix inverse, , and how it facilitates solving systems of linear equations.
Was this section helpful?
eye, used to generate identity matrices in Python.© 2026 ApX Machine LearningEngineered with