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.
- package/.eslintrc.js +23 -23
- package/dist/pi.js +40 -11
- package/dist/pi.js.map +1 -1
- package/dist/pi.min.js +1 -1
- package/dist/pi.min.js.map +1 -1
- package/docs/assets/highlight.css +78 -78
- package/docs/assets/main.js +52 -52
- package/docs/assets/style.css +1413 -1413
- package/docs/classes/Logicalset.Logicalset-1.html +4 -4
- package/docs/classes/Polynom.Rational.html +3 -3
- package/docs/classes/algebra_equation.Equation.html +25 -25
- package/docs/classes/algebra_monom.Monom.html +113 -113
- package/docs/classes/algebra_polynom.Polynom.html +29 -29
- package/docs/classes/coefficients_fraction.Fraction.html +18 -18
- package/docs/classes/coefficients_nthroot.NthRoot.html +2 -2
- package/docs/classes/geometry_circle.Circle.html +2 -2
- package/docs/classes/geometry_line.Line.html +2 -2
- package/docs/classes/geometry_triangle.Triangle.html +16 -16
- package/docs/classes/numeric.Numeric.html +13 -13
- package/docs/classes/shutingyard.Shutingyard.html +17 -17
- package/docs/index.html +10 -10
- package/docs/interfaces/algebra_equation.ISolution.html +2 -2
- package/docs/modules/Logicalset.html +2 -2
- package/docs/modules/Polynom.html +2 -2
- package/docs/modules/Vector.html +2 -2
- package/esm/maths/algebra/equation.js +4 -4
- package/esm/maths/algebra/equation.js.map +1 -10
- package/esm/maths/algebra/linearSystem.js.map +1 -10
- package/esm/maths/algebra/monom.d.ts +2 -6
- package/esm/maths/algebra/monom.js +11 -6
- package/esm/maths/algebra/monom.js.map +1 -10
- package/esm/maths/algebra/polynom.d.ts +4 -7
- package/esm/maths/algebra/polynom.js +34 -16
- package/esm/maths/algebra/polynom.js.map +1 -10
- package/esm/maths/algebra/rational.d.ts +1 -1
- package/esm/maths/algebra/rational.js +25 -4
- package/esm/maths/algebra/rational.js.map +1 -10
- package/esm/maths/expressions/polynomexp.bkp.js +1 -1
- package/esm/maths/expressions/polynomexp.bkp.js.map +1 -10
- package/esm/maths/expressions/polynomexp.js +2 -2
- package/esm/maths/expressions/polynomexp.js.map +1 -10
- package/esm/maths/geometry/point.js.map +1 -10
- package/esm/maths/randomization/random.js +1 -5
- package/esm/maths/randomization/random.js.map +1 -10
- package/package.json +1 -1
- package/public/index.html +1 -1
- package/public/matrices.html +100 -0
- package/src/maths/algebra/monom.ts +1 -2
- package/src/maths/algebra/polynom.ts +14 -8
- package/src/maths/algebra/rational.ts +26 -7
- package/tests/algebra/polynom.test.ts +13 -1
- 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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
24
|
-
|
|
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
|
-
|
|
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', () => {
|