我应该使用python来解决Matrix A ^ 1000。我尝试使用numpy内置的matrix_power函数来计算输出,但是当我尝试根据公式P *(D ^ 1000)* P ^ -1逐步计算结果时,得到的结果不完整。我想弄清楚我的精度选项是否太紧,或者我是否完全在做其他错误
我已经尝试了matrix_power函数来获得我想要的结果。但是我需要能够说明计算是如何完成的,当我这样做时,我会得到不完整的结果
import numpy as np
np.set_printoptions(precision=6) # set the precision of the output
np.set_printoptions(suppress=True) # suppress the use of scientific notation
from numpy import diag, allclose, corrcoef
from numpy.random import randint, randn
from numpy.linalg import eig, matrix_rank, inv, cholesky, qr, norm, matrix_power
from sympy import Matrix, init_printing, matrix2numpy
A = np.array([[0.9,0.15,0.25],[0.075,0.8,0.25],[0.025,0.05,0.5]])
A
#python way
A_1000 = matrix_power(A,1000)
A_1000
D , P = eig(A)
P * np.diag(D**1000) * np.linalg.inv(p)