Gravity is the weakest of all fundamental forces in physics, far weaker than electromagnetism or the so-called weak and strong interactions between subatomic particles. However, the other three forces lose out in the competition with gravity over long distances. The weak and strong interactions both have an intrinsically short range. Electromagnetism, while being long-range like gravity, suffers from a cancellation of attraction and repulsion in bulk matter, since there tend to be as almost exactly as many positive as negative charges in any sizable piece of matter. In contrast, gravitational interactions between particles are always attractive. Therefore, the larger a piece of matter is, the more gravitational force it exerts on its surroundings.
This dominance of gravity at long distances makes the job of modeling a chunk of the Universe easier. To a first approximation, it is often a good idea to neglect the other forces, and to model the objects as if they were interacting only through gravity. In many cases, we can also neglect the intrinsic dimensions of the objects, treating each object as a point in space with a given mass. All this greatly simplifies the mathematical treatment of a system, by leaving out most of the physics and chemistry that would be needed in a more accurate treatment.
This book is the first in a series of books titled Pure Gravity, to indicate that we are making this approximation of treating objects as gravitating masses and nothing more. The objects we will be studying are stars, and the environment we will focus on are dense stellar systems, where the stars are so close together that they will occasional collide and in general have frequent interesting and complex interactions. In a later series, Applied Gravity, we will look at the internal physics of those stars: how they evolve under the influence of nuclear reactions in their centers, how they may die in cosmic explosions, and what happens to their remnant cores. We will especially study how interactions between stars of all types can change their evolutionary behavior through two-body, three-body, and more complex interactions, leading to an intricate `star cluster ecology'.
This first book, Writing an N-Body Code, lays the groundwork for modeling a system of stars. We start absolutely from scratch, with a most simple code of less than a page long. In many small steps we then improve that code, pointing out the many pitfalls along the way, on the level of programming as well as astrophysical understanding. We introduce helpful code development facilities and give many hints as to how to balance simplicity, efficiency, clarity, and modularity of the code. Our intention is to introduce the topic from square one, and then to work our way up to a robust set of codes with which one can do actual research. In later volumes in this series, we will continue to develop these codes, adding many useful diagnostic tools, and integrating those in a full production-level software environment.