# hp41programs

LocalTime Local Solar Time for the HP-41

Overview

-This program calculates the local solar time defined by:  LST  = 12 h. + the hour angle of the Sun.
-12h are added because it's more convenient to regard the solar day as commencing at midnight rather than at noon.
-The equation of time ( i-e the difference between apparent and mean time ) is obtained by the following formula:

E = y.sin 2L - 2e.sin M + 4ey.sin M cos 2L - (y2/2).sin 4L - (5e2/4).sin 2M       ( in radians )

where

y = tan2(obl/2)    obl = obliquity of the ecliptic
L = Sun's mean longitude
e = eccentricity of the Earth's orbit
M = Sun's mean anomaly

-A second routine has been added to get a similar accuracy over a longer time-span.

Program Listing1

Data Registers:  R00 thru R05
Flag: /
Subroutine:  "J0" or "J1" or "J2"  ( cf "Julian & Gregorian Calendars for the HP-41" )
none if you have a Time Module

-If you have a Time module,  lines 09-10 may be replaced by   1.012   RCL Z   DDAYS
-If you want, add   24  MOD   after line 61

 01  LBL "LST" 02  DEG 03  STO 00      04  RDN 05  HR 06  STO 01 07  24 08  / 09  X<>Y  10  XEQ "J0" 11  + 12  STO 02 13  .9856 14  * 15  2.964 16  - 17  X<> 02     18  1.971295  19  * 20  199.947 21  + 22  540 23  1/X 24  SQRT 25  P-R 26  STO 03 27  RCL 02 28  SIN 29  STO 04      30  4 31  * 32  * 33  3582 34  STO 05 35  SQRT 36  ST/ 04 37  / 38  + 39  X<>Y 40  RCL 03 41  * 42  - 43  RCL 04      44  ST+ X 45  - 46  RCL 02 47  ST+ X 48  SIN 49  .8 50  / 51  RCL 05 52  / 53  - 54  R-D 55  RCL 00      56  HR 57  + 58  15 59  / 60  RCL 01 61  +  62  HMS 63  END

( 106 bytes / SIZE 006 )

 STACK INPUTS OUTPUTS Z YYYY.MNDD / Y HH.MNSS (UT) / X Longitude ( ° . '  " ) LST = HH.MNSS

Examples:   Calculate the solar time on  2004/12/31  12h25mn41s (UT)  in the U.S. Naval Observatory at Washington ( D.C.)  ( Longitude = 77°03'56"W )

2004.1231  ENTER^
12.2541  ENTER^
-77.0356  XEQ "LST"   >>>>   LST = 7h14mn13s4

Likewise,

2100.1231  ENTER^
12.2541  ENTER^
-77.0356  XEQ "LST"   >>>>   LST = 7h14mn35s1

Notes:

-The longitudes are measured positively eastwards from the meridian of Greenwich.
-The accuracy is of the order of  1 second between 1900 and 2100.

Program Listing2

-As usual, we must take into account more secular terms to get the same accuracy a few millenia around J2000

Data Registers:  R00 thru R05
Flag: /
Subroutine:  "J0" or "J1" or "J2"  ( cf "Julian & Gregorian Calendars for the HP-41" )

-If you want, add   24  MOD   after line 83

 01  LBL "LST" 02  DEG 03  STO 00 04  RDN 05  HR 06  STO 01 07  24 08  / 09  X<>Y 10  XEQ "J0" 11  + 12  365250 13  / 14  359990.503 15  RCL Y 16  65 17  / 18  - 19  * 20  2.964 21  - 22  STO 02        23  RDN 24  42 25  + 26  * 27  CHS 28  1671 29  + 30   E5 31  / 32  STO 03 33  CLX 34  15 35  / 36  720015.397 37  + 38  * 39  199.947 40  + 41  X<>Y 42  .065 43  * 44  11.7196 45  - 46  TAN 47  X^2 48  P-R 49  STO 04 50  RCL 02 51  SIN 52  STO 05 53  4 54  * 55  * 56  RCL 03        57  ST* 05 58  * 59  + 60  X<>Y 61  RCL 04  62  * 63  - 64  RCL 05 65  ST+ X 66  - 67  RCL 02 68  ST+ X 69  SIN 70  .8 71  / 72  RCL 03 73  X^2 74  * 75  - 76  R-D 77  RCL 00        78  HR 79  + 80  15 81  / 82  RCL 01 83  +  84  HMS 85  END

( 151 bytes / SIZE 006 )

 STACK INPUTS OUTPUTS Z YYYY.MNDD / Y HH.MNSS (UT) / X Longitude ( ° . '  " ) LST = HH.MNSS

Example:

4000.0716  ENTER^
16.2441  ENTER^
-77.0356  XEQ "LST"   >>>>   LST = 11h05mn54s6

References:

[1]  Jean Meeus , "Astronomical Algorithms" - Willmann-Bell  -  ISBN 0-943396-61-1
[2]  Robin M. Green - "Spherical Astronomy" - Cambridge University Press - ISBN  0-521-31779-7