I ask for advice, cause I'm a little confused.
We have such a Lagrangian:
$L=\frac{1}{2}m(\dot{x}^2+\dot{y}^2)-\lambda(x+xy+y-1)$
Here $\lambda(x+xy+y-1)$ is the constraint on the phase variables.
I need to derive the equation of motion given the constraints and solve them numerically with the help of NDSolve.
We do this in accordance with the classic formula:
$\frac{d}{dt}(\frac{dL}{d\dot{q}})-\frac{dL}{dq}=0$
Where $q=[x,y]$ are generalized coordinates. I'm not sure about the Lagrange multiplier as a generalized coordinate.
Clear["Derivative"]
ClearAll["Global`*"]
T = 1/2 m (x'[t]^2 + y'[t]^2);(*Kinetic Energy*)
f = \[Lambda] (x[t] + x[t] y[t] +y[t] - 1);(*Constraint*)
L = T - f;(*Lagrangian*)
D[D[L, x'[t]], t] - D[L, x[t]];
D[D[L, y'[t]], t] - D[L, y[t]];
D[D[L, \[Lambda]'[t]], t] - D[L, \[Lambda][t]];
Question: how are the Lagrange multipliers included in this system when compiling the ODE system and numerically solving it?
Maybe this help?
https://farside.ph.utexas.edu/teaching/336k/lectures/node90.html
https://www.sciencedirect.com/science/article/abs/pii/0045782588900850
This is a DAE system of index 2 or 3. You obtain an ODE system by adding derivatives of the equation, mainly the constraint, to the system. $$ x+xy+y=1,\\ \dot x(1+y)+\dot y(1+x)=0,\\ \ddot x(1+y)+\ddot y(1+x)+2\dot x\dot y=0 $$ From the last equation eliminate the second derivatives to get an equation for the Lagrange multiplier. With another derivative (thus index 3) you get an ODE for the multiplier. $$ m\ddot x=-λ(1+y)\\ m\ddot y=-λ(1+y)\\ \implies -λ[(1+x)^2+(1+y)^2]+2m\dot x\dot y=0\\ λ=\frac{2m\dot x\dot y}{(1+x)^2+(1+y)^2} $$