Readable easter algorithm?

I found this algorithm on the net that computes the easter day of a year:

/**

* Get easter day in a year (easter sunday).

*

* @param year Year to get easter date of.

* @return Date of easter in <i>year</i>.

*/

staticpublic Date getEasterDate(int year){

Date result =null;

int a = year % 19;

int b = year / 100;

int c = year % 100;

int d = b / 4;

int e = b % 4;

int f = ( b + 8 ) / 25;

int g = ( b - f + 1 ) / 3;

int h = ( 19 * a + b - d - g + 15 ) % 30;

int i = c / 4;

int k = c % 4;

int l = (32 + 2 * e + 2 * i - h - k) % 7;

int m = (a + 11 * h + 22 * l) / 451;

int p = (h + l - 7 * m + 114) % 31;

int month = ( h + l - 7 * m + 114 ) / 31;

int day = p + 1;

GregorianCalendar gc =new GregorianCalendar(year, month - 1, day);

result = gc.getTime();

return result;

}//getEasterDate()

... not very readable, but it works. Is there another algorithm that is more human readable to understand?

[1892 byte] By [MartinHilperta] at [2007-10-1 18:43:44]
# 1
Well, you could improve the readability of that a lot. a,b,c... are not the best variable names. Some of these values would be hard to give good names to but b and c could clearly have better names.
dubwaia at 2007-7-11 13:49:28 > top of Java-index,Other Topics,Algorithms...
# 2

Sorry, the documentation got separated from the code.

A simple google on "derivation easter algorithm" retrieves the doc,

http://www.math.nus.edu.sg/aslaksen/projects/nyl-hp.pdf

The documentation is very thorough being 80 pages in length, referencing as it must the 19 year Metonic cycle, the Georgian calendar, and of course the first ecumenical council meeting in Nicaea of 325 AD.

Personally, I think that the code is pretty obvious, you must relate the rate that the earth goes around the sun, to the rate that the moon goes around the earth to the rate the earth rotates, all of which are real numbers, not convenient little fractions, so you approximate the reals with fractions. (just like Greg did for his calendar. Well, not really Greg. Actually it was principally the astronomer Jesuit Christopher Clavius, that came up with the proposal that Pope Gregory III issued as papal bull, Inter Gravissimas, on 24 February 1582 thereby establishing what is now known as the Gregorian calendar reform.)

Anyway, cruise right out to the docs and check out the reasoning, though as I said it really is just a straight forward implementation of the fact that

"The tropical year is the period between the occurrence of one vernal equinox and the next. Some sources refer to this instead as the vernal equinox year. However for the scope of this supplement, this definition of tropical year is adequate. Astronomically, the average length of the tropical year is 365.24219 days. The synodic month or lunation is the period from one phase of the moon to its next occurrence. Two commonly phases used are the new moon and the full moon. The astronomical average lunation is 29.53059 days long."

Enjoy!

marlin314a at 2007-7-11 13:49:28 > top of Java-index,Other Topics,Algorithms...
# 3
> Is there another algorithm that is more human readable to understand?Yes.Easter falls on the first Sunday following the first ecclesiastical full moon that occurs on or after the day of the vernal equinox
tschodta at 2007-7-11 13:49:28 > top of Java-index,Other Topics,Algorithms...
# 4
I thought easter was a religious date but it seems that it's highly mathematical / astronomical ... :-/
MartinHilperta at 2007-7-11 13:49:28 > top of Java-index,Other Topics,Algorithms...
# 5
Vernal equinox is fixed.The first ecclesiastical (connected with the Christian religion) full moon on or after vernal equinox has a 19 year cycle.Computing day-of-week is trivial.
tschodta at 2007-7-11 13:49:28 > top of Java-index,Other Topics,Algorithms...
# 6

Fromint a = year % 19;

int h = ( 19 * a + b - d - g + 15 ) % 30;

you can glean the cycleint ecclFullMoonDaysAfterVernalEquinox = (19*(year%19)+ [i]24[/i] )%30;

The rest of it seems to be an attempt at obfuscation?

tschodta at 2007-7-11 13:49:28 > top of Java-index,Other Topics,Algorithms...
# 7
> Vernal equinox is fixed.Huh? You mean it shows up on the same day of the year?
jschella at 2007-7-11 13:49:28 > top of Java-index,Other Topics,Algorithms...
# 8

> > Vernal equinox is fixed.

>

> Huh? You mean it shows up on the same day of the year?

Well, in the context of determining Easter, yes.

In ecclesiastical terms the vernal equinox is 21 March.

The [url=http://en.wikipedia.org/wiki/Vernal_equinox]astronomical vernal equinox[/url] is a much more dynamic character.

tschodta at 2007-7-11 13:49:28 > top of Java-index,Other Topics,Algorithms...
# 9
that code is probably confusing because it is the answer to an exercise in an AP Computer Science cricullum =) (i remember doing it)
Linkera at 2007-7-11 13:49:28 > top of Java-index,Other Topics,Algorithms...
# 10
> Well, you could improve the readability of that a> lot. a,b,c... are not the best variable names. The algorithm was designed by a mathematician (Gauss if I'm not mistaken). Single-character variable names are de rigueur in mathematics.
DrClapa at 2007-7-11 13:49:28 > top of Java-index,Other Topics,Algorithms...
# 11

> > Well, you could improve the readability of that a

> > lot. a,b,c... are not the best variable names.

>

> The algorithm was designed by a mathematician (Gauss

> if I'm not mistaken). Single-character variable names

> are de rigueur in mathematics.

OK. That doesn't really make it easier to read, though.

dubwaia at 2007-7-11 13:49:28 > top of Java-index,Other Topics,Algorithms...