Velocity Algorithm Code

Write the simplest possible one-dimensional "molecular dynamics code" for two particles. I used matlab, so i need matlab code for molecular dynamics or velocity verlet algorithm code. I need to determine x1, x2 and v1, v2 in different time steps.

I need the code. Also, I need graphs that show the motion of two particles, specifically, when x1=1.0 and x1=-1.0, and another graph when v1=0.0 and v2 =0.0. Also, graph when 0.5*(v1(t)^2) + 0.5*(v2(t)^2) and 0.5*(v1(t)^2) + 0.5*(v2(t)^2)+U(r).

Solution Preview

I worked it out. The code is here below, which you simply have to run. I am fairly certain you have to find r for each new time, since it is the distance between the two particles. So, in your equations for f, it should come out as r(t).so i have done this and U(r(t)).
Run the code and you'll have the graphs.