Determining Day of Given Date Mathematically

Computation of day of a week from given date belonging to any century has been a great quest among astronomers and mathematicians for long time. In recent centuries, thanks to efforts of some great mathematicians we now know methods of accomplishing this task. In doing so, people have developed various methods, some of which are very concise and compact but not much accessible explanation is provided. The chief purpose of this paper is to address this issue. Also, almost all known calculations involve either usage of tables or some pre-determined codes usually assigned for months, years or centuries. In this paper, I had established the mathematical proof of determining the day of any given date which is applicable for any number of years even to the time of BCE. I had provided the detailed mathematical derivation of month codes which were key factors in determining the day of any given date. Though the procedures for determining the day of given date are quite well known, the way in which they arrived is not so well known. This paper will throw great detail in that aspect. To be precise, I had explained the formula obtained by German Mathematician Zeller in detail and tried to simplify it further which will reduce its complexity and at the same time, would be as effective as the original formula. The explanations for Leap Years and other astronomical facts were clearly presented in this paper to aid the derivation of the compact form of Zeller’s Formula. Some special cases and illustrations are provided wherever necessary to clarify the computations for better understanding of the concepts.


Introduction
Ever since humans came to understand the functioning of universe for various reasons, various forms of calendars have been put in to use. Different civilizations used different calendars. Since October 1582, when Pope Gregory XIII introduced a new calendar as a correction to then existing Julian Calendar, various parts of the globe at different times, adopted the new calendar. At present, the calendar introduced by Pope Gregory XIII was followed throughout the globe and it was named in his honour as "Gregorian Calendar".
Before we start our actual mathematical investigation, we glance through the basic structure of Gregorian calendar system.
The Gregorian calendar is a solar calendar with 12 months of 28-31 days each. A regular Gregorian year consists of 365 days, but in certain years known as leap years, a leap day is added to February. Gregorian years are identified by consecutive year numbers. Various countries had their own beginning of the year until in recent centuries everyone had accepted the fact that January 1 as the beginning of a New Year. Thus, the present Gregorian calendar consider one year from 1 st January to 31 st December of any year containing 12 months and 365/366 days. In ancient times, astronomers knew only about seven planets. Probably this might be the reason for fixing seven days for a week. Hence, all the calendar calculations regarding determination of day of a given date were based on the number 7. Thanks to various mathematicians and astronomers we now have a global calendar satisfying our needs.

Leap Years
In the Gregorian calendar, the orbital period of the Earth around the Sun is not 365 days, but closer to 365.2425 days. To account for this longer period, every four years, we add an extra day (since 0.25 × 4 = 1) in February, to make 366 days.
But observe that 365.25 -365.2425 = 0.0075. So adding 1 day in February for every 4 years will produce an over estimate of 0.0075 × 4 = 3 days. To bring down these 3 days, it is suggested that the years like 1600, 1700, 1800, 1900, 2000, 2100, . . . (called centurial years) which are divisible by 4, would be considered as leap years if they are not only divisible by 4 but also by 400. This arrangement ensures us to count only 1 leap year and leaves 3 years among any consecutive 400 years period like 1301 -1600, 1601 -2000, 2001 -2400, etc.
Thus, among the period of 400 years from 1601 -2000, the years 1700, 1800, 1900 were not leap years though they are divisible by 4 but not by 400, whereas, 2000 is a leap year since it is divisible by both 4 and 400. In this viewpoint, we present the following rule for a year being a Leap Year (which will be crucial for our task of finding day of given date): "Every year that is exactly divisible by 4 is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400." As a consequence of the above rule, we see that, in the century from 1601 -1700, there are 24 leap years (as 1700 is not a leap year). Similarly, the centuries 1701 -1800, 1801 -1900 each contain 24 leap years (since 1800, 1900 are not leap years) but the century 1901 -2000 contain 25 leap years as 2000 is a leap year. Hence in every period of four consecutive centurial years, there will be (24×3) + 25 = 97 Leap years for every 400 years in Gregorian calendar.

Cyclic Property of Gregorian Calendar
In a period of every 400 years like say 1701 -2000 or 2001 -2400, ... we will find the total number of days. As there are 97 leap years in every 400 years the total number of days would be given by (

Known Formula for Determining Day of Given Date
Exactly 300 years after Gregorian calendar got introduced; the problem of finding day of a given date in compact computable form was studied by German mathematician Julius Christian Johannes Zeller, who published an elegant algorithm for the same in 1882. Now this algorithm was named after him as "Zeller's Congruence".
According to Zeller's Congruence rule, the day of any Here, x     is called the Floor Function or Greatest Integer Function of x .
x     is defined to be greatest integer x ≤ . As a consequence of this definition, we find that if 0 x > such that 1 Similarly, (mod 7) denote the remainder when the whole term inside the bracket is divided upon by 7.

Explanation of Zeller's Congruence Rule
Let us first rewrite the Zeller's Congruence Formula and try to understand it in a better perspective.
For a given date of the form d/m/Y, where d, m, Y represents the date, month and year respectively, we note that Zeller's Formula in (1) contain 6 terms inside the bracket. The first and third terms d and Y are included as it is for computation.
Using the Leap year rule mentioned in 2., we get the fourth, fifth and sixth terms given by 4 100 400 The second term regarding month m need little explanation.
When making these calculations, Zeller made a novel approach by beginning the year with the month of March (instead of January) and ending with February of next subsequent year. With this assumption, the twelve months of a year in formula (1), is considered from m = 3,4,5,...,14 where m = 3 corresponding to March, m = 4 for April and so on until m = 12 for December, m = 13 for January and m = 14 for February but Zeller took Y -1 instead of Y for the months January and February.
Thus for example, for calculating day corresponding to any date of January 2020, according to Zeller's formula we should consider m = 13 and Y = 2019 (As beginning with March of 2019, January 2020 is viewed as 13 th month of 2019). Similarly, for finding any date corresponding to February 2020, we should consider m = 14 since this is considered as 14 th and last month of the year 2019. This explains the reason for the term m = 3,4,5,...,14 associated with the formula (1).
If we now cumulative sum of five consecutive numbers from the above list we get 3 + 2 + 3 + 2 + 3 = 13, 2 + 3 + 2 + 3 + 3 = 13, 3 + 2 + 3 + 3 + 2 = 13, and so on. In general, any set of five consecutive numbers from the above modulo list of numbers will constitute three 3's and two 2's always giving a sum of 13. So for every 5 numbers we get a sum of 13. This explains the reason for the term 13/5 in the second term of formula (1). Since any week day should be one of seven days, we finally divide the answer obtained through 6 terms of the formula by 7 and take out the remainder explaining the term (mod 7) in the formula.
We know that when any integer is divided by 7, the possible remainders are 0, 1, 2, 3, 4, 5, 6. Now depending upon the remainder, we shall consider the following assignment of days corresponding to these remainders to decide the day of a given date. 0 -Saturday, 1 -Sunday, 2 -Monday, 3 -Tuesday, 4 -Wednesday, 5 -Thursday, 6 -Friday. Since 6 correspond to Friday, we know that Albert Einstein was born on Friday.

Sample Computations
Similar to these calculations, it is possible for us to determine the day of any given date. Note that if the date correspond to BCE, then add 401 and convert it in to CE, then proceed in the same way as presented above. Now that I have explained the formation and application of the Zeller's Congruence Formula, I will present ways to reduce the complexity of the formula presented above and also derive the month codes which will be used for several centuries at the same time thanks to Cyclic property of Gregorian calendar.

Rewriting Zeller's Formula
We see that if the year number Y is quite large as in the case for Einstein date, it is usually difficult to perform the calculation in our mind. We can reduce the size of Y suitably and make Zeller's original formula in much more compact way. In this part, I provide mathematical proofs for doing that.
If Y = 100c + y, where c denote the first two digits of Y and y denote the last two digits of Y. Note here that y varies from 0 to 99 (both 0 and 99 inclusive). With this assumption, we will calculate the third, fourth, fifth and sixth terms involved in Zeller's Formula.  (2) is a concise formula to find the day of any given date compared to the calculation involved through Equation (1). Moreover, Equation (2) is the usual reference of Zeller's formula in many sources for which we have obtained a mathematical derivation. We shall call Equation (2) as modified Zeller's Formula.

Derivation of Month Codes
In 7., we saw the reduction of Year number Y considerably with lesser numbers c, y. Here we use Equation (2) to derive month codes which will further reduce our calculation of finding day of any given date.
First, let us substitute each value of m from 3 to 14 (from March to February) successively in the second term ofZeller's formula which contains the information about months.
13 (  1) 13 (9 1)  9 (mod 7) (mod 7) 5 5 5 13( 1) 13(12 1) 12 (mod 7) (mod 7) 5 5 5 Since January and February months are considered for the previous year, we have to subtract 1 from the original second term to get correct codes for these months. Thus, we obtain 13( 1) 13(14 1) 13 1 (mod 7) 1 (mod 7) 0 5 5 Thus the month codes beginning from January to December would be the following numbers respectively: 0, 3, 3, 6,1, 4, 6, 2, 5, 0, 3, 5 (3) → Now, keeping the Cyclic Property in mind, we first segregate the centuries for every 400 years in to four classes as Class I: (1 -100, 401 -500, 801 -900, 1201 -1300 Note that according to the cyclic property, the days of each century in the corresponding class would be same. Hence, I try to derive the month codes each for the above four classes which will eventually cover all centuries. Now considering current century years which is from 2001 to 2100 beginning to Class I of our segregation, we find that c = 20. With this value of c, we try to compute fifth and sixth terms of the modified Zeller's formula given in Equation (2).
Similarly considering the century from 1701 -1800 belonging to Class II, we get c = 17. Doing as above, we obtain 17 17 2 (mod 7) 2 17 (mod 7) 5 4 4 The final answers namely 0, 5, 3, 1 for centuries belonging to corresponding classes will fix the month codes required for easy computation of the day of a given date.
Now since the answer for Class II is 5, the month codes for any century belonging to Class II are obtained by just adding (modulo 7) to each of the month codes of Class I given above.
In similar fashion, by adding 3 and 1 respectively to month codes of Class I, we get month codes of each century belonging to Class III and Class IV.

Remarks:
Note that upon applying these month codes to find day of a given date, we should follow the three rules given below:

Simplification of Actual Formula
Using these month codes, we can greatly simplify the modified Zeller's Formulas given in Equation (2). If we do so, we get the following compact formula: whereM is the month code for the century belonging to one of the four classes mentioned above. The formula described in Equation (4) is usually presented in many books and online sources for determining day of a given date. I have just provided the mathematical proof for arriving that result.
Thus depending on a normal year, normal leap year or centurial year knowing the class in which the given date belong, we can immediately compute the day quite easily without using any tools.

Proving an Important Fact
Using Equation (4) along with the rules presented in Remarks, we can prove the following interesting but important calendar fact mathematically.

Theorem:
"The last day of a century cannot be a Tuesday, Thursday or Saturday"