atanh.js (1584B)
1 "use strict"; 2 3 Object.defineProperty(exports, "__esModule", { 4 value: true 5 }); 6 exports.createAtanh = 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 = 'atanh'; 15 var dependencies = ['typed', 'config', 'Complex']; 16 var createAtanh = /* #__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 arctangent of a value, 23 * defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`. 24 * 25 * For matrices, the function is evaluated element wise. 26 * 27 * Syntax: 28 * 29 * math.atanh(x) 30 * 31 * Examples: 32 * 33 * math.atanh(0.5) // returns 0.5493061443340549 34 * 35 * See also: 36 * 37 * acosh, asinh 38 * 39 * @param {number | Complex | Array | Matrix} x Function input 40 * @return {number | Complex | Array | Matrix} Hyperbolic arctangent of x 41 */ 42 return typed(name, { 43 number: function number(x) { 44 if (x <= 1 && x >= -1 || config.predictable) { 45 return (0, _index.atanhNumber)(x); 46 } 47 48 return new Complex(x, 0).atanh(); 49 }, 50 Complex: function Complex(x) { 51 return x.atanh(); 52 }, 53 BigNumber: function BigNumber(x) { 54 return x.atanh(); 55 }, 56 'Array | Matrix': function ArrayMatrix(x) { 57 // deep map collection, skip zeros since atanh(0) = 0 58 return (0, _collection.deepMap)(x, this, true); 59 } 60 }); 61 }); 62 exports.createAtanh = createAtanh;