Professional Documents
Culture Documents
Keplers Equation
This document describes several MATLAB functions that can be used to solve Keplers equation for
circular, elliptical, parabolic and hyperbolic orbits.
kepler1.m Danbys method
This MATLAB function is based on a numerical solution of Keplers equation devised by Professor J.
M. A. Danby at North Carolina State University. Additional information about this algorithm can be
found in The Solution of Keplers Equation, Celestial Mechanics, 31 (1983) 95-107, 317-328 and 40
(1987) 303-312.
The initial guess for Danby's method is
E0 M 0.85sign sin M e
The fundamental equation we want to solve is
f E E e sin E M 0
which has the first three derivatives given by
f E 1 e cos E
f E e sin E
f E e cos E
The iteration for an updated eccentric anomaly based on a current value En is given by the next four
equations:
f
En
f
f
1
f f
2
f
n En
1
1
f f 2 f
2
6
En 1 En n
En
This algorithm provides quartic convergence of Kepler's equation. This process is repeated until the
following convergence test involving the fundamental equation is satisfied:
f E
page 1
H 0 log
1.8
e
where H 0 is the hyperbolic anomaly. The fundamental equation and first three derivatives for this case
are as follows:
f H e sinh H H M
f H e cosh H 1
f H e sinh H
f H e cosh H
Otherwise, the iteration loop which calculates , , and so forth is the same. The true anomaly for
hyperbolic orbits is determined with this next set of equations:
sin e2 1sinh H
cos e cosh H
The true anomaly is then determined from a four quadrant inverse tangent evaluation of these two
equations.
The syntax of this MATLAB function is
function [eanom, tanom] = kepler1 (manom, ecc)
% solve Kepler's equation for circular,
% elliptic and hyperbolic orbits
% Danby's method
% input
%
%
page 2
where
s s1 ds
s1 z
ds
0.078s15
1 e
and
z sign 2 2
1/3
1 e
1
4e
2
1
M
2
1
4e
2
Updates to the eccentric anomaly are calculated using the same set of equations as those in Danby's
method. For hyperbolic orbits this method uses the following for the correction to s
ds
0.071s5
e 1 0.45s 2 1 4 s 2
H 0 3log s 1 s 2
ecc
% output
%
%
% output
%
%
E t e sin E t
where
a3
t t0
E eccentric anomaly
e orbital eccentricity
q
1 e
U U 3 6ec3 E
t t0
3
2q3
The true anomaly is determined from the x and y components of the heliocentric position vector as
follows:
tan-1 y, x
where
2c
x q 1 2 U 2
6ec3
y 2q
1 e 1
c1U
2e 6c3
The c functions used in these equations are called Stumpff functions. They are named after the German
astronomer Karl Stumpff and defined by the series
1 x k
cn x
k 0 2k n !
page 5
k 0,1,2,
c0 x 2 cosh x
c1 x 2
c1 x 2
sin x
x
1 cos x
c2 x 2
x
sinh x
x
cosh x 1
c2 x 2
x
1
ck x
k!
k 0,1,2,
For x 0 ,
cn x
1
n!
It is most efficient to compute c2 and c3 by series and then compute c0 and c1 by recursion according to
the following:
c0 x 1 xc2
c1 x 1 xc3
t
= time relative to perihelion passage (days)
q
= perihelion radius (AU)
ecc = orbital eccentricity (non-dimensional)
% output
%
%
r
= heliocentric distance (AU)
tanom = true anomaly (radians)
page 6