solve system of matrices
Mostra commenti meno recenti
% 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 Commenti
Torsten
il 17 Feb 2023
As far as I understand your question, you want - given A, B and C - determine dA and dB both matrices of size
(n-1) x (n-1) such that
[g(dA)-dB A*dB+B*dA]'=[g(C)+B B*A-eye(n-1)]'
where g is defined as
g(M) = 3*trace(M)
A,B are matrices of size (n-1) x (n-1) and C is a matrix of size n x n.
Is this correct ?
Hajar Alshaikh
il 17 Feb 2023
Torsten
il 17 Feb 2023
Then transform your matrix equation to the form
M*x = b
by using MATLAB's "equationsToMatrix" and solve for the unknown matrices dA and dB using
x = M\b.
Hajar Alshaikh
il 17 Feb 2023
Torsten
il 18 Feb 2023
The matrix equation you have is in reality a linear system of equations in the matrix entries of dA and dB.
"equationsToMatrix" transforms your matrix equation to this underlying linear system.
After getting the solution x of this linear system, you will have to reshape it back to get the matrices dA and dB.
Hajar Alshaikh
il 18 Feb 2023
So this is not what you want ?
rng("default")
n = 20;
A = rand(n-1);
B = rand(n-1);
C = rand(n-1);
dA = sym('dA',[n-1 n-1],'real');
dB = sym('dB',[n-1 n-1],'real');
eqn = [3*trace(dA)-dB A*dB+B*dA]'==[3*trace(C)+B B*A-eye(n-1)]';
eqn = eqn(:);
vars = [reshape(dA.',[(n-1)^2 1]);reshape(dB.',[(n-1)^2 1])];
[M,b] = equationsToMatrix(eqn,vars);
sol = double(M\b);
dA = reshape(sol(1:(n-1)^2),[n-1 n-1]).';
dB = reshape(sol((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)]'
Hajar Alshaikh
il 18 Feb 2023
Torsten
il 18 Feb 2023
My example worked - so I cannot tell you what went wrong with your code.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Mathematics in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!