How Do You Minimize a Lagrangian for a Given Trajectory Using Numerical Methods?

  • Thread starter Thread starter Catria
  • Start date Start date
  • Tags Tags
    Numerical
Click For Summary
SUMMARY

This discussion focuses on minimizing a Lagrangian defined by the integrand $L=\frac{1}{2}((\partial_tx)^2+(\partial_ty)^2)-V(x(t),y(t))$ for a trajectory $(x(t),y(t))$ between the points $(-1,-1)$ and $(-1,y_{eff})$. The potential function $V(x(t),y(t))$ is specified with parameters $\delta_1$, $\delta_2$, and $\gamma$, all set to 0.1. The user encounters a numerical issue while solving the equations using Mathematica's NDSolve, which indicates a stiff system, leading to unexpected behavior in the solution.

PREREQUISITES
  • Understanding of Lagrangian mechanics and variational principles
  • Familiarity with Mathematica version 12.0 or later for numerical solutions
  • Knowledge of Euler-Lagrange equations in polar coordinates
  • Experience with numerical methods for solving differential equations
NEXT STEPS
  • Explore the use of Mathematica's NDSolve options for stiff systems
  • Study the implementation of the Euler-Lagrange equations in numerical simulations
  • Learn about potential function modeling in variational calculus
  • Investigate alternative numerical methods for solving stiff ordinary differential equations (ODEs)
USEFUL FOR

Students and researchers in physics and applied mathematics, particularly those working on variational problems and numerical methods for differential equations.

Catria
Messages
145
Reaction score
4

Homework Statement



Here I am, trying to get the trajectory $(x(t),y(t))$ that will minimize the following Lagrangian (i.e. the integrand of the functional) between $(-1,-1)$ and $(-1,y_{eff})$ where $x_{eff}$ is defined as the point where $V(x_{eff},-1)=V(-1,-1),x<0$.

So here's the integrand of the functional:

$L=\frac{1}{2}((\partial_tx)^2+(\partial_ty)^2)-V(x(t),y(t))$

with $V(x(t),y(t))$ defined as follows:

$(x(t)^2-1)^2(x(t)^2-\delta_1)+\frac{(y(t)^2-1)^2-\frac{\delta_2}{4}(y(t)-2)(y(t)+1)^2}{x(t)^2+\gamma}$

and

$x(0.0001)=-1=y(0.0001)$

$x(10)=x_{eff},y(10)=-1$

Homework Equations



The polar-coordinate Euler-Lagrange equation

The Attempt at a Solution



Code:
Needs["VariationalMethods`"];
gamma = 0.1;
delta1 = 0.1;
delta2 = 0.1;
tmin = 0.0001;
tmax = 10;
V[x[t_], y[
    t_]] := (x[t]^2 - 1)^2 (x[t]^2 - 
      delta1) + ((y[t]^2 - 1)^2 - (delta2 (y[t] - 2) (y[t] + 1)^2)/
       4)/(x[t]^2 + gamma);
U[x_, y_] := (x^2 - 1)^2 (x^2 - delta1) + ((y^2 - 1)^2 - 
      delta2 (y - 2) (y + 1)^2/4)/(x^2 + gamma);
ftn = 2*Pi*
  t (1/2 (D[x[t], t]^2 + D[y[t], t]^2) + 
    V[x[t], y[t]]); (* Le Lagrangien *)
Veff[x_] := U[x, -1];
x0 = x /. FindRoot[Veff[x] == U[-1, -1], {x, -0.2}]
sln = EulerEquations[ftn, {x[t], y[t]}, t]
solution = 
  NDSolve[{sln, x[tmin] == -1, y[tmin] == -1, x[tmax] == x0, 
    y[tmax] == -1}, {x[t], y[t]}, {t, tmin, tmax}];
psi[t_] = x[t] /. solution[[1, 1]];
phi[t_] = y[t] /. solution[[1, 2]];
NIntegrate[
 t (1/2 (D[psi[t], t]^2 + 
       D[phi[t], t]^2) + ((psi[t]^2 - 1)^2 (psi[t]^2 - 
         delta1) + ((phi[t]^2 - 1)^2 - 
         delta2 (phi[t] - 2) (phi[t] + 1)^2/4)/(psi[t]^2 + 
         gamma))), {t, tmin, tmax}]
Plot[{psi[t], phi[t]}, {t, tmin, tmax}, PlotRange -> All]
ParametricPlot[{psi[t], phi[t]}, {t, tmin, tmax}, PlotRange -> All]

But, when I run that piece of Mathematica code, I run into an error message:

Code:
NDSolve::ndsz: At t == 0.004410099463404809`, step size is effectively zero; singularity or stiff system suspected.

Because of the stiffness of the system the numerical solution has a strange behavior...
 
Physics news on Phys.org
Catria said:

Homework Statement



Here I am, trying to get the trajectory $(x(t),y(t))$ that will minimize the following Lagrangian (i.e. the integrand of the functional) between $(-1,-1)$ and $(-1,y_{eff})$ where $x_{eff}$ is defined as the point where $V(x_{eff},-1)=V(-1,-1),x<0$.

So here's the integrand of the functional:

$L=\frac{1}{2}((\partial_tx)^2+(\partial_ty)^2)-V(x(t),y(t))$

with $V(x(t),y(t))$ defined as follows:

$(x(t)^2-1)^2(x(t)^2-\delta_1)+\frac{(y(t)^2-1)^2-\frac{\delta_2}{4}(y(t)-2)(y(t)+1)^2}{x(t)^2+\gamma}$

and

$x(0.0001)=-1=y(0.0001)$

$x(10)=x_{eff},y(10)=-1$

Homework Equations



The polar-coordinate Euler-Lagrange equation

The Attempt at a Solution



Code:
Needs["VariationalMethods`"];
gamma = 0.1;
delta1 = 0.1;
delta2 = 0.1;
tmin = 0.0001;
tmax = 10;
V[x[t_], y[
    t_]] := (x[t]^2 - 1)^2 (x[t]^2 - 
      delta1) + ((y[t]^2 - 1)^2 - (delta2 (y[t] - 2) (y[t] + 1)^2)/
       4)/(x[t]^2 + gamma);
U[x_, y_] := (x^2 - 1)^2 (x^2 - delta1) + ((y^2 - 1)^2 - 
      delta2 (y - 2) (y + 1)^2/4)/(x^2 + gamma);
ftn = 2*Pi*
  t (1/2 (D[x[t], t]^2 + D[y[t], t]^2) + 
    V[x[t], y[t]]); (* Le Lagrangien *)
Veff[x_] := U[x, -1];
x0 = x /. FindRoot[Veff[x] == U[-1, -1], {x, -0.2}]
sln = EulerEquations[ftn, {x[t], y[t]}, t]
solution = 
  NDSolve[{sln, x[tmin] == -1, y[tmin] == -1, x[tmax] == x0, 
    y[tmax] == -1}, {x[t], y[t]}, {t, tmin, tmax}];
psi[t_] = x[t] /. solution[[1, 1]];
phi[t_] = y[t] /. solution[[1, 2]];
NIntegrate[
 t (1/2 (D[psi[t], t]^2 + 
       D[phi[t], t]^2) + ((psi[t]^2 - 1)^2 (psi[t]^2 - 
         delta1) + ((phi[t]^2 - 1)^2 - 
         delta2 (phi[t] - 2) (phi[t] + 1)^2/4)/(psi[t]^2 + 
         gamma))), {t, tmin, tmax}]
Plot[{psi[t], phi[t]}, {t, tmin, tmax}, PlotRange -> All]
ParametricPlot[{psi[t], phi[t]}, {t, tmin, tmax}, PlotRange -> All]

But, when I run that piece of Mathematica code, I run into an error message:

Code:
NDSolve::ndsz: At t == 0.004410099463404809`, step size is effectively zero; singularity or stiff system suspected.

Because of the stiffness of the system the numerical solution has a strange behavior...

For inline equations, use either [i tex] xxxx [/i tex] (no spaces between i and t), or else # # xxx # # (no spaces betweent the two #s). For displayed equations, use [t ex] equations [/t ex] (no spaces between t and e). For example, ##V(x_{eff},-1)=V(-1,-1),x<0## and
L=\frac{1}{2}((\partial_tx)^2+(\partial_ty)^2)-V(x(t),y(t)).
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
Replies
9
Views
2K
Replies
5
Views
2K
  • · Replies 12 ·
Replies
12
Views
3K
Replies
2
Views
1K
  • · Replies 0 ·
Replies
0
Views
4K
  • · Replies 2 ·
Replies
2
Views
1K
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K