Sunday, November 29, 2015

HP Prime: Approximate Length of Daylight

I hope you had a great weekend and a great Thanksgiving.  For those of you in the United States, hopefully Friday was peaceful and not crazy.

HP Prime: Approximating the Length of Daylight in Hours

This time, we are taking a slightly more complex formula.   The inputs are:

lat = Earth's latitude of the observer.  (from -90° (South) to 90° (North))

day = the number of days since the December solstice (around December 21-22).  Note that is different from many approximate formulas which used the vernal equinox as a starting point.  

The formula used is a simplification of the Final Formula presented by Herbert Glarner (http://www.gandraxa.com/).  For the complete article and the derivation, please click on link:

http://www.gandraxa.com/length_of_day.xml    (Retrieved November 23, 2015)

The algorithm used in the DAYLIGHT is:

With the inputs lat and day:

m = 1 – tan(lat°) * tan(23.439° * cos(480/487 * day))

If m > 2, let m = 2.   If m < 0, let m = 0.

Then:

b = acos(1 – m)/180 *24

Where b is the length of daylight in hours.

I adjusted the formula to allow for all inputs to be in degrees.  Glamer had mixed inputs for the trigonometric functions.

Here is the program:

Program DAYLIGHT:

EXPORT DAYLIGHT(lat,day)
BEGIN
// latitude, days from
// December solstice
LOCAL m,b,a:=HAngle;
HAngle:=1; // Degrees
m:=1-TAN(lat)*TAN(23.439*COS(
480/487*day));
IF m<0 THEN
m:=0;
END;
IF m>2 THEN
m:=2;
END;
b:=ACOS(1-m)/180*24; // hours
RETURN b;
HAngle:=a;
// www.grandraxa.com
END;

Examples:

Let’s assume a 365 day and the December solstice was December 22. 

Latitude:  -60°, March 1  (day = 69)
Result:  Approx. 16.67808 hours

Latitude: 54°,  July 24  (day = 214)
Result:  Approx. 16.03426 hours

For another approximate formula, I wrote on one for the HP 35S here:  http://edspi31415.blogspot.com/2013/05/hp-35s-approximate-length-of-sunlight.html


Have a great day, 

Eddie


This blog is property of Edward Shore.  2015