0% found this document useful (0 votes)
275 views

Celestial Computing With Numerit

This document provides information about solving Kepler's equation numerically using Danby's method. It describes Danby's method for solving the elliptic and hyperbolic forms of Kepler's equation. The method provides quartic convergence and involves iteratively updating the eccentric or hyperbolic anomaly. It also discusses calculating the true anomaly from the eccentric or hyperbolic anomaly. Plots are provided showing the number of iterations and error for an example orbit.

Uploaded by

cosmomac
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
275 views

Celestial Computing With Numerit

This document provides information about solving Kepler's equation numerically using Danby's method. It describes Danby's method for solving the elliptic and hyperbolic forms of Kepler's equation. The method provides quartic convergence and involves iteratively updating the eccentric or hyperbolic anomaly. It also discusses calculating the true anomaly from the eccentric or hyperbolic anomaly. Plots are provided showing the number of iterations and error for an example orbit.

Uploaded by

cosmomac
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 76

Celestial Computing with Numerit

Danbys Solution of Keplers Equation


Keplers Equation for Parabolic and Near-parabolic Heliocentric Orbits
State Vectors and Orbital Elements
Greenwich Apparent Sidereal Time
Precision Solar Ephemeris
Orbital Elements of the Moon
An Ephemeris of Pluto
The SLP96 Ephemeris
Apparent Coordinates of a Planet or the Moon
Apparent Coordinates of a Star
Predicting Celestial Events: Part 1
Predicting Celestial Events: Part 2
Predicting Lunar Eclipses
Predicting Solar Eclipses
Predicting Lunar Occultations
Predicting Transits of Mercury and Venus
Cowells Method for Heliocentric Orbits
Enckes Method for Heliocentric Orbits
Closest Approach Between the Earth and Heliocentric Objects
The Circular-restricted Three-body Problem
Equinoxes and Solstices
Written by C. David Eagle
Celestial Computing with Numerit
page 1
Danby's Solution of Kepler's Equation
This program (demokep1) demonstrates how to interact with the Numerit function
kepler1 which solves the elliptic and hyperbolic form of Kepler's equation using a
numerical method devised by Professor J.M.A. (Tony) Danby at North Carolina State
University. Additional information about this algorithm can be found in the technical
papers "The Solution of Kepler's Equation", Celestial Mechanics, 31 (1983) 95-107,
317-328 and 40 (1987) 303-312.
The elliptic form of Kepler's equation is given by the expression
(1) M EesinE
where M is the mean anomaly, E is the eccentric anomaly and e is the orbital eccentricity.
The eccentric anomaly initial guess for Danby's method is
(2)
E
0
M + 0.85sign(sinM)e
The fundamental equation we want to solve is
(3) f (E) E esinEM 0
which has the first three derivatives given by
(4)
f (E) 1 ecos E
f (E) esinE
f (E) ecos E
The iteration for an updated eccentric anomaly E
n+1
based on a current value E
n
is given
by the next four equations:
(5)
(E
n
)
f
f

*
(E
n
)
f
f +
1
2
f

n
(E
n
)
f
f +
1
2
f +
1
6

*2
f
E
n+1
E
n
+
n
Celestial Computing with Numerit
page 2
This algorithm provides quartic convergence of Kepler's equation. The process
summarized by Eq. 5 is repeated until the following convergence test involving the
fundamental equation is satisfied:
(6) f (E)
where is the convergence tolerance. This tolerance is "hardwired" in the software to the
value ktol = 1.0e-10.
Finally, the true anomaly can be calculated with the following two equations
(7)
sin 1e
2
sinE
cos cos Ee
and the four quadrant inverse tangent given by
(8) arctan(sin, cos)
If the orbit is hyperbolic the initial guess is
(9) H
0
log



2M
e
+ 1.8
_ _

, ,
where H
0
is the hyperbolic anomaly.
The fundamental equation and first three derivatives for this case are as follows:
(10)
f (H) esinhHHM
f (H) ecoshH1
f (H) esinhH
f (H) ecoshH
Otherwise, the iteration loop which calculates ,
*
and so forth is the same. The true
anomaly for hyperbolic orbits is determined with the next two equations and a four
quadrant inverse tangent function as before.
(11)
sin e
2
1 sinhH
cos ecoshH
Celestial Computing with Numerit
page 3
The syntax for this Numerit function is as follows:
function kepler1 (manom, ecc, eanom, tanom)
` solve Kepler's equation for circular,
` elliptic and hyperbolic orbits
` Danby's method
` input
` manom = mean anomaly (radians)
` ecc = orbital eccentricity (non-dimensional)
` output
` eanom = eccentric anomaly (radians)
` tanom = true anomaly (radians)
The program will interactively prompt you for the orbital eccentricity. It will then calculate
and plot arrays containing the number of algorithm iterations and the algorithm absolute
error (Equation 3).
The following are plots of the number of algorithm iterations and the absolute error for an
orbital eccentricity of 0.735. This is the eccentricity of a typical Molniya orbit. For this
example Danby's method requires at most 3 iterations and the absolute value of the
algorithm error is always less than 10
12
.
N
u
m
b
e
r

o
f

i
t
e
r
a
t
i
o
n
s
Mean anomaly (degrees)
1
1.2
1.4
1.6
1.8
2
2.2
2.4
2.6
2.8
3
0 50 100 150 200 250 300 350
Figure 1. Algorithm iterations
Celestial Computing with Numerit
page 4
A
l
g
o
r
i
t
h
m

e
r
r
o
r
Mean anomaly (degrees)
-10
-12
-8 10
-13

-6 10
-13

-4 10
-13

-2 10
-13

0
2 10
-13

4 10
-13

6 10
-13

8 10
-13

10
-12
0 50 100 150 200 250 300 350
Figure 2. Algorithm error
Celestial Computing with Numerit
page 1
Kepler's Equation for Parabolic and
Near-parabolic Heliocentric Orbits
This program (demokep2) demonstrates how to interact with the Numerit function
kepler2 which solves Kepler's equation for heliocentric parabolic and near-parabolic
orbits. It is based on the numerical method described in Chapter 4 of Astronomy on the
Personal Computer by Oliver Montenbruck and Thomas Pfleger. This algorithm uses a
modified form of Barker's equation and Stumpff functions to solve this problem.
The form of Kepler's equation solved by this function is
(1) E(t) esinE(t)

a
3
(t t
0
)
where
E eccentric anomaly
e orbital eccentricity
gravitational constant of the Sun
a semimajor axis
t time
t
0
time of perihelion passage
The relationship between semimajor axis a and perihelion radius q is as follows
(2)
a
q
1 e
By introducing the variable
(3)
U
3ec
3
(E)
1 e
E
Kepler's equation is now given by
(4) U +
1
3
U
3
6ec
3
(E)

2q
3
(t t
0
)
where c
3
(E) (E esinE) E
3
. The kepler2 function iteratively solves for U.
The heliocentric distance is determined from the expression
(5) r q




1 +




2c
2
6c
3
1 1
1 1
1 1
] ]
U
2
_ _


, ,
Celestial Computing with Numerit
page 2
The true anomaly is determined from the x and y components of the heliocentric position
vector as follows
(6) atan(y, x)
where
x q




1




2c
2
6ec
3
1 1
1 1
1 1
] ]
U
2
_ _


, ,
y 2q
1 + e
2e



1
6c
3
1 1
1 1
] ]
c
1
U
The true anomaly can also be determined from
(7) tan


2
_ _

, ,





1 + e
3ec
3
c
2
c
1
1 1
1 1
1 1
] ]
U
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
(8) c
n
(x)

(1)
k
x
k
(2k+n)!
k0, 1, 2,
k0

For x real and x 0, the first few terms are given by the following expressions
(9)
c
0
(x
2
) cos x c
0
(x
2
) coshx
c
1
(x
2
)
sinx
x
c
1
(x
2
)
sinhx
x
c
2
(x
2
)
1 cos x
x
c
2
(x
2
)
coshx 1
x
The Stumpff functions also satisfy the recursion relationship defined by
(10)
xc
k+2
(x)
1
k!
c
k
(x) k 0, 1, 2,
For x 0,
(11)
c
n
(x)
1
n!
Celestial Computing with Numerit
page 3
It is most efficient to compute c
2
and c
3
by series, and then compute c
0
and c
1
by recursion
according to the following:
(12)
c
0
(x) 1 xc
2
c
1
(x) 1 xc
3
The program will prompt you for the perihelion radius in Astronomical Units, the time
relative to perihelion passage in days and the orbital eccentricity. Please note that times
prior to perihelion passage should be input as negative numbers. Times after perihelion
passage are positive numbers.
The following is a typical draft output created with this program.
perihelion radius (AU) = 0.6
orbital eccentricity = 0.9985000000000001
time since perihelion passage (days) = -60
heliocentric distance (AU) = 1.341035285746319
true anomaly (degrees) = 263.9152690390323
Celestial Computing with Numerit
page 1
State Vectors and Orbital Elements
This program (demosvoe) demonstrates the relationship between classical orbital elements
and the state vector of a space object in an elliptical orbit. The state vector consists of the
inertial position and velocity vectors of the object relative to the central body. The following is
a brief description of the classical orbital elements.
The semimajor axis defines the size of the orbit and the orbital eccentricity defines the shape
of the orbit. The angular orbital elements are defined with respect to a fundamental x-axis, the
vernal equinox, and a fundamental plane, the equator. The z-axis of this system is collinear
with the spin axis of the Earth, and the y-axis completes a right-handed coordinate system.
The orbital inclination is the angle between the equatorial plane and the orbit plane. Satellite
orbits with inclinations between 0 and 90 degrees are called direct orbits and satellites with
inclinations greater than 90 and less than 180 degrees are called retrograde orbits. The right
ascension of the ascending node (RAAN) is the angle measured from the x-axis (vernal
equinox) eastward along the equator to the ascending node. The argument of perigee is the
angle from the ascending node, measured along the orbit plane in the direction of increasing
true anomaly, to the argument of perigee. The true anomaly is the angle from the argument of
perigee, measured along the orbit plane in the direction of motion, to the satellite's location.
Finally, the argument of latitude is the angle from the ascending node, measured in the orbit
plane, to the satellite's location in the orbit. The argument of latitude is equal to u + .
The orbital eccentricity is an indication of the type of orbit. For values of 0 e < 1, the orbit
is circular or elliptic. The orbit is parabolic when e 1 and the orbit is hyperbolic if the
condition e > 1 is true.
The semimajor axis a is calculated using the following expression:
(1)
a
1
2
r

v
2

where r r r
2
x
+ r
2
y
+ r
2
z
is the scalar position and v v v
2
x
+ v
2
y
+ v
2
z
is the scalar
velocity or speed of the space object.
The angular orbital elements are calculated from the equinoctial orbital elements h, k, p and q
which are in turn calculated from the rectangular components of the body-centered inertial
position and velocity vectors. The equinoctial orbital elements are an alternative set of
non-singular elements which avoid computational problems when working with orbits with
small eccentricity or inclination.
Celestial Computing with Numerit
page 2
The mathematical relationship between equinoctial and classical orbital elements is given by
the following expressions:
(2)
a a
h esin( + )
k ecos( + )
M + +
p tan(i/2)sin
q tan(i/2)cos
In the fourth equation M is the mean anomaly and is called the mean longitude.
The scalar orbital eccentricity e is determined from h and k as follows:
(3)
e h
2
+ k
2
The orbital inclination i is determined from p and q using the following expression
(4) i 2arctan



p
2
+ q
2
_ _

, ,
For values of inclination greater than a small value , the right ascension of the ascending
node is given by
(5) arctan(p, q)
Otherwise, the orbit is equatorial and there is no RAAN.
If the value of orbital eccentricity is greater than , the argument of perigee is determined
from
(6) arctan(h, k)
Otherwise, the orbit is circular and there is no argument of perigee. In the Numerit code for
these calculations, 10
8
.
Finally, the true anomaly is found from the expression
(7)
In these equations, all two argument inverse tangent calculations use a four quadrant Numerit
function called atan3 to determine the correct quadrant for the angle. Angular orbital
elements which can range from 0 to 360 degrees are also processed with a modulo 2
function named modulo.
Celestial Computing with Numerit
page 3
The body-centered, inertial rectangular components of the radius vector can be determined
from the classical orbital elements as follows:
(8)
r
x
p[cos cos( + ) sincos i sin( + )]
r
y
p[sincos( + ) + cos cos i sin( + )]
r
z
psini sin( + )
The rectangular components of the velocity vector are given by
(9)
v
x


p


cos{sin( + ) + esin} + sincos i{cos( + ) + ecos }1 1
] ]
v
y


p


sin{sin( + ) + esin} coscos i{cos( + ) + ecos }1 1
] ]
v
z


p


sini{cos( + ) + ecos }1 1
] ]
In these equations p is called the semiparameter of the orbit and is calculated from
p a(1 e
2
). is the gravitational constant of the primary or central body.
The syntax of the function which converts the state vector to classical orbital elements is
function eci2orb (mu, r, v, oev)
` convert eci state vector to six
` classical orbital elements via
` equinoctial elements
` input
` mu = gravitational constant (km^3/sec^2)
` r = eci position vector (kilometers)
` v = eci velocity vector (kilometers/second)
` output
` oev[1] = semimajor axis (kilometers)
` oev[2] = orbital eccentricity (non-dimensional)
` (0 <= eccentricity < 1)
` oev[3] = orbital inclination (radians)
` (0 <= inclination <= pi)
` oev[4] = argument of perigee (radians)
` (0 <= argument of perigee <= 2 pi)
` oev[5] = right ascension of ascending node (radians)
` (0 <= raan <= 2 pi)
` oev[6] = true anomaly (radians)
` (0 <= true anomaly <= 2 pi)
Celestial Computing with Numerit
page 4
The syntax of the Numerit function which converts the classical orbital elements to a state
vector is as follows:
function orb2eci(mu, oev, r, v)
` convert classical orbital elements to eci state vector
` input
` mu = gravitational constant (km^3/sec^2)
` oev[1] = semimajor axis (kilometers)
` oev[2] = orbital eccentricity (non-dimensional)
` (0 <= eccentricity < 1)
` oev[3] = orbital inclination (radians)
` (0 <= inclination <= pi)
` oev[4] = argument of perigee (radians)
` (0 <= argument of perigee <= 2 pi)
` oev[5] = right ascension of ascending node (radians)
` (0 <= raan <= 2 pi)
` oev[6] = true anomaly (radians)
` (0 <= true anomaly <= 2 pi)
` output
` r = eci position vector (kilometers)
` v = eci velocity vector (kilometers/second)
The following is a typical draft output created with this program.
position vector (kilometers)
rx = 7475.226183658003
ry = 1103.012821501304
rz = 2150.118648247414
velocity vector (kilometers/second)
vx = -0.04900375055806951
vy = 6.629471263012779
vz = -2.774486590207703
orbital elements
semimajor axis (kilometers) = 7999.999999999996
orbital eccentricity (non-dimensional) = 0.0249999999999999
orbital inclination (degrees) = 28.5
argument of perigee (degrees) = 99.99999999999959
right ascension of the ascending node (degrees) = 220
true anomaly (degrees) = 45.00000000000041
Celestial Computing with Numerit
page 1
Greenwich Apparent Sidereal Time
This Numerit program (demogast) demonstrates how to calculate the Greenwich
apparent sidereal time using both a low and high precision algorithm. Both numerical
methods are based on the IAU 1980 nutation algorithm.
function gast1
This function calculates the apparent Greenwich sidereal time using the first few terms of
the IAU 1980 nutation algorithm.
The Greenwich apparent sidereal time is given by the expression
(1)
m
+ cos(
m
+ )
In this equation
m
is the Greenwich mean sidereal time, is the nutation in longitude,

m
is the mean obliquity of the ecliptic and is the nutation in obliquity.
The Greenwich mean sidereal time, in degrees, is calculated using the expression
(2)
m
100.46061837 + 36000.770053608T + 0.000387933T
2
T
3
/ 38710000
where T (JD 2451545)/36525 and JD is the Julian date on the UT1 time scale.
The mean obliquity of the ecliptic is determined from
(3)
m
232621.448 46.8150T 0.00059T
2
+ 0.001813T
3
The nutations in obliquity and longitude involve the following three trigonometric
arguments (in degrees):
(4)
L 280.4665 + 36000.7698T
L 218.3165 + 481267.8813T
125.04452 1934.136261T
The calculation of the nutations use the following two equations:
(5)
17.20sin 1.32sin2L 0.23sin2L + 0.21sin2
9.20cos + 0.57cos2L + 0.10cos 2L 0.09cos 2
where these corrections are in units of arc seconds.
Celestial Computing with Numerit
page 2
The syntax of this function is as follows:
function gast1 (jdate, gst)
` Greenwich apparent sidereal time
` input
` jdate = Julian date
` output
` gst = Greenwich apparent sidereal time (radians)
` (0 <= gst <= 2 pi)
function gast2
This function calculates the mean or apparent Greenwich sidereal time. For the apparent
sidereal time calculation, the obliquity in longitude and obliquity are determined using a
Numerit function named nutation which implements the full IAU 1980 nutation
algorithm (108 terms). Please note that the Julian date can be passed to this function in a
high-order (integer) and low-order (fractional) part. In the argument list k determines the
type of Greenwich sidereal time calculation (k = 0 mean, k = 1 apparent). This
function was ported to Numerit using the Fortran version of the NOVAS (Naval
Observatory Vector Astrometry Subroutines) source code which was developed at
the United States Naval Observatory.
For this numerical method, the nutation in longitude is determined from a trigonometric
series of the form
(6)
n
S
i
sin A
i
i 1

The nutation in obliquity is determined from a series of the form


(7)
n
C
i
cos A
i
i 1

where
A
i
a
i
l + b
i
l + c
i
F + d
i
D + e
i

In this expression l, l, F, Dand are fundamental arguments.
Celestial Computing with Numerit
page 3
The syntax for this Numerit function is as follows:
function gast2 (tjdh, tjdl, k, gst)
` this function computes the greenwich sidereal time
` (either mean or apparent) at julian date tjdh + tjdl
` input
` tjdh = julian date, high-order part
` tjdl = julian date, low-order part
` julian date may be split at any point, but for
` highest precision, set tjdh to be the integral part of
` the julian date, and set tjdl to be the fractional part
` k = time selection code
` set k=0 for greenwich mean sidereal time
` set k=1 for greenwich apparent sidereal time
` output
` gst = greenwich (mean or apparent) sidereal time in hours
The program will prompt you for the calendar date and universal time. The following is a
typical draft output created with this program:
program demogast - Greenwich apparent sidereal time
calendar date October 21, 1999
universal time 10 h 20 m 30 s
Julian date 2451472.930902778
low precision 12 h 18 m 11.32 s
high precision 12 h 18 m 11.31 s
Celestial Computing with Numerit
page 1
Precision Solar Ephemeris
This program (demosun1) demonstrates how to interact with a Numerit function called
sun1 which computes a true-of-date geocentric ephemeris of the Sun based on the data
and numerical methods described in the book, Planetary Programs and Tables from
-4000 to +2800 by Pierre Bretagnon and Jean-Louis Simon. This book and companion
software are available from Willmann-Bell (www.willbell.com).
The fundamental time argument for this method is the number of days relative to the Julian
epoch January 1, 2000 normalized with respect to 3652500 Julian days. This value can be
calculated for any Julian Ephemeris Date JED with the following expression
(1)
U
JED 2451545
3652500
The geocentric, ecliptic mean longitude of the Sun is calculated with a trigonometric
series of the form
(2)
m
s

0
+
1
U +
50
l
i
sin(
i
+
1
U)
i 1

The geocentric distance of the Sun is calculated with another series of the form
(3) r
s
r
0
+ r
1
U +
50
r
i
cos(
i
+
i
U)
i 1

The longitude of the Sun is corrected for the effect of aberration (in radians) with the
following equation:
(4)
a
s
10
7
{993 + 17cos(3.10 + 62830.14U)}
The nutation in longitude (in radians) is calculated from
(5) 10
7
(834sin A
1
64sin A
2
)
where
A
1
2.18 3375.70U + 0.36U
2
A
2
3.51 + 125666.39U + 0.10U
2
The apparent, geocentric ecliptic longitude of the Sun is determined as the combination of
these three components with this next expression
(6)
s

m
s
+
a
s
+
Celestial Computing with Numerit
page 2
The three rectangular components of the geocentric, ecliptic position vector of the Sun
are given by
(7)
x
s
r
s
cos
s
y
s
r
s
sin
s
z
s
0
The apparent geocentric, equatorial right ascension and declination of the Sun can be
found from
(8)

s
arctan(cos
s
, sin sin
s
)

s
arcsin(sin sin
s
)
where is the true obliquity of the ecliptic. This number is calculated from the mean
obliquity of the ecliptic
m
and the nutation in obliquity with the following three
expressions:
(9)

m
+

m
10
7
(4090928 + 446A
1
+ 28cos A
2
)
10
7
U



226938 + U

75 + U(96926 + U(2491 12104U))_ _
, ,
_ _

, ,
Finally, we can compute the three rectangular components of the apparent, geocentric
equatorial position vector of the Sun with the following three expressions:
(10)
r
x
rcos
s
cos
s
r
y
rsin
s
cos
s
r
z
rsin
s
where r is the geocentric distance of the Sun.
Initialization
The sun1 function requires initialization the first time it is called. The following statement
in the main program will accomplish this:
suncoef = 1
The sun1 function will set this variable to 0 after initialization. The main program should
also contain a common suncoef statement in order to pass this value to the sun1
function. This is a feature unique to Numerit Pro.
Celestial Computing with Numerit
page 3
The syntax and arguments of this function are as follows:
function sun1 (jdate, rasc, decl, rsun)
` precision ephemeris of the Sun
` input
` jdate = julian ephemeris date
` output
` rasc = right ascension of the Sun (radians)
` (0 <= rasc <= 2 pi)
` decl = declination of the Sun (radians)
` (-pi/2 <= decl <= pi/2)
` rsun = eci position vector of the Sun (kilometers)
` note
` coordinates are inertial, geocentric,
` equatorial and true-of-date
The demosun1 program will prompt you for the initial calendar date and ephemeris time,
and a simulation duration in days. It will then create and plot arrays of time versus right
ascension, declination and geocentric distance.
The following is a plot of the geocentric right ascension of the Sun in degrees as a
function of the elapsed time relative to January 1, 1998 at 0 hours ET.
r
i
g
h
t

a
s
c
e
n
s
i
o
n

(
d
e
g
)
simulation time (days)
0
50
100
150
200
250
300
350
0 50 100 150 200 250 300 350
Figure 1. Right ascension of the Sun
Celestial Computing with Numerit
page 4
The following is a plot of the geocentric declination of the Sun in degrees as a function of
the elapsed time relative to January 1, 1998 at 0 hours ET.
d
e
c
l
i
n
a
t
i
o
n

(
d
e
g
)
simulation time (days)
-25
-20
-15
-10
-5
0
5
10
15
20
25
0 50 100 150 200 250 300 350
Figure 2. Declination of the Sun
This final plot shows the geocentric distance of the Sun in Astronomical Units as a
function of the elapsed time relative to January 1, 1998 at 0 hours ET.
g
e
o
c
e
n
t
r
i
c

d
i
s
t
a
n
c
e

(
A
U
)
simulation time (days)
0.9800
0.9850
0.9900
0.9950
1.0000
1.0050
1.0100
1.0150
1.0200
0 50 100 150 200 250 300 350
Figure 3. Geocentric distance of the Sun
Celestial Computing with Numerit
page 1
Orbital Elements of the Moon
This Numerit program (demoelp) demonstrates how to interact with the function
elp2000.num which calculates the classical osculating orbital elements of the Moon in
the mean ecliptic and mean equinox of date coordinate system. The numerical method
used in this function is based on the book Lunar Tables and Programs From 4000 B.C.
To A.D. 8000 by Michelle Chapront-Touze and Jean Chapront. This book and (optional)
companion software are available from Willmann-Bell (www.willbell.com).
The fundamental time argument of this algorithm is
(1)
t
JED 2451545
36525
where JED is the Julian Ephemeris Date.
The osculating orbital elements are calculated from series of the form
(2) a 383397.6 + S
a
+ t S

a
where
S
a

30
a
n
cos

(0)
n
+
(1)
n
t +
(2)
n
10
4
t
2
+
(3)
n
10
6
t
3
+
(4)
n
10
8
t
4
_ _
, ,
i 1

a

3
a

n
cos

(0)
n
+
(1)
n
t_ _
, ,
i 1

The following is the syntax for this Numerit function.


function elp2000(tjd, oev)
` osculating orbital elements of the moon
` mean ecliptic and mean equinox of date
` input
` tjd = tdt julian date
` output
` oev[1] = semimajor axis (kilometers)
` oev[2] = orbital eccentricity (non-dimensional)
` (0 <= eccentricity < 1)
` oev[3] = orbital inclination (radians)
` (0 <= inclination <= pi)
` oev[4] = argument of perigee (radians)
` (0 <= argument of perigee <= 2 pi)
` oev[5] = right ascension of ascending node (radians)
` (0 <= raan <= 2 pi)
` oev[6] = true anomaly (radians)
` (0 <= true anomaly <= 2 pi)
Celestial Computing with Numerit
page 2
The demoelp program will prompt you for the initial calendar date, ephemeris time and
simulation duration, in days. Be sure to include all digits of the calendar year.
The following are plots of the orbital elements of the Moon for 60 days relative to an
initial calendar date of January 1, 1998 at 0 hours ephemeris time.
s
e
m
i
m
a
j
o
r

a
x
i
s

(
k
m
)
simulation time (days)
379000.00
380000.00
381000.00
382000.00
383000.00
384000.00
385000.00
386000.00
387000.00
388000.00
0 10 20 30 40 50 60
Figure 1. Semimajor axis of the Moon
e
c
c
e
n
t
r
i
c
i
t
y
simulation time (days)
0.0250
0.0300
0.0350
0.0400
0.0450
0.0500
0.0550
0.0600
0.0650
0.0700
0.0750
0 10 20 30 40 50 60
Figure 2. Eccentricity of the Moon
Celestial Computing with Numerit
page 3
i
n
c
l
i
n
a
t
i
o
n

(
d
e
g
)
simulation time (days)
5.05
5.1
5.15
5.2
5.25
5.3
0 10 20 30 40 50 60
Figure 3. Orbital inclination of the Moon
a
r
g
u
m
e
n
t

o
f

p
e
r
i
g
e
e

(
d
e
g
)
simulation time (days)
175
180
185
190
195
200
205
210
215
0 10 20 30 40 50 60
Figure 4. Argument of perigee of the Moon
Celestial Computing with Numerit
page 4
r
a
a
n

(
d
e
g
)
simulation time (days)
160.4
160.6
160.8
161
161.2
161.4
161.6
161.8
162
162.2
162.4
0 10 20 30 40 50 60
Figure 5. RAAN of the Moon
t
r
u
e

a
n
o
m
a
l
y

(
d
e
g
)
simulation time (days)
0
50
100
150
200
250
300
350
0 10 20 30 40 50 60
Figure 6. True anomaly of the Moon
Celestial Computing with Numerit
page 1
An Ephemeris of Pluto
This program (demoplut) demonstrates how to interact with the Numerit function
pluto which calculates the heliocentric position vector of Pluto, in kilometers, relative to
the ecliptic and equinox of J2000. This algorithm is based on the numerical method
described in Chapter 36 of Astronomical Algorithms by Jean Meeus. This book is
available from Willmann Bell (www.willbell.com). Additional information is given in "An
Accurate Representation of the Motion of Pluto", Astronomy and Astrophysics, Vol. 155,
pages 323-325 (1986).
The fundamental time argument for this method is a function of the Julian Ephemeris Date
JED as follows:
(1)
T
JED 2451545
36525
The heliocentric ecliptic coordinates of Pluto are computed from series of the form
(2)
m
+
43
Asin + Bcos
i 1

where

m
coordinate mean value
i J + j S + kP
J, S, P mean longitudes of Jupiter, Saturn and Pluto
i, j, k integer constants
A, B coefficients of periodic term
The following is the syntax and arguments for this function:
function pluto(jdate, rpluto)
` heliocentric coordinates of pluto
` heliocentric position vector of Pluto
` ecliptic and equinox of J2000
` input
` jdate = julian ephemeris date
` output
` rpluto = position vector of Pluto (km)
Celestial Computing with Numerit
page 2
Initialization
This function requires initialization the first time it is called. The following statement in the
main program will accomplish this:
ipluto = 1
The pluto function will set this variable to 0 after initialization. The main program
should also contain a common ipluto statement in order to pass this value to the
pluto function. This is a feature unique to Numerit Pro.
The program will prompt you for the initial calendar date and a simulation duration in
days. The software will then compute the position vector and heliocentric distance every
50 days during the simulation.
The following is a plot of the heliocentric distance of Pluto, in Astronomical Units, relative
to January 1, 1998 at 0 hours ephemeris time.
h
e
l
i
o
c
e
n
t
r
i
c

d
i
s
t
a
n
c
e

(
A
U
)
simulation time (years)
25
30
35
40
45
50
0 50 100 150 200 250
Figure 1. Heliocentric distance of Pluto
Celestial Computing with Numerit
page 1
The SLP96 Ephemeris
The SLP96 ephemeris consists of tables of Chebyshev polynomial coefficients which
represent the mean coordinates of the Sun, Moon and the planets Mercury, Venus, the
Earth-Moon barycenter, Mars, Jupiter, Saturn, Uranus and Neptune for the time span
1550-2350. They have been computed with the theories of the Bureau des Longitudes
(Paris) using VSOP87 for the Sun and planets, and ELP2000-82B for the Moon.
This ephemeris provides rectangular or spherical coordinates in either the equinox and
equator J2000 (FK5) or the equinox and ecliptic J2000 (dynamical). The fundamental time
argument of this ephemeris is Dynamical Barycentric Time (TDB).
Additional information about this ephemeris can be found in the following references:
P. Bretagnon and G. Francou, "Planetary Theories in Rectangular and Spherical Variables.
VSOP87 Solutions." Astronomy and Astrophysics, 202, 309, 1988.
M. Chapront-Touze and J. Chapront, "ELP 2000-85 : a Semi-analytical Lunar Ephemeris
Adequate for Historical Time", Astronomy and Astrophysics, 190, 342, 1988.
M. Chapront-Touze and J. Chapront, "The Lunar ephemeris ELP 2000", Astronomy and
Astrophysics, 124, 50, 1983.
This ephemeris in distributed in eight sequential ASCII files. Each file has the same
structure and contains Chebyshev ephemerides covering a century within the interval
1550-2350. The first record contains the ephemeris time span and description of the
Chebychev polynomials. The following records contain the tables of Chebyshev
coefficients which represent the coordinates of the Sun, Moon and eight planets.
These ASCII data files can be found on the Internet at ftp.bdl.fr/pub/ephem/sun/slp96.
Simply download one or more files into the Numerit subdirectory on your hard drive. This
Internet location also contains Fortran source code utility files and documentation.
The ASCII file names and corresponding time intervals are as follows:
SLP96.S16 1549 Dec 21 (JD2287184.5) to 1650 Jan 19 (JD2323728.5)
SLP96.S17 1649 Dec 18 (JD2323696.5) to 1750 Jan 07 (JD2360240.5)
SLP96.S18 1749 Dec 06 (JD2360208.5) to 1850 Jan 27 (JD2396784.5)
SLP96.S19 1849 Dec 26 (JD2396752.5) to 1950 Jan 15 (JD2433296.5)
SLP96.S20 1949 Dec 14 (JD2433264.5) to 2050 Jan 02 (JD2469808.5)
SLP96.S21 2049 Dec 01 (JD2469776.5) to 2150 Jan 22 (JD2506352.5)
SLP96.S22 2149 Dec 21 (JD2506320.5) to 2250 Jan 10 (JD2542864.5)
SLP96.S23 2249 Dec 09 (JD2542832.5) to 2350 Jan 30 (JD2579408.5)
Celestial Computing with Numerit
page 2
Precision
The precision of the SLP96 ephemerides can be estimated by the largest discrepancies
obtained with a comparison to the DE200 numerical integration which has been used for
the determination of the integration constants in the theories of the Bureau des Longitudes
(BDL). Information about the DE200 ephemeris can be found in "The Observational Basis
for JPL's DE200", E.M. Standish, Astronomy and Astrophysics, 233, 252.
Body 1650-1750 1750-1850 1850-1950 1950-2050 2050-2150
Mercury 0.03" 0.02" 0.01" 0.01" 0.02"
Venus 0.02" 0.02" 0.02" 0.01" 0.01"
Earth-Moon 0.04" 0.02" 0.02" 0.01" 0.02"
Mars 0.38" 0.21" 0.05" 0.04" 0.22"
Jupiter 0.38" 0.20" 0.09" 0.07" 0.11"
Saturn 0.46" 0.36" 0.22" 0.23" 0.51"
Uranus 0.14" 0.07" 0.06" 0.10" 0.19"
Neptune 1.10" 0.83" 0.23" 0.30" 0.51"
Moon 15.00" 9.20" 0.04" 0.03" 0.04"
program rwslp96
This Numerit program will read a single SLP96 ASCII data file and create the
corresponding binary data file. The software will interactively prompt you for the name of
ASCII input file and the binary output file. Be sure to include the file name extensions in
both responses.
function slp96
This function opens and processes the SLP96 binary file. It was ported to Numerit using
the Fortran source code subroutine provided by the BDL. The syntax and arguments of
this function are as follows:
function slp96(tjd, ibody, icent, ipv, iframe, icoord, result, ierr)
` solar, lunar and planetary coordinates j2000
` input
` tjd julian date tdb
` ibody body index
` ibody=01 : mercury ibody=07 : uranus
` ibody=02 : venus ibody=08 : neptune
` ibody=03 : e-m baryc. ibody=09 : void
` ibody=04 : mars ibody=10 : moon
` ibody=05 : jupiter ibody=11 : sun
` ibody=06 : saturn ibody=12 : earth
Celestial Computing with Numerit
page 3
` icent frame center index
` icent=00 : barycenter of solar system
` icent=01 : mercury icent=07 : uranus
` icent=02 : venus icent=08 : neptune
` icent=03 : e-m baryc. icent=09 : void
` icent=04 : mars icent=10 : moon
` icent=05 : jupiter icent=11 : sun
` icent=06 : saturn icent=12 : earth
` ipv position-velocity index
` ipv=1 : position.
` ipv=2 : position and velocity.
` iframe frame index
` iframe=1 : equinox and equator j2000 (fk5)
` iframe=2 : equinox and ecliptic j2000 (dynamical)
` icoord coordinates index
` icoord=1 : rectangular coordinates
` icoord=2 : spherical coordinates
` fname name of the slp96 data file
` output
` result results table
` rectangular coordinates (icoord = 1)
` position
` result[1] : equatorial or ecliptic component x (au)
` result[2] : equatorial or ecliptic component y (au)
` result[3] : equatorial or ecliptic component z (au)
` velocity
` result[4] : equatorial or ecliptic component x (au/day)
` result[5] : equatorial or ecliptic component y (au/day)
` result[6] : equatorial or ecliptic component z (au/day)
` spherical coordinates (icoord = 2)
` position
` result[1] : right ascension or longitude (radians)
` result[2] : declination or latitude (radians)
` result[3] : geometric distance (au)
` velocity
` result[4] : right ascension or longitude (rad/day)
` result[5] : declination or latitude (rad/day)
` result[6] : geometric distance (au/day)
` ierr error index
Celestial Computing with Numerit
page 4
` ierr=0 : no error
` ierr=10 : file error
` ierr=11 : date error (tjd)
` ierr=12 : body error (ibody)
` ierr=13 : frame center error (icent)
` ierr=14 : position-velocity error (ipv)
` ierr=15 : frame error (iframe)
` ierr=16 : coordinates error (icoord)
Please note that the unit of the position vector is Astronomical Units and for the velocity
vector Astronomical Units per day.
Initialization
The slp96 function requires initialization the first time it is called. The following
statement in the main program will accomplish this:
islp96 = 1
The slp96 function will set this "flag" to 0 after initialization. The value of islp96 is
passed to the slp96 function using a common islp96 statement in the main program.
Default File Name
The slp96 function will open a binary ephemeris file named slp96.bin by default.
You can change this by editing the statement binfile g = "slp96.bin" in the
slp96 function souce code.
Celestial Computing with Numerit
page 1
Apparent Coordinates of a Planet or the Moon
This program (demoapp) demonstrates how to read an SLP96 binary ephemeris file and
calculate the apparent topocentric and geocentric coordinates of a planet or the Moon.
This application uses several functions ported to Numerit using the Fortran versions of the
NOVAS (Naval Observatory Vector Astrometry Subroutines) source code which
was developed at the United States Naval Observatory.
This program includes the following types of coordinate corrections:
(1) precession
(2) nutation
(3) aberration
(4) gravitational deflection of light
Please note that this program does not include a correction for atmospheric refraction.
An excellent discussion about these corrections can be found in "Mean and Apparent
Place Computations in the New IAU System. III. Apparent, Topocentric, and Astrometric
Places of Planets and Stars", G.H. Kaplan, J.A. Hughes, P.K. Seidelmann, C.A. Smith and
B.D. Yallop, The Astronomical Journal, Vol. 97, No. 4, pages 1197-1210, 1989.
The processing steps used in this program are as follows:
(1) input a calendar date on the UT1 time scale
(2) compute the UT1 Julian date
(3) compute the TDT Julian date
(4) compute the TDB Julian date
(5) select the target body
(6) define type of coordinates
(7) evaluate the ephemeris
The syntax and arguments for this Numerit function are as follows:
function apparent(tjd, ujd, l, n, topo, glon, glat, ht, ra, dec, dis)
` this function computes the apparent geocentric or topocentric place
` of a planet or other solar system body. rectangular coordinates of
` solar system bodies are obtained from an slp96 binary data file.
` input
` tjd = tdt julian date for apparent geocentric place
` ujd = ut1 julian date for apparent topocentric place
` l = body identification number for desired planet
` n = body identification number for the earth
` topo = type of apparent place calculation
` = 0 => geocentric
Celestial Computing with Numerit
page 2
` = 1 => topocentric
` glon = geodetic longitude of observer (east +, degrees)
` glat = geodetic latitude of observer (north +, degrees)
` ht = height of observer (meters)
` output
` ra = apparent geocentric or topocentric right ascension,
` referred to true equator and equinox of date (hours)
` dec = apparent geocentric or topocentric declination,
` referred to true equator and equinox of date (degrees)
` dis = true distance from earth to planet (astronomical units)
The topocentric azimuth A and elevation (altitude) h are calculated using the topocentric
right ascension and declination and the observer's coordinates as follow:
(1)
tan A
sinH
cos Hsin tan cos
(2) sinhsin sin +cos cos cos H
where H is the apparent hour angle of the celestial object and is the geodetic latitude of
the observer. The apparent hour angle is given by the difference between the observer's
local sidereal time and the right ascension of the object as follows:
(3) H
In this program azimuth is measured positive clockwise from north. For example, east is
an azimuth of 90, south is 180 and so forth.
The demoapp software will prompt you for the calendar date, universal time, observer
coordinates, the "target" body and the type of ephemeris (topocentric or geocentric). The
program defaults to Earth as the central or "primary" body and the numerical indices for
the "target" bodies are as follows:
1 = Mercury
2 = Venus
3 = Earth-Moon barycenter
4 = Mars
5 = Jupiter
6 = Saturn
7 = Uranus
8 = Neptune
9 = void
10 = Moon
11 = Sun
12 = Earth
Celestial Computing with Numerit
page 3
The following is a typical draft output created with this program. It illustrates the
topocentric coordinates of Venus relative to Washington, DC on April 10, 1998, at 19
hours, 21 minutes UT.
topocentric apparent coordinates of a planet or the moon
Venus
Julian date 2450914.30625
calendar date April 10, 1998
universal time 19 h 21 m 00 s
observer latitude 38 d 55 m 17 s
observer longitude -77 d 3 m 56 s
observer altitude (m) 0
right ascension 22 h 26 m 12.1674 s
declination -9 d 31 m 33.9845 s
distance (AU) 0.7901488695394062
azimuth (degrees) 253 d 24 m 33.5455 s
elevation (degrees) 5 d 5 m 35.1261 s
A comparison with the MICA (Multiyear Interactive Computer Almanac) program gives
the following:
distance (AU) 0.790148825
azimuth (degrees) 253.409306
elevation (degrees) 5.09308333
Celestial Computing with Numerit
page 1
Apparent Coordinates of a Star
This program (demostar) demonstrates how to calculate the apparent topocentric and
geocentric coordinates of a star. This application uses several functions ported to Numerit
using the Fortran versions of the NOVAS (Naval Observatory Vector Astrometry
Subroutines) source code which was developed at the United States Naval Observatory.
The Earth ephemeris required for these calculations is based on SLP96.
This program includes the following types of coordinate corrections:
(1) precession
(2) nutation
(3) aberration
(4) gravitational deflection of light
(5) proper motion
(6) parallax
(7) radial velocity
Please note that this program does not include a correction for atmospheric refraction. For
extragalatic objects the proper motions, parallax and radial velocity should all be set to 0.
An excellent discussion about these corrections can be found in "Mean and Apparent
Place Computations in the New IAU System. III. Apparent, Topocentric, and Astrometric
Places of Planets and Stars", G.H. Kaplan, J.A. Hughes, P.K. Seidelmann, C.A. Smith and
B.D. Yallop, The Astronomical Journal, Vol. 97, No. 4, pages 1197-1210, 1989.
The processing steps used in this program are as follows:
(1) input a calendar date on the UT1 time scale
(2) compute the UT1 Julian date
(3) compute the TDT Julian date
(4) compute the TDB Julian date
(5) read the star's coordinates, proper motions, parallax and radial velocity
(6) define type of coordinates
(7) calculate apparent coordinates
The syntax and arguments for this Numerit function are as follows:
function apstar (tjd, ujd, topo, glon, glat, ht, ram, decm, pmra, pmdec, \
parlax, radvel, ra, dec)
` this subroutine computes the geocentric or topocentric apparent place
` of a star, given its mean place, proper motion, parallax, and radial
` velocity for j2000.0.
` input
` tjd = tdt julian date for apparent place
Celestial Computing with Numerit
page 2
` ujd = ut1 julian date for apparent topocentric place
` topo = type of apparent place calculation
` = 0 ==> geocentric
` = 1 ==> topocentric
` glon = geodetic longitude of observer (east +, degrees)
` glat = geodetic latitude of observer (north +, degrees)
` ht = height of observer (meters)
` ram = mean right ascension j2000.0 (hours)
` decm = mean declination j2000.0 (degrees)
` pmra = proper motion in ra (seconds of time/julian century)
` pmdec = proper motion in dec (seconds of arc/julian century)
` parlax = parallax (seconds of arc)
` radvel = radial velocity (kilometers per second)
` output
` ra = apparent geocentric or topocentric right ascension,
` referred to true equator and equinox of date (hours)
` dec = apparent geocentric or topocentric declination,
` referred to true equator and equinox of date (degrees)
The topocentric azimuth A and elevation (altitude) h are calculated using the topocentric
right ascension and declination and the observer's coordinates as follow:
(1)
tan A
sinH
cos Hsin tan cos
(2) sinhsin sin +cos cos cos H
where H is the apparent hour angle of the celestial object and is the geodetic latitude of
the observer. The apparent hour angle is given by the difference between the observer's
local sidereal time and the right ascension of the object as follows:
(3) H
In this program azimuth is measured positive clockwise from north. For example, east is
an azimuth of 90, south is 180 and so forth.
The demoapp software will prompt you for the calendar date, universal time, observer
coordinates, the name of the star data file and the type of ephemeris (topocentric or
geocentric). The following is a typical star data file. Do not delete any lines of text or data
as the software expects to find 20 lines of information.
star name
ALTAIR
J2000 right ascension (hours)
19.8463894440
J2000 declination (degrees)
8.8683416670
J2000 proper motion in right ascension (seconds/Julian century)
3.6290
Celestial Computing with Numerit
page 3
J2000 proper motion in declination (arcseconds/Julian century)
38.6300
parallax (arcseconds)
0.1981
radial velocity (kilometers/second)
-26.30
The following is a typical draft output created with this program. It illustrates the
topocentric coordinates of Altair relative to a sea level observer at 40 north latitude and
105 west longitude, at 0 hours UT.
topocentric apparent coordinates of a star
ALTAIR
Julian date 2450814.5
calendar date January 1, 1998
universal time 00 h 00 m 00 s
observer latitude 40 d 00 m 00 s
observer longitude -105 d 00 m 00 s
observer altitude (m) 0
right ascension 19 h 50 m 39.1674 s
declination 8 d 51 m 46.0857 s
azimuth (degrees) 255 d 13 m 1.43833 s
elevation (degrees) 30 d 10 m 14.9575 s
A comparison with the MICA (Multiyear Interactive Computer Almanac) program gives
the following:
azimuth (E of N) 255 13 02.9
zenith distance 59 49 35.0
where the units are degrees, minutes and seconds.
Celestial Computing with Numerit
page 1
Predicting Celestial Events: Part 1
This Numerit program (demoevt1) demonstrates how to calculate extrema type celestial
events. These are events which involve the minimum or maximum of a scalar objective
function. Typical extrema events include apogee and perigee of the Moon, aphelion and
perihelion of a planet , minimum angular separation between two planets, and closest
approach between two planets.
This demonstration program calculates the calendar date, universal time and heliocentric
distance, in Astronomical Units, for aphelion and perihelion of Mars. It uses a
one-dimensional optimization algorithm due to Richard Brent to solve this problem.
Additional information about this numerical method can be found in Algorithms for
Minimization Without Derivatives, R.P. Brent, Prentice-Hall, 1972. As the title of this
book indicates, this algorithm does not require derivatives of the objective function. This
feature is important because the analytic first derivative of many objective functions is
difficult to derive and code.
The Mars ephemeris used in this program is based on the numerical method described in
the technical paper "Low-Precision Formulae for Planetary Positions", T. C. Van Flandern
and K. F. Pulkkinen, The Astrophysical Journal Supplement Series, 41:391-411,
November 1979. The syntax of this Numerit ephemeris function is as follows:
function mars (jdate, rmars)
` true-of-date heliocentric, ecliptic
` position vector of Mars
` input
` jdate = julian day
` output
` rmars = position vector of mars (km)
The following is the main part of the source code of this demonstration program with
several explanatory comments.
The program begins by interactively requesting the initial calendar date as follows:
` request initial calendar date
cdate = "1,1,1998"
getdate(cdate, month, day, year)
It also request the simulation duration in days with this next prompt:
` request simulation duration (days)
Celestial Computing with Numerit
page 2
input " simulation duration (days) ?" ndays
The software calculates the initial Julian date as follows:
` initial julian date
jdate0 = 0
julian(month, day, year, jdate0)
This next section of the code defines the search and function step sizes. The search step
size dt tells the algorithm how far to move when looking for a function extrema and the
function step size dtsml tells the algorithm how far to move when looking for an
increase (or decrease) in the objective function value.
` define search parameters (days)
dt = 30
dtsml = 0.1
The software then initializes a objective function multiplier flag with the next statement.
` set initial value of objective function multiplier
ofm = 1
The numerical value of this global flag determines if the minimum (ofm = 1) or
maximum (ofm = -1) value of the objective function is used during the event search.
Notice that the maximum is equal to the negative of the minimum.
This next section of the code defines the initial and final times of the search interval.
Notice that ti is the initial Julian date of the search and tf is the final Julian date or
simply the sum of the initial Julian date and the search interval (in days).
` find events
ti = jdate0
tf = jdate0 + ndays
The actual search is performed by the following statements:
` redirect objective and events routines
objfunc -> objfunc1
events -> events1
oevent1 (ti, tf, dt, dtsml)
The search function oevent1 requires both a function which evaluates the user-defined
scalar objective value and a function which displays the circumstances of the celestial
Celestial Computing with Numerit
page 3
events. Notice how we have "rerouted" the names of both the objective (objfunc1) and
event (events1) functions prior to calling the main routine which searches for the
events. Rerouting is a powerful feature unique to Numerit Pro.
Choosing the Search Parameters
The proper selection of the search parameters dt and dtsml depends on the type of
celestial event you are trying to predict. For example, the value of dt depends on how
often the event occurs. For planetary events which happen once per orbital period
(aphelion, perihelion, etc.), a good value for dt is one fourth of the planet's orbital period.
When calculating events involving two planets, one should use one fourth of the smaller of
the two orbital periods. This same technique can be used when predicting lunar events.
For the Moon dt should be about 7 to 8 days. Be careful not to make dt too large or the
algorithm may "step over" one or more solutions.
The value of dtsml must be selected such that it produces a "big" enough change in the
objective function to tell the algorithm in what direction to move. This is similar to
choosing the value of x when numerically estimating the derivative of a function of the
form y = f(x). For planetary events a value of dtsml = 0.1 days should be adequate.
For lunar events this number should be a number between 0.01 and 0.05 days. An
examination of a plot of the objective function over a period of time can also provide
insight into the proper selection of the dtsml parameter.
The Numerit function which solves this problem has the following syntax and arguments:
function oevent1 (ti, tf, dt, dtsml)
` predict "extrema" type celestial events
` input
` ti = initial simulation time
` tf = final simulation time
` dt = step size used for bounding minima
` dtsml = small step size used to determine whether
` the function is increasing or decreasing
During the search for events, this function calls a function named minima which
calculates the extremum of a one-dimensional user-defined objective function. The syntax
of this optimization function is as follows:
function minima (a, b, tolm, xmin, fmin)
` one-dimensional minimization function
` Brent's method
` input
Celestial Computing with Numerit
page 4
` a = initial x search value
` b = final x search value
` tolm = convergence criterion
` output
` xmin = minimum x value
` fmin = minimum function value
This function requires an objective function coded as name(x, fx) where x is the
current function argument, fx is the scalar value of the objective function evaluated at x
and name is the name of the user-defined function.
The source code of the objective function for this example is as follows:
function objfunc1(x, fx)
` objective function
` heliocentric distance of Mars
` input
` x = function argument
` output
` fx = function value at x
` Celestial Computing with Numerit
``````````````````````````````````
mars (x, rmars)
fx = %ofm * sqrt(rmars[1]^2 + rmars[2]^2 + rmars[3]^2)
This code simply calculates the scalar heliocentric distance of Mars, in kilometers, fx as a
function of the Julian date argument x. Notice the use of the global "flag" %ofm which
determines whether a minimum (%ofm = 1) or maximum (%ofm = -1) is calculated.
The objective function is given by the expression
(1) f (t) r
2
x
(t) +r
2
y
(t) + r
2
z
(t)
where r
x
, r
y
and r
z
are the rectangular, heliocentric position components of Mars at any
search time t.
Finally, the function oevent1 requires another function named events1 which displays
the circumstances of each celestial event. The function source code for this example is as
follows:
Celestial Computing with Numerit
page 5
function events1 (ti, tf, topt)
` display circumstances of celestial events
` input
` ti = initial simulation time
` tf = final simulation time
` topt = extrema time
` Celestial Computing with Numerit
``````````````````````````````````
` compute and display conditions at extrema
objfunc(topt, froot)
gdate(topt, month, day, year)
thours = 24 * (day - trunc(day))
println; println
if (%ofm = 1)
println "perihelion of Mars"
else
println "aphelion of Mars"
println
prtdate(month, day, year)
println
prttime(thours)
println
outprec 16
println "heliocentric distance (AU) = ", abs(froot) / 149597870.66
` toggle objective function multiplier
%ofm = -%ofm
Notice how this function "toggles" the objective function multiplier flag %ofm after each
solution is displayed. This function must be coded as name(ti, tf, topt) where name
is the name of the user-defined function. The function parameters should be exactly as
they're shown here.
The following is a typical draft output created with this program. The initial calendar date
was January 1, 1998 and the search interval was 1000 days.
perihelion of Mars
November 25, 1999
Celestial Computing with Numerit
page 6
11 h 58 m 58.2184 s
heliocentric distance (AU) = 1.381540000311672
aphelion of Mars
November 2, 2000
23 h 58 m 35.0212 s
heliocentric distance (AU) = 1.665880000345205
Celestial Computing with Numerit
page 1
Predicting Celestial Events: Part 2
This Numerit program (demoevt2) demonstrates how to calculate root-finding types of
celestial events. These are events which involve finding the roots of a scalar objective
function which is typically a function of time. The roots of an objective function are the
points where the value of the user-defined function is zero. Since most celestial events are
a function of time, a variety of important and unique events can be calculated using this
technique. Typical root-finding events include rise and set of the Moon (this example),
planet or star, the time of the seasons , lunar occultations, transits of Mercury and Venus
and local circumstances of solar and lunar eclipses.
The basic procedure for predicting these types of events involves the following steps and
Numerit functions:
(1) locate an extremum using the functions oevent2 and minima
(2) bracket a "forward" and "backward" root using the function broot
(3) find each root using the function brent
(4) calculate the event circumstances with a user-coded function
(5) display the event circumstances with a second user-coded function
The main Numerit function which solves this type of problem has the following syntax
and arguments:
function oevent2 (ti, tf, dt, dtsml)
` predict root-finding type celestial events
` input
` ti = initial simulation time
` tf = final simulation time
` dt = step size used for bounding minima
` dtsml = small step size used to determine whether
` the function is increasing or decreasing
The search function oevent2 requires both a function which evaluates the user-defined
scalar objective value and a function which displays the circumstances of the celestial
events. The main program "reroutes" the names of both the objective and event functions
prior to calling the oevent2 function which searches for the events. Rerouting is a
powerful feature unique to Numerit Pro. The user must write the source code for both of
these support functions.
For this example the code which does the rerouting is as follows:
objfunc -> rsfunc
events -> rsevents
Celestial Computing with Numerit
page 2
Choosing the Search Parameters
The proper selection of the search parameters dt and dtsml for this algorithm depends
on the type of celestial event you are trying to predict. For example, the value of dt
depends on how often the event occurs. For planetary events which happen once per
orbital period (aphelion, perihelion, etc.), a good value for dt is one fourth of the planet's
orbital period. When calculating events involving two planets, one should use one fourth
of the smaller of the two orbital periods. This same technique can be used when predicting
lunar events. For the Moon dt should be about 0.25 days. Be careful not to make dt too
large or the algorithm may "step over" one or more solutions.
The value of dtsml must be selected such that it produces a "big" enough change in the
objective function to tell the algorithm in what direction to move. This is similar to
choosing the value of x when numerically estimating the derivative of a function of the
form y = f(x). For planetary events a value of dtsml = 0.1 days should be adequate.
For lunar events this number should be a number between 0.01 and 0.05 days. An
examination of a plot of the objective function over a period of time can also provide
insight into the proper selection of the dtsml parameter.
During the search process the oevent2 function calls a function named minima which
calculates the extremum of a one-dimensional user-defined objective function. The syntax
of this optimization function is as follows:
function minima (a, b, tolm, xmin, fmin)
` one-dimensional minimization function
` Brent's method
` input
` a = initial x search value
` b = final x search value
` tolm = convergence criterion
` output
` xmin = minimum x value
` fmin = minimum function value
This function in turn requires an objective function coded as name(x, fx) where x is
the current function argument, fx is the objective function evaluated at x and name is the
actual name of the user-coded function. The function argument is usually the time, either
as a Julian date or perhaps time since a simulation began. The function value fx might be
geocentric declination, the separation angle between two celestial bodies, the scalar
distance between two objects and so forth.
Celestial Computing with Numerit
page 3
The source code of the objective function for this example is as follows:
function rsfunc(x, fx)
` topocentric elevation angle objective function
` input
` x = simulation time argument
` output
` y = topocentric elevation angle
` with any constraint (radians)
` (-pi/2 <= elev <= +pi/2)
` Celestial Computing with Numerit
``````````````````````````````````
jed = x + %jed0
` eci position vector of observer
observer(jed, robs)
` eci position vector of the Moon
moon(jed, rmoon)
` eci vector from observer to Moon
obs2moon = rmoon - robs
` observer-to-Moon slant range
srange = sqrt(obs2moon[1]^2 + obs2moon[2]^2 + obs2moon[3]^2)
` compute topocentric unit pointing vector
upv = obs2moon / srange
` calculate elements of transformation matrix
tmatrix[1, 1] = %sobslat * %cobslst
tmatrix[1, 2] = %sobslat * %sobslst
tmatrix[1, 3] = -%cobslat
tmatrix[2, 1] = -%sobslst
tmatrix[2, 2] = %cobslst
tmatrix[2, 3] = 0
tmatrix[3, 1] = %cobslat * %cobslst
tmatrix[3, 2] = %cobslat * %sobslst
tmatrix[3, 3] = %sobslat
` perform matrix-vector multiplication
for i = 1 to 3
a = 0
for j = 1 to 3
a = a + tmatrix[i, j] * upv[j]
Celestial Computing with Numerit
page 4
lv[i] = a
` topocentric elevation angle (radians)
` (center of the Moon)
%elev = asin(lv[3])
if (%rootflg = 1)
` apply semidiameter and refraction corrections
dref = (34 / 60) * pi / 180
tsdia = asin(1738 / srange)
else
` refraction correction
elevd = %elev * 180 / pi
if (elevd >= 0)
dtr = pi / 180
dref = dtr * 1.02 / (tan(dtr * (elevd + 10.3 / (elevd +
5.11)))) / 60
tsdia = 0
fx = -(%elev + dref + tsdia)
` topocentric azimuth angle (radians)
%azim = atan3(lv[2], -lv[1])
Variables preceded with % are global items computed either in the main program or in
other support or utility functions. Notice the use of a root flag %rootflg to "toggle" the
function when finding a minimum (%rootflg = 0) or a root (%rootflg = 1). The
value of this flag is set by the rsevents function which is described later. When
searching for a root the algorithm corrects for the semidiameter of the Moon and the
atmospheric refraction at the horizon.
This function calculates the topocentric elevation angle of the Moon for any input
argument x. For this example the input argument is the elapsed time in days since the
simulation began. The lunar ephemeris used in this function is based on the algorithms
described in the book Lunar Tables and Programs From 4000 B.C. To A.D. 8000 by
Michelle Chapront-Touze and Jean Chapront. This book and (optional) companion
software are available from Willmann-Bell (www.willbell.com). This algorithm has been
coded in Numerit is a function called moon.
This function includes a simple topocentric elevation angle correction for atmospheric
refraction based on the algorithm described in Chapter 15 of Astronomical Algorithms by
Jean Meeus.
Celestial Computing with Numerit
page 5
The syntax of the function which calculates and displays the actual roots of the
user-defined objective function is as follows:
function rsevents (ti, tf, topt)
` compute and display root-finding celestial events
` input
` ti = initial simulation time
` tf = final simulation time
` topt = extrema time
` Celestial Computing with Numerit
``````````````````````````````````
` define root-bracketing and root-finding control parameters
factor = 0.25 ` geometric acceleration factor
dxmax = 0.1
rtol = 0.00000001 ` convergence tolerance
` compute and display event start conditions
%rootflg = 1
t1in = topt
t2in = t1in - 0.05
broot(t1in, t2in, factor, dxmax, t1out, t2out)
brent(t1out, t2out, rtol, troot, froot)
` set to initial time if before ti
if (troot < ti)
troot = ti
objfunc(ti, froot)
prtfunc(1, troot)
` compute and display conditions at optimum
%rootflg = 0
objfunc(topt, froot)
prtfunc(2, topt)
` compute and display event end conditions
%rootflg = 1
t2in = t1in + 0.05
broot(t1in, t2in, factor, dxmax, t1out, t2out)
brent(t1out, t2out, rtol, troot, froot)
Celestial Computing with Numerit
page 6
` set to final time if after tf
if (troot > tf)
troot = tf
objfunc(tf, froot)
prtfunc(3, troot)
%rootflg = 0
%trr = troot
The last line of this function "saves" the forward root which is made available to the
oevent2 function with a common trr statement at the beginning of the main program.
This technique forces the event-finding routine to continue the search after the forward
root is calculated which speeds up the process.
The rsevents function is a "driver" routine which uses the time of the extremum topt
to first bracket the backward and forward roots and then actually find the value of each
root. After each root is calculated this routine calls a function which displays the event
conditions.
For this example the Numerit source code listing is
function rsprint(ip, x)
` print rise/set event conditions
println; println
case ip
1:
println "rise conditions"
2:
println "maximum elevation conditions"
3:
println "set conditions"
jed = %jed0 + x
dt = (-15 + 32.5 * ((jed - 2378497) / 36525 - 0.1) ^ 2) / 86400
jdate = jed - dt
gdate(jdate, month, day, year)
thours = 24 * (day - trunc(day))
println
prtdate(month, trunc(day), year)
prttime(thours)
Celestial Computing with Numerit
page 7
print "elevation = ", %elev * 180 / pi; println "degrees"
print "azimuth = ", %azim * 180 / pi; println "degrees"
The ip "flag" determines which event is displayed. This flag is set by the rsevents
function.
The following is a brief description of the function which brackets each root.
function broot
This function can be used to bracket a single root of a single nonlinear equation of the
form yf (x). It uses a combination of geometric acceleration and rectification to bracket
single roots. The basic idea is to find the endpoints of an interval x
1
and x
2
such that
f (x
1
) f (x
2
) <0. This condition guarantees that there is at least one root in the interval
because the objective function changes sign.
The user must supply this function with an initial guess for x
1
and x
2
. Typically x
1
is the
time of an objective function minimum or maximum and x
2
is a time 0.05 days after
(forward root) or 0.05 days before (backward root) the value of x
1
.
The syntax of this Numerit function is as follows:
function broot (x1in, x2in, factor, dxmax, x1out, x2out)
` bracket a single root of a nonlinear equation
` input
` x1in = initial guess for first bracketing x value
` x2in = initial guess for second bracketing x value
` factor = acceleration factor (non-dimensional)
` dxmax = rectification interval
` output
` x1out = final value for first bracketing x value
` x2out = final value for second bracketing x value
The acceleration factor used in this demonstration program is 0.25 and the rectification
interval is 0.1 days. The acceleration factor increases the size of each step geometrically
and the rectification interval monitors the length of the current bracketing interval. When
necessary the rectification logic reinitializes the search and prevents the interval from
becoming too large and skipping one or both ends of the bracketing interval completely.
The size of each step increases geometrically until the length of the current step reaches
the value of the rectification interval. At that point the step size is reset and the process
begins again. Eventually, the process will bracket the root and the function will return the
endpoints of this bracketing interval.
Celestial Computing with Numerit
page 8
The following is a brief description of the function which solves for each root.
function brent
This function uses Brent's method to find a single root of a single nonlinear equation of the
form y f (x). Analytic derivatives are not required for this algorithm. However, the user
should ensure that a root is bracketed before calling this routine. Whenever a root is
bracketed the following condition is satisfied; f (x
1
) f (x
2
) < 0. This inequality implies that
the sign of the function has changed between x
1
to x
2
.
Additional information about this numerical method can be found in Algorithms for
Minimization Without Derivatives, R. P. Brent, Prentice-Hall, 1972. As the title of this
book indicates, this algorithm does not require derivatives of the objective function. This
feature is important because the analytic first derivative of many objective functions is
difficult to derive and code.
The syntax and arguments of this function are
function brent (x1, x2, rtol, xroot, froot)
` solve for a single real root of a nonlinear equation
` Brent's method
` input
` x1 = lower bound of search interval
` x2 = upper bound of search interval
` rtol = algorithm convergence criterion
` output
` xroot = real root of f(x) = 0
` froot = function value at f(x) = 0
The root-finding performance of this algorithm is determined by rtol. A value of
1.0e-8 should be adequate for most problems. Smaller values will predict roots more
accurately at the expense of longer program execution times.
The program will prompt you for an initial calendar date and search interval in days. It will
also ask you for the geographic coordinates of the observer. Please note that north
latitudes are positive and south latitudes are negative. Also note that east longitudes are
positive and west longitudes are negative. Furthermore, observer sites above sea level
have positive altitudes and sites below sea level are negative.
Celestial Computing with Numerit
page 9
The following is an example of several rise and sets of the Moon calculated with this
program. The initial calendar date was January 1, 1998, and the observer was located at
40 north latitude and 105 west longitude. The altitude of the site was 0 meters. The
calendar date and time displayed is on the UTC time scale.
rise and set of the Moon
rise conditions
January 1, 1998
16 h 27 m 3.46372 s
elevation = -0.83556 degrees
azimuth = 107.274 degrees
maximum elevation conditions
January 1, 1998
21 h 55 m 48.8168 s
elevation = 36.9326 degrees
azimuth = 180.749 degrees
set conditions
January 2, 1998
3 h 25 m 21.8616 s
elevation = -0.835934 degrees
azimuth = 254.835 degrees
rise conditions
January 2, 1998
17 h 7 m 18.9669 s
elevation = -0.836224 degrees
azimuth = 102.286 degrees
maximum elevation conditions
January 2, 1998
22 h 49 m 50.9979 s
elevation = 40.9287 degrees
azimuth = 180.884 degrees
set conditions
January 3, 1998
4 h 33 m 47.4062 s
elevation = -0.836327 degrees
azimuth = 260.287 degrees
Celestial Computing with Numerit
page 1
Predicting Lunar Eclipses
This Numerit program (eclipse) can be used to predict lunar eclipses. The source
ephemeris for this program is SLP96. This software provides the eclipse type, the
universal times and topocentric coordinates of the Moon at the beginning and end of the
penumbra contacts, and the time and coordinates at maximum eclipse.
This program uses a combination of one-dimensional minimization and root-finding to
solve this classic problem. The objective function used in these calculations involves the
geocentric separation angle between the center of the Moon and the anti-Sun position
vector or shadow axis, and the semidiameter and horizontal parallax of the Sun and Moon.
The objective function used during the search for lunar eclipses is given by the following
expression:
(1) f (t) cos
1
(U
m
U
s
) f
1
+ s
m
where
U
s
geocentric unit position vector of the Sun
U
m
geocentric unit position vector of the Moon
f
1
1.02(
1
+
s
+ s
s
) size of penumbra shadow

1
0.99834
m
corrected parallax

m
horizontal parallax of the Moon

s
horizontal parallax of the Sun
s
m
semidiameter of the Moon
s
s
semidiameter of the Sun
In these expressions
(2)

m
sin
1



r
eq
d
m
_ _

, ,

s
sin
1



r
eq
d
s
_ _

, ,
s
m
sin
1



r
m
d
m
_ _

, ,
s
s
sin
1



r
s
d
s
_ _

, ,
where r
eq
is the equatorial radius of the Earth (6378.14 kilometers), r
m
is the radius of the
Moon (1738 kilometers), r
s
is the radius of the Sun (696,000 kilometers), d
m
is the
geocentric distance of the Moon and d
s
is the geocentric distance of the Sun.
If we let represent the minimum geocentric separation angle of the Moon relative to the
shadow axis, a penumbral lunar eclipse occurs whenever the following geometric
condition is satisfied:
Celestial Computing with Numerit
page 2
(3) < 1.02(
1
+
s
+ s
s
) + s
m
A partial lunar eclipse will happen whenever the following is true:
(4) < 1.02(
1
+
s
s
s
) + s
m
Finally, the geometric condition for a total lunar eclipse is given by
(5) < 1.02(
1
+
s
s
s
) s
m
The following is a typical draft output created with this program. It illustrates the
circumstances of the penumbral lunar eclipse of March 13, 1998. The topocentric
coordinates correspond to an observer located in Denver, Colorado.
penumbral lunar eclipse
begin penumbral phase of lunar eclipse
calendar date March 13, 1998
universal time 2 h 14 m 16.8698 s
UTC Julian date 2450885.593250808
lunar azimuth angle 97 d 31 m 43.799 s
lunar elevation angle 14 d 44 m 12.6553 s
greatest eclipse conditions
calendar date March 13, 1998
universal time 4 h 20 m 1.9293 s
UTC Julian date 2450885.680577886
lunar azimuth angle 121 d 37 m 55.0332 s
lunar elevation angle 36 d 37 m 56.4931 s
end penumbral phase of lunar eclipse
calendar date March 13, 1998
universal time 6 h 25 m 49.395 s
UTC Julian date 2450885.767932812
lunar azimuth angle 159 d 57 m 20.5276 s
lunar elevation angle 51 d 31 m 55.7293 s
event duration 4 h 11 m 32.5252 s
Celestial Computing with Numerit
page 1
Predicting Solar Eclipses
This Numerit program (seclipse) can be used to predict the local circumstances of
solar eclipses relative to an observer anywhere on the Earth. The source ephemeris for this
program is SLP96. This software provides the eclipse type, the universal times and
topocentric coordinates of the Moon at the beginning and end of the penumbra contacts,
and the time and coordinates at maximum eclipse.
This program uses a combination of one-dimensional minimization and root-finding to
solve this classic problem. The objective function used in these calculations involves the
selenocentric separation angle between the axis of the shadow cast by the Moon and an
Earth observer. The objective function used during the search for solar eclipses is given by
the following expression:
(1) f (t) cos
1
(U
axis
U
mo
)
p
where
U
axis
selenocentric unit vector of the Moon's shadow
U
mo
selenocentric unit position vector of the observer

p
penumbra shadow angle
The penumbra shadow angle at the distance of the Earth observer is determined from
(2)
p
sin
1



r
m
d
m
_ _

, ,
+ sin
1




r
s
+ r
m
d
ms
_ _


, ,
In this expression r
m
is the radius of the Moon (1738 kilometers), r
s
is the radius of the
Sun (696,000 kilometers), d
m
is the topocentric distance of the Moon and d
ms
is the
distance from the Moon to the Sun.
The selenocentric position vector of the Sun is computed from the expression
(3)
r
ms
r
s
r
m
where r
s
is the geocentric position vector of the Sun and r
s
is the geocentric position
vector of the Moon.
This software uses a special version of the Numerit minimization event prediction
algorithm. Whenever the program finds a minimum it also checks to see if the topocentric
elevation angle of the center of the Moon is positive. This check insures that the solar
eclipse is visible to the Earth observer. If this condition is true, the software then uses
Brent's root-finding algorithm to calculate the event begin and end times and the
topocentric coordinates of the Moon.
Celestial Computing with Numerit
page 2
The following is a typical draft output created with this program. It illustrates the local
circumstances of the solar eclipse of May 10, 1994. It is based on the example given on
page 203 of the book Astronomy on the Personal Computer, Second Edition by Oliver
Montenbruck and Thomas Pfleger.
begin penumbral phase of solar eclipse
calendar date May 10, 1994
universal time 17 h 50 m 46.4522 s
UTC Julian date 2449483.243593196
lunar azimuth angle 280 d 49 m 9.55257 s
lunar elevation angle 15 d 58 m 41.317 s
greatest eclipse conditions
calendar date May 10, 1994
universal time 18 h 58 m 33.9913 s
UTC Julian date 2449483.290671196
lunar azimuth angle 289 d 27 m 56.576 s
lunar elevation angle 2 d 51 m 50.4514 s
end penumbral phase of solar eclipse
calendar date May 10, 1994
universal time 19 h 59 m 18.4396 s
UTC Julian date 2449483.33285231
lunar azimuth angle 297 d 56 m 2.06632 s
lunar elevation angle -8 d 14 m 35.518 s
event duration 2 h 8 m 31.9875 s
Celestial Computing with Numerit
page 1
Predicting Lunar Occultations
This Numerit program (occult) can be used to predict the local circumstances of lunar
occultations of a planet and star. The source ephemeris for this program is SLP96. This
software provides the universal times and topocentric coordinates of the Moon at the
beginning and end of the lunar occultation. It also displays the event duration.
This program uses a combination of one-dimensional minimization and root-finding to
solve this classic problem. The objective function used in these calculations is the
topocentric separation angle between the center of the Moon and the object being
occulted. The objective function used during the search for lunar eclipses is given by the
following expression:
(1) f (t) cos
1
(U
m
U
b
) (s
m
+ s
b
)
where
U
m
topocentric unit position vector of the Moon
U
b
topocentric unit position vector of the object
s
m
semidiameter of the Moon
s
b
semidiameter of the object
The semidiameter of the Moon is given by
(2) s
m
sin
1



r
m
d
m
_ _

, ,
where r
m
is the radius of the Moon (1738 kilometers) and d
m
is the topocentric distance of
the Moon.
The semidiameter of a star is zero and the semidiameter of a planet is
(3) s
p

s
p
0
r
p
where s
p
0
is the semidiamter of the planet at a distance of 1 astronomical unit and r
p
is the
topocentric distance of the planet.
Celestial Computing with Numerit
page 2
The following is a typical draft output created with this program. It illustrates a lunar
occultation of the star Spica relative to an observer located in Denver, Colorado.
Lunar occultation of a star
begin lunar occultation
calendar date February 18, 1987
universal time 12 h 27 m 3.88759 s
UTC Julian date 2446845.018794995
lunar azimuth angle 214 d 3 m 46.6015 s
lunar elevation angle 32 d 51 m 54.5059 s
end lunar occultation
calendar date February 18, 1987
universal time 13 h 17 m 45.9234 s
UTC Julian date 2446845.054003743
lunar azimuth angle 226 d 5 m 11.8468 s
lunar elevation angle 26 d 32 m 29.9466 s
event duration 00 h 50 m 42.0358 s
star name
SPICA
J2000 right ascension (hours)
13.4198852780
J2000 declination (degrees)
-11.1613083330
J2000 proper motion in right ascension (seconds/Julian century)
-0.2780
J2000 proper motion in declination (arcseconds/Julian century)
-2.8300
parallax (arcseconds)
0.0210
radial velocity (kilometers/second)
1.0
Celestial Computing with Numerit
page 1
Predicting Transits of Mercury and Venus
This Numerit program (transit) can be used to predict the local circumstances of
transits of Mercury and Venus. The source ephemeris for this program is SLP96. This
software provides the the universal times and topocentric coordinates of the Sun at
ingress, least separation distance and egress. The ingress and egress conditions correspond
to exterior contact.
This program uses a combination of one-dimensional minimization and root-finding to
solve this classic problem. The objective function used in these calculations is the
topocentric separation angle between the center of the Sun and the planet in transit.
The objective function used during the search for transits of Mercury and Venus is given
by the following expression:
(1) f (t) cos
1
(U
s
U
p
) (s
s
+ s
p
)
where
U
s
geocentric unit position vector of the Sun
U
p
geocentric unit position vector of the planet
s
s
semidiameter of the Sun
s
p
semidiameter of the planet
The semidiameter of the Sun is given by
(2) s
s
(t) sin
1



r
s
d
s
_ _

, ,
where r
s
is the radius of the Sun (696,000 kilometers) and d
s
is the topocentric distance of
the Sun at any search time t.
The semidiameter of Mercury and Venus is determined from the expression
(3) s
p

s
p
0
r
p
where s
p
0
is the semidiamter of the planet at a distance of 1 astronomical unit and r
p
is the
topocentric distance of the planet. This program uses a value of 3.36 arcseconds for
Mercury and 8.41 arcseconds for Venus.
Celestial Computing with Numerit
page 2
The following is a typical draft output created with this program. It is Example 6 from the
book Transits by Jean Meeus.
Transit of Venus
ingress - exterior contact
calendar date June 5, 2012
universal time 22 h 3 m 44.5196 s
UTC Julian date 2456084.419265273
solar azimuth angle 279 d 5 m 5.26833 s
solar elevation angle 25 d 56 m 12.8208 s
least distance conditions
calendar date June 6, 2012
universal time 1 h 26 m 9.99654 s
UTC Julian date 2456084.559837923
solar azimuth angle 309 d 47 m 3.49342 s
solar elevation angle -9 d 39 m 3.1792 s
egress - exterior contact
calendar date June 6, 2012
universal time 4 h 50 m 59.9329 s
UTC Julian date 2456084.702082557
solar azimuth angle 355 d 49 m 16.1755 s
solar elevation angle -28 d 16 m 40.7003 s
event duration 6 h 47 m 15.4133 s
Celestial Computing with Numerit
page 1
Cowell's Method for Heliocentric Orbits
This Numerit program (cowell) demonstrates heliocentric orbit propagation of
spacecraft, asteroid or comet motion using a classic technique called Cowell's method.
Cowell's method numerically integrates the orbital equations of motion. This program
includes the point mass gravity perturbations due to the planets Venus, Earth, Mars,
Jupiter, and Saturn. The planetary ephemerides used in this program are computer
implementations of the numerical method described in "Low-Precision Formulae for
Planetary Positions", T. C. Van Flandern and K. F. Pulkkinen, The Astrophysical Journal
Supplement Series, 41:391-411, November 1979.
The second-order heliocentric equations of motion of a satellite or celestial body subject
to the point mass gravitational attraction of the Sun and planets are given by
(1)
d
2
r
dt
2
(r, t)
s
r
sb
r
sb
3

9

p
i





r
(pb)
i
r
(pb)
i
3
+
r
p
i
r
p
i
3
_ _



, ,
i 1

where

s
gravitational constant of the Sun

p
i
gravitational constant of planet i
r
p
i
position vector from the Sun to planet i
r
sb
position vector from the Sun to the body
r
(pb)
i
position vector from planet i to the body
These position vectors are related according to
(2)
r
sb
r
p
+ r
pb
This Numerit program uses a Runge-Kutta-Fehlberg 7(8) method to numerically integrate
the first-order form of the orbital equations of motion. This is a variable step size method
of order 7 with an 8
th
order error estimate which is used to dynamically change the
integration step size during the simulation. The user can control how well the equations
are solved by specifying a truncation error tolerance.
The syntax of this Numerit function is as follows:
function rkf78 (neq, ti, tf, h, tetol, x, xout)
` solve first order system of differential equations
` Runge-Kutta-Fehlberg 7(8) method
` input
` neq = number of differential equations
Celestial Computing with Numerit
page 2
` ti = initial simulation time
` tf = final simulation time
` h = initial guess for integration step size
` tetol = truncation error tolerance (non-dimensional)
` x = integration vector at time = ti
` output
` xout = integration vector at time = tf
This algorithm requires the following statement the first time it is called.
rkcoef = 1
This statement is placed in the main program and is used to initialize the integration
coefficients for this numerical method. The value of rkcoef is passed to the rkf78
function using a common rkcoef statement in the main program. The rkf78 function
will then set this to 0 after the coefficients are calculated.
This function also requires a second function which defines the user's system of first-order
differential equations. The format of this function is given by
function orbeqm (time, y, ydot)
` first order equations of orbital motion
` cowell's method
` input
` time = simulation time (seconds)
` y = state vector
` output
` ydot = integration vector
where orbeqm is the actual name of the user-coded function. The function parameter list
should be exactly as shown here. The main program uses "rerouting" to tell the rkf78
function which equations of motion function to use. For this example the code is
orbeqm -> ceqm
The cowell program will prompt you for the name of an orbital elements data file,
including the file name extension. It will also prompt you for the initial calendar date and
universal time. The final request asks for the simulation duration in days.
The orbital elements data file contains true-of-date, heliocentric ecliptic classical orbital
elements. It is a simple ascii text file created with a text editor. The format and contents of
a typical data file are as follows:
Celestial Computing with Numerit
page 3
calendar date of perihelion passage
(1 <= month <= 12, 1 <= day <= 31, year = all digits!)
2,9,1986
universal time of perihelion passage
(0 <= hours <= 24, 0 <= minutes <= 60, 0 <= seconds <= 60)
15,52,14.592
perihelion radius (Astronomical Units)
(perihelion radius > 0)
0.587478
orbital eccentricity (non-dimensional)
(0 <= eccentricity < 1)
0.967329
orbital inclination (degrees)
(0 <= inclination <= 180)
162.2486
argument of perigee (degrees)
(0 <= argument of perigee <= 360)
111.8114
right ascension of the ascending node (degrees)
(0 <= raan <= 360)
58.1291
You can change the explanatory text and data in this file, but do not change the number of
lines or the type of information in each line. The software expects to find exactly 27 total
lines. This data file is called halley.dat and contains elements for Halley's comet.
The following is a typical example for Halley's comet using this data file:
initial orbital elements
January 1, 1986
10h 20m 30s
sma (km) eccentricity inclination (deg) argper (deg)
2690014320.33 0.967329 162.2486 111.8114
raan (deg) true anomaly (deg) arglat (deg) period (days)
58.1291 279.035113226 30.8465132264 27851.0902191
final orbital elements
May 1, 1986
10h 20m 30s
sma (km) eccentricity inclination (deg) argper (deg)
2690311083.86 0.967331951657 162.248987975 111.813339888
raan (deg) true anomaly (deg) arglat (deg) period (days)
Celestial Computing with Numerit
page 4
58.1306470436 107.680222659 219.493562547 27855.6991624
perihelion radius = 0.58748972935 AU
The initial calendar date and universal time for this example were January 1, 1986 at 0
hours UT. The simulation period was 120 days and the RKF truncation tolerance was
1.0e-8. This tolerance is "hard-wired" in the code (tetol) and can be easily changed
by the user. Smaller values of tetol will predict the orbit more accurately at the expense
of longer run times.
Celestial Computing with Numerit
page 1
Encke's Method for Heliocentric Orbits
This Numerit application (encke) demonstrates heliocentric orbit propagation of
spacecraft, asteroid or comet motion using a classical technique called Encke's method. It
includes the point mass gravity perturbations due to the planets Venus, Earth, Mars,
Jupiter, and Saturn. The planetary ephemerides used in this program are computer
implementations of the numerical method described in Low-Precision Formulae for
Planetary Positions, T. C. Van Flandern and K. F. Pulkkinen, The Astrophysical Journal
Supplement Series, 41:391-411, November 1979.
The classic form of Encke's special perturbation method solves the initial value problem
(IVP) of celestial mechanics by analytically propagating a two-body "reference" orbit and
numerically integrating the deviations from two-body motion. These two procedures are
performed for the same time interval or step size. Since the two-body solution is "exact",
the time interval used is usually a function of the numerical integration technique and the
magnitude of the perturbations. After each propagation interval, the errors between the
reference orbit and the perturbed orbit are evaluated. When these errors become "large", a
process known as rectification of the orbit is performed. This involves adding the
integrated deviations to the two-body orbit to produce a new reference orbit called the
osculating orbit. After rectification, the algorithm is reinitialized with the elements of the
new osculating orbit and the process is repeated until either the errors become large once
more or the final simulation time is reached.
The numerical algorithm used in this program simplifies this technique by using a variable
step-size integration method to automatically select the propagation step size. Since this
type of integrator "senses" the magnitude of the perturbations, it will choose the "best"
and largest step size for each propagation interval. The user can control how well this
procedure is performed with the algorithm truncation error tolerance. Furthermore, the
software eliminates the logic required to determine when rectification should occur by
simply rectifying the orbit after each and every propagation step.
The two-body or unperturbed equations of motion of a spacecraft or celestial body are
(1)
d
2
r
k
dt
2
+
r
k
(t)
r
3
k
0
where r
k
is the unperturbed position vector of the spacecraft at any time t and is the
gravitational constant of the primary body. In this equation r
k
is the scalar magnitude of
the position vector r
k
.
The equations of motion of motion of a spacecraft subject to a point mass central body
and other external perturbations are
Celestial Computing with Numerit
page 2
(2)
d
2
r
p
dt
2
+
r
p
(t)
r
3
p
a(r
p
, t)
where r
p
is the perturbed position vector at any time t and a(r
p
, t) is the vector of
planetary perturbations or other "indirect" accelerations.
The difference between these two types of orbital motion is
(3)

2
r
dt
2

d
2
r
p
dt
2

d
2
r
k
dt
2
In order to avoid numerical difficulties when subtracting small differences of vector
equations, the following form of the equations of motion is used:
(4)

2
r
dt
2

3
[f (q)r
p
(t) + r
p
(t)] + a(r
p
, t)
where
(5) f (q) q





3 + 3q + q
2
1 + (1 + q)
3
2
_ _



, ,
and
(6) q
(r 2r) r
r
2
At any time the position and velocity vectors of the true orbit are given by the vector sum
of the two body and perturbed components as follows:
(7)
r(t) r
k
(t) + r
p
(t)
v(t) v
k
(t) + v
p
(t)
The gravitational acceleration on the spacecraft, asteroid or comet due to each planet is
determined from the following expression:
(8) a(r, t)





r
pb
r
pb
3
+
r
p
r
p
3
_ _



, ,
where
Celestial Computing with Numerit
page 3
(9)
r
pb
position vector of body relative to planet
r
p
position vector of body relative to the Sun
gravitational constant of planet
The software (encke.num) uses a slightly modified version of Stanley Shepperd's two
body algorithm to provide the unperturbed solution for any simulation time. The
derivation of this algorithm is described in "Universal Keplerian State Transition Matrix",
Celestial Mechanics, 35 (1985) 129-144. The "deviation" equations of motion are
integrated using a slightly modified version of the Runge-Kutta-Fehlberg 7(8) method
called rkencke. Additional information about this algorithm can be found in the
technical discussion for the cowell program.
Although simple and straight-forward, this approach does require special attention to the
initialization at the start of each propagation step. Since there are no perturbations at the
initial epoch of the osculating reference orbit, the integrator would use the initial step size
defined by the user. This will cause very large errors before rectification can be performed.
To avoid this problem, the software forces the algorithm to perform the first phase of the
orbit propagation with a fixed step size. This is accomplished by setting the initial step size
guess to a small value and the truncation error tolerance to a very large value. For the
second phase of the propagation, the step size estimate is increased and the RKF algorithm
is allowed to change the actual step size to the largest value based on the perturbations
and user-defined error tolerance. The truncation error tolerance for this phase is set to a
very small number. The "best" initial step size depends on the type of orbit propagation
and the initial conditions.
Additional information about this algorithm can be found in AAS 92-196, "A Simple and
Efficient Computer Implementation of Encke's Method", AAS/AIAA Spaceflight
Mechanics Meeting, Colorado Springs, Colorado, February 24-26, 1992.
The program will prompt you for the name of the orbital elements data file, including the
file name extension. It will also prompt your for the initial calendar date and universal
time. The final request asks for the simulation duration in days.
The following is a typical example for Halley's comet:
initial orbital elements
January 1, 1986
10h 20m 30s
sma (km) eccentricity inclination (deg) argper (deg)
2690014320.33 0.967329 162.2486 111.8114
raan (deg) true anomaly (deg) arglat (deg) period (days)
58.1291 279.035113226 30.8465132264 27851.0902191
Celestial Computing with Numerit
page 4
final orbital elements
May 1, 1986
10h 20m 30s
sma (km) eccentricity inclination (deg) argper (deg)
2690310721.2 0.967331947242 162.248987969 111.813339887
raan (deg) true anomaly (deg) arglat (deg) period (days)
58.1306467941 107.680210212 219.493550099 27855.6935299
perihelion radius = 0.58748972956 AU
This example uses a true-of-date, heliocentric ecliptic orbital elements data file named
halley.dat. The contents of this file are as follows:
calendar date of perihelion passage
(1 <= month <= 12, 1 <= day <= 31, year = all digits!)
2,9,1986
universal time of perihelion passage
(0 <= hours <= 24, 0 <= minutes <= 60, 0 <= seconds <= 60)
15,52,14.592
perihelion radius (Astronomical Units)
(perihelion radius > 0)
0.587478
orbital eccentricity (non-dimensional)
(0 <= eccentricity < 1)
0.967329
orbital inclination (degrees)
(0 <= inclination <= 180)
162.2486
argument of perigee (degrees)
(0 <= argument of perigee <= 360)
111.8114
right ascension of the ascending node (degrees)
(0 <= raan <= 360)
58.1291
You can change the explanatory text and data in this file, but do not change the number of
lines or the type of information in each line. The software expects to find exactly 27 lines.
Please note the units of each data item.
The simulation period for this example was 120 days and the RKF truncation tolerance
was 1.0e-8. This tolerance is "hard-wired" in the code (tetol) and can be easily
changed by the user. Smaller values of tetol will predict the orbit more accurately at the
expense of longer run times.
Celestial Computing with Numerit
page 1
Closest Approach Between the Earth and Heliocentric Objects
This Numerit application (cae2ho) uses a combination of Cowell's method and
one-dimensional minimization to predict closest approach conditions between the Earth
and objects such as asteroids, comets and other bodies in heliocentric elliptic orbits. It
includes the point mass gravity perturbations due to the planets Mercury, Venus, Earth,
Mars, Jupiter and Saturn. It also includes the point-mass effect of the Moon via a
combined Earth/Moon gravitational constant. The coordinates of the planets are
determined with the SLP96 ephemeris. The software expects to find this ephemeris in a
binary data file named slp96.bin.
The second-order heliocentric equations of motion of a satellite or celestial body subject
to the point mass gravitational attraction of the Sun and planets are given by
(1)
d
2
r
dt
2
(r, t)
s
r
sb
r
sb
3

9

p
i





r
(pb)
i
r
(pb)
i
3
+
r
p
i
r
p
i
3
_ _



, ,
i 1

where

s
gravitational constant of the Sun

p
i
gravitational constant of planet i
r
p
i
position vector from the Sun to planet i
r
sb
position vector from the Sun to the body
r
(pb)
i
position vector from planet i to the body
These position vectors are related according to
(2)
r
sb
r
p
+ r
pb
This Numerit program uses a Runge-Kutta-Fehlberg 7(8) method to numerically integrate
the first-order form of these orbital equations of motion. This is a variable step size
method of order 7 with an 8
th
order error estimate which is used to dynamically change the
integration step size during the simulation.
The syntax of this Numerit function is as follows:
function rkf78 (neq, ti, tf, h, tetol, x, xout)
` solve first order system of differential equations
` Runge-Kutta-Fehlberg 7(8) method
` input
` neq = number of differential equations
` ti = initial simulation time
Celestial Computing with Numerit
page 2
` tf = final simulation time
` h = initial guess for integration step size
` tetol = truncation error tolerance (non-dimensional)
` x = integration vector at time = ti
` output
` xout = integration vector at time = tf
This function requires that the following statement be executed prior to the first time
rkf78 is called.
rkcoef = 1
This statement is placed in the main program and is used to initialize the integration
coefficients for this numerical method. The value of rkcoef is passed to the rkf78
function using a common rkcoef statement in the main program. The rkf78 function
will then set this "flag" to 0 after the coefficients are calculated.
This function also requires a second function which defines the user's system of first-order
vector differential equations. The format of this function is given by
function orbeqm (time, y, ydot)
` first order equations of orbital motion
` cowell's method
` input
` time = simulation time (seconds)
` y = state vector
` output
` ydot = integration vector
where orbeqm is the actual name of the user-coded function. The function parameter list
should be exactly as shown here. The main program uses "rerouting" to tell the rkf78
function which equations of motion function to use. For this example the code is
orbeqm -> caeqm
This software also uses a one-dimensional optimization algorithm due to Richard Brent to
solve the close approach problem. Additional information about this numerical method can
be found in Algorithms for Minimization Without Derivatives, R.P. Brent, Prentice-Hall,
1972. As the title of this book indicates, this algorithm does not require derivatives of the
objective function. This feature is important because the analytic first derivative of many
objective functions is difficult to derive and code. The objective function for this classical
celestial mechanics problem is the scalar geocentric distance of the heliocentric body.
Celestial Computing with Numerit
page 3
The software will ask you for the name of a simple ASCII input file which defines the
simulation. When responding to this request be sure to include the file name extension.
The software will also ask you for the total simulation (search) duration in days and an
Earth-to-body close approach constraint in astronomical units. The software will ignore
any close approaches that are larger than the close approach constraint. Please note the
proper units and coordinate system (J2000 equinox) of the input orbital elements. Notice
also that time on the Barycentric Dynamical Time (TDB) scale is used.
The following is a typical input data file (xf11n.dat) for this program. It contains the
J2000 dynamical equator and equinox heliocentric orbital elements of the asteroid 1997
XF 11. This file was created using data available on the Horizons ephemeris system which
is located on the Internet at http://ssd.jpl.nasa.gov/horizons.html. Additional information
about NEOs (Near Earth Objects) can also be found at http://newton.dm.unipi.it/neodys/.
Do not change the total number of lines or the order of annotation and data in this file.
The software expects to find exactly 34 lines of information in the input data file. The last
data item of this file defines the fundamental plane of the J2000 coordinate system.
initial calendar date
(1 <= month <= 12, 1 <= day <= 31, year = all digits!)
10,20,1998
initial TDB
(0 <= hours <= 24, 0 <= minutes <= 60, 0 <= seconds <= 60)
0,0,0
initial semimajor axis (AU)
(semimajor axis > 0)
0.1441779254846407D+01
initial orbital eccentricity (non-dimensional)
(0 <= eccentricity < 1)
0.4836740409964595D+00
initial orbital inclination
(degrees; 0 <= inclination <= 180)
0.2017287833484568D+02
initial argument of perihelion
(degrees; 0 <= argument of perihelion <= 360)
0.3228014264370198D+03
initial right ascension of the ascending node
(degrees; 0 <= raan <= 360)
0.3533298230482567D+03
initial mean anomaly
(degrees; 0 <= mean anomaly <= 360)
0.2708752703925974D+03
coordinate frame (1 = ecliptic, 2 = equator)
2
Celestial Computing with Numerit
page 4
The conversion of a position r and velocity vector v from the J2000 ecliptic frame
(subscript ec) to the J2000 equatorial frame (subscript eq) is given by the following
matrix-vector relationship:
(3)



r
v
1 1
1 1
] ]
eq





1 0 0
0 cos sin
0 sin cos
1 1
1 1
1 11 1
] ]



r
v
1 1
1 1
] ]
ec
In this expression is the J2000 obliquity of the ecliptic.
The following is the draft output created by this program for this example. The program
output and all internal calculations are performed in the J2000 dynamical equinox and
equator coordinate system. All angular elements in this output are in degrees.
initial heliocentric orbital elements
(J2000 dynamical equinox and equator)
October 20, 1998
00 h 00 m 00 s
semimajor axis (au) 1.441779254846407
eccentricity 0.4836740409964595
inclination 20.17287833484568
argument of perihelion 322.8014264370198
right ascension of ascending node 353.3298230482567
true anomaly 221.6544086526512
close approach conditions
October 31, 2002
00 h 30 m 40.5942 s
heliocentric orbital elements
(J2000 dynamical equinox and equator)
semimajor axis (AU) 1.442267124200949
eccentricity 0.4841223848226988
inclination 20.16564547782856
argument of perihelion 322.7924266589294
right ascension of ascending node 353.3467738153024
true anomaly 77.11093827535139
geocentric distance (AU) 0.06355264422584024
Celestial Computing with Numerit
page 1
The Circular Restricted Three-body Problem
This Numerit program (g3body) graphically displays motion in the circular-restricted
three-body problem (CRTBP). This algorithm and program examples are based on the
methods described in "Periodic Orbits in the Restricted Three-Body Problem with
Earth-Moon Masses", by R. A. Broucke, JPL TR 32-1168, 1968. In the discussion which
follows, subscript 1 is the Earth and subscript 2 is the Moon.
The system of second order vector differential equations of motion of a point mass
satellite in the CRTBP are given by
(1)
d
2
x
dt
2
2
dy
dt
x (1 )
xx
1
r
3
1

xx
2
x
3
2
d
2
y
dt
2
2
dx
dt
y (1 )
y
r
3
1

y
x
3
2
where
x x component of position
y y component of position
x
1

x
2
1
Earth-Moon mass ratio m
1
m
2
1 81.27
r
2
1
(x x
1
)
2
+ y
2
r
2
2
(x x
2
)
2
+ y
2
The motion of the spacecraft is displayed in a coordinate system which is rotating about
the center-of-mass or barycenter of the Earth-Moon system. The motion is confined to the
x-y plane.
For convenience, the problem is formulated in canonical units. The unit of length is taken
to be the constant distance between the Earth and Moon, and the unit of time is chosen
such that the Earth and Moon have an angular velocity about the barycenter equal to 1.
Kepler's third law is then
(2)
2
m
1
m
2
3
g(m
1
+ m
2
) 1
In his technical report, Professor Brouke calls these synodical coordinates.
Celestial Computing with Numerit
page 2
In his prize memoir of 1772, Joseph-Louis Lagrange proved that there are five
equilibrium points in the circular-restricted three-body problem. If we place a satellite or
celestial body at one of these points with zero initial velocity, it will stay there
permanently. These special positions are also called libration points.
For the Earth-Moon mass ratio value of , the x and y coordinates of these five equilibrium
points L
i
are as follows:
L
1
x = +0.836892919 y = 0
L
2
x = +1.155699520 y = 0
L
3
x = -1.005064520 y = 0
L
4
x = +0.487844901 y = +0.866025404
L
5
x = +0.487844901 y = +0.866025404
Three of these libration points are on the x-axis and the other two form equilateral
triangles with the positions of the Earth and Moon.
The program begins by asking you to select from 4 main program options. The first three
options will display typical periodic orbits about the respective libration point. The initial
conditions for each of these orbits are as follows:
(1) periodic orbit about the L
1
libration point
x
0
0.300000161
y

0
2.536145497
0.012155092
t
f
5.349501906
(2) periodic orbit about the L
2
libration point
x
0
2.840829343
y

0
2.747640074
0.012155085
t
f
11.933318588
(3) periodic orbit about the L
3
libration point
x
0
1.600000312
y

0
2.066174572
0.012155092
t
f
6.303856312
Celestial Computing with Numerit
page 3
Notice that each orbit is defined by an initial x-component of position, x
0
, an initial
y-component of velocity, y

0
, a value of Earth-Moon mass ratio , and an orbital period
or final time t
f
. The initial y-component of position and x-component of velocity for each
these orbits is equal to zero. The software will draw the location of the libration point on
the graphics display.
If you would like to experiment with your own initial conditions, select option 4. The
program will then prompt you for the initial x and y components of the orbit's position and
velocity vector, and the value of to use in the simulation. The software will also ask for an
initial and final time to run the simulation, and an integration step size. The value 0.01 is a
good number for step size.
Here is a short list of initial conditions for several other periodic orbits which you may
want to display with this program.
(1) Retrograde periodic orbit about m
1

x
0
2.499999883
y

0
2.100046263
0.012155092
t
f
11.99941766
(2) Direct periodic orbit about m
1

x
0
0.952281734
y

0
0.957747254
0.012155092
t
f
6.450768946
(3) Direct periodic orbit about m
1
and m
2

x
0
3.147603117
y

0
3.07676285
0.012155092
t
f
12.567475674
(4) Direct periodic orbit about m
2

x
0
1.399999991
y

0
0.9298385561
0.012155092
t
f
13.775148738
Celestial Computing with Numerit
page 4
The following is a plot of a periodic orbit about the L
2
libration point. This plot was
created by selecting program option 2.
y

c
o
o
r
d
i
n
a
t
e
x coordinate
-3
-2
-1
0
1
2
3
-3 -2 -1 0 1 2 3
Figure 1. Periodic Orbit about the L
2
Libration Point
For a correct graphic display, the Width and Height dimensions should be the same as well
as the x and y axes scales. You can change these properties interactively by double
clicking on this graph with the left mouse button.
Celestial Computing with Numerit
page 1
Predicting Equinoxes and Solstices
This Numerit program (equsol) determines the time of the equinoxes and solstices of
the Earth. The time of equinoxes and solstices determine the beginning and end of our
seasons. These events are the times when the apparent geocentric longitude of the Sun is
an exact multiple of 90 degrees. This software uses Brent's root-finder and the sun1 solar
ephemeris to calculate these events.
Brent's method requires an objective function which defines the single nonlinear equation
to be solved. The objective function for the spring and fall equinoxes is the geocentric
declination of the Sun. For the summer and winter solstices the objective function is
s

, where 90 for the summer solstice, 270 for the winter solstice and
s
is the
geocentric apparent longitude of the Sun.
Brent's method also requires an initial and final time which bounds the root of the
objective function. The initial time for the spring equinox is March 15, for the summer
solstice June 15, for the fall equinox September 15 and for the winter solstice December
15. For each event, the final time is equal to these initial dates plus 15 days.
The following is the Numerit source code for this objective function:
function esfunc(x, fx)
` equinox/solstice objective function
` Celestial Computing with Numerit
``````````````````````````````````
jdate = %jdatei + x
` compute coordinates of the sun
sun1 (jdate, rasc, decl, rsun)
` iequsol flag determines if this
` is an equinox or solstice
if (%iequsol = 1 or %iequsol = 3)
fx = decl
else
fx = %along2 - %rlsun
This code returns a function value fx for any input time argument x. The type of
calculation performed by this function is determined by the value of the %iequsol
"flag". This flag is set by the main program. In this listing decl is the declination of the
Sun, along2 is the apparent longitude of the event and rlsun is the apparent
geocentric longitude of the Sun.
Celestial Computing with Numerit
page 2
This program will prompt you for the calendar year of interest. The following is a typical
draft output created with this program. Please note that the event is displayed in dynamical
or ephemeris time.
time of the equinoxes and solstices
spring equinox
calendar date March 20, 2000
dynamical time 7 h 36 m 11.4938 s
summer solstice
calendar date June 21, 2000
dynamical time 1 h 48 m 48.2259 s
fall equinox
calendar date September 22, 2000
dynamical time 17 h 28 m 44.6439 s
winter solstice
calendar date December 21, 2000
dynamical time 13 h 38 m 29.9393 s

You might also like