craig-moon

[ Originally published in Datafile, Vol 11 No 7/8, December 1992, page
55. ]

	      A Phase-of-the-Moon Program for the 32SII

				  by
			   Craig A. Finseth
			      member# ??


As I was pulling together the information for the HPDATAbase (by the
time you see this article, you should already know about *that*), I
needed a manual for the 32SII.  So I did the obvious thing and called
EduCALC and ordered one.

When the manual showed up, it turned out to be a copy of the manual
for the previous machine, the 32S.  Inside was a note from HP saying
that they had run out of 32S manuals and, since the machine was no
longer in production, they were shipping these copies instead.

I called EduCALC and it turned out that their entire stock of 32SII
manuals was just like this.  Apparantly, someone at HP had gotten
confused when shipping their last order.

EduCALC, of course, offered me a full refund for the wrong manual.  (I
decided to keep it as a curiosity.)  However, they didn't have any
32SII manuals in stock (as HP had shipped the wrong ones...this all
happened in one telephone call).  So, the person offered to ship me a
32SII saying that I could just return it after gleaning the
information from the manual.

The person there clearly knows his market.  After receiving the
machine and playing with it for a few days, I decided to keep it.

So, I now have this machine and want to do something interesting with
it.  And one thing that I like to see for all machines is the ability
to calculate the phase of the moon.  This is so that bugs that depend
on the phase of the moon can be properly excercised.  It would not do
to have a bug that is supposed to appear during a full moon show up
early in the first quarter.


ALGORITHM

The algorithm that I use in all of my phase of the moon programs is,
of course, wrong (poetic justice.)  The actual expression for the
phase of the moon has something like 30 sine terms.  I use a
single-term approximation.  This can produce results that vary from
the real phase by up to two days.

The start date and time (new moon) is	12 Jan 1975 10.21 GMT
The length of a cycle is		42532 minutes
The algorithm is

	fractional part ( (now - start) / cycle length )

The resulting fraction is interpreted as

	new moon	0
	first quarter	.25
	full moon	.50
	last quarter	.75

This same algorithm is used in all versions of my program (for the
41CX, 48SX, and in C for Unix and MSDOS computers).


THE 32SII VERSION

This was tricky, as the calculator has no clock or date arithmetic and
has very little memory.  I decided to only use the date and leave the
time out of it.  For the date arithmetic, which needs the number of
days between now and the start date, I used this formula:

	(y - 1975)*365.2423 + (m - 1)*30.5 + d - 12

which can be rewritten (with a trivial modification) to

	(y - 1975)*365.2423 + m*30.5 + d - 12 - 31

and, to take advantage of recall arithmetic to save space

	-( (1975 - y)*365.2423 - m*30.5 - d + 43 )

and the program itself is:

M01	LBL M
M02	INPUT Y
M03	INPUT M
M04	INPUT D
M05	1,975
M06	RCL- Y
M07	365.2422
M08	x
M09	30.5
M10	RCLx M
M11	-
M12	RCL- D
M13	43
M14	+
M15	+/-
M16	29.5361111	displays as 2.95361e1
M17	\:-
M18	FP
M19	SF 10
M20	ENTER
M21	ENTER
M22	4
M23	x
M24	IP
M25	x=0?
M26	NM		equation
M27	1
M28	-
M29	x=0?
M30	FQ		equation
M31	1
M32	-
M33	x=0?
M34	FM		equation
M35	1
M36	-
M37	x=0?
M38	LQ		equation
M39	Rv
M40	7.384
M41	x
M42	RTN

115.0 bytes, checksum 9B48

The program uses three variables (Y, M, and D) and all of the stack
levels.  It sets flag 10.


EXAMPLE

Here is an example of its use:

	display		key in

			XEQ M
	Y?		1991 R/S
	M?		12 R/S
	D?		18 R/S
	FQ		R/S
	2.9569839026	(i.e., not quite 3 days)

Areas

General

Craig's Articles

 

 
 

I am Craig A. Finseth.

Back to Home.

Back to top.

Last modified Saturday, 2012-02-25T17:29:05-06:00.