# Homework Help: Numerical variational problem

1. Jul 15, 2014

### Catria

1. The problem statement, all variables and given/known data

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$

2. Relevant equations

The polar-coordinate Euler-Lagrange equation

3. The attempt at a solution

Code (Text):
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 (Text):
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...

2. Jul 15, 2014

### Ray Vickson

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)).$$