【问题标题】:numpy.linalg.eig does not find obvious eigen vectornumpy.linalg.eig 没有找到明显的特征向量
【发布时间】:2021-01-29 16:19:39
【问题描述】:

我有一个矩阵A 如下:

A
Out[34]: 
array([[1, 1, 1, 1, 0, 0, 0, 0],
       [1, 1, 1, 1, 0, 0, 0, 0],
       [1, 1, 1, 1, 0, 0, 0, 0],
       [1, 1, 1, 1, 0, 0, 0, 0],
       [0, 0, 0, 0, 1, 1, 1, 1],
       [0, 0, 0, 0, 1, 1, 1, 1],
       [0, 0, 0, 0, 1, 1, 1, 1],
       [0, 0, 0, 0, 1, 1, 1, 1]])

我想找到特征值和特征向量。

考虑如下向量x

x
Out[35]: array([4, 4, 4, 4, 0, 0, 0, 0])

这是一个特征向量,如下所示:

np.matmul(A, x) == 4 * x
Out[36]: array([ True,  True,  True,  True,  True,  True,  True,  True])
(np.matmul(A, x) == 4 * x).all()
Out[37]: True

但是,当我使用np.linalg.eig 计算特征向量时,它不包括 x(或 x 的缩放向量)。

l, v = np.linalg.eig(A)

l
Out[40]: array([0., 4., 0., 0., 0., 4., 0., 0.])


v
Out[41]: 
array([[-8.66025404e-01,  5.00000000e-01, -2.77555756e-17,
        -2.77555756e-17,  0.00000000e+00,  0.00000000e+00,
         0.00000000e+00,  0.00000000e+00],
       [ 2.88675135e-01,  5.00000000e-01, -5.77350269e-01,
        -5.77350269e-01,  0.00000000e+00,  0.00000000e+00,
         0.00000000e+00,  0.00000000e+00],
       [ 2.88675135e-01,  5.00000000e-01,  7.88675135e-01,
        -2.11324865e-01,  0.00000000e+00,  0.00000000e+00,
         0.00000000e+00,  0.00000000e+00],
       [ 2.88675135e-01,  5.00000000e-01, -2.11324865e-01,
         7.88675135e-01,  0.00000000e+00,  0.00000000e+00,
         0.00000000e+00,  0.00000000e+00],
       [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00,
         0.00000000e+00, -8.66025404e-01,  5.00000000e-01,
        -2.77555756e-17, -2.77555756e-17],
       [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00,
         0.00000000e+00,  2.88675135e-01,  5.00000000e-01,
        -5.77350269e-01, -5.77350269e-01],
       [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00,
         0.00000000e+00,  2.88675135e-01,  5.00000000e-01,
         7.88675135e-01, -2.11324865e-01],
       [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00,
         0.00000000e+00,  2.88675135e-01,  5.00000000e-01,
        -2.11324865e-01,  7.88675135e-01]])

虽然包含了特征值4,但缺少了特征向量。我错过了什么吗?

【问题讨论】:

    标签: numpy linear-algebra


    【解决方案1】:

    解决方案是正确的。如果你检查,

    import numpy as np
    
    A = np.array([[1, 1, 1, 1, 0, 0, 0, 0],
           [1, 1, 1, 1, 0, 0, 0, 0],
           [1, 1, 1, 1, 0, 0, 0, 0],
           [1, 1, 1, 1, 0, 0, 0, 0],
           [0, 0, 0, 0, 1, 1, 1, 1],
           [0, 0, 0, 0, 1, 1, 1, 1],
           [0, 0, 0, 0, 1, 1, 1, 1],
           [0, 0, 0, 0, 1, 1, 1, 1]])
    
    l, v = np.linalg.eig(A)
    
    print(v[:, 1])
    

    给出[0.5 0.5 0.5 0.5 0. 0. 0. 0. ],它是特征向量,是您要查找的向量的标量倍数。该函数给出了归一化向量,这就是为什么它都是 0.5 而不是 4。但是,它们在这种情况下是等价的。

    【讨论】:

    • 我意识到我正在查看行,而我应该查看列。谢谢。
    • 知道为什么[1, 1, 1, 1, 1, 1, 1, 1] 没有被列为特征向量。它的特征值为 4。
    • 因为可以使用[1, 1, 1, 1, 0, 0, 0, 0][0, 0, 0, 0, 1, 1, 1, 1] 的线性组合来创建,两者的特征值也都是4。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-31
    • 2023-03-02
    • 2021-11-21
    • 1970-01-01
    • 2013-05-15
    • 2011-12-26
    相关资源
    最近更新 更多