UNPKG

1.37 kBJavaScriptView Raw
1import { factory } from '../../utils/factory.js';
2import { deepMap } from '../../utils/collection.js';
3import { atanhNumber } from '../../plain/number/index.js';
4var name = 'atanh';
5var dependencies = ['typed', 'config', 'Complex'];
6export var createAtanh = /* #__PURE__ */factory(name, dependencies, (_ref) => {
7 var {
8 typed,
9 config,
10 Complex
11 } = _ref;
12
13 /**
14 * Calculate the hyperbolic arctangent of a value,
15 * defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.
16 *
17 * For matrices, the function is evaluated element wise.
18 *
19 * Syntax:
20 *
21 * math.atanh(x)
22 *
23 * Examples:
24 *
25 * math.atanh(0.5) // returns 0.5493061443340549
26 *
27 * See also:
28 *
29 * acosh, asinh
30 *
31 * @param {number | Complex | Array | Matrix} x Function input
32 * @return {number | Complex | Array | Matrix} Hyperbolic arctangent of x
33 */
34 return typed(name, {
35 number: function number(x) {
36 if (x <= 1 && x >= -1 || config.predictable) {
37 return atanhNumber(x);
38 }
39
40 return new Complex(x, 0).atanh();
41 },
42 Complex: function Complex(x) {
43 return x.atanh();
44 },
45 BigNumber: function BigNumber(x) {
46 return x.atanh();
47 },
48 'Array | Matrix': function ArrayMatrix(x) {
49 // deep map collection, skip zeros since atanh(0) = 0
50 return deepMap(x, this, true);
51 }
52 });
53});
\No newline at end of file