{"id":6873,"date":"2021-04-08T21:36:43","date_gmt":"2021-04-09T01:36:43","guid":{"rendered":"https:\/\/blogs.mathworks.com\/cleve\/?p=6873"},"modified":"2021-04-08T21:36:43","modified_gmt":"2021-04-09T01:36:43","slug":"easter-sunday-and-april-fools","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/cleve\/2021\/04\/08\/easter-sunday-and-april-fools\/","title":{"rendered":"Easter Sunday and April Fools"},"content":{"rendered":"\r\n<div class=\"content\"><!--introduction--><p>What do the years 2018, 2029 and 2040 have in common? They are the only years in the 21st century when Easter Sunday occurs on April Fools Day.<\/p><!--\/introduction--><h3>Contents<\/h3><div><ul><li><a href=\"#cd3f4165-3778-436f-b2c2-acbd99f83118\">Fool Meets Bunny<\/a><\/li><li><a href=\"#1d4af8fb-bf2d-464a-ba7f-04681f0a5b03\">21st Century<\/a><\/li><li><a href=\"#4ed98ef1-2cad-4797-8c08-4c56dc40d99a\">Easter Day<\/a><\/li><li><a href=\"#5766f6de-9662-402c-8e97-e70ace91e019\">Easter function<\/a><\/li><\/ul><\/div><h4>Fool Meets Bunny<a name=\"cd3f4165-3778-436f-b2c2-acbd99f83118\"><\/a><\/h4><pre class=\"codeinput\">    <span class=\"keyword\">for<\/span> y = 1:100\r\n       april_first = datenum(y+2000,4,1);\r\n       delta(y) = easter(y+2000) - april_first;\r\n    <span class=\"keyword\">end<\/span>\r\n    years = 2000 + find(delta == 0)\r\n<\/pre><pre class=\"codeoutput\">\r\nyears =\r\n\r\n        2018        2029        2040\r\n\r\n<\/pre><h4>21st Century<a name=\"1d4af8fb-bf2d-464a-ba7f-04681f0a5b03\"><\/a><\/h4><p>This plot shows the April Fools Easter Sundays in the 21st century and also shows that Easter can occur on any date between March 22 between April 25.<\/p><pre class=\"codeinput\">    p = plot(delta,<span class=\"string\">'.'<\/span>);\r\n    annotate(p,delta)\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/easter_blog_01.png\" alt=\"\"> <h4>Easter Day<a name=\"4ed98ef1-2cad-4797-8c08-4c56dc40d99a\"><\/a><\/h4><p>Easter Day is one of the most important events in the Christian calendar It is also one of the most mathematically elusive. In fact, regularization of the observance of Easter was one of the primary motivations for calendar reform. The informal rule is that Easter Day is the first Sunday after the first full moon after the vernal equinox. But the ecclesiastical full moon and equinox involved in this rule are not always the same as the corresponding astronomical events, which, after all, depend upon the location of the observer on the earth. Some details are in my <a href=\"https:\/\/blogs.mathworks.com\/cleve\/2013\/03\/18\/easter\">blog post from 2013<\/a>.<\/p><p>Computing the date of Easter is featured in Don Knuth&#8217;s classic <i>The Art of Computer Programming<\/i> and has consequently become a frequent exercise in programming courses.<\/p><p>Wikipedia has several relevant articles. <a href=\"https:\/\/en.wikipedia.org\/wiki\/Easter\">Easter<\/a>, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Computus\">Computus<\/a>, and <a href=\"https:\/\/en.wikipedia.org\/wiki\/Metonic_cycle\">Metonic_cycle<\/a>.<\/p><h4>Easter function<a name=\"5766f6de-9662-402c-8e97-e70ace91e019\"><\/a><\/h4><p>Here is the Easter function from <a href=\"https:\/\/www.mathworks.com\/content\/dam\/mathworks\/mathworks-dot-com\/moler\/exm\/chapters\/calendar.pdf\">Experiments in MATLAB<\/a>.  It is also available <a href=\"https:\/\/blogs.mathworks.com\/cleve\/files\/easter.m\">here<\/a>.<\/p><pre class=\"codeinput\">    <span class=\"comment\">% addpath ..\/exm<\/span>\r\n    type <span class=\"string\">easter<\/span>\r\n<\/pre><pre class=\"codeoutput\">\r\nfunction dn = easter(y)\r\n% EASTER  Date of Easter.\r\n% EASTER(y) is the datenum of Easter in year y.\r\n% Ref: Donald Knuth, The Art of Computer Programming,\r\n%      Fundamental Algorithms, pp. 155-156.\r\n\r\n%   Copyright 2014 Cleve Moler\r\n%   Copyright 2014 The MathWorks, Inc.\r\n% Golden number in 19-year Metonic cycle.\r\ng = mod(y,19) + 1;\r\n\r\n% Century number.\r\nc = floor(y\/100) + 1;\r\n\r\n% Corrections for leap years and moon's orbit.\r\nx = floor(3*c\/4) - 12;\r\nz = floor((8*c+5)\/25) - 5;\r\n\r\n% Epact.\r\ne = mod(11*g+20+z-x,30);\r\nif (e==25 &amp;&amp; g&gt;11 || e==24), e = e + 1; end\r\n\r\n% Full moon.\r\nn = 44 - e;\r\nif n &lt; 21, n = n + 30; end\r\n\r\n% Find a Sunday.\r\nd = floor(5*y\/4) - x - 10;\r\n\r\n% Easter is a Sunday in March or April.\r\nd = n + 7 - mod(d+n,7);\r\ndn = datenum(y,3,d);\r\n<\/pre><script language=\"JavaScript\"> <!-- \r\n    function grabCode_2a1f74e0a9894599805d1a8d37b3f1a5() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='2a1f74e0a9894599805d1a8d37b3f1a5 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 2a1f74e0a9894599805d1a8d37b3f1a5';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        copyright = 'Copyright 2021 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n\r\n        d.title = title + ' (MATLAB code)';\r\n        d.close();\r\n    }   \r\n     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_2a1f74e0a9894599805d1a8d37b3f1a5()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2020a<br><\/p><\/div><!--\r\n2a1f74e0a9894599805d1a8d37b3f1a5 ##### SOURCE BEGIN #####\r\n%% Easter Sunday and April Fools\r\n% What do the years 2018, 2029 and 2040 have in common?\r\n% They are the only years in the 21st century when Easter Sunday occurs\r\n% on April Fools Day.\r\n\r\n%% Fool Meets Bunny\r\n\r\n    for y = 1:100\r\n       april_first = datenum(y+2000,4,1);\r\n       delta(y) = easter(y+2000) - april_first;\r\n    end\r\n    years = 2000 + find(delta == 0)\r\n\r\n%% 21st Century\r\n% This plot shows the April Fools Easter Sundays in the 21st century\r\n% and also shows that Easter can occur on any date between \r\n% March 22 between April 25.\r\n\r\n    p = plot(delta,'.');\r\n    annotate(p,delta)\r\n    \r\n%% Easter Day\r\n% Easter Day is one of the most important events in the Christian calendar\r\n% It is also one of the most mathematically elusive. In fact, \r\n% regularization of the observance of Easter was one of the primary\r\n% motivations for calendar reform. The informal rule is that Easter Day\r\n% is the first Sunday after the first full moon after the vernal equinox.\r\n% But the ecclesiastical full moon and equinox involved in this rule are not\r\n% always the same as the corresponding astronomical events, which,\r\n% after all, depend upon the location of the observer on the earth. \r\n% Some details are in my\r\n% <https:\/\/blogs.mathworks.com\/cleve\/2013\/03\/18\/easter\r\n% blog post from 2013>.\r\n\r\n%%\r\n% Computing the date of Easter is featured in Don Knuth\u2019s classic\r\n% _The Art of Computer Programming_ and has consequently become a frequent\r\n% exercise in programming courses. \r\n\r\n%%\r\n% Wikipedia has several relevant articles.\r\n% <https:\/\/en.wikipedia.org\/wiki\/Easter Easter>,\r\n% <https:\/\/en.wikipedia.org\/wiki\/Computus Computus>, and\r\n% <https:\/\/en.wikipedia.org\/wiki\/Metonic_cycle Metonic_cycle>.\r\n\r\n    \r\n%% Easter function\r\n% Here is the Easter function from\r\n% <https:\/\/www.mathworks.com\/content\/dam\/mathworks\/mathworks-dot-com\/moler\/exm\/chapters\/calendar.pdf\r\n% Experiments in MATLAB>.  It is also available\r\n% <https:\/\/blogs.mathworks.com\/cleve\/files\/easter.m here>.\r\n\r\n    % addpath ..\/exm\r\n    type easter\r\n##### SOURCE END ##### 2a1f74e0a9894599805d1a8d37b3f1a5\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/easter_blog_01.png\" onError=\"this.style.display ='none';\" \/><\/div><!--introduction--><p>What do the years 2018, 2029 and 2040 have in common? They are the only years in the 21st century when Easter Sunday occurs on April Fools Day.... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/cleve\/2021\/04\/08\/easter-sunday-and-april-fools\/\">read more >><\/a><\/p>","protected":false},"author":78,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[11,5,34,4,37],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/6873"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/users\/78"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/comments?post=6873"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/6873\/revisions"}],"predecessor-version":[{"id":6875,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/6873\/revisions\/6875"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media?parent=6873"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/categories?post=6873"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/tags?post=6873"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}