1 | 'use strict';
|
2 |
|
3 | var 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 |
|
28 |
|
29 | var sech = typed('sech', {
|
30 | 'number': _sech,
|
31 |
|
32 | 'Complex': function Complex(x) {
|
33 | return x.sech();
|
34 | },
|
35 |
|
36 | 'BigNumber': function BigNumber(x) {
|
37 | return new type.BigNumber(1).div(x.cosh());
|
38 | },
|
39 |
|
40 | 'Unit': function Unit(x) {
|
41 | if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) {
|
42 | throw new TypeError('Unit in function sech is no angle');
|
43 | }
|
44 | return sech(x.value);
|
45 | },
|
46 |
|
47 | 'Array | Matrix': function ArrayMatrix(x) {
|
48 | return deepMap(x, sech);
|
49 | }
|
50 | });
|
51 |
|
52 | sech.toTex = { 1: '\\mathrm{sech}\\left(${args[0]}\\right)' };
|
53 |
|
54 | return sech;
|
55 | }
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 | function _sech(x) {
|
64 | return 2 / (Math.exp(x) + Math.exp(-x));
|
65 | }
|
66 |
|
67 | exports.name = 'sech';
|
68 | exports.factory = factory; |
\ | No newline at end of file |