# Category:Astronomy

I always welcome suggestions, comments, and criticism. If you have something to contribute to this site, please follow this link: Contributing Information. Thank you!

## Books

• Practical Astronomy With Your Calculator by Peter Duffett-Smith, 3rd Edition, Cambridge University Press, 1988. ISBN 0-5213-5699-7
• Astronomical Algorithms by Jean Meeus, 2nd Edition, Willmann-Bell, 1998. ISBN 0-9433-9661-1
• Astronomical Formulae for Calculators by Jean Meeus, 3rd Edition, Willmann-Bell, 1985. ISBN 0-9433-9609-3
• Planetary Programs and Tables from -4000 to +2800 by Pierre Bretagnon and Jean-Louis Simon, Willmann-Bell, 1986.
• Celestial BASIC: Astronomy on Your Computer by Eric Burgess, Revised Edition, Sybex, 1985. ISBN 0-8958-8087-3

## Programs, algorithms, and code

### Equations

#### Geo::Distance

Note: The `d` at the end of each of the following equations means "distance".

• hsin: Haversine Formula
``` dlon = lon2 - lon1
dlat = lat2 - lat1
a = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2
c = 2 * atan2( sqrt(a), sqrt(1-a) )
d = R * c
```

Note: The hsin formula has improved accuracy over the cos formula.

• polar: Polar Coordinate Flat-Earth Formula
``` a = pi/2 - lat1
b = pi/2 - lat2
c = sqrt( a^2 + b^2 - 2 * a * b * cos(lon2 - lon1) )
d = R * c
```
• cos: Law of Cosines for Spherical Trigonometry
``` a = sin(lat1) * sin(lat2)
b = cos(lat1) * cos(lat2) * cos(lon2 - lon1)
c = arccos(a + b)
d = R * c
```

Note: Although this formula is mathematically exact, it is unreliable for small distances because the inverse cosine is ill-conditioned.

• gcd: Great Circle Distance.
``` c = 2 * asin( sqrt(
( sin(( lat1 - lat2 )/2) )^2 +
cos( lat1 ) * cos( lat2 ) *
( sin(( lon1 - lon2 )/2) )^2
) )
```
• mt: Math::Trig great_circle_distance
``` lat0 = 90 degrees - phi0
lat1 = 90 degrees - phi1
d = R * arccos(cos(lat0) * cos(lat1) * cos(lon1 - lon01) + sin(lat0) * sin(lat1))
```

### Convert right ascension and declination to altitude and azimuth

Given the hour angle H of the object with right ascension RA and declination DEC, and the observer's latitude LAT:

```azimuth = atan2(sin(H), cos(H) * sin(LAT) - tan(DEC) * cos(LAT))
altitude = asin(sin(LAT) * sin(DEC) + cos(LAT)* cos(DEC) * cos(H))
```

where "atan2(x,y)" is C-library function equivalent to "atan(x/y)".

### Hour angle

Given an object with right ascension RA and the observer's longitude LONG, and the sidereal time at Greenwich ST:

```H = ST - LONG - RA
```

where LONG is positive to the west and ST is represented as an angle. If you measure longitude to the east:

```H = ST + LONG - RA.
```

### Calculate the date of Easter

```see: (FAQ) Astronomical Calculations for the Amateur
```

Note: Easter is the first Sunday after the first full Moon following the vernal equinox.

This is "astronomical Easter", and it is usually but not always the same day as "ecclesiastical Easter", which is the date used by the churches and printed on calendars. "Ecclesiastical Easter" is determined by a formula codified many years ago.

Perform integer math and drop all remainders. It is valid for any Gregorian year "Y":

```C = Y / 100
N = Y - 19 * (Y / 19)
K = (C - 17) / 25
I = C - C / 4 - (C - K) / 3 + 19 * N + 15
I = I - 30 * (I / 30)
I = I - (I / 28) * (1 - (I / 28) * (29 / (I + 1)) * ((21 - N) / 11))
J = Y + Y / 4 + I + 2 - C + C / 4
J = J - 7 * (J / 7)
L = I - J
M = 3 + (L + 40) / 44
D = L + 28 - 31 * (M / 4)
```

"M" is the month number (3 -> March, 4 -> April) and "D" is the day of the month.