UNPKG

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