In physics and astronomy, an N -body simulation is a simulation of a dynamical system of particles, usually under the influence of physical forces, such as gravity (see n -body problem for other applications). N -body simulations are widely used tools in astrophysics, from investigating the dynamics of few-body systems like the Earth - Moon - Sun system to understanding the evolution of the large-scale structure of the universe. In physical cosmology, N -body simulations are used to study processes of non-linear structure formation such as galaxy filaments and galaxy halos from the influence of dark matter. Direct N -body simulations are used to study the dynamical evolution of star clusters.