UNPKG

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