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
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)).
 
There are two things I don't understand about this problem. First, when finding the nth root of a number, there should in theory be n solutions. However, the formula produces n+1 roots. Here is how. The first root is simply ##\left(r\right)^{\left(\frac{1}{n}\right)}##. Then you multiply this first root by n additional expressions given by the formula, as you go through k=0,1,...n-1. So you end up with n+1 roots, which cannot be correct. Let me illustrate what I mean. For this...
Back
Top