coth.js (1630B)
1 "use strict"; 2 3 Object.defineProperty(exports, "__esModule", { 4 value: true 5 }); 6 exports.createCoth = 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 = 'coth'; 15 var dependencies = ['typed', 'BigNumber']; 16 var createCoth = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) { 17 var typed = _ref.typed, 18 _BigNumber = _ref.BigNumber; 19 20 /** 21 * Calculate the hyperbolic cotangent of a value, 22 * defined as `coth(x) = 1 / tanh(x)`. 23 * 24 * For matrices, the function is evaluated element wise. 25 * 26 * Syntax: 27 * 28 * math.coth(x) 29 * 30 * Examples: 31 * 32 * // coth(x) = 1 / tanh(x) 33 * math.coth(2) // returns 1.0373147207275482 34 * 1 / math.tanh(2) // returns 1.0373147207275482 35 * 36 * See also: 37 * 38 * sinh, tanh, cosh 39 * 40 * @param {number | Complex | Unit | Array | Matrix} x Function input 41 * @return {number | Complex | Array | Matrix} Hyperbolic cotangent of x 42 */ 43 return typed(name, { 44 number: _index.cothNumber, 45 Complex: function Complex(x) { 46 return x.coth(); 47 }, 48 BigNumber: function BigNumber(x) { 49 return new _BigNumber(1).div(x.tanh()); 50 }, 51 Unit: function Unit(x) { 52 if (!x.hasBase(x.constructor.BASE_UNITS.ANGLE)) { 53 throw new TypeError('Unit in function coth 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.createCoth = createCoth;