Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: JWinslow23 on January 31, 2014, 05:08:11 pm

Title: Easter Calculator
Post by: JWinslow23 on January 31, 2014, 05:08:11 pm
Here is code in TI-BASIC to calculate the day of Easter Sunday.
Code: [Select]
ClrHome
Input "YEAR?           ",Y
int(Y/E2             //Scientific E, not the variable E
50-30fPart((11(1+19fPart(Y/19))-Ans+int(Ans/4)+int(8(Ans+11)/25))/30
Ans+7-round(7fPart((int(23(3+(Ans>31))/9)+Ans-31(Ans>31)+2+Y+int(Y/4)-int(V/E2)+int(Y/400))/7),0
If Ans=50 or Ans=49 and 10<19fPart(Y/19
Ans-1
Disp sub("MARCHAPRIL",1+5(Ans>31),5
Output(3,7,round(Ans-31(Ans>31),0

Whaddaya think? Any improvements?
Title: Re: Easter Calculator
Post by: ClrDraw on January 31, 2014, 05:44:25 pm
That's a nice segment of code. I never knew there was so much math in determining the day Easter was on  ;)
Title: Re: Easter Calculator
Post by: JWinslow23 on January 31, 2014, 05:45:22 pm
Not really.

There's so much math in calculating the Paschal Full Moon.

Once that is known, then Easter is the Sunday after.
Title: Re: Easter Calculator
Post by: DJ Omnimaga on January 31, 2014, 07:02:25 pm
Wait wow, I didn't know Easter was determined like that lol. Anyway, nice :D
Title: Re: Easter Calculator
Post by: utz on February 01, 2014, 11:30:18 am
Supermarkets over here are already selling chocolate bunnies, so according to my calculations Easter is happening ... pretty damn soon enough :p
Title: Re: Easter Calculator
Post by: Xeda112358 on February 01, 2014, 03:00:02 pm
I'm not getting the right dates according to Wikipedia :/

Starting in 2012, it is off by 1, before that, it's just off. I copied it to Source Coder and edited the E2 things to be the correct one.

EDIT: Also, for suggestions, sub() can be used to divide by 100, using the fPart() method to do modulo has issues with rounding error, causing it to pass unexpected results, so you should use the int() method:
Code: [Select]
X-Nint(X/N
And you will save some more bytes by computing some of the constants and using the inverse token. For example, see these two lines:
Code: [Select]
50-30fPart((11(1+19fPart(Y/19))-Ans+int(Ans/4)+int(8(Ans+11)/25))/30
50-30fPart(30{^-1}(11+209fPart(Y/19)-Ans+int(Ans/4)+int(.32(Ans+11
Title: Re: Easter Calculator
Post by: JWinslow23 on February 01, 2014, 10:11:01 pm
OK, here's the code that should eliminate all rounding errors (unoptimized):

Code: [Select]
:int(Y/ᴇ2
:50-30fPart((11(1+19fPart(Y/19))-Ans+int(Ans/4)+int(8(Ans+11)/25))/30
:If Ans=50 or Ans=49 and 11≤19fPart(Y/19
:Ans-1
:round(Ans+7-7fPart((int(23(3+(Ans>31))/9)+Ans-31(Ans>31)+2+Y+int(Y/4)-int(Y/ᴇ2)+int(Y/400))/7),0

Optmizing soon.

Oh, and Xeda? That's what the final line's round( is for. To eliminate rounding errors.

And I tested, and the dates are correct.
Title: Re: Easter Calculator
Post by: Sorunome on February 02, 2014, 03:42:13 am
Wait wow, I didn't know Easter was determined like that lol. Anyway, nice :D
I thought it was first sunday after first fullmoon after the astronomic beginning of spring ???
Title: Re: Easter Calculator
Post by: JWinslow23 on February 02, 2014, 12:55:35 pm
Wait wow, I didn't know Easter was determined like that lol. Anyway, nice :D
I thought it was first sunday after first fullmoon after the astronomic beginning of spring ???

It is.

The Paschal Full Moon is basically that. The first full moon after the astronomic beginning of spring.