"Implement verlet algorithm for simple pendulum"

Nstep=5000;
g=9.81;k=1.0;l=1.0;m=1.0;Omega=Sqrt[g/l];
T=2.0*Pi/Omega;
tinit=0;tlast=10T;
Deltat=(tlast-tinit)/Nstep;

(*boundary condition*)
x0=1.0;vx0=0.0;
x[0]=x0;vx[0]=vx0;
(*end of boundary condition*)

Fx[i_]:=-k*x[i];
ax[i_]:=Fx[i]/m;

For[i=0,i≤Nstep-1,i++,
x[i+1]=x[i]+vx[i]*Deltat+0.5*ax[i]*Deltat^2;
vx[i+1]=vx[i]+0.5*(ax[i]+ax[i+1])*Deltat;
];(*end for i*)

ttx=Table[{i*Deltat,x[i]},{i,0,Nstep}];
lptttx=ListPlot[ttx,Joined->True,Mesh->All,PlotRange->All,PlotLabel->"x vs. t"];

ttvx=Table[{i*Deltat,vx[i]},{i,0,Nstep}];
lptttvx=ListPlot[ttvx,Joined->True,Mesh->All,PlotRange->All,PlotLabel->"vx vs. t"]

"Implement verlet algorithm for 2D projectile"

Nstep=100;
g=9.81;m=1.0;
(*boundary condition*)
theta0=45Degree;v0=0.25;
x0=0.0;vx0=v0*Cos[theta0];x[0]=x0;vx[0]=vx0;
y0=0.0;vy0=v0*Sin[theta0];y[0]=y0;vy[0]=vy0;
(*end of boundary condition*)

T=2.0*vy0/g;
tinit=0;tlast=T;
Deltat=(tlast-tinit)/Nstep;


Fx[i_]:=0;ax[i_]:=Fx[i]/m;
Fy[i_]:=-m*g;ay[i_]:=Fy[i]/m;

For[i=0,i≤Nstep-1,i++,
x[i+1]=x[i]+vx[i]*Deltat+0.5*ax[i]*Deltat^2;
vx[i+1]=vx[i]+0.5*(ax[i]+ax[i+1])*Deltat;

y[i+1]=y[i]+vy[i]*Deltat+0.5*ay[i]*Deltat^2;
vy[i+1]=vy[i]+0.5*(ay[i]+ay[i+1])*Deltat;
];(*end for i*)

txy=Table[{x[i],y[i]},{i,0,Nstep}];
lptxy=ListPlot[txy,Joined->True,Mesh->All,PlotRange->All,PlotLabel->"x vs. y"];

ttv=Table[{i*Deltat,Sqrt[vy[i]^2+vx[i]^2]},{i,0,Nstep}];
lptttv=ListPlot[ttv,Joined->True,Mesh->All,PlotRange->All,PlotLabel->"v vs. t"];
Print[lptxy];
Print[lptttv];

R=vx[0]*tlast;H=vy0/(2g);
Manipulate[
ttake=Take[txy,{1,i}];
ListPlot[ttake,PlotRange->{{0,R},{-H,H}},PlotLabel->"y vs x"<>";time ="<>ToString[i*Deltat]]
,{i,1,Nstep,1}]