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