Phase

# Phases of the Moon for the HP-41

Overview

-The following programs compute the date & time of a phase of the Moon that occurs near a given date.

-A few secular terms are used in the first version which is valid over the time-span [1000,3000]  ( the accuracy remains of the order of a few minutes )
-The second program uses more secular terms and an accuracy of the order of 10 minutes is achieved near 3000 B.C. ( compared to DE406/LE406 )
-The 3rd program is valid over the time-span [1900,2100]

-See also "Eclipses for the HP-41" for a non-standard definition of the phases.

Program#1

Data Registers:    R00 = T = instant of the mean phase is expressed in millennia since J2000.

R01 = M                        where M = mean anomaly of the Sun                            R04 = phase
R02 = M'-180°              where M' = mean anomaly of the Moon                        R05 = 0 for a New Moon or a Full Moon, 1 otherwise
R03 = 1 for a Full Moon, 0 otherwise and then  2 F                                            R06 = 7.38264721 x 4k

where F = mean argument of latitude of the Moon

Flags:  none. However, set flag F04 for dates before 1582/10/15 if you use "J1" and "D1" instead of "J0" & "DT"

Subroutines:  "J0" & "DT"  ( cf "Julian & Gregorian Calendars for the HP-41" )  or "J1" & "D1" or "J2" & "D2"
none if you have a TIME Module, provided the dates are after 1582/10/14

-If you have a TIME Module, line 03 may be replaced by   1.012   STO 07   X<>Y   DDAYS
-In this case, key in the date in the current format:  MDY or DMY
-If you have a TIME Module, lines 148-149 may be replaced by   RCL 07   RCL Z   DATE+

 01  LBL "PHASE"   02  DEG   03  XEQ "J0"     04  7.38264721   05  STO 06   06  /   07  INT   08  STO 00   09  ST* 06   10  4   11  MOD   12  STO 04   13  2   14  STO 03   15  X#Y?   16  ST- 03   17  ST/ 03   18  MOD   19  STO 05   20  221   21  *   22  RCL 03   23  -   24  407   25  +   26  RCL 00   27  49474   28  /   29  STO 00   30  8   31  % 32  +   33  4771976.76      34  +   35  RCL 00   36  *   37  465   38  SQRT   39  +   40  STO 02   41  SIN   42  *   43  1   44  RCL 00   45  40   46  /   47  -   48  RCL 00   49  359989.6   50  *   51  13   52  LN   53  +   54  STO 01   55  SIN   56  *   57  172   58  RCL 03   59  +   60  *   61  +   62  16 63  RCL 05   64  7   65  *   66  -   67  RCL 02   68  ST+ X   69  SIN   70  *   71  +   72  5   73  RCL 05   74  -   75  ST+ X   76  RCL 00   77  9664016          78  *   79  39   80  -   81  STO 03   82  SIN   83  *   84  +   85  RCL 05   86  ST+ X   87  7   88  -   89  RCL 02   90  RCL 01   91  -   92  SIN   93  * 94  +   95  RCL 05   96  7   97  *   98  5   99  + 100  RCL 01 101  RCL 02 102  + 103  SIN 104  * 105  + 106  RCL 01         107  ST+ X 108  SIN 109  ST+ X 110  + 111  RCL 05 112  RCL 02 113  RCL 03 114  - 115  SIN 116  ST* Y 117  + 118  + 119  RCL 04 120  2 121  - 122  RCL 05 123  * 124  3 125  * 126  - 127  5598 128  + 129   E3 130  / 131  RCL 00 132  X^2 133  65 134  / 135  + 136  RCL 06         137  + 138  INT 139  LASTX 140  FRC 141  X<0? 142  DSE Y 143  ""    144  24 145  ST* Y 146  MOD 147  HMS 148  X<>Y  149  XEQ "DT" 150  RCL 04 151  END

( 231 bytes / SIZE 007 )

 STACK INPUTS OUTPUTS Z / HH.MNSS Y / YYYY.MNDD X yyyy.mndd Phase

where  yyyy.mndd  is an approximate date

Phase = 0  for a New Moon
Phase = 1  for a First Quarter
Phase = 2  for a Full Moon
Phase = 3  for a Last Quarter

YYYY.MNDD  &  HH.MNSS  are the date & time ( in Terrestrial Time ) of the Phase

Example:

-We want to know the instant of a phase of the Moon near July 4th 2002

2002.0704   XEQ "PHASE"  >>>>     3                                                    ---Execution time = 17s---
RDN                2002.0702
RDN                 17.2314

-There is a Last Quarter on July 2nd 2002  at 17h23 TT or 17h22 UT  ( the exact value is 17h21 UT )

-If we seek a New Moon, we can guess it happens about 7 days later,
so we execute "PHASE" again with this new initial value:

2002.0709    R/S       yields         0
RDN                 2002.0710
RDN                   10.2715

-The New Moon occurs on July 10th 2002 at 10h27 TT or 10h26 UT  ( the exact value )

Other numerical checks:

1000.0101   XEQ "PHASE"    >>>>  0   RDN   1000.0109   RDN   15h32m33s  TT    ( New Moon on 1000/01/09 at 15h33 TT )
1600.0215             R/S            >>>>  1   RDN   1600.0221   RDN     8h41m43s  TT    ( First Quarter on 1600/02/21 at 8h42 TT )
2500.0412             R/S            >>>>  2   RDN   2500.0415   RDN   16h24m58s  TT    ( Full Moon on 2500/04/15 at 16h25 TT )
3000.0714             R/S            >>>>  3   RDN   3000.0716   RDN   21h38m01s  TT    ( Last Quarter on 3000/07/16 at 21h38 TT )

-Errors can reach about 1 hour near 3000 B.C.
-Using more secular terms will increase accuracy:

Program#2

Data Registers:    R00 = T = instant of the mean phase    ( expressed in unit of 10000 julian years since J2000 )

R01 = M                        where M = mean anomaly of the Sun                            R04 = phase
R02 = M'-180°              where M' = mean anomaly of the Moon                        R05 = 0 for a New Moon or a Full Moon, 1 otherwise
R03 = 1 for a Full Moon,  0 otherwise and then  2 F                                           R06 = E

where F = mean argument of latitude of the Moon                                               R07 =  7.382647215 x 4k

Flags:  none. However, set flag F04 for dates before 1582/10/15 if you use "J1" and "D1" instead of "J0" & "DT"

Subroutines:  "J0" & "DT"  ( cf "Julian & Gregorian Calendars for the HP-41" )  or "J1" & "D1" or "J2" & "D2"

 01  LBL "PHASE"   02  DEG   03  XEQ "J0"   04  7.382647215   05  STO 07   06  /   07  INT   08  STO 00   09  ST* 07   10  4   11  MOD   12  STO 04   13  2   14  STO 03   15  X#Y?   16  ST- 03   17  ST/ 03   18  MOD   19  STO 05   20  1   21  RCL 00   22  494740   23  /   24  STO 00   25  13   26  /   27  .252   28  +   29  RCL 00   30  *   31  -   32  STO 06   33  13   34  LN   35  RCL 00   36  X^2   37  9   38  / 39  3599896          40  -   41  RCL 00   42  *   43  -   44  STO 01   45  ST+ X   46  SIN   47  ST+ X   48  *   49  RCL 01   50  SIN   51  172   52  RCL 03   53  +   54  *   55  +   56  465   57  SQRT   58  RCL 00   59  5.8   60  *   61  12.38   62  -   63  RCL 00   64  *   65  6164   66  D-R   67  -   68  RCL 00   69  *   70  47719767.64   71  -   72  RCL 00   73  *   74  -   75  STO 02   76  RCL 01 77  -   78  SIN   79  RCL 05   80  ST+ X   81  7   82  -   83  *   84  +   85  RCL 05   86  7   87  *   88  5   89  +   90  RCL 01   91  RCL 02           92  +   93  SIN   94  *   95  +   96  RCL 06   97  *   98  RCL 05   99  221 100  * 101  RCL 03 102  - 103  407 104  + 105  RCL 02 106  SIN 107  * 108  + 109  16 110  RCL 05 111  7 112  * 113  - 114  RCL 02 115  ST+ X 116  SIN 117  * 118  + 119  RCL 00 120  ST+ X 121  5 122  - 123  RCL 00 124  X^2 125  * 126  96640162      127  + 128  RCL 00 129  * 130  39 131  - 132  STO 03 133  SIN 134  5 135  RCL 05 136  - 137  ST+ X 138  * 139  + 140  RCL 05 141  RCL 02 142  RCL 03 143  - 144  SIN 145  ST* Y 146  + 147  + 148  RCL 04 149  2 150  - 151  RCL 05 152  * 153  3 154  * 155  - 156  5598 157  + 158  73 159  RCL 00 160  * 161  150 162  - 163  RCL 00         164  * 165  1544 166  + 167  RCL 00 168  X^2 169  * 170  + 171   E3 172  / 173  RCL 07 174  + 175  INT 176  LASTX 177  FRC 178  X<0? 179  DSE Y 180  ""    181  24 182  ST* Y 183  MOD 184  HMS 185  X<>Y 186  XEQ "DT" 187  RCL 04 188  END

( 289 bytes / SIZE 008 )

 STACK INPUTS OUTPUTS Z / HH.MNSS Y / YYYY.MNDD X yyyy.mndd Phase

where  yyyy.mndd  is an approximate date

Phase = 0  for a New Moon
Phase = 1  for a First Quarter
Phase = 2  for a Full Moon
Phase = 3  for a Last Quarter

YYYY.MNDD  &  HH.MNSS  are the date & time ( in Terrestrial Time ) of the Phase

Example:

-3101.0210      XEQ "PHASE"      returns:                                                   ---Execution time = 20s---

0                          A New Moon occured
RDN    -3101.0217                     on  -3101/02/17                        Julian Calendar             ( -3101 = 3102 B.C. )
RDN         22.5512                      at    22h55m  TT

Program#3

-A little shorter.

Data Registers:    R00 thru R06: temp
Flags:
/
Subroutines:
"J0" & "DT"  ( cf "Julian & Gregorian Calendars for the HP-41" )  or "J1" & "D1" or "J2" & "D2"

 01 LBL "PHASE"  02 DEG  03 XEQ "J1"  04 7.382647  05 STO 03  06 /  07 INT  08 STO 06  09 ST* 03  10 4  11 MOD  12 STO 04  13 2  14 STO 02  15 X#Y?  16 ST- 02  17 ST/ 02  18 MOD  19 STO 05  20 221  21 *  22 RCL 02            23 -  24 407  25 +  26 RCL 06 27 96.45423  28 *  29 21.6  30 +  31 STO 00  32 SIN  33 *  34 RCL 06  35 7.2763  36 *  37 2.6  38 +  39 STO 01  40 SIN  41 172  42 RCL 02  43 +  44 *  45 +  46 RCL 05            47 7  48 *  49 16  50 -  51 RCL 00  52 ST+ X 53 SIN  54 *  55 -  56 RCL 05  57 5  58 -  59 ST+ X  60 RCL 06  61 195.335  62 *  63 39  64 -  65 STO 02  66 SIN  67 *  68 -  69 RCL 05  70 ST+ X  71 7  72 -  73 RCL 00            74 RCL 01  75 -  76 SIN  77 *  78 + 79 RCL 05  80 7  81 *  82 5  83 +  84 RCL 00  85 RCL 01  86 +  87 SIN  88 *  89 +  90 RCL 01  91 ST+ X  92 SIN  93 ST+ X  94 +  95 RCL 05  96 RCL 00  97 RCL 02            98 -  99 SIN 100 ST* Y 101 + 102 + 103 RCL 04 104 2 105 - 106 RCL 05 107 * 108 3 109 * 110 - 111 5598 112 + 113 3 114 10^X 115 / 116 RCL 03         117 + 118 INT 119 LASTX 120 FRC 121 X<0? 122 DSE Y 123 FRC 124 24 125 ST* Y 126 MOD 127 HMS 128 X<>Y 129 XEQ "D1" 130 RCL 04 131 END

( 200 bytes / SIZE 007 )

 STACK INPUTS OUTPUTS Z / HH.MNSS Y / YYYY.MNDD X yyyy.mndd Phase

where  yyyy.mndd  is an approximate date

Phase = 0  for a New Moon
Phase = 1  for a First Quarter
Phase = 2  for a Full Moon
Phase = 3  for a Last Quarter

YYYY.MNDD  &  HH.MNSS  are the date & time ( in Terrestrial Time ) of the Phase

Example:

2023.0815   XEQ "PHASE"  >>>>      0                  ( New Moon )                 ---Execution time = 13s---
RDN                2023.0816
RDN                   9.4159

Notes:

-All results are expressed in Terrestrial Time. The difference TT - UT can be approximated by a formula given by Morrison & Stephenson:
TT - UT ( in seconds ) = -15 + ( 32.5 +/- 2 ).( t - 0.1 )2  where t is measured in centuries from AD 1800.

-Many other periodic terms are given in "Astronomical Algorithms"

Reference:

[1]  Jean Meeus , "Astronomical Algorithms" - Willmann-Bell  -  ISBN 0-943396-61-1