Finding generalized eigenvectors numerically in Matlab

前端 未结 1 1437
星月不相逢
星月不相逢 2021-02-14 00:59

I have a matrix such as this example (my actual matrices can be much larger)

A = [-1 -2   -0.5;
      0  0.5  0;
      0  0   -1];

that has onl

1条回答
  •  不思量自难忘°
    2021-02-14 01:19

    As mentioned in my comments, if your matrix is defective, but you know which eigenvectors/eigenvalue pair you want to consider as identical given your tolerance, you can proceed as with this example below:

    % example matrix A:
    A = [1 0 0 0 0; 
         3 1 0 0 0; 
         6 3 2 0 0; 
         10 6 3 2 0;
         15 10 6 3 2]
    % Produce eigenvalues and eigenvectors (not generalized ones)
    [vecs,vals] = eig(A)
    

    This should output:

    vecs =
    
         0         0         0         0    0.0000
         0         0         0    0.2236   -0.2236
         0         0    0.0000   -0.6708    0.6708
         0    0.0000   -0.0000    0.6708   -0.6708
    1.0000   -1.0000    1.0000   -0.2236    0.2236
    
    
    vals =
    
     2     0     0     0     0
     0     2     0     0     0
     0     0     2     0     0
     0     0     0     1     0
     0     0     0     0     1
    

    Where we see that the first three eigenvectors are almost identical to working precision, as are the two last ones. Here, you must know the structure of your problem and identify the identical eigenvectors of identical eigenvalues. Here, eigenvalues are exactly identical, so we know which ones to consider, and we will assume that corresponding vectors 1-2-3 are identical and vectors 4-5. (In practice you will likely check the norm of the differences of eigenvectors and compare it to your tolerance)

    Now we proceed to compute the generalized eigenvectors, but this is ill-conditioned to solve simply with matlab's \, because obviously (A - lambda*I) is not full rank. So we use pseudoinverses:

    genvec21 = pinv(A - vals(1,1)*eye(size(A)))*vecs(:,1);
    genvec22 = pinv(A - vals(1,1)*eye(size(A)))*genvec21;
    genvec1 = pinv(A - vals(4,4)*eye(size(A)))*vecs(:,4);
    

    Which should give:

    genvec21 =
    
       -0.0000
        0.0000
       -0.0000
        0.3333
             0
    
    genvec22 =
    
        0.0000
       -0.0000
        0.1111
       -0.2222
             0
    
    genvec1 =
    
        0.0745
       -0.8832
        1.5317
        0.6298
       -3.5889
    

    Which are our other generalized eigenvectors. If we now check these to obtain the jordan normal form like this:

    jordanJ = [vecs(:,1) genvec21 genvec22 vecs(:,4) genvec1];
    jordanJ^-1*A*jordanJ
    

    We obtain:

    ans =
    
    2.0000    1.0000    0.0000   -0.0000   -0.0000
         0    2.0000    1.0000   -0.0000   -0.0000
         0    0.0000    2.0000    0.0000   -0.0000
         0    0.0000    0.0000    1.0000    1.0000
         0    0.0000    0.0000   -0.0000    1.0000
    

    Which is our Jordan normal form (with working precision errors).

    0 讨论(0)
提交回复
热议问题