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