Hi Ikram,
Using N in place of inv(M) for simplicity, you are looking for a D such that
Let K*N and N*K have eigenvalue expansions
(K*N)*W = W*lambda
(N*K)*V = V*lambda
for matrices W and V and diagonal eigenvalue matrix lambda (although the code outputs lambda as a vector for convenience). It's the same lambda in both cases since the eigenvalues of K*N and N*K are identical. Matlab does not put eigenvalues in any particular order, so the code sorts the lambdas to make sure they are in the same order in each case. For simplicity I also assume no repeated eigenvalues because things are more complicated in that situation. It's easy to show that
is the solution.
n = 7;
K = rand(n,n);
N = rand(n,n);
[W lam] = eig(K*N,'vector');
[~,ind] = sort(lam);
W = W(:,ind);
[V lam] = eig(N*K,'vector');
[~,ind] = sort(lam);
V = V(:,ind);
D = real(W/V);
K*N*D - D*N*K
4 Comments
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/725907-how-do-i-find-a-d-matrix-that-satisfies-k-inv-m-d-d-inv-m-k#comment_1284718
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/725907-how-do-i-find-a-d-matrix-that-satisfies-k-inv-m-d-d-inv-m-k#comment_1284718
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/725907-how-do-i-find-a-d-matrix-that-satisfies-k-inv-m-d-d-inv-m-k#comment_1285143
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/725907-how-do-i-find-a-d-matrix-that-satisfies-k-inv-m-d-d-inv-m-k#comment_1285143
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/725907-how-do-i-find-a-d-matrix-that-satisfies-k-inv-m-d-d-inv-m-k#comment_1285693
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/725907-how-do-i-find-a-d-matrix-that-satisfies-k-inv-m-d-d-inv-m-k#comment_1285693
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/725907-how-do-i-find-a-d-matrix-that-satisfies-k-inv-m-d-d-inv-m-k#comment_1286263
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/725907-how-do-i-find-a-d-matrix-that-satisfies-k-inv-m-d-d-inv-m-k#comment_1286263
Sign in to comment.