How to avoid using det, when looking for the complex root w with det(M(w)) = 0
Afficher commentaires plus anciens
Hi all,
I want to find a complex number w such that det(M(w)) converges to 0 (note that M is a matrix and it is a function of w), but the det function seems to have a large error, how can I avoid using it?M is an 8*8 matrix, so it would be very complicated to write out its determinant expression.
Thanks in advance.
6 commentaires
KSSV
le 6 Juil 2022
Show us your M...
ma Jack
le 6 Juil 2022
KSSV
le 6 Juil 2022
What exactly you are trying to do? x is not defined in your case.
ma Jack
le 6 Juil 2022
Walter Roberson
le 6 Juil 2022
As discussed in your previous question, you have the difficulty that you are working with a matrix whose determinant is on the order of 10^250
On the first ModeXY matrix that is generated, there are only four unique values. If you construct a representative symbolic matrix in terms of the pattern of unique values, and take det() of it, and substitute in the unique values, then that is a lot faster than calculating det() of the original matrix symbolically. The idea of calculating it symbolically being to reduce the error in the calculation of det()
ModeXY = [M1,M2,M2,M2;...
M2,M1,M2,M2;...
M2,M2,M1,M2;...
M2,M2,M2,M1];%size:(2*4,2*4)
That promises that the pattern continues of there being only 4 unique elements in the matrix, so you can
pre-calculate the determinant as
(V1 + V2 - V3 - V4)^3*(V1 - V2 - V3 + V4)^3*(V1 + V2 + 3*V3 + 3*V4)*(V1 - V2 + 3*V3 - 3*V4)
which would be 0 if and only if any one of the sub-expressions is 0, which happens if
V1 + V2 = V3 + V4
V1 + V4 = V2 + V3
V1 + 3*V3 = V2 + 3*V4
V1 + V2 + 3*V3 + 3*V4 == 0
You might be able to take advantage of those to seek for a zero with a lower range.
ma Jack
le 7 Juil 2022
Réponses (1)
Because your matrix appears to be symmetric, I suggest minimizing instead norm(M(w)) which is the maximum absolute eigenvalue of M. This is the same as forcing M to be singular.
EDIT: rcond(M) is probably more appropriate than norm(M)
Additionally, I suggest using fminsearch instead of lsqnonlin, since you only have a small number of variables and a non-differentiable cost function. Be mindful, however, that you must express your objective function in terms of a vector z of real variables.
w=@(z) complex(z(1),z(2));
zopt=fminsearch(@(z) norm(M(w(z))) ,z0)
wopt=w(zopt)
21 commentaires
ma Jack
le 6 Juil 2022
I don't quite understand why norm(M(w)) is used instead of det(M(w)),
John demonstrated the problems with det() in your earlier post. Let's see how norm(M) does in similar examples:
M1=eye(1200)/2;
M2=0*M1;
det(M1), det(M2)
norm(M1), norm(M2)
Clearly norm(M) is better able to distinguish between singular and non-singular matrices than det. rcond() would be even better because it is independent of the scaling of M1:
rcond(M1),rcond(1e-100*M1), rcond(M2)
is there any advantage of fminsearch over lsqnonlin?
lsqnonlin assumes that the cost function is differentiable whereas fminsearch does not. It's not clear to me that your M(w) is a differentiable function of w, so fminsearch might therefore be safer. But you can also try lsqnonlin if you wish.
Matt J
le 6 Juil 2022
ma Jack's comment moved here:
Thank you very much for your reply sir, but I think I need to spend some time to understand and test them.
ma Jack
le 6 Juil 2022
Matt J
le 6 Juil 2022
Yes. All of the above are conditions for M --> singular matrix.
For a matrix M, norm(M) is the maximum singular value of M. M can be singular even though norm(M) ~=0. Of course, norm(M) == 0 means M is singular, but that condition seems overly restrictive (I think norm(M) == 0 is only true for the zero matrix?) .
M = [1 0;0 0];
norm(M)
det(M)
Am I missing something?
Bruno Luong
le 7 Juil 2022
Modifié(e) : Bruno Luong
le 7 Juil 2022
And of course det(M(w)) can converge to 0, "independent" of smalest/largest sinigular value
M1(w) = w*eye(n)
and
M2(w) = diag(1/w, w)
The question as it stands has very little interest mathematically, and if M is numercial approximated, one can never estimate accuracy smalleste eigen value below eps(1)*norm(M); which prevent ANY numerical algorithm to solve the problem OP asks.
In other word asking question on det is mostly a dead end numericaly in gerenal.
I've edited my post to recommend rcond(M) rather than norm(M). As Bruno's examples suggest, rcond would also be problematic without an upper bound on the largest eigenvalue. However, from the OP's code, it appears that the M(i,j) in this case are all globally bounded functions of w. They are just sums of complex exponential terms whos phases are functions of w. That would be enough to globally bound the largest eigenvalue.
Bruno Luong
le 7 Juil 2022
On a side note, numerically it is more reasonable to work with log(det(A)). It has some physical interpretation in some circumstance and equivalent to det(log(A)) such as A is definite positive matrix.
If the eigen values are purely complex phase, log(det) transforms to the sim of the phases.
ma Jack
le 7 Juil 2022
Bruno Luong
le 7 Juil 2022
Modifié(e) : Bruno Luong
le 7 Juil 2022
What is the unit and physical interpretation of the determinant of M for you?
If you can't answer my question accurately I would bet you stil not totally clear about the claim that you know how to translate the physics into maths.
Ifthe unit is (eV)^8 you might also have trouble and think about the physics again.
The only possibility of valid answer is det(M) has unitless unit. Is it the case?
ma Jack
le 7 Juil 2022
My goal is to find a complex w such that det(ModeXY)->0 (since this ensures that the eigenvector of an eigenequation like H\psi=lam\psi is not a 0-vector)
Eigenvectors are never 0-vectors, regardless of the determinant of H.
If you meant that you want to make sure H has a trivial null-space, det(H)=0 would be the opposite of what you want.
ma Jack
le 8 Juil 2022
Sorry I did't make it clear, not det(H), but det(H-eye*lam),
Still not clear. The condition det(H-eye*lam)=0 ensures that lam is an eigenvalue. Is that what you want?
in addition I use norm found that the effect is not det good
Of course not. Above, we said the idea of using norm(M) should be abandoned. What about rcond?
Bruno Luong
le 8 Juil 2022
det(H-eye*lam) (= 0)
So your problem is find the eigen values/vectors or H. Sorry but why not simply tell us that at the first place instead of asking a question with innacurate description that is not mathematically equivalent?
ma Jack
le 8 Juil 2022
Bruno Luong
le 8 Juil 2022
"due to simplification"
Please never do that when asking question. You would think it helps? Generally no, you should ask accurately question, since a simplified problem can have completily solution.
ma Jack
le 12 Juil 2022
Rosalinda
le 9 Avr 2024
hello ma jack..i encounter the same problem for 8by 8 matrix..if you could please tell me how you resolve your issue
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!