pimath 0.0.26 → 0.0.27

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.
Files changed (50) hide show
  1. package/dev/index.html +8 -7
  2. package/dev/pi.js +225 -94
  3. package/dev/pi.js.map +1 -1
  4. package/dist/pi.js +1 -1
  5. package/dist/pi.js.map +1 -1
  6. package/docs/assets/search.js +1 -1
  7. package/docs/classes/algebra.Equation.html +9 -9
  8. package/docs/classes/algebra.LinearSystem.html +1 -1
  9. package/docs/classes/algebra.Logicalset.html +2 -2
  10. package/docs/classes/algebra.Monom.html +45 -44
  11. package/docs/classes/algebra.Polynom.html +9 -9
  12. package/docs/classes/algebra.Rational.html +2 -2
  13. package/docs/classes/coefficients.Fraction.html +6 -6
  14. package/docs/classes/coefficients.Nthroot.html +1 -1
  15. package/docs/classes/geometry.Circle.html +1 -1
  16. package/docs/classes/geometry.Line.html +2 -2
  17. package/docs/classes/geometry.Point.html +1 -1
  18. package/docs/classes/geometry.Triangle.html +5 -5
  19. package/docs/classes/geometry.Vector.html +1 -1
  20. package/docs/classes/numeric.Numeric.html +5 -5
  21. package/docs/classes/shutingyard.Shutingyard.html +5 -5
  22. package/docs/interfaces/geometry.remarquableLines.html +1 -1
  23. package/docs/modules/algebra.html +1 -1
  24. package/docs/modules/random.Random.html +1 -1
  25. package/docs/modules/random.html +1 -1
  26. package/esm/main.js +2 -0
  27. package/esm/main.js.map +1 -1
  28. package/esm/maths/algebra/logicalset.js +1 -1
  29. package/esm/maths/algebra/logicalset.js.map +1 -1
  30. package/esm/maths/algebra/monom.d.ts +2 -1
  31. package/esm/maths/algebra/monom.js +7 -1
  32. package/esm/maths/algebra/monom.js.map +1 -1
  33. package/esm/maths/algebra/rational.d.ts +1 -1
  34. package/esm/maths/algebra/rational.js +2 -2
  35. package/esm/maths/algebra/rational.js.map +1 -1
  36. package/esm/maths/numexp.d.ts +11 -0
  37. package/esm/maths/numexp.js +107 -0
  38. package/esm/maths/numexp.js.map +1 -0
  39. package/esm/maths/shutingyard.d.ts +21 -4
  40. package/esm/maths/shutingyard.js +72 -74
  41. package/esm/maths/shutingyard.js.map +1 -1
  42. package/package.json +1 -1
  43. package/src/main.ts +2 -0
  44. package/src/maths/algebra/logicalset.ts +2 -2
  45. package/src/maths/algebra/monom.ts +35 -22
  46. package/src/maths/algebra/rational.ts +1 -1
  47. package/src/maths/numexp.ts +127 -0
  48. package/src/maths/shutingyard.ts +144 -94
  49. package/tests/algebra/monom.test.ts +1 -1
  50. package/tests/shutingyard.test.ts +3 -3
package/dev/index.html CHANGED
@@ -29,14 +29,16 @@
29
29
  </head>
30
30
  <body>
31
31
 
32
- <div x-data="dev()">
33
- <template x-for="(item, index) of output" :key="index">
34
- <div class="katex-left" x-html="`\\[${item}\\]`"></div>
35
- </template>
36
- </div>
32
+ <!--<div x-data="dev()">-->
33
+ <!-- <template x-for="(item, index) of output" :key="index">-->
34
+ <!-- <div class="katex-left" x-html="`\\[${item}\\]`"></div>-->
35
+ <!-- </template>-->
36
+ <!--</div>-->
37
37
 
38
38
  <script>
39
- ex1()
39
+ let ne = new Pi.NumExp('x^2-2*x+3*y-8')
40
+
41
+ console.log(ne.evaluate({x: 5, y: 3}))
40
42
 
41
43
  function dev () {
42
44
  let output = []
@@ -224,7 +226,6 @@
224
226
  ]
225
227
  }
226
228
 
227
-
228
229
  </script>
229
230
  </body>
230
231
  </html>
package/dev/pi.js CHANGED
@@ -664,9 +664,6 @@ class LinearSystem {
664
664
  }
665
665
  return this;
666
666
  }
667
- get isLinearSystem() {
668
- return true;
669
- }
670
667
  get equations() {
671
668
  return this._equations;
672
669
  }
@@ -881,7 +878,7 @@ class Logicalset {
881
878
  }
882
879
  ;
883
880
  parse = (value) => {
884
- this._rpn = new shutingyard_1.Shutingyard('set').parse(value).rpn;
881
+ this._rpn = new shutingyard_1.Shutingyard(shutingyard_1.ShutingyardMode.SET).parse(value).rpn;
885
882
  return this;
886
883
  };
887
884
  evaluate(tokenSets, reference) {
@@ -1039,7 +1036,7 @@ class Monom {
1039
1036
  return this._coefficient;
1040
1037
  }
1041
1038
  set coefficient(F) {
1042
- this._coefficient = F;
1039
+ this._coefficient = new coefficients_1.Fraction(F);
1043
1040
  }
1044
1041
  get literal() {
1045
1042
  return this._literal;
@@ -1178,6 +1175,12 @@ class Monom {
1178
1175
  let d = this.display;
1179
1176
  return (d[0] !== '-' ? '+' : '') + d;
1180
1177
  }
1178
+ get texWithSign() {
1179
+ if (this.coefficient.isStrictlyPositive()) {
1180
+ return '+' + this.tex;
1181
+ }
1182
+ return this.tex;
1183
+ }
1181
1184
  get tex() {
1182
1185
  let L = '', letters = Object.keys(this._literal).sort();
1183
1186
  for (let letter of letters) {
@@ -1906,7 +1909,7 @@ class Polynom {
1906
1909
  const degreeP = P.degree(letter);
1907
1910
  let newM;
1908
1911
  let MaxIteration = this.degree(letter).clone().multiply(2);
1909
- while (reminder.degree(letter) >= degreeP && MaxIteration.isPositive()) {
1912
+ while (reminder.degree(letter).geq(degreeP) && MaxIteration.isPositive()) {
1910
1913
  MaxIteration.subtract(1);
1911
1914
  newM = reminder.monomByDegree(undefined, letter).clone().divide(maxMP);
1912
1915
  if (newM.isZero()) {
@@ -2417,7 +2420,7 @@ exports.Polynom = Polynom;
2417
2420
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2418
2421
  exports.Rational = void 0;
2419
2422
  const polynom_1 = __webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts");
2420
- const fraction_1 = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
2423
+ const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
2421
2424
  class Rational {
2422
2425
  _rawString;
2423
2426
  _numerator;
@@ -2516,7 +2519,7 @@ class Rational {
2516
2519
  }
2517
2520
  }
2518
2521
  else {
2519
- return this._numerator.evaluate({ letter: new fraction_1.Fraction(value) }).divide(this._denominator.evaluate({ letter: new fraction_1.Fraction(value) }));
2522
+ return this._numerator.evaluate({ letter: new coefficients_1.Fraction(value) }).divide(this._denominator.evaluate({ letter: new coefficients_1.Fraction(value) }));
2520
2523
  }
2521
2524
  };
2522
2525
  }
@@ -4231,6 +4234,122 @@ class Numeric {
4231
4234
  exports.Numeric = Numeric;
4232
4235
 
4233
4236
 
4237
+ /***/ }),
4238
+
4239
+ /***/ "./src/maths/numexp.ts":
4240
+ /*!*****************************!*\
4241
+ !*** ./src/maths/numexp.ts ***!
4242
+ \*****************************/
4243
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4244
+
4245
+
4246
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
4247
+ exports.NumExp = void 0;
4248
+ const shutingyard_1 = __webpack_require__(/*! ./shutingyard */ "./src/maths/shutingyard.ts");
4249
+ const coefficients_1 = __webpack_require__(/*! ./coefficients */ "./src/maths/coefficients/index.ts");
4250
+ class NumExp {
4251
+ _rpn;
4252
+ _expression;
4253
+ constructor(value) {
4254
+ this._expression = value;
4255
+ this._rpn = new shutingyard_1.Shutingyard(shutingyard_1.ShutingyardMode.NUMERIC).parse(value).rpn;
4256
+ }
4257
+ _extractDecimalPart(value) {
4258
+ let decimal = value.toString();
4259
+ if (!decimal.includes('.')) {
4260
+ return '';
4261
+ }
4262
+ decimal = decimal.split('.')[1];
4263
+ return decimal.substring(0, decimal.length - 2);
4264
+ }
4265
+ _numberCorrection(value) {
4266
+ const omega = 0.00000000000001, number_of_digits = 6;
4267
+ let decimal = this._extractDecimalPart(value);
4268
+ const n9 = decimal.match(/9+$/g);
4269
+ const n0 = decimal.match(/0+$/g);
4270
+ if (n9 && n9[0].length >= number_of_digits) {
4271
+ let mod = this._extractDecimalPart(value + omega), mod0 = mod.match(/0+$/g);
4272
+ if (mod0 && mod0[0].length >= number_of_digits) {
4273
+ return +((value + omega).toString().split(mod0[0])[0]);
4274
+ }
4275
+ }
4276
+ if (n0 && n0[0].length >= number_of_digits) {
4277
+ let mod = this._extractDecimalPart(value - omega), mod9 = mod.match(/9+$/g);
4278
+ if (mod9 && mod9[0].length >= number_of_digits) {
4279
+ return +((value - omega).toString().split(mod9[0])[0]);
4280
+ }
4281
+ }
4282
+ return value;
4283
+ }
4284
+ _addToStack(stack, value) {
4285
+ stack.push(this._numberCorrection(value));
4286
+ }
4287
+ evaluate(values) {
4288
+ let stack = [];
4289
+ for (const element of this._rpn) {
4290
+ if (element.tokenType === shutingyard_1.ShutingyardType.COEFFICIENT) {
4291
+ if (!isNaN(+element.token)) {
4292
+ this._addToStack(stack, +element.token);
4293
+ }
4294
+ else {
4295
+ this._addToStack(stack, new coefficients_1.Fraction(element.token).value);
4296
+ }
4297
+ }
4298
+ else if (element.tokenType === shutingyard_1.ShutingyardType.VARIABLE) {
4299
+ if (values[element.token] !== undefined) {
4300
+ this._addToStack(stack, +values[element.token]);
4301
+ }
4302
+ }
4303
+ else if (element.tokenType === shutingyard_1.ShutingyardType.CONSTANT) {
4304
+ this._addToStack(stack, shutingyard_1.tokenConstant[element.token]);
4305
+ }
4306
+ else if (element.tokenType === shutingyard_1.ShutingyardType.OPERATION) {
4307
+ if (element.token === '*') {
4308
+ const b = +stack.pop(), a = +stack.pop();
4309
+ this._addToStack(stack, a * b);
4310
+ }
4311
+ else if (element.token === '/') {
4312
+ const b = +stack.pop(), a = +stack.pop();
4313
+ this._addToStack(stack, a / b);
4314
+ }
4315
+ else if (element.token === '+') {
4316
+ const b = +stack.pop(), a = +stack.pop();
4317
+ this._addToStack(stack, a + b);
4318
+ }
4319
+ else if (element.token === '-') {
4320
+ const b = +stack.pop(), a = +stack.pop();
4321
+ this._addToStack(stack, a - b);
4322
+ }
4323
+ else if (element.token === '^') {
4324
+ const b = +stack.pop(), a = +stack.pop();
4325
+ this._addToStack(stack, Math.pow(a, b));
4326
+ }
4327
+ }
4328
+ else if (element.tokenType === shutingyard_1.ShutingyardType.FUNCTION) {
4329
+ const a = +stack.pop();
4330
+ if (element.token === 'sin') {
4331
+ this._addToStack(stack, Math.sin(a));
4332
+ }
4333
+ else if (element.token === 'cos') {
4334
+ this._addToStack(stack, Math.cos(a));
4335
+ }
4336
+ else if (element.token === 'tan') {
4337
+ this._addToStack(stack, Math.tan(a));
4338
+ }
4339
+ }
4340
+ }
4341
+ if (stack.length === 1) {
4342
+ return stack[0];
4343
+ }
4344
+ else {
4345
+ console.error('There was a problem parsing', this._expression, '. The RPN array is', this._rpn);
4346
+ return 0;
4347
+ }
4348
+ }
4349
+ }
4350
+ exports.NumExp = NumExp;
4351
+
4352
+
4234
4353
  /***/ }),
4235
4354
 
4236
4355
  /***/ "./src/maths/random/index.ts":
@@ -4348,6 +4467,7 @@ class rndFraction extends randomCore_1.randomCore {
4348
4467
  super();
4349
4468
  this._defaultConfig = {
4350
4469
  negative: true,
4470
+ max: 10,
4351
4471
  reduced: true,
4352
4472
  zero: true,
4353
4473
  natural: false
@@ -4357,16 +4477,16 @@ class rndFraction extends randomCore_1.randomCore {
4357
4477
  generate = () => {
4358
4478
  let Q = new coefficients_1.Fraction();
4359
4479
  if (this._config.negative) {
4360
- Q.numerator = index_1.Random.numberSym(10, this._config.zero);
4480
+ Q.numerator = index_1.Random.numberSym(this._config.max, this._config.zero);
4361
4481
  }
4362
4482
  else {
4363
- Q.numerator = index_1.Random.number(this._config.zero ? 0 : 1, 10);
4483
+ Q.numerator = index_1.Random.number(this._config.zero ? 0 : 1, this._config.max);
4364
4484
  }
4365
4485
  if (this._config.natural) {
4366
4486
  Q.denominator = 1;
4367
4487
  }
4368
4488
  else {
4369
- Q.denominator = index_1.Random.number(1, 10);
4489
+ Q.denominator = index_1.Random.number(1, this._config.max);
4370
4490
  }
4371
4491
  return this._config.reduced ? Q.reduce() : Q;
4372
4492
  };
@@ -4445,7 +4565,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
4445
4565
  exports.rndMonom = void 0;
4446
4566
  const randomCore_1 = __webpack_require__(/*! ./randomCore */ "./src/maths/random/randomCore.ts");
4447
4567
  const index_1 = __webpack_require__(/*! ./index */ "./src/maths/random/index.ts");
4448
- const monom_1 = __webpack_require__(/*! ../algebra/monom */ "./src/maths/algebra/monom.ts");
4568
+ const algebra_1 = __webpack_require__(/*! ../algebra */ "./src/maths/algebra/index.ts");
4449
4569
  class rndMonom extends randomCore_1.randomCore {
4450
4570
  constructor(userConfig) {
4451
4571
  super();
@@ -4458,12 +4578,17 @@ class rndMonom extends randomCore_1.randomCore {
4458
4578
  this._config = this.mergeConfig(userConfig, this._defaultConfig);
4459
4579
  }
4460
4580
  generate = () => {
4461
- let M = new monom_1.Monom();
4462
- M.coefficient = index_1.Random.fraction({
4463
- zero: this._config.zero,
4464
- reduced: true,
4465
- natural: !this._config.fraction
4466
- });
4581
+ let M = new algebra_1.Monom();
4582
+ if (typeof this._config.fraction === "boolean") {
4583
+ M.coefficient = index_1.Random.fraction({
4584
+ zero: this._config.zero,
4585
+ reduced: true,
4586
+ natural: !this._config.fraction
4587
+ });
4588
+ }
4589
+ else {
4590
+ M.coefficient = index_1.Random.fraction(this._config.fraction);
4591
+ }
4467
4592
  if (this._config.letters.length > 1) {
4468
4593
  for (let L of this._config.letters.split('')) {
4469
4594
  M.setLetter(L, 0);
@@ -4508,7 +4633,8 @@ class rndPolynom extends randomCore_1.randomCore {
4508
4633
  unit: false,
4509
4634
  factorable: false,
4510
4635
  allowNullMonom: true,
4511
- numberOfMonoms: 0
4636
+ numberOfMonoms: 0,
4637
+ positive: true
4512
4638
  };
4513
4639
  this._config = this.mergeConfig(userConfig, this._defaultConfig);
4514
4640
  }
@@ -4529,8 +4655,13 @@ class rndPolynom extends randomCore_1.randomCore {
4529
4655
  }
4530
4656
  P.add(M);
4531
4657
  }
4658
+ if (this._config.positive && P.monomByDegree().coefficient.isNegative()) {
4659
+ P.monomByDegree().coefficient.opposed();
4660
+ }
4532
4661
  if (this._config.numberOfMonoms > 0 && this._config.numberOfMonoms < P.length) {
4533
- P.monoms = index_1.Random.array(P.monoms, this._config.numberOfMonoms);
4662
+ let M = P.monomByDegree().clone();
4663
+ P.monoms = index_1.Random.array(P.monoms.slice(1), this._config.numberOfMonoms - 1);
4664
+ P.add(M).reorder().reduce();
4534
4665
  }
4535
4666
  return P;
4536
4667
  };
@@ -4570,46 +4701,75 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
4570
4701
 
4571
4702
 
4572
4703
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4573
- exports.Shutingyard = void 0;
4704
+ exports.Shutingyard = exports.ShutingyardMode = exports.ShutingyardType = exports.tokenConstant = void 0;
4705
+ exports.tokenConstant = {
4706
+ pi: Math.PI,
4707
+ e: Math.exp(1)
4708
+ };
4709
+ var ShutingyardType;
4710
+ (function (ShutingyardType) {
4711
+ ShutingyardType["VARIABLE"] = "variable";
4712
+ ShutingyardType["COEFFICIENT"] = "coefficient";
4713
+ ShutingyardType["OPERATION"] = "operation";
4714
+ ShutingyardType["CONSTANT"] = "constant";
4715
+ ShutingyardType["FUNCTION"] = "function";
4716
+ ShutingyardType["MONOM"] = "monom";
4717
+ })(ShutingyardType = exports.ShutingyardType || (exports.ShutingyardType = {}));
4718
+ var ShutingyardMode;
4719
+ (function (ShutingyardMode) {
4720
+ ShutingyardMode["POLYNOM"] = "polynom";
4721
+ ShutingyardMode["SET"] = "set";
4722
+ ShutingyardMode["NUMERIC"] = "numeric";
4723
+ })(ShutingyardMode = exports.ShutingyardMode || (exports.ShutingyardMode = {}));
4574
4724
  class Shutingyard {
4575
4725
  _rpn = [];
4576
4726
  _mode;
4577
4727
  _tokenConfig;
4728
+ _tokenConstant;
4578
4729
  _uniformize;
4730
+ _tokenKeys;
4579
4731
  constructor(mode) {
4580
- this._mode = typeof mode === 'undefined' ? 'polynom' : mode;
4732
+ this._mode = typeof mode === 'undefined' ? ShutingyardMode.POLYNOM : mode;
4581
4733
  this.tokenConfigInitialization();
4582
4734
  }
4583
- isOperation(token) {
4584
- if (token[0].match(/[+\-*/^]/g)) {
4585
- return true;
4586
- }
4587
- return false;
4588
- }
4589
4735
  tokenConfigInitialization() {
4590
- if (this._mode === 'set') {
4736
+ if (this._mode === ShutingyardMode.SET) {
4591
4737
  this._tokenConfig = {
4592
- '&': { precedence: 3, associative: 'left' },
4593
- '|': { precedence: 3, associative: 'left' },
4594
- '!': { precedence: 4, associative: 'right' },
4595
- '-': { precedence: 2, associative: 'left' }
4738
+ '&': { precedence: 3, associative: 'left', type: ShutingyardType.OPERATION },
4739
+ '|': { precedence: 3, associative: 'left', type: ShutingyardType.OPERATION },
4740
+ '!': { precedence: 4, associative: 'right', type: ShutingyardType.OPERATION },
4741
+ '-': { precedence: 2, associative: 'left', type: ShutingyardType.OPERATION }
4596
4742
  };
4597
4743
  this._uniformize = false;
4598
4744
  }
4745
+ else if (this._mode === ShutingyardMode.NUMERIC) {
4746
+ this._tokenConfig = {
4747
+ '^': { precedence: 4, associative: 'right', type: ShutingyardType.OPERATION },
4748
+ '*': { precedence: 3, associative: 'left', type: ShutingyardType.OPERATION },
4749
+ '/': { precedence: 3, associative: 'left', type: ShutingyardType.OPERATION },
4750
+ '+': { precedence: 2, associative: 'left', type: ShutingyardType.OPERATION },
4751
+ '-': { precedence: 2, associative: 'left', type: ShutingyardType.OPERATION },
4752
+ '%': { precedence: 3, associative: 'right', type: ShutingyardType.OPERATION },
4753
+ 'sin': { precedence: 4, associative: 'right', type: ShutingyardType.FUNCTION },
4754
+ 'cos': { precedence: 4, associative: 'right', type: ShutingyardType.FUNCTION },
4755
+ 'tan': { precedence: 4, associative: 'right', type: ShutingyardType.FUNCTION },
4756
+ };
4757
+ }
4599
4758
  else {
4600
4759
  this._tokenConfig = {
4601
- '^': { precedence: 4, associative: 'right' },
4602
- '*': { precedence: 3, associative: 'left' },
4603
- '/': { precedence: 3, associative: 'left' },
4604
- '+': { precedence: 2, associative: 'left' },
4605
- '-': { precedence: 2, associative: 'left' },
4606
- '%': { precedence: 3, associative: 'right' },
4607
- 'sin': { precedence: 4, associative: 'right' },
4608
- 'cos': { precedence: 4, associative: 'right' },
4609
- 'tab': { precedence: 4, associative: 'right' },
4760
+ '^': { precedence: 4, associative: 'right', type: ShutingyardType.OPERATION },
4761
+ '*': { precedence: 3, associative: 'left', type: ShutingyardType.OPERATION },
4762
+ '/': { precedence: 3, associative: 'left', type: ShutingyardType.OPERATION },
4763
+ '+': { precedence: 2, associative: 'left', type: ShutingyardType.OPERATION },
4764
+ '-': { precedence: 2, associative: 'left', type: ShutingyardType.OPERATION },
4765
+ '%': { precedence: 3, associative: 'right', type: ShutingyardType.OPERATION },
4766
+ 'sin': { precedence: 4, associative: 'right', type: ShutingyardType.FUNCTION },
4767
+ 'cos': { precedence: 4, associative: 'right', type: ShutingyardType.FUNCTION },
4768
+ 'tan': { precedence: 4, associative: 'right', type: ShutingyardType.FUNCTION },
4610
4769
  };
4611
4770
  this._uniformize = true;
4612
4771
  }
4772
+ this._tokenKeys = Object.keys(this._tokenConfig).sort((a, b) => b.length - a.length);
4613
4773
  return this._tokenConfig;
4614
4774
  }
4615
4775
  NextToken2(expr, start) {
@@ -4629,75 +4789,43 @@ class Shutingyard {
4629
4789
  tokenType = 'function-argument';
4630
4790
  }
4631
4791
  else {
4632
- const keys = Object.keys(this._tokenConfig).sort((a, b) => b.length - a.length);
4633
- for (let key of keys) {
4634
- if (expr.substr(start, key.length) === key) {
4792
+ for (let key of this._tokenKeys) {
4793
+ if (expr.substring(start, start + key.length) === key) {
4794
+ token += key;
4795
+ tokenType = this._tokenConfig[key].type;
4796
+ break;
4797
+ }
4798
+ }
4799
+ for (let key in exports.tokenConstant) {
4800
+ if (expr.substring(start, start + key.length) === key) {
4635
4801
  token += key;
4636
- tokenType = 'operation';
4802
+ tokenType = ShutingyardType.CONSTANT;
4637
4803
  break;
4638
4804
  }
4639
4805
  }
4640
4806
  if (token === '') {
4641
4807
  if (expr[start].match(/[0-9]/)) {
4642
- token = expr.substr(start).match(/^([0-9.,/]+)/)[0];
4643
- tokenType = 'coefficient';
4808
+ if (this._mode === ShutingyardMode.POLYNOM) {
4809
+ token = expr.substring(start).match(/^([0-9.,/]+)/)[0];
4810
+ }
4811
+ else {
4812
+ token = expr.substring(start).match(/^([0-9.,]+)/)[0];
4813
+ }
4814
+ tokenType = ShutingyardType.COEFFICIENT;
4644
4815
  }
4645
4816
  else if (expr[start].match(/[a-zA-Z]/)) {
4646
- token = expr.substr(start).match(/^([a-zA-Z])/)[0];
4647
- tokenType = 'variable';
4817
+ token = expr.substring(start).match(/^([a-zA-Z])/)[0];
4818
+ tokenType = ShutingyardType.VARIABLE;
4648
4819
  }
4649
4820
  else {
4650
4821
  console.log('Unidentified token', expr[start], expr, start);
4651
4822
  token = expr[start];
4652
- tokenType = 'monom';
4823
+ tokenType = ShutingyardType.MONOM;
4653
4824
  }
4654
4825
  }
4655
4826
  }
4656
4827
  return [token, start + token.length, tokenType];
4657
4828
  }
4658
- NextToken(expr, start) {
4659
- let tokenMatch, token, tokenType;
4660
- this.NextToken2(expr, start);
4661
- tokenMatch = (expr.substr(start).match(/^[0-9/a-zA-Z^]+/g)) || [];
4662
- if (expr.substr(start, start + 3).match(/^(sin|cos|tan)/g)) {
4663
- token = expr.substr(start, 3);
4664
- tokenType = 'function';
4665
- }
4666
- else if (tokenMatch.length > 0) {
4667
- token = tokenMatch[0];
4668
- tokenType = 'monom';
4669
- }
4670
- else if (expr[start].match(/[+\-*/^]/g)) {
4671
- token = expr[start];
4672
- tokenType = 'operation';
4673
- }
4674
- else if (expr[start].match(/[&|!]/g)) {
4675
- token = expr[start];
4676
- tokenType = 'operation';
4677
- }
4678
- else if (expr[start] === '(') {
4679
- token = '(';
4680
- tokenType = '(';
4681
- }
4682
- else if (expr[start] === ')') {
4683
- token = ')';
4684
- tokenType = ')';
4685
- }
4686
- else if (expr[start] === ',') {
4687
- token = ',';
4688
- tokenType = 'function-argument';
4689
- }
4690
- else {
4691
- token = tokenMatch[0];
4692
- tokenType = 'monom';
4693
- if (token === '') {
4694
- token = expr[start];
4695
- tokenType = 'monom';
4696
- console.log('SHUTING YARD - NEXT TOKEN: error at ', start);
4697
- }
4698
- }
4699
- return [token, start + token.length, tokenType];
4700
- }
4701
4829
  Uniformizer(expr) {
4702
4830
  if (!this._uniformize) {
4703
4831
  return expr;
@@ -4730,6 +4858,7 @@ class Shutingyard {
4730
4858
  case 'monom':
4731
4859
  case 'coefficient':
4732
4860
  case 'variable':
4861
+ case 'constant':
4733
4862
  outQueue.push({
4734
4863
  token,
4735
4864
  tokenType
@@ -4842,6 +4971,7 @@ var exports = __webpack_exports__;
4842
4971
 
4843
4972
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4844
4973
  const numeric_1 = __webpack_require__(/*! ./maths/numeric */ "./src/maths/numeric.ts");
4974
+ const numexp_1 = __webpack_require__(/*! ./maths/numexp */ "./src/maths/numexp.ts");
4845
4975
  const shutingyard_1 = __webpack_require__(/*! ./maths/shutingyard */ "./src/maths/shutingyard.ts");
4846
4976
  const random_1 = __webpack_require__(/*! ./maths/random */ "./src/maths/random/index.ts");
4847
4977
  const coefficients_1 = __webpack_require__(/*! ./maths/coefficients */ "./src/maths/coefficients/index.ts");
@@ -4850,6 +4980,7 @@ const geometry_1 = __webpack_require__(/*! ./maths/geometry */ "./src/maths/geom
4850
4980
  window.Pi = {
4851
4981
  ShutingYard: shutingyard_1.Shutingyard,
4852
4982
  Numeric: numeric_1.Numeric,
4983
+ NumExp: numexp_1.NumExp,
4853
4984
  Fraction: coefficients_1.Fraction,
4854
4985
  Root: coefficients_1.Nthroot,
4855
4986
  Monom: algebra_1.Monom,