The physics and equations of the two­ and three­body problem (Windows)

The physics and equations of the two‐ and three‐body
This section is optional and covers the physics and mathematical details of the two‐body problem and three‐body problem.

The two‐body problem
Consider two point masses, m1 and m2, moving within a plane ﴾that is, the 2‐dimensional case﴿. Let the position of m1 be denoted by ﴾x1, y1﴿ and m2 by ﴾x2,
y2﴿. Because the masses are moving with respect to time, their positional coordinates ﴾x, y﴿ are actually functions of time t, that is ﴾x﴾t﴿, y﴾t﴿﴿. Figure 1 shows
such a situation for a particular value of t ﴾a moment frozen in time﴿:

Figure 1
In figure 1, we see that m1 and m2 are a distance r apart and are mutually attracted to one another through the force of gravity F1 and F2 ﴾whose
magnitudes are the same﴿.
This force of gravity ﴾F﴿ is given by Newton's law of universal gravitation:

The force vector F1 acting on the first point mass m1 has the following x‐ and y‐components ﴾Fx and Fy, respectively﴿, as can be seen here:

Figure 2



we have: Now. shows that: If we focus on Fx and substitute for F and cos θ.85). the distance r between m1 and m2 is given by: Therefore ﴾for m1 in the x‐direction﴿. we see that: Where. the first from Newton’s second law and the second from Newton’s law of universal gravitation: By using the Pythagorean theorem ﴾see figure 2﴿. we have: Now given the initial positions ﴾x1.28.com/en­us/library/ie/dn528554(v=vs.aspx 2/5 . for now. y2﴿ at t = 0. y1﴿ and ﴾x2.microsoft. in the last expression.2015 The physics and equations of the two­ and three­body problem (Windows) Using trigonometry. we see that the acceleration equations are identical except for a change in sign ﴾indicating opposite force directions﴿ as provided by the swap in positional terms in the numerator: https://msdn. If. using the larger triangle. We now have two expressions for Fx. we can calculate the acceleration of m1 due to m2 in the x‐direction using equation 14. we see that: And.1. we drop the implied function of time variable t. Newton’s second law states: Where F﴾t﴿ and a﴾t﴿ are both vector functions of time. We can use the same reasoning as above to show that the y‐component of m1’s acceleration ﴾due to m2﴿ is given by: From m2’s perspective. we consider just the x‐direction of m1.

For the position Verlet algorithm. The three‐body problem When there are three masses.85). Using the previously calculated values. 4. where the numeric subscripts indicate the mass m1 or m2: Where: physically impossible﴿.com/en­us/library/ie/dn528554(v=vs. use equation 22 to calculate the 9.28. for a given directional component. xi is the position. This information leads to the following algorithm: 1. Using the values from the prior step. 8. Using the values from the prior step. Using the values from the prior step. Choose initial ﴾component‐wise﴿ position and velocity values for all masses. For example. and ai the acceleration of the ith mass.1. on first use. calculate the values using equation 23 7. equation 22 is replaced with the following: After first use. use equation 25 to calculate the initial 5. any one mass has two forces acting on it from the other two masses. values. calculate the values using equation 24. Go to step 5 until the user chooses to stop. Let i indicate one of the masses ﴾i = 1. Consider N celestial masses.2015 The physics and equations of the two­ and three­body problem (Windows) Thus. vi the velocity. 2. values. Using equations 18 through 21. 3.microsoft. calculate initial acceleration values. we have the following set of equations. the ith mass’s next position and velocity values are calculated as follows: Where. m1 has the following forces ﴾F2 and F3﴿ acting on it: https://msdn. we’ll use leapfrog integration ﴾the position Verlet algorithm﴿ in that it’s relatively simple but reasonably accurate and stable. …. values. In order to improve accuracy. Using the values from the prior step. an infinite acceleration is imparted when the two masses exactly collide. ﴾when α = 0. which is Now we have acceleration as a function of each mass’s current position but how do we approximate its velocity and position at some small amount of time h ﴾that is. In particular. N﴿ and h a small time interval. equation 25 is not used and equation 22 is used instead ﴾see Leapfrog Integration﴿. Choose a small value for h ﴾Δt﴿.aspx 3/5 . Δt﴿ later? This is where numerical integration comes in. use equations 18 through 21 to calculate the 6.

aspx 4/5 .microsoft.28. That is. the magnitude of the net force F1 on m1 can be broken into its x‐ and y‐components as follows: Using the red and green triangles in figure 3.2015 The physics and equations of the two­ and three­body problem (Windows) Figure 3 To start.com/en­us/library/ie/dn528554(v=vs.1. F2 and F3 can be expressed as: Substituting equation 28 through 33 into equations 26 and 27 results in: Simplifying 34 and 35 yields: Replacing r2 and r3 with their Pythagorean formulae yields the following x‐ and y‐component acceleration equation for m1: https://msdn. we see that: From Newton’s law of universal gravitation.85). F1 = m1a1 = F2 + F3 Now applying the same trigonometry used in figure 2 to figure 3. we note that the net force F1 acting on m1 is the sum of F2 and F3.

microsoft. a web worker can be utilized to perform the numeric integration in a thread separate from the main page UI thread. and velocity values for each body﴿ with reasonable accuracy and stability. Related topics The leapfrog method and other "symplectic" algorithms for integrating Newton’s laws of motion Leapfrog Integration Basic 3D graphics using Three.2015 The physics and equations of the two­ and three­body problem (Windows) Where α and β are as follows ﴾for r.aspx 5/5 . leapfrog integration ﴾equations 22 through 25﴿ can be used to numerically solve this system of equations ﴾42 through 47﴿ given a set of initial conditions ﴾mass. To allow for speedy high precision.com/en­us/library/ie/dn528554(v=vs.85).28. position.js The one‐body problem The two‐body problem The three‐body problem     © 2015 Microsoft https://msdn. see equation 13﴿: Applying the same procedure to m2 and m3 produces the following system of acceleration equations: Where: As was done in the two‐body problem.1.