-
Notifications
You must be signed in to change notification settings - Fork 9
/
defs.dart
95 lines (91 loc) · 2.57 KB
/
defs.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
part of function_tree;
/// A mapping of string representations to functions.
final Map<String, Function> _functionMap = {
'abs': (num x) => x.abs(),
'acos': acos,
'asin': asin,
'atan': atan,
'ceil': (num x) => x.ceil(),
'cos': cos,
'cosh': (num x) => (pow(e, x) + pow(e, -x)) / 2,
'cot': (num x) => 1 / tan(x),
'coth': (num x) => (pow(e, x) + pow(e, -x)) / (pow(e, x) - pow(e, -x)),
'csc': (num x) => 1 / sin(x),
'csch': (num x) => 2 / (pow(e, x) - pow(e, -x)),
'exp': exp,
'floor': (num x) => x.floor(),
'ln': log,
'log': log,
'round': (num x) => x.round(),
'sec': (num x) => 1 / cos(x),
'sech': (num x) => 2 / (pow(e, x) + pow(e, -x)),
'sin': sin,
'sinh': (num x) => (pow(e, x) - pow(e, -x)) / 2,
'sqrt': sqrt,
'tan': tan,
'tanh': (num x) => (pow(e, x) - pow(e, -x)) / (pow(e, x) + pow(e, -x))
};
/// A mapping of string representations of functions to LaTeX.
final Map<String, String> _functionLatexRepresentation = {
'abs': r'\left| C \right| ',
'acos': r'\arccos\left( C \right) ',
'asin': r'\arcsin\left( C \right) ',
'atan': r'\arctan\left( C \right) ',
'ceil': r'\lceil C \rceil ',
'cos': r'\cos\left( C \right) ',
'cosh': r'\cosh\left( C \right) ',
'cot': r'\cot\left( C \right) ',
'coth': r'\coth\left( C \right) ',
'csc': r'\csc\left( C \right) ',
'csch': r'\csch\left( C \right) ',
'exp': r'\exp\left( C \right) ',
'floor': r'\lfloor C \rfloor ',
'ln': r'\ln\left( C \right) ',
'log': r'\log\left( C \right) ',
'round': r'\left[ C \right] ',
'sec': r'\sec\left( C \right) ',
'sech': r'\sech\left( C \right) ',
'sin': r'\sin\left( C \right) ',
'sinh': r'\sinh\left( C \right) ',
'sqrt': r'\sqrt{ C } ',
'tan': r'\tan\left( C \right) ',
'tanh': r'\tanh\left( C \right) '
};
/// A mapping of string representations to constants.
final Map<String, num> _constantMap = {
'E': e,
'PI': pi,
'LN2': ln2,
'LN10': ln10,
'LOG2E': log2e,
'LOG10E': log10e,
'SQRT1_2': sqrt1_2,
'SQRT2': sqrt2,
'e': e,
'pi': pi,
'ln2': ln2,
'ln10': ln10,
'log2e': log2e,
'log10e': log10e,
'sqrt1_2': sqrt1_2,
'sqrt2': sqrt2,
};
/// A mapping of string representations of constants to LaTeX.
final Map<String, String> _constantLatexRepresentation = {
'E': 'e ',
'LN2': r'\ln 2 ',
'LN10': r'\ln 10 ',
'LOG2E': r'\log_2e ',
'LOG10E': r'\log_{10} e ',
'PI': r'\pi ',
'SQRT1_2': r'\frac{\sqrt2}{2} ',
'SQRT2': r'\sqrt{2} ',
'e': 'e ',
'ln2': r'\ln 2 ',
'ln10': r'\ln 10 ',
'log2e': r'\log_2e ',
'log10e': r'\log_{10} e ',
'pi': r'\pi ',
'sqrt1_2': r'\frac{\sqrt2}{2} ',
'sqrt2': r'\sqrt{2} '
};