Click here to Skip to main content
15,900,973 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Recognizing Chart Trends Pin
Newbie1814-Jul-12 3:00
Newbie1814-Jul-12 3:00 
AnswerRe: Recognizing Chart Trends Pin
Eddy Vluggen14-Jul-12 3:25
professionalEddy Vluggen14-Jul-12 3:25 
GeneralRe: Recognizing Chart Trends Pin
Newbie1815-Jul-12 1:34
Newbie1815-Jul-12 1:34 
AnswerRe: Recognizing Chart Trends Pin
Eddy Vluggen15-Jul-12 5:24
professionalEddy Vluggen15-Jul-12 5:24 
AnswerRe: Recognizing Chart Trends Pin
Kenneth Haugland24-Jul-12 10:44
mvaKenneth Haugland24-Jul-12 10:44 
Generalalgorithmic approach to calculating number of full moon since a certain date ? Pin
BillWoodruff1-Jul-12 1:39
professionalBillWoodruff1-Jul-12 1:39 
GeneralRe: algorithmic approach to calculating number of full moon since a certain date ? Pin
Richard MacCutchan1-Jul-12 6:23
mveRichard MacCutchan1-Jul-12 6:23 
GeneralRe: algorithmic approach to calculating number of full moon since a certain date ? Pin
jsc423-Sep-12 23:46
professionaljsc423-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):
C#
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 ? Pin
Richard MacCutchan4-Sep-12 0:22
mveRichard MacCutchan4-Sep-12 0:22 
AnswerRe: algorithmic approach to calculating number of full moon since a certain date ? Pin
Peter_in_27802-Jul-12 20:41
professionalPeter_in_27802-Jul-12 20:41 
GeneralRe: algorithmic approach to calculating number of full moon since a certain date ? Pin
Luc Pattyn2-Jul-12 22:02
sitebuilderLuc Pattyn2-Jul-12 22:02 
QuestionShortest Path on Unweighted Edges Pin
maxx231024-Jun-12 17:25
maxx231024-Jun-12 17:25 
AnswerRe: Shortest Path on Unweighted Edges Pin
Luc Pattyn24-Jun-12 18:07
sitebuilderLuc Pattyn24-Jun-12 18:07 
GeneralRe: Shortest Path on Unweighted Edges Pin
maxx231024-Jun-12 18:33
maxx231024-Jun-12 18:33 
AnswerRe: Shortest Path on Unweighted Edges Pin
Luc Pattyn24-Jun-12 19:04
sitebuilderLuc Pattyn24-Jun-12 19:04 
AnswerRe: Shortest Path on Unweighted Edges Pin
BupeChombaDerrick25-Jun-12 11:48
BupeChombaDerrick25-Jun-12 11:48 
AnswerRe: Shortest Path on Unweighted Edges Pin
Luc Pattyn25-Jun-12 11:56
sitebuilderLuc Pattyn25-Jun-12 11:56 
GeneralRe: Shortest Path on Unweighted Edges Pin
BupeChombaDerrick25-Jun-12 14:56
BupeChombaDerrick25-Jun-12 14:56 
GeneralRe: Shortest Path on Unweighted Edges Pin
Tadeusz Westawic9-Jul-12 5:00
Tadeusz Westawic9-Jul-12 5:00 
QuestionColor mixing algorithm Pin
Kobi_Z14-Jun-12 5:03
Kobi_Z14-Jun-12 5:03 
AnswerRe: Color mixing algorithm - Repost Pin
Richard MacCutchan14-Jun-12 5:38
mveRichard MacCutchan14-Jun-12 5:38 
GeneralRe: Color mixing algorithm - Repost Pin
Kobi_Z14-Jun-12 7:09
Kobi_Z14-Jun-12 7:09 
QuestionRe: Color mixing algorithm Pin
BupeChombaDerrick16-Jun-12 13:14
BupeChombaDerrick16-Jun-12 13:14 
AnswerRe: Color mixing algorithm Pin
Kobi_Z17-Jun-12 7:41
Kobi_Z17-Jun-12 7:41 
GeneralRe: Color mixing algorithm Pin
BupeChombaDerrick17-Jun-12 13:50
BupeChombaDerrick17-Jun-12 13:50 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.