This book discusses in detail all the relevant numerical methods for the classical N-body problem. It demonstrates how to develop clear and elegant algorithms for models of gravitational systems, and explains the fundamental mathematical tools needed to describe the dynamics of a large number of mutually attractive particles. Particular attention is given to the techniques needed to model astrophysical phenomena such as close encounters and the dynamics of black hole binaries. The author reviews relevant work in the field and covers applications to the problems of planetary formation and star cluster dynamics, both of Pleiades type and globular clusters. Self-contained and pedagogical, this book is suitable for graduate students and researchers in theoretical physics, astronomy and cosmology.