pimath 0.0.54 → 0.0.57

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 (52) hide show
  1. package/.eslintrc.js +23 -23
  2. package/dist/pi.js +40 -11
  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/main.js +52 -52
  8. package/docs/assets/style.css +1413 -1413
  9. package/docs/classes/Logicalset.Logicalset-1.html +4 -4
  10. package/docs/classes/Polynom.Rational.html +3 -3
  11. package/docs/classes/algebra_equation.Equation.html +25 -25
  12. package/docs/classes/algebra_monom.Monom.html +113 -113
  13. package/docs/classes/algebra_polynom.Polynom.html +29 -29
  14. package/docs/classes/coefficients_fraction.Fraction.html +18 -18
  15. package/docs/classes/coefficients_nthroot.NthRoot.html +2 -2
  16. package/docs/classes/geometry_circle.Circle.html +2 -2
  17. package/docs/classes/geometry_line.Line.html +2 -2
  18. package/docs/classes/geometry_triangle.Triangle.html +16 -16
  19. package/docs/classes/numeric.Numeric.html +13 -13
  20. package/docs/classes/shutingyard.Shutingyard.html +17 -17
  21. package/docs/index.html +10 -10
  22. package/docs/interfaces/algebra_equation.ISolution.html +2 -2
  23. package/docs/modules/Logicalset.html +2 -2
  24. package/docs/modules/Polynom.html +2 -2
  25. package/docs/modules/Vector.html +2 -2
  26. package/esm/maths/algebra/equation.js +4 -4
  27. package/esm/maths/algebra/equation.js.map +1 -10
  28. package/esm/maths/algebra/linearSystem.js.map +1 -10
  29. package/esm/maths/algebra/monom.d.ts +2 -6
  30. package/esm/maths/algebra/monom.js +11 -6
  31. package/esm/maths/algebra/monom.js.map +1 -10
  32. package/esm/maths/algebra/polynom.d.ts +4 -7
  33. package/esm/maths/algebra/polynom.js +34 -16
  34. package/esm/maths/algebra/polynom.js.map +1 -10
  35. package/esm/maths/algebra/rational.d.ts +1 -1
  36. package/esm/maths/algebra/rational.js +25 -4
  37. package/esm/maths/algebra/rational.js.map +1 -10
  38. package/esm/maths/expressions/polynomexp.bkp.js +1 -1
  39. package/esm/maths/expressions/polynomexp.bkp.js.map +1 -10
  40. package/esm/maths/expressions/polynomexp.js +2 -2
  41. package/esm/maths/expressions/polynomexp.js.map +1 -10
  42. package/esm/maths/geometry/point.js.map +1 -10
  43. package/esm/maths/randomization/random.js +1 -5
  44. package/esm/maths/randomization/random.js.map +1 -10
  45. package/package.json +1 -1
  46. package/public/index.html +1 -1
  47. package/public/matrices.html +100 -0
  48. package/src/maths/algebra/monom.ts +1 -2
  49. package/src/maths/algebra/polynom.ts +14 -8
  50. package/src/maths/algebra/rational.ts +26 -7
  51. package/tests/algebra/polynom.test.ts +13 -1
  52. package/tests/algebra/rationnal.test.ts +6 -0
@@ -182,7 +182,6 @@ export class Polynom {
182
182
  if (element.token === '-') {
183
183
  stack.push(stack.pop().opposed())
184
184
  } else {
185
- console.error('While parsing, cannot apply ', element.token, 'to', stack[0].tex)
186
185
  throw "Error parsing the polynom " + this._rawString
187
186
  }
188
187
  }
@@ -405,9 +404,14 @@ export class Polynom {
405
404
  const quotient: Polynom = new Polynom().zero();
406
405
  const reminder: Polynom = this.clone().reorder(letter);
407
406
 
408
- // There is no variable !
407
+ // There is no variable - means it's a number
409
408
  if (P.variables.length === 0) {
410
- return {quotient, reminder}
409
+ let q = this.clone().divide(P)
410
+ return {
411
+ quotient: this.clone().divide(P),
412
+ reminder: new Polynom().zero()
413
+ }
414
+
411
415
  }
412
416
 
413
417
  // Get at least a letter
@@ -444,8 +448,11 @@ export class Polynom {
444
448
  return this.divideByFraction(value);
445
449
  } else if (typeof value === 'number' && Number.isSafeInteger(value)) {
446
450
  return this.divideByInteger(value);
451
+ } else if (value instanceof Polynom) {
452
+ if (value.monoms.length === 1 && value.variables.length === 0) {
453
+ return this.divideByFraction(value.monoms[0].coefficient)
454
+ }
447
455
  }
448
-
449
456
  }
450
457
 
451
458
  pow = (nb: number): Polynom => {
@@ -778,8 +785,7 @@ export class Polynom {
778
785
 
779
786
  // It has a common monom.
780
787
  if (!M.isOne()) {
781
- tempPolynom = new Polynom()
782
- tempPolynom.monoms = [M]
788
+ tempPolynom = new Polynom(M)
783
789
  factors = [tempPolynom.clone()]
784
790
  P = P.euclidian(tempPolynom).quotient;
785
791
  }
@@ -803,8 +809,8 @@ export class Polynom {
803
809
  break
804
810
  } else {
805
811
  // Get the first and last monom and build all their dividers.
806
- let m1 = P.monoms[0].dividers,
807
- m2 = P.monoms[P.monoms.length - 1].dividers
812
+ // let m1 = P.monoms[0].dividers,
813
+ // m2 = P.monoms[P.monoms.length - 1].dividers
808
814
 
809
815
  // Create the list of all "potential" polynom dividers.
810
816
  let allDividers:Polynom[] = this._getAllPotentialFactors(P,letter)
@@ -19,9 +19,23 @@ export class Rational {
19
19
  * @param numerator
20
20
  * @param denominator
21
21
  */
22
- constructor(numerator?: Polynom, denominator?: Polynom) {
23
- this._numerator = numerator ? numerator.clone() : new Polynom();
24
- this._denominator = denominator ? denominator.clone() : new Polynom();
22
+ constructor(numerator?: Polynom | string, denominator?: Polynom | string) {
23
+ if (numerator instanceof Polynom) {
24
+ this._numerator = numerator.clone()
25
+ } else if (typeof numerator === 'string') {
26
+ this._numerator = new Polynom(numerator)
27
+ } else {
28
+ this._numerator = new Polynom()
29
+ }
30
+
31
+ if (denominator instanceof Polynom) {
32
+ this._denominator = denominator.clone()
33
+ } else if (typeof denominator === 'string') {
34
+ this._denominator = new Polynom(denominator)
35
+ } else {
36
+ this._denominator = new Polynom()
37
+ }
38
+
25
39
  }
26
40
 
27
41
  private _numerator: Polynom;
@@ -183,7 +197,7 @@ export class Rational {
183
197
  this._numerator.factorize()
184
198
  this._denominator.factorize()
185
199
 
186
- let zeroes = Equation.makeSolutionsUnique([...this._numerator.getZeroes(), ...this._denominator.getZeroes()], true),
200
+ let zeroes = Equation.makeSolutionsUnique([...this._numerator.getZeroes(), ...this._denominator.getZeroes()], true).filter(x => !isNaN(x.value)),
187
201
  NFactors = this._numerator.factors,
188
202
  DFactors = this._denominator.factors
189
203
 
@@ -265,12 +279,16 @@ export class Rational {
265
279
  }
266
280
  private _makeOneLineOfTableOfSigns = (factor: Polynom, zeroes: ISolution[], zeroSign: string): string[] => {
267
281
  let oneLine: string[] = [],
268
- currentZero = factor.getZeroes().map(x=>x.tex)
269
-
282
+ currentZero = factor.getZeroes().map(x => x.tex)
270
283
 
271
284
  // First +/- sign, before the first zero
272
285
  oneLine.push('')
273
- oneLine.push(factor.evaluate(zeroes[0].value - 1).sign() === 1 ? '+' : '-')
286
+ if (factor.degree().isZero()) {
287
+ oneLine.push(factor.monoms[0].coefficient.sign() === 1 ? '+' : '-')
288
+ } else {
289
+ oneLine.push(factor.evaluate(zeroes[0].value - 1).sign() === 1 ? '+' : '-')
290
+ }
291
+
274
292
 
275
293
  for (let i = 0; i < zeroes.length; i++) {
276
294
  // Add the zero if it's the current one
@@ -285,6 +303,7 @@ export class Rational {
285
303
 
286
304
  }
287
305
 
306
+
288
307
  oneLine.push('')
289
308
 
290
309
  return oneLine
@@ -76,7 +76,19 @@ describe('Polynom tests', () => {
76
76
  let P2 = new Polynom('x^4-32x^2+256')
77
77
  P2.factorize()
78
78
  expect(P2.factors.map(x => x.tex)).to.have.all.members(['x-4', 'x-4', 'x+4', 'x+4'])
79
- })
79
+
80
+ let P3 = new Polynom('6x^2-48x-8')
81
+ P3.factorize()
82
+ expect(P3.factors.map(x => x.tex)).to.have.all.members(['2', '3x^{2}-24x-4'])
83
+ });
84
+
85
+ it('should factorize special polynom', function () {
86
+ let P = new Polynom('x^6-16x^5-58x^4+1592x^3-1207x^2-37576x+94864')
87
+
88
+ P.factorize()
89
+
90
+ console.log(P.factors.map(x=>x.tex))
91
+ });
80
92
  })
81
93
 
82
94
  describe('Polynom parsing with rational power', () => {
@@ -93,4 +93,10 @@ describe('Rational tests', () => {
93
93
 
94
94
  FR.derivative()
95
95
  });
96
+
97
+ it('should test', function () {
98
+ let P = new Rational('245', '3x-5')
99
+ console.log(P.tex)
100
+ console.log(P.makeTableOfSigns())
101
+ });
96
102
  })