pimath 0.0.125 → 0.0.126

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 (78) hide show
  1. package/.idea/inspectionProfiles/Project_Default.xml +5 -5
  2. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]/shelved.patch +192 -192
  3. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43_[Default_Changelist]/shelved.patch +2404 -2404
  4. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01_[Default_Changelist]/shelved.patch +1362 -1362
  5. package/dev/pimath.js +7945 -0
  6. package/dev/pimath.js.map +1 -0
  7. package/dist/pimath.js +192 -221
  8. package/dist/pimath.js.map +1 -1
  9. package/dist/pimath.min.js +1 -1
  10. package/dist/pimath.min.js.map +1 -1
  11. package/docs/.nojekyll +1 -0
  12. package/docs/assets/highlight.css +78 -0
  13. package/docs/assets/main.js +59 -0
  14. package/docs/assets/navigation.js +1 -0
  15. package/docs/assets/search.js +1 -0
  16. package/docs/assets/style.css +1383 -0
  17. package/docs/classes/Logicalset.Logicalset.html +217 -0
  18. package/docs/classes/Polynom.Rational.html +397 -0
  19. package/docs/classes/Vector-1.Vector.html +490 -0
  20. package/docs/classes/Vector.Point.html +337 -0
  21. package/docs/classes/algebra_equation.Equation.html +790 -0
  22. package/docs/classes/algebra_linearSystem.LinearSystem.html +404 -0
  23. package/docs/classes/algebra_monom.Monom.html +962 -0
  24. package/docs/classes/algebra_polynom.Polynom.html +1275 -0
  25. package/docs/classes/coefficients_fraction.Fraction.html +934 -0
  26. package/docs/classes/geometry_circle.Circle.html +472 -0
  27. package/docs/classes/geometry_line.Line.html +774 -0
  28. package/docs/classes/geometry_triangle.Triangle.html +429 -0
  29. package/docs/classes/numeric.Numeric.html +265 -0
  30. package/docs/classes/shutingyard.Shutingyard.html +250 -0
  31. package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +83 -0
  32. package/docs/enums/geometry_line.LinePropriety.html +97 -0
  33. package/docs/enums/shutingyard.ShutingyardMode.html +97 -0
  34. package/docs/enums/shutingyard.ShutingyardType.html +111 -0
  35. package/docs/index.html +63 -0
  36. package/docs/interfaces/algebra_equation.ISolution.html +105 -0
  37. package/docs/interfaces/algebra_polynom.IEuclidian.html +87 -0
  38. package/docs/interfaces/geometry_triangle.remarquableLines.html +163 -0
  39. package/docs/modules/Logicalset.html +65 -0
  40. package/docs/modules/Polynom.html +65 -0
  41. package/docs/modules/Vector-1.html +65 -0
  42. package/docs/modules/Vector.html +65 -0
  43. package/docs/modules/algebra_equation.html +69 -0
  44. package/docs/modules/algebra_linearSystem.html +61 -0
  45. package/docs/modules/algebra_monom.html +65 -0
  46. package/docs/modules/algebra_polynom.html +69 -0
  47. package/docs/modules/coefficients_fraction.html +65 -0
  48. package/docs/modules/geometry_circle.html +61 -0
  49. package/docs/modules/geometry_line.html +65 -0
  50. package/docs/modules/geometry_triangle.html +65 -0
  51. package/docs/modules/numeric.html +61 -0
  52. package/docs/modules/shutingyard.html +75 -0
  53. package/docs/types/algebra_monom.literalType.html +61 -0
  54. package/docs/types/algebra_polynom.PolynomParsingType.html +56 -0
  55. package/docs/types/coefficients_fraction.FractionParsingType.html +56 -0
  56. package/docs/types/shutingyard.Token.html +63 -0
  57. package/docs/types/shutingyard.tokenType.html +68 -0
  58. package/docs/variables/shutingyard.tokenConstant.html +61 -0
  59. package/esm/index.js +1 -1
  60. package/esm/index.js.map +1 -1
  61. package/esm/maths/algebra/monom.d.ts +19 -19
  62. package/esm/maths/algebra/monom.js +66 -66
  63. package/esm/maths/algebra/monom.js.map +1 -1
  64. package/esm/maths/algebra/polynom.d.ts +14 -14
  65. package/esm/maths/algebra/polynom.js +72 -50
  66. package/esm/maths/algebra/polynom.js.map +1 -1
  67. package/esm/maths/numeric.js +3 -48
  68. package/esm/maths/numeric.js.map +1 -1
  69. package/package.json +1 -1
  70. package/src/index.ts +1 -1
  71. package/src/maths/algebra/monom.ts +138 -130
  72. package/src/maths/algebra/polynom.ts +107 -85
  73. package/src/maths/numeric.ts +61 -90
  74. package/tests/algebra/linear.test.ts +1 -1
  75. package/tests/algebra/polynom.test.ts +152 -1
  76. package/tests/algebra/study.test.ts +1 -0
  77. package/tests/geometry/circle.test.ts +114 -130
  78. package/tests/geometry/line.test.ts +8 -17
@@ -7,8 +7,6 @@ import {Shutingyard, ShutingyardType, Token} from '../shutingyard';
7
7
  import {Numeric} from '../numeric';
8
8
  import {Fraction} from "../coefficients/fraction";
9
9
  import {Equation, ISolution} from "./equation";
10
- import {Random} from "../randomization/random";
11
- import {loadHighlighter} from "typedoc/dist/lib/utils/highlighter";
12
10
 
13
11
  export type PolynomParsingType = string | Polynom | number | Fraction | Monom
14
12
 
@@ -24,14 +22,7 @@ export interface IEuclidian {
24
22
  * ```
25
23
  */
26
24
  export class Polynom {
27
- private _dirty_factors: boolean
28
- private _dirty_zeroes: boolean
29
- private _euclidianCache: { [Key: string]: IEuclidian }
30
- private _factors: Polynom[];
31
- private _monoms: Monom[];
32
25
  private _rawString: string;
33
- private _texString: string;
34
- private _zeroes: ISolution[]
35
26
 
36
27
  /**
37
28
  *
@@ -49,14 +40,19 @@ export class Polynom {
49
40
  return this;
50
41
  }
51
42
 
52
- get euclidianCache(): { [p: string]: IEuclidian } {
53
- return this._euclidianCache;
43
+ private _dirty_factors: boolean
44
+
45
+ // ------------------------------------------
46
+ get dirty_factors(): boolean {
47
+ return this._dirty_factors;
54
48
  }
55
49
 
56
- set euclidianCache(value: { [p: string]: IEuclidian }) {
57
- this._euclidianCache = value;
50
+ set dirty_factors(value: boolean) {
51
+ this._dirty_factors = value;
58
52
  }
59
53
 
54
+ private _dirty_zeroes: boolean
55
+
60
56
  get dirty_zeroes(): boolean {
61
57
  return this._dirty_zeroes;
62
58
  }
@@ -65,27 +61,17 @@ export class Polynom {
65
61
  this._dirty_zeroes = value;
66
62
  }
67
63
 
68
- // ------------------------------------------
69
- get dirty_factors(): boolean {
70
- return this._dirty_factors;
71
- }
72
-
73
- set dirty_factors(value: boolean) {
74
- this._dirty_factors = value;
75
- }
64
+ private _euclidianCache: { [Key: string]: IEuclidian }
76
65
 
77
- // ------------------------------------------
78
- get monoms() {
79
- return this._monoms;
66
+ get euclidianCache(): { [p: string]: IEuclidian } {
67
+ return this._euclidianCache;
80
68
  }
81
69
 
82
- set monoms(M: Monom[]) {
83
- this._monoms = M;
70
+ set euclidianCache(value: { [p: string]: IEuclidian }) {
71
+ this._euclidianCache = value;
84
72
  }
85
73
 
86
- get zeroes(): ISolution[] {
87
- return this.getZeroes()
88
- }
74
+ private _factors: Polynom[];
89
75
 
90
76
  get factors(): Polynom[] {
91
77
  return this.factorize()
@@ -96,10 +82,29 @@ export class Polynom {
96
82
  this._factors = value;
97
83
  }
98
84
 
85
+ private _monoms: Monom[];
86
+
87
+ // ------------------------------------------
88
+ get monoms() {
89
+ return this._monoms;
90
+ }
91
+
92
+ set monoms(M: Monom[]) {
93
+ this._monoms = M;
94
+ }
95
+
96
+ private _texString: string;
97
+
99
98
  get texString(): string {
100
99
  return this._texString;
101
100
  }
102
101
 
102
+ private _zeroes: ISolution[]
103
+
104
+ get zeroes(): ISolution[] {
105
+ return this.getZeroes()
106
+ }
107
+
103
108
  get texFactors(): string {
104
109
  this.factorize()
105
110
 
@@ -439,7 +444,7 @@ export class Polynom {
439
444
  this.mark_as_dirty()
440
445
 
441
446
  if (value instanceof Polynom) {
442
- return this.multiplyByPolynom(value);
447
+ return this.multiplyByPolynom(value)
443
448
  } else if (value instanceof Fraction) {
444
449
  return this.multiplyByFraction(value);
445
450
  } else if (value instanceof Monom) {
@@ -471,33 +476,33 @@ export class Polynom {
471
476
  if (P.variables.length === 0) {
472
477
  let q = this.clone().divide(P)
473
478
  return {
474
- quotient: this.clone().divide(P),
479
+ quotient: this.clone().divide(P).reduce(),
475
480
  reminder: new Polynom().zero()
476
481
  }
477
482
  }
478
483
 
479
484
  // Get at least a letter
480
-
481
485
  const maxMP: Monom = P.monomByDegree(undefined, letter);
482
486
  const degreeP: Fraction = P.degree(letter);
483
487
 
484
488
  let newM: Monom;
485
489
 
486
490
  // Make the euclidian division of the two polynoms.
487
- let MaxIteration = this.degree(letter).clone().multiply(2);
488
- while (reminder.degree(letter).geq(degreeP) && MaxIteration.isPositive()) {
489
- MaxIteration.subtract(1)
491
+ let MaxIteration = this.degree(letter).value * 2;
492
+ while (reminder.degree(letter).geq(degreeP) && MaxIteration > 0) {
493
+ MaxIteration--
490
494
 
491
495
  // Get the greatest monom divided by the max monom of the divider
492
496
  newM = reminder.monomByDegree(undefined, letter).clone().divide(maxMP);
493
497
 
494
- if (newM.isZero()) {
495
- break;
496
- }
498
+ if (newM.isZero()) break;
497
499
 
498
500
  // Get the new quotient and reminder.
499
501
  quotient.add(newM);
500
502
  reminder.subtract(P.clone().multiply(newM));
503
+
504
+ // Check if the reminder is zero.
505
+ if (newM.degree(letter).isZero()) break
501
506
  }
502
507
 
503
508
  quotient.reduce()
@@ -517,11 +522,11 @@ export class Polynom {
517
522
  } else if (value instanceof Polynom) {
518
523
  if (value.monoms.length === 1 && value.variables.length === 0) {
519
524
  return this.divideByFraction(value.monoms[0].coefficient)
520
- }else {
525
+ } else {
521
526
  let {quotient, reminder} = this.euclidian(value)
522
- if(reminder.isZero()){
527
+ if (reminder.isZero()) {
523
528
  return quotient
524
- }else{
529
+ } else {
525
530
  console.log(`${this.tex} is not divideable by ${value.tex}`)
526
531
  return new Polynom().zero()
527
532
  }
@@ -663,19 +668,21 @@ export class Polynom {
663
668
  let polyFactors = factors.map(x => new Polynom(x));
664
669
 
665
670
  // polyFactors contain all polynoms.
666
- let checkPolyFactors = polyFactors.filter(x=>x.degree().geq(1) && !x.commonMonom().isOne())
671
+ let checkPolyFactors = polyFactors.filter(x => x.degree().geq(1) && !x.commonMonom().isOne())
667
672
 
668
673
  // Some polynoms are not completely factorized.
669
- if(checkPolyFactors.length>0 && !soft){return false}
670
- if(checkPolyFactors.length>0 && soft){
671
- polyFactors = polyFactors.filter(x=>x.commonMonom().isOne())
674
+ if (checkPolyFactors.length > 0 && !soft) {
675
+ return false
676
+ }
677
+ if (checkPolyFactors.length > 0 && soft) {
678
+ polyFactors = polyFactors.filter(x => x.commonMonom().isOne())
672
679
 
673
680
  let FactorizedConstant = new Fraction().one()
674
- for(let p of checkPolyFactors){
681
+ for (let p of checkPolyFactors) {
675
682
  let k = p.commonMonom(),
676
683
  pFactor = p.clone().divide(k)
677
684
 
678
- if(k.degree().isZero()){
685
+ if (k.degree().isZero()) {
679
686
  FactorizedConstant.multiply(k.coefficient)
680
687
  polyFactors.push(pFactor.clone())
681
688
  }
@@ -786,39 +793,57 @@ export class Polynom {
786
793
  // -------------------------------------
787
794
  reduce = (): Polynom => {
788
795
  // Reduce the polynom
789
- let values = [...this._monoms],
796
+ let values = this._monoms.map(x => x.clone()),
790
797
  vars = [...this.variables]
791
798
 
792
- this._monoms = []
793
-
794
- let coeffs = values.filter(x => x.variables.length === 0)
795
-
796
- if (coeffs.length > 0) {
797
- this._monoms.push(coeffs.reduce((a, b) => a.add(b)))
798
- }
799
-
800
- // Build the new monoms
801
- for (let letter of vars) {
802
- // Monom with same letters, but might be of different degrees
803
- let M = values.filter(x => x.hasLetter(letter))
804
-
805
- while (M.length > 0) {
806
- // Take the first element
807
- const m = M.shift(), degree = m.degree(letter)
808
-
809
- for (let a of M.filter(x => x.degree(letter).isEqual(degree))) {
810
- m.add(a)
799
+ // Group the monoms by similarity
800
+ let i = 0
801
+ while (i < this._monoms.length) {
802
+ for (let j = i + 1; j < this._monoms.length; j++) {
803
+ if (this._monoms[i].isSameAs(this._monoms[j])) {
804
+ this._monoms[i].add(this._monoms[j])
805
+ this._monoms.splice(j, 1)
806
+ if (this._monoms[i].isZero()) {
807
+ this._monoms[i] = new Monom().zero()
808
+ }
809
+ j--
811
810
  }
812
-
813
- this._monoms.push(m)
814
-
815
- // Make the new array.
816
- M = M.filter(x => x.degree(letter).isNotEqual(degree))
817
811
  }
818
- // reduce the monom
819
-
812
+ i++
820
813
  }
821
814
 
815
+ //
816
+ //
817
+ //
818
+ // let coeffs = values.filter(x => x.variables.length === 0)
819
+ //
820
+ // if (coeffs.length > 0) {
821
+ // this._monoms.push(coeffs.reduce((a, b) => a.add(b)))
822
+ // }
823
+ //
824
+ // // Build the new monoms
825
+ // for (let letter of vars) {
826
+ // // Monom with same letters, but might be of different degrees
827
+ // let M = values.filter(x => x.hasLetter(letter))
828
+ //
829
+ // while (M.length > 0) {
830
+ // // Take the first element
831
+ // const m = M.shift(), degree = m.degree(letter)
832
+ //
833
+ // for (let a of M.filter(x => x.degree(letter).isEqual(degree))) {
834
+ // m.add(a)
835
+ // }
836
+ //
837
+ // this._monoms.push(m)
838
+ //
839
+ // // Make the new array.
840
+ // M = M.filter(x => x.degree(letter).isNotEqual(degree))
841
+ // }
842
+ // // reduce the monom
843
+ //
844
+ // }
845
+
846
+
822
847
  // Remove all null monoms
823
848
  this._monoms = this._monoms.filter((m) => {
824
849
  return m.coefficient.value !== 0
@@ -832,11 +857,14 @@ export class Polynom {
832
857
  if (this.length === 0) {
833
858
  return new Polynom().zero();
834
859
  }
860
+
835
861
  return this.reorder();
836
862
  };
837
863
 
838
864
  reorder = (letter: string = 'x', revert?: boolean): Polynom => {
839
- if(revert===undefined){revert = false}
865
+ if (revert === undefined) {
866
+ revert = false
867
+ }
840
868
 
841
869
  // TODO: Must handle multiple setLetter reorder system
842
870
  let otherLetters = this.variables.filter(x => x !== letter)
@@ -845,7 +873,7 @@ export class Polynom {
845
873
  db = b.degree(letter).value
846
874
 
847
875
  // Values are different
848
- if (da !== db) return revert?da-db : db - da
876
+ if (da !== db) return revert ? da - db : db - da
849
877
 
850
878
  // if values are equals, check other letters - it must be revert in that case !
851
879
  if (otherLetters.length > 0) {
@@ -854,7 +882,7 @@ export class Polynom {
854
882
  db = b.degree(L).value
855
883
 
856
884
  // Values are different
857
- if (da !== db) return revert?da - db : db - da
885
+ if (da !== db) return revert ? da - db : db - da
858
886
  }
859
887
  }
860
888
 
@@ -1045,16 +1073,10 @@ export class Polynom {
1045
1073
  dC = x.monoms[x.monoms.length - 1]
1046
1074
 
1047
1075
  // Check last item (degree zero)
1048
- if (!pC.isDivisible(dC)) {
1049
- return false
1050
- }
1076
+ if (!pC.isDivisible(dC)) return false
1051
1077
 
1052
1078
  // Check the first item (degree max)
1053
- if (!pX.isDivisible(dX)) {
1054
- return false
1055
- }
1056
-
1057
- return true
1079
+ return pX.isDivisible(dX);
1058
1080
  })
1059
1081
  }
1060
1082
  }
@@ -1,18 +1,18 @@
1
- export class Numeric{
2
- static round(value:number, decimals:number=2):number {
3
- return Number(Math.round(Number(value+'e'+decimals))+'e-'+decimals);
1
+ export class Numeric {
2
+ static round(value: number, decimals: number = 2): number {
3
+ return Number(Math.round(Number(value + 'e' + decimals)) + 'e-' + decimals);
4
4
  }
5
5
 
6
6
  /**
7
7
  * Get the list of the nth first prime numbers.
8
8
  * @param nb : number of primes to choose from
9
9
  */
10
- static primes(nb?:number):number[]{
11
- let primesValues:number[] = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973];
12
- if(nb === undefined){
10
+ static primes(nb?: number): number[] {
11
+ let primesValues: number[] = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973];
12
+ if (nb === undefined) {
13
13
  return primesValues;
14
- }else{
15
- return primesValues.slice(0,Math.min(primesValues.length,nb));
14
+ } else {
15
+ return primesValues.slice(0, Math.min(primesValues.length, nb));
16
16
  }
17
17
  }
18
18
 
@@ -20,88 +20,102 @@ export class Numeric{
20
20
  * Get the list of all dividers of a number.
21
21
  * @param value
22
22
  */
23
- static dividers(value:number):number[]{
23
+ static dividers(value: number): number[] {
24
24
  let D: number[];
25
25
  const maxV = Math.sqrt(Math.abs(value));
26
26
 
27
27
  // Initialize the list of dividers.
28
28
  D = [];
29
29
 
30
- for(let i=1; i<=maxV; i++){
31
- if(value%i===0){
30
+ for (let i = 1; i <= maxV; i++) {
31
+ if (value % i === 0) {
32
32
  D.push(i);
33
- D.push(value/i);
33
+ D.push(value / i);
34
34
  }
35
35
  }
36
36
 
37
37
  // Order numbers.
38
- D.sort(function(a, b){return a-b;});
38
+ D.sort(function (a, b) {
39
+ return a - b;
40
+ });
39
41
 
40
42
  // Make sure the array of value is unique.
41
43
  return [...new Set(D)];
42
44
  }
45
+
43
46
  /**
44
47
  * Great Common Divisor
45
48
  * @param values : number values
46
49
  */
47
- static gcd(...values:number[]):number{
50
+ static gcd(...values: number[]): number {
48
51
  // Define the gcd for two number
49
- let gcd2 = function(a:number,b:number):number{
50
- if(b===0){return a;}
51
- return gcd2(b, a%b);
52
+ let gcd2 = function (a: number, b: number): number {
53
+ if (b === 0) {
54
+ return a;
55
+ }
56
+ return gcd2(b, a % b);
52
57
  };
53
58
 
54
- let g:number = 1,
55
- i:number = 2;
59
+ let g: number = 1,
60
+ i: number = 2;
56
61
 
57
62
  // Nothing is given
58
- if(values.length===0){return 1;}
63
+ if (values.length === 0) {
64
+ return 1;
65
+ }
59
66
  // Only one number is given
60
- if(values.length===1){
67
+ if (values.length === 1) {
61
68
  // The first number is zero
62
- if(values[0]===0){return 1;}
69
+ if (values[0] === 0) {
70
+ return 1;
71
+ }
63
72
  // Return the number
64
73
  return values[0];
65
74
  }
66
75
 
67
76
  // We have at least 2 numbers.
68
- g = gcd2(values[0],values[1]);
77
+ g = gcd2(values[0], values[1]);
69
78
 
70
79
  // The gcd of the two first value is one ? It's already finished.
71
- if(g===1){return 1;}
80
+ if (g === 1) {
81
+ return 1;
82
+ }
72
83
 
73
84
  // The current gcd isn't one. Continue with all next values.
74
- for(i=2; i<values.length; i++){
85
+ for (i = 2; i < values.length; i++) {
75
86
  g = gcd2(g, values[i]);
76
87
  // Escape if gcd is already one.
77
- if(g===1){break;}
88
+ if (g === 1) {
89
+ break;
90
+ }
78
91
  }
79
92
 
80
93
  return Math.abs(g);
81
94
  }
82
95
 
83
- static divideNumbersByGCD(...values: number[]): number[]{
96
+ static divideNumbersByGCD(...values: number[]): number[] {
84
97
  let gcd = Numeric.gcd(...values)
85
98
 
86
- return values.map(x=>x/gcd)
99
+ return values.map(x => x / gcd)
87
100
  }
101
+
88
102
  /**
89
103
  * Least Common Multiple
90
104
  * @param values: list of numbers
91
105
  */
92
- static lcm(...values:number[]):number{
93
- return values.reduce(function(a,b){
106
+ static lcm(...values: number[]): number {
107
+ return values.reduce(function (a, b) {
94
108
  return Math.abs(a * b / Numeric.gcd(a, b));
95
109
  });
96
110
  }
97
111
 
98
- static pythagoricianTripletsWithTarget(target: number, targetIsSquare?:boolean): number[][] {
112
+ static pythagoricianTripletsWithTarget(target: number, targetIsSquare?: boolean): number[][] {
99
113
  // méthode inverse, à partir du triplet.
100
114
  const triplets = [],
101
- targetValue = targetIsSquare===true?+target:target**2
102
- for(let u = 0; u <= target; u++){
103
- for(let v = 0; v <=target; v++){
104
- if(u**2+v**2===targetValue){
115
+ targetValue = targetIsSquare === true ? +target : target ** 2
116
+ for (let u = 0; u <= target; u++) {
117
+ for (let v = 0; v <= target; v++) {
118
+ if (u ** 2 + v ** 2 === targetValue) {
105
119
  triplets.push([u, v, target])
106
120
  }
107
121
  }
@@ -110,80 +124,37 @@ export class Numeric{
110
124
  return triplets
111
125
  }
112
126
 
113
- static numberCorrection(value: number, epsilonDigit:number = 1, epsilonNumberOfDigits: number = 10, number_of_digits: number = 8){
127
+ static numberCorrection(value: number, epsilonDigit: number = 1, epsilonNumberOfDigits: number = 10, number_of_digits: number = 8) {
114
128
  return +value.toFixed(number_of_digits)
115
- //
116
- // // Must modify the number if it's like:
117
- // // a: 3.0000000000000003
118
- // // b: 3.9999999999999994
119
- // // remove the last character
120
- // // check if around n last characters are either 0 or 9
121
- // // if it is, 'round' the number.
122
- // function extractDecimalPart(valueToExtract: number, decimalLength: number){
123
- // let decimal = valueToExtract.toString()
124
- //
125
- // if (!decimal.includes('.')) {
126
- // return ''
127
- // }
128
- //
129
- // decimal = decimal.split('.')[1]
130
- // return decimal.substring(0, decimalLength)
131
- // }
132
- //
133
- // const epsilon = Number(`0.${"0".repeat(epsilonNumberOfDigits-1)}${epsilonDigit}`)
134
- // const decimal = extractDecimalPart(value, epsilonNumberOfDigits)
135
- // if(decimal===''){return value}
136
- //
137
- // const n9 = decimal.match(/9+$/g)
138
- // const n0 = decimal.match(/0+$/g)
139
- //
140
- // if (n9 && n9[0].length >= number_of_digits) {
141
- // // New tested values.
142
- // const mod = extractDecimalPart(value + epsilon, epsilonNumberOfDigits),
143
- // mod0 = mod.match(/0+$/g)
144
- //
145
- // if(mod0 && mod0[0].length>= number_of_digits){
146
- // return +((value+epsilon).toString().split(mod0[0])[0])
147
- // }
148
- // }
149
- //
150
- // if (n0 && n0[0].length >= number_of_digits) {
151
- // // New tested values.
152
- // const mod = extractDecimalPart(value - epsilon, epsilonNumberOfDigits),
153
- // mod9 = mod.match(/9+$/g)
154
- //
155
- // if(mod9 && mod9[0].length>= number_of_digits){
156
- // // The value can be changed. Remove all nines!
157
- // return +(value.toString().split(n0[0])[0])
158
- // }
159
- // }
160
- //
161
- // return value
162
129
  }
163
130
 
164
- static periodic(value: number):number{
165
- if(Number.isSafeInteger(value)){return 0}
131
+ static periodic(value: number): number {
132
+ if (Number.isSafeInteger(value)) {
133
+ return 0
134
+ }
166
135
 
167
136
  // Assume it's with decimal.
168
137
  let decimal = (value.toString()).split('.')[0]
169
138
 
170
139
  // The decimal part is limited
171
- if(decimal.length<10){return 0}
140
+ if (decimal.length < 10) {
141
+ return 0
142
+ }
172
143
 
173
144
  // Find the periodic if it exists.
174
145
  }
175
146
 
176
- static decompose(value: number): number[][]{
147
+ static decompose(value: number): number[][] {
177
148
  let dividers = Numeric.dividers(value),
178
149
  limit = Math.sqrt(value),
179
150
  arr = [],
180
151
  u, v
181
152
 
182
- while(dividers.length>0){
153
+ while (dividers.length > 0) {
183
154
  u = dividers.shift()
184
- v = dividers.length>0?dividers.pop():+u
155
+ v = dividers.length > 0 ? dividers.pop() : +u
185
156
 
186
- arr.push([u,v])
157
+ arr.push([u, v])
187
158
  }
188
159
 
189
160
  return arr
@@ -40,7 +40,7 @@ describe('Linear systems tests', () => {
40
40
  E2 = new Polynom('-6x+21y-3z')
41
41
 
42
42
  E1.add(E2);
43
- expect(E1.display).to.be.equal('42y-6z')
43
+ expect(E1.reduce().display).to.be.equal('42y-6z')
44
44
  });
45
45
 
46
46
  it('should use a reduced linear reducation', function () {