Click here to Skip to main content
       

Algorithms

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Generalalgorithmic approach to calculating number of full moon since a certain date ? [modified]memberBillWoodruff1 Jul '12 - 1:39 
Edit: the location of this database of full moons: "Full Moon Dates Between (1900 - 2100)"[^] ... has eliminated my need to find an algorithm. But, I'll leave this "up," in case the link the database is useful to someone else.
 
No, I am not "into" astrology, but a friend asked me if I could write a calculator that given year, month, day, would indicate the number of full moons between that date, and the current date.
 
So, this is a question more of "curiosity," rather than one aimed at any practical result.
 
Here's a text-file dataset (times shown: GMT +1) of full moons from 1943-1953.[^]. Also see:[^].
 
What interests me is whether, given the variance between solar year time (in the "western" calendar, given "leap years," etc.) and lunar cycles, one can algorithmicly compute the number of years between the full moon falling on a certain day of the week in a specific week and month, and the next full moon falling on the same day of the month and week in the future.
 
Other potential complexities, of lunar cycle duration, and systems of lunation numbering, are well-described here:[^], and here:[^].
 
Now, if one had an algorithm that would compute the number of years with 13, rather than 12, moons per year, based on a starting year, month, date, I suppose that would make it easier.
 
Appreciate any thoughts, thanks, Bill
The glyphs you are reading now: are place-holders signifying the total absence of a signature.


modified 1 Jul '12 - 10:31.

GeneralRe: algorithmic approach to calculating number of full moon since a certain date ?mvpRichard MacCutchan1 Jul '12 - 6:23 
I have some code that calculates the date of Easter for any year, based on the first full moon after March 21st. I do not fully understand it but I know it works; I guess it could be adapted to what you are looking for.

GeneralRe: algorithmic approach to calculating number of full moon since a certain date ?memberjsc423 Sep '12 - 23:46 
Richard MacCutchan wrote:
date of Easter for any year, based on the first full moon after March 21st.

Note that the date of Easter (western, not Greek Orthodox or Russian Orthodox) relies on a specific definition of what is a Full Moon - it is 'as seen from Rome', and it is after the first Sunday after the 21st March which makes an unsubtle variation in the actual date (up to +/- 7 days) as seen from the observer's position because it may be Sunday earlier or later locally than it is in Rome. Gauss's algorithm does not work 100% of the time (IIRC there was at least one date in the 1800s that his algorithm got wrong).
 
This is the formula that I have been using for the last 35 years (changed language several times but same method):
Date.prototype.Easter   =   // Date of Easter Sunday for the year that the date object represents or for a given year
    function(optYear)   // Optionally can override year that the date is for
        // optYear can be a Date object or a numeric year
    {
        var year    = optYear
            ?   (   optYear.constructor == Date
                ?   optYear.getFullYear()
                :   ( optYear < 1900 ? optYear + 1900 : optYear )   // Assume number
                )
            :   this.getFullYear();
 
        // Algorithm optimised from 'Puzzles and Paradoxes' by T H O'Beirne
        // (Oxford University Press, London (c) 1965)
        var a   = year % 19;
        var b   = Math.floor(year / 100);
        var c   = year % 100;
        var d   = Math.floor(b / 4);
        var h   = (19 * a + b - d - Math.floor((8 * b + 13) / 25) + 15) % 30;
        var mu  = Math.floor((a + 11 * h) / 319) - h;
        var lambda  = (2 * (b - d * 4) + Math.floor(c / 4) * 6 - c + mu + 32) % 7 - mu;
        var month   = Math.floor((lambda + 90) / 25);
 
        return  new Date(year, month - 1, (lambda + month + 19) % 32);
    };  // Date.prototype.Easter
The variable names are based on the names in the original article cited in the comments but I have optimised the calculations (used to be 10 steps, now only 8 steps).
GeneralRe: algorithmic approach to calculating number of full moon since a certain date ?mvpRichard MacCutchan4 Sep '12 - 0:22 
I did not bother to check every year in the last 2000+, since it seemed to work for plus or minus 5 years since I started using it.
One of these days I'm going to think of a really clever signature.

AnswerRe: algorithmic approach to calculating number of full moon since a certain date ?memberPeter_in_27802 Jul '12 - 20:41 
For this sort of question, and many more such, my reference is Dershowitz & Reingold's Calendrical Calculations. I have a first ed dead tree; I think it's now up to 3rd ed. All the code from the book (Lisp!) is available for free download. I think there's also Java available.
Google knows more than me... (but do either of us understand?)
 
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012

GeneralRe: algorithmic approach to calculating number of full moon since a certain date ?mvpLuc Pattyn2 Jul '12 - 22:02 
A lunar month equals 29 days, 12 hours, 44 minutes; so I'd divide the timespan by that, yielding a pretty good estimate. It might be off by one if either one of the dates is just before/after a full moon.
 
Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 18 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid