acosh.js (1616B)
1 "use strict"; 2 3 Object.defineProperty(exports, "__esModule", { 4 value: true 5 }); 6 exports.createAcosh = 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 = 'acosh'; 15 var dependencies = ['typed', 'config', 'Complex']; 16 var createAcosh = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) { 17 var typed = _ref.typed, 18 config = _ref.config, 19 Complex = _ref.Complex; 20 21 /** 22 * Calculate the hyperbolic arccos of a value, 23 * defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`. 24 * 25 * For matrices, the function is evaluated element wise. 26 * 27 * Syntax: 28 * 29 * math.acosh(x) 30 * 31 * Examples: 32 * 33 * math.acosh(1.5) // returns 0.9624236501192069 34 * 35 * See also: 36 * 37 * cosh, asinh, atanh 38 * 39 * @param {number | Complex | Unit | Array | Matrix} x Function input 40 * @return {number | Complex | Array | Matrix} Hyperbolic arccosine of x 41 */ 42 return typed(name, { 43 number: function number(x) { 44 if (x >= 1 || config.predictable) { 45 return (0, _index.acoshNumber)(x); 46 } 47 48 if (x <= -1) { 49 return new Complex(Math.log(Math.sqrt(x * x - 1) - x), Math.PI); 50 } 51 52 return new Complex(x, 0).acosh(); 53 }, 54 Complex: function Complex(x) { 55 return x.acosh(); 56 }, 57 BigNumber: function BigNumber(x) { 58 return x.acosh(); 59 }, 60 'Array | Matrix': function ArrayMatrix(x) { 61 return (0, _collection.deepMap)(x, this); 62 } 63 }); 64 }); 65 exports.createAcosh = createAcosh;