Why the results are different while using eig() to solve syms and double Jacobian matrix?

11 次查看(过去 30 天)
Dearl all,
When I use eig to find the eigenvalues for a Jacobian matrix, the outputs are different if I define the Jacobian matrix as syms and double types. The order of each values are different in particular. I appreciate any clues for this difference:))
Many thanks,
JL
Here is an example:
% Create a syms J matrix and a dounble J matrix
JacobianSyms = vpa([1, 2, 3; 2, 1 8; 3, 8 9]);
JacobianDoub = double(JacobianSyms);
% Calculate their eigenvalues
[evs, eigenvaluesfromJacobianSyms] = eig(JacobianSyms)
evs = 
outPutfromJacobianSyms = 
[evd, eigenvaluesfromJacobianDoub] = eig(JacobianDoub)
evd = 3×3
-0.0294 0.9675 0.2513 0.8534 -0.1066 0.5103 -0.5205 -0.2294 0.8225
outPutfromJacobianDoub = 3×3
-3.9479 0 0 0 0.0681 0 0 0 14.8798

采纳的回答

Bruno Luong
Bruno Luong 2023-7-27
编辑:Bruno Luong 2023-7-27
If I ask a set of 3 integer numbers > 1 so that 30 is the product, what do you tell me?
(5,3,2) or
(5,2,3) or
(3,5,2) or
(3,2,5) or
(2,5,3) or
(2,3,5)
?
It's the same thing with eigen value and vectors, the order is just arbitrary set. So when you ask two different implementations for eigen values/vectors, you'll get the order that is arbitrary set by this routine.
  7 个评论
Juntong Lai
Juntong Lai 2023-7-28
编辑:Juntong Lai 2023-7-28
Hi Bruno,
Thank you very much for your kind explaination!
I think I am going to stick with using the jacobian matrix of the double type other than syms, but your further clarification clears my confusion.
In terms of Each eigenvalue represents the convergency of each variable in its dimension, you are right, Torsten. I am sorry for a bit of confusion above, please let me make the statement clearer.
In a linearisation of nonlinear ordinary differential equations, the eigenvalues can indicate the convergency of each variable in the corresponding directions (eigenvectors) in a phase plane, i.e. Ideally, the value of each variable will be convergent to zero if the eigenvalue is negative, and it will be away from zero if the eigenvalue is positive. So far, it does not matter how the order of eigenvalues is. However, it becomes important for me to ensure the order consistent if there is an additional dimension that is independently convergent. Namely, Torsten you are completely right in the case I came up with, but there will be a noise eigenvalue (always negative) to interfere with indexing the other eigenvalues to see whether they are negative/positive/complex values. I can traverse all of them but it will be much easier to analise the others if I keep the noise eigenvalue at the end of the matrix. That is the 'order' I meant essentially.
For instance:
% Create a syms J matrix and a dounble J matrix
JacobianSyms = vpa([1, 2, 3, 9, 9; ...
2, 1, 8, 9, 9; ...
3, 8, 9, 9, 9; ...
9, 8, 3, 9, 9; ...
0, 0, 0, 0, -1,]);
JacobianDoub = double(JacobianSyms);
% Calculate their eigenvalues
[evs, eigenvaluesfromJacobianSyms] = eig(JacobianSyms)
evs = 
eigenvaluesfromJacobianSyms = 
[evd, eigenvaluesfromJacobianDoub] = eig(JacobianDoub)
evd = 5×5
-0.3297 -0.3199 0.5400 0.7083 0.1188 -0.4520 0.2928 0.5967 -0.4953 -0.0198 -0.6208 0.7674 -0.0680 0.3967 0.0000 -0.5492 -0.4723 -0.5896 -0.3093 -0.7129 0 0 0 0 0.6909
eigenvaluesfromJacobianDoub = 5×5
24.3799 0 0 0 0 0 5.2621 0 0 0 0 0 -6.9940 0 0 0 0 0 -2.6480 0 0 0 0 0 -1.0000
In this example, -1.0 would be the noise eigenvalue, and I do not want to analyse it as I know it will be always a negative real value. Thus, the variable that may not be convergent at a point will be possibly regarded as convergent to the point if -1.0 appears in the middle of the eigenvalue matrix, though the above example can not mislead the judgement as there is no complex value here and the stability is quite obvious.
Again, thank you both for answering my questions and it is now well solved.
ATB,
JL
Bruno Luong
Bruno Luong 2023-7-28
编辑:Bruno Luong 2023-7-28
BTW if you want to take the control and impose your order, for example sorted on real part of eigen value just do this
[V,D] =eig(A)
[~,p] = sort(real(diag(D)));
V = V(:,p)
D = D(p,p)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by