One of the side projects I have going at home is a return to numerical modeling and astrophysics. What this really means is I’ve been writing code to solve n-body problems.
What’s the n-body problem?
The n-body problem is effectively a class of problems, which can be described (generically) as the problem of taking an initial set of data that gives the positions, masses, and velocities of some set of n bodies, for some particular point in time, and then using that set of data to determine the motions of the n bodies, and to find their positions at other times, in accordance with the laws of classical mechanics, i.e., Newton’s laws of motion and Newton’s law of gravity.
In other words, calculating how stars interact with each other based on the gravitational forces between them.
The n-body problem is interesting for a number of reasons. Firstly, there’s no general analytical solution for n > 2. Secondly, for large n it scales as O(n2) for most trivial implementations and O(n log n) for more complex tree based ones. Which means it uses a lot of CPU for realistic problems.
What’s really amazed me here is the huge amount of compute power that’s available on the desktop today for relatively small amounts of cash. A a thousand dollars or so buys an Intel i7 based machine capable of far more than the high end Transputer systems I used as part of my PhD. It’s now possible to model thousands of bodies on the machine which sits on my desk.
Some other pages on n-body modeling and NBody.net, an n-body implementation on the Microsoft platform:
- N-Body modeling with NBody.net – An interactive n-body model based written using mixed languages; C#, F#, C++/CLI, C++ and C/CUDA
- N-Body resources – Useful resources on the web, both the physics and computational science involved in writing an n-body model. Plus some links related to specific implementation details.