asech.js (1566B)
1 import { factory } from '../../utils/factory.js'; 2 import { deepMap } from '../../utils/collection.js'; 3 import { asechNumber } from '../../plain/number/index.js'; 4 var name = 'asech'; 5 var dependencies = ['typed', 'config', 'Complex', 'BigNumber']; 6 export var createAsech = /* #__PURE__ */factory(name, dependencies, _ref => { 7 var { 8 typed, 9 config, 10 Complex, 11 BigNumber: _BigNumber 12 } = _ref; 13 14 /** 15 * Calculate the hyperbolic arcsecant of a value, 16 * defined as `asech(x) = acosh(1/x) = ln(sqrt(1/x^2 - 1) + 1/x)`. 17 * 18 * For matrices, the function is evaluated element wise. 19 * 20 * Syntax: 21 * 22 * math.asech(x) 23 * 24 * Examples: 25 * 26 * math.asech(0.5) // returns 1.3169578969248166 27 * 28 * See also: 29 * 30 * acsch, acoth 31 * 32 * @param {number | Complex | Array | Matrix} x Function input 33 * @return {number | Complex | Array | Matrix} Hyperbolic arcsecant of x 34 */ 35 return typed(name, { 36 number: function number(x) { 37 if (x <= 1 && x >= -1 || config.predictable) { 38 var xInv = 1 / x; 39 40 if (xInv > 0 || config.predictable) { 41 return asechNumber(x); 42 } 43 44 var ret = Math.sqrt(xInv * xInv - 1); 45 return new Complex(Math.log(ret - xInv), Math.PI); 46 } 47 48 return new Complex(x, 0).asech(); 49 }, 50 Complex: function Complex(x) { 51 return x.asech(); 52 }, 53 BigNumber: function BigNumber(x) { 54 return new _BigNumber(1).div(x).acosh(); 55 }, 56 'Array | Matrix': function ArrayMatrix(x) { 57 return deepMap(x, this); 58 } 59 }); 60 });