simple-squiggle

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

acsc.js (1717B)


      1 "use strict";
      2 
      3 Object.defineProperty(exports, "__esModule", {
      4   value: true
      5 });
      6 exports.createAcsc = 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 = 'acsc';
     15 var dependencies = ['typed', 'config', 'Complex', 'BigNumber'];
     16 var createAcsc = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
     17   var typed = _ref.typed,
     18       config = _ref.config,
     19       Complex = _ref.Complex,
     20       _BigNumber = _ref.BigNumber;
     21 
     22   /**
     23    * Calculate the inverse cosecant of a value, defined as `acsc(x) = asin(1/x)`.
     24    *
     25    * For matrices, the function is evaluated element wise.
     26    *
     27    * Syntax:
     28    *
     29    *    math.acsc(x)
     30    *
     31    * Examples:
     32    *
     33    *    math.acsc(0.5)           // returns number 0.5235987755982989
     34    *    math.acsc(math.csc(1.5)) // returns number ~1.5
     35    *
     36    *    math.acsc(2)             // returns Complex 1.5707963267948966 -1.3169578969248166 i
     37    *
     38    * See also:
     39    *
     40    *    csc, asin, asec
     41    *
     42    * @param {number | Complex | Array | Matrix} x   Function input
     43    * @return {number | Complex | Array | Matrix} The arc cosecant of x
     44    */
     45   return typed(name, {
     46     number: function number(x) {
     47       if (x <= -1 || x >= 1 || config.predictable) {
     48         return (0, _index.acscNumber)(x);
     49       }
     50 
     51       return new Complex(x, 0).acsc();
     52     },
     53     Complex: function Complex(x) {
     54       return x.acsc();
     55     },
     56     BigNumber: function BigNumber(x) {
     57       return new _BigNumber(1).div(x).asin();
     58     },
     59     'Array | Matrix': function ArrayMatrix(x) {
     60       return (0, _collection.deepMap)(x, this);
     61     }
     62   });
     63 });
     64 exports.createAcsc = createAcsc;