sech.js (1434B)
1 import { factory } from '../../utils/factory.js'; 2 import { deepMap } from '../../utils/collection.js'; 3 import { sechNumber } from '../../plain/number/index.js'; 4 var name = 'sech'; 5 var dependencies = ['typed', 'BigNumber']; 6 export var createSech = /* #__PURE__ */factory(name, dependencies, _ref => { 7 var { 8 typed, 9 BigNumber: _BigNumber 10 } = _ref; 11 12 /** 13 * Calculate the hyperbolic secant of a value, 14 * defined as `sech(x) = 1 / cosh(x)`. 15 * 16 * For matrices, the function is evaluated element wise. 17 * 18 * Syntax: 19 * 20 * math.sech(x) 21 * 22 * Examples: 23 * 24 * // sech(x) = 1/ cosh(x) 25 * math.sech(0.5) // returns 0.886818883970074 26 * 1 / math.cosh(0.5) // returns 0.886818883970074 27 * 28 * See also: 29 * 30 * cosh, csch, coth 31 * 32 * @param {number | Complex | Unit | Array | Matrix} x Function input 33 * @return {number | Complex | Array | Matrix} Hyperbolic secant of x 34 */ 35 return typed(name, { 36 number: sechNumber, 37 Complex: function Complex(x) { 38 return x.sech(); 39 }, 40 BigNumber: function BigNumber(x) { 41 return new _BigNumber(1).div(x.cosh()); 42 }, 43 Unit: function Unit(x) { 44 if (!x.hasBase(x.constructor.BASE_UNITS.ANGLE)) { 45 throw new TypeError('Unit in function sech 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 });