Tutorials › Linear Algebra › Computing Large Matrix Powers by Diagonalization

Diagonalization · Tutorial 540 of 1000

Computing Large Matrix Powers by Diagonalization

Use a verified diagonalization to compute and check large nonnegative integer powers of a matrix.

Intermediate 10 min read

What You'll Learn

  • Identify the diagonalization needed to compute a matrix power
  • Raise each diagonal entry to a positive integer exponent
  • Reconstruct the power using the eigenvector matrix and its inverse
  • Handle the zero power without interpreting scalar zero to the zero power
  • Check a computed power using its action on the eigenvector matrix
  • Avoid omitting the inverse during reconstruction

Why Diagonalization Helps with Powers

Repeatedly multiplying a matrix by itself can make a large power tedious to calculate, even when the entries of the original matrix are small. Diagonalization offers a different route: in a suitable coordinate system, the matrix acts by scaling each coordinate separately. A power then raises those scaling factors to the desired exponent. The final change back to the original coordinates requires matrix multiplication, but it avoids carrying out a long sequence of repeated products.

Throughout, matrices and scalars are real. Let \(\mathbf{A}\in\mathbb{R}^{n\times n}\). A diagonalization of \(\mathbf{A}\) is a factorization \(\mathbf{A}=\mathbf{P}\mathbf{D}\mathbf{P}^{-1}\), where \(\mathbf{P}\) is invertible and \(\mathbf{D}\) is diagonal. In the eigenvector interpretation, the columns of \(\mathbf{P}\), in order, are eigenvectors of \(\mathbf{A}\), and the corresponding eigenvalues appear in the same order on the diagonal of \(\mathbf{D}\). The order must match: changing the order of eigenvectors without making the corresponding change to \(\mathbf{D}\) will generally break the factorization.

Key idea: If \(\mathbf{A}=\mathbf{P}\mathbf{D}\mathbf{P}^{-1}\) and \(k\) is a positive integer, then \(\mathbf{A}^k=\mathbf{P}\mathbf{D}^k\mathbf{P}^{-1}\). If \(\mathbf{D}=\operatorname{diag}(\lambda_1,\dots,\lambda_n)\), then \(\mathbf{D}^k=\operatorname{diag}(\lambda_1^k,\dots,\lambda_n^k)\). This method requires a diagonalization over the field in which the matrices are being considered.

For \(k=0\), the convention is \(\mathbf{A}^0=\mathbf{I}_n\), and the result is \(\mathbf{I}_n\) without any calculation. For positive \(k\), each diagonal entry is raised to \(k\), including a zero diagonal entry, whose positive integer power is zero. This distinction avoids treating the scalar expression \(0^0\) as an ordinary arithmetic operation.

Why the Power Formula Works

The matrix identity can be justified directly from the definition of a diagonalization. For positive powers, every adjacent pair \(\mathbf{P}^{-1}\mathbf{P}\) in the repeated product equals \(\mathbf{I}_n\). The following proof makes this cancellation precise, including the first positive power.

Theorem: If \(\mathbf{A}=\mathbf{P}\mathbf{D}\mathbf{P}^{-1}\), where \(\mathbf{P}\in\mathbb{R}^{n\times n}\) is invertible and \(\mathbf{D}\in\mathbb{R}^{n\times n}\) is diagonal, then for every positive integer \(k\), \(\mathbf{A}^k=\mathbf{P}\mathbf{D}^k\mathbf{P}^{-1}\).

Proof. We use induction on \(k\). When \(k=1\), the assertion is the given equality \(\mathbf{A}=\mathbf{P}\mathbf{D}\mathbf{P}^{-1}\). Suppose it holds for a positive integer \(k\), so \(\mathbf{A}^k=\mathbf{P}\mathbf{D}^k\mathbf{P}^{-1}\). Then, using the definition of a matrix power and \(\mathbf{P}^{-1}\mathbf{P}=\mathbf{I}_n\),

$$ \mathbf{A}^{k+1} =\mathbf{A}^k\mathbf{A} =(\mathbf{P}\mathbf{D}^k\mathbf{P}^{-1})(\mathbf{P}\mathbf{D}\mathbf{P}^{-1}) =\mathbf{P}\mathbf{D}^k\mathbf{I}_n\mathbf{D}\mathbf{P}^{-1} =\mathbf{P}\mathbf{D}^{k+1}\mathbf{P}^{-1}. $$

Thus the formula holds for \(k+1\). By induction, it holds for every positive integer \(k\). \(\square\)

There is a useful entrywise version of the same calculation. Write \(p_{i\ell}\) for the entry in row \(i\), column \(\ell\) of \(\mathbf{P}\), and \(q_{\ell j}\) for the entry in row \(\ell\), column \(j\) of \(\mathbf{P}^{-1}\). For positive \(k\), the \((i,j)\) entry of the power is a sum of contributions from the diagonal coordinates:

Entry formula: If \(\mathbf{D}=\operatorname{diag}(\lambda_1,\dots,\lambda_n)\), then \((\mathbf{A}^k)_{ij}=\sum_{\ell=1}^n p_{i\ell}\lambda_\ell^k q_{\ell j}\) for every positive integer \(k\).

Proof. By the theorem, \(\mathbf{A}^k=\mathbf{P}\mathbf{D}^k\mathbf{P}^{-1}\). The \((i,j)\) entry of a product of three matrices is obtained by summing over the row and column indices used to multiply them. Since \(\mathbf{D}^k\) is diagonal, its entry in row \(\ell\), column \(r\) is zero unless \(\ell=r\); when \(\ell=r\), that entry is \(\lambda_\ell^k\). Therefore only the terms with matching indices remain, giving \((\mathbf{A}^k)_{ij}=\sum_{\ell=1}^n p_{i\ell}\lambda_\ell^k q_{\ell j}\). \(\square\)

A Reliable Calculation Procedure

1
Start with a verified diagonalization.
Use \(\mathbf{A}=\mathbf{P}\mathbf{D}\mathbf{P}^{-1}\), with \(\mathbf{P}\) invertible and the eigenvectors and eigenvalues in matching order. If the proposed factorization is not known to be correct, check it before using it.
2
Power the diagonal matrix.
For \(k\ge1\), replace each diagonal entry \(\lambda_i\) by \(\lambda_i^k\); the off-diagonal entries remain zero.
3
Reconstruct in the original coordinates.
Compute \(\mathbf{P}\mathbf{D}^k\mathbf{P}^{-1}\), keeping the inverse on the right. This is the desired \(\mathbf{A}^k\).
4
Check the result.
Multiply the proposed answer by \(\mathbf{P}\). It should give \(\mathbf{P}\mathbf{D}^k\). This follows from the formula and \(\mathbf{P}^{-1}\mathbf{P}=\mathbf{I}_n\), and it provides a check of the reconstruction.

Worked Calculations

Worked Example: A Symmetric Matrix Raised to the Eighth Power

Compute \(\mathbf{A}^8\) for \(\mathbf{A}=\begin{bmatrix}2&1\\1&2\end{bmatrix}\), using the diagonalization \(\mathbf{P}=\begin{bmatrix}1&1\\1&-1\end{bmatrix}\) and \(\mathbf{D}=\begin{bmatrix}3&0\\0&1\end{bmatrix}\).

First, \(\mathbf{P}^{-1}=\tfrac12\begin{bmatrix}1&1\\1&-1\end{bmatrix}\). Check that the stated factors do diagonalize \(\mathbf{A}\):

$$ \mathbf{A}\mathbf{P} =\begin{bmatrix}2&1\\1&2\end{bmatrix} \begin{bmatrix}1&1\\1&-1\end{bmatrix} =\begin{bmatrix}3&1\\3&-1\end{bmatrix} =\mathbf{P}\mathbf{D}. $$

Thus \(\mathbf{A}=\mathbf{P}\mathbf{D}\mathbf{P}^{-1}\). The diagonal entries raised to the eighth power are \(3^8=6561\) and \(1^8=1\). Reconstruct:

$$ \mathbf{A}^8 =\begin{bmatrix}1&1\\1&-1\end{bmatrix} \begin{bmatrix}6561&0\\0&1\end{bmatrix} \frac12\begin{bmatrix}1&1\\1&-1\end{bmatrix} =\frac12\begin{bmatrix}6562&6560\\6560&6562\end{bmatrix} =\begin{bmatrix}3281&3280\\3280&3281\end{bmatrix}. $$

Check: Multiplying the answer by \(\mathbf{P}\) gives

$$ \begin{bmatrix}3281&3280\\3280&3281\end{bmatrix} \begin{bmatrix}1&1\\1&-1\end{bmatrix} =\begin{bmatrix}6561&1\\6561&-1\end{bmatrix} =\mathbf{P}\mathbf{D}^8. $$

This matches the required relation \(\mathbf{A}^8\mathbf{P}=\mathbf{P}\mathbf{D}^8\).

Worked Example: A Nonsymmetric Matrix Raised to the Tenth Power

Compute the tenth power of \(\mathbf{A}=\begin{bmatrix}2&1\\0&3\end{bmatrix}\), given \(\mathbf{P}=\begin{bmatrix}1&1\\0&1\end{bmatrix}\) and \(\mathbf{D}=\begin{bmatrix}2&0\\0&3\end{bmatrix}\).

The inverse of \(\mathbf{P}\) is \(\begin{bmatrix}1&-1\\0&1\end{bmatrix}\), since their product in either order is \(\mathbf{I}_2\). To verify the diagonalization, compare \(\mathbf{A}\mathbf{P}\) with \(\mathbf{P}\mathbf{D}\):

$$ \mathbf{A}\mathbf{P} =\begin{bmatrix}2&1\\0&3\end{bmatrix} \begin{bmatrix}1&1\\0&1\end{bmatrix} =\begin{bmatrix}2&3\\0&3\end{bmatrix} =\mathbf{P}\mathbf{D}. $$

Now \(2^{10}=1024\) and \(3^{10}=59049\). Therefore

$$ \mathbf{A}^{10} =\begin{bmatrix}1&1\\0&1\end{bmatrix} \begin{bmatrix}1024&0\\0&59049\end{bmatrix} \begin{bmatrix}1&-1\\0&1\end{bmatrix} =\begin{bmatrix}1024&-1024+59049\\0&59049\end{bmatrix} =\begin{bmatrix}1024&58025\\0&59049\end{bmatrix}. $$

Check: Multiplying by \(\mathbf{P}\) gives

$$ \begin{bmatrix}1024&58025\\0&59049\end{bmatrix} \begin{bmatrix}1&1\\0&1\end{bmatrix} =\begin{bmatrix}1024&59049\\0&59049\end{bmatrix} =\mathbf{P}\mathbf{D}^{10}. $$

The off-diagonal entry is not obtained by raising the original off-diagonal entry to the tenth power; it comes from the reconstruction.

Worked Example: A Three-by-Three Power

Let \(\mathbf{A}=\begin{bmatrix}1&1&-1\\0&2&1\\0&0&3\end{bmatrix}\), \(\mathbf{P}=\begin{bmatrix}1&1&0\\0&1&1\\0&0&1\end{bmatrix}\), and \(\mathbf{D}=\begin{bmatrix}1&0&0\\0&2&0\\0&0&3\end{bmatrix}\). Compute \(\mathbf{A}^6\).

The inverse is \(\mathbf{P}^{-1}=\begin{bmatrix}1&-1&1\\0&1&-1\\0&0&1\end{bmatrix}\), as direct multiplication verifies. The columns of \(\mathbf{P}\) are \((1,0,0)^\top\), \((1,1,0)^\top\), and \((0,1,1)^\top\). Multiplication by \(\mathbf{A}\) sends these to \((1,0,0)^\top\), \((2,2,0)^\top\), and \((0,3,3)^\top\), respectively. These are the same columns scaled by \(1\), \(2\), and \(3\), so \(\mathbf{A}\mathbf{P}=\mathbf{P}\mathbf{D}\) and the diagonalization is verified.

The powered diagonal entries are \(1^6=1\), \(2^6=64\), and \(3^6=729\). Hence

$$ \mathbf{A}^6 =\begin{bmatrix}1&1&0\\0&1&1\\0&0&1\end{bmatrix} \begin{bmatrix}1&0&0\\0&64&0\\0&0&729\end{bmatrix} \begin{bmatrix}1&-1&1\\0&1&-1\\0&0&1\end{bmatrix} =\begin{bmatrix}1&63&-63\\0&64&665\\0&0&729\end{bmatrix}. $$

Check: The proposed result times \(\mathbf{P}\) is

$$ \begin{bmatrix}1&63&-63\\0&64&665\\0&0&729\end{bmatrix} \begin{bmatrix}1&1&0\\0&1&1\\0&0&1\end{bmatrix} =\begin{bmatrix}1&64&0\\0&64&729\\0&0&729\end{bmatrix} =\mathbf{P}\mathbf{D}^6. $$

Thus the reconstruction has the required action on all three eigenvector columns.

Common Error: Leaving Out the Inverse

The reconstruction is \(\mathbf{P}\mathbf{D}^k\mathbf{P}^{-1}\), not \(\mathbf{P}\mathbf{D}^k\mathbf{P}\). For the first example, use \(k=2\). Since \(\mathbf{D}^2=\begin{bmatrix}9&0\\0&1\end{bmatrix}\), incorrectly multiplying by \(\mathbf{P}\) on the right gives

$$ \mathbf{P}\mathbf{D}^2\mathbf{P} =\begin{bmatrix}1&1\\1&-1\end{bmatrix} \begin{bmatrix}9&0\\0&1\end{bmatrix} \begin{bmatrix}1&1\\1&-1\end{bmatrix} =\begin{bmatrix}10&8\\8&10\end{bmatrix}. $$

But \(\mathbf{A}^2=\begin{bmatrix}2&1\\1&2\end{bmatrix}\begin{bmatrix}2&1\\1&2\end{bmatrix}=\begin{bmatrix}5&4\\4&5\end{bmatrix}\), so that calculation is wrong. The correction is to use \(\mathbf{P}^{-1}=\tfrac12\mathbf{P}\) on the right:

$$ \mathbf{P}\mathbf{D}^2\mathbf{P}^{-1} =\frac12\begin{bmatrix}10&8\\8&10\end{bmatrix} =\begin{bmatrix}5&4\\4&5\end{bmatrix} =\mathbf{A}^2. $$

This example also shows why \(\mathbf{P}\) and \(\mathbf{P}^{-1}\) cannot be interchanged or omitted merely because they are related. In general, the inverse is essential to return from diagonal coordinates to the original coordinates.

When the Method Applies

The calculation applies when the matrix has a diagonalization over the chosen scalar field. If no such factorization is available, this procedure does not provide a diagonal form for computing the power; one must not assume that every matrix is diagonalizable. When a diagonalization is given, the diagonal entries can be powered independently, even if some eigenvalues repeat or are zero. For \(k\ge1\), a zero diagonal entry remains zero; for \(k=0\), the matrix power is the identity by definition.

For a large exponent, the benefit is most pronounced when the eigenvalues have simple powers or when many different powers of the same matrix are needed. The matrix \(\mathbf{P}\) and its inverse stay fixed while only the entries of \(\mathbf{D}^k\) change. The final multiplication may still involve arithmetic, but the repeated multiplication of the original matrix has been replaced by scalar powers and a single reconstruction.

Check Your Understanding

For each question, keep the order of the eigenvectors and diagonal entries consistent, and check the resulting power against the corresponding diagonal-coordinate relation.

  1. If \(\mathbf{A}=\mathbf{P}\operatorname{diag}(2,5)\mathbf{P}^{-1}\), what diagonal matrix is used when computing \(\mathbf{A}^4\)?
  2. For \(\mathbf{P}=\begin{bmatrix}1&1\\0&1\end{bmatrix}\) and \(\mathbf{D}=\operatorname{diag}(1,2)\), compute \(\mathbf{P}\mathbf{D}^3\mathbf{P}^{-1}\).
  3. Why does the reconstruction formula require \(\mathbf{P}^{-1}\) on the right?
  4. What is \(\mathbf{A}^0\), and why should a zero diagonal entry not be treated by calculating scalar \(0^0\)?
  5. State a matrix multiplication check for a proposed result \(\mathbf{B}=\mathbf{A}^k\) when \(\mathbf{A}=\mathbf{P}\mathbf{D}\mathbf{P}^{-1}\).

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon