Hi,
We all know how calculate a "Day of year" say also "YearDay".
A beautifull little routine stays in the WP34s Library for this.
But reverse is it possible, say I know the DOY and, of course, the year of this day of year ?
Yes it is possible with that little routine adapted from A POUPLIER in Jean MEEUS.
Code:
LBL'DYD' ; stand for the Date from a Year Day
#002
STO I
X<>Z
LEAP?
DEC I
[<=>] YZXX ; to fit the convenient stack
#032
X>? Y
SF 00
DROP
RCL I
X<>Z
DROP
+
RCL L
X<>Y
#009
x ; Multiplicate
2
7
5
/
#098
SDR 002
+
IP
FS?C 00
RCL/ X
STO 00
2
7
5
x ; Multiplicate
9
/
IP

RCL 00
9
+
#012
/
IP
RCL I
x ; Multiplicate
+
#030
+
RCL 00
SDR 002
+
X<>Y
SDR 006
+
RTN
END
Enter first YEAR and second DOY !
So, 1908 297 > 23,101908 my Father born
1914 169 > 18,061914 my Mother born
1907 90 > 31,031907
1908 91 > 31,031908
Gérard.
:
(11032015 05:37 PM)ggauny@live.fr Wrote: [ > ]Yes it is possible with that little routine adapted from A POUPLIER in Jean MEEUS.
Why not use the powerful features of the WP34s and make this program MUCH shorter?
Code:
001 LBL 'DYD'
002 # 001
003 [<>] XXZY
004 [>]DATE
005 x[<>] Y
006 DEC X
007 DAYS+
008 END
Franz
Hi Franz,
I see that I have a lot of thinks in programing !!!!
Really super, I've put this into my special folder where I copy all optimisations.
I've not think of this way. Really nice short and elegant routine !
I wish you good night, I wish me programing like this. First I learn, after I do as you and Dieter..... (May be ?)
Thank's you.
Gérard.
Really breathtaking !
Gérard.
(11032015 07:47 PM)ggauny@live.fr Wrote: [ > ]Really breathtaking !
It's the rich function set of the 34s that makes such programs possible – short, elegant and straightforward. For instance, if you know there is a DAYS+ command all you have to do is add the day number (minus one) to 1 Jan of that year. That's what Franz' program does in a few steps. It also shows that such a program actually is not really required – a manual calculation requires just a few keystrokes.
I suggest you take a trip through the IOP section of the 34s manual (index of operations) where you will find all those nice functions. Here and there I am still discovering details I did not know of before. ;)
Dieter
Hi Franz,
The genials things are always simple as said Einstein !
But how you reason to view like this, it is easy to copy but it is harder and better to understand as Masters reason, as masters dread the problems. In my youngth (23 years old) I was Champion of Lorraine in chess (First table), with reading, learnig, training yes but also because I was abble to see and reason better then my adversaries, Can't explain but we can learn this with goods professors. I think that you, Dieter and so others see better than the majority !
In other routine you cut it off the half, 49 steps to 29 steps !!!
Thank's again.
In french, in same situations, we say(a bit slang incorrect), "I'm on the ass !" !
Pardon....
Gérard.
huh:
Hi Dieter,
Y're right, as many I play with machine without deeply lear the manuals ! And I have the Walter Bonin manual. I'm going to stop programing like this and follow your advertising ! First learn, after programing !
Thank's
Gérard.
(11032015 08:29 PM)ggauny@live.fr Wrote: [ > ]I'm going to stop programing like this and follow your advertising ! First learn, after programing !
No, no! Learning and doing are two sides of the same thing.
So write programs. Then write better programs. Finally write perfect programs. ;)
Dieter
It is my wish, Dieter.
It is may be nut but I look at yours routines of you and Franz and so many other as a chidren in front of sugar shop !!!
Yes I think that in few time, I will programing as you all.....
My wife call me to go sleep, I go.... (with time, she is like my Mother, worth ! yes, yes)
Cheezr
Gérard.
This is only for Fhub/Franz.
(11042015 12:16 PM)ggauny@live.fr Wrote: [ > ]This is only for Fhub/Franz.
Hi Gérard!
This is one of the problems I don't really like, because you just need to put a long and complicated formula into a calculator program  simply boring.
And there's not much to 'optimize' apart from the usual tricks (using register arithmetics, complex registers etc.)
Since your picture doesn't really say what the result should be, I've found the following website which seems to use the same algorithm (but more clearly), and I've made the program 'GED' (Gregorian Easter Date) from these formulas:
http://ghiorzi.org/easterda.htm
It has 74 steps (incl. the subroutine 'LBL 00' which calculates 'div' in X and 'mod' in Y)  maybe it could be shortened by a few steps with some more optimizations (certainly not more than 3 or 4, I guess), but I think it's not worth trying this.
Code:
001 LBL'GED'
002 LocR 008
003 STO .00
004 # 019
005 MOD
006 STO .01
007 RCL .00
008 # 100
009 XEQ 00
010 [cmplx]STO .02
011 # 004
012 XEQ 00
013 [cmplx]STO .04
014 # 008
015 RCL+ .02
016 # 025
017 IDIV
018 # 001
019 RCL+ .02
020 RCL Y
021 # 003
022 IDIV
023 # 015
024 # 019
025 RCL[times] .01
026 +
027 RCL+ .02
028 RCL .04
029 RCL Y
030 # 030
031 MOD
032 STO .06
033 RCL .03
034 # 004
035 XEQ 00
036 RCL+ .05
037 RCL+ X
038 # 032
039 +
040 RCL .06
041 RCL Y
042 # 007
043 MOD
044 STO .07
045 RCL+ X
046 RCL+ .06
047 # 011
048 [times]
049 RCL+ .01
050 4
051 5
052 1
053 IDIV
054 # 007
055 [times]
056 # 114
057 RCL+ .06
058 RCL+ .07
059 RCL Y
060 # 031
061 XEQ 00
062 INC Y
063 RCL .00
064 SDR 004
065 +
066 SDR 002
067 +
068 RTN
069 LBL 00
070 [cmplx]ENTER
071 MOD
072 [<>] YZXT
073 IDIV
074 END
Franz
(11042015 04:33 PM)fhub Wrote: [ > ]This is one of the problems I don't really like, because you just need to put a long and complicated formula into a calculator program  simply boring.
And there's not much to 'optimize' apart from the usual tricks (using register arithmetics, complex registers etc.)
Easter programs for programmable calculators have a long tradition – exactly because they handle these long and complicated formulas. May I draw the gentlemen's attention for instance to this article:
An Easter program for the HP29C.
In general, there are several ways of computing the Easter date. Gauss himself changed his formula several times. A good overview can be found in the
respectice German wikipedia article. Please especially note the Lichtenberg formula at the end, as it directly includes two exceptions that else would have to be handled separately.
Dieter
(11052015 01:30 PM)Dieter Wrote: [ > ]Easter programs for programmable calculators have a long tradition – exactly because they handle these long and complicated formulas.
Well, I prefer short and simple formulas, e.g. calculating the Christmas date.
But seriously, since I'm atheist I'm not interested at all in any kinds of religious dates, and from a scientific point of view this Easter date is also absolutely uninteresting  it's just a 'human defined' special day of the year.
Franz