pimath 0.0.49 → 0.0.53

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 (127) hide show
  1. package/README.md +1 -1
  2. package/dist/pi.js +626 -358
  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/highlight.css +78 -78
  7. package/docs/assets/icons.css +1043 -1043
  8. package/docs/assets/main.js +52 -52
  9. package/docs/assets/search.js +1 -1
  10. package/docs/assets/style.css +1413 -1388
  11. package/docs/classes/Logicalset.Logicalset-1.html +5 -0
  12. package/docs/classes/Polynom.Rational.html +4 -0
  13. package/docs/classes/Vector.Point.html +1 -0
  14. package/docs/classes/Vector.Vector-1.html +1 -0
  15. package/docs/classes/algebra_equation.Equation.html +26 -0
  16. package/docs/classes/algebra_linearSystem.LinearSystem.html +1 -0
  17. package/docs/classes/algebra_monom.Monom.html +114 -0
  18. package/docs/classes/algebra_polynom.Polynom.html +30 -0
  19. package/docs/classes/coefficients_fraction.Fraction.html +19 -0
  20. package/docs/classes/coefficients_nthroot.NthRoot.html +3 -0
  21. package/docs/classes/expressions_numexp.NumExp.html +1 -0
  22. package/docs/classes/expressions_polynomexp.PolynomExpFactor.html +1 -0
  23. package/docs/classes/expressions_polynomexp.PolynomExpProduct.html +1 -0
  24. package/docs/classes/geometry_circle.Circle.html +3 -0
  25. package/docs/classes/geometry_line.Line.html +3 -0
  26. package/docs/classes/geometry_triangle.Triangle.html +17 -0
  27. package/docs/classes/numeric.Numeric.html +14 -14
  28. package/docs/classes/shutingyard.Shutingyard.html +18 -18
  29. package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +1 -0
  30. package/docs/enums/geometry_line.LinePropriety.html +1 -0
  31. package/docs/enums/shutingyard.ShutingyardMode.html +1 -1
  32. package/docs/enums/shutingyard.ShutingyardType.html +1 -1
  33. package/docs/index.html +11 -11
  34. package/docs/interfaces/algebra_equation.ISolution.html +3 -0
  35. package/docs/interfaces/geometry_triangle.remarquableLines.html +1 -0
  36. package/docs/modules/Logicalset.html +3 -0
  37. package/docs/modules/Polynom.html +3 -0
  38. package/docs/modules/Vector.html +3 -0
  39. package/docs/modules/algebra_equation.html +1 -0
  40. package/docs/modules/algebra_linearSystem.html +1 -0
  41. package/docs/modules/algebra_monom.html +1 -0
  42. package/docs/modules/algebra_polynom.html +1 -0
  43. package/docs/modules/coefficients_fraction.html +1 -0
  44. package/docs/modules/coefficients_nthroot.html +1 -0
  45. package/docs/modules/expressions_numexp.html +1 -0
  46. package/docs/modules/expressions_polynomexp.html +1 -0
  47. package/docs/modules/geometry_circle.html +1 -0
  48. package/docs/modules/geometry_line.html +1 -0
  49. package/docs/modules/geometry_triangle.html +1 -0
  50. package/docs/modules/numeric.html +1 -1
  51. package/docs/modules/shutingyard.html +1 -1
  52. package/docs/modules.html +1 -1
  53. package/esm/index.d.ts +2 -2
  54. package/esm/index.js +2 -2
  55. package/esm/maths/algebra/equation.d.ts +7 -2
  56. package/esm/maths/algebra/equation.js +62 -19
  57. package/esm/maths/algebra/equation.js.map +10 -1
  58. package/esm/maths/algebra/linearSystem.js +1 -1
  59. package/esm/maths/algebra/linearSystem.js.map +10 -1
  60. package/esm/maths/algebra/monom.js +2 -2
  61. package/esm/maths/algebra/monom.js.map +10 -1
  62. package/esm/maths/algebra/polynom.d.ts +5 -1
  63. package/esm/maths/algebra/polynom.js +157 -81
  64. package/esm/maths/algebra/polynom.js.map +1 -1
  65. package/esm/maths/algebra/rational.d.ts +16 -6
  66. package/esm/maths/algebra/rational.js +139 -30
  67. package/esm/maths/algebra/rational.js.map +10 -1
  68. package/esm/maths/coefficients/fraction.d.ts +3 -1
  69. package/esm/maths/coefficients/fraction.js +37 -5
  70. package/esm/maths/coefficients/fraction.js.map +1 -1
  71. package/esm/maths/coefficients/{nthroot.d.ts → nthRoot.d.ts} +5 -5
  72. package/esm/maths/coefficients/{nthroot.js → nthRoot.js} +5 -5
  73. package/esm/maths/coefficients/{nthroot.js.map → nthRoot.js.map} +1 -1
  74. package/esm/maths/expressions/polynomexp.bkp.js +2 -3
  75. package/esm/maths/expressions/polynomexp.bkp.js.map +10 -1
  76. package/esm/maths/expressions/polynomexp.js +3 -3
  77. package/esm/maths/expressions/polynomexp.js.map +10 -1
  78. package/esm/maths/geometry/line.js +8 -0
  79. package/esm/maths/geometry/line.js.map +1 -1
  80. package/esm/maths/geometry/point.js +1 -1
  81. package/esm/maths/geometry/point.js.map +10 -1
  82. package/esm/maths/randomization/random.js +5 -1
  83. package/esm/maths/randomization/random.js.map +10 -1
  84. package/package.json +11 -11
  85. package/public/index.html +234 -235
  86. package/src/index.ts +2 -2
  87. package/src/maths/algebra/equation.ts +68 -19
  88. package/src/maths/algebra/linearSystem.ts +1 -1
  89. package/src/maths/algebra/monom.ts +3 -4
  90. package/src/maths/algebra/polynom.ts +170 -87
  91. package/src/maths/algebra/rational.ts +243 -98
  92. package/src/maths/coefficients/fraction.ts +44 -6
  93. package/src/maths/coefficients/{nthroot.ts → nthRoot.ts} +5 -5
  94. package/src/maths/expressions/polynomexp.bkp.ts +1 -2
  95. package/src/maths/expressions/polynomexp.ts +2 -1
  96. package/src/maths/geometry/line.ts +0 -1
  97. package/src/maths/geometry/point.ts +1 -1
  98. package/tests/algebra/equation.test.ts +36 -0
  99. package/tests/algebra/monom.test.ts +2 -5
  100. package/tests/algebra/polynom.test.ts +7 -3
  101. package/tests/algebra/rationnal.test.ts +96 -0
  102. package/tests/coefficients/fraction.test.ts +43 -1
  103. package/tests/geometry/circle.test.ts +4 -2
  104. package/tests/polynomexp.test.ts +0 -3
  105. package/tsconfig.json +16 -5
  106. package/docs/classes/Algebra.Equation.html +0 -26
  107. package/docs/classes/algebra.LinearSystem.html +0 -1
  108. package/docs/classes/algebra.Logicalset.html +0 -5
  109. package/docs/classes/algebra.Monom.html +0 -114
  110. package/docs/classes/algebra.Polynom.html +0 -30
  111. package/docs/classes/algebra.PolynomExpFactor.html +0 -1
  112. package/docs/classes/algebra.PolynomExpProduct.html +0 -1
  113. package/docs/classes/algebra.Rational.html +0 -4
  114. package/docs/classes/coefficients.Fraction.html +0 -19
  115. package/docs/classes/coefficients.Nthroot.html +0 -3
  116. package/docs/classes/geometry.Circle.html +0 -3
  117. package/docs/classes/geometry.Line.html +0 -3
  118. package/docs/classes/geometry.Point.html +0 -1
  119. package/docs/classes/geometry.Triangle.html +0 -17
  120. package/docs/classes/geometry.Vector.html +0 -1
  121. package/docs/enums/geometry.LinePropriety.html +0 -1
  122. package/docs/interfaces/geometry.remarquableLines.html +0 -1
  123. package/docs/modules/Algebra.html +0 -1
  124. package/docs/modules/Random.html +0 -1
  125. package/docs/modules/coefficients.html +0 -1
  126. package/docs/modules/geometry.html +0 -1
  127. package/docs/modules/random.Random.html +0 -1
package/dist/pi.js CHANGED
@@ -1,11 +1,11 @@
1
- /******/ (() => { // webpackBootstrap
2
- /******/ "use strict";
3
- /******/ var __webpack_modules__ = ({
4
-
5
- /***/ 607:
6
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
7
-
8
- var __webpack_unused_export__;
1
+ /******/ (() => { // webpackBootstrap
2
+ /******/ "use strict";
3
+ /******/ var __webpack_modules__ = ({
4
+
5
+ /***/ 607:
6
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
7
+
8
+ var __webpack_unused_export__;
9
9
 
10
10
  __webpack_unused_export__ = ({ value: true });
11
11
  exports.l = void 0;
@@ -14,7 +14,7 @@ const numexp_1 = __webpack_require__(735);
14
14
  const shutingyard_1 = __webpack_require__(505);
15
15
  const random_1 = __webpack_require__(330);
16
16
  const fraction_1 = __webpack_require__(506);
17
- const nthroot_1 = __webpack_require__(923);
17
+ const nthRoot_1 = __webpack_require__(872);
18
18
  const monom_1 = __webpack_require__(937);
19
19
  const polynom_1 = __webpack_require__(38);
20
20
  const equation_1 = __webpack_require__(760);
@@ -33,7 +33,7 @@ exports.l = {
33
33
  Numeric: numeric_1.Numeric,
34
34
  NumExp: numexp_1.NumExp,
35
35
  Fraction: fraction_1.Fraction,
36
- Root: nthroot_1.Nthroot,
36
+ Root: nthRoot_1.NthRoot,
37
37
  Monom: monom_1.Monom,
38
38
  Polynom: polynom_1.Polynom,
39
39
  Equation: equation_1.Equation,
@@ -52,20 +52,25 @@ exports.l = {
52
52
  }
53
53
  };
54
54
  window.Pi = exports.l;
55
-
56
-
57
- /***/ }),
58
-
59
- /***/ 760:
60
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
61
-
55
+
56
+
57
+ /***/ }),
58
+
59
+ /***/ 760:
60
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
61
+
62
62
 
63
63
  Object.defineProperty(exports, "__esModule", ({ value: true }));
64
- exports.Equation = void 0;
64
+ exports.Equation = exports.PARTICULAR_SOLUTION = void 0;
65
65
  const polynom_1 = __webpack_require__(38);
66
66
  const numeric_1 = __webpack_require__(956);
67
67
  const fraction_1 = __webpack_require__(506);
68
- const nthroot_1 = __webpack_require__(923);
68
+ const nthRoot_1 = __webpack_require__(872);
69
+ var PARTICULAR_SOLUTION;
70
+ (function (PARTICULAR_SOLUTION) {
71
+ PARTICULAR_SOLUTION["real"] = "\\mathbb{R}";
72
+ PARTICULAR_SOLUTION["varnothing"] = "\\varnothing";
73
+ })(PARTICULAR_SOLUTION = exports.PARTICULAR_SOLUTION || (exports.PARTICULAR_SOLUTION = {}));
69
74
  class Equation {
70
75
  /**
71
76
  * Create an Equation using two polynoms.
@@ -74,8 +79,11 @@ class Equation {
74
79
  */
75
80
  constructor(...equations) {
76
81
  // Undetermined texSolutions.
77
- this._varnothing = '\\varnothing';
78
- this._real = '\\mathbb{R}';
82
+ this._varnothing = PARTICULAR_SOLUTION.varnothing;
83
+ this._real = PARTICULAR_SOLUTION.real;
84
+ this.hasVariable = (letter) => {
85
+ return this.variables.includes(letter);
86
+ };
79
87
  // ------------------------------------------
80
88
  // Creation / parsing functions
81
89
  // -----------------------------------------------
@@ -270,6 +278,8 @@ class Equation {
270
278
  default:
271
279
  this._solveDegree3plus();
272
280
  }
281
+ // cleanup the solutions.
282
+ this._solutions = Equation.makeSolutionsUnique(this._solutions);
273
283
  return this;
274
284
  };
275
285
  this.test = (values) => {
@@ -400,7 +410,7 @@ class Equation {
400
410
  }
401
411
  else {
402
412
  this._solutions = [{
403
- tex: v.display,
413
+ tex: v.tex,
404
414
  value: v.value,
405
415
  exact: v
406
416
  }];
@@ -460,7 +470,7 @@ class Equation {
460
470
  ];
461
471
  }
462
472
  else {
463
- nthDelta = new nthroot_1.Nthroot(delta).reduce();
473
+ nthDelta = new nthRoot_1.NthRoot(delta).reduce();
464
474
  if (nthDelta.hasRadical()) {
465
475
  // -b +- coeff\sqrt{radical}
466
476
  // -------------------------
@@ -487,12 +497,12 @@ class Equation {
487
497
  else {
488
498
  this._solutions = [
489
499
  {
490
- tex: `\\dfrac{${-b / gcd} - ${nthDelta.tex} }{ ${2 * a / gcd} }`,
500
+ tex: `\\frac{${-b / gcd} - ${nthDelta.tex} }{ ${2 * a / gcd} }`,
491
501
  value: realX1,
492
502
  exact: false
493
503
  },
494
504
  {
495
- tex: `\\dfrac{${-b / gcd} + ${nthDelta.tex} }{ ${2 * a / gcd} }`,
505
+ tex: `\\frac{${-b / gcd} + ${nthDelta.tex} }{ ${2 * a / gcd} }`,
496
506
  value: realX2,
497
507
  exact: false
498
508
  },
@@ -517,12 +527,12 @@ class Equation {
517
527
  else {
518
528
  this._solutions = [
519
529
  {
520
- tex: `\\dfrac{- ${nthDelta.tex} }{ ${2 * a / gcd} }`,
530
+ tex: `\\frac{- ${nthDelta.tex} }{ ${2 * a / gcd} }`,
521
531
  value: realX1,
522
532
  exact: false
523
533
  },
524
534
  {
525
- tex: `\\dfrac{${nthDelta.tex} }{ ${2 * a / gcd} }`,
535
+ tex: `\\frac{${nthDelta.tex} }{ ${2 * a / gcd} }`,
526
536
  value: realX2,
527
537
  exact: false
528
538
  },
@@ -535,12 +545,12 @@ class Equation {
535
545
  const S1 = new fraction_1.Fraction(-b - nthDelta.coefficient, 2 * a).reduce(), S2 = new fraction_1.Fraction(-b + nthDelta.coefficient, 2 * a).reduce();
536
546
  this._solutions = [
537
547
  {
538
- tex: S1.dfrac,
548
+ tex: S1.frac,
539
549
  value: realX1,
540
550
  exact: S1
541
551
  },
542
552
  {
543
- tex: S2.dfrac,
553
+ tex: S2.frac,
544
554
  value: realX2,
545
555
  exact: S2
546
556
  }
@@ -551,7 +561,7 @@ class Equation {
551
561
  else if (delta === 0) {
552
562
  const sol = new fraction_1.Fraction(-b, 2 * a).reduce();
553
563
  this._solutions = [{
554
- tex: sol.dfrac,
564
+ tex: sol.frac,
555
565
  value: sol.value,
556
566
  exact: sol
557
567
  }];
@@ -634,9 +644,27 @@ class Equation {
634
644
  }
635
645
  return this._solutions;
636
646
  };
637
- this._solveDegree3plus = () => {
638
- // TODO: try to resolve equations with a degree superior than 2.
639
- this._solutions = [{ tex: 'solve x - not yet handled', value: NaN, exact: false }]; // ESLint remove system :(
647
+ this._solveDegree3plus = (letter) => {
648
+ // Push everything to the left
649
+ // factorize
650
+ // solve each factors.
651
+ let equ = this.clone().moveLeft();
652
+ equ.left.factorize();
653
+ this._solutions = [];
654
+ equ.left.factors.forEach(factor => {
655
+ if (factor.degree(letter).leq(2)) {
656
+ let factorAsEquation = new Equation(factor, 0);
657
+ factorAsEquation.solve();
658
+ factorAsEquation.solutions.forEach(solution => {
659
+ this._solutions.push(solution);
660
+ });
661
+ }
662
+ else {
663
+ console.log(factor.tex, ': cannot actually get the solution of this equation');
664
+ }
665
+ });
666
+ // TODO: check equation resolution for more than degree 2
667
+ // this._solutions = [{tex: 'solve x - not yet handled', value: NaN, exact: false}]; // ESLint remove system :(
640
668
  return this._solutions;
641
669
  };
642
670
  // Default equation
@@ -751,15 +779,30 @@ class Equation {
751
779
  set randomizeDefaults(value) {
752
780
  this._randomizeDefaults = value;
753
781
  }
782
+ static makeSolutionsUnique(solutions, sorted) {
783
+ let solutionAsTex = [], uniqueSolutions = solutions.filter(sol => {
784
+ if (!solutionAsTex.includes(sol.tex)) {
785
+ solutionAsTex.push(sol.tex);
786
+ return true;
787
+ }
788
+ else {
789
+ return false;
790
+ }
791
+ });
792
+ if (sorted === true) {
793
+ uniqueSolutions.sort((a, b) => a.value - b.value);
794
+ }
795
+ return uniqueSolutions;
796
+ }
754
797
  }
755
798
  exports.Equation = Equation;
756
-
757
-
758
- /***/ }),
759
-
760
- /***/ 554:
761
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
762
-
799
+
800
+
801
+ /***/ }),
802
+
803
+ /***/ 554:
804
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
805
+
763
806
 
764
807
  Object.defineProperty(exports, "__esModule", ({ value: true }));
765
808
  exports.LinearSystem = void 0;
@@ -974,7 +1017,7 @@ class LinearSystem {
974
1017
  console.log(`Undefined (letter ${letter})`);
975
1018
  return;
976
1019
  }
977
- tex.push(this._solutions[letter].value.dfrac);
1020
+ tex.push(this._solutions[letter].value.frac);
978
1021
  }
979
1022
  return `(${tex.join(';')})`;
980
1023
  }
@@ -1020,13 +1063,13 @@ class LinearSystem {
1020
1063
  }
1021
1064
  }
1022
1065
  exports.LinearSystem = LinearSystem;
1023
-
1024
-
1025
- /***/ }),
1026
-
1027
- /***/ 236:
1028
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1029
-
1066
+
1067
+
1068
+ /***/ }),
1069
+
1070
+ /***/ 236:
1071
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1072
+
1030
1073
 
1031
1074
  /**
1032
1075
  * Polynom module contains everything necessary to handle polynoms.
@@ -1184,13 +1227,13 @@ class Logicalset {
1184
1227
  }
1185
1228
  }
1186
1229
  exports.Logicalset = Logicalset;
1187
-
1188
-
1189
- /***/ }),
1190
-
1191
- /***/ 937:
1192
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1193
-
1230
+
1231
+
1232
+ /***/ }),
1233
+
1234
+ /***/ 937:
1235
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1236
+
1194
1237
 
1195
1238
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1196
1239
  exports.Monom = void 0;
@@ -1900,7 +1943,7 @@ class Monom {
1900
1943
  if (L === '') {
1901
1944
  // No setLetter - means it's only a number !
1902
1945
  if (this._coefficient.value != 0) {
1903
- return `${this._coefficient.dfrac}`;
1946
+ return `${this._coefficient.frac}`;
1904
1947
  }
1905
1948
  else {
1906
1949
  return '0';
@@ -1917,7 +1960,7 @@ class Monom {
1917
1960
  return '0';
1918
1961
  }
1919
1962
  else {
1920
- return `${this._coefficient.dfrac}${L}`;
1963
+ return `${this._coefficient.frac}${L}`;
1921
1964
  }
1922
1965
  }
1923
1966
  }
@@ -2026,13 +2069,13 @@ Monom.xmultiply = (...monoms) => {
2026
2069
  }
2027
2070
  return M;
2028
2071
  };
2029
-
2030
-
2031
- /***/ }),
2032
-
2033
- /***/ 38:
2034
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2035
-
2072
+
2073
+
2074
+ /***/ }),
2075
+
2076
+ /***/ 38:
2077
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2078
+
2036
2079
 
2037
2080
  /**
2038
2081
  * Polynom module contains everything necessary to handle polynoms.*
@@ -2043,6 +2086,7 @@ const monom_1 = __webpack_require__(937);
2043
2086
  const shutingyard_1 = __webpack_require__(505);
2044
2087
  const numeric_1 = __webpack_require__(956);
2045
2088
  const fraction_1 = __webpack_require__(506);
2089
+ const equation_1 = __webpack_require__(760);
2046
2090
  /**
2047
2091
  * Polynom class can handle polynoms, reorder, resolve, ...
2048
2092
  * ```
@@ -2069,8 +2113,15 @@ class Polynom {
2069
2113
  if (typeof inputStr === 'string') {
2070
2114
  return this._parseString(inputStr, ...values);
2071
2115
  }
2072
- else if (typeof inputStr === 'number' || inputStr instanceof fraction_1.Fraction || inputStr instanceof monom_1.Monom) {
2116
+ else if ((typeof inputStr === 'number' || inputStr instanceof fraction_1.Fraction || inputStr instanceof monom_1.Monom)
2117
+ && (values === undefined || values.length === 0)) {
2118
+ this._monoms.push(new monom_1.Monom(inputStr));
2119
+ }
2120
+ else if (inputStr instanceof monom_1.Monom && values.length > 0) {
2073
2121
  this._monoms.push(new monom_1.Monom(inputStr));
2122
+ values.forEach(m => {
2123
+ this._monoms.push(new monom_1.Monom(m));
2124
+ });
2074
2125
  }
2075
2126
  else if (inputStr instanceof Polynom) {
2076
2127
  for (const m of inputStr.monoms) {
@@ -2545,105 +2596,148 @@ class Polynom {
2545
2596
  P = P.euclidian(tempPolynom).quotient;
2546
2597
  }
2547
2598
  let securityLoop = P.degree().clone().multiply(2).value;
2599
+ let result;
2548
2600
  // securityLoop = 0
2549
2601
  while (securityLoop >= 0) {
2550
2602
  securityLoop--;
2551
2603
  if (P.monoms.length < 2) {
2552
2604
  if (!P.isOne()) {
2553
2605
  factors.push(P.clone());
2606
+ P.one();
2554
2607
  }
2555
2608
  break;
2556
2609
  }
2610
+ else if (P.degree(letter).isOne()) {
2611
+ factors.push(P.clone());
2612
+ P.one();
2613
+ break;
2614
+ }
2557
2615
  else {
2558
- // Get the first and last monom.
2616
+ // Get the first and last monom and build all their dividers.
2559
2617
  let m1 = P.monoms[0].dividers, m2 = P.monoms[P.monoms.length - 1].dividers;
2560
- for (let m1d of m1) {
2561
- for (let m2d of m2) {
2562
- // if(m1d.degree()===m2d.degree()){continue}
2563
- let dividerPolynom = new Polynom(), result;
2564
- dividerPolynom.monoms = [m1d.clone(), m2d.clone()];
2565
- result = P.euclidian(dividerPolynom);
2566
- if (result.reminder.isZero()) {
2567
- P = result.quotient.clone();
2568
- factors.push(dividerPolynom);
2569
- continue;
2570
- }
2571
- dividerPolynom.monoms = [m1d.clone(), m2d.clone().opposed()];
2572
- result = P.euclidian(dividerPolynom);
2573
- if (result.reminder.isZero()) {
2574
- P = result.quotient.clone();
2575
- factors.push(dividerPolynom);
2576
- }
2618
+ // Create the list of all "potential" polynom dividers.
2619
+ let allDividers = this._getAllPotentialFactors(P, letter);
2620
+ allDividers.every(div => {
2621
+ result = P.euclidian(div);
2622
+ if (result.reminder.isZero()) {
2623
+ P = result.quotient.clone();
2624
+ factors.push(div);
2625
+ return false;
2577
2626
  }
2578
- }
2627
+ return true;
2628
+ });
2579
2629
  }
2580
2630
  }
2631
+ if (!P.isOne()) {
2632
+ factors.push(P.clone());
2633
+ }
2581
2634
  this.factors = factors;
2582
2635
  return factors;
2583
2636
  };
2637
+ this._getAllPotentialFactors = (P, letter) => {
2638
+ let m1 = P.monoms[0].dividers, m2 = P.monoms[P.monoms.length - 1].dividers;
2639
+ let allDividers = [];
2640
+ m1.forEach(m1d => {
2641
+ m2.forEach(m2d => {
2642
+ if (m1d.degree(letter).isNotEqual(m2d.degree(letter))) {
2643
+ allDividers.push(new Polynom(m1d, m2d));
2644
+ allDividers.push(new Polynom(m1d, m2d.clone().opposed()));
2645
+ }
2646
+ });
2647
+ });
2648
+ return allDividers;
2649
+ };
2584
2650
  // TODO: get zeroes for more than first degree and for more than natural degrees
2585
2651
  this.getZeroes = () => {
2586
- const Z = [];
2587
- switch (this.degree().value) {
2588
- case 0:
2589
- if (this._monoms[0].coefficient.value === 0) {
2590
- return [true];
2591
- }
2592
- else {
2593
- return [false];
2594
- }
2595
- case 1:
2596
- // There is only one monoms,
2597
- if (this._monoms.length === 1) {
2598
- return [new fraction_1.Fraction().zero()];
2599
- }
2600
- else {
2601
- const P = this.clone().reduce().reorder();
2602
- return [P.monoms[1].coefficient.opposed().divide(P.monoms[0].coefficient)];
2603
- }
2604
- // TODO: Determine the zeros of an equation of second degree.
2605
- //case 2:
2606
- default:
2607
- // Make sure the polynom is factorized.
2608
- if (this._factors.length === 0) {
2609
- this.factorize();
2610
- }
2611
- let zeroes = [], zeroesAsTex = [];
2612
- for (let P of this._factors) {
2613
- if (P.degree().greater(2)) {
2614
- // TODO: Handle other polynom.
2615
- }
2616
- else if (P.degree().value === 2) {
2617
- let A = P.monomByDegree(2).coefficient, B = P.monomByDegree(1).coefficient, C = P.monomByDegree(0).coefficient, D = B.clone().pow(2).subtract(A.clone().multiply(C).multiply(4));
2618
- if (D.value > 0) {
2619
- /*console.log('Two zeroes for ', P.tex); */
2620
- let x1 = (-(B.value) + Math.sqrt(D.value)) / (2 * A.value), x2 = (-(B.value) - Math.sqrt(D.value)) / (2 * A.value);
2621
- zeroes.push(new fraction_1.Fraction(x1.toFixed(3)).reduce());
2622
- zeroes.push(new fraction_1.Fraction(x2.toFixed(3)).reduce());
2623
- }
2624
- else if (D.value === 0) {
2625
- /*console.log('One zero for ', P.tex); */
2626
- }
2627
- else {
2628
- console.log('No zero for ', P.tex);
2629
- }
2630
- }
2631
- else {
2632
- for (let z of P.getZeroes()) {
2633
- // Check if the zero is already in the list.
2634
- if (z === false || z === true) {
2635
- continue;
2636
- }
2637
- if (zeroesAsTex.indexOf(z.frac) === -1) {
2638
- zeroes.push(z);
2639
- zeroesAsTex.push(z.frac);
2640
- }
2641
- }
2642
- }
2643
- }
2644
- return zeroes;
2645
- }
2646
- return Z;
2652
+ let equ = new equation_1.Equation(this.clone(), 0);
2653
+ equ.solve();
2654
+ return equ.solutions;
2655
+ //
2656
+ // const Z: Fraction[] = [];
2657
+ //
2658
+ // // ISolution: {tex: string, value: number, exact: boolean|Fraction|...}
2659
+ //
2660
+ // switch (this.degree().value) {
2661
+ // case 0:
2662
+ // if (this._monoms[0].coefficient.value === 0) {
2663
+ // return [{
2664
+ // tex: '\\mathbb{R}',
2665
+ // value: NaN,
2666
+ // exact: false
2667
+ // }];
2668
+ // } else {
2669
+ // return [{
2670
+ // tex: '\\varnothing',
2671
+ // value: NaN,
2672
+ // exact: false
2673
+ // }];
2674
+ // }
2675
+ // case 1:
2676
+ // // There is only one monoms,
2677
+ // if (this._monoms.length === 1) {
2678
+ // return [{
2679
+ // tex: '0',
2680
+ // value: 0,
2681
+ // exact: new Fraction().zero()
2682
+ // }];
2683
+ // } else {
2684
+ // const P = this.clone().reduce().reorder();
2685
+ // const coeff = P.monoms[1].coefficient.opposed().divide(P.monoms[0].coefficient)
2686
+ // return [{
2687
+ // tex: coeff.tex,
2688
+ // value: coeff.value,
2689
+ // exact: coeff
2690
+ // }];
2691
+ // }
2692
+ // // TODO: Determine the zeros of an equation of second degree.
2693
+ // //case 2:
2694
+ // default:
2695
+ // // Make sure the polynom is factorized.
2696
+ // if (this._factors.length === 0) {
2697
+ // this.factorize()
2698
+ // }
2699
+ //
2700
+ // let zeroes:Fraction[] = [], zeroesAsTex = [];
2701
+ // for (let P of this._factors) {
2702
+ // if (P.degree().greater(2)) {
2703
+ // // TODO: get zeroes of polynom with a degree greater than 2.
2704
+ //
2705
+ // } else if (P.degree().value === 2) {
2706
+ // let A = P.monomByDegree(2).coefficient,
2707
+ // B = P.monomByDegree(1).coefficient,
2708
+ // C = P.monomByDegree(0).coefficient,
2709
+ // D = B.clone().pow(2).subtract(A.clone().multiply(C).multiply(4));
2710
+ //
2711
+ // if (D.value > 0) {
2712
+ // /*console.log('Two zeroes for ', P.tex); */
2713
+ // let x1 = (-(B.value) + Math.sqrt(D.value)) / (2 * A.value),
2714
+ // x2 = (-(B.value) - Math.sqrt(D.value)) / (2 * A.value);
2715
+ //
2716
+ // zeroes.push(new Fraction(x1.toFixed(3)).reduce());
2717
+ // zeroes.push(new Fraction(x2.toFixed(3)).reduce());
2718
+ // } else if (D.value === 0) {
2719
+ // /*console.log('One zero for ', P.tex); */
2720
+ // } else {
2721
+ // console.log('No zero for ', P.tex);
2722
+ // }
2723
+ // } else {
2724
+ // for (let z of P.getZeroes()) {
2725
+ // // Check if the zero is already in the list.
2726
+ // // if (z === false || z === true) {
2727
+ // // continue;
2728
+ // // }
2729
+ // if (zeroesAsTex.indexOf(z.frac) === -1) {
2730
+ // zeroes.push(z);
2731
+ // zeroesAsTex.push(z.frac);
2732
+ // }
2733
+ // }
2734
+ // }
2735
+ // }
2736
+ //
2737
+ //
2738
+ // return zeroes;
2739
+ // }
2740
+ // return Z;
2647
2741
  };
2648
2742
  // TODO: analyse the next functions to determine if they are useful or not...
2649
2743
  this.monomByDegree = (degree, letter) => {
@@ -2736,6 +2830,28 @@ class Polynom {
2736
2830
  }
2737
2831
  return M;
2738
2832
  };
2833
+ this.limitToInfinity = (letter) => {
2834
+ const M = this.monomByDegree(undefined, letter), sign = M.coefficient.sign(), degree = M.degree(letter);
2835
+ if (degree.isStrictlyPositive()) {
2836
+ return sign === 1 ? (new fraction_1.Fraction()).infinite() : (new fraction_1.Fraction()).infinite().opposed();
2837
+ }
2838
+ else if (degree.isZero()) {
2839
+ return M.coefficient;
2840
+ }
2841
+ // Any other cases
2842
+ return (new fraction_1.Fraction()).zero();
2843
+ };
2844
+ this.limitToNegativeInfinity = (letter) => {
2845
+ const M = this.monomByDegree(undefined, letter), sign = M.coefficient.sign(), degree = M.degree(letter);
2846
+ if (degree.isStrictlyPositive()) {
2847
+ return sign === -1 ? (new fraction_1.Fraction()).infinite() : (new fraction_1.Fraction()).infinite().opposed();
2848
+ }
2849
+ else if (degree.isZero()) {
2850
+ return M.coefficient;
2851
+ }
2852
+ // Any other cases
2853
+ return (new fraction_1.Fraction()).zero();
2854
+ };
2739
2855
  this.genDisplay = (output, forceSign, wrapParentheses) => {
2740
2856
  let P = '';
2741
2857
  for (const k of this._monoms) {
@@ -2993,6 +3109,9 @@ class Polynom {
2993
3109
  }
2994
3110
  get texFactors() {
2995
3111
  this.factorize();
3112
+ if (this.factors.length === 0) {
3113
+ return this.tex;
3114
+ }
2996
3115
  let tex = '';
2997
3116
  for (let f of this.factors) {
2998
3117
  if (f.monoms.length > 1) {
@@ -3172,13 +3291,13 @@ Polynom.addToken = (stack, element) => {
3172
3291
  break;
3173
3292
  }
3174
3293
  };
3175
-
3176
-
3177
- /***/ }),
3178
-
3179
- /***/ 107:
3180
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3181
-
3294
+
3295
+
3296
+ /***/ }),
3297
+
3298
+ /***/ 107:
3299
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3300
+
3182
3301
 
3183
3302
  /**
3184
3303
  * Rational polynom module contains everything necessary to handle rational polynoms.
@@ -3188,6 +3307,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
3188
3307
  exports.Rational = void 0;
3189
3308
  const polynom_1 = __webpack_require__(38);
3190
3309
  const fraction_1 = __webpack_require__(506);
3310
+ const equation_1 = __webpack_require__(760);
3191
3311
  /**
3192
3312
  * Rational class can handle rational polynoms
3193
3313
  */
@@ -3205,18 +3325,15 @@ class Rational {
3205
3325
  };
3206
3326
  this.domain = () => {
3207
3327
  let zeroes = this._denominator.getZeroes();
3208
- if (zeroes.length === 0 || zeroes[0] === false) {
3209
- return '\\mathbb{R}';
3328
+ if (zeroes.length === 0 || zeroes[0].tex === equation_1.PARTICULAR_SOLUTION.real) {
3329
+ return equation_1.PARTICULAR_SOLUTION.real;
3210
3330
  }
3211
- else if (zeroes[0] === true) {
3212
- return '\\varnothing';
3331
+ else if (zeroes[0].tex === equation_1.PARTICULAR_SOLUTION.varnothing) {
3332
+ return equation_1.PARTICULAR_SOLUTION.varnothing;
3213
3333
  }
3214
3334
  else {
3215
- return '\\mathbb{R}\\setminus\\left{' +
3216
- zeroes.map(x => {
3217
- return (typeof x === 'boolean') ? '' : x.frac;
3218
- })
3219
- .join(';') + '\\right}';
3335
+ return '\\mathbb{R}\\setminus\\left\\{' +
3336
+ zeroes.map(x => x.tex).join(';') + '\\right\\}';
3220
3337
  }
3221
3338
  };
3222
3339
  this.amplify = (P) => {
@@ -3224,6 +3341,12 @@ class Rational {
3224
3341
  this._denominator.multiply(P);
3225
3342
  return this;
3226
3343
  };
3344
+ this.derivative = (letter) => {
3345
+ let N = this._numerator.clone(), D = this._denominator.clone(), dN = N.clone().derivative(letter), dD = D.clone().derivative(letter);
3346
+ this._numerator = dN.clone().multiply(D).subtract(N.clone().multiply(dD));
3347
+ this._denominator = D.clone().pow(2);
3348
+ return this;
3349
+ };
3227
3350
  this.simplify = (P) => {
3228
3351
  let NumeratorEuclidien = this._numerator.euclidian(P);
3229
3352
  if (!NumeratorEuclidien.reminder.isZero()) {
@@ -3238,9 +3361,7 @@ class Rational {
3238
3361
  return this;
3239
3362
  };
3240
3363
  this.reduce = () => {
3241
- console.log(this._numerator.tex);
3242
3364
  this._numerator.factorize();
3243
- console.log(this._numerator.factors.map(x => x.tex));
3244
3365
  for (let f of this._numerator.factors) {
3245
3366
  this.simplify(f);
3246
3367
  }
@@ -3265,50 +3386,157 @@ class Rational {
3265
3386
  this.subtract = (R) => {
3266
3387
  return this.add(R.clone().opposed());
3267
3388
  };
3268
- this.limits = (value, letter) => {
3389
+ this.limits = (value, offset, letter) => {
3269
3390
  if (value === Infinity || value === -Infinity) {
3270
- let N = this._numerator.monomByDegree(this._numerator.degree(letter), letter), D = this._denominator.monomByDegree(this._denominator.degree(letter), letter);
3271
- N.divide(D);
3272
- if (N.degree(letter).isStrictlyPositive()) {
3273
- return N.coefficient.sign() * (Math.pow((value > 0 ? 1 : -1), N.degree(letter).value % 2)) === 1 ? Infinity : -Infinity;
3274
- }
3275
- if (N.degree(letter).isZero()) {
3276
- return N.coefficient;
3391
+ let { quotient, reminder } = this._numerator.clone().euclidian(this._denominator);
3392
+ // quotient is positive => it will be infinite.
3393
+ if (quotient.degree(letter).isStrictlyPositive()) {
3394
+ return value === Infinity ? quotient.limitToInfinity(letter) : quotient.limitToNegativeInfinity(letter);
3395
+ // return quotient.monomByDegree(undefined, letter).coefficient.sign()===1?(new Fraction()).infinite():(new Fraction()).infinite().opposed()
3277
3396
  }
3278
- if (N.degree(letter).isStrictlyPositive()) {
3279
- return N.coefficient.sign() * (Math.pow(-1, N.degree(letter).value % 2)) === 1 ? 0 : -0;
3397
+ else {
3398
+ return quotient.monomByDegree(undefined, letter).coefficient;
3280
3399
  }
3281
3400
  }
3282
3401
  else {
3283
- return this._numerator.evaluate({ letter: new fraction_1.Fraction(value) }).divide(this._denominator.evaluate({ letter: new fraction_1.Fraction(value) }));
3402
+ let evalValues = {}, evalValuesOffset = {}, theLimit, theSign, FR = this.clone().reduce();
3403
+ evalValues[letter === undefined ? 'x' : letter] = new fraction_1.Fraction(value);
3404
+ if (offset !== 'above' && offset !== 'below') {
3405
+ theLimit = FR._numerator.evaluate(evalValues)
3406
+ .divide(FR._denominator.evaluate(evalValues));
3407
+ return theLimit.isInfinity() ? theLimit.abs() : theLimit;
3408
+ }
3409
+ else {
3410
+ if (offset === 'above') {
3411
+ evalValuesOffset[letter === undefined ? 'x' : letter] = (new fraction_1.Fraction(value)).add(0.000001);
3412
+ }
3413
+ else if (offset === 'below') {
3414
+ evalValuesOffset[letter === undefined ? 'x' : letter] = (new fraction_1.Fraction(value)).subtract(0.000001);
3415
+ }
3416
+ theLimit = FR._numerator.evaluate(evalValues)
3417
+ .divide(FR._denominator.evaluate(evalValues));
3418
+ theSign = FR._numerator.evaluate(evalValuesOffset)
3419
+ .divide(FR._denominator.evaluate(evalValuesOffset)).sign();
3420
+ if (theLimit.isInfinity()) {
3421
+ return theSign === 1 ? theLimit.abs() : theLimit.abs().opposed();
3422
+ }
3423
+ else {
3424
+ return theLimit;
3425
+ }
3426
+ }
3427
+ }
3428
+ };
3429
+ this.makeTableOfSigns = () => {
3430
+ // Factorize the numerator and the denominator
3431
+ this._numerator.factorize();
3432
+ this._denominator.factorize();
3433
+ let zeroes = equation_1.Equation.makeSolutionsUnique([...this._numerator.getZeroes(), ...this._denominator.getZeroes()], true), NFactors = this._numerator.factors, DFactors = this._denominator.factors;
3434
+ let tableOfSigns = [], result = [];
3435
+ NFactors.forEach(factor => {
3436
+ tableOfSigns.push(this._makeOneLineOfTableOfSigns(factor, zeroes, 'z'));
3437
+ });
3438
+ DFactors.forEach(factor => {
3439
+ tableOfSigns.push(this._makeOneLineOfTableOfSigns(factor, zeroes, 'd'));
3440
+ });
3441
+ // Empty line
3442
+ tableOfSigns.push([]);
3443
+ // Add the final row as cumulative
3444
+ let resultLine = tableOfSigns[0].map((x, index) => {
3445
+ if (index === 0) {
3446
+ return '';
3447
+ }
3448
+ if (index === tableOfSigns[0].length - 1) {
3449
+ return '';
3450
+ }
3451
+ if (index % 2 === 0) {
3452
+ return 't';
3453
+ }
3454
+ return '+';
3455
+ });
3456
+ for (let current of tableOfSigns) {
3457
+ for (let i = 0; i < current.length; i++) {
3458
+ if (i % 2 === 0) {
3459
+ // t, z or d
3460
+ if (resultLine[i] === 'd') {
3461
+ continue;
3462
+ }
3463
+ if (current[i] !== 't') {
3464
+ resultLine[i] = current[i];
3465
+ }
3466
+ }
3467
+ else {
3468
+ // + or -
3469
+ if (current[i] === '-') {
3470
+ resultLine[i] = resultLine[i] === '+' ? '-' : '+';
3471
+ }
3472
+ }
3473
+ }
3284
3474
  }
3475
+ // Add the variation line.
3476
+ // TODO: add the variation line.
3477
+ tableOfSigns.push(resultLine);
3478
+ let tos = {
3479
+ factors: [...NFactors, ...DFactors],
3480
+ zeroes: zeroes,
3481
+ signs: tableOfSigns,
3482
+ tex: ''
3483
+ };
3484
+ this._makeTexFromTableOfSigns(tos);
3485
+ return tos;
3486
+ };
3487
+ this._makeTexFromTableOfSigns = (tos) => {
3488
+ let tex = `\\begin{tikzpicture}
3489
+ \\tkzTabInit[lgt=3,espcl=2,deltacl=0]{/1.2,\\(${tos.factors.map(x => x.tex).join('\\)/1,\\(')}\\)/1,/.1,\\(f(x)\\)/1.2}{{\\scriptsize \\hspace{1cm} \\(-\\infty\\)},\\(${tos.zeroes.map(x => x.tex).join('\\),\\(')}\\),{\\scriptsize \\hspace{-1cm} \\(+\\infty\\)}}`;
3490
+ tos.signs.forEach(list => {
3491
+ tex += (`\n\\tkzTabLine{${list.join(',')}}`);
3492
+ });
3493
+ tex += `\n\\end{tikzpicture}`;
3494
+ tos.tex = tex;
3495
+ return tex;
3496
+ };
3497
+ this._makeOneLineOfTableOfSigns = (factor, zeroes, zeroSign) => {
3498
+ let oneLine = [], currentZero = factor.getZeroes().map(x => x.tex);
3499
+ // First +/- sign, before the first zero
3500
+ oneLine.push('');
3501
+ oneLine.push(factor.evaluate(zeroes[0].value - 1).sign() === 1 ? '+' : '-');
3502
+ for (let i = 0; i < zeroes.length; i++) {
3503
+ // Add the zero if it's the current one
3504
+ oneLine.push(currentZero.includes(zeroes[i].tex) ? zeroSign : 't');
3505
+ // + / - sign after the current zero
3506
+ if (i < zeroes.length - 1) {
3507
+ oneLine.push(factor.evaluate((zeroes[i].value + zeroes[i + 1].value) / 2).sign() === 1 ? '+' : '-');
3508
+ }
3509
+ else if (i === zeroes.length - 1) {
3510
+ oneLine.push(factor.evaluate(zeroes[i].value + 1).sign() === 1 ? '+' : '-');
3511
+ }
3512
+ }
3513
+ oneLine.push('');
3514
+ return oneLine;
3285
3515
  };
3286
3516
  this._numerator = numerator ? numerator.clone() : new polynom_1.Polynom();
3287
3517
  this._denominator = denominator ? denominator.clone() : new polynom_1.Polynom();
3288
3518
  }
3289
- get tex() {
3290
- return `\\dfrac{ ${this._numerator.tex} }{ ${this._denominator.tex} }`;
3291
- }
3292
- get texFactors() {
3293
- this._numerator.factorize();
3294
- this._denominator.factorize();
3295
- return `\\dfrac{ ${this._numerator.texFactors} }{ ${this._denominator.texFactors} }`;
3296
- }
3297
3519
  get numerator() {
3298
3520
  return this._numerator;
3299
3521
  }
3300
3522
  get denominator() {
3301
3523
  return this._denominator;
3302
3524
  }
3525
+ get tex() {
3526
+ return `\\frac{ ${this._numerator.tex} }{ ${this._denominator.tex} }`;
3527
+ }
3528
+ get texFactors() {
3529
+ return `\\frac{ ${this._numerator.texFactors} }{ ${this._denominator.texFactors} }`;
3530
+ }
3303
3531
  }
3304
3532
  exports.Rational = Rational;
3305
-
3306
-
3307
- /***/ }),
3308
-
3309
- /***/ 506:
3310
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3311
-
3533
+
3534
+
3535
+ /***/ }),
3536
+
3537
+ /***/ 506:
3538
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3539
+
3312
3540
 
3313
3541
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3314
3542
  exports.Fraction = void 0;
@@ -3639,10 +3867,10 @@ class Fraction {
3639
3867
  return isNaN(this._numerator);
3640
3868
  };
3641
3869
  this.isInfinity = () => {
3642
- return this._numerator === Infinity;
3870
+ return Math.abs(this._numerator) === Infinity;
3643
3871
  };
3644
3872
  this.isFinite = () => {
3645
- return !this.isInfinity();
3873
+ return !this.isInfinity() && !this.isNaN();
3646
3874
  };
3647
3875
  this.isSquare = () => {
3648
3876
  return Math.sqrt(this._numerator) % 1 === 0 && Math.sqrt(this._denominator) % 1 === 0;
@@ -3687,9 +3915,6 @@ class Fraction {
3687
3915
  }
3688
3916
  return this;
3689
3917
  }
3690
- get isFraction() {
3691
- return true;
3692
- }
3693
3918
  // ------------------------------------------
3694
3919
  // Getter and setter
3695
3920
  // ------------------------------------------
@@ -3710,6 +3935,9 @@ class Fraction {
3710
3935
  }
3711
3936
  // Display getter
3712
3937
  get tex() {
3938
+ if (this.isInfinity()) {
3939
+ return `${this.sign() === 1 ? '+' : '-'}\\infty`;
3940
+ }
3713
3941
  if (this._denominator === 1) {
3714
3942
  return `${this._numerator}`;
3715
3943
  }
@@ -3760,20 +3988,52 @@ Fraction.min = (...fractions) => {
3760
3988
  }
3761
3989
  return M;
3762
3990
  };
3763
-
3764
-
3765
- /***/ }),
3766
-
3767
- /***/ 923:
3768
- /***/ ((__unused_webpack_module, exports) => {
3769
-
3991
+ Fraction.average = (...fractions) => {
3992
+ let M = new Fraction().zero();
3993
+ for (let f of fractions) {
3994
+ M.add(f);
3995
+ }
3996
+ M.divide(fractions.length);
3997
+ return M;
3998
+ };
3999
+ Fraction.unique = (fractions, sorted) => {
4000
+ // TODO: make sure it's wokring -> test !
4001
+ let unique = {}, distinct = [];
4002
+ fractions.forEach(x => {
4003
+ if (!unique[x.clone().reduce().tex]) {
4004
+ distinct.push(x.clone());
4005
+ unique[x.tex] = true;
4006
+ }
4007
+ });
4008
+ if (sorted) {
4009
+ return Fraction.sort(distinct);
4010
+ }
4011
+ else {
4012
+ return distinct;
4013
+ }
4014
+ };
4015
+ Fraction.sort = (fractions, reverse) => {
4016
+ // Todo make sure it's the correct order, not reverse -> make a test
4017
+ let sorted = fractions.sort((a, b) => a.value - b.value);
4018
+ if (reverse) {
4019
+ sorted.reverse();
4020
+ }
4021
+ return sorted;
4022
+ };
4023
+
4024
+
4025
+ /***/ }),
4026
+
4027
+ /***/ 872:
4028
+ /***/ ((__unused_webpack_module, exports) => {
4029
+
3770
4030
 
3771
4031
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3772
- exports.Nthroot = void 0;
4032
+ exports.NthRoot = void 0;
3773
4033
  /**
3774
- * Nthroot is something like "a+b\sqrt{3}
4034
+ * NthRoot is something like "a+b\sqrt{3}
3775
4035
  */
3776
- class Nthroot {
4036
+ class NthRoot {
3777
4037
  constructor(...values) {
3778
4038
  // ------------------------------------------
3779
4039
  // Creation / parsing functions
@@ -3879,14 +4139,14 @@ class Nthroot {
3879
4139
  return this._coefficient * Math.pow(this._radical, 1 / this._nth);
3880
4140
  }
3881
4141
  }
3882
- exports.Nthroot = Nthroot;
3883
-
3884
-
3885
- /***/ }),
3886
-
3887
- /***/ 735:
3888
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3889
-
4142
+ exports.NthRoot = NthRoot;
4143
+
4144
+
4145
+ /***/ }),
4146
+
4147
+ /***/ 735:
4148
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4149
+
3890
4150
 
3891
4151
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3892
4152
  exports.NumExp = void 0;
@@ -4041,13 +4301,13 @@ class NumExp {
4041
4301
  }
4042
4302
  }
4043
4303
  exports.NumExp = NumExp;
4044
-
4045
-
4046
- /***/ }),
4047
-
4048
- /***/ 75:
4049
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4050
-
4304
+
4305
+
4306
+ /***/ }),
4307
+
4308
+ /***/ 75:
4309
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4310
+
4051
4311
 
4052
4312
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4053
4313
  exports.PolynomExpProduct = exports.PolynomExpFactor = void 0;
@@ -4206,7 +4466,7 @@ class PolynomExpProduct {
4206
4466
  }
4207
4467
  // restore all degrees to negative again.
4208
4468
  denominators.map(x => x.degree.opposed());
4209
- tex = `\\dfrac{ ${numeratorsAsTex.join(' \\cdot ')} }{ ${denominatorsAsTex.join(' \\cdot ')} }`;
4469
+ tex = `\\frac{ ${numeratorsAsTex.join(' \\cdot ')} }{ ${denominatorsAsTex.join(' \\cdot ')} }`;
4210
4470
  }
4211
4471
  }
4212
4472
  // Apply the modification
@@ -4293,13 +4553,13 @@ class PolynomExpProduct {
4293
4553
  }
4294
4554
  }
4295
4555
  exports.PolynomExpProduct = PolynomExpProduct;
4296
-
4297
-
4298
- /***/ }),
4299
-
4300
- /***/ 699:
4301
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4302
-
4556
+
4557
+
4558
+ /***/ }),
4559
+
4560
+ /***/ 699:
4561
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4562
+
4303
4563
 
4304
4564
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4305
4565
  exports.Circle = void 0;
@@ -4606,13 +4866,13 @@ class Circle {
4606
4866
  }
4607
4867
  }
4608
4868
  exports.Circle = Circle;
4609
-
4610
-
4611
- /***/ }),
4612
-
4613
- /***/ 9:
4614
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4615
-
4869
+
4870
+
4871
+ /***/ }),
4872
+
4873
+ /***/ 9:
4874
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4875
+
4616
4876
 
4617
4877
  /**
4618
4878
  * This class works for 2d line in a plane.
@@ -4696,6 +4956,14 @@ class Line {
4696
4956
  return this.parseByPointAndVector(values[0], values[1]);
4697
4957
  }
4698
4958
  }
4959
+ else if (values[0] instanceof point_1.Point && values[1] instanceof Line) {
4960
+ if (values[2] === LinePropriety.Parallel || values[2] === null) {
4961
+ return this.parseByPointAndLine(values[0], values[1], LinePropriety.Parallel);
4962
+ }
4963
+ else {
4964
+ return this.parseByPointAndLine(values[0], values[1], LinePropriety.Perpendicular);
4965
+ }
4966
+ }
4699
4967
  }
4700
4968
  // TODO: Add the ability to create line from a normal vector
4701
4969
  console.log('Someting wrong happend while creating the line');
@@ -5009,13 +5277,13 @@ class Line {
5009
5277
  exports.Line = Line;
5010
5278
  Line.PERPENDICULAR = LinePropriety.Perpendicular;
5011
5279
  Line.PARALLEL = LinePropriety.Parallel;
5012
-
5013
-
5014
- /***/ }),
5015
-
5016
- /***/ 557:
5017
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5018
-
5280
+
5281
+
5282
+ /***/ }),
5283
+
5284
+ /***/ 557:
5285
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5286
+
5019
5287
 
5020
5288
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5021
5289
  exports.Point = void 0;
@@ -5114,7 +5382,7 @@ class Point {
5114
5382
  let V = new vector_1.Vector(this, item);
5115
5383
  value = V.norm;
5116
5384
  fraction = V.normSquare.sqrt();
5117
- tex = V.normSquare.isSquare() ? fraction.tex : `\\sqrt{\\dfrac{ ${V.normSquare.numerator} }{ ${V.normSquare.denominator} }}`;
5385
+ tex = V.normSquare.isSquare() ? fraction.tex : `\\sqrt{\\frac{ ${V.normSquare.numerator} }{ ${V.normSquare.denominator} }}`;
5118
5386
  }
5119
5387
  return { value, fraction, tex };
5120
5388
  };
@@ -5179,13 +5447,13 @@ Point.pmatrix = (a, b, c) => {
5179
5447
  return `\\begin{pmatrix} ${a.tex ? a.tex : a} \\\\ ${b.tex ? b.tex : b} \\\\ ${c.tex ? c.tex : c} \\end{pmatrix}`;
5180
5448
  }
5181
5449
  };
5182
-
5183
-
5184
- /***/ }),
5185
-
5186
- /***/ 164:
5187
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5188
-
5450
+
5451
+
5452
+ /***/ }),
5453
+
5454
+ /***/ 164:
5455
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5456
+
5189
5457
 
5190
5458
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5191
5459
  exports.Triangle = void 0;
@@ -5454,13 +5722,13 @@ class Triangle {
5454
5722
  }
5455
5723
  }
5456
5724
  exports.Triangle = Triangle;
5457
-
5458
-
5459
- /***/ }),
5460
-
5461
- /***/ 586:
5462
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5463
-
5725
+
5726
+
5727
+ /***/ }),
5728
+
5729
+ /***/ 586:
5730
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5731
+
5464
5732
 
5465
5733
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5466
5734
  exports.Vector = void 0;
@@ -5638,13 +5906,13 @@ Vector.scalarProduct = (v1, v2) => {
5638
5906
  // TODO: Transform to fraction with nthroot.
5639
5907
  return v1.x.value * v2.x.value + v1.y.value * v2.y.value;
5640
5908
  };
5641
-
5642
-
5643
- /***/ }),
5644
-
5645
- /***/ 956:
5646
- /***/ ((__unused_webpack_module, exports) => {
5647
-
5909
+
5910
+
5911
+ /***/ }),
5912
+
5913
+ /***/ 956:
5914
+ /***/ ((__unused_webpack_module, exports) => {
5915
+
5648
5916
 
5649
5917
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5650
5918
  exports.Numeric = void 0;
@@ -5750,13 +6018,13 @@ class Numeric {
5750
6018
  }
5751
6019
  }
5752
6020
  exports.Numeric = Numeric;
5753
-
5754
-
5755
- /***/ }),
5756
-
5757
- /***/ 330:
5758
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
5759
-
6021
+
6022
+
6023
+ /***/ }),
6024
+
6025
+ /***/ 330:
6026
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
6027
+
5760
6028
 
5761
6029
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5762
6030
  if (k2 === undefined) k2 = k;
@@ -5818,13 +6086,13 @@ var Random;
5818
6086
  }
5819
6087
  Random.shuffle = shuffle;
5820
6088
  })(Random = exports.Random || (exports.Random = {}));
5821
-
5822
-
5823
- /***/ }),
5824
-
5825
- /***/ 373:
5826
- /***/ ((__unused_webpack_module, exports) => {
5827
-
6089
+
6090
+
6091
+ /***/ }),
6092
+
6093
+ /***/ 373:
6094
+ /***/ ((__unused_webpack_module, exports) => {
6095
+
5828
6096
 
5829
6097
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5830
6098
  exports.randomCore = void 0;
@@ -5846,13 +6114,13 @@ class randomCore {
5846
6114
  }
5847
6115
  }
5848
6116
  exports.randomCore = randomCore;
5849
-
5850
-
5851
- /***/ }),
5852
-
5853
- /***/ 754:
5854
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5855
-
6117
+
6118
+
6119
+ /***/ }),
6120
+
6121
+ /***/ 754:
6122
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
6123
+
5856
6124
 
5857
6125
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5858
6126
  exports.rndFraction = void 0;
@@ -5892,13 +6160,13 @@ class rndFraction extends randomCore_1.randomCore {
5892
6160
  }
5893
6161
  }
5894
6162
  exports.rndFraction = rndFraction;
5895
-
5896
-
5897
- /***/ }),
5898
-
5899
- /***/ 140:
5900
- /***/ ((__unused_webpack_module, exports) => {
5901
-
6163
+
6164
+
6165
+ /***/ }),
6166
+
6167
+ /***/ 140:
6168
+ /***/ ((__unused_webpack_module, exports) => {
6169
+
5902
6170
 
5903
6171
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5904
6172
  exports.rndHelpers = void 0;
@@ -5967,13 +6235,13 @@ class rndHelpers {
5967
6235
  }
5968
6236
  }
5969
6237
  exports.rndHelpers = rndHelpers;
5970
-
5971
-
5972
- /***/ }),
5973
-
5974
- /***/ 793:
5975
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5976
-
6238
+
6239
+
6240
+ /***/ }),
6241
+
6242
+ /***/ 793:
6243
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
6244
+
5977
6245
 
5978
6246
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5979
6247
  exports.rndMonom = void 0;
@@ -6026,13 +6294,13 @@ class rndMonom extends randomCore_1.randomCore {
6026
6294
  }
6027
6295
  }
6028
6296
  exports.rndMonom = rndMonom;
6029
-
6030
-
6031
- /***/ }),
6032
-
6033
- /***/ 22:
6034
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
6035
-
6297
+
6298
+
6299
+ /***/ }),
6300
+
6301
+ /***/ 22:
6302
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
6303
+
6036
6304
 
6037
6305
  Object.defineProperty(exports, "__esModule", ({ value: true }));
6038
6306
  exports.rndPolynom = void 0;
@@ -6107,22 +6375,22 @@ class rndPolynom extends randomCore_1.randomCore {
6107
6375
  }
6108
6376
  }
6109
6377
  exports.rndPolynom = rndPolynom;
6110
-
6111
-
6112
- /***/ }),
6113
-
6114
- /***/ 230:
6115
- /***/ ((__unused_webpack_module, exports) => {
6116
-
6378
+
6379
+
6380
+ /***/ }),
6381
+
6382
+ /***/ 230:
6383
+ /***/ ((__unused_webpack_module, exports) => {
6384
+
6117
6385
 
6118
6386
  Object.defineProperty(exports, "__esModule", ({ value: true }));
6119
-
6120
-
6121
- /***/ }),
6122
-
6123
- /***/ 505:
6124
- /***/ ((__unused_webpack_module, exports) => {
6125
-
6387
+
6388
+
6389
+ /***/ }),
6390
+
6391
+ /***/ 505:
6392
+ /***/ ((__unused_webpack_module, exports) => {
6393
+
6126
6394
 
6127
6395
  Object.defineProperty(exports, "__esModule", ({ value: true }));
6128
6396
  exports.Shutingyard = exports.ShutingyardMode = exports.ShutingyardType = exports.tokenConstant = void 0;
@@ -6427,43 +6695,43 @@ class Shutingyard {
6427
6695
  }
6428
6696
  }
6429
6697
  exports.Shutingyard = Shutingyard;
6430
-
6431
-
6432
- /***/ })
6433
-
6434
- /******/ });
6435
- /************************************************************************/
6436
- /******/ // The module cache
6437
- /******/ var __webpack_module_cache__ = {};
6438
- /******/
6439
- /******/ // The require function
6440
- /******/ function __webpack_require__(moduleId) {
6441
- /******/ // Check if module is in cache
6442
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
6443
- /******/ if (cachedModule !== undefined) {
6444
- /******/ return cachedModule.exports;
6445
- /******/ }
6446
- /******/ // Create a new module (and put it into the cache)
6447
- /******/ var module = __webpack_module_cache__[moduleId] = {
6448
- /******/ // no module.id needed
6449
- /******/ // no module.loaded needed
6450
- /******/ exports: {}
6451
- /******/ };
6452
- /******/
6453
- /******/ // Execute the module function
6454
- /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
6455
- /******/
6456
- /******/ // Return the exports of the module
6457
- /******/ return module.exports;
6458
- /******/ }
6459
- /******/
6460
- /************************************************************************/
6461
- /******/
6462
- /******/ // startup
6463
- /******/ // Load entry module and return exports
6464
- /******/ // This entry module is referenced by other modules so it can't be inlined
6465
- /******/ var __webpack_exports__ = __webpack_require__(607);
6466
- /******/
6467
- /******/ })()
6468
- ;
6698
+
6699
+
6700
+ /***/ })
6701
+
6702
+ /******/ });
6703
+ /************************************************************************/
6704
+ /******/ // The module cache
6705
+ /******/ var __webpack_module_cache__ = {};
6706
+ /******/
6707
+ /******/ // The require function
6708
+ /******/ function __webpack_require__(moduleId) {
6709
+ /******/ // Check if module is in cache
6710
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
6711
+ /******/ if (cachedModule !== undefined) {
6712
+ /******/ return cachedModule.exports;
6713
+ /******/ }
6714
+ /******/ // Create a new module (and put it into the cache)
6715
+ /******/ var module = __webpack_module_cache__[moduleId] = {
6716
+ /******/ // no module.id needed
6717
+ /******/ // no module.loaded needed
6718
+ /******/ exports: {}
6719
+ /******/ };
6720
+ /******/
6721
+ /******/ // Execute the module function
6722
+ /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
6723
+ /******/
6724
+ /******/ // Return the exports of the module
6725
+ /******/ return module.exports;
6726
+ /******/ }
6727
+ /******/
6728
+ /************************************************************************/
6729
+ /******/
6730
+ /******/ // startup
6731
+ /******/ // Load entry module and return exports
6732
+ /******/ // This entry module is referenced by other modules so it can't be inlined
6733
+ /******/ var __webpack_exports__ = __webpack_require__(607);
6734
+ /******/
6735
+ /******/ })()
6736
+ ;
6469
6737
  //# sourceMappingURL=pi.js.map