eig versus svd functions to calculate eigenvalues of complex matrix

12 Ansichten (letzte 30 Tage)
Hello,
I use the eig and svd respectively to calculate the eigenvalues of a 7*7 complex matrix, which is the result of FFT, but I get different results from the two funcion,
K=[-0.469586517065409 + 0.175378013674380i,-0.162669155608248 + 0.474138893683794i,0.187585296250523 + 0.464844814234381i,-0.0470935259817215 - 0.499050242461219i,0.501128494899033 - 0.0117973001242788i,-0.491929587334346 + 0.0963027818655986i,-0.491929587334346 + 0.0963027818655986i;-0.162669155608248 + 0.474138893683794i,0.263016111526474 + 0.426721770908734i,0.478226533722468 + 0.150227584463661i,-0.415448433490139 - 0.280484480498623i,0.309072541453745 - 0.394643014393155i,-0.237946127637339 + 0.441192231382635i,-0.237946127637339 + 0.441192231382635i;0.187585296250523 + 0.464844814234381i,0.478226533722468 + 0.150227584463661i,0.459785835505823 - 0.199664544068809i,-0.497649694446211 + 0.0601142770694749i,-0.0248843875256234 - 0.500649290369484i,0.109120724497475 + 0.489245962860338i,0.109120724497475 + 0.489245962860338i;-0.0470935259817215 - 0.499050242461219i,-0.415448433490139 - 0.280484480498623i,-0.497649694446211 + 0.0601142770694749i,0.494104399695533 + 0.0844380654178533i,-0.119058443001582 + 0.486923024553196i,0.0350717196883265 - 0.500038917653513i,0.0350717196883265 - 0.500038917653513i;0.501128494899033 - 0.0117973001242788i,0.309072541453745 - 0.394643014393155i,-0.0248843875256234 - 0.500649290369484i,-0.119058443001582 + 0.486923024553196i,-0.477319052929875 - 0.153086467070477i,0.496322714229578 + 0.0702332402056026i,0.496322714229578 + 0.0702332402056026i;-0.491929587334346 + 0.0963027818655986i,-0.237946127637339 + 0.441192231382635i,0.109120724497475 + 0.489245962860338i,0.0350717196883265 - 0.500038917653513i,0.496322714229578 + 0.0702332402056026i,-0.501053513999558 + 0.0146396994056337i,-0.501053513999558 + 0.0146396994056337i;-0.491929587334346 + 0.0963027818655986i,-0.237946127637339 + 0.441192231382635i,0.109120724497475 + 0.489245962860338i,0.0350717196883265 - 0.500038917653513i,0.496322714229578 + 0.0702332402056026i,-0.501053513999558 + 0.0146396994056337i,-0.501053513999558 + 0.0146396994056337i];
[~,S1,~]=svd(K);
[~,S2]=eig(K);
The primary eigenvalue from svd is real and the one from eig is complex. Based on my set, I know that svd gives the correct result, but I have no idea what causes this difference. Will you please give me any hints why this will occur? Besides, is there some useful algorithm to calculate the eigenvector of a normal complex matrix?
Any help would be highly appreciated!
Qiping

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 17 Feb. 2022
K=[-0.469586517065409 + 0.175378013674380i,-0.162669155608248 + 0.474138893683794i,0.187585296250523 + 0.464844814234381i,-0.0470935259817215 - 0.499050242461219i,0.501128494899033 - 0.0117973001242788i,-0.491929587334346 + 0.0963027818655986i,-0.491929587334346 + 0.0963027818655986i;-0.162669155608248 + 0.474138893683794i,0.263016111526474 + 0.426721770908734i,0.478226533722468 + 0.150227584463661i,-0.415448433490139 - 0.280484480498623i,0.309072541453745 - 0.394643014393155i,-0.237946127637339 + 0.441192231382635i,-0.237946127637339 + 0.441192231382635i;0.187585296250523 + 0.464844814234381i,0.478226533722468 + 0.150227584463661i,0.459785835505823 - 0.199664544068809i,-0.497649694446211 + 0.0601142770694749i,-0.0248843875256234 - 0.500649290369484i,0.109120724497475 + 0.489245962860338i,0.109120724497475 + 0.489245962860338i;-0.0470935259817215 - 0.499050242461219i,-0.415448433490139 - 0.280484480498623i,-0.497649694446211 + 0.0601142770694749i,0.494104399695533 + 0.0844380654178533i,-0.119058443001582 + 0.486923024553196i,0.0350717196883265 - 0.500038917653513i,0.0350717196883265 - 0.500038917653513i;0.501128494899033 - 0.0117973001242788i,0.309072541453745 - 0.394643014393155i,-0.0248843875256234 - 0.500649290369484i,-0.119058443001582 + 0.486923024553196i,-0.477319052929875 - 0.153086467070477i,0.496322714229578 + 0.0702332402056026i,0.496322714229578 + 0.0702332402056026i;-0.491929587334346 + 0.0963027818655986i,-0.237946127637339 + 0.441192231382635i,0.109120724497475 + 0.489245962860338i,0.0350717196883265 - 0.500038917653513i,0.496322714229578 + 0.0702332402056026i,-0.501053513999558 + 0.0146396994056337i,-0.501053513999558 + 0.0146396994056337i;-0.491929587334346 + 0.0963027818655986i,-0.237946127637339 + 0.441192231382635i,0.109120724497475 + 0.489245962860338i,0.0350717196883265 - 0.500038917653513i,0.496322714229578 + 0.0702332402056026i,-0.501053513999558 + 0.0146396994056337i,-0.501053513999558 + 0.0146396994056337i];
[~,S1,~]=svd(K)
S1 = 7×7
3.5089 0 0 0 0 0 0 0 0.0000 0 0 0 0 0 0 0 0.0000 0 0 0 0 0 0 0 0.0000 0 0 0 0 0 0 0 0.0000 0 0 0 0 0 0 0 0.0000 0 0 0 0 0 0 0 0.0000
[V2,S2]=eig(K)
V2 =
0.3780 + 0.0000i 0.2574 + 0.3036i -0.2401 + 0.2540i -0.2353 + 0.0517i 0.6982 + 0.0000i -0.1343 - 0.2593i -0.0365 + 0.0798i 0.2400 - 0.2920i 0.4525 + 0.0000i 0.2497 + 0.4245i -0.5440 + 0.1804i -0.3244 - 0.3176i 0.1908 - 0.2371i -0.0163 + 0.0136i -0.0099 - 0.3778i 0.3908 - 0.1266i 0.1743 - 0.1595i 0.5962 + 0.0000i 0.1494 + 0.1472i 0.3779 - 0.0556i 0.0469 + 0.0001i -0.0984 + 0.3649i -0.3733 + 0.2407i -0.1992 - 0.0839i -0.1908 - 0.3324i 0.2512 + 0.0947i 0.7412 + 0.0000i -0.0299 - 0.0401i -0.3571 - 0.1239i -0.0367 - 0.2892i 0.6534 + 0.0000i 0.1011 + 0.1998i 0.3603 + 0.2016i -0.3276 + 0.0283i 0.0389 + 0.0585i 0.3729 + 0.0618i -0.0582 + 0.2992i 0.2166 + 0.0777i 0.0843 + 0.1528i 0.0362 + 0.0928i 0.0783 + 0.0566i 0.7073 + 0.0000i 0.3729 + 0.0618i -0.0582 + 0.2992i 0.2166 + 0.0777i 0.0843 + 0.1528i 0.0362 + 0.0928i 0.0783 + 0.0566i -0.6935 + 0.0304i
S2 =
-0.7321 + 0.3631i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i -0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i -0.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i
temp = K'*K;
[~, temp2] = eig(temp);
S3 = sqrt(temp2)
S3 =
0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 3.5089 + 0.0000i
[~, S4] = eig(K)
S4 =
-0.7321 + 0.3631i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i -0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i -0.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i
format long g
sort(diag(S1), 'descend')
ans = 7×1
3.50887136980107 1.86578569609242e-15 9.7974672191401e-16 6.85329314059033e-16 4.27828408846602e-16 2.97234766540242e-16 7.60468150321396e-47
sort(diag(S3), 'descend')
ans =
3.50887136980107 + 0i 0 + 4.66622021324581e-08i 0 + 4.1817762387402e-08i 3.21756996073276e-08 + 0i 1.52990786017383e-08 + 0i 0 + 9.48351405909584e-09i 9.0637016425485e-09 + 0i
double(sort(diag(S4), 'descend'))
ans =
-0.73210625126657 + 0.363066237672952i 1.81144542351345e-16 - 3.23986413761137e-15i 3.5227363817712e-16 + 5.95757232884645e-16i -6.79101177552285e-16 - 3.02616219958971e-17i -3.93505984622934e-16 + 3.7514824870622e-16i 2.19351918660426e-16 - 3.98579307143519e-16i 1.7717710782892e-48 + 6.71192464190797e-48i
The complex parts are due to round-off error (and probably the nearly-zero parts are as well.)
Why are they diffferent? Well, SVD is defined in a way that only matches eig() when the matrix is square and real. eigenvalues involve the roots of a polynomial, and when the polynomial does not have real components it it certain that the roots will not all be real valued and non-negative and so cannot be the same as the singular values.
Singular values might be what you need for your purpose, but do not mistake them as being the eigenvalues of a complex matrix.
  2 Kommentare
Weijie Qi
Weijie Qi am 17 Feb. 2022
I get it. Thank you so much for your help.
Qiping Zhou
Paul
Paul am 17 Feb. 2022
"SVD is defined in a way that only matches eig() when the matrix is square and real."
Did you mean "matches" in a literal sense? I don't think that's the case
M = [1 0.2;3 4];
eig(M)
ans = 2×1
0.8118 4.1882
svd(M)
ans = 2×1
5.0585 0.6721

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

AndresVar
AndresVar am 17 Feb. 2022
I saw an answer Student in stackexchange that says eigenvalues and singular values coincide for a matrix that is real symmetric with non-negative eigenvalues
For the complex matrix K you can say singular values of K squared are equal to eigen values of K*K' (note ' is the conjugate transpose)
K=[-0.469586517065409 + 0.175378013674380i,-0.162669155608248 + 0.474138893683794i,0.187585296250523 + 0.464844814234381i,-0.0470935259817215 - 0.499050242461219i,0.501128494899033 - 0.0117973001242788i,-0.491929587334346 + 0.0963027818655986i,-0.491929587334346 + 0.0963027818655986i;-0.162669155608248 + 0.474138893683794i,0.263016111526474 + 0.426721770908734i,0.478226533722468 + 0.150227584463661i,-0.415448433490139 - 0.280484480498623i,0.309072541453745 - 0.394643014393155i,-0.237946127637339 + 0.441192231382635i,-0.237946127637339 + 0.441192231382635i;0.187585296250523 + 0.464844814234381i,0.478226533722468 + 0.150227584463661i,0.459785835505823 - 0.199664544068809i,-0.497649694446211 + 0.0601142770694749i,-0.0248843875256234 - 0.500649290369484i,0.109120724497475 + 0.489245962860338i,0.109120724497475 + 0.489245962860338i;-0.0470935259817215 - 0.499050242461219i,-0.415448433490139 - 0.280484480498623i,-0.497649694446211 + 0.0601142770694749i,0.494104399695533 + 0.0844380654178533i,-0.119058443001582 + 0.486923024553196i,0.0350717196883265 - 0.500038917653513i,0.0350717196883265 - 0.500038917653513i;0.501128494899033 - 0.0117973001242788i,0.309072541453745 - 0.394643014393155i,-0.0248843875256234 - 0.500649290369484i,-0.119058443001582 + 0.486923024553196i,-0.477319052929875 - 0.153086467070477i,0.496322714229578 + 0.0702332402056026i,0.496322714229578 + 0.0702332402056026i;-0.491929587334346 + 0.0963027818655986i,-0.237946127637339 + 0.441192231382635i,0.109120724497475 + 0.489245962860338i,0.0350717196883265 - 0.500038917653513i,0.496322714229578 + 0.0702332402056026i,-0.501053513999558 + 0.0146396994056337i,-0.501053513999558 + 0.0146396994056337i;-0.491929587334346 + 0.0963027818655986i,-0.237946127637339 + 0.441192231382635i,0.109120724497475 + 0.489245962860338i,0.0350717196883265 - 0.500038917653513i,0.496322714229578 + 0.0702332402056026i,-0.501053513999558 + 0.0146396994056337i,-0.501053513999558 + 0.0146396994056337i];
S1=svd(K).^2
S1 = 7×1
12.3122 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
S2=sort(abs(diag(eig(K*K','matrix'))),'descend')
S2 = 7×1
12.3122 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000

Kategorien

Mehr zu Eigenvalues finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by