You are on page 1of 3

Math 151A Winter 2014

Programming Project 1
Due: Feb 4th. NO late submissions are allowed.
1 Goal
In orbital mechanics, the position of an orbiting body, e.g., a satellite, is determined by solving the Keplers
equation
M(t) = E(t) e sin E(t), (1)
which relates the eccentric anomaly E, with the eccentricity of the orbit e and the average anomaly M. For
validation purposes, astronomers want to build a library with the routines to nd roots of the Keplers equation.
2 Detailed description
2.1 Mathematical Model
The position of the satellite is given by the true anomaly :
x(t) = r cos (t)
y(t) = r sin (t)
where
r =
a(1 e
2
)
1 + e cos
, a =
3

T
2

2
, = 3.986012 10
5
km
3
s
2
.
The true anomaly relates to (1) through the equation
= arccos

e cos E
e cos E 1

. (2)
and the dependence on time is established through M by
M = 2
t
T
, (3)
where T is the period of the orbit. To determine the , take into account that [0, ] if E [0, ], and
[, 2] if E [, 2].
Then, for all i {0, . . . , n} nd M(t
i
) from (3), you have to solve the Kepler equation (1), and nally nd
(t
i
) using (2). To solve the Kepler equation, you shall combine Newtons method and bisection method; a
possible way of doing that is described in the following algorithm:
Algorithm 1: Root nding algorithm combining bisection method and Newtons method
INPUT : endpoints of the interval containing the zero a, b; tolerances for the bisection method and
Newtons method tolb, toln; maximum number of iterations for the Newtons method nmax
OUTPUT: eccentric anomaly E
Step 1: Set error = |b a|;
Step 2: while error > toln do
Step 3: set {a, b} = bisection(a, b, tolb);
Step 4: set {E, error} = newton(a + (b a)/2, toln, nmax);
Step 5: if error > toln then set tolb = tolb/2 else OUTPUT(E); STOP.
end
OUTPUT(Method failed to achieve error toln);
STOP.
1
Math 151A Winter 2014
2.2 Routines
You have to code:
1. A routine
function [root a b] = bis(a,b,tolb,func,pars)
to nd a root of a function f(x) C(R) using bisection method. We use pars to store the constants M(t)
and e in (1), which can be a vector or other types of array.
2. A routine
function [root found iter] = nwt(seed,toln,nmax,func,dfunc,pars)
to nd a root of a function f(x) C
2
(R) using Newtons method. Here found is a logical indicating whether
the root is found, and iter is the number of iterations actually used.
3. A routine
function [root iter itern] = bisnwt(a,b,tolb,toln,nmax,func,dfunc,pars)
to nd a root of a function f(x) C
2
(R) using Algorithm 1. Here iter is the number of iterations used, and
itern is the number of iterations used in the Newtons method.
4. An application
function [orbit] = tanom(T,e,n,varargin)
that solves the Kepler equation and gives the position of the satellite in its orbital plane. This function
expects the arguments:
T: the period of the orbit in hours.
e: the eccentricity of the orbit.
n: the number of points where we want to localize the satellite on its orbit.
Also, the following arguments can optionally be passed to the function through varargin. (see mathworks):
[tolb]: the error for bisection method;
[toln]: the error for Newton method;
[nmax]: the maximum iterations that we allow to Newton method.
The output argument of the program, orbit, must be a matrix of the format
t
0
E
0

0
r
0
x
0
y
0
t
1
E
1

1
r
1
x
1
y
1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
t
n
E
n

n
r
n
x
n
y
n
where t
i
= iT/n, E
i
is the solution to Kepler Equation,
i
is the true anomaly corresponding to t
i
, r
i
is the
distance between the satellite and the earth at t
i
and (x
i
, y
i
) are the cartesian coordinates.
Each function must be in a dierent .m le, with the same name as the function.
2
Math 151A Winter 2014
3 Summary
You are required to submit to the CCLE page of the course a .zip le containing the following les:
1. The source les bis.m, nwt.m, bisnwt.m, tanom.m described above.
2. A .pdf le with a brief report of the project. The report should include the following sections:
User Guide: A concise description of all the routines and applications: what do they do, calling syntax,
output format, and return values or messages.
Implementation:
The argument toln in the routine tanom.m represents the error that we allow in the approximation
of the Kepler equation. If we want the error in the coordinates of the orbit to be smaller than 10
6
,
which value should we use for toln? Justify your answer.
Intuitively, the root-nding routines are meant for x R and thus, the points in the orbit can be
found one by one, applying Algorithm 1 and the transformations described in Section 2.1 for each
time of the period. A slight change, though, would allow us to work with a vector x R
n
and nd
all the points of the orbit at once. Discuss about the dierences between the two approaches.
Describe the tests that you have done to validate your code, what you have discovered, the problems
encountered, and their respective solutions. You must include at least the following test
T = 4, e = 0.25, n = 100,
and tolerance 1e-12 in bisnwt.m.
Solutions: Plot the orbits that you have obtained with your selected initial data and parameters.
3

You might also like