1 |
|
2 |
|
3 | const deepMap = require('../../utils/collection/deepMap')
|
4 |
|
5 | function factory (type, config, load, typed) {
|
6 | /**
|
7 | * Calculate the hyperbolic arcsine of a value,
|
8 | * defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.
|
9 | *
|
10 | * For matrices, the function is evaluated element wise.
|
11 | *
|
12 | * Syntax:
|
13 | *
|
14 | * math.asinh(x)
|
15 | *
|
16 | * Examples:
|
17 | *
|
18 | * math.asinh(0.5) // returns 0.48121182505960347
|
19 | *
|
20 | * See also:
|
21 | *
|
22 | * acosh, atanh
|
23 | *
|
24 | * @param {number | Complex | Array | Matrix} x Function input
|
25 | * @return {number | Complex | Array | Matrix} Hyperbolic arcsine of x
|
26 | */
|
27 | const asinh = typed('asinh', {
|
28 | 'number': Math.asinh || function (x) {
|
29 | return Math.log(Math.sqrt(x * x + 1) + x)
|
30 | },
|
31 |
|
32 | 'Complex': function (x) {
|
33 | return x.asinh()
|
34 | },
|
35 |
|
36 | 'BigNumber': function (x) {
|
37 | return x.asinh()
|
38 | },
|
39 |
|
40 | 'Array | Matrix': function (x) {
|
41 | // deep map collection, skip zeros since asinh(0) = 0
|
42 | return deepMap(x, asinh, true)
|
43 | }
|
44 | })
|
45 |
|
46 | asinh.toTex = { 1: `\\sinh^{-1}\\left(\${args[0]}\\right)` }
|
47 |
|
48 | return asinh
|
49 | }
|
50 |
|
51 | exports.name = 'asinh'
|
52 | exports.factory = factory
|