Moving Stars Around

This is a wiki import, and, eventually, update of Piet Hut's and Jun Makino's Moving Stars Around.

If you add or edit any pages below, at the top please include a link back to this page using the text:

Table of Contents

0. Preface

1. The Universe in a Computer 2. The Gravitational N-Body Problem 3. The Gravitational 2-Body Problem 4. A Gravitational 1-Body Problem 5. Writing the Code (Ruby) 6. Running the Code (Ruby) 7. Debugging the Code (Ruby) 8. Convergence for a Circular Orbit (Ruby) 9. Convergence for an Elliptic Orbit (Ruby) 10. The Modified Euler Algorithm (Ruby) 11. Arrays (Ruby) 12. Array Methods (Ruby) 13. Overloading the + Operator (Ruby) 14. A Vector Class with + and - (Ruby) 15. A Complete Vector Class (Ruby) 16. A Matter of Speed (Ruby) 17. Modified Euler in Vector Form (Ruby) 18. Leapfrog (Ruby) 19. Time Reversibility (Ruby) 20. Energy Conservation (Ruby) 21. Scaling of Energy Errors (Ruby) 22. Error Scaling for 2nd-Order Schemes (Ruby) 23. Error Behavior for 2nd-Order Schemes (Ruby) 24. Literature References
 * 1) Gravity
 * 2) Galactic Suburbia
 * 3) Globular Clusters
 * 4) Galactic Nuclei
 * 5) Star Forming Regions
 * 6) Open Clusters
 * 7) Writing your own star cluster simulator
 * 1) Background
 * 2) Our Setting
 * 3) Fun and Profit
 * 4) What is the Problem, and why N and Bodies?
 * 1) Absolute Coordinates
 * 2) Coordinate Systems
 * 3) A Fourth Point
 * 4) Center of Mass
 * 5) Relative Coordinates
 * 1) Coordinates
 * 2) Equivalent coordinates
 * 3) Closing the Circle
 * 4) Newton's Equations of Motion
 * 5) An Equivalent 1-Body Problem
 * 6) Wrapping Up
 * 1) Choosing a Computer Language
 * 2) Choosing an Algorithm
 * 3) Specifying Initial Conditions
 * 4) Looping in Ruby
 * 5) Interactive Ruby: irb
 * 6) Compiled vs. Interpreted vs. Interactive
 * 7) One Step at a Time
 * 8) Printing the Result
 * 1) A Surprise
 * 2) Too Much, Too Soon
 * 3) A Circular Orbit
 * 4) Radial Acceleration
 * 5) Virial Theorem
 * 6) Circular Motion
 * 7) One Step at a Time
 * 1) One Integration Step: Verification
 * 2) A Different Surprise
 * 3) One Integration Step: Validation
 * 4) More Integration Steps
 * 5) Even More Integration Steps
 * 6) Printing Plots
 * 1) Better Numbers
 * 2) Even Better Numbers
 * 3) An Even Better Orbit
 * 4) Reasons for Failure
 * 5) Signs of Hope
 * 1) Adding a Counter
 * 2) Sparse Output
 * 3) Better and Better
 * 4) A Print Method
 * 5) From One Body to Two Bodies
 * 1) A Wild Idea
 * 2) Backward and Forward
 * 3) On Shaky Ground
 * 4) Specifying the Steps
 * 5) Implementation
 * 6) Experimentation
 * 7) Simplification
 * 8) Second Order Scaling
 * 1) The DRY Principle
 * 2) Vector Notation
 * 3) Arrays
 * 4) Declaration
 * 5) Classes
 * 1) An Array Declaration
 * 2) Three Array Methods
 * 3) The Methods each and each_index
 * 4) The map Method
 * 5) Defining a Method
 * 6) The Array#inject Method
 * 7) Shorter and Shorter
 * 8) Enough
 * 1) A DRY Version of Modified Euler
 * 2) Not quite DRY yet
 * 3) Array Addition
 * 4) Who is Adding What
 * 5) The plus Method
 * 6) The + Method
 * 7) A Small Matter: the Role of the Period
 * 8) Testing the + Method
 * 9) A Vector Class
 * 1) Vector Subtraction
 * 2) Unary +
 * 3) Unary -
 * 4) An Unexpected Result
 * 5) Converting
 * 6) Augmenting the Array Class
 * 7) Fixing the Bug
 * 1) Vector Multiplication
 * 2) An Unnatural Asymmetry
 * 3) Vector Division
 * 4) The Score: Six to One
 * 5) A Solution
 * 6) Augmenting the Fixnum Class
 * 7) Augmenting the Float Class
 * 8) Vector Class Listing
 * 9) Forward Euler in Vector Form
 * 1) Slowdown by a Factor Two
 * 2) A C Version of Forward Euler
 * 3) A Simple Ruby Version
 * 4) A Ruby Array Version
 * 5) A Ruby Vector Version
 * 6) More Timing Precision
 * 7) Conclusion
 * 1) An Easy Translation
 * 2) Variable Names
 * 3) Consistency
 * 4) A Method Returning Multiple Values
 * 5) Simplification
 * 1) Interleaving Positions and Velocities
 * 2) Time Symmetry
 * 3) A Vector Implementation
 * 4) Saving Some Work
 * 5) The DRY Principle Once Again
 * 1) Long Time Behavior
 * 2) Discussing Time Symmetry
 * 3) Testing Time Symmetry
 * 4) Two Ways to Go Backward
 * 5) Testing a Lack of Time Symmetry
 * 1) Kinetic and Potential Energy
 * 2) Relative Coordinates
 * 3) Specific Energies
 * 4) Diagnostics
 * 5) Checking Energy
 * 6) Error Growth
 * 7) Pericenter Troubles
 * 1) A Matter of Time
 * 2) A New Control Structure
 * 3) Overshooting
 * 4) Knowing When To Stop
 * 5) Linear Scaling
 * 6) Picture Time
 * 1) Modified Euler
 * 2) Energy Error Scaling
 * 3) Leapfrog
 * 4) Another Error Scaling Exercise
 * 5) Roundoff Kicks In
 * 1) Modified Euler: Energy Error Peaks
 * 2) Almost Too Good
 * 3) Leapfrog: Peaks on Top of a Flat Valley
 * 4) Time Symmetry
 * 5) Surprisingly High Accuracy
 * 6) Squaring Off