• Jump To … +
    Either.js List.js Maybe.js Set.js Stream.js Thunk.js Tuple.js boolean.js char.js base.js extra.js fold.js map.js zipWith.js collection.js control.js curried.js eq.js floating.js fractional.js function.js integral.js match.js num.js numeric.js object.js ord.js realfrac.js register.js string.js type.js nodash.js
  • floating.js

  • ¶
    /* vim: set et sw=2 ts=2: */
    'use strict';
    
    module.exports = [ 'Math', function (Math) {
    
      return {
    
        exp: Math.exp,
    
        sqrt: Math.sqrt,
    
        log: Math.log,
    
        logBase: function (a, b) {
          return Math.log(a) / Math.log(b);
        },
    
        '** pow ^ ^^': Math.pow,
    
        sin: Math.sin,
    
        tan: Math.tan,
    
        cos: Math.cos,
    
        asin: Math.asin,
    
        atan: Math.atan,
    
        acos: Math.acos,
    
        sinh: Math.sinh || function (x) {
          return (Math.exp(x) - Math.exp(-x)) / 2;
        },
    
        tanh: Math.tanh || function (x) {
          if (x === Infinity) {
            return 1;
          } else if (x === -Infinity) {
            return -1;
          } else {
            return (Math.exp(x) - Math.exp(-x)) / (Math.exp(x) + Math.exp(-x));
          }
        },
    
        cosh: Math.cosh || function (x) {
          return (Math.exp(x) + Math.exp(-x)) / 2;
        },
    
        asinh: Math.asinh || function (x) {
          if (x === -Infinity) {
            return x;
          } else {
            return Math.log(x + Math.sqrt(x * x + 1));
          }
        },
    
        atanh: Math.atanh || function (x) {
          return Math.log((1 + x) / (1 - x)) / 2;
        },
    
        acosh: Math.acosh || function (x) {
          return Math.log(x + Math.sqrt(x * x - 1));
        }
    
      };
    }];