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