simple-squiggle

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

acoth.js (1614B)


      1 "use strict";
      2 
      3 Object.defineProperty(exports, "__esModule", {
      4   value: true
      5 });
      6 exports.createAcoth = 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 = 'acoth';
     15 var dependencies = ['typed', 'config', 'Complex', 'BigNumber'];
     16 var createAcoth = /* #__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 hyperbolic arccotangent of a value,
     24    * defined as `acoth(x) = atanh(1/x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.
     25    *
     26    * For matrices, the function is evaluated element wise.
     27    *
     28    * Syntax:
     29    *
     30    *    math.acoth(x)
     31    *
     32    * Examples:
     33    *
     34    *    math.acoth(0.5)       // returns 0.8047189562170503
     35    *
     36    * See also:
     37    *
     38    *    acsch, asech
     39    *
     40    * @param {number | Complex | Array | Matrix} x  Function input
     41    * @return {number | Complex | Array | Matrix} Hyperbolic arccotangent of x
     42    */
     43   return typed(name, {
     44     number: function number(x) {
     45       if (x >= 1 || x <= -1 || config.predictable) {
     46         return (0, _index.acothNumber)(x);
     47       }
     48 
     49       return new Complex(x, 0).acoth();
     50     },
     51     Complex: function Complex(x) {
     52       return x.acoth();
     53     },
     54     BigNumber: function BigNumber(x) {
     55       return new _BigNumber(1).div(x).atanh();
     56     },
     57     'Array | Matrix': function ArrayMatrix(x) {
     58       return (0, _collection.deepMap)(x, this);
     59     }
     60   });
     61 });
     62 exports.createAcoth = createAcoth;