solve system of matrices
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hajar Alshaikh
el 17 de Feb. de 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 comentarios
Torsten
el 18 de Feb. de 2023
My example worked - so I cannot tell you what went wrong with your code.
Respuesta aceptada
Torsten
el 19 de Feb. de 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 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!