# Sunrise and sunset times

This applet computes sunrise, sunset and twilight times
The sunrise and sunset times at any given day and location can be found using so-called Sunrise equation[1]

[[Math:c|\cos \omega_o = -\operatorname{tan}(\phi) \times \operatorname{tan}( \delta_\odot) ]]

here:

[[Math:c|\delta_\odot]] is the sun declination.
[[Math:c|\,\!\phi]] is the latitude of the observer
[[Math:c|\,\!\omega_o]] is the time, expressed in degrees (with 24 hours corresponding to 360 degrees). Take negative value for sunset and positive value for sunrise.

## Computing declination

An object has a declination 0° on the (celestial) equator, +90° at the north pole and −90° at the south pole. The Sun's declination is approximately equal to[2]

[[Math:c|\delta_\odot = -23.45^\circ \cdot \cos \Big \left \frac{360^\circ}{365} \cdot ( N \plus 284 ) \Big \right ]]

where -23.45 is the axial tilt of the earth. N is the number of the days elapsed after the 1 of January that year.

There are also various more complex, but also more precise formulas. For instance, the same source gives the formula

[[Math:c| \begin{matrix} \delta_\odot = \frac{180^\circ}{\pi} \cdot (0.006918 - 0.399912 \cos \tau_d \plus 0.070257 \sin \tau_d - \\ 0.006758 \cos 2\tau_d \plus 0.000907 \sin 2\tau_d - 0.002697 \cos 3\tau_d \plus 0.00148 \sin 3\tau_d) \end{matrix} ]]

where

[[Math:c|\tau_d = \frac{2\pi}{365} ( N - 1 ) ]]

is the day angle (fractional year) in radians.

Changes of the declination over year give the raise of seasons.

Given formulas compute the sunrise and sunset times in the vacuum (if it would be in the Moon). For more precise output, refraction in the Earth's atmosphere must also be taken into consideration:

[[Math:c|\cos(\omega_o) = \dfrac{\sin(-a) - \sin(\phi) \times \sin(\delta_\odot)}{\cos(\phi) \times \cos(\delta_\odot)}]]

where a is the altitude of the centre of the solar disc in angular units (about 0.83°)

## References

1. 1 Wikipedia on Sunrise Equation
2. 2 Desmond Fletcher (2007) Solar Declination