-1

Continuing the questions:

Lagrangian of three-mass system with Mathematica

Equations of motion for two-mass torsional oscillator with the gear train

Derivation of equations of motion for a multi-body system using Mathematica

A Lagrangian is given in which the kinetic energy is written as quadratic form:

$L=\frac{1}{2}\dot{\theta_1}^2+\frac{1}{2}\dot{\theta_2}^2+\frac{1}{2}\dot{\theta_3}^2+\frac{1}{2}\boldsymbol{\omega}^T I_2(\theta_1,\theta_2,\theta_3)\boldsymbol{\omega}+\frac{1}{2}\boldsymbol{\Omega}^T I_p(\theta_1,\theta_2,\theta_3)\boldsymbol{\Omega}+\frac{c_1(\theta_1-\boldsymbol{\omega})^2}{2}$

where $\omega,\Omega$ - vectors;

$I_2,I_p$ - matrix;

Generalized coordinates $\boldsymbol{q}=[\theta_1,\theta_2,\theta_3,\boldsymbol{\omega},\boldsymbol{\Omega}]$

$\frac{d}{dt}(\frac{dL}{d\dot{\boldsymbol{q}}})-\frac{dL}{d\boldsymbol{q}}=0$

How to get equations of motion from $L$ without writing out vectors and matrices component-wise, but assuming that we are dealing only with matrices and vectors?

(those. to actually work with vector and matrix differentiation in Mathematica).

I considered the issue in the previous topic, but I could not solve it correctly.

Quadratic form derivative in Mathematica

EDIT:

There is my Lagrangian in Mathematica:

L = 1/2 Subscript[\[Theta], 1]^2 + 1/2 Subscript[\[Theta], 2]^2 + 
  1/2 Subscript[\[Theta], 3]^2 + 
  1/2 Transpose[\[Omega]] I2[Subscript[\[Theta], 1]^2, 
    Subscript[\[Theta], 2]^2, Subscript[\[Theta], 3]^2] \[Omega] + 
  1/2 Transpose[\[CapitalOmega]] Ip[Subscript[\[Theta], 1]^2, 
    Subscript[\[Theta], 2]^2, 
    Subscript[\[Theta], 3]^2] \[CapitalOmega]

When I try to get $\frac{dL}{d\omega}$, i get this incorrect result. Mathematica can't work with Matrix Calculus ?

enter image description here

dtn
  • 2,394
  • 2
  • 8
  • 18
  • 6
    Please post your Lagrangian as copyable code and make it as easy as possible for others to help you. – Sjoerd Smit Jul 08 '21 at 09:48
  • @SjoerdSmit see my edit – dtn Jul 09 '21 at 12:45
  • 1
    dtn, what is the result that you are expecting to get? – CA Trevillian Jul 09 '21 at 13:02
  • @CATrevillian I want to get the equation of motion through this Lagrangian in symbolic form. But kinetic energy, represented as a quadratic form, doesn't let me do it correctly. As far as I understand, Mathematica does not work with Matrix Calculus. – dtn Jul 09 '21 at 13:05
  • @CATrevillian And the packages offered here. They do not differentiate or work incorrectly. Can't it work? https://mathematica.stackexchange.com/questions/250670/quadratic-form-derivative-in-mathematica/250674?noredirect=1#comment628240_250674 – dtn Jul 09 '21 at 13:06
  • 1
    dtn, it looks like some clarification was asked of you by those who have made effort to answer your question there, however, you have not yet provided that by way of editing your question with the clarifying information. That should be a good place to start by editing your previous question. I will say that I expect that you should need to tell Mathematica what exactly your variables are in the way of specifying them as matrices or otherwise. I’m not sure you need to indicate dimensions, but certainly to tell whether they are matrices or scalars or operators, etc. – CA Trevillian Jul 09 '21 at 13:27
  • @CATrevillian yes, the problem is the impossibility of differentiating the quadratic norm with respect to a vector in Mathematica. Are you suggesting to indicate that they are vectors, matrices, etc., how to do this? – dtn Jul 09 '21 at 15:37

1 Answers1

1

All the objects involved should be defined before used like

theta = {ctheta[1], ctheta[2], ctheta[3]};
omega = {comega[1], comega[2], comega[3]};
Omega = {cOmega[1], cOmega[2], cOmega[3]};
I2 = Table[i2[ctheta[1], ctheta[2], ctheta[3]][i, j], {i, 1, 3}, {j, 1, 3}];
Ip = Table[ip[ctheta[1], ctheta[2], ctheta[3]][i, j], {i, 1, 3}, {j, 1, 3}];

L = 1/2 theta.theta + 1/2 omega.I2.omega + 1/2 Omega.Ip.Omega Grad[L, omega]

Cesareo
  • 3,963
  • 7
  • 11
  • Thank you for your answer! I was hoping to get a similar result using Mathematica (without attracting extraneous packages ): https://ibb.co/8YhNWF2 – dtn Jul 09 '21 at 18:09
  • did I understand correctly that I should do something like this? and then look for the equation of motion through the components of the generalized coordinate (in the case of a vector)?

    \[Omega] = {{\[Omega]x}, {\[Omega]y}, {\[Omega]z}};

    Ip = {{Ixx, Ixy, Ixz}, {Ixy, Iyy, Iyz}, {Ixz, Iyz, Izz}};

    1/2 Transpose[\[Omega]].Ip. \[Omega];

    – dtn Jul 09 '21 at 18:13