Negative sign produced by "functionalDerivative" - why?
Afficher commentaires plus anciens
I am asking this question to both get some understanding, but to also provide a possible workaround to a problem that I have seen posted before with no solutions.
I have written some code to determine the equations of motion for a somewhat simple system (in preparation for the analysis of a much more complex system) and have noticed some odd behavior when using the "functionalDerivative" command and am curious is anyone has ideas on why the behavior detailed below occurs.
Background:
The Lagrangian is given by:
The constraint equations are given by:
I have already developed the EOM's using the method of Lagrange multipliers, and would now like to develop them by simply substituting the constraint equations into the Lagrangian. Note however that
is a function of time, therefore f is a composite function:
Note that the generalized coordinate
is acted on by a non-conservative generalized force, which I account for on the rhs of the equation of motion (line 20).
Initial Attempts
My initial attempts utilized the "diff" command to try and determine the generalized forces and momenta, however I got the following error message for the generalized force for
:
"Error using symengine, First argument must not contain functionals"
This makes sense, as "diff" needs a symbolic variable, not a function. Since this failed, I decided to utilize the functionalDerivative command (which coincidently requires much less code and appears to be overall more efficient), as shown in the code below:
syms theta_c(t) theta_hc(t) z_h(t) I_eq I_h m_h k z_hi Q_c f(t)
%setting assumptions
assume(I_eq,'positive');
assume(I_h,'positive');
assume(m_h,'positive');
assume(z_hi,'positive');
assume(k,'positive');
%constraint equations
theta_h=theta_c+theta_hc;
g=compose(f,theta_hc);
%Lagrangian
L=0.5*I_eq*diff(theta_c,t)^2+0.5*I_h*diff(theta_h,t)^2+0.5*m_h*diff(z_h,t)^2-0.5*k*(z_hi+z_h)^2;
%substitution
L=subs(L,z_h,g); %note that theta_h substitution occurs automatically
%Equations of Motion
EOM_theta_c=functionalDerivative(L,theta_c) == Q_c;
EOM_theta_hc=functionalDerivative(L,theta_hc) == 0;
%isolating accelerations
theta_c_2dot=isolate(EOM_theta_c,diff(theta_c,t,t));
theta_hc_2dot=isolate(EOM_theta_hc,diff(theta_hc,t,t));
Question
The resulting equations of motion were given by MATLAB as:

When applying the Euler-Lagrange equation by hand the equation for
is correct, but the equation for
has an incorrect sign for
as it should be positive. Checking just the functional derivative gives:
test=functionalDerivative(L,theta_c)
test(t)=

I am confused as to why these terms have a negative sign, as according the standard form of the Euler-Lagrange equation these terms should have a positive sign. Now, in cases where the functional derivative is equal to zero (conservative systems) this negative sign has no bearing on the result as it can simply be divided out. However, as I have shown in my case (non-conservative) this negative sign does have a bearing on the result. Why is this negative sign added when the functional derivative is calculated?
Possible Fix
I have managed to mitigate this behavior by adjusting my code:
%Equations of Motion
EOM_theta_c=-functionalDerivative(L,theta_c) == Q_c;
EOM_theta_hc=-functionalDerivative(L,theta_hc) == 0;
My only worry when moving to a more complex system is if the behavior of the functionalDerivative command will be consistent as far as signs are considered.
Réponses (1)
As you can see here at the bottom of the page
functionalDerivative(S,theta_c) = deltaS/delta(theta_c) = dL/d(theta_c) - d/dx (dL/d(theta_c')) + higher order terms
Note the minus sign in front of the second term on the right-hand side.
Are you really sure that you want to determine the variational derivative ?
4 commentaires
Jacob Seifert
le 13 Mai 2024
So is your question answered ? In your case, the minus signs stem from the terms
- d/dx (dL/d(theta_c'))
- d/dx (dL/d(theta_hc'))
in the functional derivatives.
Hi Jacob,
According to my old notes, Lagrange's equation of motion is
where L = T - V.
The form of the LHS of Lagrange's equation is the negative of the variational (or functional) derivative of the integral of L as computed by functionalDerivative and as used on the LHS of Euler's equation that is solved for the extremum of a functional, at least in the limited literature I've seen.
David Goodmanson
le 14 Mai 2024
Hi Jacob, The Lagrange equations for any system always employ the negative of the functional derivative (assuming Qj on the right hand side is as shown by Paul and not multiplied by a negative sign). The simplest possible example verifies the sign of both terms on the left hand side since L = (m/2) (x')^2 -V(x) produces m x'' = -dV/dx + Q = total force.
Catégories
En savoir plus sur Stability Analysis dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!