Homepage › Solution manuals › Gilbert Strang › Linear Algebra and Learning from Data › Exercise 4.7.6
Exercise 4.7.6
Answers
For the 2 by 4 mesh of 8 nodes, I make nodes on the left half, with on diagonal. Similarly, are on the right side, with on diagonal. With weight , we have the matrix
From the calculation below, we see that , the corresponding has the top half with negative values and the bottom half with positive values, this cuts the nodes in the middle, where belong to one cluster and belong to another.
#### Problem IV.7.6 import numpy as np import scipy as sp a = np.array([[2, -1, -1, 0, 0, 0, 0, 0], [-1, 3, 0, -1, -1, 0, 0, 0], [-1, 0, 2, -1, 0, 0, 0, 0], [0, -1, -1, 3, 0, 0, -1, 0], [0, -1, 0, 0, 3, -1, -1, 0], [0, 0, 0, 0, -1, 2, 0, -1], [0, 0, 0, -1, -1, 0, 3, -1], [0, 0, 0, 0, 0, -1, -1, 2]]) D = np.diag(np.diag(a)) v, L = sp.linalg.eig(a, D) #np.argmin(v), np.iscomplex(v) vi = np.argsort(v) print(’lambda␣2:␣’, v[vi[1]]) z = L[:, vi[1]] print(’second␣eigenvector:␣’, z) np.matmul(np.ones(8).reshape(1,8), np.matmul(D, z))
lambda 2: (0.2712864461218309+0j) second eigenvector: [-0.45468835 -0.20798678 -0.45468835 -0.20798678 0.20798678 0.45468835 0.20798678 0.45468835] array([1.33226763e-15])