solve system of matrices
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hajar Alshaikh
am 17 Feb. 2023
Bearbeitet: Torsten
am 19 Feb. 2023
% 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 Kommentare
Akzeptierte Antwort
Torsten
am 19 Feb. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!