applications, a general solution written in C++ could look like below. A simplified drag force is used to demonstrate change in acceleration, however it is only needed if acceleration is not constant.struct Body { Vec3d pos { 0.0, 0.0, 0.0 }; Vec3d vel { 2.0, 0.0, 0.0 }; // 2 m/s along x-axis Vec3d acc { 0.0, 0.0, 0.0 }; // no acceleration at first double mass = 1.0; // 1kg double drag = 0.1; // rho*C*Area – simplified drag for this example /** * Update pos and vel using "Velocity Verlet" integration * @param dt DeltaTime / time step [eg: 0.01] */ void update(double dt) { Vec3d new_pos = pos + vel*dt + acc*(dt*dt*0.5); Vec3d new_acc = apply_forces(); // only needed if acceleration is not constant Vec3d new_vel = vel + (acc+new_acc)*(dt*0.5); pos = new_pos; vel = new_vel; acc = new_acc; } Vec3d apply_forces() const { Vec3d grav_acc = Vec3d{0.0, 0.0, -9.81 }; // 9.81 m/s² down in the z-axis Vec3d drag_force = 0.5 * drag * (vel * vel); // D = 0.5 * (rho * C * Area * vel^2) Vec3d drag_acc = drag_force / mass; // a = F/m return grav_acc - drag_acc; } }; Error terms The global truncation error of the Verlet method is , both for position and velocity. This is in contrast with the fact that the local error in position is only as described above. The difference is due to the accumulation of the local truncation error over all of the iterations. The global error can be derived by noting the following: and Therefore Similarly: which can be generalized to (it can be shown by induction, but it is given here without proof): If we consider the global error in position between and , where , it is clear that and therefore, the global (cumulative) error over a constant interval of time is given by Because the velocity is determined in a non-cumulative way from the positions in the Verlet integrator, the global error in velocity is also . In molecular dynamics simulations, the global error is typically far more important than the local error, and the Verlet integrator is therefore known as a second-order integrator. Constraints Systems of multiple particles with constraints are simpler to solve with Verlet integration than with Euler methods. Constraints between points may be, for example, potentials constraining them to a specific distance or attractive forces.