1 | import { factory } from '../../utils/factory'
|
2 | import { deepMap } from '../../utils/collection'
|
3 | import { asechNumber } from '../../plain/number'
|
4 |
|
5 | const name = 'asech'
|
6 | const dependencies = ['typed', 'config', 'Complex', 'BigNumber']
|
7 |
|
8 | export const createAsech = factory(name, dependencies, ({ typed, config, Complex, BigNumber }) => {
|
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 && x >= -1) || config.predictable) {
|
33 | const xInv = 1 / x
|
34 | if (xInv > 0 || config.predictable) {
|
35 | return asechNumber(x)
|
36 | }
|
37 |
|
38 | const ret = Math.sqrt(xInv * xInv - 1)
|
39 | return new Complex(Math.log(ret - xInv), Math.PI)
|
40 | }
|
41 |
|
42 | return new Complex(x, 0).asech()
|
43 | },
|
44 |
|
45 | Complex: function (x) {
|
46 | return x.asech()
|
47 | },
|
48 |
|
49 | BigNumber: function (x) {
|
50 | return new BigNumber(1).div(x).acosh()
|
51 | },
|
52 |
|
53 | 'Array | Matrix': function (x) {
|
54 | return deepMap(x, this)
|
55 | }
|
56 | })
|
57 | })
|