simple-squiggle

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

csch.js (1627B)


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