線性代數3:本徵值,本徵向量

    1. 本徵值,本徵向量

    2. The eigenvalue equation for a matrix \(\mathbf{A} \) is \[ \mathbf{A}x_i=\lambda_i x_i \] For a n-dimensional matrix there are n eigenvalues \(\lambda_i\) and n corresponding eigenvector \(x_i\). Lets take an example: \[ \mathbf{A}= \begin{pmatrix} 2 & -2 & 0 \\ -2 & 1 & -2 \\ 0 & -2 & 0 \end{pmatrix}; \] You can verify that the 3 \(\lambda_i\) are \[ \lambda_i=4, 1, -2 \] and the 3 corresponding eigenvectors are \[ x_0=\begin{bmatrix}-2/3\\-2/3\\1/3 \end{bmatrix}; \lambda_0=4 \\ x_1=\begin{bmatrix}-2/3\\-1/3\\2/3 \end{bmatrix} ; \lambda_1=1 \\ x_2=\begin{bmatrix}1/3\\2/3\\2/3 \end{bmatrix} ; \lambda_2=-2 \\ \] \[ \begin{array}{lr} \mathbf{A}x_0= \begin{bmatrix}2&-2&0\\-2&1&-2\\0&-2&0\end{bmatrix} \begin{bmatrix}-2/3\\-2/3\\1/3 \end{bmatrix} = 4 \begin{bmatrix}-2/3\\-2/3\\1/3 \end{bmatrix} =\lambda_0 x_0 \end{array} \] You can show that the same results for the other 2 eigenvectors: \[ \mathbf{A} x_1 = \lambda_1 x_1; \mathbf{A} x_2 = \lambda_2 x_2; \]
    3. similarity transformation

    4. A matrix with its column vectors as the eigenvectors can transform the original matrix into a diagonal matrix: \[ \mathbf{V}=[x_0^t, x_1^t, x_2^t,...] \] \[ V^t A V=D \] \[ \mathbf{D}=\begin{bmatrix}\lambda_1&0&\cdots &0\\0&\lambda_1&\cdots &0\\\vdots &\vdots &\ddots &\vdots \\0&0&\cdots &\lambda_{n-1}\end{bmatrix} \] The diagonal matrix elements of \(\mathbf{D}\) are the eigenvalues of \(\mathbf{A}\).

    5. 使用numpy的linalg.eig函數求本徵值,本徵向量

    6. Use the following statement you can get the eigenvalues(D) and eigenvectors(V) of A:

      D,V=np.linalg.eig(A)



      import numpy as np
      A=np.mat([[2,-2,0],
                [-2,1,-2],
                [0,-2,0]])
      print 'A=\n',A
      print 'A.T=\n',A.T
      print 'Test if A=A.T:',np.all(A==A.T)
      
      print '\n\n--------------Use linalg.eig----'
      
      D,V=np.linalg.eig(A) 
      
      print 'D=',D 
      print 'V=\n',V
      
      print '\n\nVerify the column vectors of V are the corresponding eigenvetors----'
      for i in range(3):
          Vi=V[:,i]
          Ui=np.dot(A,Vi)
          print '--------i=',i,D[i]
          print 'Vi=\n',Vi
          print 'Ui=A.V[i]=\n',Ui
          print 'D[i]V[i]=\n',D[i]*Vi
          D1=D[i]*Vi-Ui
          print D1.T
          print 'check with allclose:',np.allclose(D[i]*Vi,Ui)
      
      print '\n\nConstruct diagonal matrix with np.diag(D)----'
      E=np.diag(D) 
      print 'Diagonalized matrix, E=\n',E
      
      print '\n\n The similarity transformation of A, V^t A V=d ===='
      s=np.dot(A,V)
      d=np.dot(V.T,s)
      print 'd=\n',d