Power of a Matrix Using Eigen Decomposition
Introduction to Matrix Powers with NumPy
Welcome to this lesson on computing the power of a matrix using eigen decomposition. In previous lessons, we explored the fundamentals of eigenvalues and eigenvectors, followed by matrix diagonalization. Now, we will take these concepts a step further to efficiently compute the power of a matrix, which is a matrix multiplied by itself a specific number of times. This operation finds applications in various fields, such as physics and computer graphics, where transformations and repeated operations are vital.
Eigen Decomposition Refresher
As a quick refresher, eigen decomposition involves expressing a matrix in terms of its eigenvalues and eigenvectors, which simplifies many matrix calculations. An eigenvalue is a scalar that, when multiplied by its corresponding eigenvector, yields a vector that points in the direction of the original vector after the transformation by the matrix. This decomposition plays a crucial role in raising matrices to powers, as it helps break the task into more manageable parts without directly multiplying the matrices repeatedly.
Example: Computing Matrix Powers Using Eigen Decomposition
Let's dive into an example to understand how eigen decomposition can be used to compute the power of a matrix. We will follow these steps in Python with NumPy:
-
Matrix Definition: We start by defining a 2x2 square matrix using
np.array(), which is a standard way to create matrices in NumPy. -
Eigen Decomposition: Using
np.linalg.eig(), we decompose the matrix into its eigenvalues and eigenvectors. This function returns two arrays: one for eigenvalues and another for eigenvectors. -
Calculate Powers of Eigenvalues: We calculate the power of the eigenvalues using the
**operator and create a diagonal matrix usingnp.diag(). This is crucial because, in matrix algebra, powers are easier to compute when the matrix is diagonal. -
Reconstruct the Powered Matrix: We reconstruct the matrix raised to the specified power using the formula:
matrix_power = eigenvectors @ diagonal_power @ np.linalg.inv(eigenvectors). The@operator in NumPy performs matrix multiplication, andnp.linalg.inv()calculates the inverse of the eigenvector matrix. -
Output: The final lines print the original matrix and the matrix raised to the specified power (3 in this case).
This output shows our original matrix and the result after raising it to the third power using eigen decomposition, giving the values [[86. 39.] [78. 47.]].
