solve system of matrices
2 次查看(过去 30 天)
显示 更早的评论
% 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 个评论
采纳的回答
Torsten
2023-2-19
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!