Estimate sunrise and sunset times for a date.
Sunrise and sunset are solar noon plus or minus the sunrise hour angle, converted at four minutes per degree. Solar noon itself depends on longitude within your time zone and on the equation of time — the up-to-sixteen-minute discrepancy between clock time and true solar time caused by Earth's elliptical orbit and axial tilt. The zenith used is 90.833 degrees, which accounts for atmospheric refraction and the sun's apparent radius.
Sunrise and sunset times
cos(hour angle) = (cos 90.833 - sin(lat) sin(dec)) / (cos(lat) cos(dec)); solar noon = 720 - 4 x longitude - equation of time + offset; sunrise = solar noon - 4 x hour angle
Because clock time is standardised across a whole time zone and because of the equation of time. Both effects together can shift true solar noon by well over half an hour.
The difference between apparent solar time and mean clock time, ranging roughly from minus 14 to plus 16 minutes over the year due to orbital eccentricity and axial tilt.
Atmospheric refraction lifts the sun's image by about 34 arcminutes and its disc has a radius of about 16, so sunrise is defined when the geometric centre is slightly below the horizon.