coth.js (1443B)
1 import { factory } from '../../utils/factory.js'; 2 import { deepMap } from '../../utils/collection.js'; 3 import { cothNumber } from '../../plain/number/index.js'; 4 var name = 'coth'; 5 var dependencies = ['typed', 'BigNumber']; 6 export var createCoth = /* #__PURE__ */factory(name, dependencies, _ref => { 7 var { 8 typed, 9 BigNumber: _BigNumber 10 } = _ref; 11 12 /** 13 * Calculate the hyperbolic cotangent of a value, 14 * defined as `coth(x) = 1 / tanh(x)`. 15 * 16 * For matrices, the function is evaluated element wise. 17 * 18 * Syntax: 19 * 20 * math.coth(x) 21 * 22 * Examples: 23 * 24 * // coth(x) = 1 / tanh(x) 25 * math.coth(2) // returns 1.0373147207275482 26 * 1 / math.tanh(2) // returns 1.0373147207275482 27 * 28 * See also: 29 * 30 * sinh, tanh, cosh 31 * 32 * @param {number | Complex | Unit | Array | Matrix} x Function input 33 * @return {number | Complex | Array | Matrix} Hyperbolic cotangent of x 34 */ 35 return typed(name, { 36 number: cothNumber, 37 Complex: function Complex(x) { 38 return x.coth(); 39 }, 40 BigNumber: function BigNumber(x) { 41 return new _BigNumber(1).div(x.tanh()); 42 }, 43 Unit: function Unit(x) { 44 if (!x.hasBase(x.constructor.BASE_UNITS.ANGLE)) { 45 throw new TypeError('Unit in function coth is no angle'); 46 } 47 48 return this(x.value); 49 }, 50 'Array | Matrix': function ArrayMatrix(x) { 51 return deepMap(x, this); 52 } 53 }); 54 });