Diminishing Returns Formula





3
Date Submitted Sun. Oct. 7th, 2007 3:47 AM
Revision 1 of 1
Helper chaos
Tags "diminishing returns" | formula | JavaScript | math
Comments 0 comments
A simple, flexible formula for generating diminishing returns out of input numbers. Full explanation and home, with sample calculators and versions of the code in other languages, on the Lost Souls MUD Grimoire.

function diminishing_returns(val, scale) {
    if(val < 0)
        return -diminishing_returns(-val, scale);
    var mult = val / scale;
    var trinum = (Math.sqrt(8.0 * mult + 1.0) - 1.0) / 2.0;
    return trinum * scale;
}
 

Comments

There are currently no comments for this snippet.

Voting

Votes Down