derivative of two matrices 2 by 2

If I have a matrix P of size 2 by 2 and a matrix F of size 2 by 2, how do I find the derivative of P with respect to F? Note that P and F are matrices are real numbers.
Is this code is mathmatically correct?
syms F1 F2 F3 F4; % Define symbolic variables for the elements of matrix F
F = [F1, F2; F3, F4]; % Define matrix F
syms p1 p2 p3 p4; % Define symbolic variables for the elements of matrix p
p = [p1, p2; p3, p4]; % Define matrix p
% Calculate the derivative of p with respect to F
dpdF = jacobian(p(:), F(:));
disp(dpdF)
The out put is
[0, 0, 0, 0]
[0, 0, 0, 0]
[0, 0, 0, 0]
[0, 0, 0, 0]

 Risposta accettata

Sam Chak
Sam Chak il 1 Mag 2024
Modificato: Sam Chak il 1 Mag 2024
If the four elements in Matrix P do not involve any variables defined in Matrix F, then taking the derivative of the four elements in P with respect to the four variables in F will result in a 4-by-4 array of zeros.
If that is not the case, then you maybe looking for this:
syms F1 F2 F3 F4; % Define symbolic variables for the elements of matrix F
F = [F1, F2;
F3, F4] % Define matrix F
F = 
p1 = 1*F1;
p2 = 2*F2;
p3 = 3*F3;
p4 = 4*F4;
p = [p1, p2;
p3, p4] % Define matrix p
p = 
% Calculate the derivative of p with respect to F
pt = transpose(p);
Ft = transpose(F);
dpdF= jacobian(pt(:), Ft(:))
dpdF = 

2 Commenti

Thank you Sam Chak , I really appricate your help it really complex for me as alot of variable involved. I need to calculate first Piola–Kirchhoff stress which is defined as derivative of strain energy density with respect to deformation gradient.
You're welcome, @Omar Aref. If there is no efficient way to express the elements in Matrix P, then you will need to input all the variables manually.

Accedi per commentare.

Più risposte (0)

Prodotti

Release

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by