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?