4.6. Powers of A¶
How does one compute matrix \(\bf{A}\) raised to the power \(k\) (\(\mathbf{A}^k\))?
The brute force approach is to multiply \(\bf{A}\) by itself \(k-1\) times, which is slow if \(k\) and the size of the matrix (\(n\)) are large. If we are clever about the order of the multiplications, it could be reduced to \(\log_{2}(k)\) matrix multiplications. That is:
Diagonalization allows us to compute \(\mathbf{A}^k\) faster.
Because the \(\bf{\Lambda}\) matrix is diagonal, only the individual \(\lambda\) values need be raised to the \(k\) power (element-wise exponent).
Example Power of A
In this example, the matrix is symmetric, so the inverse simplifies to a transpose.
In [54]: A = 2*np.random.randn(4, 4)
In [55]: S = A.T @ A
In [56]: L, Q = eig(S)
In [57]: L = np.diag(L)
In [58]: (Q @ L**5 @ Q.T) - S@S@S@S@S
Out[58]:
array([[-0.+0.j, 0.+0.j, -0.+0.j, -0.+0.j],
[ 0.+0.j, 0.+0.j, -0.+0.j, -0.+0.j],
[-0.+0.j, -0.+0.j, 0.+0.j, 0.+0.j],
[-0.+0.j, -0.+0.j, 0.+0.j, 0.+0.j]])