UNPKG

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