solve system of matrices
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
% I want to solve this system
f'(A,B)*[dA dB]'=[g(C))+B B*A-eye(n-1)]'
but when I found the derivative of f in the left side, I found that
f'(A,B)*[dA dB]'= [g(dA))-dB A*dB+B*dA]'
where A,B are (n-1)×(n-1) matrices
and C is n×n matrices
and I define a function chi from (n-1)×(n-1) matrices to the n×n matrices as
function chi= g(X)
chi= 3*trace X;
end
I want to solve this system for dA and dB
the problem for me is in the derivative part here
f'(A,B)*[dA dB]'= [g(dA))-dB A*dB+B*dA]'
can I said
[g(dA))-dB A*dB+B*dA]'= [g -eye(n-1);B A]*[dA dB]'
if not can I solve this system for dA and dB if i write it as
[g(dA)-dB A*dB+B*dA]'=[g(C)+B B*A-eye(n-1)]'
9 commentaires
Réponse acceptée
Torsten
le 19 Fév 2023
Should be faster than the symbolic solution.
rng("default")
n = 50;
A = rand(n-1);
B = rand(n-1);
C = rand(n-1);
x0 = zeros(2*(n-1)^2,1);
x = fsolve(@(x)fun(x,A,B,C,n),x0);
dA = reshape(x(1:(n-1)^2),[n-1,n-1])
dB = reshape(x((n-1)^2+1:2*(n-1)^2),[n-1,n-1])
[3*trace(dA)-dB A*dB+B*dA]'-[3*trace(C)+B B*A-eye(n-1)]'
function res = fun(x,A,B,C,n)
dA = reshape(x(1:(n-1)^2),[n-1,n-1]);
dB = reshape(x((n-1)^2+1:2*(n-1)^2),[n-1,n-1]);
res = [3*trace(dA)-dB A*dB+B*dA]' - [3*trace(C)+B B*A-eye(n-1)]';
res = res(:);
end
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!