simple-squiggle

A restricted subset of Squiggle
Log | Files | Refs | README

cosh.js (1489B)


      1 "use strict";
      2 
      3 Object.defineProperty(exports, "__esModule", {
      4   value: true
      5 });
      6 exports.createCosh = void 0;
      7 
      8 var _factory = require("../../utils/factory.js");
      9 
     10 var _collection = require("../../utils/collection.js");
     11 
     12 var _number = require("../../utils/number.js");
     13 
     14 var name = 'cosh';
     15 var dependencies = ['typed'];
     16 var createCosh = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
     17   var typed = _ref.typed;
     18 
     19   /**
     20    * Calculate the hyperbolic cosine of a value,
     21    * defined as `cosh(x) = 1/2 * (exp(x) + exp(-x))`.
     22    *
     23    * For matrices, the function is evaluated element wise.
     24    *
     25    * Syntax:
     26    *
     27    *    math.cosh(x)
     28    *
     29    * Examples:
     30    *
     31    *    math.cosh(0.5)       // returns number 1.1276259652063807
     32    *
     33    * See also:
     34    *
     35    *    sinh, tanh
     36    *
     37    * @param {number | BigNumber | Complex | Unit | Array | Matrix} x  Function input
     38    * @return {number | BigNumber | Complex | Array | Matrix} Hyperbolic cosine of x
     39    */
     40   return typed(name, {
     41     number: _number.cosh,
     42     Complex: function Complex(x) {
     43       return x.cosh();
     44     },
     45     BigNumber: function BigNumber(x) {
     46       return x.cosh();
     47     },
     48     Unit: function Unit(x) {
     49       if (!x.hasBase(x.constructor.BASE_UNITS.ANGLE)) {
     50         throw new TypeError('Unit in function cosh is no angle');
     51       }
     52 
     53       return this(x.value);
     54     },
     55     'Array | Matrix': function ArrayMatrix(x) {
     56       return (0, _collection.deepMap)(x, this);
     57     }
     58   });
     59 });
     60 exports.createCosh = createCosh;