UNPKG

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