From c5a686cbed259b61186eae2abf8729ded4658964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kn=C3=BCttel?= Date: Wed, 23 Jan 2019 16:21:46 +0100 Subject: [PATCH] fixed ex42 --- ex_42.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ex_42.py b/ex_42.py index 113851b..dcce932 100644 --- a/ex_42.py +++ b/ex_42.py @@ -10,10 +10,13 @@ A = np.array( , [0, 0, 0, 0, 1, 0] ]) -eigvalues, eigvectors = np.linalg.eig(A) +eigvalues, eigvectors = np.linalg.eigh(A) +print(eigvalues) +print(eigvectors) l_max_i = eigvalues.argmax() l_max = eigvalues[l_max_i] +print(l_max_i, l_max) v_max = eigvectors[l_max_i] def some_norm(M): @@ -22,8 +25,8 @@ def some_norm(M): B = A for k in range(1, 21): B = B.dot(A) - print(B) - print(l_max**k * np.outer(v_max, v_max)) - print("some kind of error for k =", k, ":", some_norm(B - l_max**k * np.outer(v_max, v_max))) + print("some kind of error for k =", k, ":", some_norm(B - l_max**k * np.outer(v_max, v_max)) / l_max**k) + +print(v_max.argmax())