26 lines
467 B
Python
26 lines
467 B
Python
import numpy as np
|
|
|
|
|
|
A = np.array(
|
|
[ [0, 1, 1, 0, 0, 0]
|
|
, [1, 0, 1, 0, 1, 0]
|
|
, [1, 1, 0, 1, 0, 0]
|
|
, [0, 0, 1, 0, 1, 0]
|
|
, [0, 0, 0, 1, 0, 1]
|
|
, [0, 0, 0, 0, 1, 0]
|
|
])
|
|
|
|
eigvalues, eigvectors = np.linalg.eig(A)
|
|
|
|
l_max_i = eigvalues.argmax()
|
|
l_max = eigvalues[l_max_i]
|
|
v_max = eigvectors[l_max_i]
|
|
|
|
def some_norm(M):
|
|
return np.abs(M).max()
|
|
|
|
for k in range(1, 21):
|
|
print("some kind of error for k =", k, ":", some_norm(A**k - l_max**k * np.outer(v_max, v_max.T)))
|
|
|
|
|