Interpreting eigenvalues and eigenvectors when using symbolic toolbox

조회 수: 6 (최근 30일)
When using the symbolic math toolbox (symbolic "d" in this case) I sometimes end up with results (using different stochastic matrices) where I get more eigenvalues returned than eigenvectors which does not make sense to me. Might it be that since the eigenvalues are returned in the same dimension as the input matrix the first eigenvalue in this case 0 is to be ignored. I.e we get three eigenvalues (1, -(d*(3 + 15^(1/2)*1i))/6, (d*(- 3 + 15^(1/2)*1i))/6) corresponding to the three eigenvectors in the example provided below?
Thanks in advance for any input!
Btw I did notice that if I change the symbolic 'd' to a scalar e.g d= 0.5 I get 4 eigenvectors and 4 eigenvalues.
function [eig_mat,eig_val,M] = pagerank_function(linkMatrix,d)
n = size(linkMatrix,1)
M = times(d, linkMatrix) + times((1-d)/n , ones(n))
% diagonal matrix eigenvalues D, eigenvectors mtx U
[U,D] = eig((M))
extract_ev = diag(D)
%x = round(U, 2);
eig_mat = simplify(U)
eig_val = simplify(extract_ev)
end
Where I input the following matrix :
D125 = [0,1/3,1/3,1/3;
0,0,1,0;
1,0,0,0;
0,0,1,0];
And run the function using ;
d = sym('d');
[eig_mat,eig_val,M] = pagerank_function(D125,d);
% Latex code
latex_evtable = latex(sym([eig_mat]))
latex_etable = latex(sym([eig_val]))
latex_matrix = latex(sym(M))
Mtx_maker = latex(sym(D125))

채택된 답변

Christine Tobler
Christine Tobler 2022년 5월 16일
I'm getting both 4 eigenvalues and 4 eigenvectors when running your code:
linkMatrix = [0,1/3,1/3,1/3;
0,0,1,0;
1,0,0,0;
0,0,1,0];
d = sym('d');
n = size(linkMatrix,1)
n = 4
M = times(d, linkMatrix) + times((1-d)/n , ones(n))
M = 
% diagonal matrix eigenvalues D, eigenvectors mtx U
[U,D] = eig((M))
U = 
D = 
extract_ev = diag(D)
extract_ev = 
%x = round(U, 2);
eig_mat = simplify(U)
eig_mat = 
eig_val = simplify(extract_ev)
eig_val = 
Can you describe more of what outputs you are seeing?
  댓글 수: 4
Fredrik Scheie
Fredrik Scheie 2022년 5월 18일
I am not sure I understand the part about numerical computations where all matrices are treated as diagonizable. Is it the round off in numerical computation which can round off essentially two very similar eigenvalues and produce in the case of your A matrix 4 eigenvectors instead of the 3 produced using the symbolic calculations which calculates the eigenvectors using the null space?
Christine Tobler
Christine Tobler 2022년 5월 19일
Yes, that's the gist of it. Basically, numerical computation of EIG is based on a series of orthogonal similarity transformations applied to matrix A (Anew = Q*A*Q'). The transformations being orthogonal is important, since it means the amount of round-off error is kept minimal compared to doing Anew = X*A*inv(X) with a non-orthogonal matrix. But while the round-off is minimal, it still exists and means that we can't meaningfully tell the difference between two exactly identical eigenvalues and two eigenvalues that are just very close to each other.
If you're interested in more details, you might take a look at the Schur decomposition, which is an intermediate step in numerically computing the eigenvalue decomposition of a matrix. It decomposes A = U*T*U' where T is upper triangular (if you use the 'complex' flag) and U is orthogonal. The eigenvectors are then computed from T in a second step.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by