comp.lang.ada
 help / color / mirror / Atom feed
From: Randy MacDonald <randy@godin.on.ca>
Subject: Re: Friday 13th, try it yourself (was Language Wars..)
Date: 1996/09/23
Date: 1996-09-23T00:00:00+00:00	[thread overview]
Message-ID: <32462521.76DD@godin.on.ca> (raw)
In-Reply-To: 51bv60$8d@pheidippides.axion.bt.co.uk


I've reposted this message from Roger Hui, since his access to
the newsgroup didn't allow for posting to the other groups.
With apologies to the comp.lang.apl folk...

<BEGIN>

Subject: Re: Triskaidekanalysis
       Date: 21 Sep 96 05:35:19 GMT
       From: Roger Hui <Roger.Hui@SYMPATICO.CA>
Organization: UofNB News Gateway, Fredericton, CANADA
  Newsgroups:comp.lang.apl


A more recent and complete leap year rule specifies that years
divisible by 4000 are common (not leap) years.  In J, the following
verb is 1 if the argument is a leap year, and 0 if it is common:

   leapyear=: 0&(~:/ . =) @ (4000 400 100 4&(|/))

In words: Compute the remainder of division by 4000, 400, 100,
and 4.  If the number of 0 remainders is odd, then it is
a leap year; if even, then it is a common year.

The additional 4000-year rule is described in Guy Ottewell's
"The Astronomical Companion", 1979, Furman University, Greenville,
SC, USA, Telephone (803) 294-2208.  The reason for having the rule
is to bring the average calendar year closer to the tropical year
(within one day in 20000 years):

   1460969 days % 4000 years = 365.24225 days/year  (4000 year rule)
   146097  days % 400  years = 365.2425  days/year  (400  year rule)

Therefore, to determine the distribution of the 13-th day over
the days of the week, it is necessary to consider not just a
400 year cycle, but a 28000 year cycle.  (Actually the first
should be a 2800 year cycle, with a short cut to 400 years made
possible by the fact that 146097 is divisible by 7.)

The analysis can be done in J as follows:

   p=: 31 28,10$5$31 30       NB. days in month in common years
   q=: 31 29,10$5$31 30       NB. days in month in leap   years
   +/,(leapyear i.4000){p,:q  NB. # days in 4000 years
1460969

   y=: i.28000                NB. year numbers from 0 to 27999.

   d=: (leapyear y){p,:q      NB. # of days in each month in y
   $d                         NB. d is a 28000 by 12 matrix
28000 12
   5{.d                       NB. first 5 rows of d
31 28 31 30 31 30 31 31 30 31 30 31
31 28 31 30 31 30 31 31 30 31 30 31
31 28 31 30 31 30 31 31 30 31 30 31
31 28 31 30 31 30 31 31 30 31 30 31
31 29 31 30 31 30 31 31 30 31 30 31

   w=: 7| +/\ ,d              NB. day-of-week of every 13-th day of
month
   20 {. w                    NB. first 20 entries in w
3 3 6 1 4 6 2 5 0 3 5 1 4 4 0 2 5 0 3 6

   t=: /:~ (~.w) ,. #/.~ w    NB. sorted table of day-of-week, #
occurrences
   t
0 48000
1 48000
2 48000
3 48000
4 48000
5 48000
6 48000

The next example shows that a 4000-year cycle exhibits uneven
distribution.
Since the number of days in 4000 years (1460969) is not divisible by 7,
the unevenness is smoothed out when the cycle is lengthen by a factor of
7,
as above.

   /:~ (~.w) ,. #/.~ w=: 7 | +/\ , (leapyear i.4000){p,:q
0 6880
1 6840
2 6869
3 6851
4 6850
5 6870
6 6840

<END>




  parent reply	other threads:[~1996-09-23  0:00 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-09-13  0:00 language wars (results 13 September) last posting Roy Gardiner
1996-09-13  0:00 ` William Clodius
1996-09-13  0:00   ` Peter Seebach
1996-09-21  0:00     ` Robert Dewar
1996-09-21  0:00     ` Robert Dewar
1996-09-16  0:00   ` Robert Fahey
1996-09-18  0:00 ` James Giles
1996-09-18  0:00 ` Andrew Gierth
1996-09-18  0:00 ` Luke Chao
1996-09-18  0:00 ` Norman H. Cohen
1996-09-18  0:00 ` James Giles
1996-09-19  0:00 ` Andrew Gierth
1996-09-19  0:00 ` Daniel J. Long
1996-09-21  0:00   ` Ken Pizzini
1996-09-21  0:00   ` Ken Pizzini
1996-09-24  0:00     ` Art Schwarz
1996-09-26  0:00       ` Matthew D. Healy
1996-09-29  0:00         ` Randy MacDonald
1996-10-03  0:00           ` galina.kasminskaya
1996-10-03  0:00             ` Dave Tholen
1996-09-26  0:00       ` Ken Pizzini
1996-09-29  0:00         ` Paul Gilmartin
1996-09-19  0:00 ` Norman H. Cohen
1996-09-20  0:00 ` John Girash
1996-09-20  0:00   ` John Girash
1996-09-20  0:00 ` Friday 13th, try it yourself (was Language Wars..) Clinton Pierce
1996-09-21  0:00   ` Russell Mosemann
1996-09-21  0:00   ` Russell Mosemann
1996-09-25  0:00     ` Ken Pizzini
1996-09-25  0:00       ` Results of my test: Re: Friday 13th, try it yourself Lee Crites
1996-09-25  0:00         ` William Clodius
1996-09-27  0:00         ` Dik T. Winter
     [not found]           ` <52qpqt$1b3l@ilx018.iil.intel.com>
1996-10-02  0:00             ` Dik T. Winter
1996-10-02  0:00             ` Ken Pizzini
1996-09-26  0:00       ` Dr John Stockton
1996-09-26  0:00         ` Lee Crites
1996-09-26  0:00           ` Daan Sandee
1996-09-26  0:00             ` Jeff Drummond
1996-09-30  0:00               ` Ray Dunn
1996-09-26  0:00           ` John Winters
1996-09-26  0:00           ` Adam Beneschan
1996-09-27  0:00             ` Glen Clark
1996-09-27  0:00           ` CHI Research, Inc. 
1996-09-27  0:00             ` Lee Crites
1996-09-28  0:00               ` John Winters
1996-09-30  0:00               ` Adam Beneschan
1996-10-01  0:00             ` Mike McCarty
1996-09-26  0:00         ` Dr John Stockton
     [not found]         ` <199609302101.JAA04610@kauri.vuw.ac.nz>
1996-09-30  0:00           ` Lee Crites
1996-09-25  0:00     ` Friday 13th, try it yourself (was Language Wars..) Barrie Walker
1996-09-26  0:00       ` Jim Shapiro
1996-09-23  0:00   ` Matthew D. Healy
1996-09-23  0:00     ` Dik T. Winter
1996-09-25  0:00     ` Paul Gilmartin
1996-09-22  0:00 ` Dr John Stockton
1996-09-23  0:00 ` Dr John Stockton
1996-09-23  0:00 ` Randy MacDonald [this message]
1996-09-23  0:00   ` Dik T. Winter
1996-09-25  0:00   ` John Harper
1996-09-25  0:00     ` jupiter
1996-09-24  0:00 ` language wars (results 13 September) last posting Andrew Gierth
1996-09-24  0:00   ` Art Schwarz
  -- strict thread matches above, loose matches on Subject: below --
1996-09-25  0:00 Friday 13th, try it yourself (was Language Wars..) Barrie Walker
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox