UNPKG

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