simple-squiggle

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

acot.js (1294B)


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