1 | 'use strict'
|
2 |
|
3 | const deepMap = require('../../utils/collection/deepMap')
|
4 | const sign = require('../../utils/number').sign
|
5 |
|
6 | function factory (type, config, load, typed) {
|
7 | |
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | const csch = typed('csch', {
|
31 | 'number': _csch,
|
32 |
|
33 | 'Complex': function (x) {
|
34 | return x.csch()
|
35 | },
|
36 |
|
37 | 'BigNumber': function (x) {
|
38 | return new type.BigNumber(1).div(x.sinh())
|
39 | },
|
40 |
|
41 | 'Unit': function (x) {
|
42 | if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) {
|
43 | throw new TypeError('Unit in function csch is no angle')
|
44 | }
|
45 | return csch(x.value)
|
46 | },
|
47 |
|
48 | 'Array | Matrix': function (x) {
|
49 | return deepMap(x, csch)
|
50 | }
|
51 | })
|
52 |
|
53 | csch.toTex = { 1: `\\mathrm{csch}\\left(\${args[0]}\\right)` }
|
54 |
|
55 | return csch
|
56 | }
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | function _csch (x) {
|
65 |
|
66 | if (x === 0) {
|
67 | return Number.POSITIVE_INFINITY
|
68 | } else {
|
69 | return Math.abs(2 / (Math.exp(x) - Math.exp(-x))) * sign(x)
|
70 | }
|
71 | }
|
72 |
|
73 | exports.name = 'csch'
|
74 | exports.factory = factory
|