The Astronomical Applications Department frequently receives requests for the formulae or algorithms used to compute times of sunrise, sunset, twilight, moonrise, and moonset. Unfortunately, no single formula can be used to predict times of these phenomena accurately over an acceptably wide range of dates and places. The good news, though, is that algorithms to compute times of solar and lunar phenomena have been published in many places and are readily available. A few sources for this information are listed below. The U.S. Navy neither endorses nor recommends any product or vendor.

- Urban, S. & Seidelmann, P. K. ed. 2012.
*Explanatory Supplement to the Astronomical Almanac*, 3rd ed., Mill Valley, CA: University Science Books

is the authoritative source describing the methods used to compute astronomical phenomena in*The Astronomical Almanac*. Chapter 12 presents algorithms for computing times of rise, set, and transit. This book is written at the intermediate to advanced level. - Meeus, J. 1999.
*Astronomical Algorithms*, 2nd ed., Richmond, VA: Willmann-Bell

is a general source of algorithms for performing a wide variety of celestial calculations. This book can be utilized by technical people who are not necessarily specialists in astronomy and contains many worked examples which are invaluable for checking your own calculations or computer code. Chapter 15 covers the computation of times of rise, set, and transit. This book also contains algorithms for low-precision ephemerides of major celestial bodies. - Sinnott, R. W. Jul 1989. "Astronomical Computing: Ups and Downs of the Moon,"
*Sky & Telescope*, Vol. 78, No. 1: 78–80

Sinnott, R. W. Aug 1994. "Astronomical Computing: Sunrise and Sunset: A Challenge,"*Sky & Telescope*, Vol. 88, No. 2: 84–85

Sinnott, R. W. Mar 1995. "Astronomical Computing: Sunrise/Sunset Challenge: The Winners,"*Sky & Telescope*, Vol. 89, No. 3: 84–86

is a series of articles discussing the computation of times of rise and set published in*Sky & Telescope*magazine. These columns contain printed listings of simple BASIC programs employing the algorithms discussed. BASIC is quite readable, which facilitates the conversion of the code to other computer languages. Better still, the BASIC source code given in the first two articles is available for download from*Sky & Telescope's*Web site. The programs are**MOONUP.BAS**and**SUNUP.BAS**. - Yallop, B. D. 1996.
*A Simple Algorithm to Calculate Times of Sunrise and Sunset*, H.M. Nautical Almanac Office (U. K.) Technical Note 70

contains a simple, compact algorithm for calculating times of sunrise and sunset, which is valid from 1980–2050. For information on its availability, send e-mail to hmnao@ukho.gov.uk. - Chapront-Touze, M. & Chapront, J. 1991.
*Lunar Tables and Programs from 4000 BC to AD 8000*, Richmond, VA: Willmann-Bell

Bretagnon, P. & Simon, J.-L. 1986.*Planetary Programs and Tables from -4000 to +2800*, Richmond, VA: Willmann-Bell

include accurate, easy-to-implement ephemerides of the Sun, Moon, and major planets. They contain Fortran source code listings with an option to get the code and data on disk.