nerdamer 1.1.9 → 1.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Algebra.js +2061 -1850
- package/Calculus.js +761 -680
- package/Extra.js +148 -117
- package/README.md +30 -1
- package/Solve.js +476 -332
- package/all.min.js +1 -0
- package/gulpfile.js +16 -0
- package/index.d.ts +150 -13
- package/nerdamer.core.js +2166 -1901
- package/package.json +57 -52
- package/spec/LaTeX.spec.js +14 -44
- package/spec/TeXConvert.spec.js +3 -2
- package/spec/algebra.spec.js +181 -732
- package/spec/calculus.spec.js +160 -673
- package/spec/core.spec.js +35 -8
- package/spec/extra.spec.js +39 -171
- package/spec/solve.spec.js +89 -305
package/package.json
CHANGED
|
@@ -1,54 +1,59 @@
|
|
|
1
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
|
-
|
|
2
|
+
"author": {
|
|
3
|
+
"name": "Martin Donk",
|
|
4
|
+
"email": "martin.r.donk@gmail.com"
|
|
5
|
+
},
|
|
6
|
+
"description": "javascript light-weight symbolic math expression evaluator",
|
|
7
|
+
"name": "nerdamer",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"version": "1.1.13",
|
|
10
|
+
"homepage": "http://nerdamer.com/",
|
|
11
|
+
"directory": {
|
|
12
|
+
"lib": "./"
|
|
13
|
+
},
|
|
14
|
+
"main": "nerdamer.core.js",
|
|
15
|
+
"typings": "index.d.ts",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"math",
|
|
18
|
+
"matrix",
|
|
19
|
+
"complex",
|
|
20
|
+
"number",
|
|
21
|
+
"parser",
|
|
22
|
+
"expression",
|
|
23
|
+
"functions",
|
|
24
|
+
"numeric",
|
|
25
|
+
"equation solver",
|
|
26
|
+
"linear algebra",
|
|
27
|
+
"vectors",
|
|
28
|
+
"symbolic",
|
|
29
|
+
"integration",
|
|
30
|
+
"differentiation",
|
|
31
|
+
"derivative",
|
|
32
|
+
"algebra",
|
|
33
|
+
"calculus",
|
|
34
|
+
"mathematics",
|
|
35
|
+
"constants",
|
|
36
|
+
"symbolic math"
|
|
37
|
+
],
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "https://github.com/jiggzson/nerdamer.git"
|
|
41
|
+
},
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/jiggzson/nerdamer/issues"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=0.10.0"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"test": "jasmine"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"gulp": "^4.0.2",
|
|
53
|
+
"gulp-cli": "^2.3.0",
|
|
54
|
+
"gulp-concat": "^2.6.1",
|
|
55
|
+
"gulp-uglify": "^3.0.2",
|
|
56
|
+
"gulp-watch": "^5.0.1",
|
|
57
|
+
"jasmine": "^2.99.0"
|
|
58
|
+
}
|
|
54
59
|
}
|
package/spec/LaTeX.spec.js
CHANGED
|
@@ -184,6 +184,11 @@ describe('TeX features', function () {
|
|
|
184
184
|
given: 'nthroot(a,b)',
|
|
185
185
|
TeX: '\\sqrt[b]{a}',
|
|
186
186
|
decimalTeX: '\\sqrt[b]{a}'
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
given: 'x_aa_bb+y_cc_dd',
|
|
190
|
+
TeX: 'x_{aa_{bb}}+y_{cc_{dd}}',
|
|
191
|
+
decimalTeX: 'x_{aa_{bb}}+y_{cc_{dd}}'
|
|
187
192
|
}
|
|
188
193
|
];
|
|
189
194
|
|
|
@@ -261,50 +266,15 @@ describe('TeX features', function () {
|
|
|
261
266
|
});
|
|
262
267
|
|
|
263
268
|
it('should explicitly convert to LaTeX', function () {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
given: 'diff(cos(x),x)',
|
|
276
|
-
expected: '\\frac{d}{d x}\\left({\\mathrm{cos}\\left(x\\right)}\\right)'
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
given: 'integrate(cos(x),x)',
|
|
280
|
-
expected: '\\int {\\mathrm{cos}\\left(x\\right)}\\, dx'
|
|
281
|
-
},
|
|
282
|
-
{
|
|
283
|
-
given: '2*(sqrt(3)+sqrt(2))',
|
|
284
|
-
expected: '2 \\cdot \\left(\\sqrt{3} + \\sqrt{2}\\right)'
|
|
285
|
-
},
|
|
286
|
-
// Redundant sign in powers
|
|
287
|
-
{
|
|
288
|
-
given: '(a+1)(x+a)^(-5)+1',
|
|
289
|
-
expected: '\\frac{a + 1}{{\\left(x + a\\right)}^{5}} + 1'
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
given: 'a*x^-3+1/a',
|
|
293
|
-
expected: '\\frac{a}{{x}^{3}} + \\frac{1}{a}'
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
given: 'a*x^+3+1/a',
|
|
297
|
-
expected: 'a \\cdot {x}^{3} + \\frac{1}{a}'
|
|
298
|
-
}
|
|
299
|
-
];
|
|
300
|
-
|
|
301
|
-
for(var i = 0; i < testCases.length; ++i) {
|
|
302
|
-
// when
|
|
303
|
-
var teX = nerdamer.convertToLaTeX(testCases[i].given);
|
|
304
|
-
|
|
305
|
-
// then
|
|
306
|
-
expect(teX).toEqual(testCases[i].expected);
|
|
307
|
-
}
|
|
269
|
+
expect(nerdamer.convertToLaTeX('realpart(a)')).toEqual('\\operatorname{Re}\\left(a\\right)');
|
|
270
|
+
expect(nerdamer.convertToLaTeX('imagpart(a)')).toEqual('\\operatorname{Im}\\left(a\\right)');
|
|
271
|
+
expect(nerdamer.convertToLaTeX('diff(cos(x),x)')).toEqual('\\frac{d}{d x}\\left({\\mathrm{cos}\\left(x\\right)}\\right)');
|
|
272
|
+
expect(nerdamer.convertToLaTeX('integrate(cos(x),x)')).toEqual('\\int {\\mathrm{cos}\\left(x\\right)}\\, dx');
|
|
273
|
+
expect(nerdamer.convertToLaTeX('2*(sqrt(3)+sqrt(2))')).toEqual('2 \\cdot \\left(\\sqrt{3} + \\sqrt{2}\\right)');
|
|
274
|
+
expect(nerdamer.convertToLaTeX('(a+1)(x+a)^(-5)+1')).toEqual('\\frac{a + 1}{{\\left(x + a\\right)}^{5}} + 1');
|
|
275
|
+
expect(nerdamer.convertToLaTeX('a*x^-3+1/a')).toEqual('\\frac{a}{{x}^{3}} + \\frac{1}{a}');
|
|
276
|
+
expect(nerdamer.convertToLaTeX('a*x^+3+1/a')).toEqual('a \\cdot {x}^{3} + \\frac{1}{a}');
|
|
277
|
+
expect(nerdamer.convertToLaTeX('x^2/y-x')).toEqual('\\frac{{x}^{2}}{y} - x');
|
|
308
278
|
});
|
|
309
279
|
|
|
310
280
|
it('should display integrals', function () {
|
package/spec/TeXConvert.spec.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
var nerdamer = require('../nerdamer.core.js');
|
|
2
|
-
it('
|
|
2
|
+
it('Should convert from TeX', function () {
|
|
3
3
|
expect(nerdamer.convertFromLaTeX('x^6 \\cdot cos(\\frac{1}{2})').toString()).toEqual('cos(1/2)*x^6');
|
|
4
4
|
expect(nerdamer.convertFromLaTeX('\\sqrt[3]{1+a}+1').toString()).toEqual('(1+a)^(1/3)+1');
|
|
5
5
|
expect(nerdamer.convertFromLaTeX('\\begin{matrix} \\begin{matrix}1 & 2 \\\\ 7 & 8\\end{matrix} & 2+9 \\\\ 7 & 8\\end{matrix}').toString())
|
|
6
|
-
|
|
6
|
+
.toEqual('matrix([matrix([1,2],[7,8]),11],[7,8])');
|
|
7
|
+
expect(nerdamer.convertFromLaTeX('\\int_{0}^{\\pi}(\\sin(y)),y').toString()).toEqual('defint(sin(y),0,pi,y)');
|
|
7
8
|
});
|