(* Action: units are chosen so that the mass and the time interval of integration is assumed to be unity *)
Action[coord_] :=  KineticEnergy[coord]-PotentialEnergy[coord]
KineticEnergy[coord_] := Module[{howmany},
howmany = Length[coord];
Sum[(coord[[i]]-coord[[i-1]])^2,{i,2,howmany}](howmany-1)^2 /2]
PotentialEnergy[coord_] := 0 (* This defines a free particle *)

(* The change in each of the dynamical variables: the changes in the boundary values is always zero. *)
SuggestNew[width_,howmany_] := Flatten[{0,RandomReal[NormalDistribution[0,width],howmany-1],0}]

(* Initializations *)
howmany=32; (* You can change this to check what happens *)
Configuration=Table[Random[Real,2]-1,{i,howmany+1}]; 
Configuration[[1]] = 1/2; Configuration[[howmany+1]] = -1/2;
InitialConfiguration=Configuration;
OldConfiguration=Configuration;
action=Action[Configuration];

(* Minimization loop *)
width=1/512; (* You can change this to check what happens *)
Do[Suggestion=Configuration+SuggestNew[width,howmany];
suggestaction=Action[Suggestion];
change=suggestaction-action;
If [change < 0,
Configuration=Suggestion;
action=suggestaction],
{step,1000}]

x=Table[(i-1)/howmany,{i,howmany+1}];
Exact=1/2-x;
(* Don't worry about the details of this function *) ListPlot[{Transpose[{x,Exact}],Transpose[{x,OldConfiguration}],Transpose[{x,Configuration}]}, Joined -> True, PlotRange-> {{ 0,1},{-1,1}},PlotStyle ->{Black,Thick,Blue}]
OldConfiguration=Configuration;