The Calendar package, now obsolete, had functionality for "special dates"; in particular, EasterSunday[]. The documentation says it's been subsumed into the Wolfram Language. But it hasn't, at least not to any meaningful degree that I can see. How would I, for example, get the date of Easter Sunday from 1950 - 2050 in a useful form (i.e. something that gives me the equivalent of EasterSunday[#] & /@ Range[1950, 2050]? Free form input is very bad at doing things like this in a straightforward way. I don't care if Easter Sunday 2032 is the 91st anniversary of the Battle of Cape Matapan, I really don't.
Asked
Active
Viewed 488 times
9
J. M.'s missing motivation
- 124,525
- 11
- 401
- 574
David G
- 629
- 4
- 6
3 Answers
9
For reference, here is a Mathematica implementation of this algorithm from an anonymous source, and reproduced in a number of other references (e.g. Meeus):
SetAttributes[easter, Listable];
easter[y_Integer] := Module[{y19 = Mod[y, 19], b, c, d, e, h, i, k, l},
{b, c} = QuotientRemainder[y, 100];
{d, e} = QuotientRemainder[b, 4]; {i, k} = QuotientRemainder[c, 4];
h = Mod[19 y19 + b - d - Quotient[b + 1 - Quotient[b + 8, 25], 3] + 15, 30];
l = Mod[2 e + 2 i - h - k + 32, 7];
Prepend[QuotientRemainder[h + l - 7 Quotient[y19 + 11 (h + 2 l), 451] +
114, 31] + {0, 1}, y]]
Test:
Table[DataPaclets`CalendarDataDump`EasterSunday[k], {k, 1950, 2000}] ===
easter[Range[1950, 2000]]
True
As a belated bonus, here is a compact implementation of the computus for Greek Orthodox Easter, based on Meeus's version:
SetAttributes[easterGreek, Listable];
easterGreek[y_Integer] := Module[{p, q, r, u},
{p, q, r} = Mod[y, {19, 7, 4}]; u = Mod[19 p + 16, 30];
u = u + Mod[4 q + 2 r + 6 u, 7] + Quotient[y, 100] - Quotient[y, 400] - 12;
{y, 4 + Boole[u > 30], Mod[u, 30, 1]}]
This should work for the years 1500-5100.
J. M.'s missing motivation
- 124,525
- 11
- 401
- 574
7
Another undocumented interface similar to the one in Michael E2's answer
Developer`CalendarData[{#}, "Easter"] & /@ Range[1950, 2050]
Also, while the Calendar package has been deprecated, it is still present in the layout, in other words it is still possible to use EasterSunday
Needs["Calendar`"]
EasterSunday /@ Range[1950, 2050]
6
DataPaclets`CalendarDataDump`EasterSunday /@ Range[1950, 2050]
DataPaclets`CalendarDataDump`EasterSundayGreekOrthodox /@ Range[1950, 2050]
Michael E2
- 235,386
- 17
- 334
- 747
DataPaclets`CalendarDataDump`EasterSundayGreekOrthodox– Mr.Wizard Feb 18 '15 at 01:20Function. :o) – Mr.Wizard Feb 18 '15 at 01:22