mattsmi/EasterCalcsPython3

[question]

Closed this issue · 5 comments

First let me express my gratitude for the way you've laid your code, it really helps learning by example :-)
I've been experimenting with Easter Sunday calculations and came up to your way of calculating.
Alternatively, I've tried to create an algorithm according to the Bulgarian Christian Orthodox Church Code (Типик или Църковен устав, Синодално издателство, 1980г., scanned copy available at https://churchdocs.wordpress.com/2018/11/12/tipik/).
Basically they list a series of tables and instructions to divide the year to 28 and 19 and use the remainders to get column/row (outlined on p.510).
According to common knowledge, the BG Christian Orthodox Church should follow the Revised Julian Calendar.
Interestingly though, if I follow the instructions in the linked book, my calculations match yours only for the period b/w 1924 and 2099.
Any idea where I should look for the mistake :-)
Again, this is a 1980 publication, so I do have my doubts....

I have quickly checked my personal web site, which has a list of all possible Easter dates (Orthodox, Western, and Orthodox according to the Julian calendar) for the years AD 326 (after the First Ecumenical Council of Nicæa, AD 325) up to AD 4099, the last year, in which the current definition of the Gregorian Calendar will hold true (without an update). It appears to be working fine. (It does not use Python, so I wanted to check that against it first.)

I have checked a couple of other sites, and my web site appears to be correct (https://www.oocities.org/hjsmithh/Easter/EasterG.html , http://5ko.free.fr/en/easter.php ).

Then I checked the Python code that I have published, and to which you refer. I was initially concerned that I had accidentally left an old version there, and had not updated it. Thankfully, it contains the latest Python code. The Python script appears accurate for a random check in several centuries. (Before posting it, I had checked every year in each calendar for accuracy.)

So I think that the Python code is indeed accurate. The problem lies in your interpretation or realisation of the calculation from the Bulgarian typikon.

I suspect that your problem lies in rounding. I had trouble with Python, CLIPS, and a couple of other programming languages, when their rounding or their precision was not accurate enough. I had to rewrite the code to take that into account. One of the changes I had to make was to make the calculations much simpler — no long lines of calculations that would be held in memory.

Using the mathematical floor function is critical to the Easter calendrical calculations. Hence my use of the Python floor division operator (//).

Are you using integer division (accidentally)? Are you calculating with floating point numbers or integers (integers are fine, but you must take that into account when dividing)? Are you flooring your divisions?

Lastly, if it helps, I have published the calculations in two other languages (Tcl and CLIPS ). Looking at that code might also give you some clues.

I think the error is not in rounding, because I'm using the python operator '%' and then with the remainder (which is an integer) I look up values in tables, so there are no float calculations.
Moreover, if I use the tables in the typikon and do calculations by hand and get the same result as my code shows - 1 day difference from your table, starting 2100:
BG typkon gives May 1st 2100, your table gives May 2nd 2100.
I remember reading somewhere there's a constant for calculating Julian vs Gregorian and that that constant should change every century, so I'll keep reading.
I think the table might be in the tables, but I'm worried that if I ask a cleric are there any amendments for after year 2100 they might think I'm crazy.

also, 2 days difference after year 2200, 3 days difference after 2300, etc.

Don't worry. If your Bulgarian clergy are anything like the ones I deal with, there will be only one among them all, who might understand what you are saying! :)

Yes, your Julian and Gregorian calculations must take into account the difference, which changes. See here; the difference is currently 13 days, but in 2100, it becomes 14 days. It might seem like a constant, but it is really a variable. It is just that the variable changes very slowly (depending on leap years not recognised by the Gregorian calendar but still valid in the Julian calendar).

See my code from Lines 92 to 101. I have to calculate the difference between the Julian and Gregorian calendars each time.

You will have to add a calculation to allow for that difference in your own workings. Otherwise, your dates will not be valid for years later than 2100.

Am glad we found it!

Thanks, solved! You've provided a great number of resources, starting to go through them all :-)