The state of the mechanical system considering the classical approach is specified by a set of positions and momenta. This provides an accurate description of the physical state of multibody systems and the system in a fully deterministic way.
The dynamics of such a multibody system are thus typically described by using a coupled set of differential equations, such as Newton’s equations of motion, individual dynamics of each particle in the system.
However, we can apply the alternative approach to describing dynamics, and describe the dynamics by studying, selected particles moving in the presence of the other particles which we regard as a background, whose detailed dynamics are not treated.
In this case, we select a particle of interest and find an equation that describes the dynamics of a chosen particle in the presence of the other particles. The classical example of this is the Langevin equation developed in a heuristic way by Paul Langevin to describe the Brownian motion.
I solved the above differential equation in C++ by applying the Runge–Kutta methods. The source code is on my GitHub.
Below I plotted solutions of particle motion in 2D and 3D. Check how the mass of the particle influences the motion.
Plotting requires incorporating the header file which has to be in the same folder as your cpp (a file you can clone from my repository).
Your program can be compiled as follows.