The definitive source of information about the position of the Sun, Moon and planets can be found at the NASA Jet Propulsion Laboratory. The data is named DE4XX, where the latest is DE438. The data comes in ASCII files which span over 1,000 years from 1550 to 2650. The data sets are updated periodically, usually as a result of improved data from space probes. The data is calculated using numerical integration based on actual data and so is quite accurate.

The DE438 data is in a set of ASCII files. The header file header.438 describes the data and defines constants. The data files ascp01550.438 through ascp2550.438 contain large numbers of data values. The file testpo.438 contains results for testing. The JPL data files can be found here.

The header file `header.483`

is the key to understanding the data. The header file has a number of groups starting with a number of the form 10XX.

GROUP 1010 defines the ephemeris number and the start and end dates 1549-12-21 to 2650-01-25.

GROUP 1030 defines the start Julian date, the end Julian date and the duration of each data block - 32 days.

GROUP 1040 contains the labels of 576 constants. The labels are rather cryptic.

GROUP 1041 contains the data for the 576 constants.

GROUP 1050 defines the data for each of the bodies. The first row contains the data offset for the start of the data for each planet. The second row contains the number of Chebychev polynomial coefficents for each of the bodies. The third row contains the number of time intervals each body's data is split into.

The order in which the bodies are defined is:

- Mercury
- Venus
- Earth
- Mars
- Jupiter
- Saturn
- Uranus
- Neptune
- Pluto
- Moon
- Sun
- Solar System Barycenter
- Earth Moon Barycenter
- Lunar nutations
- Lunar librations

There are 11 data files which contain the actual coordinate data for each of the bodies. Each data file spans 100 years. They are named `ascp01550.438`

, `ascp01650.438`

... `ascp02550.438`

Each data file contains 1142 blocks of 1018 values. The first two values in each block are the start Julian date and the end Julian date for the block. Each block spans 32 days.

Using the offsets given in header group 1050 we know that the 3rd value in each block is the start of the data for Mercury. The 171st value in each block is the start of the data for Venus. This means that there are 168 values for Mercury in each block.

Header group 1050 tells us that there are 4 time intervals for Mercury. This means that the 168 values for Mercury are divided into 4 consecutive blocks of 42 values each defining data for `interval_time = 32 / 4 = 8`

days.

Header group 1050 tells us that there are 14 Chebychev polynomial coefficients for each coordinate position for Mercury. This means that each block of `interval_size = 42`

values is divided into 3 consecutive sets of 14 values, one for
each of the x, y and z axes.

To calculate the position of Mercury for a Julian date `t`

.

- Locate the data file containing the data for date
`t`

. - Locate the 32 day data block where
`start_date <= t < end_date`

. - Calculate which of the 4 time intervals to use
`interval = floor((t - start_date) / interval_time)`

.

The date needs to be converted into a Chebychev time in the range `[-1, 1]`

.

`tc = 2(t - start_date - interval * interval_time) / interval_time - 1`

The Chebychev coefficients for the x coordinate are the 14 values `C`

starting at offset _{i}`3 + interval + interval_size`

from the data block.

The Chebychev terms `T`

are defined as _{i}`T`

,
_{0} = 1`T`

, _{1} = tc`T`

._{i} = 2 * tc * T_{i-1} - T_{i-2}

The Chebychev velocity terms `T'`

can be determined by differentiating the Chebychev terms
_{i}`T'`

,
_{0} = 0`T'`

, _{1} = 1`T'`

.
_{i} = 2 * T_{i-1} + 2 * tc * T'_{i-1} - T'_{i-2}

The position can be calculated as `x = ΣC`

. The velocity can be calculated as _{i}T_{i}`x' = ΣC`

.
_{i}T'_{i}

The y and z positions and velocities can be calculated from the next two 14 values in the data block.