hp41programs

Eclipses

Eclipses for the HP-41


Overview
 

 1°)  Program#1
 2°)  Program#2 ( lower accuracy )
 3°)  Eclipses+Phases of the Moon #1
 4°)  Phases of the Moon+Eclipses #2
 

-Programs #1 & #2 calculate the date & time of a Solar or a Lunar eclipse.
-The type of the eclipse is also determined: Partial, Annular, Total or Hybrid ( also called Annular-Total ) for a Solar eclipse
  and Partial or Total, Umbral or Penumbral for a Lunar eclipse.
-The magnitude is also returned.

-The first routine is valid a few centuries around J2000 with an accuracy of the order of a few minutes for the time of maximum eclipse.
-For the second and third programs, the accuracy is about 5 minutes over the time span [1900,2100]
-Program #4 has an accuracy of a few minutes for dates between 1000 and 3000 ( at least )
 

1°)  Program#1
 

Data Registers:   R00 thru R15: temp

                              R04 = 0  for a Solar eclipse        R03 = m'      R10 = gamma
                              R04 = 1  for a Lunar eclipse       R09 = m

       For a Solar eclipse, gamma =  the least "distance" from the center of the Earth to the axis of the Moon's shadow ( unit = Earth's radius )
       For a Lunar eclipse, gamma =  the least "distance" from the center of the Moon to the axis of the Earth's shadow ( unit = Earth's radius )

Flag:   F02 is set to indicate a Hybrid ( solar ) eclipse.
Subroutines:  "J0" & "DT"  ( cf "Julian & Gregorian Calendars for the HP-41" )  or "J1" & "D1" or "J2" & "D2"
 

-R06 contains an integer that is even for a Solar eclipse and odd for a Lunar eclipse.
-One is added to R06 until the HP-41 finds an eclipse.

-Line 07 may be replaced by  FLOOR
-Line 178 is a three-byte GTO 01
-Lines 322 & 324:   FLOOR and  FRC2  are 2 M-Code routines listed in "A Few M-Code Routines for the HP-41"
  but lines 322 to 326 may be replaced by     INT   LASTX   FRC   X<0?   DSE Y   FRC   24   ST* Y   MOD
 
 

 01  LBL "ECLIPSE"
  02  DEG
  03  XEQ "J0"
  04  14.7652944
  05  STO 05
  06  /
  07  INT
  08  STO 06
  09  GTO 00
  10  LBL 01
  11  ISG 06
  12  LBL 00
  13  .36
  14  RCL 06
  15  195.33525
  16  *
  17  160.71
  18  +
  19  STO 04
  20  SIN
  21  ABS
  22  X>Y?
  23  GTO 01
  24  CF 02
  25  125
  26  RCL 06
  27  .782
  28  *
  29  -
  30  SIN
  31  37
  32  /
  33  ST- 04
  34  RCL 06
  35  14.55268
  36  *
  37  2.55
  38  +
  39  STO 01
  40  SIN
  41  2070
  42  *
  43  RCL 01
  44  ST+ X
  45  STO 14
  46  SIN
  47  24
  48  *
  49  +
  50  RCL 06
  51  192.90847
  52  *
  53  201.56
  54  +
  55  STO 00
  56  RCL 01
  57  + 
  58  STO 12            
  59  SIN
  60  73
  61  *
  62  -
  63  RCL 00
  64  RCL 01
  65  -
  66  STO 13
  67  SIN
  68  67
  69  *
  70  +
  71  1
  72  RCL 06
  73   E6
  74  /
  75  -
  76  STO 15
  77  *
  78  RCL 00
  79  SIN
  80  392
  81  *
  82  -
  83  RCL 00
  84  ST+ X
  85  STO 11
  86  SIN
  87  116
  88  *
  89  +
  90  RCL 04
  91  ST+ X
  92  STO 02
  93  SIN
  94  118
  95  *
  96  +
  97  RCL 04
  98  COS
  99  STO 03
100  *
101  RCL 14
102  COS
103  20
104  *
105  RCL 01
106  COS
107  48
108  *
109  -
110  RCL 12
111  COS
112  60
113  * 
114  -
115  RCL 13            
116  COS
117  41
118  *
119  +
120  RCL 15
121  *
122  RCL 00
123  COS
124  3299
125  *
126  -
127  52207
128  +
129  RCL 04
130  SIN
131  *
132  +
133  1
134  RCL 03
135  ABS
136  208
137  /
138  -
139  *
140  STO 10
141  ABS
142  STO 07
143  RCL 01
144  COS
145  46
146  *
147  RCL 15
148  *
149  59
150  +
151  RCL 00
152  COS
153  182
154  *
155  -
156  RCL 11
157  COS
158  4
159  *
160  +
161  RCL 12
162  COS
163  5
164  *
165  -
166  STO 08
167  15433
168  +
169  RCL 06 
170  2
171  MOD
172  STO 04            
173  140
174  *
175  +
176  -
177  X>0?
178  GTO 01
179  CHS
180  STO 03
181  RCL 04
182  X=0?
183  GTO 00
184  10128
185  RCL 07
186  -
187  RCL 08
188  -
189  5450
190  ST/ 03
191  /
192  STO 09
193  GTO 02
194  LBL 00
195  RCL 07
196  9972
197  X>Y?
198  SF 02
199  RCL 08
200  ABS
201  +
202  X>Y?
203  GTO 00
204  CLX
205  X<> 03
206  5461
207  RCL 08
208  ST+ X
209  +
210  /
211  STO 09
212  GTO 02
213  LBL 00
214  RCL 07
215   E4
216  /
217  X^2
218  SIGN
219  ENTER^
220  STO 03
221  LASTX
222  -
223  X<0?
224  CLX
225  SQRT
226  46.4
227  *
228  RCL 08            
229  X<Y?
230  X<0?
231  CF 02
232  X<>Y
233  5461
234  ST- Z
235  -
236  /
237  X>Y?
238  STO 03 
239  STO 09
240  LBL 02
241  RCL 01
242  SIN
243  1721
244  RCL 04
245  6
246  *
247  +
248  *
249  RCL 13
250  SIN
251  73
252  *
253  +
254  RCL 12
255  SIN
256  50
257  *
258  -
259  RCL 14
260  SIN
261  21
262  *
263  +
264  RCL 01
265  RCL 11
266  +
267  SIN
268  6
269  *
270  +
271  RCL 15
272  *
273  4075
274  RCL 04
275  10
276  *
277  -
278  RCL 00
279  SIN
280  *
281  -
282  RCL 11            
283  SIN
284  161
285  *
286  +
287  RCL 02
288  SIN
289  97
290  *
291  -
292  RCL 00
293  RCL 02
294  -
295  SIN
296  23
297  *
298  -
299  RCL 00
300  RCL 02
301  +
302  SIN
303  12
304  *
305  +
306  RCL 00
307  RCL 11
308  +
309  SIN
310  4
311  *
312  -
313  55977
314  +
315   E4
316  ST/ 10
317  /
318  RCL 05
319  RCL 06
320  *
321  +
322  FLOOR
323  LASTX
324  FRC2
325  24
326  *
327  HMS
328  X<>Y
329  XEQ "DT"
330  RCL 03
331  RCL 09
332  R^
333  R^
334  END

 
    ( 505 bytes / SIZE 016 )
 
 

      STACK        INPUTS      OUTPUTS
           T             /            m'
           Z             /            m
           Y             /      HH.MNSS
           X     yyyy.mndd   YYYY.MNDD

    where   yyyy.mndd  is an approximate date

        YYYY.MNDD  is the date of the eclipse
          HH.MNSS      is the time of maximum eclipse

  For a Lunar Eclipse:

         m = magnitude of the umbral eclipse               m , m' > 1  for a total eclipse,                  if  m < 0  there is no umbral eclipse
         m' = magnitude of the penumbral eclipse         m , m' < 1  for a partial eclipse

  For a Solar Eclipse:

         m = magnitude of the eclipse                          m > 1  for a total or hybrid eclipse                m < 1  for a partial eclipse

         m' = 0   for a partial eclipse
         m' = 1   for an annular eclipse
         m' = m  for a total or hybrid eclipse                F02 will be set for a hybrid eclipse

Example1:

   2008.0701  XEQ "ECLIPSE"   >>>>   2008.0801                     --- Execution time = 39s ---
                                                    RDN       10.2230
                                                    RDN         1.0193
                                                    RDN         1.0193                           and flag F02 is clear

-So, there is a Total Solar eclipse on 2008/08/01 at 10h23mn TT and its magnitude = 1.019

-You also have R04 = 0 to confirm that it is a Solar eclipse.

-And  R10 = gamma = 0.8315 , therefore, the eclipse is visible in the northern hemisphere

-If  R10 < 0  the eclipse is visible in the southern hemisphere
-If  R10 is small ( compared to 1 ), the eclipse is visible from equatorial regions.

 >>>>  To search for the next eclipse, simply press  XEQ 01  without disturbing  R05 & R06

-Here, it yields in 34 seconds:              2008.0816
                                               RDN       21.1117
                                               RDN         0.8012
                                               RDN         1.8307

-Thus, there is a Lunar eclipse on 2008/08/16 at 21h11mn TT
-This eclipse is an umbral one ( m > 0 ) and its magnitude is m = 0.801

Example2:

     2013.1101   R/S   >>>>    2013.1103
                                 RDN         12.4713
                                 RDN           1.0078
                                 RDN           1.0078              and flag F02 is set

-So, there will be a Hybrid ( Annular/Solar )  eclipse on 2013/11/03 at 12h47mn TT and its magnitude = 1.008

Example3:

     2001.1225   R/S   >>>>    2001.1230
                                  RDN        10.3049
                                  RDN        -0.1241
                                  RDN         0.8846

-There was a Lunar eclipse on 2001/12/30 at 10h31mn TT
-Since m < 0 , it was not an umbral eclipse but a penumbral one and its magnitude was 0.885

Example4:

     2001.1201   R/S   >>>>    2001.1214
                                  RDN        20.5339
                                  RDN          0.9832
                                  RDN          1.0000               flag  F02 is clear

-Since m' = 1 and m < 1 , there was an Annular Solar eclipse on 2001/12/14 at 20h54mn TT  magnitude = 0.983
 

Notes:

-There is no ambiguity between Solar and Lunar eclipses after seeing registers Z and T
-But in order to get a clearer information, you could replace lines 330 to 333 by

   "LUNAR"   RCL 04   X=0?   "SOLAR"   CLX   RCL 03   RCL 09   R^   R^   AVIEW

-Other lines may of course be added so that the HP-41 displays the exact type of the eclipse, but it will cost several extra bytes...

-More periodic terms can be found in reference [1] to get the time of maximum eclipse with a better accuracy.
-I've also neglected several secular terms that should be added to seek eclipses that occurred more than 2 or 3 centuries ago.
 

2°)  Program#2
 

-In order to save bytes, we can round some coefficients and use less terms ( and a few "tricks" )
 

Data Registers:   R00 thru R14: temp

                               R04 = 0  for a Solar eclipse        R03 = m'      R10 = gamma
                               R04 = 1  for a Lunar eclipse       R09 = m

       For a Solar eclipse, gamma =  the least "distance" from the center of the Earth to the axis of the Moon's shadow ( unit = Earth's radius )
       For a Lunar eclipse, gamma =  the least "distance" from the center of the Moon to the axis of the Earth's shadow ( unit = Earth's radius )

Flag:   F02 is set to indicate a Hybrid ( solar ) eclipse.
Subroutines:  "J0" & "DT"  ( cf "Julian & Gregorian Calendars for the HP-41" )  or "J1" & "D1" or "J2" & "D2"

-Line 153 is  a three-byte  GTO 01
-Lines 268 to 272 may be replaced by     INT   LASTX   FRC   X<0?   DSE Y   FRC   24   ST* Y   MOD
 
 

  01  LBL "ECL"
  02  DEG
  03  XEQ "J0"
  04  14.7652944
  05  STO 05      
  06  /
  07  INT 
  08  STO 06
  09  GTO 00
  10  LBL 01
  11  ISG 06
  12  LBL 00
  13  .36
  14  RCL 06
  15  195.33525
  16  *
  17  372
  18  SQRT
  19  -
  20  STO 04
  21  SIN
  22  ABS
  23  X>Y?
  24  GTO 01
  25  CF 02
  26  RCL 06
  27  14.55268
  28  *
  29  13
  30  LN
  31  +
  32  STO 01
  33  SIN
  34  207
  35  *
  36  RCL 06
  37  192.90847
  38  *
  39  465
  40  SQRT
  41  +
  42  STO 00
  43  SIN
  44  39
  45  *
  46  +
  47  RCL 00
  48  ST+ X
  49  STO 11 
  50  SIN
  51  RCL 04      
  52  ST+ X
  53  STO 02
  54  SIN
  55  +
  56  11.7
  57  *
  58  +
  59  RCL 01
  60  ST+ X
  61  STO 14
  62  SIN
  63  ST+ X
  64  +
  65  RCL 00
  66  RCL 01
  67  +
  68  STO 12
  69  SIN
  70  RCL 00
  71  RCL 01
  72  -
  73  STO 13
  74  SIN
  75  -
  76  7
  77  *
  78  +
  79  RCL 04
  80  COS
  81  STO 03
  82  *
  83  5221
  84  RCL 01
  85  COS
  86  5
  87  *
  88  -
  89  RCL 14
  90  COS
  91  ST+ X
  92  +
  93  RCL 00
  94  COS
  95  330
  96  *
  97  +
  98  RCL 12      
  99  COS
100  6
101  *
102  +
103  RCL 13
104  COS
105  4
106  *
107  -
108  RCL 04
109  SIN
110  *
111  +
112  RCL 03
113  ABS
114  208
115  /
116  1
117  -
118  *
119  STO 10
120  ABS
121  STO 07
122  5.9
123  RCL 00
124  COS
125  18
126  *
127  +
128  RCL 01
129  COS
130  9
131  *
132  RCL 11
133  COS
134  +
135  RCL 12
136  COS
137  +
138  2
139  /
140  +
141  STO 08
142  1543
143  +
144  RCL 06      
145  2
146  MOD
147  STO 04
148  14
149  *
150  +
151  -
152  X>0?
153  GTO 01
154  CHS
155  STO 03
156  RCL 04
157  X=0?
158  GTO 00
159  1013
160  RCL 07
161  -
162  RCL 08
163  -
164  545
165  ST/ 03
166  /
167  STO 09
168  GTO 02
169  LBL 00
170  RCL 07
171  997.2
172  X>Y?
173  SF 02
174  RCL 08
175  ABS
176  +
177  X>Y?
178  GTO 00
179  CLX
180  X<> 03
181  546
182  RCL 08
183  ST+ X
184  +
185  /
186  STO 09
187  GTO 02
188  LBL 00
189  RCL 07      
190   E3
191  /
192  X^2
193  SIGN
194  ENTER^
195  STO 03 
196  LASTX
197  -
198  22
199  *
200  X<0?
201  CLX
202  SQRT
203  RCL 08
204  X<Y?
205  X<0?
206  CF 02
207  X<>Y
208  546
209  ST- Z
210  -
211  /
212  X>Y?
213  STO 03
214  STO 09
215  LBL 02
216  RCL 01
217  SIN
218  86
219  *
220  RCL 11
221  SIN
222  8
223  *
224  +
225  RCL 02
226  SIN
227  5
228  *
229  -
230  RCL 00
231  RCL 02
232  -
233  SIN
234  +
235  RCL 14
236  SIN
237  +
238  ST+ X
239  RCL 00      
240  SIN
241  407
242  *
243  +
244  RCL 13
245  SIN
246  7
247  *
248  -
249  RCL 12
250  SIN
251  5
252  *
253  +
254  RCL 00
255  RCL 02
256  +
257  SIN
258  -
259  5598
260  +
261   E3
262  ST/ 10
263  /
264  RCL 05
265  RCL 06
266  *
267  +
268  FLOOR
269  LASTX
270  FRC2
271  24
272  *
273  HMS
274  X<>Y
275  XEQ "DT"
276  RCL 03
277  RCL 09
278  R^
279  R^
280  END

 
   ( 401 bytes / SIZE 015 )
 

-The instructions are identical, for example:
 

   2008.0701  XEQ "ECL"   >>>>   2008.0801                     --- Execution time = 35s ---
                                            RDN       10.2424
                                            RDN         1.0191
                                            RDN         1.0191                           and flag F02 is clear

 So, there is a Total Solar eclipse on 2008/08/01 at 10h24mn TT and its magnitude = 1.019

 R10 = gamma = 0.8335 , therefore, the eclipse is visible in the northern hemisphere.
 

Notes:

-With respect to Solar eclipses over the interval [ 1900 , 2100 ]  the type of the eclipse is correctly found
  except on 1935/01/05 where the partial eclipse - magnitude = 0.001 - is not found at all!
  and on 1948/05/09:  there was an annular eclipse - magnitude = 0.9999 - whereas "ECL" gives a hybrid eclipse - magnitude = 1.0002.

-Three more bytes can be saved if you delete lines 213-212-194
-In this case, the HP-41 will return m' = 1 for annular, hybrid and total Solar eclipses
 
 

3°)  Eclipses + Phases of the Moon
 

-We can combine "ECL" and "PHASE" to reduce space memory.
-The phases of the Moon are usually defined by the difference between the longitudes of the Moon and the Sun ( 0° 90° 180° 270° )
-In the following routine, we use another definition i-e when the illuminated fraction of the Moon's disk equals 0 , 1/2 , 1 , 1/2
-Thus - unlike the standard definition - the instant of a Solar eclipse is identical to the instant of the New Moon
  ( likewise for a Lunar eclipse and a Full Moon )  which is perhaps more logical...
 

Data Registers:   R00 = M'-180°   where M' = Moon's mean anomaly               R05 = 7.382647         R08 = 1000 u  ( u = radius of the umbral cone )

                               R01 = M             where M = Sun's mean anomaly                   R06 = 4k                    R09 = 0 for New Moon or Full Moon
                               R02 = 2F            where  F = Moon's argument of latitude        R07 = phase               R09 = 1 for First Quarter or Last Quarter
                               R03 = m'                               R10 = m
                               R04 = F-180°, gamma          R11 = 2M'   R12 = M'+M-180°   R13 = M'-M-180°   R14 = 2M       R15 = 1000 | gamma |

       For a Solar eclipse, gamma =  the least "distance" from the center of the Earth to the axis of the Moon's shadow ( unit = Earth's radius )
       For a Lunar eclipse, gamma =  the least "distance" from the center of the Moon to the axis of the Earth's shadow ( unit = Earth's radius )

Flag:   F02 is set to indicate a Hybrid ( solar ) eclipse.
Subroutines:  "J0" & "DT"  ( cf "Julian & Gregorian Calendars for the HP-41" )  or "J1" & "D1" or "J2" & "D2"

-If you prefer the standard definitions for the New Moon and Full Moon,

    add   SF 10                                        after line 304
    add   X<0?  FS? 10  FS? 30  CHS    after line  42
    add   CF 10                                       after line  13

-If you prefer the standard definitions for the First and Last Quarters,
   replace line 93 by  -   and lines 83 to 86 by  3
-Lines 103 to 111 may be replaced by    FLOOR   LASTX   FRC2   24  *
-Line 242 is a three-byte  GTO 10
 
 

 01  LBL "PHASE"
  02  XEQ 05
  03  INT
  04  STO 06
  05  4
  06  MOD
  07  STO 07
  08  2
  09  MOD
  10  STO 09
  11  XEQ 06
  12  XEQ 07
  13  STO 04
  14  LBL 08
  15  RCL 09
  16  221
  17  *
  18  407
  19  +
  20  RCL 00
  21  SIN
  22  *
  23  RCL 01
  24  SIN
  25  172
  26  *
  27  +
  28  RCL 09
  29  7
  30  *
  31  16
  32  -
  33  RCL 11
  34  SIN
  35  *
  36  -
  37  RCL 09
  38  9
  39  * 
  40  5
  41  - 
  42  ST+ X 
  43  RCL 02 
  44  SIN
  45  *
  46  +
  47  RCL 09
  48  ST+ X
  49  7
  50  -
  51  RCL 13
  52  SIN
  53  *
  54  +
  55  RCL 09
  56  7
  57  *
  58  5
  59  +
  60  RCL 12         
  61  SIN
  62  *
  63  +
  64  RCL 14
  65  SIN
  66  RCL 00
  67  RCL 02
  68  -
  69  SIN
  70  +
  71  ST+ X
  72  +
  73  RCL 00
  74  RCL 02
  75  +
  76  SIN
  77  RCL 09
  78  ST+ X
  79  1
  80  -
  81  *
  82  +
  83  RCL 00
  84  COS
  85  9
  86  +
  87  RCL 07
  88  2
  89  -
  90  RCL 09
  91  *
  92  *
  93  +
  94  5598
  95  +
  96   E3
  97  ST/ 04
  98  /
  99  RCL 05
100  RCL 06
101  *
102  +
103  INT
104  LASTX 
105  FRC
106  X<0?
107  DSE Y
108  FRC
109  24
110  ST* Y
111  MOD
112  HMS
113  X<>Y
114  XEQ "DT"
115  RCL 07
116  RTN
117  LBL "ECL"
118  XEQ 05
119  2
120  /
121  INT 
122  ST+ X
123  STO 06         
124  GTO 00
125  LBL 10
126  2
127  ST+ 06
128  LBL 00
129  .36
130  XEQ 06
131  SIN
132  ABS
133  X>Y?
134  GTO 10
135  CF 02
136  RCL 06
137  4
138  MOD
139  STO 07
140  CLX
141  STO 09
142  XEQ 07
143  SIN
144  207
145  *
146  RCL 14
147  SIN
148  ST+ X
149  +
150  RCL 00
151  SIN
152  39
153  *
154  +
155  RCL 11
156  SIN
157  RCL 02
158  SIN
159  +
160  11.7
161  *
162  +
163  RCL 12
164  SIN
165  RCL 13
166  SIN
167  -
168  7
169  *
170  +
171  RCL 04
172  COS
173  STO 03
174  *
175  5221
176  RCL 01
177  COS
178  5
179  *
180  -
181  RCL 14         
182  COS
183  ST+ X
184  +
185  RCL 00
186  COS
187  330
188  *
189  +
190  RCL 12
191  COS
192  6
193  *
194  +
195  RCL 13
196  COS
197  4
198  *
199  -
200  RCL 04
201  SIN
202  *
203  +
204  RCL 03
205  ABS
206  208
207  /
208  1
209  -
210  *
211  STO 04
212  ABS
213  STO 15
214  5.9
215  RCL 00
216  COS
217  18
218  *
219  +
220  RCL 01
221  COS
222  9
223  *
224  RCL 11
225  COS
226  +
227  RCL 12
228  COS
229  +
230  2
231  /
232  +
233  STO 08
234  1543
235  +
236  RCL 07
237  7
238  *
239  +
240  -
241  X>0?
242  GTO 10 
243  CHS
244  STO 03         
245  RCL 07
246  X=0?
247  GTO 00
248  1013
249  RCL 15
250  -
251  RCL 08
252  -
253  545
254  ST/ 03
255  /
256  STO 10
257  GTO 09
258  LBL 00
259  RCL 15
260  997.2
261  X>Y?
262  SF 02
263  RCL 08
264  ABS
265  +
266  X>Y?
267  GTO 00
268  CLX
269  X<> 03
270  546
271  RCL 08
272  ST+ X
273  +
274  /
275  STO 10
276  GTO 09
277  LBL 00
278  RCL 15
279   E3
280  /
281  X^2
282  SIGN
283  ENTER^
284  STO 03
285  LASTX
286  -
287  22
288  *
289  X<0?
290  CLX
291  SQRT
292  RCL 08
293  X<Y?
294  X<0?
295  CF 02
296  X<>Y
297  546
298  ST- Z
299  -
300  /
301  X>Y?
302  STO 03         
303  STO 10
304  LBL 09
305  XEQ 08
306  CLX
307  RCL 03
308  RCL 10
309  R^
310  R^
311  RTN
312  LBL 05
313  XEQ "J0"
314  7.3826472
315  STO 05
316  /
317  DEG
318  RTN
319  LBL 06
320  RCL 06
321  97.667626
322  *
323  372
324  SQRT
325  -
326  STO 02
327  STO 04
328  ST+ 02
329  RTN
330  LBL 07
331  RCL 06
332  96.454234
333  *
334  465
335  SQRT
336  +
337  STO 00
338  STO 11
339  STO 12
340  STO 13
341  ST+ 11
342  RCL 06
343  7.27634
344  *
345  13
346  LN
347  +
348  STO 01
349  STO 14
350  ST+ 12
351  ST- 13
352  ST+ 14
353  END

 
    ( 503 bytes / SIZE 016 )
 
 

        STACK         INPUT  OUTPUT1(phase)  OUTPUT2(eclipse)
             T              /               /              m'
             Z              /       HH.MNSS              m
             Y              /    YYYY.MNDD        HH.MNSS
             X       yyyy.mndd          Phase     YYYY.MNDD

    where   yyyy.mndd  is an approximate date   and   Phase = 0 , 1 , 2 , 3  for  New Moon ,  First Quarter ,  Full Moon , Last Quarter.

        YYYY.MNDD  is the date of the phase or the eclipse
          HH.MNSS      is the time of the phase or the maximum eclipse

  For a Lunar Eclipse:

         m = magnitude of the umbral eclipse               m , m' > 1  for a total eclipse,                  if  m < 0  there is no umbral eclipse
         m' = magnitude of the penumbral eclipse         m , m' < 1  for a partial eclipse

  For a Solar Eclipse:

         m = magnitude of the eclipse                          m > 1  for a total or hybrid eclipse                m < 1  for a partial eclipse

         m' = 0   for a partial eclipse
         m' = 1   for an annular eclipse
         m' = m  for a total or hybrid eclipse                F02 will be set for a hybrid eclipse
 

Example1:

   2008.0801   XEQ "PHASE"   >>>>          0                                              --- Execution time = 17s ---
                                                  RDN    2008.0801
                                                  RDN        10.2424

  So, there is a New Moon on 2008/08/01 at 10h24mn TT                          10h16m16s  TT   with the standard definition

-Likewise,

   First Quarter on  2008/08/08  at  20h02m42  TT          20h21m17s  TT   with the standard definition
   Full Moon   on   2008/08/16  at  21h12m38  TT          21h19m43s  TT   with the standard definition
   Last Quarter on   2008/08/24  at  00h08m38  TT         23h52m45s  TT  on  2008/08/23  with the standard definition

Example2:

   2008.0701     XEQ "ECL"        >>>>   2008.0801                     --- Execution time = 39s ---
                                                    RDN       10.2424
                                                    RDN         1.0191
                                                    RDN         1.0191                           and flag F02 is clear

  There is a Total Solar eclipse on 2008/08/01 at 10h24mn TT and its magnitude = 1.019

-You also have R07 = 0 to confirm that it is a Solar eclipse.

-And  R04 = gamma = 0.8334 > 0   ( the eclipse is visible in the northern hemisphere )

-If  R04 < 0  the eclipse is visible in the southern hemisphere
-If  R04 is small ( compared to 1 ), the eclipse is visible from equatorial regions.

 >>>>  To search for the next eclipse, simply press  XEQ 10  without disturbing  R05 & R06

-Here, it yields:

                  2008.0816                            ( in 34 seconds )
       RDN       21.1238
       RDN        0.8045
       RDN        1.8328

  Partial Lunar eclipse on 2008/08/16  at  21h13mn TT ,  magnitude in the umbra = 0.804
 

Note:

-Three bytes can be saved if you delete lines 302-301-283
-The HP-41 will then return m' = 1 for annular, hybrid and total Solar eclipses
 

4°)  Phases of the Moon + Eclipses
 

-This routine calculates the phases of the Moon with the same - non-standard - definition as the 3rd program
-More secular terms have been used to produce an accuracy of about 5 minutes for dates between 1000 & 3000 and probably a little more...
 

Data Registers:   R00 = 4.k               R05 = 0 or 1         R10 = 2.F                        R15 = 7.38264721

                               R01 = m                 R06:   temp           R11 = 2.M'                      R16:    temp
                               R02 = m'                R07 = E                R12 = M'+M-180°
                               R03 = gamma         R08 = M' - 180°   R13 = M'-M-180°
                               R04 = phase           R09 = M               R14 = 2M

       For a Solar eclipse, gamma =  the least "distance" from the center of the Earth to the axis of the Moon's shadow ( unit = Earth's radius )
       For a Lunar eclipse, gamma =  the least "distance" from the center of the Moon to the axis of the Earth's shadow ( unit = Earth's radius )

Flag:   F02 is set to indicate a Hybrid ( solar ) eclipse.
Subroutines:  "J0" & "DT"  ( cf "Julian & Gregorian Calendars for the HP-41" )  or "J1" & "D1" or "J2" & "D2"

-Lines 108 to 116 may be replaced by    FLOOR   LASTX   FRC2   24   *
-Line 247 is a three-byte  GTO
 
 

 01  LBL "PHASE"
  02  XEQ 05
  03  INT
  04  STO 00
  05  4
  06  MOD
  07  STO 04
  08  XEQ 06
  09  XEQ 07
  10  LBL 08
  11  RCL 00
  12  2
  13  MOD
  14  STO 05
  15  221
  16  *
  17  407
  18  +
  19  RCL 08
  20  SIN
  21  *
  22  RCL 09
  23  SIN
  24  172
  25  *
  26  RCL 07
  27  *
  28  +
  29  RCL 05
  30  7
  31  *
  32  16
  33  -
  34  RCL 11
  35  SIN
  36  *
  37  -
  38  RCL 05
  39  9
  40  *
  41  5
  42  -
  43  ST+ X
  44  RCL 10
  45  SIN
  46  *
  47  +
  48  RCL 05
  49  ST+ X
  50  7
  51  -
  52  RCL 13
  53  SIN
  54  *
  55  +
  56  RCL 05
  57  7
  58  *
  59  5
  60  +
  61  RCL 12
  62  SIN 
  63  *
  64  +
  65  RCL 14         
  66  SIN
  67  RCL 08
  68  RCL 10
  69  -
  70  SIN
  71  +
  72  ST+ X
  73  +
  74  RCL 08
  75  RCL 10
  76  +
  77  SIN
  78  RCL 05
  79  ST+ X
  80  1
  81  -
  82  *
  83  +
  84  RCL 08
  85  COS
  86  9
  87  +
  88  RCL 04
  89  2
  90  -
  91  RCL 05
  92  *
  93  *
  94  +
  95  5598
  96  +
  97   E3
  98  ST/ 03
  99  /
100  RCL 00
101  RCL 15
102  *
103  +
104  RCL 16
105  70
106  /
107  +
108  INT
109  LASTX
110  FRC
111  X<0?
112  DSE Y
113  FRC
114  24
115  ST* Y
116  MOD
117  HMS
118  X<>Y
119  XEQ "DT"
120  RCL 04
121  RTN
122  LBL "ECL"
123  XEQ 05 
124  2
125  /
126  INT
127  1
128  -
129  ST+ X
130  STO 00         
131  LBL 10
132  2
133  ST+ 00
134  .36
135  XEQ 06
136  SIN
137  ABS
138  X>Y?
139  GTO 10
140  CF 02
141  RCL 00
142  4
143  MOD
144  STO 04
145  XEQ 07
146  SIN
147  207
148  *
149  RCL 07
150  *
151  RCL 14
152  SIN
153  ST+ X
154  +
155  RCL 08
156  SIN
157  39
158  *
159  +
160  RCL 10
161  SIN
162  RCL 11
163  SIN
164  +
165  11.7
166  *
167  +
168  RCL 12
169  SIN
170  RCL 13
171  SIN
172  -
173  7
174  *
175  +
176  RCL 03
177  COS
178  STO 02
179  *
180  5221
181  RCL 09
182  COS
183  5
184  * 
185  -
186  RCL 14
187  COS
188  ST+ X
189  +
190  RCL 08         
191  COS
192  330
193  *
194  +
195  RCL 12
196  COS
197  6
198  *
199  +
200  RCL 13
201  COS
202  4
203  *
204  -
205  RCL 03
206  SIN
207  *
208  +
209  RCL 02
210  ABS
211  208
212  /
213  1
214  -
215  *
216  STO 03
217  ABS
218  STO 05
219  5.9
220  RCL 08
221  COS
222  18
223  *
224  +
225  RCL 09
226  COS
227  9
228  *
229  RCL 11
230  COS
231  +
232  RCL 12
233  COS
234  +
235  2
236  /
237  +
238  STO 06
239  1543
240  +
241  RCL 04
242  7
243  *
244  +
245  -
246  X>0?
247  GTO 10 
248  CHS
249  STO 02
250  RCL 04
251  X=0?
252  GTO 00
253  1013
254  RCL 05         
255  -
256  RCL 06
257  -
258  545
259  ST/ 02
260  /
261  STO 01
262  GTO 09
263  LBL 00
264  RCL 05
265  997.2
266  X>Y?
267  SF 02
268  RCL 06
269  ABS
270  +
271  X>Y?
272  GTO 00
273  CLX
274  X<> 02
275  546
276  RCL 06
277  ST+ X
278  +
279  /
280  STO 01
281  GTO 09
282  LBL 00
283  RCL 05
284   E3
285  /
286  X^2
287  SIGN
288  STO 02
289  LASTX
290  -
291  22
292  *
293  X<0?
294  CLX
295  SQRT
296  RCL 06
297  X<Y?
298  X<0?
299  CF 02
300  X<>Y
301  546
302  ST- Z
303  -
304  /
305  STO 01
306  LBL 09
307  XEQ 08 
308  CLX
309  RCL 02
310  RCL 01         
311  R^
312  R^
313  RTN
314  LBL 05
315  XEQ "J0"
316  7.38264721
317  STO 15
318  /
319  DEG
320  RTN
321  LBL 06
322  RCL 00
323  97.667626
324  *
325  372
326  SQRT
327  -
328  STO 03
329  STO 10
330  ST+ 10
331  RTN
332  LBL 07
333  1
334  RCL 00
335  197 E4
336  /
337  -
338  STO 07
339  96.454234
340  RCL 00
341  ST* Y
342  47699
343  /
344  X^2
345  STO 16
346  +
347  465
348  SQRT
349  +
350  STO 08
351  STO 11
352  ST+ 11
353  STO 12
354  STO 13
355  RCL 00
356  7.276339
357  *
358  13
359  LN
360  +
361  STO 09
362  ST+ 12
363  ST- 13
364  STO 14
365  ST+ 14
366  END

 
   ( 527 bytes / SIZE 017 )
 
 

        STACK         INPUT  OUTPUT1(phase)  OUTPUT2(eclipse)
             T              /               /              m'
             Z              /       HH.MNSS              m
             Y              /    YYYY.MNDD        HH.MNSS
             X       yyyy.mndd          Phase     YYYY.MNDD

    where   yyyy.mndd  is an approximate date   and   Phase = 0 , 1 , 2 , 3  for  New Moon ,  First Quarter ,  Full Moon , Last Quarter.

        YYYY.MNDD  is the date of the phase or the eclipse
          HH.MNSS      is the time of the phase or the maximum eclipse

  For a Lunar Eclipse:

         m = magnitude of the umbral eclipse               m , m' > 1  for a total eclipse,                  if  m < 0  there is no umbral eclipse
         m' = magnitude of the penumbral eclipse         m , m' < 1  for a partial eclipse

  For a Solar Eclipse:

         m = magnitude of the eclipse                          m > 1  for a total or hybrid eclipse                m < 1  for a partial eclipse

         m' = 0   for a partial eclipse
         m' = 1   for an annular eclipse
         m' = m  for a total or hybrid eclipse                F02 will be set for a hybrid eclipse
 

Examples:

   3000.0715   XEQ "PHASE"   >>>>         3                    ( Last Quarter )
                                                  RDN    3000.0716
                                                  RDN        21.5653           Note the difference with the standard definition of phases:  21h38m01s

   3000.1016   XEQ "ECL"   >>>>    3000.1019                Flag  F02 is set, so we have a Hybrid ( Solar ) eclipse
                                              RDN        16.0807
                                              RDN     m = 1.0027              R03 = gamma = -0.2167
                                              RDN     m' = 1                      R04 = phase = 0 ( New Moon )

-The exact time is  16h10m16s and the exact m = 1.0049

-The instructions are identical to those of the program listed in §3, in particular:
 

>>>>  To search for the next eclipse, simply press  XEQ 10
 

-In the last example, it yields:

     3000/11/04     RDN    5h44m53s    RDN    m = -0.4165    RDN    m' = 0.5983       R03 = gamma = -1.2355       R04 = 2  ( Full Moon )

-Since  m < 0 , there is no eclipse in the umbra:  this Lunar eclipse is a penumbral one.
 

References:

[1]  Jean Meeus - "Astronomical Algorithms" - Willmann-Bell  -  ISBN 0-943396-61-1
[2]  Five Millennium Canon of Solar Eclipses: -1999 to +3000
[3]  http://eclipse.gsfc.nasa.gov/LEcat/LEcatalog.html