Computes the instantaneous potential and kinetic energies of all particles in an N-body system. Here, the potential energy of a particle i means the potential energy it has with all other particles (sum_j -G*m[i]*[j]/rij). Hence the total potential energy of the system is half the sum of the individual potential energies.
energy(m, x, v, rsmooth = 0, G = 6.67408e-11, cpp = TRUE)Returns a list with vector items Ekin, Epot, Emec=Ekin+Epot; and the associated total quantities Ekin.tot, Epot.tot, Emec=Ekin+Epot.tot.
N-vector with the masses of the N particles. Negative masses are treated as positive masses of same magnitude, since negative masses normally represent positive background masses in the nbody package.
N-by-3 matrix specifying the initial position in Cartesian coordinates
N-by-3 matrix specifying the initial velocities
top-hat smoothing radius.
gravitational constant. The default is the measured value in SI units.
logical flag. If TRUE (default), the computation is performed efficiently in C++.
Danail Obreschkow