I'd like to say to everyone starting out doing math with computers: You see that old book of numerical recipes or physics problems done in Fortran? Yeah, those are pretty damn good recipes. Do you need some weird function, like a gamma function or hypergeometric function? Maybe you want to minimize a function with simulated annealing or you want to design a Chebyshev filter? You can dig up a library somewhere or you can just look in that dusty old book on the shelf.
There's a C version but the Fortran version is easier to find.
> The following license terms and the Disclaimer of Warranty, below, apply to individual purchases of the Numerical Recipes Code download product, and to purchases of the Numerical Recipes Code CD-ROM.
So all I have to do is simply pirate it and the restrictions don't apply to me?
> So all I have to do is simply pirate it and the restrictions don't apply to me?
The "restrictions" are limitations on permissions which do not exist without the license. So, sure, the restrictions don't apply to you, because you have been given no permissions with regard to the work, so there is no point in imposing conditions on those permissions.
Their code can be kind of buggy and often does not handle corner cases well, however. I've had some of their iterative solvers iterate forever when the initial iterate is the solution, etc.
It's a great reference book, and does a good job of citing the work that you actually want to use for your implementation. The code in the book itself (especially the C and C++ versions) should usually be taken with several large grains of salt.
I think porting code from one language over into another is one of the better ways to learn a new language. Especially older, lower-level code. I've probably learned more from rewriting an old school project ray tracer in three or four different languages, or grinding away at utilities to load up Quake and Wolfenstein 3D assets based on the ID code, than I have in my actual day job.
This reminds me of something that’s always struck me as odd about large-scale physics simulations: using invariant spacial coordinates when doing a gravitational simulation is totally absurd. Wouldn’t precision problems be much less of an issue if you distorted space according to gravitational influence, as happens in real life?
The 'resources' section of the post has 2 links, e.g. www.ma.utexas.edu/mp_arc/e/03-547.pdf goes through several rather clever transformations of (spatial and/or time) variables to improve accuracy.
I just took a class of dynamic systems and this post struck me.
Actually it is possible to model the planets using simple mathematical tools and find a space of solution to the problem (have planets that keep staying together) in an analytic or simil-analytic form.
All this can be done on paper, which is actually faster than code integrator but way less cool to watch...
The three body problem though is famous for having no solution in terms of basic functions. I think for your planets model you must have been making different assumptions than in the article.
In system dynamic you can divide a problem in simple (with a finite number of solution) and complex (with an infinite, fractal shaped, number of solution).
If the problem is "complicated" (a lot of strange, ugly, non analytic equation)but simple you can roughly cut the solution space by hand, assuming a small number of solution.
If the problem is complex all you can do is looking for cycle and equilibrium point using your intuition about the system or being lucky and find a strage attractor (chaotic behavior) slightly moving the parameter.
So, yes, I was to quick writing my reply, you can definitely model the n-body problem, exactly solve it is another beast, check a solution however is still relatively easy...
There is a vast literature on some simplifications: Circular Restricted Three Body (two bodies in a fixed orbit, third subject to their field) and even two fixed points (Euler Problem). Even here there are complex orbits.
There's a C version but the Fortran version is easier to find.