UNPKG

1.46 kBJavaScriptView Raw
1import { factory } from '../../utils/factory';
2import { deepMap } from '../../utils/collection';
3import { cschNumber } from '../../plain/number';
4var name = 'csch';
5var dependencies = ['typed', 'BigNumber'];
6export var createCsch =
7/* #__PURE__ */
8factory(name, dependencies, function (_ref) {
9 var typed = _ref.typed,
10 _BigNumber = _ref.BigNumber;
11
12 /**
13 * Calculate the hyperbolic cosecant of a value,
14 * defined as `csch(x) = 1 / sinh(x)`.
15 *
16 * For matrices, the function is evaluated element wise.
17 *
18 * Syntax:
19 *
20 * math.csch(x)
21 *
22 * Examples:
23 *
24 * // csch(x) = 1/ sinh(x)
25 * math.csch(0.5) // returns 1.9190347513349437
26 * 1 / math.sinh(0.5) // returns 1.9190347513349437
27 *
28 * See also:
29 *
30 * sinh, sech, coth
31 *
32 * @param {number | Complex | Unit | Array | Matrix} x Function input
33 * @return {number | Complex | Array | Matrix} Hyperbolic cosecant of x
34 */
35 var csch = typed(name, {
36 number: cschNumber,
37 Complex: function Complex(x) {
38 return x.csch();
39 },
40 BigNumber: function BigNumber(x) {
41 return new _BigNumber(1).div(x.sinh());
42 },
43 Unit: function Unit(x) {
44 if (!x.hasBase(x.constructor.BASE_UNITS.ANGLE)) {
45 throw new TypeError('Unit in function csch is no angle');
46 }
47
48 return csch(x.value);
49 },
50 'Array | Matrix': function ArrayMatrix(x) {
51 return deepMap(x, csch);
52 }
53 });
54 return csch;
55});
\No newline at end of file