Determining the relative position of the sun from any location on Earth at any time of the year involves a series of calculations, many of which are approximations.  The first step to understanding these is to summarize a few basic quantities.

Declination of the Sun () – This is the angle between the Earth’s axis of rotation and the plane normal to a line connecting the centers of the Earth and Sun.

A simple approximation for the declination (in degrees) is:

,  where  is the day of year.

Hour Angle () – This is the angle of the Sun in its apparent orbit through the sky.  By convention it is defined to zero at solar noon (when the Sun reaches its highest point in the sky each day).  Since it takes approximately 24 hours for the Earth to rotate each day, the hour angle changes by 15 degrees each hour (360°/24).

Solar vs. Standard Time – While local time is synchronous across a single time zone, solar time is defined as the relative position of the sun to an observation point.  Therefore, solar time will vary by longitude across the time zone at a given local time.  What is known as the “Equation of Time” is used to calculate the difference between solar and local time as a function of location and time of year.

The equation of time () can be approximated with a series of equations depending on the day of the year:

For n=1 to 106:

For n=107 to 166

For n =167 to 246

For n = 247 to 365

Using this approximation the solar time () in hours is calculated as:

, where  is the longitude of the standard meridian of the observer’s time zone (degrees) and  is the longitude of the observer (degrees).

The hour angle (radians) can be calculated as a function of solar time as:

.

The cosine of the solar zenith angle can then be calculated as:

, where  is the latitude of the observer.