1 | import { factory } from '../../utils/factory'
|
2 | import { deepMap } from '../../utils/collection'
|
3 | import { acoshNumber } from '../../plain/number'
|
4 |
|
5 | const name = 'acosh'
|
6 | const dependencies = ['typed', 'config', 'Complex']
|
7 |
|
8 | export const createAcosh = factory(name, dependencies, ({ typed, config, Complex }) => {
|
9 | |
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | return typed(name, {
|
31 | number: function (x) {
|
32 | if (x >= 1 || config.predictable) {
|
33 | return acoshNumber(x)
|
34 | }
|
35 | if (x <= -1) {
|
36 | return new Complex(Math.log(Math.sqrt(x * x - 1) - x), Math.PI)
|
37 | }
|
38 | return new Complex(x, 0).acosh()
|
39 | },
|
40 |
|
41 | Complex: function (x) {
|
42 | return x.acosh()
|
43 | },
|
44 |
|
45 | BigNumber: function (x) {
|
46 | return x.acosh()
|
47 | },
|
48 |
|
49 | 'Array | Matrix': function (x) {
|
50 | return deepMap(x, this)
|
51 | }
|
52 | })
|
53 | })
|