pimath 0.0.32 → 0.0.35
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/dist/pi.js +6537 -1
- package/dist/pi.js.map +1 -1
- package/dist/pi.min.js +2 -0
- package/dist/pi.min.js.map +1 -0
- package/docs/assets/search.js +1 -1
- package/docs/classes/algebra.Equation.html +9 -9
- package/docs/classes/algebra.LinearSystem.html +1 -1
- package/docs/classes/algebra.Logicalset.html +2 -2
- package/docs/classes/algebra.Monom.html +37 -37
- package/docs/classes/algebra.Polynom.html +10 -10
- package/docs/classes/algebra.PolynomExpFactor.html +1 -1
- package/docs/classes/algebra.PolynomExpProduct.html +1 -1
- package/docs/classes/algebra.Rational.html +2 -2
- package/docs/classes/coefficients.Fraction.html +4 -4
- package/docs/classes/coefficients.Nthroot.html +1 -1
- package/docs/classes/geometry.Circle.html +2 -2
- package/docs/classes/geometry.Line.html +2 -2
- package/docs/classes/geometry.Point.html +1 -1
- package/docs/classes/geometry.Triangle.html +5 -5
- package/docs/classes/geometry.Vector.html +1 -1
- package/docs/classes/numeric.Numeric.html +5 -5
- package/docs/classes/shutingyard.Shutingyard.html +4 -4
- package/docs/enums/geometry.LinePropriety.html +1 -0
- package/docs/enums/shutingyard.ShutingyardMode.html +1 -1
- package/docs/enums/shutingyard.ShutingyardType.html +1 -1
- package/docs/interfaces/geometry.remarquableLines.html +1 -1
- package/docs/modules/algebra.html +1 -1
- package/docs/modules/coefficients.html +1 -1
- package/docs/modules/geometry.html +1 -1
- package/docs/modules/random.Random.html +1 -1
- package/docs/modules/random.html +1 -1
- package/docs/modules/shutingyard.html +1 -1
- package/esm/main.d.ts +30 -1
- package/esm/main.js +4 -1
- package/esm/main.js.map +1 -1
- package/esm/maths/algebra/equation.d.ts +62 -17
- package/esm/maths/algebra/equation.js +597 -502
- package/esm/maths/algebra/equation.js.map +1 -1
- package/esm/maths/algebra/index.js +5 -1
- package/esm/maths/algebra/index.js.map +1 -1
- package/esm/maths/algebra/linearSystem.js +154 -101
- package/esm/maths/algebra/linearSystem.js.map +1 -1
- package/esm/maths/algebra/logicalset.d.ts +11 -0
- package/esm/maths/algebra/logicalset.js +18 -6
- package/esm/maths/algebra/logicalset.js.map +1 -1
- package/esm/maths/algebra/monom.d.ts +144 -0
- package/esm/maths/algebra/monom.js +626 -398
- package/esm/maths/algebra/monom.js.map +1 -1
- package/esm/maths/algebra/polynom.d.ts +49 -0
- package/esm/maths/algebra/polynom.js +995 -712
- package/esm/maths/algebra/polynom.js.map +1 -1
- package/esm/maths/algebra/rational.d.ts +12 -0
- package/esm/maths/algebra/rational.js +97 -82
- package/esm/maths/algebra/rational.js.map +1 -1
- package/esm/maths/coefficients/fraction.d.ts +18 -0
- package/esm/maths/coefficients/fraction.js +390 -332
- package/esm/maths/coefficients/fraction.js.map +1 -1
- package/esm/maths/coefficients/index.js +5 -1
- package/esm/maths/coefficients/index.js.map +1 -1
- package/esm/maths/coefficients/nthroot.d.ts +3 -0
- package/esm/maths/coefficients/nthroot.js +48 -33
- package/esm/maths/coefficients/nthroot.js.map +1 -1
- package/esm/maths/expressions/numexp.js +11 -3
- package/esm/maths/expressions/numexp.js.map +1 -1
- package/esm/maths/expressions/polynomexp.bkp.js +93 -93
- package/esm/maths/expressions/polynomexp.bkp.js.map +1 -1
- package/esm/maths/expressions/polynomexp.js +22 -9
- package/esm/maths/expressions/polynomexp.js.map +1 -1
- package/esm/maths/geometry/circle.d.ts +18 -6
- package/esm/maths/geometry/circle.js +139 -42
- package/esm/maths/geometry/circle.js.map +1 -1
- package/esm/maths/geometry/index.js +5 -1
- package/esm/maths/geometry/index.js.map +1 -1
- package/esm/maths/geometry/line.d.ts +9 -2
- package/esm/maths/geometry/line.js +245 -188
- package/esm/maths/geometry/line.js.map +1 -1
- package/esm/maths/geometry/point.d.ts +12 -0
- package/esm/maths/geometry/point.js +121 -73
- package/esm/maths/geometry/point.js.map +1 -1
- package/esm/maths/geometry/triangle.d.ts +23 -1
- package/esm/maths/geometry/triangle.js +197 -158
- package/esm/maths/geometry/triangle.js.map +1 -1
- package/esm/maths/geometry/vector.d.ts +5 -1
- package/esm/maths/geometry/vector.js +139 -115
- package/esm/maths/geometry/vector.js.map +1 -1
- package/esm/maths/numeric.d.ts +17 -0
- package/esm/maths/numeric.js +40 -0
- package/esm/maths/numeric.js.map +1 -1
- package/esm/maths/random/index.js +5 -1
- package/esm/maths/random/index.js.map +1 -1
- package/esm/maths/random/randomCore.js +15 -15
- package/esm/maths/random/randomCore.js.map +1 -1
- package/esm/maths/random/rndFraction.d.ts +3 -0
- package/esm/maths/random/rndFraction.js +19 -16
- package/esm/maths/random/rndFraction.js.map +1 -1
- package/esm/maths/random/rndHelpers.d.ts +17 -0
- package/esm/maths/random/rndHelpers.js +20 -0
- package/esm/maths/random/rndHelpers.js.map +1 -1
- package/esm/maths/random/rndMonom.d.ts +3 -0
- package/esm/maths/random/rndMonom.js +33 -26
- package/esm/maths/random/rndMonom.js.map +1 -1
- package/esm/maths/random/rndPolynom.d.ts +3 -0
- package/esm/maths/random/rndPolynom.js +49 -37
- package/esm/maths/random/rndPolynom.js.map +1 -1
- package/esm/maths/shutingyard.d.ts +21 -0
- package/esm/maths/shutingyard.js +86 -9
- package/esm/maths/shutingyard.js.map +1 -1
- package/package.json +2 -2
- package/public/index.html +47 -0
- package/src/main.ts +2 -2
- package/src/maths/algebra/equation.ts +142 -128
- package/src/maths/algebra/monom.ts +6 -2
- package/src/maths/algebra/polynom.ts +2 -7
- package/src/maths/geometry/circle.ts +168 -75
- package/src/maths/geometry/index.ts +1 -1
- package/src/maths/geometry/line.ts +1 -1
- package/src/maths/geometry/point.ts +25 -2
- package/src/maths/geometry/triangle.ts +1 -1
- package/src/maths/geometry/vector.ts +1 -1
- package/src/maths/numeric.ts +15 -0
- package/tests/algebra/polynom.test.ts +7 -0
- package/tests/geometry/circle.test.ts +33 -0
- package/tsconfig.json +2 -2
- package/webpack-production-min.config.js +26 -0
- package/webpack-production.config.js +1 -1
- package/dev/pi.js +0 -5392
- package/dev/pi.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {Polynom} from "./polynom";
|
|
2
|
-
import {Monom} from "./monom";
|
|
2
|
+
import {literalType, Monom} from "./monom";
|
|
3
3
|
import {Numeric} from "../numeric";
|
|
4
4
|
import {Fraction, Nthroot} from "../coefficients";
|
|
5
5
|
|
|
@@ -13,13 +13,7 @@ interface ISolution {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export class Equation {
|
|
16
|
-
private _left: Polynom; // Left part of the equation
|
|
17
|
-
private _right: Polynom; // Right part of the equation
|
|
18
|
-
private _sign: string; // Signe of the equation, by default =
|
|
19
|
-
|
|
20
16
|
private _polynom: Polynom; // Used to solve the equation // TODO: remove the private value ?
|
|
21
|
-
private _solutions: ISolution[]
|
|
22
|
-
|
|
23
17
|
// Undetermined texSolutions.
|
|
24
18
|
private _varnothing: string = '\\varnothing';
|
|
25
19
|
private _real: string = '\\mathbb{R}';
|
|
@@ -36,21 +30,21 @@ export class Equation {
|
|
|
36
30
|
this._sign = '=';
|
|
37
31
|
|
|
38
32
|
if (equations.length === 1) {
|
|
39
|
-
if(equations[0] instanceof Equation) {
|
|
33
|
+
if (equations[0] instanceof Equation) {
|
|
40
34
|
return equations[0].clone();
|
|
41
|
-
} else if(typeof equations[0] === 'string') {
|
|
35
|
+
} else if (typeof equations[0] === 'string') {
|
|
42
36
|
this.parse(equations[0]);
|
|
43
37
|
}
|
|
44
38
|
} else if (equations.length === 2) {
|
|
45
|
-
if(equations[0] instanceof Polynom){
|
|
39
|
+
if (equations[0] instanceof Polynom) {
|
|
46
40
|
this.left = equations[0].clone()
|
|
47
|
-
}else if(typeof equations[0] === 'string'){
|
|
41
|
+
} else if (typeof equations[0] === 'string') {
|
|
48
42
|
this.left = new Polynom(equations[0])
|
|
49
43
|
}
|
|
50
44
|
|
|
51
|
-
if(equations[1] instanceof Polynom){
|
|
45
|
+
if (equations[1] instanceof Polynom) {
|
|
52
46
|
this.right = equations[1].clone()
|
|
53
|
-
}else if(typeof equations[1] === 'string'){
|
|
47
|
+
} else if (typeof equations[1] === 'string') {
|
|
54
48
|
this.right = new Polynom(equations[1])
|
|
55
49
|
}
|
|
56
50
|
} else {
|
|
@@ -61,16 +55,51 @@ export class Equation {
|
|
|
61
55
|
return this;
|
|
62
56
|
}
|
|
63
57
|
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
private _left: Polynom; // Left part of the equation
|
|
59
|
+
|
|
60
|
+
get left(): Polynom {
|
|
61
|
+
return this._left;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
set left(value: Polynom) {
|
|
65
|
+
this._left = value;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private _right: Polynom; // Right part of the equation
|
|
69
|
+
|
|
70
|
+
get right(): Polynom {
|
|
71
|
+
return this._right;
|
|
66
72
|
}
|
|
67
73
|
|
|
68
74
|
// ------------------------------------------
|
|
69
75
|
// Getter and setter
|
|
76
|
+
|
|
77
|
+
set right(value: Polynom) {
|
|
78
|
+
this._right = value;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private _sign: string; // Signe of the equation, by default =
|
|
82
|
+
|
|
83
|
+
get sign(): string {
|
|
84
|
+
return this._sign;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
set sign(value: string) {
|
|
88
|
+
// Set the sign value as formatted.
|
|
89
|
+
this._sign = this._formatSign(value);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private _solutions: ISolution[]
|
|
93
|
+
|
|
70
94
|
// ------------------------------------------
|
|
71
95
|
get solutions(): ISolution[] {
|
|
72
96
|
return this._solutions
|
|
73
97
|
}
|
|
98
|
+
|
|
99
|
+
get isEquation() {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
|
|
74
103
|
get solution(): string {
|
|
75
104
|
if (this._solutions.length === 1
|
|
76
105
|
&&
|
|
@@ -117,7 +146,6 @@ export class Equation {
|
|
|
117
146
|
return `${this._left.display}${this.signAsTex}${this._right.display}`;
|
|
118
147
|
}
|
|
119
148
|
|
|
120
|
-
|
|
121
149
|
get raw(): string {
|
|
122
150
|
return `${this._left.raw}${this.signAsTex}${this._right.raw}`;
|
|
123
151
|
}
|
|
@@ -130,34 +158,23 @@ export class Equation {
|
|
|
130
158
|
return this.variables.length;
|
|
131
159
|
}
|
|
132
160
|
|
|
133
|
-
get left(): Polynom {
|
|
134
|
-
return this._left;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
set left(value: Polynom) {
|
|
138
|
-
this._left = value;
|
|
139
|
-
}
|
|
140
161
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
162
|
+
// ------------------------------------------
|
|
163
|
+
// Creation / parsing functions
|
|
144
164
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
165
|
+
// -----------------------------------------------
|
|
166
|
+
private _randomizeDefaults: { [key: string]: number | string | boolean } = {
|
|
167
|
+
degree: 2
|
|
168
|
+
};
|
|
148
169
|
|
|
149
|
-
get
|
|
150
|
-
return this.
|
|
170
|
+
get randomizeDefaults(): { [key: string]: number | string | boolean } {
|
|
171
|
+
return this._randomizeDefaults;
|
|
151
172
|
}
|
|
152
173
|
|
|
153
|
-
set
|
|
154
|
-
|
|
155
|
-
this._sign = this._formatSign(value);
|
|
174
|
+
set randomizeDefaults(value) {
|
|
175
|
+
this._randomizeDefaults = value;
|
|
156
176
|
}
|
|
157
177
|
|
|
158
|
-
|
|
159
|
-
// ------------------------------------------
|
|
160
|
-
// Creation / parsing functions
|
|
161
178
|
// ------------------------------------------
|
|
162
179
|
parse = (equationString: string): Equation => {
|
|
163
180
|
let pStr: string[], strSign: string | false;
|
|
@@ -175,77 +192,6 @@ export class Equation {
|
|
|
175
192
|
return this.create(new Polynom(pStr[0]), new Polynom(pStr[1]), this._formatSign(strSign));
|
|
176
193
|
};
|
|
177
194
|
|
|
178
|
-
private _findSign = (equationString: string): string | false => {
|
|
179
|
-
let strSign: string = '';
|
|
180
|
-
|
|
181
|
-
if (equationString.includes('geq')) {
|
|
182
|
-
return (equationString.includes('\\geq')) ? '\\geq' : 'geq';
|
|
183
|
-
} else if (equationString.includes('leq')) {
|
|
184
|
-
return (equationString.includes('\\leq')) ? '\\leq' : 'leq';
|
|
185
|
-
} else if (equationString.includes('>=')) {
|
|
186
|
-
return '>=';
|
|
187
|
-
} else if (equationString.includes('=>')) {
|
|
188
|
-
return '=>';
|
|
189
|
-
} else if (equationString.includes('>')) {
|
|
190
|
-
return '>';
|
|
191
|
-
} else if (equationString.includes('<=')) {
|
|
192
|
-
return '<=';
|
|
193
|
-
} else if (equationString.includes('=<')) {
|
|
194
|
-
return '=<';
|
|
195
|
-
} else if (equationString.includes('<')) {
|
|
196
|
-
return '<';
|
|
197
|
-
} else if (equationString.includes('=')) {
|
|
198
|
-
return '='
|
|
199
|
-
}
|
|
200
|
-
if (strSign === '') {
|
|
201
|
-
console.log('Equation: parse string : sign not found');
|
|
202
|
-
return false;
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
private _formatSign = (signStr: string): string => {
|
|
207
|
-
if (signStr === undefined) {
|
|
208
|
-
return '=';
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
if (signStr.includes('geq')) {
|
|
212
|
-
return '>=';
|
|
213
|
-
} else if (signStr.includes('>=')) {
|
|
214
|
-
return '>=';
|
|
215
|
-
} else if (signStr.includes('=>')) {
|
|
216
|
-
return '>=';
|
|
217
|
-
} else if (signStr.includes('>')) {
|
|
218
|
-
return '>';
|
|
219
|
-
} else if (signStr.includes('leq')) {
|
|
220
|
-
return '<=';
|
|
221
|
-
} else if (signStr.includes('<=')) {
|
|
222
|
-
return '<=';
|
|
223
|
-
} else if (signStr.includes('=<')) {
|
|
224
|
-
return '<=';
|
|
225
|
-
} else if (signStr.includes('<')) {
|
|
226
|
-
return '<';
|
|
227
|
-
} else {
|
|
228
|
-
return '='
|
|
229
|
-
}
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
private _reverseSign = (): Equation => {
|
|
233
|
-
if (this._sign === '=') {
|
|
234
|
-
return this;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
if (this._sign.includes('<')) {
|
|
238
|
-
this._sign.replace('<', '>');
|
|
239
|
-
return this;
|
|
240
|
-
}
|
|
241
|
-
if (this._sign.includes('>')) {
|
|
242
|
-
this._sign.replace('>', '<');
|
|
243
|
-
return this;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return this;
|
|
247
|
-
};
|
|
248
|
-
|
|
249
195
|
create = (left: Polynom, right: Polynom, sign?: string): Equation => {
|
|
250
196
|
this._left = left;
|
|
251
197
|
this._right = right;
|
|
@@ -259,26 +205,12 @@ export class Equation {
|
|
|
259
205
|
|
|
260
206
|
// -----------------------------------------------
|
|
261
207
|
// Equations generators and randomizers
|
|
262
|
-
// -----------------------------------------------
|
|
263
|
-
private _randomizeDefaults: { [key: string]: number | string | boolean } = {
|
|
264
|
-
degree: 2
|
|
265
|
-
};
|
|
266
|
-
get randomizeDefaults(): { [key: string]: number | string | boolean } {
|
|
267
|
-
return this._randomizeDefaults;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
set randomizeDefaults(value) {
|
|
271
|
-
this._randomizeDefaults = value;
|
|
272
|
-
}
|
|
273
208
|
|
|
274
209
|
randomize = (opts?: {}, sign?: string): Equation => {
|
|
275
210
|
// TODO: Generate equations randomly, using config.
|
|
276
211
|
return new Equation().create(new Polynom(), new Polynom(), sign);
|
|
277
212
|
};
|
|
278
213
|
|
|
279
|
-
|
|
280
|
-
// -----------------------------------------------
|
|
281
|
-
// Equations operations
|
|
282
214
|
// -----------------------------------------------
|
|
283
215
|
/**
|
|
284
216
|
* Reorder will move all monoms containing a letter on the left, all the other on the right.
|
|
@@ -288,6 +220,7 @@ export class Equation {
|
|
|
288
220
|
this._right.zero()
|
|
289
221
|
return this;
|
|
290
222
|
}
|
|
223
|
+
|
|
291
224
|
reorder = (allLeft?: boolean): Equation => {
|
|
292
225
|
// Move all monoms of degree greater than 0 to the left.
|
|
293
226
|
// and all zero degree monoms to the right.
|
|
@@ -321,6 +254,10 @@ export class Equation {
|
|
|
321
254
|
return this;
|
|
322
255
|
}
|
|
323
256
|
|
|
257
|
+
|
|
258
|
+
// -----------------------------------------------
|
|
259
|
+
// Equations operations
|
|
260
|
+
|
|
324
261
|
/**
|
|
325
262
|
* Reorder the polynom to have only one letter on the left, the rest on the right.
|
|
326
263
|
* @param letter
|
|
@@ -415,10 +352,6 @@ export class Equation {
|
|
|
415
352
|
}
|
|
416
353
|
}
|
|
417
354
|
|
|
418
|
-
// -----------------------------------------------
|
|
419
|
-
// Equations helpers
|
|
420
|
-
// -----------------------------------------------
|
|
421
|
-
|
|
422
355
|
/**
|
|
423
356
|
* Get the degree of the equation
|
|
424
357
|
* @param letter
|
|
@@ -440,7 +373,9 @@ export class Equation {
|
|
|
440
373
|
}
|
|
441
374
|
|
|
442
375
|
// -----------------------------------------------
|
|
443
|
-
// Equations
|
|
376
|
+
// Equations helpers
|
|
377
|
+
// -----------------------------------------------
|
|
378
|
+
|
|
444
379
|
// -----------------------------------------------
|
|
445
380
|
solve = (): Equation => {
|
|
446
381
|
// Initialise the variables:
|
|
@@ -464,6 +399,84 @@ export class Equation {
|
|
|
464
399
|
return this;
|
|
465
400
|
};
|
|
466
401
|
|
|
402
|
+
test = (values: literalType): Boolean => {
|
|
403
|
+
return this.left.evaluate(values).isEqual(this.right.evaluate(values))
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
private _findSign = (equationString: string): string | false => {
|
|
407
|
+
let strSign: string = '';
|
|
408
|
+
|
|
409
|
+
if (equationString.includes('geq')) {
|
|
410
|
+
return (equationString.includes('\\geq')) ? '\\geq' : 'geq';
|
|
411
|
+
} else if (equationString.includes('leq')) {
|
|
412
|
+
return (equationString.includes('\\leq')) ? '\\leq' : 'leq';
|
|
413
|
+
} else if (equationString.includes('>=')) {
|
|
414
|
+
return '>=';
|
|
415
|
+
} else if (equationString.includes('=>')) {
|
|
416
|
+
return '=>';
|
|
417
|
+
} else if (equationString.includes('>')) {
|
|
418
|
+
return '>';
|
|
419
|
+
} else if (equationString.includes('<=')) {
|
|
420
|
+
return '<=';
|
|
421
|
+
} else if (equationString.includes('=<')) {
|
|
422
|
+
return '=<';
|
|
423
|
+
} else if (equationString.includes('<')) {
|
|
424
|
+
return '<';
|
|
425
|
+
} else if (equationString.includes('=')) {
|
|
426
|
+
return '='
|
|
427
|
+
}
|
|
428
|
+
if (strSign === '') {
|
|
429
|
+
console.log('Equation: parse string : sign not found');
|
|
430
|
+
return false;
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
// -----------------------------------------------
|
|
435
|
+
// Equations solving algorithms
|
|
436
|
+
|
|
437
|
+
private _formatSign = (signStr: string): string => {
|
|
438
|
+
if (signStr === undefined) {
|
|
439
|
+
return '=';
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
if (signStr.includes('geq')) {
|
|
443
|
+
return '>=';
|
|
444
|
+
} else if (signStr.includes('>=')) {
|
|
445
|
+
return '>=';
|
|
446
|
+
} else if (signStr.includes('=>')) {
|
|
447
|
+
return '>=';
|
|
448
|
+
} else if (signStr.includes('>')) {
|
|
449
|
+
return '>';
|
|
450
|
+
} else if (signStr.includes('leq')) {
|
|
451
|
+
return '<=';
|
|
452
|
+
} else if (signStr.includes('<=')) {
|
|
453
|
+
return '<=';
|
|
454
|
+
} else if (signStr.includes('=<')) {
|
|
455
|
+
return '<=';
|
|
456
|
+
} else if (signStr.includes('<')) {
|
|
457
|
+
return '<';
|
|
458
|
+
} else {
|
|
459
|
+
return '='
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
private _reverseSign = (): Equation => {
|
|
464
|
+
if (this._sign === '=') {
|
|
465
|
+
return this;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
if (this._sign.includes('<')) {
|
|
469
|
+
this._sign.replace('<', '>');
|
|
470
|
+
return this;
|
|
471
|
+
}
|
|
472
|
+
if (this._sign.includes('>')) {
|
|
473
|
+
this._sign.replace('>', '<');
|
|
474
|
+
return this;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
return this;
|
|
478
|
+
};
|
|
479
|
+
|
|
467
480
|
private isGreater = (): boolean => {
|
|
468
481
|
if (this._sign.indexOf('>') !== -1) {
|
|
469
482
|
return true;
|
|
@@ -471,9 +484,11 @@ export class Equation {
|
|
|
471
484
|
return this._sign.indexOf('geq') !== -1;
|
|
472
485
|
|
|
473
486
|
};
|
|
487
|
+
|
|
474
488
|
private isStrictEqual = (): boolean => {
|
|
475
489
|
return this._sign === '=';
|
|
476
490
|
};
|
|
491
|
+
|
|
477
492
|
private isAlsoEqual = (): boolean => {
|
|
478
493
|
if (this._sign.indexOf('=') !== -1) {
|
|
479
494
|
return true;
|
|
@@ -752,5 +767,4 @@ export class Equation {
|
|
|
752
767
|
this._solutions = [{tex: 'solve x - not yet handled', value: NaN, exact: false}]; // ESLint remove system :(
|
|
753
768
|
return this._solutions;
|
|
754
769
|
};
|
|
755
|
-
|
|
756
770
|
}
|
|
@@ -161,11 +161,13 @@ export class Monom {
|
|
|
161
161
|
|
|
162
162
|
get dividers(): Monom[] {
|
|
163
163
|
// Decompose only if the coefficient is a natural number
|
|
164
|
-
if (this.coefficient.
|
|
164
|
+
if (!this.coefficient.isRelative()) {
|
|
165
165
|
return [this.clone()]
|
|
166
166
|
}
|
|
167
|
+
|
|
168
|
+
|
|
167
169
|
// Decompose only if the power values are natural numbers.
|
|
168
|
-
if (this.hasFractionCoefficient) {
|
|
170
|
+
if (this.hasFractionCoefficient()) {
|
|
169
171
|
return [this.clone()]
|
|
170
172
|
}
|
|
171
173
|
|
|
@@ -173,6 +175,8 @@ export class Monom {
|
|
|
173
175
|
if (this.coefficient.numerator > 10000) {
|
|
174
176
|
return [this.clone()]
|
|
175
177
|
}
|
|
178
|
+
|
|
179
|
+
|
|
176
180
|
const dividers = Numeric.dividers(Math.abs(this.coefficient.numerator))
|
|
177
181
|
|
|
178
182
|
// Decompose the literals parts.
|
|
@@ -740,6 +740,7 @@ export class Polynom {
|
|
|
740
740
|
let P = this.clone().reorder(),
|
|
741
741
|
M = P.commonMonom(),
|
|
742
742
|
tempPolynom: Polynom
|
|
743
|
+
|
|
743
744
|
// It has a common monom.
|
|
744
745
|
if (!M.isOne()) {
|
|
745
746
|
tempPolynom = new Polynom()
|
|
@@ -750,10 +751,10 @@ export class Polynom {
|
|
|
750
751
|
|
|
751
752
|
let securityLoop = P.degree().clone().multiply(2).value
|
|
752
753
|
// securityLoop = 0
|
|
754
|
+
|
|
753
755
|
while (securityLoop >= 0) {
|
|
754
756
|
securityLoop--
|
|
755
757
|
|
|
756
|
-
|
|
757
758
|
if (P.monoms.length < 2) {
|
|
758
759
|
if (!P.isOne()) {
|
|
759
760
|
factors.push(P.clone());
|
|
@@ -764,9 +765,6 @@ export class Polynom {
|
|
|
764
765
|
let m1 = P.monoms[0].dividers,
|
|
765
766
|
m2 = P.monoms[P.monoms.length - 1].dividers
|
|
766
767
|
|
|
767
|
-
// console.log('CURRENT VALUE')
|
|
768
|
-
// console.log(P.tex)
|
|
769
|
-
// console.log('---------------------')
|
|
770
768
|
for (let m1d of m1) {
|
|
771
769
|
for (let m2d of m2) {
|
|
772
770
|
// if(m1d.degree()===m2d.degree()){continue}
|
|
@@ -775,7 +773,6 @@ export class Polynom {
|
|
|
775
773
|
dividerPolynom.monoms = [m1d.clone(), m2d.clone()]
|
|
776
774
|
result = P.euclidian(dividerPolynom)
|
|
777
775
|
|
|
778
|
-
// console.log(dividerPolynom.tex, '=>', result.reminder.tex, '|||||', result.quotient.tex)
|
|
779
776
|
if (result.reminder.isZero()) {
|
|
780
777
|
P = result.quotient.clone();
|
|
781
778
|
factors.push(dividerPolynom)
|
|
@@ -788,11 +785,9 @@ export class Polynom {
|
|
|
788
785
|
P = result.quotient.clone();
|
|
789
786
|
factors.push(dividerPolynom)
|
|
790
787
|
}
|
|
791
|
-
// console.log(dividerPolynom.tex, '=>', result.reminder.tex)
|
|
792
788
|
}
|
|
793
789
|
}
|
|
794
790
|
}
|
|
795
|
-
|
|
796
791
|
}
|
|
797
792
|
|
|
798
793
|
this.factors = factors
|