Jump To …

p.js

(function (global) {

var p = (function () {
  var that = {},
    Em1 = Math.E - 1;

  function expm1 (x) {
    if (Math.abs(x) < 1e-5) {
      return x + 0.5*x*x;
    } else {
      return Math.exp(x) - 1.0;
    }
  }

  function expm1dEm1 (x) {
    return expm1(x) / Em1;
  }

  function rexpm1dEm1 (x) {
    return 1 - expm1(x) / Em1;
  }

  function makeExpm1dXm1  (b) {
    return function (x) {
      return (Math.pow(b,x) - 1) / (b-1);
    };
  }

  function makeRexpm1dXm1 (b) {
    return function (x) {
      return 1 - (Math.pow(b,x) - 1) / (b-1);
    };
  }


  that.Em1 = Em1;
  that.expm1 = expm1;
  that.expm1dEm1 = expm1dEm1;
  that.rexpm1dEm1 = rexpm1dEm1;
  that.makeExpm1dXm1 = makeExpm1dXm1;
  that.makeRexpm1dXm1 = makeRexpm1dXm1;
  return that;
}());

if (typeof module != 'undefined' && module.exports) {
  module.exports = p;
} else {
  global.trurl = global.trurl || {};
  global.trurl.opcodes = global.trurl.opcodes || {};
  global.trurl.opcodes.p = p;
}

}(this));