Nov-28-2018, 07:03 AM
(This post was last modified: Nov-28-2018, 07:03 AM by Gribouillis.)
Here is how I was able to do it for a particular matrix
In the three matrices shown in the original post, the third line is
import numpy as np from numpy import linalg as la A = np.array([ [0.94328, 0.04779, 0.00892658], [0.367962, 0.52199275, 0.1100448852], [0, 0, 1], ]) # compute the eigenvalues and eigenvectors of A w, v = la.eig(A) # We are lucky, A is diagonalizable and its # eigenvalues (the components of w) are non negative # Aa = np.dot(v, np.dot(np.diag(w), la.inv(v))) ww = w ** (1/12) B = np.dot(v, np.dot(np.diag(ww), la.inv(v))) Aaa = la.matrix_power(B, 12) print(Aaa - A)
Output:[[ -1.44328993e-15 -1.73472348e-16 -1.35308431e-16]
[ -6.66133815e-16 -3.33066907e-16 1.80411242e-16]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00]]
You need to figure out what to do if there are complex eigenvalues or if A is not diagonalizable. Usually, there won't be a unique matrix B solution of this problem, and usually the matrix B will be complex.In the three matrices shown in the original post, the third line is
0, 0, 1
. If this is always the case, it makes the problem simpler because 1 is always an eigenvalue, and we're basically working in dimension 2.