# Least action principle — numerical simulation strangeness

I'm trying to get some experience with the least action principle, and for this I chose a simple 1-dimensional problem of a particle moving in some field. The least action principle would then look like:

$$\int_{t_1}^{t_2}(T(v)-U(x))dt=\min$$

So I discretize time into some points and try to minimize the sum:

$$\sum_{i=1}^n (T(v_i)-U(x_i))\Delta t.$$

But I get into some strange results: first, if I don't constrain the system, the sum appears unbounded from below. Well, it's understandable because there can be multiple solutions corresponding to different initial/boundary conditions. OK, I choose some values for $x_1$ and $x_n$ as constraints. But even the sum appears unbounded. Well, I then choose to reduce possible range of $x_i$, and the sum finally can be minimized...

But the result appears complete nonsense. Here's the result for $n=10$, $t_1=0$, $t_2=1$, $|x_i|<5$:

Positions

Velocities

Here velocities don't seem to reflect change in positions.

What am I missing here? Should I add some other constraints, or have I done some simple mistake?

• Presumably T(v) is the usual quadratic $\frac{1}{2}mv^2$, but what are you using for U(x)? Also, maybe you are trying to independently vary $v_i,x_i$ without the constraint $v = \frac{dx}{dt}$? Oct 31 '14 at 15:21
• @adipy I've tried setting $U=0$ first, then recognizing that it doesn't constraint $x_i$ at all, tried $U=1$, $U=x^2$, ..., but the results are basically the same. And indeed, I didn't put such a constraint as $v=\frac{dx}{dt}$, since I never saw any discussion of such constraint in the books (namely, Landau&Lifshitz "Mechanics"). I assumed $x$ and $v$ must vary independently. Oct 31 '14 at 15:33
• No, $x$ and $v$ are dependent in the action. For more details, see physics.stackexchange.com/q/885/2451 Oct 31 '14 at 15:42
• Hmm, thanks @Qmechanic, it seems my question is a duplicate of that one then. Oct 31 '14 at 15:50

As said in this answer, velocity and position are not varied independently. Indeed, when deriving Euler-Lagrange equations, we explicitly use the fact that $\delta v=\frac d{dt}\delta x$.
So, when I add the constraint $v_i=\frac{x_{i+1}-x_i}{\Delta t}$, specifying $x_1$ and $x_n$ remains the only additional thing to converge to the solution. For example, setting $U=x^4-4x^3+4.5x^2$, $x_1=0$, $x_n=2.651$ and $n=51$, I get:
Here the last point of velocity is wrong, but it's an artifact of the constraint: I've used a right-hand finite difference derivative, which can't be done for $v_n$. This can be fixed by choosing some other difference scheme, but for the purposes of this answer it's an unimportant implementation detail.
What's more important, is that if we choose $x_n>2.651$ in this example, the action appears unbounded from below even with the correct constraints. I believe this is no longer a problem in the implementation, but rather a result from the fact that the action just has to be stationary, but not minimal, so minimization is not a good enough procedure to obtain a true trajectory.