simple-squiggle

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

acsc.js (1492B)


      1 import { factory } from '../../utils/factory.js';
      2 import { deepMap } from '../../utils/collection.js';
      3 import { acscNumber } from '../../plain/number/index.js';
      4 var name = 'acsc';
      5 var dependencies = ['typed', 'config', 'Complex', 'BigNumber'];
      6 export var createAcsc = /* #__PURE__ */factory(name, dependencies, _ref => {
      7   var {
      8     typed,
      9     config,
     10     Complex,
     11     BigNumber: _BigNumber
     12   } = _ref;
     13 
     14   /**
     15    * Calculate the inverse cosecant of a value, defined as `acsc(x) = asin(1/x)`.
     16    *
     17    * For matrices, the function is evaluated element wise.
     18    *
     19    * Syntax:
     20    *
     21    *    math.acsc(x)
     22    *
     23    * Examples:
     24    *
     25    *    math.acsc(0.5)           // returns number 0.5235987755982989
     26    *    math.acsc(math.csc(1.5)) // returns number ~1.5
     27    *
     28    *    math.acsc(2)             // returns Complex 1.5707963267948966 -1.3169578969248166 i
     29    *
     30    * See also:
     31    *
     32    *    csc, asin, asec
     33    *
     34    * @param {number | Complex | Array | Matrix} x   Function input
     35    * @return {number | Complex | Array | Matrix} The arc cosecant of x
     36    */
     37   return typed(name, {
     38     number: function number(x) {
     39       if (x <= -1 || x >= 1 || config.predictable) {
     40         return acscNumber(x);
     41       }
     42 
     43       return new Complex(x, 0).acsc();
     44     },
     45     Complex: function Complex(x) {
     46       return x.acsc();
     47     },
     48     BigNumber: function BigNumber(x) {
     49       return new _BigNumber(1).div(x).asin();
     50     },
     51     'Array | Matrix': function ArrayMatrix(x) {
     52       return deepMap(x, this);
     53     }
     54   });
     55 });