UNPKG

1.19 kBJavaScriptView Raw
1'use strict';
2
3var deepMap = require('../../utils/collection/deepMap');
4
5function factory(type, config, load, typed) {
6 /**
7 * Calculate the hyperbolic arccosecant of a value,
8 * defined as `acsch(x) = asinh(1/x) = ln(1/x + sqrt(1/x^2 + 1))`.
9 *
10 * For matrices, the function is evaluated element wise.
11 *
12 * Syntax:
13 *
14 * math.acsch(x)
15 *
16 * Examples:
17 *
18 * math.acsch(0.5) // returns 1.4436354751788103
19 *
20 * See also:
21 *
22 * asech, acoth
23 *
24 * @param {number | Complex | Array | Matrix} x Function input
25 * @return {number | Complex | Array | Matrix} Hyperbolic arccosecant of x
26 */
27 var acsch = typed('acsch', {
28 'number': function number(x) {
29 x = 1 / x;
30 return Math.log(x + Math.sqrt(x * x + 1));
31 },
32
33 'Complex': function Complex(x) {
34 return x.acsch();
35 },
36
37 'BigNumber': function BigNumber(x) {
38 return new type.BigNumber(1).div(x).asinh();
39 },
40
41 'Array | Matrix': function ArrayMatrix(x) {
42 return deepMap(x, acsch);
43 }
44 });
45
46 acsch.toTex = { 1: '\\mathrm{csch}^{-1}\\left(${args[0]}\\right)' };
47
48 return acsch;
49}
50
51exports.name = 'acsch';
52exports.factory = factory;
\No newline at end of file