expm1.js (1736B)
1 "use strict"; 2 3 Object.defineProperty(exports, "__esModule", { 4 value: true 5 }); 6 exports.createExpm1 = 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 = 'expm1'; 15 var dependencies = ['typed', 'Complex']; 16 var createExpm1 = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) { 17 var typed = _ref.typed, 18 _Complex = _ref.Complex; 19 20 /** 21 * Calculate the value of subtracting 1 from the exponential value. 22 * For matrices, the function is evaluated element wise. 23 * 24 * Syntax: 25 * 26 * math.expm1(x) 27 * 28 * Examples: 29 * 30 * math.expm1(2) // returns number 6.38905609893065 31 * math.pow(math.e, 2) - 1 // returns number 6.3890560989306495 32 * math.log(math.expm1(2) + 1) // returns number 2 33 * 34 * math.expm1([1, 2, 3]) 35 * // returns Array [ 36 * // 1.718281828459045, 37 * // 6.3890560989306495, 38 * // 19.085536923187668 39 * // ] 40 * 41 * See also: 42 * 43 * exp, log, pow 44 * 45 * @param {number | BigNumber | Complex | Array | Matrix} x A number or matrix to apply expm1 46 * @return {number | BigNumber | Complex | Array | Matrix} Exponent of `x` 47 */ 48 return typed(name, { 49 number: _index.expm1Number, 50 Complex: function Complex(x) { 51 var r = Math.exp(x.re); 52 return new _Complex(r * Math.cos(x.im) - 1, r * Math.sin(x.im)); 53 }, 54 BigNumber: function BigNumber(x) { 55 return x.exp().minus(1); 56 }, 57 'Array | Matrix': function ArrayMatrix(x) { 58 return (0, _collection.deepMap)(x, this); 59 } 60 }); 61 }); 62 exports.createExpm1 = createExpm1;