pimath 0.0.91 → 0.0.93

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 (42) hide show
  1. package/.eslintrc.js +23 -23
  2. package/dist/pi.js +97 -10
  3. package/dist/pi.js.map +1 -1
  4. package/dist/pi.min.js +1 -1
  5. package/dist/pi.min.js.map +1 -1
  6. package/docs/assets/main.js +52 -52
  7. package/docs/classes/Logicalset.Logicalset-1.html +4 -4
  8. package/docs/classes/Polynom.Rational.html +3 -3
  9. package/docs/classes/algebra_equation.Equation.html +25 -25
  10. package/docs/classes/algebra_monom.Monom.html +113 -113
  11. package/docs/classes/algebra_polynom.Polynom.html +29 -29
  12. package/docs/classes/coefficients_fraction.Fraction.html +18 -18
  13. package/docs/classes/coefficients_nthroot.NthRoot.html +2 -2
  14. package/docs/classes/geometry_circle.Circle.html +2 -2
  15. package/docs/classes/geometry_line.Line.html +2 -2
  16. package/docs/classes/geometry_triangle.Triangle.html +16 -16
  17. package/docs/classes/numeric.Numeric.html +13 -13
  18. package/docs/classes/shutingyard.Shutingyard.html +17 -17
  19. package/docs/index.html +10 -10
  20. package/docs/interfaces/algebra_equation.ISolution.html +2 -2
  21. package/esm/maths/algebra/monom.d.ts +8 -2
  22. package/esm/maths/algebra/monom.js +20 -0
  23. package/esm/maths/algebra/monom.js.map +1 -1
  24. package/esm/maths/algebra/polynom.d.ts +10 -4
  25. package/esm/maths/algebra/polynom.js +7 -0
  26. package/esm/maths/algebra/polynom.js.map +1 -1
  27. package/esm/maths/algebra/rational.d.ts +9 -4
  28. package/esm/maths/algebra/rational.js +3 -0
  29. package/esm/maths/algebra/rational.js.map +1 -1
  30. package/esm/maths/algebra/study/rationalStudy.d.ts +11 -1
  31. package/esm/maths/algebra/study/rationalStudy.js +62 -13
  32. package/esm/maths/algebra/study/rationalStudy.js.map +1 -1
  33. package/esm/maths/algebra/study.d.ts +14 -4
  34. package/esm/maths/algebra/study.js +10 -3
  35. package/esm/maths/algebra/study.js.map +1 -1
  36. package/package.json +12 -12
  37. package/src/maths/algebra/monom.ts +25 -0
  38. package/src/maths/algebra/polynom.ts +9 -0
  39. package/src/maths/algebra/rational.ts +4 -0
  40. package/src/maths/algebra/study/rationalStudy.ts +68 -9
  41. package/src/maths/algebra/study.ts +11 -2
  42. package/tests/algebra/study.test.ts +8 -10
package/.eslintrc.js CHANGED
@@ -1,24 +1,24 @@
1
- module.exports = {
2
- "env": {
3
- "browser": true,
4
- "es6": true
5
- },
6
- "extends": [
7
- "eslint:recommended",
8
- "plugin:@typescript-eslint/eslint-recommended"
9
- ],
10
- "globals": {
11
- "Atomics": "readonly",
12
- "SharedArrayBuffer": "readonly"
13
- },
14
- "parser": "@typescript-eslint/parser",
15
- "parserOptions": {
16
- "ecmaVersion": 2018,
17
- "sourceType": "module"
18
- },
19
- "plugins": [
20
- "@typescript-eslint"
21
- ],
22
- "rules": {
23
- }
1
+ module.exports = {
2
+ "env": {
3
+ "browser": true,
4
+ "es6": true
5
+ },
6
+ "extends": [
7
+ "eslint:recommended",
8
+ "plugin:@typescript-eslint/eslint-recommended"
9
+ ],
10
+ "globals": {
11
+ "Atomics": "readonly",
12
+ "SharedArrayBuffer": "readonly"
13
+ },
14
+ "parser": "@typescript-eslint/parser",
15
+ "parserOptions": {
16
+ "ecmaVersion": 2018,
17
+ "sourceType": "module"
18
+ },
19
+ "plugins": [
20
+ "@typescript-eslint"
21
+ ],
22
+ "rules": {
23
+ }
24
24
  };
package/dist/pi.js CHANGED
@@ -1700,6 +1700,26 @@ class Monom {
1700
1700
  }
1701
1701
  return r;
1702
1702
  };
1703
+ this.evaluateAsNumeric = (values) => {
1704
+ let r = this.coefficient.value;
1705
+ if (typeof values === 'number') {
1706
+ let tmpValues = {};
1707
+ tmpValues[this.variables[0]] = values;
1708
+ return this.evaluateAsNumeric(tmpValues);
1709
+ }
1710
+ if (typeof values === 'object') {
1711
+ if (this.variables.length === 0) {
1712
+ return this.coefficient.value;
1713
+ }
1714
+ for (let L in this._literal) {
1715
+ if (values[L] === undefined) {
1716
+ return 0;
1717
+ }
1718
+ r *= values[L] ** (this._literal[L].value);
1719
+ }
1720
+ }
1721
+ return r;
1722
+ };
1703
1723
  /**
1704
1724
  * Derivative the monom
1705
1725
  * @param letter
@@ -2680,6 +2700,13 @@ class Polynom {
2680
2700
  });
2681
2701
  return r;
2682
2702
  };
2703
+ this.evaluateAsNumeric = (values) => {
2704
+ let r = 0;
2705
+ this._monoms.forEach(monom => {
2706
+ r += monom.evaluateAsNumeric(values);
2707
+ });
2708
+ return r;
2709
+ };
2683
2710
  this.derivative = (letter) => {
2684
2711
  let dP = new Polynom();
2685
2712
  for (let m of this._monoms) {
@@ -3481,6 +3508,9 @@ class Rational {
3481
3508
  let N = this._numerator.evaluate(values), D = this._denominator.evaluate(values);
3482
3509
  return N.divide(D);
3483
3510
  };
3511
+ this.evaluateAsNumeric = (values) => {
3512
+ return this._numerator.evaluateAsNumeric(values) / this._denominator.evaluateAsNumeric(values);
3513
+ };
3484
3514
  this.study = () => {
3485
3515
  return new rationalStudy_1.RationalStudy(this);
3486
3516
  };
@@ -3533,7 +3563,7 @@ exports.Rational = Rational;
3533
3563
  * @module Polynom
3534
3564
  */
3535
3565
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3536
- exports.Study = exports.TABLE_OF_SIGNS = exports.FUNCTION_EXTREMA = exports.ASYMPTOTE = exports.ZEROTYPE = void 0;
3566
+ exports.Study = exports.TABLE_OF_SIGNS = exports.FUNCTION_EXTREMA = exports.ASYMPTOTE_POSITION = exports.ASYMPTOTE = exports.ZEROTYPE = void 0;
3537
3567
  const fraction_1 = __webpack_require__(506);
3538
3568
  const numexp_1 = __webpack_require__(735);
3539
3569
  var ZEROTYPE;
@@ -3549,6 +3579,13 @@ var ASYMPTOTE;
3549
3579
  ASYMPTOTE["SLOPE"] = "ao";
3550
3580
  ASYMPTOTE["HOLE"] = "hole";
3551
3581
  })(ASYMPTOTE = exports.ASYMPTOTE || (exports.ASYMPTOTE = {}));
3582
+ var ASYMPTOTE_POSITION;
3583
+ (function (ASYMPTOTE_POSITION) {
3584
+ ASYMPTOTE_POSITION["LT"] = "LT";
3585
+ ASYMPTOTE_POSITION["RT"] = "RT";
3586
+ ASYMPTOTE_POSITION["LB"] = "LB";
3587
+ ASYMPTOTE_POSITION["RB"] = "RB";
3588
+ })(ASYMPTOTE_POSITION = exports.ASYMPTOTE_POSITION || (exports.ASYMPTOTE_POSITION = {}));
3552
3589
  var FUNCTION_EXTREMA;
3553
3590
  (function (FUNCTION_EXTREMA) {
3554
3591
  FUNCTION_EXTREMA["MIN"] = "min";
@@ -3560,7 +3597,7 @@ var TABLE_OF_SIGNS;
3560
3597
  (function (TABLE_OF_SIGNS) {
3561
3598
  TABLE_OF_SIGNS["SIGNS"] = "signs";
3562
3599
  TABLE_OF_SIGNS["GROWS"] = "grows";
3563
- TABLE_OF_SIGNS["VARIATIONS"] = "variatins";
3600
+ TABLE_OF_SIGNS["VARIATIONS"] = "variations";
3564
3601
  })(TABLE_OF_SIGNS = exports.TABLE_OF_SIGNS || (exports.TABLE_OF_SIGNS = {}));
3565
3602
  /**
3566
3603
  * The study class is a "function study" class that will get:
@@ -3890,8 +3927,7 @@ class RationalStudy extends study_1.Study {
3890
3927
  }
3891
3928
  ;
3892
3929
  makeSigns() {
3893
- let tos = this._getSigns(this.fx, this.zeroes);
3894
- return tos;
3930
+ return this._getSigns(this.fx, this.zeroes);
3895
3931
  }
3896
3932
  ;
3897
3933
  makeAsymptotes() {
@@ -3900,8 +3936,8 @@ class RationalStudy extends study_1.Study {
3900
3936
  let asymptotes = [];
3901
3937
  this.zeroes.filter(x => x.type === study_1.ZEROTYPE.DEFENCE).forEach(zero => {
3902
3938
  // Check if it's a hole or an asymptote
3903
- // TODO: Check for a hole ! Means calculate the limits !
3904
3939
  let Ztype = study_1.ASYMPTOTE.VERTICAL, tex = `x=${zero.tex}`;
3940
+ // Check if it's a hole: the reduced polynom should not be null
3905
3941
  if (zero.exact instanceof fraction_1.Fraction) {
3906
3942
  if (reduced.denominator.evaluate(zero.exact).isNotZero()) {
3907
3943
  Ztype = study_1.ASYMPTOTE.HOLE;
@@ -3914,14 +3950,45 @@ class RationalStudy extends study_1.Study {
3914
3950
  tex = `(${zero.tex};${reduced.evaluate(zero.value).tex})`;
3915
3951
  }
3916
3952
  }
3953
+ // Get the position before and after the asymptote.
3954
+ const delta = 0.000001;
3955
+ let before = this.fx.evaluateAsNumeric(zero.value - delta), after = this.fx.evaluateAsNumeric(zero.value + delta), position = [], pm = "";
3956
+ if (after < -10000) {
3957
+ position.push(study_1.ASYMPTOTE_POSITION.RB);
3958
+ pm += "m";
3959
+ }
3960
+ else if (after > 10000) {
3961
+ position.push(study_1.ASYMPTOTE_POSITION.RT);
3962
+ pm += "p";
3963
+ }
3964
+ if (before < -10000) {
3965
+ position.push(study_1.ASYMPTOTE_POSITION.LB);
3966
+ pm += "m";
3967
+ }
3968
+ else if (before > 10000) {
3969
+ position.push(study_1.ASYMPTOTE_POSITION.LT);
3970
+ pm += "p";
3971
+ }
3972
+ // Left and right are to infinity
3973
+ // TODO: handle the case were one side of the asymptote isn't infinity (not possible in rational study?!)
3974
+ if (pm === "pp") {
3975
+ pm = "+";
3976
+ }
3977
+ else if (pm === "mm") {
3978
+ pm = "-";
3979
+ }
3980
+ else {
3981
+ pm = `\\${pm}`;
3982
+ }
3917
3983
  asymptotes.push({
3918
3984
  fx: null,
3919
3985
  type: Ztype,
3920
3986
  tex: tex,
3921
3987
  zero: zero,
3922
- limits: `\\lim_{x\\to${zero.tex} }\\ f(x) = \\pm\\infty`,
3988
+ limits: `\\lim_{x\\to${zero.tex} }\\ f(x) = ${pm}\\infty`,
3923
3989
  deltaX: null,
3924
- tableOfSign: null
3990
+ tableOfSign: null,
3991
+ position
3925
3992
  });
3926
3993
  });
3927
3994
  // Sloped asymptote
@@ -3929,6 +3996,7 @@ class RationalStudy extends study_1.Study {
3929
3996
  if (NDegree.isEqual(DDegree)) {
3930
3997
  let H = this.fx.numerator.monomByDegree().coefficient.clone().divide(this.fx.denominator.monomByDegree().coefficient), Htex = H.tex;
3931
3998
  let { reminder } = reduced.euclidian(), deltaX = new rational_1.Rational(reminder, reduced.denominator);
3999
+ // Determine the position above or below on the left / right of the asymptote.
3932
4000
  asymptotes.push({
3933
4001
  fx: new polynom_1.Polynom(H),
3934
4002
  type: study_1.ASYMPTOTE.HORIZONTAL,
@@ -3936,7 +4004,8 @@ class RationalStudy extends study_1.Study {
3936
4004
  zero: null,
3937
4005
  limits: `\\lim_{x\\to\\infty}\\ f(x) = ${Htex}`,
3938
4006
  deltaX,
3939
- tableOfSign: this._getSigns(deltaX)
4007
+ tableOfSign: this._getSigns(deltaX),
4008
+ position: this._getHorizontalAsymptoteRelativePositon(deltaX)
3940
4009
  });
3941
4010
  }
3942
4011
  else if (DDegree.greater(NDegree)) {
@@ -3947,7 +4016,8 @@ class RationalStudy extends study_1.Study {
3947
4016
  zero: null,
3948
4017
  limits: `\\lim_{x\\to\\infty}\\ f(x) = ${0}`,
3949
4018
  deltaX: null,
3950
- tableOfSign: null
4019
+ tableOfSign: null,
4020
+ position: this._getHorizontalAsymptoteRelativePositon(this.fx)
3951
4021
  });
3952
4022
  }
3953
4023
  else if (NDegree.value - 1 === DDegree.value) {
@@ -3960,12 +4030,29 @@ class RationalStudy extends study_1.Study {
3960
4030
  zero: null,
3961
4031
  limits: ``,
3962
4032
  deltaX: new rational_1.Rational(reminder, reduced.denominator),
3963
- tableOfSign: this._getSigns(deltaX)
4033
+ tableOfSign: this._getSigns(deltaX),
4034
+ position: this._getHorizontalAsymptoteRelativePositon(deltaX)
3964
4035
  });
3965
4036
  }
3966
4037
  return asymptotes;
3967
4038
  }
3968
4039
  ;
4040
+ _getHorizontalAsymptoteRelativePositon(deltaX, delta = 1000000) {
4041
+ let position = [], before = deltaX.evaluateAsNumeric(-delta), after = deltaX.evaluateAsNumeric(delta);
4042
+ if (before >= 0) {
4043
+ position.push(study_1.ASYMPTOTE_POSITION.LT);
4044
+ }
4045
+ else {
4046
+ position.push(study_1.ASYMPTOTE_POSITION.LB);
4047
+ }
4048
+ if (after >= 0) {
4049
+ position.push(study_1.ASYMPTOTE_POSITION.RT);
4050
+ }
4051
+ else {
4052
+ position.push(study_1.ASYMPTOTE_POSITION.RB);
4053
+ }
4054
+ return position;
4055
+ }
3969
4056
  makeDerivative() {
3970
4057
  let dx = this.fx.clone().derivative(), tos = this._getSigns(dx, this._getZeroes(dx), study_1.TABLE_OF_SIGNS.GROWS);
3971
4058
  let result = this.makeGrowsResult(tos);