Cleve Moler is the author of the first MATLAB, one of the创始人Mathworks,目前是该公司的首席数学家。他是有关MATLAB的两本书的作者在线的。He writes here about MATLAB, scientific computing and interesting mathematics.
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 centuries ago. Easter is linked to the Jewish Passover. 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. The date varies between March 22 and April 25. There is aneaster程序中的程序Experiments with MATLAB。让今年的检查。
datestr(easter(2013))
ans = 31-Mar-2013
明年怎么样?
datestr(easter(2014))
ans = 20-Apr-2014
Don Knuth
Theexmprogram is based on the algorithm presented in the first volume of the classic series by Donald Knuth,计算机编程的艺术。Knuth has used it in several publications to illustrate different programming languages. The task has often been the topic of an exercise in computer programming courses. Knuth says that the algorithm is due to the Neapolitan astronomer Aloysius Lilius and the German Jesuit mathematician Christopher Clavious in the late 16th century and that it is used by most Western churches to determine the date of Easter Sunday for any year after 1582.
is not the ratio of small integers. However, in the 5th century BC, an astronomer from Athens named Meton observed that the ratio is very close to 235/19.
格式shortratio meton = 235/19
ratio = 12.3685 meton = 12.3684
In other words, 19 tropical years is close to 235 synodic months. This Metonic cycle was the basis for the Greek calendar and is the key to the algorithm for determining Easter.
MATLABprogram
Here is the complete MATLAB program.
%addpath ../../exm类型easter
function dn = easter(y) % EASTER Date of Easter. % EASTER(y) is the datenum of Easter in year y. % Ref: Donald Knuth, The Art of Computer Programming, % Fundamental Algorithms, pp. 155-156. % Golden number in 19-year Metonic cycle. g = mod(y,19) + 1; % Century number. c = floor(y/100) + 1; % Corrections for leap years and moon's orbit. x = floor(3*c/4) - 12; z = floor((8*c+5)/25) - 5; % Epact. e = mod(11*g+20+z-x,30); if (e==25 && g>11 || e==24), e = e + 1; end % Full moon. n = 44 - e; if n < 21, n = n + 30; end % Find a Sunday. d = floor(5*y/4) - x - 10; % Easter is a Sunday in March or April. d = n + 7 - mod(d+n,7); dn = datenum(y,3,d);
注释
To leave a comment, please click这里to sign in to your MathWorks Account or create a new one.