UNPKG

1.44 kBJavaScriptView Raw
1import { factory } from '../../utils/factory.js';
2import { deepMap } from '../../utils/collection.js';
3var name = 'asin';
4var dependencies = ['typed', 'config', 'Complex'];
5export var createAsin = /* #__PURE__ */factory(name, dependencies, (_ref) => {
6 var {
7 typed,
8 config,
9 Complex
10 } = _ref;
11
12 /**
13 * Calculate the inverse sine of a value.
14 *
15 * For matrices, the function is evaluated element wise.
16 *
17 * Syntax:
18 *
19 * math.asin(x)
20 *
21 * Examples:
22 *
23 * math.asin(0.5) // returns number 0.5235987755982989
24 * math.asin(math.sin(1.5)) // returns number ~1.5
25 *
26 * math.asin(2) // returns Complex 1.5707963267948966 -1.3169578969248166 i
27 *
28 * See also:
29 *
30 * sin, atan, acos
31 *
32 * @param {number | BigNumber | Complex | Array | Matrix} x Function input
33 * @return {number | BigNumber | Complex | Array | Matrix} The arc sine of x
34 */
35 return typed(name, {
36 number: function number(x) {
37 if (x >= -1 && x <= 1 || config.predictable) {
38 return Math.asin(x);
39 } else {
40 return new Complex(x, 0).asin();
41 }
42 },
43 Complex: function Complex(x) {
44 return x.asin();
45 },
46 BigNumber: function BigNumber(x) {
47 return x.asin();
48 },
49 'Array | Matrix': function ArrayMatrix(x) {
50 // deep map collection, skip zeros since asin(0) = 0
51 return deepMap(x, this, true);
52 }
53 });
54});
\No newline at end of file