1 | ;
|
2 |
|
3 | var deepMap = require('../../utils/collection/deepMap');
|
4 |
|
5 | function factory(type, config, load, typed) {
|
6 | /**
|
7 | * Calculate the inverse cosecant of a value, defined as `acsc(x) = asin(1/x)`.
|
8 | *
|
9 | * For matrices, the function is evaluated element wise.
|
10 | *
|
11 | * Syntax:
|
12 | *
|
13 | * math.acsc(x)
|
14 | *
|
15 | * Examples:
|
16 | *
|
17 | * math.acsc(0.5) // returns number 0.5235987755982989
|
18 | * math.acsc(math.csc(1.5)) // returns number ~1.5
|
19 | *
|
20 | * math.acsc(2) // returns Complex 1.5707963267948966 -1.3169578969248166 i
|
21 | *
|
22 | * See also:
|
23 | *
|
24 | * csc, asin, asec
|
25 | *
|
26 | * @param {number | Complex | Array | Matrix} x Function input
|
27 | * @return {number | Complex | Array | Matrix} The arc cosecant of x
|
28 | */
|
29 | var acsc = typed('acsc', {
|
30 | 'number': function number(x) {
|
31 | if (x <= -1 || x >= 1 || config.predictable) {
|
32 | return Math.asin(1 / x);
|
33 | }
|
34 | return new type.Complex(x, 0).acsc();
|
35 | },
|
36 |
|
37 | 'Complex': function Complex(x) {
|
38 | return x.acsc();
|
39 | },
|
40 |
|
41 | 'BigNumber': function BigNumber(x) {
|
42 | return new type.BigNumber(1).div(x).asin();
|
43 | },
|
44 |
|
45 | 'Array | Matrix': function ArrayMatrix(x) {
|
46 | return deepMap(x, acsc);
|
47 | }
|
48 | });
|
49 |
|
50 | acsc.toTex = { 1: '\\csc^{-1}\\left(${args[0]}\\right)' };
|
51 |
|
52 | return acsc;
|
53 | }
|
54 |
|
55 | exports.name = 'acsc';
|
56 | exports.factory = factory; |
\ | No newline at end of file |