Thesis PDF
Thesis PDF
Thesis PDF
Joachim Worthington
Applied Mathematics
University of Sydney
October 2012
C ONTENTS
Chapter 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 2. Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1. History of the Three Body Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2. Particular Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3. Lagrangian and Hamiltonian Mechanics . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Chapter 3. Setting Up the Three Body Problem . . . . . . . . . . . . . . . . . . . . . . . 12
3.1. The Two Body Problem: exact solution . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2. The Three Body Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.3. Dynamics of the Three Body Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.4. The Poincaré Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.5. The Extended Phase Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Chapter 4. Regularisations and other Numerical Considerations . . . . . . . 24
4.1. Splitting Method for Hamiltonian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.2. Regularising Collision Orbits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.3. Local Regularisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.4. Global Regularisations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.5. The Thiele-Burrau Transformation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.6. Numerical Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.7. Calculating the Poincaré Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Chapter 5. Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.1. Program Design and Methodologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.2. Analysing Orbits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Chapter 6. Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Appendix A. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Appendix B. Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
iii
C HAPTER 1
Introduction
Since the 17th century, the N -body problem has held the attention of genera-
tions of astronomers and mathematicians. The problem is simple: given a collec-
tion of N celestial bodies (be they planets, asteroids, stars, black holes) interacting
with each other through gravitational forces, what will their trajectories be? For
N = 2, the problem has been solved for centuries; for N ≥ 3, the problem still has
no solution in any meaningful sense. As the theory and vocabulary of dynamics
have evolved, so too has the analysis of the problem, and indeed the study of the
problem has often directly led to the development of new concepts and ideas in
dynamics.
In this thesis, we consider the planar circular restricted three body problem, a
specific case of the N -body problem for N = 3. The primary goal is to develop
a fast, user-friendly program which can quickly and reliably calculate trajectories
from user input. The program will also calculate Poincaré maps, which will be
used to analyse the system for various parameter values. We then hope to verify the
existence of a particular bifurcation called the twistless bifurcation for orbits near
the Lagrangian points. The twistless bifurcation was found for a general system by
Dullin, Meiss and Sterling [12], and it is expected that the planar circular restricted
three body problem will exhibit the same behaviour.
We begin with a discussion of the history of the problem in Chapter 2, us-
ing Barrow-Green [5], Valtonen & Karttunen [10] and James [23] as our primary
sources. This background serves a dual purpose, neatly introducing many of the
theoretical concepts used to analyse the problem. We discuss several “particular
solutions” which illustrate useful ideas and dynamics, and give a summary of the
theory of Lagrangian and Hamiltonian mechanics.
In Chapter 3, the solution to the two body problem is presented, and the dy-
namics for the three body problem are derived. Following Koon, Lo, Marsden &
Ross [22], we take a Hamiltonian approach to the problem. Other physical consid-
erations such as the Hill region and Lagrangian points are introduced. Also defined
are the Poincaré map and extended phase space.
Chapter 4 deals with the biggest obstacle in any attempt to integrate trajec-
tories of the N -body problem, regularising collision orbits. Although an elegant
split-step integrator can be found for the problem, regularising transforms are still
required. The discussion of these transformations follows from Szebehely [16],
but are here derived in the context of Hamiltonian mechanics. The Levi-Civita,
Birkhoff and Thiele-Burrau transformations are discussed. An elegant numerical
method for calculating Poincaré maps designed by Henón [20] is also presented.
1
2 1. I NTRODUCTION
Chapter 5 gives a brief outline of the development and use of the completed
program, and a comparison of the observed bifurcations to those predicted by the
theory. Also included is a consideration of the Earth-Moon system, predicting the
behaviour of a possible Earth-Moon trojan.
C HAPTER 2
Background
The study and theory of the three body problem has developed over the last
four centuries concurrent to (and often catalysing) the general theory of dynamical
systems. It is therefore natural to explore the history of the problem, not only for
context and insight but to introduce key approaches and techniques to be utilised
in the project.
mass (see 3.2.1). When considered with a circular orbits for the two masses, this is
also known as the Euler three body problem. Euler also used variation of parame-
ters to study perturbations of the planetary motion.
At the same time as Euler, Joseph Lagrange made significant progress on the
general three body problem. Lagrange’s major contributions to theory included re-
ducing the problem from a system of differential equations of order 18 to a system
of order 7, and describing two types of particular solutions to the general problem
(see 2.2.2). Also of major importance, not just to the three body problem but to the
general theory of dynamic systems, was his development of Lagrangian Mechanics
(see 2.3).
Unaware of Lagrange’s work, Carl Jacobi reduced the general problem to a
sixth order system and the restricted problem to a fourth-order system. A constant
of motion was found, known as Jacobi’s integral, and is the only known conserved
quantity of the restricted problem. In 1878, George Hill demonstrated a very useful
application of Jacobi’s integral, describing the regions of possible motion for the
body of negligible mass (see 3.3.2).
Another contributor to the theory of the problem was Charles-Eugéne Delau-
nay. By taking repeated canonical transformations of the problem, requiring a truly
staggering number of calculations, Delaunay completely eliminated the secular
terms of the problem. Taking over two decades to complete, Delaunay’s methods
were published in 1846 but his final results could not be published until 1860 and
1867, when they were published in two large volumes of over nine hundred pages
each. A key useful result of the work was the introduction of Delaunay variables,
a set of canonical action angles which give the equations of motion in Hamiltonian
form. Although Delaunay’s method was impractical at the time (the expressions
involved were extremely complex and converged very slowly), the theory has been
highly influential, not only in lunar theory but in fields such as quantum theory as
well.
The end of the “classical” period of work on the three
body problem was marked by the extremely influential work
of Henri Poincaré. In the late nineteenth century, King Os-
car II of Sweden established a prize for solving the N -body
problem (a more general form of the problem with N rather
than 3 masses) on the advice of Gösta Mittag-Leffler, Karl
Weierstrass, and Charles Hermite. The statement of the
problem was as follows:
Although Poincaré did not solve the problem as stated, his paper was so pro-
gressive and important that he won the prize regardless. However, his initial sub-
mission contained a fatal mathematical error, which led to a fallacious stability
result for the N = 3. After having all copies of the original paper destroyed (at a
high personal cost), he published an updated paper which rectified the mistake. In
doing so, he raised several influential ideas which would lead to the development
of the theory of mathematical chaos, and changed core ideas of the mathematical
study of dynamics. He also introduced the concept of a first return map, now also
known as a Poincaré map (see 3.4). For more on Poincaré’s work on the three body
problem, see Barrow-Green [5].
In fact, the problem as it had originally been stated would not be solved until
1912 by Sundman for N = 3. The general case would remain unsolved until
1991, when Qiudong Wang published The Global Solution of N -body Problem
[8]. However, in both cases, the series constructed converged so slowly that they
were essentially useless in practice. Though his work met the requirements of King
Oscar’s problem, Wang himself would characterise his result as “a tricky, simple
and useless answer” while praising the publications that Poincaré did complete
(see [7]).
After much of the foundations were laid by Poincaré, the twentieth century
saw progress on many different fronts. Simplified versions of the restricted three
body problem were analysed. For example, the Copenhagen problem assumes the
two masses to be equal, and were considered by Strömgren and colleagues from
1913 in detail.
Another approach to the problem in last century was the development of statis-
tical analysis of the orbits. Poincaré had demonstrated the system is chaotic, which
opens the possibility of systematically analysing orbits based on statistical distri-
butions. In most occurences, the general three body problem results in one mass
leaving the two other bodies permanently, and the other two forming a binary sys-
tem. This is known as an escape orbit. Valtonen and Karttunen (see [10]) applied
statistical methods to analyse the scattering of these escape orbits. These results
were directly compared to experimental values, which could be carried out thanks
to the proliferation of powerful computers at the end of the twentieth century.
An altogether different approach to classify the possible motions was Hénon’s
analysis of the restricted three body problem. By perturbing the mass of one of the
bodies near µ = 0 (an idea explored already by Poincaré), Hénon considered fam-
ilies of orbits. This research led to his fascinating books of “generating families”
[2] [3].
2.2.1. Euler’s Solution. The earliest and simplest particular solution was dis-
covered by Euler in 1765. In Euler’s solution, the three masses are collinear, po-
sitioned according to their masses. Then at every future time, the masses remain
6 2. BACKGROUND
m3
m3
m1 m2
m2
m1
Figure 2.1. The Euler solution: the three bodies remain collinear at all
times, in elliptical orbits around the centre of mass. Left: all masses
equal. Right: unequal masses.
collinear, and the distances between them remain at the same ratio. In the particular
case of the three bodies having equal masses, this corresponds to a situation where
two of the bodies rotate in a circle around the third. For unequal masses, each mass
will travel in an elliptical orbit around the centre of mass. See Figure 2.1 for an
illustration of these behaviours.
Although this solution is interesting, and deeply connected to the theory we
will develop, such orbits are unstable. The smallest of perturbations will destroy
the symmetry, so such a situation will never be realised in a physical system.
m1 m3
m3
m2
m1 m2
Figure 2.2. The Lagrange solution: the three bodies form an equilateral
triangle at all times. Left: three equal masses. Right: unequal masses
be stable, although only under certain conditions. If one of the masses completely
dominates the system, then the orbits become stable. In fact, such orbits explain
the existence of Trojans. Trojans are satellites (often asteroids) that orbit at spe-
cific locations relative to two larger masses. In the restricted case, both Euler and
Lagrange’s solutions reduce to a description of the Lagrangian points where these
trojans are found. These Lagrangian points are discussed in Section 3.3.1.
2.2.3. The Figure-Eight Solution. Long after Euler and Lagrange’s solu-
tions, another particular solution was found: the figure-eight solution. First discov-
ered numerically by Cristopher Moore in 1993, its existence was rigorously proved
in 2001 by Alain Chenciner and Richard Montgomery [11]. Unlike the other par-
ticular solutions it only occurs in the case of three equal masses, but remarkably
is stable. In the figure eight solution, all three bodies trace the same figure-eight
shaped orbit, with the double point at the centre also being the centre of mass. This
is illustrated in Figure 2.3.
m3
m1
m2
Figure 2.3. The figure-eight solution. The three equal masses chase
each other in a figure-eight formation.
Although the solution is not as useful in analysing the problem as Euler or La-
grange’s, it is notable for being discovered so recently. Its discovery led to what
have been termed N -body choreographies, periodic solutions to the N -body prob-
lem where all bodies trace out the same path in space. These choreographies were
studied by Carlés Simó who found many highly unlikely but extremely interesting
orbits. The ongoing research into these kinds of orbits has led to some interesting
considerations into the general N -body problem when Einstein’s theory of Gen-
eral Relativity is taken into account. For more on these orbits, and some extremely
interesting examples, see [13].
2.2.4. Hill’s Solutions. Of much more practical importance are what are termed
“Hill’s solutions”1 to the problem, also known as tight binaries. These solutions
are very familiar, corresponding to the dynamics of the Sun-Earth-Moon system.
In Hill’s solution, two of the masses will remain close to each other and form a bi-
nary which will orbit the third body which remains further away. This is illustrated
in Figure 2.4.
The kinds of orbits described by Hill are the most commonly occuring “nice”
orbits, and examples can be found for any sufficiently low energy. These orbits
will show up clearly in the model developed in this project.
1Despite the name, these do not necessarily occur as explicit solutions like Euler and Lagrange’s
solutions do.
8 2. BACKGROUND
m1=3
m3=5 m2=4
theorised by Ernst Meissel that such a configuration would lead to periodic orbits.
By the 1960s, computers were sufficiently advanced to numerically integrate the
problem (as we shall in this paper) and it was demonstrated that the orbits were
not periodic, nor particularly unique. However, they did demonstrate a very typical
behaviour of the system: one of the three masses drifts away from the others, leav-
ing a stable binary system behind (Figure 2.5). This is common for our restricted
problem, and for high energies is the norm rather than an exception. Such orbits
are known as escape orbits.
Thus the quantity E = ni=1 q̇i ∂L∂ q̇i − L is constant, and is called the energy.
P
10 2. BACKGROUND
3These generating functions can depend on time; for this project, we will not need this detail,
so it is omitted.
2.3. L AGRANGIAN AND H AMILTONIAN M ECHANICS 11
F2 (qi , Pi ) pi = ∂F
∂qi
2
Qi = ∂F2
∂Pi
F3 (pi , Qi ) qi = − ∂F
∂pi
3 ∂F3
Pi = − ∂Q i
F4 (pi , Pi ) qi = − ∂F
∂pi
4 ∂F4
Qi = ∂Pi
C HAPTER 3
12
3.2. T HE T HREE B ODY P ROBLEM 13
particle will not affect the orbits of the heavier bodies, which we call the primary
masses or just primaries. This simplified system is referred to as the restricted
three body problem.
The next simplification is to fix the orbits of the primaries. As they are only
affected by each other and not the particle, the primaries are a two body system,
which we solved exactly above. Although we discovered that the two body problem
is solved by any conic section, we take a circular orbit for our simplified model.
This is the circular restricted three body problem. As noted previously, this form
of the problem was proposed by Euler.
Our final simplification is to restrict the motion of the particle to the same plane
as the orbit of of the primaries. The orbits thus occur on a two-dimensional plane.
This is the planar circular restricted three body problem, which will be referred to
as the PCR3BP in this paper.
Figure 3.1. The simplifications we take to the three body problem. Top
left: the general three body problem. Top right: the restricted three body
problem. Bottom left: the circular restricted three body problem. Bottom
right: the planar circular restricted three body problem.
(3.5) (X1 , Y1 ) = (−µ cos t, −µ sin t) (X2 , Y2 ) = ((1−µ) cos t, (1−µ) sin t)
Y y
M2
-1+μ -μ 0 +μ 1-μ -μ 0 1-μ
X x
M1 M1 M2
X = x cos t − y sin t
(3.8)
Y = x sin t + y cos t.
The corresponding velocities transform as
1 1−µ µ
(3.11) Lrotating (x, y, ẋ, ẏ) = ((ẋ − y)2 + (ẏ + x)2 ) + + .
2 r1 r2
Now, the Hamiltonian formulation is derived from the Lagrangian formulation.
The conjugate momenta are
∂L ∂L
(3.12) px = = ẋ − y py = = ẏ + x
∂ ẋ ∂ ẏ
and the Legendre transform defined by
(3.13) H = ẋpx + ẏpy − L
gives the corresponding Hamiltonian
(3.14)
µ 1−µ
H (x, y, px , py ) = 1 2 1 2
2 px + px y + 2 py − py x − r1 − r2
1 2 1 2 1 2 1 2 1−µ µ
= 2 (px + y) + 2 (py − x) − 2 x − 2 y − r1 − r2 .
1 1−µ µ
U (x, y) = − (x2 + y 2 ) − −
2 r1 r2
1 1−µ µ
= − {(1 − µ)r12 + µr22 } − −
2 r1 r2
3
We have ignored some constant terms. This is allowed with Hamiltonians as Hamilton’s equa-
tions will remain unchanged, allowing us to add or remove constant terms as we wish.
3.2. T HE T HREE B ODY P ROBLEM 17
∂H
(3.18) ẏ =
∂py
= Tpy
∂H
(3.19) p˙x = −
∂x
= −Tx − Ux
∂r1 ∂r2
= −Tx − Ur1 − Ur2
∂x ∂x
∂H
(3.20) p˙y =
∂y
= −Ty − Uy
∂r1 ∂r2
= −Ty − Ur1 − Ur2 .
∂y ∂y
It is often useful to recontextualise the Hamiltonian in complex space. If
z = x + iy and pz = px − ipy 5 then
1 1 1−µ µ
(3.21) H = |z + ip̄z | − {(1 − µ)r12 + µr22 } − −
2 2 r1 r2
1 1−µ µ
= (pz p̄z + i(zp¯ z − zpz )) − −
2 r1 r2
(3.22) r1 = |z + µ| r2 = |z − (1 − µ)|.
4It should be emphasised that this value is not the kinetic energy of the particle; this particular
splitting is made for mathematical convenience rather than physical reasons.
5Strictly speaking, this transformation is not canonical. The Poisson bracket
(an object which can be used to test if a given transformation is canonical) is
{z, pz } = {x + iy, px − ipy } = {x, px } + {y, py } = 2 rather than 1. If we scale the
√ √
variables as z = 1/ 2(x + iy), pz = 1/ 2(px − ipy ), then the transformation is canonical. In
practice, we can safely ignore this point, particularly as the equations will be converted back into
separate coordinates at the final step.
18 3. S ETTING U P THE T HREE B ODY P ROBLEM
(-μ,0) (1-μ,0)
Figure 3.4. The five fixed points for the particle, or Lagrangians, marked in red.
If y = 0, then r1 = |x + µ| and r2 = |x − 1 + µ| so
1 1
(3.26) 0 = −x + (x + µ)(1 − µ) 3
+ µ(x + µ − 1) .
|x + µ| |x + µ − 1|3
This has one solution in each of the ranges (−∞, −µ), (−µ, 1−µ) and (1−µ, ∞).
These solutions can be calculated numerically as they are the roots of polynomials.
It is important to consider the stability of these Lagrangian points as well. L1 ,
L2 and L3 are always unstable. L4 and L5 are stable only p for certain values of the
mass ratio; specifically, only when M1/M2 > 25 2 (1 + 1 − 4/625) ≈ 24.96. For
−1
our system, this becomes µ < 25
p
2 (1 + 1 − 4/625) + 1 ≈ 0.0385 (these
figures are derived in [6]).
3.4. T HE P OINCARÉ M AP 19
Figure 3.5. The five possible shapes for Hill’s region. The five figures
show Hill regions for decreasing values of the energy E from top to
bottom. The white area is the region of possible motion, or Hill’s region,
and the grey area is the so-called “forbidden region". Also shown are
the Lagrangian points, which coincide with the critical points of Hill’s
region. Compare these regions to the potential function in Figure 3.3.
Also compare the critical points with the Lagrangian points in Figure
3.4.
3.4. T HE P OINCARÉ M AP 21
x
P(x) S
Figure 3.6. A Poincaré Map P . The map takes points on the surface S
to the next point where the orbit intersects the surface.
is a Poincaré map (or first return map) if for every point x ∈ S, ∃τ ≥ 0 such that
Φτ (x) ∈ S and Φt (x) ∈ / S ∀ 0 ≤ t < τ and P (x) = Φτ (x). S is called the
Poincaré section.
For our Poincaré maps, we will also take only the intersecting points that have
the same orientation. These ideas are illustrated in Figure 3.6.
Having defined this map, we can now characterise orbits based on the Poincaré
map’s action on the initial condition. For a periodic orbit, there exists some n ∈ N
such that
(3.32) P n (x) = x.
For a periodic orbit, this set will be finite. As we will see, the nature of this set can
be used to classify particular classes of orbits.
For a fixed energy, our system is restricted to the three dimensional energy
manifold in equation (3.27). We should thus take a two dimensional section S ⊂ M .
In general for a Hamiltonian with n spatial dimensions, we can take an n − 2 di-
mensional section.
For this project, we will initially consider the section defined by
This section is quite simple. The corresponding map calculates the next in-
tersection of the particle with the x-axis, with a positive y-momentum. We can
project the section into x − px space, which allows us to visually acquire a lot of
information about the dynamics of the system.
22 3. S ETTING U P THE T HREE B ODY P ROBLEM
When the user makes a selection in the x − px space, this uniquely defines an
initial condition. The fixed parameters E and µ are used to calculate py . Rearrang-
ing equation (3.14),
1 2 1 1−µ µ
(3.35) py − xpy + −E + p2x + ypx − − = 0.
2 2 r1 r2
As E, µ, x and px have been chosen by the user, and y has been defined by the
section, the quadratic in py can be solved to give the complete initial condition,
with the choice of root determined by the condition py > 0.
A second useful section for this problem is
S2 (E; µ) = {(x, y,px , py )|(x, y, px , py ) ∈ M (E; µ);
(3.36) √
y = 3(x + µ); pperp ≥ 0}.
This section is a line passing through the primary at (−µ, 0) and L4 . We define
pperp as the momentum in the direction perpendicular to this line
1 √
(3.37) pperp = (px − py 3)
2
and the momentum parallel to this line as
1 √
(3.38) pnorm = (px 3 + py ).
2
We can then project the section down to x − pnorm space as we did for the
previous section. The reason we study this section and the associated map is that it
allows us to see the dynamics of orbits around L4 , which will not show up on S2 .
As before equation (3.35) is used to determine the full initial condition (although
it must be rewritten in terms of pperp and pnorm ).
One note here is that for the above sections, P (x) is not necessarily well-
defined for all x ∈ S. In particular for S2 , the corresponding map P2 is undefined
for any particle that will subsequently orbit about the primary at M2 . There is no
reason why P should be well defined everywhere for an arbitrarily constructed S.
However, in practice this becomes irrelevant. The maps allow us to see partic-
ular orbits we are interested in, and ignore the orbits for which P (x) is undefined.
S1 is used to analyse orbits around either or both of the two primaries, while S2 is
used to analyse behaviour near L4 . If other behaviours need to be considered, new
sections can be defined.
7This theory is usually derived for a time-dependent Hamiltonian, but is simplified here for
clarity.
C HAPTER 4
Having derived the necessary equations of motion, the next step is to develop
a robust integrator for these equations. This requires a discussion of some key
concerns of the problem, most notably the regularisation of collision orbits. This
chapter will also discuss some candidates for the integrator and other relevant nu-
merical concerns.
0 1 1 0
−1 0
0 1
(4.4) ẋ =
x = Ax.
−1 0 0 1
0 −1 −1 0
We can explicitly calculate etA , giving the exact solution
x(t) =A1 sin 2t + A2 cos 2t + C1
y(t) =A1 cos 2t − A2 sin 2t + C2
px (t) =A1 cos 2t − A2 sin 2t − C2
py (t) = − A1 sin 2t − A2 cos 2t + C1
where
1 1
A1 = (y(0) + px (0)) A2 = (x(0) − py (0))
2 2
1 1
C1 = (x(0) − py (0)) C2 = (y(0) − px (0)).
2 2
We can also calculate an explicit flow for the Hamiltonian given by U . The
differential equations are
(4.5) ẋ = 0 ẏ = 0 p˙x = −Ux p˙y = −Uy .
As U depends only on x and y, the flow is (left in terms of partial derivatives
for brevity)
x(t) =x(0) y(t) =y(0)
px (t) = − Ux (x(0), y(0))t + px (0) py (t) = − Uy (x(0), y(0))t + py (0).
Having calculated φTt and φU t explicitly, the value of the splitting method is
clear. We can substitute these into (4.2) to get
(4.6) φH U T U
t ∼ φt/2 ◦ φt ◦ φt/2 .
This integrator is accurate to second order. For our problem, this is more than
adequate for many orbits. However, U and Ux,y have singularities at r1 , r2 = 0.
As the orbits approach these points, the integrator becomes increasingly and fatally
unstable. To be able to consistently and accurately integrate around these points,
we must deal with these singularities.
1It should be noted that our derivation assume a point mass for both the primaries and the par-
ticle.. However, the difference in scale between the distance between planets and their diameters, as
well the relative symmetry of the bodies, means that point masses are a very practical approximation.
Relatively few changes need to be made to the model to allow for trajectories which actually begin
and/or end on the surface of a planet.
2Recall that p = p + ip is not a canonical transformation.
z x y
4.3. L OCAL R EGULARISATION 27
1.5
0.5
Im(q)
0
−0.5
−1
−1.5
−2
−5 0 5
Re(q)
Collision Orbits in w−space after local transformation at q=−0.5
2.5
1.5
0.5
Im(w)
−0.5
−1
−1.5
−2
−2.5
0 0.5 1 1.5 2 2.5
Re(w)
Collision Orbits in w−space after Thiele−Barrau transformation
3
1
Im(w)
−1
−2
−3
0 0.5 1 1.5 2 2.5 3 3.5
Re(w)
This, along with the same transformation of the kinetic energy T , define a new
Hamiltonian H1 (w, pw ). The details are omitted here for brevity.
Similarly, for regularisation about the primary at (1 − µ, 0), the transformation
is
p
(4.16) w = z − 1 + µ pw = 2wpz
and the effective potential becomes
1 1−µ µ
(4.17) U (w) = − {(1 − µ)|w2 + 1|2 + µ|w|4 } − 2 − .
2 |w + 1| |w|2
4.3.1. Time Transformations. The next step is to take the time transforma-
tion. As we have established the structure of the extended phase space in 3.5 and
calculated the form of the time transformation, most of the work is already done.
We first define our extended phase space Hamiltonian
(4.18) Ĥ1 (w, t, pw , E) = H1 (w, pw ) − E
(the energy E is invariant under our transformations) and then take the time trans-
formation given by Equation (4.11)
(4.19) H̄1 (w, t, pw , E) = |f 0 (w)|2 Ĥ1 (w, t, pw , E)
= 4|w|2 Ĥ1 (w, t, pw , E).
The |w|2 cancels with the singularity in the potential at w = 0. Analogously,
we can derive a Hamiltonian H̄2 (w, t, pw , E) for orbits passing near the other pri-
mary.
The integration process is now
Algorithm 4.20 (Local Transformation Integrator). For some fixed θ < 12 ,
1. If r1 < θ, take a (Euler, Runge-Kutta, etc) dt integration step in φH̄
t
1
(the flow
induced by H̄1 )
2. Else, if r2 < θ, take a dt step in φH̄
t
2
H
3. Else, take a dt step in φt
4. Repeat
Such an integrator works, but is inelegant. The natural question is can we
develop a transformation that regularises both singularities at once? In the next
section we will see two examples of exactly that: the Birkhoff transformation and
the Thiele-Burrau transformation
(1 − µ)|w| µ|w|
(4.26) = +
|αw + β + 2 w| |αw + β − 12 w|
2 1 2
1
(4.41) H (q, pq ) = (pq pq + i(qpq − qpq + (1/2 − µ)(pq − pq )))
2
1−µ µ
− −
|q + /2| |q − 1/2|
1
Many other Runge-Kutta schemes exist for higher orders and other choices of
coefficients in ki . We will see in the next chapter that this scheme is more than
accurate enough for our purposes.
and
n
X ∂D
(4.62) fn+1 (x) = fi (x) .
∂xi
i=1
Then the section is defined by xn+1 = 0, and we can follow the procedure de-
scribed above.
Although this method is accurate to the same level as our integration method
and theoretically does not require much analytical work, it does require the intro-
duction of a lot of new structure in the program to be developed in the next chapter.
A much simpler algorithm is used
Algorithm 4.63 (Simple Method for Calculating Poincare Maps). Given the sys-
tem in (4.57) and the associated section,
1. Take an initial condition x0 ∈ S
2. Propogate (4.57), calculating D, the signed distance to the section, at each
point
3. Stop when D changes sign
4. Extrapolate P (x0 ) from the current point, the previous point and their distances
from the section
Although this method is less accurate and far less defensible, our integrator
will take sufficiently small steps that we can calculate these points to a sufficiently
high accuracy.
C HAPTER 5
Results
Select µ
and E
parameters
Select
Poincaré
section
Select User
initial Interrupt
condition
Calculate
the initial
momentum
Intersected Integrate
P-section the orbit
Update
Orbit
Update window
P-section
window
Figure 5.1. Control flow diagram for the program. The user makes se-
lections for the parameters and initial condition using either the point-
and-click interface or by direct entry at the command line. Equation
(3.35) or similar is used to calculate the full initial condition. The pro-
gram then integrates the orbits and calculates the corresponding Poincaré
map until it is interrupted by the user.
the console (not shown), as well as switch Poincaré section type, change
the orbit colour, and other options.
• The parameter window. This window is used to select the values of the
E and µ parameters, with horizontal position determining µ and vertical
position determining E.
• The Poincaré section window. Clicking in this window allows the user
to select an initial condition for an orbit, which will immediately begin
integration. Also, whenever an orbit passes through the section, the point is
drawn on the section, visually showing the Poincaré map defined in Section
3.4. The grey regions delineate the Hill region, and the grey lines mark the
positions of the primaries.
• The z-space orbit window, which shows the motion of the particle in z
coordinates. One orbit is shown at a time, and will automatically be dis-
played as the trajectory is calculated. Also marked are the locations of the
primaries, the centre of mass, and the five Lagrangians. The Hill region
is delineated with a grey regions. A light grey line shows the currently
selection Poincaré section. This window can be hidden to improve perfor-
mance.
• The w-space orbit window, which shows the motion of the particle under
the Thiele-Burrau coordinates. This is mostly provided for reference and
testing. Again, it can be hidden to improve performance.
5.2.2. The Vanishing Twist. As noted in the introduction, a goal of this project
is to demonstrate a particular bifurcation in the system called the vanishing twist.
This follows from the theory developed in Generic twistless bifurcations by Dullin,
Meiss and Sterling [12].
In the paper, Dullin et al. proved that in the neighbourhood of the tripling bifur-
cation of a fixed point of an area-preserving map, there is what they call a twistless
5.2. A NALYSING O RBITS 39
bifurcation. We can access this idea for our system by defining the rotation number
of our Poincaré map.
Definition 5.2 (Rotation number). For a map f : [0, 2π) → [0, 2π), the rotation
number of f is defined as
f n (x) − x
(5.3) Ω(f ) = lim .
n→∞ n
In the paper, bifurcations occur at points corresponding to special values of this
rotation number. In particular, the twistless bifurcation occurs when the derivative
40 5. R ESULTS
of the rotation number as a function of the action vanishes. The structures around
this bifurcation are shown in Figure 5.6.
The goal is then to demonstrate these behaviours in the PCR3BP. The equilib-
rium at L4 is a suitable canditate for this structure, as the Poincaré map has a fixed
point. A fixed energy is considered, close (but not too close) to the critical value of
the energy at L4 (which, as found in Equation (3.29) is E = −1.5 + µ(1 − µ)).
The Poincaré map (as a function of energy) can, for quasiperiodic orbits, be
defined on a curve isomorphic to the circle. Then the rotation number can be
defined as in 5.2 as a function of the action. At particular values of this, we observe
bifurcations. In particular, rational rotation numbers lead to resonance resulting in
a bifurcation. A formula for the mass ratios where this occurs is a known result.
Introduction to Hamiltonian Dynamical Systems and the N -Body Problem [24]
5.2. A NALYSING O RBITS 43
Figure 5.6. The bifurcations near the twistless bifurcation, and repre-
sentative phase portraits. Picture credit: Generic twistless bifurcations
[12].
where µr is the value of µ where the 1r resonance occurs (where the rotation number
is 31 ). This formula is only valid for E = −1.5 + µ(1 − µ) (the critical energy value
found in (3.29)), but gives a good estimate for close energy values.
We can then consider the rotation number of the map as a function of the action
Ω(J). Then for periodic orbits bifurcations occur at resonant values of the rotation
number. In particular,
44 5. R ESULTS
Figure 5.7. Bifurcation analysis for the Poincaré map near L4 . For these
plots, E = −1.49.
Top row, left to right: µ = 0.0025, 0.0030, 0.0035.
Second row: µ = 0.0040, 0.0045, 0.0050.
Third row: µ = 0.0055, 0.0060, 0.0065.
Bottom row: µ = 0.0075, 0.0080, 0.0085.
This continued in Figure 5.8. The bifurcations described by Figure 5.6
can be seen. In particular, note the bifurcation at µ = 0.008, and the
complex structure at µ = 0.003.
5.2. A NALYSING O RBITS 45
Figure 5.8. Bifurcation analysis for the Poincaré map near L4 . Contin-
ued from Figure 5.7
Top row, left to right: µ = 0.0090, 0.0095, 0.0100.
Second row: µ = 0.0105, 0.0110, 0.0115.
Third row: µ = 0.0120, 0.0125, 0.0130.
Bottom row: µ = 0.0135, 0.0140, 0.0145.
In particular note the bifurcation at µ = 0.0130 corresponding to the
1/3 bifurcation in Figure 5.6, and the structure at µ = 0.0100 which is
Figure 5.9. Top: the Poincaré map for the Poincaré section through L4 ,
for the parameter values µ = 0.0100, E = −1.49. Bottom: the structure
predicted near the vanishing twist bifurcation by [12]. Also visible is the
additional structure in the top left of the top diagram; this small island
chain is a remnant of a resonant rotation number. Picture credit for lower
figure: Generic twistless bifurcations [12].
5.2. A NALYSING O RBITS 47
Figure 5.10. Top figure: Figure 5.9, with a particular set highlighted
which is invariant under the Poincaré map . Bottom figure: The orbit
around L4 corresponding to this invariant set. Recall that points on the
Poincaré section are generated when the orbit crosses the grey line where
the section is defined.
48 5. R ESULTS
• If Ω(0) is rational the orbit is resonant, and a chain of “islands” form. See
µ = 0.0035 and µ = 0.0045, µ = 0.0070 and µ = 0.0095 in Figures 5.7
and 5.8 for examples of this.
• If Ω(J) is rational with Ω(J) = pq for p, q ∈ N, we get chains of islands
with q smaller islands in the big island. µ = 0.0030 in Figure 5.7 corre-
sponds to this with Ω(J) = 3/10. However, there appear to be more than
10 smaller islands, though is most likely a quirk of the way the Poincaré
map has been constructed or calculated.
• A circle where Ω0 (J) = 0 is called twistless.
Based on the diagrams from the paper by Dullin et al., we can identify the
ranges where our system undergoes these bifurcations, by comparing Figures 5.7
and 5.8 and the phase portraits in Figure 5.6. The figures show the evolution of
the structure of the Poincaré map for fixed energy and µ being varied between
µ = 0.0025 and µ = 0.01451.
Of particular note are the bifurcations which occur near µ = 0.0080 and
µ = 0.0130, and the structure near the twistless bifurcation at µ = 0.0100. This
structure is shown in more detail in Figure 5.9. A striking orbit in this structure is
shown in Figure 5.10.
There are some key differences between the PCR3BP and the system consid-
ered by Dullin et al, most notably the second parameter. However, we can still
observe that the bifurcations match the theoretical predictions very closely.
5.2.3. The Earth-Moon system. One final analysis is to study the structure
of the Poincaré map when the energy parameter is altered, rather than the mass
parameter. The results of this are shown in Figures 5.11 and 5.12. Of note is the
choice of mass parameter for this analysis; we take µ = 0.01215. This is the
mass parameter for the Earth-Moon system. The moon’s orbit around the Earth
has a low eccentricity of about 0.05 (from [25]), so the “circular” part of our ap-
proximation is reasonable. As of October 2012, no trojans have been discovered
in the Earth-Moon system. This does not mean they do not exist; it was only
in July 2011 that the first trojans in the Sun-Earth system was found, an aster-
oid called TK7 (see [26]). The plots show possible stable orbits around L4 for
−1.4855 < E < −1.4975 (although the possibility of stable orbits for other en-
ergy values cannot be discounted).
1Recall that orbits around L are only stable when µ < 0.0385, so only a relatively small range
4
of the parameter is being considered.
5.2. A NALYSING O RBITS 49
Figure 5.11. Analysing the Poincaré section for the Earth-Moon system
near L4 . For the Earth-Moon system, µ = 0.01215. The above images
are the result of adjusting the Energy parameter.
Top row, left to right: E = −1.4855, −1.4860, −1.4865.
Second row: E = −1.4870, −1.4875, −1.4880.
Third row: E = −1.4885, −1.4890, −1.4895.
Bottom row: E = −1.4900, −1.4905, −1.4910.
50 5. R ESULTS
Figure 5.12. The Poincaré section for the Earth-Moon system near L4 .
Continued from Figure 5.11.
Top row, left to right: E = −1.4915, −1.4920, −1.4925.
Second row: E = −1.4930, −1.4935, −1.4940.
Third row: E = −1.4945, −1.4950, −1.4955.
Bottom row: E = −1.4960, −1.4970, −1.4975.
C HAPTER 6
Conclusion
51
References
52
R EFERENCES 53
Acknowledgements
The author would like to thank Holger Dullin, whose expertise and enthusiasm
have made this project not only possible but extremely gratifying.
Thanks must also go to William Rowley, whose advice on C++ was invaluable,
and Ting-Ying Chang, whose input has been exceedingly propitious.
54
A PPENDIX B
Code
/*
THREE BODY PROBLEM
JOACHIM WORTHINGTON
2012
5 jwor6721@uni.sydney.edu.au
10 */
#include <stdio.h>
#include <tchar.h>
15 #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <GL/glut.h>
#include <GL/gl.h>
20 #include <iostream>
#include <string>
#include <sstream>
#include <complex>
std::stringstream sstm;
using namespace std;
55
56 B. C ODE
50 /*FOR PRIMARY ORBITS: for orbits that orbit one or both primaries
*/
#define MAX_MU 0.5 //Maximum value of mu parameter; minimum
is 0
#define MAX_ENERGY 5.0 //Really the minimum energy; .energy
between 0 and -this
#define MIN_ENERGY -1.0 //Again, really the maximum energy;
consider -this
#define MAX_PX 2.0 //Maximum selection of p_x in the poincare
window
55 #define MIN_PX -2.0 //Minumum selection of p_x in the poincare
window
#define MAX_X 2.0 //Maximum selection of x in the poincare
window
#define MIN_X -2.0 //Minumum selection of x in the poincare
window
int menu;
110
double scaleOut=0.5; //Scale for the orbit window
void redrawOrbit(void);
void mouseOrbit(int button, int state, int x, int y);
void reshapeOrbitW (int w, int h);
void renderSceneOrbitW(void);
150 void redrawOrbitW(void);
void mouseOrbitW(int button, int state, int x, int y);
void reshapePoin (int w, int h);
void renderScenePoin(void);
void mousePoin(int button, int state, int x, int y);
155 void sKeyboardPoin(int key, int x, int y);
void reshapeUI (int w, int h);
void renderSceneUI(void);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
220 glClearColor(1.0, 1.0, 1.0, 1.0);
B. C ODE 61
int pSpaceH=paramWindowHeight;
double ratioH=(MAX_ENERGY-MIN_ENERGY)/pSpaceH;
230 double crossY=(-1*(hP+MIN_ENERGY)/ratioH);
crossY=-1*(2*crossY/paramWindowHeight-1);
glBegin( GL_LINES );
glColor3f( 0, 0, 0 );
235 glVertex2f( crossX-CROSS_SIZE, crossY );
glVertex2f( crossX+CROSS_SIZE, crossY );
glVertex2f( crossX, crossY-CROSS_SIZE );
glVertex2f( crossX, crossY+CROSS_SIZE );
glEnd();
240
if (!fastMode) glutSwapBuffers();
}
paramWindowWidth=w;
paramWindowHeight=h;
glViewport(0,0,(GLsizei)w,(GLsizei)h);
250 glutPostRedisplay();
glutSetWindow(paramWindow);
renderSceneParam();
}
if ( button == GLUT_LEFT_BUTTON ) {
if (state == GLUT_DOWN ) {
260
muP=x*MAX_MU/paramWindowWidth;
hP=-y*(MAX_ENERGY-MIN_ENERGY)/paramWindowHeight-MIN_ENERGY;
verifyParameters();
265
}
}
integrateOn=false;
newOrbit=true;
62 B. C ODE
270 glutSetWindow(paramWindow);
renderSceneParam();
if (orbitWindowOn)
{
glutSetWindow(orbitWindow);
275 renderSceneOrbit();
}
if (orbitWindowOnW)
{
glutSetWindow(orbitWindowW);
280 renderSceneOrbitW();
}
glutSetWindow(poinWindow);
renderScenePoin();
}
285
void sKeyboardParam(int key, int x, int y){
//Special Keyboard callback for Parameter Window
switch (key) {
290 case GLUT_KEY_UP: hP+=PARAM_Y_RES;
break;
case GLUT_KEY_DOWN: hP-=PARAM_Y_RES;
break;
case GLUT_KEY_LEFT: muP-=PARAM_X_RES;
295 break;
case GLUT_KEY_RIGHT: muP+=PARAM_X_RES;
break;
}
integrateOn=false;
300 newOrbit=true;
verifyParameters();
glutSetWindow(paramWindow);
renderSceneParam();
if (orbitWindowOn)
305 {
glutSetWindow(orbitWindow);
renderSceneOrbit();
}
if (orbitWindowOnW)
310 {
glutSetWindow(orbitWindowW);
renderSceneOrbitW();
}
glutSetWindow(poinWindow);
315 }
glutSetWindow(orbitWindow);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
345 glClearColor(1.0, 1.0, 1.0, 1.0);
glVertex2f( +1, 0 );
glEnd();
}
}
425 flag=true;
}
for (j=1; j<=orbitWindowWidth*HILL_DETAIL; j++){
for (i=1; i<=orbitWindowHeight*HILL_DETAIL; i++){
x=(i*(2.0/HILL_DETAIL)-orbitWindowHeight*1.0)/(
orbitWindowHeight*1.0*scaleOut);
430 y=(j*(2.0/HILL_DETAIL)-orbitWindowWidth)/(orbitWindowWidth
*scaleOut);
if (!hillRegion(x,y)){
if (flag){
//Plot zero velocity curve
glBegin( GL_POINTS );
435 glColor3f( 0, 0, 0 );
glVertex2f( x*scaleOut, y*scaleOut );
glEnd();
flag=false;
}
440 }
else if (!flag){
//Plot zero velocity curve
glBegin( GL_POINTS );
glColor3f( 0, 0, 0 );
445 glVertex2f( x*scaleOut, y*scaleOut );
glEnd();
flag=true;
}
450 }
flag=true;
}
glPointSize( 1.0 );
}
455
66 B. C ODE
if (!fastMode) glutSwapBuffers();
520 }
glutSetWindow(orbitWindow);
glPointSize( 2.0 );
float r=0,g=0,b=0; //Set up colour
535 if (colour==0) r=0.5;
else if (colour==1) g=0.5;
else if (colour==2) b=0.5;
glBegin( GL_POINTS );
540 glColor3f(r, g, b);
glVertex2f( x*scaleOut, y*scaleOut );
glEnd();
68 B. C ODE
if (!fastMode) glutSwapBuffers();
}
545
//ORBIT WINDOW (W-SPACE)
void reshapeOrbitW (int w, int h){
//Reshaping the Orbit window
550 orbitWindowWWidth=w;
orbitWindowWHeight=h;
glViewport(0,0,(GLsizei)w,(GLsizei)h);
gluOrtho2D(-PI,PI,-4,4);
glutPostRedisplay();
555 if (orbitWindowOnW){
glutSetWindow(orbitWindowW);
renderSceneOrbitW();
}
glutSetWindow(poinWindow);
560 renderScenePoin();
}
void renderSceneOrbitW(void) {
//Render the Orbit window
glutSetWindow(orbitWindowW);
570 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(1.0, 1.0, 1.0, 1.0);
}
}
}
glPointSize( 1.0 );
595 }
if (!fastMode) glutSwapBuffers();
605 }
renderScenePoin();
640 }
if (poinRegionOn){
//Draw in Hill’s region
//(or, more accurately, draw !Hill’s region in grey)
655
double mu1=1-muP;
double mu2=muP;
glPointSize( 2.0 );
glBegin( GL_POINTS );
glColor3f( 0.8, 0.8, 0.8 );
glVertex2f( x, px );
690 glEnd();
}
}
}
}
695
//Draw lines for the Large Body coordinates
glBegin( GL_LINES );
glColor3f( 0.6, 0.6, 0.6 );
glVertex2f( -muP, -100 );
700 glVertex2f( -muP, +100 );
glVertex2f( -(muP-1), -100 );
glVertex2f( -(muP-1), +100 );
glEnd();
if (!fastMode) glutSwapBuffers();
715 }
double pN=poinPY;
735 double pP=poinPX;
poinPX=(pP+SQRT3*pN)/2;
poinPY=(-SQRT3*pP+pN)/2;
}
}
740 }
integrateOn=true;
verifyParameters();
if (clearOrbits){
renderSceneOrbit();
745 renderSceneOrbitW();
}
coords[0]=poinX;
if (sectionTwo) coords[1]=sqrt(3.0)*(poinX+muP);
else if (sectionThree) coords[1]=-sqrt(3.0)*(poinX+muP-1);
750 else coords[1]=0;
coords[2]=poinPX;
if (poinPY==-1111.11) integrateOn=false;
coords[3]=poinPY;
zToW_tb(coords);
755 newOrbit=false;
}
switch (key) {
case GLUT_KEY_UP: poinPX+=PARAM_Y_RES;
780 break;
case GLUT_KEY_DOWN: poinPX-=PARAM_Y_RES;
B. C ODE 73
break;
case GLUT_KEY_LEFT: poinX-=PARAM_X_RES;
break;
785 case GLUT_KEY_RIGHT: poinX+=PARAM_X_RES;
break;
}
integrateOn=false;
newOrbit=true;
790 poinPY=initPY(poinX,poinPX);
verifyParameters();
glutSetWindow(poinWindow);
renderScenePoin();
if (clearOrbits) {
795 renderSceneOrbit();
renderSceneOrbitW();
}
}
825 UIWindowWidth=w;
UIWindowHeight=h;
glViewport(0,0,(GLsizei)w,(GLsizei)h);
glutPostRedisplay();
glutSetWindow(UIWindow);
74 B. C ODE
830 renderSceneUI();
}
void redrawUI(void){
if (!fastMode) glutSwapBuffers();
835 }
void renderSceneUI(void) {
//Render the UI window
875 if (sectionTwo) {
double oldVal, newVal;
oldVal=sin(oldU)*sinh(oldV)+SQRT3*cos(oldU)*cosh(oldV)+
SQRT3;
newVal=sin(coords[0])*sinh(coords[1])+SQRT3*cos(coords[0])
*cosh(coords[1])+SQRT3;
if (oldVal>0 && newVal<0) {
880 complex<double> oldw(oldU,oldV);
complex<double> oldpw(oldPU,-oldPV);
complex<double> neww(coords[0],coords[1]);
complex<double> newpw(coords[2],-coords[3]);
complex<double> oldz, oldpz, newz, newpz;
885 oldz=0.5*(1-2*muP+cos(oldw)); //Previous coordinate
oldpz=-2.0*oldpw/(sin(oldw));
newz=0.5*(1-2*muP+cos(neww)); //Current coordinate
newpz=-2.0*newpw/(sin(neww));
double ratio=oldVal/(oldVal-newVal); //Extrapolation
distance
890 double x0=real(oldz)+ratio*(real(newz)-real(oldz)); //
Extrapolate the point
double px0=real(oldpz)+ratio*(real(newpz)-real(oldpz));
double py0=imag(oldpz)+ratio*(imag(newpz)-imag(oldpz));
910 oldz=0.5*(1-2*muP+cos(oldw));
oldpz=-2.0*oldpw/(sin(oldw));
newz=0.5*(1-2*muP+cos(neww));
newpz=-2.0*newpw/(sin(neww));
double ratio=oldVal/(oldVal-newVal);
915 double x0=real(oldz)+ratio*(real(newz)-real(oldz));
double px0=real(oldpz)+ratio*(real(newpz)-real(oldpz));
76 B. C ODE
double py0=imag(oldpz)+ratio*(imag(newpz)-imag(oldpz));
oldz=0.5*(1-2*muP+cos(oldw));
935 oldpz=-2.0*oldpw/(sin(oldw));
newz=0.5*(1-2*muP+cos(neww));
newpz=-2.0*newpw/(sin(neww));
double ratio=(imag(oldz))/(imag(oldz)-imag(newz));
double x0=real(oldz)+ratio*(real(newz)-real(oldz));
940 double px0=real(oldpz)+ratio*(real(newpz)-real(oldpz));
if (imag(newz)>=0)
addPoincare(x0,px0);
}
}
945
if (orbitWindowOn)
addOrbit(coords[0],coords[1]);
if (orbitWindowOnW)
addOrbitW(coords[0],coords[1]);
950 if (abs(K_E(coords))>1 || abs(coords[1])>TOO_FAR)
integrateOn=false;
}
}
glutSetWindow(UIWindow);
955 renderSceneUI();
}
//MENUS
960 void createGLUTMenus() {
// Create the menu
menu = glutCreateMenu(processMenuEvents);
B. C ODE 77
case INTEGRATE:
integrateOn=true;
1000 if (newOrbit)
{
coords[0]=poinX;
if (!sectionTwo)
1005 coords[1]=0;
else
coords[1]=sqrt(3.0)*(poinX+muP);
coords[2]=poinPX;
1010 if (initPY(poinX,poinPX)==-1111.11) integrateOn=false;
coords[3]=initPY(poinX,poinPX);
78 B. C ODE
zToW_tb(coords);
newOrbit=false;
}
1015 break;
case HILL_ON:
hillRegionOn=(!hillRegionOn);
break;
case POIN_ON:
1020 poinRegionOn=(!poinRegionOn);
break;
case ZOOM_IN:
scaleOut+=0.1;
if (orbitWindowOn)
1025 {
glutSetWindow(orbitWindow);
renderSceneOrbit();
}
if (orbitWindowOnW)
1030 {
glutSetWindow(orbitWindowW);
renderSceneOrbitW();
}
glutSetWindow(poinWindow);
1035 renderScenePoin();
break;
case ZOOM_OUT:
scaleOut-=0.1;
if (scaleOut<0.1) scaleOut=0.1;
1040 if (orbitWindowOn)
{
glutSetWindow(orbitWindow);
renderSceneOrbit();
}
1045 if (orbitWindowOnW)
{
glutSetWindow(orbitWindowW);
renderSceneOrbitW();
}
1050 glutSetWindow(poinWindow);
renderScenePoin();
break;
case ENTER_PARAM:
//Enter parameter values at the Console window
1055 cout<<"\n\nEnter value of mu (mass parameter):\t";
cin>>muP;
cout<<"\nEnter energy level:\t";
cin>>hP;
integrateOn=false;
B. C ODE 79
1060 newOrbit=true;
poinPY=initPY(poinX,poinPX);
verifyParameters();
glutSetWindow(poinWindow);
renderScenePoin();
1065 glutSetWindow(paramWindow);
renderSceneParam();
break;
case ENTER_POIN:
cout<<"\n\nEnter initial value of x:\t";
1070 cin>>poinX;
cout<<"\nEnter initial value of p_x:\t";
cin>>poinPX;
integrateOn=false;
newOrbit=true;
1075 poinPY=initPY(poinX,poinPX);
verifyParameters();
glutSetWindow(poinWindow);
glutSetWindow(paramWindow);
renderSceneParam();
1080 break;
case ORBIT_ON:
orbitWindowOn=!orbitWindowOn;
if (!orbitWindowOn){
glutSetWindow(orbitWindow);
1085 glutHideWindow();
}
else{
glutSetWindow(orbitWindow);
glutShowWindow();
1090 renderSceneOrbit();
}
break;
case ORBIT_ON_W:
orbitWindowOnW=!orbitWindowOnW;
1095 if (!orbitWindowOnW){
glutSetWindow(orbitWindowW);
glutHideWindow();
}
else{
1100 glutSetWindow(orbitWindowW);
glutShowWindow();
renderSceneOrbitW();
}
break;
1105 case SWITCH_POIN:
if (sectionTwo) {
sectionTwo=false;
80 B. C ODE
sectionThree=true;
}
1110 else if (sectionThree) {
sectionThree=false;
sectionTwo=false;
}
else {
1115 sectionTwo=true;
sectionThree=false;
}
glutSetWindow(poinWindow);
renderScenePoin();
1120 glutSetWindow(paramWindow);
renderSceneParam();
glutSetWindow(orbitWindow);
renderSceneOrbit();
break;
1125 case EACH_NEW:
clearOrbits=!clearOrbits;
}
}
1130
//MATHS FUNCTIONS
void verifyParameters()
{
//Check that the current parameters are valid, if not fix them
up
1135 if (muP<0) muP=0;
if (muP>MAX_MU) muP=MAX_MU;
if (hP>-MIN_ENERGY) hP=-MIN_ENERGY;
if (hP<-MAX_ENERGY) hP=-MAX_ENERGY;
}
1140
double uHat(double x, double y){
//Calculates uHat, the effective potential, in z-space
double mu1=1-muP;
double mu2=muP;
1145 double r1=sqrt((x+mu2)*(x+mu2)+y*y);
double r2=sqrt((x-mu1)*(x-mu1)+y*y);
return 0.5*(-x*x-y*y)-mu1/r1-mu2/r2;
}
double r1=sqrt((u*u-v*v)*(u*u-v*v)+4*u*u*v*v);
1155 double r2=sqrt((u*u-v*v-1)*(u*u-v*v-1)+4*u*u*v*v);
return -0.5*(mu1*r1*r1+mu2*r2*r2)-mu1/r1-mu2/r2;
}
double y=SQRT3*(x+muP);
double r1=sqrt((x+mu2)*(x+mu2)+y*y);
1200 double r2=sqrt((x-mu1)*(x-mu1)+y*y);
double a=0.5;
double b=-0.5*(SQRT3*y+1*x);
double c=-hP+0.5*px*px+0.5*(y-SQRT3*x)*px-mu2/r2-mu1/r1;
if (b*b-4*a*c<0) return -1111.11; //Impossible Selection!
1111.11 is a dummy
1205 return (-b+sqrt(b*b-4.0*a*c))/(2.0*a); //the normal momentum
}
else if (sectionThree){
//Section Three code; calculate Normal momentum from Parallel
momentum
double mu1=1-muP;
1210 double mu2=muP;
double y=-SQRT3*(x+muP-1);
double r1=sqrt((x+mu2)*(x+mu2)+y*y);
double r2=sqrt((x-mu1)*(x-mu1)+y*y);
double a=0.5;
1215 double b=0.5*(SQRT3*y-1*x);
double c=-hP+0.5*px*px+0.5*(y+SQRT3*x)*px-mu2/r2-mu1/r1;
if (b*b-4*a*c<0) return -1111.11; //Impossible Selection!
1111.11 is a dummy
return (-b+sqrt(b*b-4.0*a*c))/(2.0*a); //the normal momentum
}
1220 else {
//Section One code
double mu1=1-muP;
double mu2=muP;
double y=0;
1225 double r1=sqrt((x+mu2)*(x+mu2)+y*y);
double r2=sqrt((x-mu1)*(x-mu1)+y*y);
double a=0.5;
double b=-x;
double c=-hP+0.5*px*px+y*px-mu2/r2-mu1/r1;
1230 if (b*b-4*a*c<0) return -1111.11; //Impossible Selection!
1111.11 is a dummy
return (-b+sqrt(b*b-4.0*a*c))/(2.0*a);
}
}
return result;
}
double L1(){
//Calculate the Lagrangian point in the range (-mu,1-mu)
1260 double L_point=0;
int i;
for (i=0; i<NEWTON_STEPS; i++){
L_point-=(Lagrangian_f(L_point,1)/Lagrangian_fdash(L_point,1))
;
}
1265 return -L_point;
}
double L2(){
//Calculate the Lagrangian point in the range (1-mu,infinity)
1270 double L_point=3;
int i;
for (i=0; i<NEWTON_STEPS; i++){
L_point-=(Lagrangian_f(L_point,2)/Lagrangian_fdash(L_point,2))
;
}
1275 return -L_point;
}
double L3(){
//Calculate the Lagrangian point in the range (-infinity,-mu)
1280 double L_point=-1;
int i;
for (i=0; i<NEWTON_STEPS; i++){
L_point-=(Lagrangian_f(L_point,3)/Lagrangian_fdash(L_point,3))
;
}
1285 return -L_point;
}
84 B. C ODE
void integrationStep()
1300 {
/*ORIGINAL SPLIT-STEP METHOD No transformation
uHatStep(coords,dt/2);
tStep(coords,dt);
uHatStep(coords,dt/2);*/
1305
/* UNFINISHED: Levi-Civita Local transformations
double r1=sqrt((c[0]+muP)*(c[0]+muP)+c[1]*c[1]);
double r2=sqrt((c[0]+muP)*(c[0]+muP)+c[1]*c[1]);
if (r1<TOO_CLOSE){ //If we are Too Close to the first body
1310 zToW_lc1(c);
uHatStep_lc1(c,dt/2);
tHatStep_lc1(c,dt);
uHatStep_lc1(c,dt/2);
wToZ_lc1(c);
1315 }
else
{
tStep(c,dt/2);
uHatStep(c,dt);
1320 tStep(c,dt/2);
}*/
/*THIELE-BARRAU TRANSFORMATION*/
runge_kutta_4(coords,f_tb,dt);
1335 while (coords[0]<0)
coords[0]+=2*PI;
while (coords[0]>=2*PI)
coords[0]-=2*PI;
return;
1340 }
return;
}
complex<double> SNO(0,1);
result=pw*conj(pw)/(2.0*fp*fbp);
result=result+SNO*0.5*((conj(pw)*fb/fbp)-(pw*f/fp));
result=result-muP/abs(f-1.0+muP);
1385 result=result-(1.0-muP)/abs(f+muP);
if (abs(imag(result))>0.1)
cout<<"There is an issue!!";
return real(result);
}
1390
double* delUhat(double* c){
//Derivative of uHat
double* delU=new double[4];
delU[0]=0;
1395 delU[1]=0;
double mu1=1-muP;
double mu2=muP;
double r1=sqrt((c[0]+mu2)*(c[0]+mu2)+c[1]*c[1]);
double r2=sqrt((c[0]-mu1)*(c[0]-mu1)+c[1]*c[1]);
1400
double Uhat_r1=-mu1*r1+mu1/(r1*r1);
double Uhat_r2=-mu2*r2+mu2/(r2*r2);
double dr1dx=(c[0]+mu2)/r1;
double dr1dy=c[1]/r1;
1405 double dr2dx=(c[0]-mu1)/r2;
double dr2dy=c[1]/r2;
double Uhat_x=Uhat_r1*dr1dx+Uhat_r2*dr2dx;
double Uhat_y=Uhat_r1*dr1dy+Uhat_r2*dr2dy;
1410 delU[2]=-Uhat_x;
delU[3]=-Uhat_y;
return delU;
}
r2=0.5*abs(cos(w)-1.0);
1570 double dudr1, dudr2;
dudr1=-0.5*(3.0*mu1*r1*r1*r2+mu2*r2*r2*r2)-mu2-hP*r2;
dudr2=-0.5*(3.0*mu2*r1*r2*r2+mu1*r1*r1*r1)-mu1-hP*r1;
complex<double> dr1dw, dr2dw;
dr1dw=-(sin(w)*(cos(conj(w))+1.0))/(4.0*r1);
1575 dr2dw=-(sin(w)*(cos(conj(w))-1.0))/(4.0*r2);
wdot=0;
pwdot=dudr1*dr1dw+dudr2*dr2dw;
w=w+step*wdot;
pw=pw-step*pwdot;
1580 c[0]=real(w);
c[1]=imag(w);
c[2]=real(pw);
c[3]=-imag(pw);
return;
1585 }
c[0]=real(q)-muP+0.5;
c[1]=imag(q);
1665 c[2]=real(pq);
c[3]=imag(pq);
return dtau;
}
1705 return;
}
1730
int main(int argc, char **argv){
//User option: ’pretty mode’ enables double buffering, runs much
slower, less flickery
char a;
cout<<"(f)ast mode or (p)retty mode? ";
1735 cin>>a;
while (a!=’f’ && a!=’p’)
cin>>a;
glutReshapeFunc(reshapeParam);
glutDisplayFunc(renderSceneParam);
glutMouseFunc(mouseParam);
glutSpecialFunc(sKeyboardParam);
1760 glutKeyboardFunc(nKeyboardPoin);
glutSetCursor(GLUT_CURSOR_FULL_CROSSHAIR);
createGLUTMenus();
1805 glutSetMenu(menu);