UNPKG

1.64 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.createCoth = void 0;
7
8var _factory = require("../../utils/factory");
9
10var _collection = require("../../utils/collection");
11
12var _number = require("../../plain/number");
13
14var name = 'coth';
15var dependencies = ['typed', 'BigNumber'];
16var createCoth = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
17 var typed = _ref.typed,
18 _BigNumber = _ref.BigNumber;
19
20 /**
21 * Calculate the hyperbolic cotangent of a value,
22 * defined as `coth(x) = 1 / tanh(x)`.
23 *
24 * For matrices, the function is evaluated element wise.
25 *
26 * Syntax:
27 *
28 * math.coth(x)
29 *
30 * Examples:
31 *
32 * // coth(x) = 1 / tanh(x)
33 * math.coth(2) // returns 1.0373147207275482
34 * 1 / math.tanh(2) // returns 1.0373147207275482
35 *
36 * See also:
37 *
38 * sinh, tanh, cosh
39 *
40 * @param {number | Complex | Unit | Array | Matrix} x Function input
41 * @return {number | Complex | Array | Matrix} Hyperbolic cotangent of x
42 */
43 var coth = typed(name, {
44 number: _number.cothNumber,
45 Complex: function Complex(x) {
46 return x.coth();
47 },
48 BigNumber: function BigNumber(x) {
49 return new _BigNumber(1).div(x.tanh());
50 },
51 Unit: function Unit(x) {
52 if (!x.hasBase(x.constructor.BASE_UNITS.ANGLE)) {
53 throw new TypeError('Unit in function coth is no angle');
54 }
55
56 return coth(x.value);
57 },
58 'Array | Matrix': function ArrayMatrix(x) {
59 return (0, _collection.deepMap)(x, coth);
60 }
61 });
62 return coth;
63});
64exports.createCoth = createCoth;
\No newline at end of file