How to correctly differentiate quadratic form by vector in Mathematica, i.e.:
$Q=\omega^T I_{p} \omega$
$\frac{dQ}{d\omega}= ??? $
Clear["Derivative"];
ClearAll["Global`*"];
Q = Transpose[[CapitalOmega]].Ip.[CapitalOmega];
D[Q, [CapitalOmega]];
How to correctly differentiate quadratic form by vector in Mathematica, i.e.:
$Q=\omega^T I_{p} \omega$
$\frac{dQ}{d\omega}= ??? $
Clear["Derivative"];
ClearAll["Global`*"];
Q = Transpose[[CapitalOmega]].Ip.[CapitalOmega];
D[Q, [CapitalOmega]];
There is no concept of "transposed vector" in Mathematica.
To illustrate, let's give your variables concrete values:
Ip = {{Ixx, Ixy, Ixz}, {Ixy, Iyy, Iyz}, {Ixz, Iyz, Izz}};
ω = {ωx, ωy, ωz};
Your $Q$ is simply
Q = ω . Ip . ω // Expand
(* Ixx ωx^2 + 2 Ixy ωx ωy + Iyy ωy^2 + 2 Ixz ωx ωz + 2 Iyz ωy ωz + Izz ωz^2 *)
and its gradient with respect to $\omega$ is $\nabla_{\omega}Q=2I_p\cdot\omega$:
D[Q, {ω}] == 2 Ip . ω // Expand
(* True *)
MatrixD[Transpose[X].A.X, X] // TraditionalFormtry this code with package, it seems to me, or is it working with an error? – dtn Jul 13 '21 at 06:07