pimath 0.0.15 → 0.0.19
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/dev/index.html +39 -3
- package/dev/pi.js +933 -721
- package/dev/pi.js.map +1 -1
- package/dist/pi.js +1 -1
- package/dist/pi.js.map +1 -1
- package/esm/main.js +24 -22
- package/esm/main.js.map +1 -1
- package/esm/maths/algebra/equation.d.ts +3 -1
- package/esm/maths/algebra/equation.js +32 -25
- package/esm/maths/algebra/equation.js.map +1 -1
- package/esm/maths/algebra/index.d.ts +0 -20
- package/esm/maths/algebra/index.js +18 -33
- package/esm/maths/algebra/index.js.map +1 -1
- package/esm/maths/algebra/linearSystem.d.ts +1 -1
- package/esm/maths/algebra/linearSystem.js +19 -15
- package/esm/maths/algebra/linearSystem.js.map +1 -1
- package/esm/maths/algebra/logicalset.js +7 -3
- package/esm/maths/algebra/logicalset.js.map +1 -1
- package/esm/maths/algebra/monom.d.ts +15 -18
- package/esm/maths/algebra/monom.js +182 -84
- package/esm/maths/algebra/monom.js.map +1 -1
- package/esm/maths/algebra/polynom.d.ts +6 -27
- package/esm/maths/algebra/polynom.js +62 -218
- package/esm/maths/algebra/polynom.js.map +1 -1
- package/esm/maths/algebra/rational.js +15 -10
- package/esm/maths/algebra/rational.js.map +1 -1
- package/esm/maths/coefficients/fraction.d.ts +20 -10
- package/esm/maths/coefficients/fraction.js +83 -15
- package/esm/maths/coefficients/fraction.js.map +1 -1
- package/esm/maths/coefficients/index.js +14 -2
- package/esm/maths/coefficients/index.js.map +1 -1
- package/esm/maths/coefficients/nthroot.js +5 -1
- package/esm/maths/coefficients/nthroot.js.map +1 -1
- package/esm/maths/geometry/circle.d.ts +16 -1
- package/esm/maths/geometry/circle.js +95 -14
- package/esm/maths/geometry/circle.js.map +1 -1
- package/esm/maths/geometry/index.d.ts +0 -17
- package/esm/maths/geometry/index.js +17 -28
- package/esm/maths/geometry/index.js.map +1 -1
- package/esm/maths/geometry/line.d.ts +20 -4
- package/esm/maths/geometry/line.js +123 -49
- package/esm/maths/geometry/line.js.map +1 -1
- package/esm/maths/geometry/point.d.ts +1 -0
- package/esm/maths/geometry/point.js +22 -12
- package/esm/maths/geometry/point.js.map +1 -1
- package/esm/maths/geometry/triangle.js +31 -27
- package/esm/maths/geometry/triangle.js.map +1 -1
- package/esm/maths/geometry/vector.d.ts +0 -1
- package/esm/maths/geometry/vector.js +22 -21
- package/esm/maths/geometry/vector.js.map +1 -1
- package/esm/maths/numeric.js +5 -1
- package/esm/maths/numeric.js.map +1 -1
- package/esm/maths/random/index.d.ts +3 -1
- package/esm/maths/random/index.js +32 -14
- package/esm/maths/random/index.js.map +1 -1
- package/esm/maths/random/randomCore.js +5 -1
- package/esm/maths/random/randomCore.js.map +1 -1
- package/esm/maths/random/rndFraction.d.ts +9 -0
- package/esm/maths/random/rndFraction.js +30 -0
- package/esm/maths/random/rndFraction.js.map +1 -0
- package/esm/maths/random/rndHelpers.js +5 -1
- package/esm/maths/random/rndHelpers.js.map +1 -1
- package/esm/maths/random/rndMonom.d.ts +2 -2
- package/esm/maths/random/rndMonom.js +15 -8
- package/esm/maths/random/rndMonom.js.map +1 -1
- package/esm/maths/random/rndPolynom.js +14 -11
- package/esm/maths/random/rndPolynom.js.map +1 -1
- package/esm/maths/random/rndTypes.d.ts +5 -0
- package/esm/maths/random/rndTypes.js +2 -1
- package/esm/maths/shutingyard.js +5 -1
- package/esm/maths/shutingyard.js.map +1 -1
- package/package.json +5 -5
- package/src/maths/algebra/equation.ts +13 -7
- package/src/maths/algebra/index.ts +1 -17
- package/src/maths/algebra/linearSystem.ts +3 -3
- package/src/maths/algebra/monom.ts +764 -612
- package/src/maths/algebra/monom_bck.backup +746 -0
- package/src/maths/algebra/polynom.ts +977 -1176
- package/src/maths/algebra/rational.ts +6 -6
- package/src/maths/coefficients/fraction.ts +98 -27
- package/src/maths/geometry/circle.ts +133 -21
- package/src/maths/geometry/index.ts +0 -14
- package/src/maths/geometry/line.ts +162 -58
- package/src/maths/geometry/point.ts +9 -0
- package/src/maths/geometry/vector.ts +1 -5
- package/src/maths/random/index.ts +7 -1
- package/src/maths/random/rndFraction.ts +37 -0
- package/src/maths/random/rndMonom.ts +6 -3
- package/src/maths/random/rndPolynom.ts +0 -1
- package/src/maths/random/rndTypes.ts +5 -0
- package/src/maths/shutingyard.ts +2 -0
- package/tests/algebra/monom.test.ts +47 -8
- package/tests/algebra/polynom.test.ts +13 -22
- package/tests/coefficients/fraction.test.ts +35 -38
- package/tests/shutingyard.test.ts +0 -1
- package/tsconfig.json +2 -2
- package/tsconfig.testing.json +28 -0
package/dev/pi.js
CHANGED
|
@@ -6,20 +6,15 @@
|
|
|
6
6
|
/*!***************************************!*\
|
|
7
7
|
!*** ./src/maths/algebra/equation.ts ***!
|
|
8
8
|
\***************************************/
|
|
9
|
-
/***/ ((__unused_webpack_module,
|
|
9
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
10
10
|
|
|
11
|
-
__webpack_require__.r(__webpack_exports__);
|
|
12
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
13
|
-
/* harmony export */ "default": () => (/* binding */ Equation)
|
|
14
|
-
/* harmony export */ });
|
|
15
|
-
/* harmony import */ var _polynom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts");
|
|
16
|
-
/* harmony import */ var _numeric__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
17
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
18
|
-
/* harmony import */ var _coefficients_nthroot__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../coefficients/nthroot */ "./src/maths/coefficients/nthroot.ts");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
11
|
|
|
12
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
13
|
+
exports.Equation = void 0;
|
|
14
|
+
const polynom_1 = __webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts");
|
|
15
|
+
const numeric_1 = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
16
|
+
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
17
|
+
const coefficients_2 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
23
18
|
class Equation {
|
|
24
19
|
_left;
|
|
25
20
|
_right;
|
|
@@ -29,8 +24,8 @@ class Equation {
|
|
|
29
24
|
_varnothing = '\\varnothing';
|
|
30
25
|
_real = '\\mathbb{R}';
|
|
31
26
|
constructor(...equations) {
|
|
32
|
-
this._left = new
|
|
33
|
-
this._right = new
|
|
27
|
+
this._left = new polynom_1.Polynom().zero();
|
|
28
|
+
this._right = new polynom_1.Polynom().zero();
|
|
34
29
|
this._sign = '=';
|
|
35
30
|
if (equations.length === 1) {
|
|
36
31
|
if (equations[0].isEquation === true) {
|
|
@@ -41,8 +36,8 @@ class Equation {
|
|
|
41
36
|
}
|
|
42
37
|
}
|
|
43
38
|
else if (equations.length === 2) {
|
|
44
|
-
this.left = equations[0].
|
|
45
|
-
this.right = equations[1].
|
|
39
|
+
this.left = (equations[0] instanceof polynom_1.Polynom) ? equations[0].clone() : new polynom_1.Polynom(equations[0]);
|
|
40
|
+
this.right = (equations[1] instanceof polynom_1.Polynom) ? equations[1].clone() : new polynom_1.Polynom(equations[1]);
|
|
46
41
|
}
|
|
47
42
|
else {
|
|
48
43
|
return this;
|
|
@@ -89,6 +84,9 @@ class Equation {
|
|
|
89
84
|
get tex() {
|
|
90
85
|
return `${this._left.tex}${this.signAsTex}${this._right.tex}`;
|
|
91
86
|
}
|
|
87
|
+
get display() {
|
|
88
|
+
return `${this._left.display}${this.signAsTex}${this._right.display}`;
|
|
89
|
+
}
|
|
92
90
|
get raw() {
|
|
93
91
|
return `${this._left.raw}${this.signAsTex}${this._right.raw}`;
|
|
94
92
|
}
|
|
@@ -124,7 +122,7 @@ class Equation {
|
|
|
124
122
|
return;
|
|
125
123
|
}
|
|
126
124
|
pStr = equationString.split(strSign);
|
|
127
|
-
return this.create(new
|
|
125
|
+
return this.create(new polynom_1.Polynom(pStr[0]), new polynom_1.Polynom(pStr[1]), this._formatSign(strSign));
|
|
128
126
|
};
|
|
129
127
|
_findSign = (equationString) => {
|
|
130
128
|
let strSign = '';
|
|
@@ -225,7 +223,7 @@ class Equation {
|
|
|
225
223
|
this._randomizeDefaults = value;
|
|
226
224
|
}
|
|
227
225
|
randomize = (opts, sign) => {
|
|
228
|
-
return new Equation().create(new
|
|
226
|
+
return new Equation().create(new polynom_1.Polynom(), new polynom_1.Polynom(), sign);
|
|
229
227
|
};
|
|
230
228
|
moveLeft = () => {
|
|
231
229
|
this._left = this._left.clone().subtract(this._right);
|
|
@@ -240,7 +238,7 @@ class Equation {
|
|
|
240
238
|
}
|
|
241
239
|
let mMove;
|
|
242
240
|
for (let m of this._left.monoms) {
|
|
243
|
-
if (m.degree()
|
|
241
|
+
if (m.degree().isZero()) {
|
|
244
242
|
mMove = m.clone();
|
|
245
243
|
this._left.subtract(mMove);
|
|
246
244
|
this._right.subtract(mMove);
|
|
@@ -251,12 +249,12 @@ class Equation {
|
|
|
251
249
|
return this;
|
|
252
250
|
};
|
|
253
251
|
simplify = () => {
|
|
254
|
-
this.multiply(
|
|
255
|
-
this.divide(
|
|
252
|
+
this.multiply(numeric_1.Numeric.lcm(...this._left.getDenominators(), ...this._right.getDenominators()));
|
|
253
|
+
this.divide(numeric_1.Numeric.gcd(...this._left.getNumerators(), ...this._right.getNumerators()));
|
|
256
254
|
return this;
|
|
257
255
|
};
|
|
258
256
|
isolate = (letter) => {
|
|
259
|
-
if (this.degree(letter)
|
|
257
|
+
if (!this.degree(letter).isOne()) {
|
|
260
258
|
return false;
|
|
261
259
|
}
|
|
262
260
|
if (this.isMultiVariable()) {
|
|
@@ -286,7 +284,7 @@ class Equation {
|
|
|
286
284
|
return this;
|
|
287
285
|
};
|
|
288
286
|
multiply = (value) => {
|
|
289
|
-
let F = new
|
|
287
|
+
let F = new coefficients_1.Fraction(value);
|
|
290
288
|
this._left.multiply(F);
|
|
291
289
|
this._right.multiply(F);
|
|
292
290
|
if (this._sign !== '=' && F.sign() === -1) {
|
|
@@ -295,7 +293,7 @@ class Equation {
|
|
|
295
293
|
return this;
|
|
296
294
|
};
|
|
297
295
|
divide = (value) => {
|
|
298
|
-
let F = new
|
|
296
|
+
let F = new coefficients_1.Fraction(value);
|
|
299
297
|
if (F.isZero()) {
|
|
300
298
|
return this;
|
|
301
299
|
}
|
|
@@ -304,7 +302,7 @@ class Equation {
|
|
|
304
302
|
}
|
|
305
303
|
};
|
|
306
304
|
degree = (letter) => {
|
|
307
|
-
return
|
|
305
|
+
return coefficients_1.Fraction.max(this._left.degree(letter), this._right.degree(letter));
|
|
308
306
|
};
|
|
309
307
|
isMultiVariable = () => {
|
|
310
308
|
return this._left.isMultiVariable || this._right.isMultiVariable;
|
|
@@ -315,7 +313,7 @@ class Equation {
|
|
|
315
313
|
solve = (letter) => {
|
|
316
314
|
this._solutions = [];
|
|
317
315
|
this._polynom = this._left.clone().subtract(this._right);
|
|
318
|
-
switch (this._polynom.degree(letter)) {
|
|
316
|
+
switch (this._polynom.degree(letter).value) {
|
|
319
317
|
case 0:
|
|
320
318
|
case 1:
|
|
321
319
|
this._solveDegree1(letter);
|
|
@@ -391,7 +389,7 @@ class Equation {
|
|
|
391
389
|
return this._solutions;
|
|
392
390
|
};
|
|
393
391
|
_solveDegree2 = (letter) => {
|
|
394
|
-
let aF = this._polynom.monomByDegree(2, letter).coefficient, bF = this._polynom.monomByDegree(1, letter).coefficient, cF = this._polynom.monomByDegree(0, letter).coefficient, delta, nthDelta, lcm =
|
|
392
|
+
let aF = this._polynom.monomByDegree(2, letter).coefficient, bF = this._polynom.monomByDegree(1, letter).coefficient, cF = this._polynom.monomByDegree(0, letter).coefficient, delta, nthDelta, lcm = numeric_1.Numeric.lcm(aF.denominator, bF.denominator, cF.denominator), a = aF.multiply(lcm).value, b = bF.multiply(lcm).value, c = cF.multiply(lcm).value, realX1, realX2, sX1, sX2;
|
|
395
393
|
delta = b * b - 4 * a * c;
|
|
396
394
|
if (delta > 0) {
|
|
397
395
|
realX1 = (-b - Math.sqrt(delta)) / (2 * a);
|
|
@@ -403,9 +401,9 @@ class Equation {
|
|
|
403
401
|
];
|
|
404
402
|
}
|
|
405
403
|
else {
|
|
406
|
-
nthDelta = new
|
|
404
|
+
nthDelta = new coefficients_2.Nthroot().parse(delta).reduce();
|
|
407
405
|
if (nthDelta.hasRadical()) {
|
|
408
|
-
let gcd =
|
|
406
|
+
let gcd = numeric_1.Numeric.gcd(b, 2 * a, nthDelta.coefficient);
|
|
409
407
|
nthDelta.coefficient = nthDelta.coefficient / gcd;
|
|
410
408
|
if (b !== 0) {
|
|
411
409
|
if (2 * a / gcd === 1) {
|
|
@@ -438,14 +436,14 @@ class Equation {
|
|
|
438
436
|
}
|
|
439
437
|
else {
|
|
440
438
|
this._solutions = [
|
|
441
|
-
new
|
|
442
|
-
new
|
|
439
|
+
new coefficients_1.Fraction(-b - nthDelta.coefficient, 2 * a).reduce().dfrac,
|
|
440
|
+
new coefficients_1.Fraction(-b + nthDelta.coefficient, 2 * a).reduce().dfrac
|
|
443
441
|
];
|
|
444
442
|
}
|
|
445
443
|
}
|
|
446
444
|
}
|
|
447
445
|
else if (delta === 0) {
|
|
448
|
-
this._solutions = [new
|
|
446
|
+
this._solutions = [new coefficients_1.Fraction(-b, 2 * a).reduce().dfrac];
|
|
449
447
|
}
|
|
450
448
|
else {
|
|
451
449
|
this._solutions = [this._varnothing];
|
|
@@ -500,6 +498,35 @@ class Equation {
|
|
|
500
498
|
return this._solutions;
|
|
501
499
|
};
|
|
502
500
|
}
|
|
501
|
+
exports.Equation = Equation;
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
/***/ }),
|
|
505
|
+
|
|
506
|
+
/***/ "./src/maths/algebra/index.ts":
|
|
507
|
+
/*!************************************!*\
|
|
508
|
+
!*** ./src/maths/algebra/index.ts ***!
|
|
509
|
+
\************************************/
|
|
510
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
514
|
+
if (k2 === undefined) k2 = k;
|
|
515
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
516
|
+
}) : (function(o, m, k, k2) {
|
|
517
|
+
if (k2 === undefined) k2 = k;
|
|
518
|
+
o[k2] = m[k];
|
|
519
|
+
}));
|
|
520
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
521
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
522
|
+
};
|
|
523
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
524
|
+
__exportStar(__webpack_require__(/*! ./equation */ "./src/maths/algebra/equation.ts"), exports);
|
|
525
|
+
__exportStar(__webpack_require__(/*! ./linearSystem */ "./src/maths/algebra/linearSystem.ts"), exports);
|
|
526
|
+
__exportStar(__webpack_require__(/*! ./logicalset */ "./src/maths/algebra/logicalset.ts"), exports);
|
|
527
|
+
__exportStar(__webpack_require__(/*! ./monom */ "./src/maths/algebra/monom.ts"), exports);
|
|
528
|
+
__exportStar(__webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts"), exports);
|
|
529
|
+
__exportStar(__webpack_require__(/*! ./rational */ "./src/maths/algebra/rational.ts"), exports);
|
|
503
530
|
|
|
504
531
|
|
|
505
532
|
/***/ }),
|
|
@@ -508,20 +535,15 @@ class Equation {
|
|
|
508
535
|
/*!*******************************************!*\
|
|
509
536
|
!*** ./src/maths/algebra/linearSystem.ts ***!
|
|
510
537
|
\*******************************************/
|
|
511
|
-
/***/ ((__unused_webpack_module,
|
|
538
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
512
539
|
|
|
513
|
-
__webpack_require__.r(__webpack_exports__);
|
|
514
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
515
|
-
/* harmony export */ "default": () => (/* binding */ LinearSystem)
|
|
516
|
-
/* harmony export */ });
|
|
517
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
518
|
-
/* harmony import */ var _equation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./equation */ "./src/maths/algebra/equation.ts");
|
|
519
|
-
/* harmony import */ var _polynom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts");
|
|
520
|
-
/* harmony import */ var _random_random__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../random/random */ "./src/maths/random/random.ts");
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
540
|
|
|
541
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
542
|
+
exports.LinearSystem = void 0;
|
|
543
|
+
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
544
|
+
const equation_1 = __webpack_require__(/*! ./equation */ "./src/maths/algebra/equation.ts");
|
|
545
|
+
const polynom_1 = __webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts");
|
|
546
|
+
const random_1 = __webpack_require__(/*! ../random */ "./src/maths/random/index.ts");
|
|
525
547
|
class LinearSystem {
|
|
526
548
|
_solutions;
|
|
527
549
|
_resolutionSteps;
|
|
@@ -535,7 +557,7 @@ class LinearSystem {
|
|
|
535
557
|
}
|
|
536
558
|
return this;
|
|
537
559
|
}
|
|
538
|
-
get
|
|
560
|
+
get isLinearSystem() {
|
|
539
561
|
return true;
|
|
540
562
|
}
|
|
541
563
|
get equations() {
|
|
@@ -602,7 +624,7 @@ class LinearSystem {
|
|
|
602
624
|
return `(${tex.join(';')})`;
|
|
603
625
|
}
|
|
604
626
|
parse = (...equations) => {
|
|
605
|
-
this._equations = equations.map(value => new
|
|
627
|
+
this._equations = equations.map(value => new equation_1.Equation(value));
|
|
606
628
|
this._findLetters();
|
|
607
629
|
return this;
|
|
608
630
|
};
|
|
@@ -610,7 +632,7 @@ class LinearSystem {
|
|
|
610
632
|
this._equations = [];
|
|
611
633
|
let i = 0;
|
|
612
634
|
while (i < coefficients.length - this._letters.length) {
|
|
613
|
-
let left = new
|
|
635
|
+
let left = new polynom_1.Polynom().parse(this._letters.join(''), ...coefficients.slice(i, i + this._letters.length)), right = new polynom_1.Polynom(coefficients[i + this._letters.length].toString()), equ = new equation_1.Equation().create(left, right);
|
|
614
636
|
this._equations.push(equ.clone());
|
|
615
637
|
i = i + this._letters.length + 1;
|
|
616
638
|
}
|
|
@@ -635,7 +657,7 @@ class LinearSystem {
|
|
|
635
657
|
let solutionsF = [];
|
|
636
658
|
for (let s of solutions) {
|
|
637
659
|
if (typeof s === "number") {
|
|
638
|
-
solutionsF.push(new
|
|
660
|
+
solutionsF.push(new coefficients_1.Fraction(s.toString()));
|
|
639
661
|
}
|
|
640
662
|
else {
|
|
641
663
|
solutionsF.push(s.clone());
|
|
@@ -648,15 +670,15 @@ class LinearSystem {
|
|
|
648
670
|
return this;
|
|
649
671
|
};
|
|
650
672
|
_generateOneEquation = (...solutions) => {
|
|
651
|
-
let coeff = [], leftValue = new
|
|
673
|
+
let coeff = [], leftValue = new coefficients_1.Fraction().zero(), letters = ['x', 'y', 'z', 't', 'u', 'v', 'w', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'], equString = '', equ;
|
|
652
674
|
for (let i = 0; i < solutions.length; i++) {
|
|
653
|
-
coeff.push(
|
|
675
|
+
coeff.push(random_1.Random.numberSym(5));
|
|
654
676
|
leftValue.add(solutions[i].clone().multiply(coeff[i]));
|
|
655
677
|
equString += `${(coeff[i] < 0) ? coeff[i] : '+' + coeff[i]}${letters[i]}`;
|
|
656
678
|
}
|
|
657
|
-
equ = new
|
|
679
|
+
equ = new equation_1.Equation(`${equString}=${leftValue.display}`);
|
|
658
680
|
if (equ.right.monoms[0].coefficient.denominator != 1) {
|
|
659
|
-
equ.multiply(new
|
|
681
|
+
equ.multiply(new coefficients_1.Fraction(equ.right.monoms[0].coefficient.denominator, 1));
|
|
660
682
|
}
|
|
661
683
|
if (this._checkIfLinerCombination(equ)) {
|
|
662
684
|
return equ;
|
|
@@ -670,7 +692,7 @@ class LinearSystem {
|
|
|
670
692
|
return this.mergeEquations(eq1, eq2, c2, c1);
|
|
671
693
|
}
|
|
672
694
|
mergeEquations = (eq1, eq2, factor1, factor2) => {
|
|
673
|
-
let eq1multiplied = eq1.clone().multiply(new
|
|
695
|
+
let eq1multiplied = eq1.clone().multiply(new coefficients_1.Fraction(factor1)), eq2multiplied = eq2.clone().multiply(new coefficients_1.Fraction(factor2));
|
|
674
696
|
eq1multiplied.left.add(eq2multiplied.left);
|
|
675
697
|
eq1multiplied.right.add(eq2multiplied.right);
|
|
676
698
|
return eq1multiplied;
|
|
@@ -710,7 +732,7 @@ class LinearSystem {
|
|
|
710
732
|
let E = this._resolutionSteps[this._resolutionSteps.length - 1].equations[0];
|
|
711
733
|
E.solve();
|
|
712
734
|
return {
|
|
713
|
-
value: new
|
|
735
|
+
value: new coefficients_1.Fraction(E.solutions[0]),
|
|
714
736
|
isReal: E.isReal,
|
|
715
737
|
isVarnothing: E.isVarnothing
|
|
716
738
|
};
|
|
@@ -724,6 +746,7 @@ class LinearSystem {
|
|
|
724
746
|
return str;
|
|
725
747
|
};
|
|
726
748
|
}
|
|
749
|
+
exports.LinearSystem = LinearSystem;
|
|
727
750
|
|
|
728
751
|
|
|
729
752
|
/***/ }),
|
|
@@ -732,14 +755,12 @@ class LinearSystem {
|
|
|
732
755
|
/*!*****************************************!*\
|
|
733
756
|
!*** ./src/maths/algebra/logicalset.ts ***!
|
|
734
757
|
\*****************************************/
|
|
735
|
-
/***/ ((__unused_webpack_module,
|
|
758
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
736
759
|
|
|
737
|
-
__webpack_require__.r(__webpack_exports__);
|
|
738
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
739
|
-
/* harmony export */ "default": () => (/* binding */ Logicalset)
|
|
740
|
-
/* harmony export */ });
|
|
741
|
-
/* harmony import */ var _shutingyard__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../shutingyard */ "./src/maths/shutingyard.ts");
|
|
742
760
|
|
|
761
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
762
|
+
exports.Logicalset = void 0;
|
|
763
|
+
const shutingyard_1 = __webpack_require__(/*! ../shutingyard */ "./src/maths/shutingyard.ts");
|
|
743
764
|
class Logicalset {
|
|
744
765
|
_rawString;
|
|
745
766
|
_rpn;
|
|
@@ -753,7 +774,7 @@ class Logicalset {
|
|
|
753
774
|
}
|
|
754
775
|
;
|
|
755
776
|
parse = (value) => {
|
|
756
|
-
this._rpn = new
|
|
777
|
+
this._rpn = new shutingyard_1.Shutingyard('set').parse(value).rpn;
|
|
757
778
|
return this;
|
|
758
779
|
};
|
|
759
780
|
evaluate(tokenSets, reference) {
|
|
@@ -880,6 +901,7 @@ class Logicalset {
|
|
|
880
901
|
return varStack[0].token;
|
|
881
902
|
}
|
|
882
903
|
}
|
|
904
|
+
exports.Logicalset = Logicalset;
|
|
883
905
|
|
|
884
906
|
|
|
885
907
|
/***/ }),
|
|
@@ -888,16 +910,14 @@ class Logicalset {
|
|
|
888
910
|
/*!************************************!*\
|
|
889
911
|
!*** ./src/maths/algebra/monom.ts ***!
|
|
890
912
|
\************************************/
|
|
891
|
-
/***/ ((__unused_webpack_module,
|
|
913
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
892
914
|
|
|
893
|
-
__webpack_require__.r(__webpack_exports__);
|
|
894
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
895
|
-
/* harmony export */ "default": () => (/* binding */ Monom)
|
|
896
|
-
/* harmony export */ });
|
|
897
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
898
|
-
/* harmony import */ var _numeric__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
899
|
-
|
|
900
915
|
|
|
916
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
917
|
+
exports.Monom = void 0;
|
|
918
|
+
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
919
|
+
const numeric_1 = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
920
|
+
const shutingyard_1 = __webpack_require__(/*! ../shutingyard */ "./src/maths/shutingyard.ts");
|
|
901
921
|
class Monom {
|
|
902
922
|
_coefficient;
|
|
903
923
|
_literal;
|
|
@@ -908,9 +928,6 @@ class Monom {
|
|
|
908
928
|
}
|
|
909
929
|
return this;
|
|
910
930
|
}
|
|
911
|
-
get isMonom() {
|
|
912
|
-
return true;
|
|
913
|
-
}
|
|
914
931
|
get coefficient() {
|
|
915
932
|
return this._coefficient;
|
|
916
933
|
}
|
|
@@ -921,10 +938,10 @@ class Monom {
|
|
|
921
938
|
return this._literal;
|
|
922
939
|
}
|
|
923
940
|
get literalSqrt() {
|
|
924
|
-
if (this.
|
|
941
|
+
if (this.isLiteralSquare()) {
|
|
925
942
|
let L = {};
|
|
926
943
|
for (let key in this._literal) {
|
|
927
|
-
L[key] = this._literal[key]
|
|
944
|
+
L[key] = this._literal[key].clone().sqrt();
|
|
928
945
|
}
|
|
929
946
|
return L;
|
|
930
947
|
}
|
|
@@ -938,15 +955,15 @@ class Monom {
|
|
|
938
955
|
set literalStr(inputStr) {
|
|
939
956
|
for (const v of [...inputStr.matchAll(/([a-z])\^([+-]?[0-9]+)/g)]) {
|
|
940
957
|
if (!(v[1] in this._literal)) {
|
|
941
|
-
this._literal[v[1]] =
|
|
958
|
+
this._literal[v[1]] = new coefficients_1.Fraction().zero();
|
|
942
959
|
}
|
|
943
|
-
this._literal[v[1]]
|
|
960
|
+
this._literal[v[1]].add(+v[2]);
|
|
944
961
|
}
|
|
945
962
|
for (const v of [...inputStr.matchAll(/([a-z](?!\^))/g)]) {
|
|
946
963
|
if (!(v[1] in this._literal)) {
|
|
947
|
-
this._literal[v[1]] =
|
|
964
|
+
this._literal[v[1]] = new coefficients_1.Fraction().zero();
|
|
948
965
|
}
|
|
949
|
-
this._literal[v[1]]
|
|
966
|
+
this._literal[v[1]].add(1);
|
|
950
967
|
}
|
|
951
968
|
}
|
|
952
969
|
get variables() {
|
|
@@ -954,12 +971,12 @@ class Monom {
|
|
|
954
971
|
return Object.keys(this._literal);
|
|
955
972
|
}
|
|
956
973
|
get display() {
|
|
957
|
-
let L = '';
|
|
958
|
-
for (let letter
|
|
959
|
-
if (this._literal[letter]
|
|
974
|
+
let L = '', letters = Object.keys(this._literal).sort();
|
|
975
|
+
for (let letter of letters) {
|
|
976
|
+
if (this._literal[letter].isNotZero()) {
|
|
960
977
|
L += `${letter}`;
|
|
961
|
-
if (this._literal[letter]
|
|
962
|
-
L += `^${this._literal[letter]}`;
|
|
978
|
+
if (this._literal[letter].isNotEqual(1)) {
|
|
979
|
+
L += `^${this._literal[letter].display}`;
|
|
963
980
|
}
|
|
964
981
|
}
|
|
965
982
|
}
|
|
@@ -990,29 +1007,32 @@ class Monom {
|
|
|
990
1007
|
if (this.coefficient.denominator !== 1) {
|
|
991
1008
|
return [this.clone()];
|
|
992
1009
|
}
|
|
1010
|
+
if (this.hasFractionCoefficient) {
|
|
1011
|
+
return [this.clone()];
|
|
1012
|
+
}
|
|
993
1013
|
if (this.coefficient.numerator > 10000) {
|
|
994
1014
|
return [this.clone()];
|
|
995
1015
|
}
|
|
996
|
-
const dividers =
|
|
997
|
-
let
|
|
1016
|
+
const dividers = numeric_1.Numeric.dividers(Math.abs(this.coefficient.numerator));
|
|
1017
|
+
let literals = [];
|
|
998
1018
|
for (let L in this.literal) {
|
|
999
|
-
|
|
1019
|
+
literals = this._getLiteralDividers(literals, L);
|
|
1000
1020
|
}
|
|
1001
1021
|
const monomDividers = [];
|
|
1002
|
-
if (
|
|
1022
|
+
if (literals.length > 0 && dividers.length > 0) {
|
|
1003
1023
|
for (let N of dividers) {
|
|
1004
|
-
for (let L of
|
|
1024
|
+
for (let L of literals) {
|
|
1005
1025
|
let M = new Monom();
|
|
1006
|
-
M.coefficient = new
|
|
1026
|
+
M.coefficient = new coefficients_1.Fraction(N);
|
|
1007
1027
|
M.literal = L;
|
|
1008
1028
|
monomDividers.push(M);
|
|
1009
1029
|
}
|
|
1010
1030
|
}
|
|
1011
1031
|
}
|
|
1012
1032
|
else if (dividers.length === 0) {
|
|
1013
|
-
for (let L of
|
|
1033
|
+
for (let L of literals) {
|
|
1014
1034
|
let M = new Monom();
|
|
1015
|
-
M.coefficient = new
|
|
1035
|
+
M.coefficient = new coefficients_1.Fraction().one();
|
|
1016
1036
|
M.literal = L;
|
|
1017
1037
|
monomDividers.push(M);
|
|
1018
1038
|
}
|
|
@@ -1020,18 +1040,18 @@ class Monom {
|
|
|
1020
1040
|
else {
|
|
1021
1041
|
for (let N of dividers) {
|
|
1022
1042
|
let M = new Monom();
|
|
1023
|
-
M.coefficient = new
|
|
1043
|
+
M.coefficient = new coefficients_1.Fraction(N);
|
|
1024
1044
|
monomDividers.push(M);
|
|
1025
1045
|
}
|
|
1026
1046
|
}
|
|
1027
1047
|
return monomDividers.length === 0 ? [new Monom().one()] : monomDividers;
|
|
1028
1048
|
}
|
|
1029
|
-
|
|
1049
|
+
_getLiteralDividers(arr, letter) {
|
|
1030
1050
|
let tmpList = [];
|
|
1031
|
-
for (let d = 0; d <= this.literal[letter]; d++) {
|
|
1051
|
+
for (let d = 0; d <= this.literal[letter].value; d++) {
|
|
1032
1052
|
if (arr.length === 0) {
|
|
1033
1053
|
let litt = {};
|
|
1034
|
-
litt[letter] = d;
|
|
1054
|
+
litt[letter] = new coefficients_1.Fraction(d);
|
|
1035
1055
|
tmpList.push(litt);
|
|
1036
1056
|
}
|
|
1037
1057
|
else {
|
|
@@ -1040,7 +1060,7 @@ class Monom {
|
|
|
1040
1060
|
for (let currentLetter in item) {
|
|
1041
1061
|
litt[currentLetter] = item[currentLetter];
|
|
1042
1062
|
}
|
|
1043
|
-
litt[letter] = d;
|
|
1063
|
+
litt[letter] = new coefficients_1.Fraction(d);
|
|
1044
1064
|
tmpList.push(litt);
|
|
1045
1065
|
}
|
|
1046
1066
|
}
|
|
@@ -1052,12 +1072,12 @@ class Monom {
|
|
|
1052
1072
|
return (d[0] !== '-' ? '+' : '') + d;
|
|
1053
1073
|
}
|
|
1054
1074
|
get tex() {
|
|
1055
|
-
let L = '';
|
|
1056
|
-
for (let letter
|
|
1057
|
-
if (this._literal[letter]
|
|
1075
|
+
let L = '', letters = Object.keys(this._literal).sort();
|
|
1076
|
+
for (let letter of letters) {
|
|
1077
|
+
if (this._literal[letter].isNotZero()) {
|
|
1058
1078
|
L += `${letter}`;
|
|
1059
|
-
if (this._literal[letter]
|
|
1060
|
-
L +=
|
|
1079
|
+
if (this._literal[letter].isNotEqual(1)) {
|
|
1080
|
+
L += `^{${this._literal[letter].display}}`;
|
|
1061
1081
|
}
|
|
1062
1082
|
}
|
|
1063
1083
|
}
|
|
@@ -1085,37 +1105,96 @@ class Monom {
|
|
|
1085
1105
|
}
|
|
1086
1106
|
}
|
|
1087
1107
|
parse = (inputStr) => {
|
|
1088
|
-
this.
|
|
1089
|
-
this
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1108
|
+
this._shutingYardToReducedMonom(inputStr);
|
|
1109
|
+
return this;
|
|
1110
|
+
};
|
|
1111
|
+
_shutingYardToReducedMonom = (inputStr) => {
|
|
1112
|
+
const SY = new shutingyard_1.Shutingyard().parse(inputStr);
|
|
1113
|
+
const rpn = SY.rpn;
|
|
1114
|
+
let stack = [], m, pow, letter, q1, q2;
|
|
1115
|
+
if (rpn.length === 0) {
|
|
1116
|
+
this.zero();
|
|
1117
|
+
return this;
|
|
1118
|
+
}
|
|
1119
|
+
else if (rpn.length === 1) {
|
|
1120
|
+
const element = rpn[0];
|
|
1121
|
+
this.one();
|
|
1122
|
+
if (element.tokenType === 'coefficient') {
|
|
1123
|
+
this.coefficient = new coefficients_1.Fraction(element.token);
|
|
1124
|
+
}
|
|
1125
|
+
else if (element.tokenType === 'variable') {
|
|
1126
|
+
this.setLetter(element.token, 1);
|
|
1127
|
+
}
|
|
1128
|
+
return this;
|
|
1129
|
+
}
|
|
1130
|
+
else {
|
|
1131
|
+
for (const element of rpn) {
|
|
1132
|
+
if (element.tokenType === 'coefficient') {
|
|
1133
|
+
let M = new Monom().one();
|
|
1134
|
+
M.coefficient = new coefficients_1.Fraction(element.token);
|
|
1135
|
+
stack.push(M.clone());
|
|
1136
|
+
}
|
|
1137
|
+
else if (element.tokenType === 'variable') {
|
|
1138
|
+
let M = new Monom().one();
|
|
1139
|
+
M.setLetter(element.token, 1);
|
|
1140
|
+
stack.push(M.clone());
|
|
1141
|
+
}
|
|
1142
|
+
else if (element.tokenType === 'operation') {
|
|
1143
|
+
switch (element.token) {
|
|
1144
|
+
case '-':
|
|
1145
|
+
q2 = (stack.pop()) || new Monom().zero();
|
|
1146
|
+
q1 = (stack.pop()) || new Monom().zero();
|
|
1147
|
+
stack.push(q1.subtract(q2));
|
|
1148
|
+
break;
|
|
1149
|
+
case '*':
|
|
1150
|
+
q2 = (stack.pop()) || new Monom().one();
|
|
1151
|
+
q1 = (stack.pop()) || new Monom().one();
|
|
1152
|
+
stack.push(q1.multiply(q2));
|
|
1153
|
+
break;
|
|
1154
|
+
case '^':
|
|
1155
|
+
pow = (stack.pop().coefficient) || new coefficients_1.Fraction().one();
|
|
1156
|
+
m = (stack.pop()) || new Monom().one();
|
|
1157
|
+
letter = m.variables[0];
|
|
1158
|
+
if (letter !== undefined) {
|
|
1159
|
+
m.setLetter(letter, pow);
|
|
1160
|
+
}
|
|
1161
|
+
stack.push(m);
|
|
1162
|
+
break;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1093
1165
|
}
|
|
1094
|
-
this._coefficient.multiply(new _coefficients_fraction__WEBPACK_IMPORTED_MODULE_0__["default"](v.trim()));
|
|
1095
1166
|
}
|
|
1167
|
+
this.one();
|
|
1168
|
+
this.multiply(stack[0]);
|
|
1096
1169
|
return this;
|
|
1097
1170
|
};
|
|
1098
1171
|
clone = () => {
|
|
1099
1172
|
let F = new Monom();
|
|
1100
1173
|
F.coefficient = this._coefficient.clone();
|
|
1101
1174
|
for (let k in this._literal) {
|
|
1102
|
-
F.setLetter(k, this._literal[k]);
|
|
1175
|
+
F.setLetter(k, this._literal[k].clone());
|
|
1103
1176
|
}
|
|
1104
1177
|
return F;
|
|
1105
1178
|
};
|
|
1179
|
+
makeSame = (M) => {
|
|
1180
|
+
for (let k in M._literal) {
|
|
1181
|
+
this.setLetter(k, M._literal[k].clone());
|
|
1182
|
+
}
|
|
1183
|
+
return this;
|
|
1184
|
+
};
|
|
1106
1185
|
zero = () => {
|
|
1107
|
-
this._coefficient = new
|
|
1186
|
+
this._coefficient = new coefficients_1.Fraction().zero();
|
|
1108
1187
|
this._literal = {};
|
|
1109
1188
|
return this;
|
|
1110
1189
|
};
|
|
1111
1190
|
one = () => {
|
|
1112
|
-
this._coefficient = new
|
|
1191
|
+
this._coefficient = new coefficients_1.Fraction().one();
|
|
1113
1192
|
this._literal = {};
|
|
1114
1193
|
return this;
|
|
1115
1194
|
};
|
|
1116
1195
|
clean = () => {
|
|
1117
1196
|
for (let letter in this._literal) {
|
|
1118
|
-
if (this._literal[letter]
|
|
1197
|
+
if (this._literal[letter].isZero()) {
|
|
1119
1198
|
delete this._literal[letter];
|
|
1120
1199
|
}
|
|
1121
1200
|
}
|
|
@@ -1128,6 +1207,9 @@ class Monom {
|
|
|
1128
1207
|
add = (...M) => {
|
|
1129
1208
|
for (let m of M) {
|
|
1130
1209
|
if (this.isSameAs(m)) {
|
|
1210
|
+
if (this.isZero()) {
|
|
1211
|
+
this.makeSame(m);
|
|
1212
|
+
}
|
|
1131
1213
|
this._coefficient.add(m.coefficient);
|
|
1132
1214
|
}
|
|
1133
1215
|
else {
|
|
@@ -1139,7 +1221,10 @@ class Monom {
|
|
|
1139
1221
|
subtract = (...M) => {
|
|
1140
1222
|
for (let m of M) {
|
|
1141
1223
|
if (this.isSameAs(m)) {
|
|
1142
|
-
this.
|
|
1224
|
+
if (this.isZero()) {
|
|
1225
|
+
this.makeSame(m);
|
|
1226
|
+
}
|
|
1227
|
+
this._coefficient.add(m.clone().coefficient.opposed());
|
|
1143
1228
|
}
|
|
1144
1229
|
else {
|
|
1145
1230
|
console.log('Subtract: Is not similar: ', m.display);
|
|
@@ -1151,7 +1236,12 @@ class Monom {
|
|
|
1151
1236
|
for (let m of M) {
|
|
1152
1237
|
this._coefficient.multiply(m.coefficient);
|
|
1153
1238
|
for (let letter in m.literal) {
|
|
1154
|
-
|
|
1239
|
+
if (this._literal[letter] === undefined) {
|
|
1240
|
+
this._literal[letter] = m.literal[letter].clone();
|
|
1241
|
+
}
|
|
1242
|
+
else {
|
|
1243
|
+
this._literal[letter].add(m.literal[letter]);
|
|
1244
|
+
}
|
|
1155
1245
|
}
|
|
1156
1246
|
}
|
|
1157
1247
|
return this;
|
|
@@ -1164,8 +1254,8 @@ class Monom {
|
|
|
1164
1254
|
for (let v of M) {
|
|
1165
1255
|
this._coefficient.divide(v.coefficient);
|
|
1166
1256
|
for (let letter in v.literal) {
|
|
1167
|
-
this._literal[letter] = (this._literal[letter] === undefined) ?
|
|
1168
|
-
if (this._literal[letter]
|
|
1257
|
+
this._literal[letter] = (this._literal[letter] === undefined) ? v.literal[letter].clone().opposed() : this._literal[letter].subtract(v.literal[letter]);
|
|
1258
|
+
if (this._literal[letter].isZero()) {
|
|
1169
1259
|
delete this._literal[letter];
|
|
1170
1260
|
}
|
|
1171
1261
|
}
|
|
@@ -1175,7 +1265,7 @@ class Monom {
|
|
|
1175
1265
|
pow = (nb) => {
|
|
1176
1266
|
this._coefficient.pow(nb);
|
|
1177
1267
|
for (let letter in this._literal) {
|
|
1178
|
-
this._literal[letter]
|
|
1268
|
+
this._literal[letter].pow(nb);
|
|
1179
1269
|
}
|
|
1180
1270
|
return this;
|
|
1181
1271
|
};
|
|
@@ -1186,7 +1276,7 @@ class Monom {
|
|
|
1186
1276
|
if (this.isSquare()) {
|
|
1187
1277
|
this._coefficient.sqrt();
|
|
1188
1278
|
for (let letter in this._literal) {
|
|
1189
|
-
this._literal[letter]
|
|
1279
|
+
this._literal[letter].clone().divide(2);
|
|
1190
1280
|
}
|
|
1191
1281
|
}
|
|
1192
1282
|
return this.root(2);
|
|
@@ -1203,12 +1293,14 @@ class Monom {
|
|
|
1203
1293
|
return this._coefficient.isEqual(M.coefficient);
|
|
1204
1294
|
case 'same':
|
|
1205
1295
|
let M1 = this.variables, M2 = M.variables, K = M1.concat(M2.filter((item) => M1.indexOf(item) < 0));
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1296
|
+
if (!this.isZero() && !M.isZero()) {
|
|
1297
|
+
for (let key of K) {
|
|
1298
|
+
if (this._literal[key] === undefined || M.literal[key] === undefined) {
|
|
1299
|
+
return false;
|
|
1300
|
+
}
|
|
1301
|
+
if (!this._literal[key].isEqual(M.literal[key])) {
|
|
1302
|
+
return false;
|
|
1303
|
+
}
|
|
1212
1304
|
}
|
|
1213
1305
|
}
|
|
1214
1306
|
return true;
|
|
@@ -1232,53 +1324,68 @@ class Monom {
|
|
|
1232
1324
|
if (!this.coefficient.isSquare()) {
|
|
1233
1325
|
return false;
|
|
1234
1326
|
}
|
|
1235
|
-
return this.
|
|
1327
|
+
return this.isLiteralSquare();
|
|
1236
1328
|
};
|
|
1237
|
-
|
|
1329
|
+
isLiteralSquare = () => {
|
|
1238
1330
|
for (let letter in this.literal) {
|
|
1239
|
-
if (this.literal[letter]
|
|
1331
|
+
if (this.literal[letter].isRational()) {
|
|
1332
|
+
return false;
|
|
1333
|
+
}
|
|
1334
|
+
if (this.literal[letter].isEven()) {
|
|
1240
1335
|
return false;
|
|
1241
1336
|
}
|
|
1242
1337
|
}
|
|
1243
1338
|
return true;
|
|
1244
1339
|
};
|
|
1340
|
+
hasFractionCoefficient = () => {
|
|
1341
|
+
for (let letter in this._literal) {
|
|
1342
|
+
if (this._literal[letter].isRational()) {
|
|
1343
|
+
return true;
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
return false;
|
|
1347
|
+
};
|
|
1245
1348
|
hasLetter = (letter) => {
|
|
1246
|
-
|
|
1349
|
+
if (this._literal[letter === undefined ? 'x' : letter] === undefined) {
|
|
1350
|
+
return false;
|
|
1351
|
+
}
|
|
1352
|
+
return this._literal[letter === undefined ? 'x' : letter].isNotZero();
|
|
1247
1353
|
};
|
|
1248
1354
|
setLetter = (letter, pow) => {
|
|
1249
|
-
if (pow
|
|
1250
|
-
if (this.
|
|
1355
|
+
if (pow instanceof coefficients_1.Fraction) {
|
|
1356
|
+
if (this.hasLetter(letter) && pow.isZero()) {
|
|
1251
1357
|
delete this._literal[letter];
|
|
1252
1358
|
}
|
|
1359
|
+
this._literal[letter] = pow.clone();
|
|
1253
1360
|
}
|
|
1254
1361
|
else {
|
|
1255
|
-
this.
|
|
1362
|
+
this.setLetter(letter, new coefficients_1.Fraction(pow));
|
|
1256
1363
|
}
|
|
1257
1364
|
};
|
|
1258
1365
|
degree = (letter) => {
|
|
1259
1366
|
if (this.variables.length === 0) {
|
|
1260
|
-
return
|
|
1367
|
+
return new coefficients_1.Fraction().zero();
|
|
1261
1368
|
}
|
|
1262
1369
|
if (letter === undefined) {
|
|
1263
|
-
return Object.values(this._literal).reduce((t, n) => t
|
|
1370
|
+
return Object.values(this._literal).reduce((t, n) => t.clone().add(n));
|
|
1264
1371
|
}
|
|
1265
1372
|
else {
|
|
1266
|
-
return this._literal[letter] === undefined ?
|
|
1373
|
+
return this._literal[letter] === undefined ? new coefficients_1.Fraction().zero() : this._literal[letter].clone();
|
|
1267
1374
|
}
|
|
1268
1375
|
};
|
|
1269
1376
|
evaluate = (values) => {
|
|
1270
1377
|
let r = this.coefficient.clone();
|
|
1271
|
-
if (typeof values === 'number' || values instanceof
|
|
1378
|
+
if (typeof values === 'number' || values instanceof coefficients_1.Fraction) {
|
|
1272
1379
|
let tmpValues = {};
|
|
1273
|
-
tmpValues[this.variables[0]] = new
|
|
1380
|
+
tmpValues[this.variables[0]] = new coefficients_1.Fraction(values);
|
|
1274
1381
|
return this.evaluate(tmpValues);
|
|
1275
1382
|
}
|
|
1276
1383
|
if (typeof values === 'object') {
|
|
1277
1384
|
for (let L in this._literal) {
|
|
1278
1385
|
if (values[L] === undefined) {
|
|
1279
|
-
return new
|
|
1386
|
+
return new coefficients_1.Fraction().zero();
|
|
1280
1387
|
}
|
|
1281
|
-
let value = new
|
|
1388
|
+
let value = new coefficients_1.Fraction(values[L]);
|
|
1282
1389
|
r.multiply(value.pow(this._literal[L]));
|
|
1283
1390
|
}
|
|
1284
1391
|
}
|
|
@@ -1289,9 +1396,9 @@ class Monom {
|
|
|
1289
1396
|
letter = 'x';
|
|
1290
1397
|
}
|
|
1291
1398
|
if (this.hasLetter(letter)) {
|
|
1292
|
-
let d =
|
|
1293
|
-
dM._literal[letter]
|
|
1294
|
-
dM._coefficient.multiply(new
|
|
1399
|
+
let d = this._literal[letter].clone(), dM = this.clone();
|
|
1400
|
+
dM._literal[letter].subtract(1);
|
|
1401
|
+
dM._coefficient.multiply(new coefficients_1.Fraction(d.clone()));
|
|
1295
1402
|
return dM;
|
|
1296
1403
|
}
|
|
1297
1404
|
else {
|
|
@@ -1302,34 +1409,40 @@ class Monom {
|
|
|
1302
1409
|
if (letter === undefined) {
|
|
1303
1410
|
letter = 'x';
|
|
1304
1411
|
}
|
|
1305
|
-
let M = this.clone();
|
|
1412
|
+
let M = this.clone(), degree;
|
|
1306
1413
|
if (M.hasLetter(letter)) {
|
|
1307
|
-
|
|
1308
|
-
M.
|
|
1414
|
+
degree = M.degree(letter).clone().add(1);
|
|
1415
|
+
M.coefficient = M.coefficient.clone().divide(degree);
|
|
1416
|
+
M.setLetter(letter, degree);
|
|
1309
1417
|
}
|
|
1310
1418
|
else {
|
|
1311
1419
|
if (M.coefficient.isZero()) {
|
|
1312
|
-
M.coefficient = new
|
|
1420
|
+
M.coefficient = new coefficients_1.Fraction().one();
|
|
1313
1421
|
}
|
|
1314
1422
|
M.setLetter(letter, 1);
|
|
1315
1423
|
}
|
|
1316
1424
|
return M;
|
|
1317
1425
|
};
|
|
1318
1426
|
static lcm = (...monoms) => {
|
|
1319
|
-
|
|
1320
|
-
|
|
1427
|
+
for (let m of monoms) {
|
|
1428
|
+
if (m.hasFractionCoefficient()) {
|
|
1429
|
+
return new Monom().zero();
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
let M = new Monom(), coeffN = monoms.map(value => value.coefficient.numerator), coeffD = monoms.map(value => value.coefficient.denominator), n = numeric_1.Numeric.gcd(...coeffN), d = numeric_1.Numeric.lcm(...coeffD);
|
|
1433
|
+
M.coefficient = new coefficients_1.Fraction(n, d).reduce();
|
|
1321
1434
|
for (let m of monoms) {
|
|
1322
1435
|
for (let letter in M.literal) {
|
|
1323
1436
|
if (!(letter in m.literal)) {
|
|
1324
|
-
M.literal[letter]
|
|
1437
|
+
M.literal[letter].zero();
|
|
1325
1438
|
}
|
|
1326
1439
|
}
|
|
1327
1440
|
for (let letter in m.literal) {
|
|
1328
|
-
if (M.literal[letter] === undefined && m.literal[letter]
|
|
1329
|
-
M.literal[letter] = m.literal[letter];
|
|
1441
|
+
if (M.literal[letter] === undefined && m.literal[letter].isStrictlyPositive()) {
|
|
1442
|
+
M.literal[letter] = m.literal[letter].clone();
|
|
1330
1443
|
}
|
|
1331
1444
|
else {
|
|
1332
|
-
M.literal[letter] = Math.min(m.literal[letter], M.literal[letter]);
|
|
1445
|
+
M.literal[letter] = new coefficients_1.Fraction(Math.min(m.literal[letter].value, M.literal[letter].value));
|
|
1333
1446
|
}
|
|
1334
1447
|
}
|
|
1335
1448
|
}
|
|
@@ -1363,6 +1476,7 @@ class Monom {
|
|
|
1363
1476
|
return true;
|
|
1364
1477
|
};
|
|
1365
1478
|
}
|
|
1479
|
+
exports.Monom = Monom;
|
|
1366
1480
|
|
|
1367
1481
|
|
|
1368
1482
|
/***/ }),
|
|
@@ -1371,22 +1485,15 @@ class Monom {
|
|
|
1371
1485
|
/*!**************************************!*\
|
|
1372
1486
|
!*** ./src/maths/algebra/polynom.ts ***!
|
|
1373
1487
|
\**************************************/
|
|
1374
|
-
/***/ ((__unused_webpack_module,
|
|
1488
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1375
1489
|
|
|
1376
|
-
__webpack_require__.r(__webpack_exports__);
|
|
1377
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1378
|
-
/* harmony export */ "default": () => (/* binding */ Polynom)
|
|
1379
|
-
/* harmony export */ });
|
|
1380
|
-
/* harmony import */ var _monom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./monom */ "./src/maths/algebra/monom.ts");
|
|
1381
|
-
/* harmony import */ var _shutingyard__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../shutingyard */ "./src/maths/shutingyard.ts");
|
|
1382
|
-
/* harmony import */ var _numeric__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
1383
|
-
/* harmony import */ var _random_random__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../random/random */ "./src/maths/random/random.ts");
|
|
1384
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
1490
|
|
|
1491
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1492
|
+
exports.Polynom = void 0;
|
|
1493
|
+
const monom_1 = __webpack_require__(/*! ./monom */ "./src/maths/algebra/monom.ts");
|
|
1494
|
+
const shutingyard_1 = __webpack_require__(/*! ../shutingyard */ "./src/maths/shutingyard.ts");
|
|
1495
|
+
const numeric_1 = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
1496
|
+
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
1390
1497
|
class Polynom {
|
|
1391
1498
|
_rawString;
|
|
1392
1499
|
_monoms;
|
|
@@ -1400,10 +1507,6 @@ class Polynom {
|
|
|
1400
1507
|
}
|
|
1401
1508
|
return this;
|
|
1402
1509
|
}
|
|
1403
|
-
get isPolynom() {
|
|
1404
|
-
return true;
|
|
1405
|
-
}
|
|
1406
|
-
;
|
|
1407
1510
|
get monoms() {
|
|
1408
1511
|
return this._monoms;
|
|
1409
1512
|
}
|
|
@@ -1491,9 +1594,7 @@ class Polynom {
|
|
|
1491
1594
|
this._rawString = inputStr;
|
|
1492
1595
|
if (inputStr !== '' && !isNaN(Number(inputStr))) {
|
|
1493
1596
|
this.empty();
|
|
1494
|
-
let m = new
|
|
1495
|
-
m.coefficient = new _coefficients_fraction__WEBPACK_IMPORTED_MODULE_4__["default"](inputStr);
|
|
1496
|
-
m.literalStr = '';
|
|
1597
|
+
let m = new monom_1.Monom(inputStr);
|
|
1497
1598
|
this.add(m);
|
|
1498
1599
|
return this;
|
|
1499
1600
|
}
|
|
@@ -1501,11 +1602,11 @@ class Polynom {
|
|
|
1501
1602
|
}
|
|
1502
1603
|
else if (/^[a-z]/.test(inputStr)) {
|
|
1503
1604
|
this.empty();
|
|
1504
|
-
let fractions = values.map(x => new
|
|
1605
|
+
let fractions = values.map(x => new coefficients_1.Fraction(x));
|
|
1505
1606
|
if (inputStr.length > 1) {
|
|
1506
1607
|
let letters = inputStr.split(''), i = 0;
|
|
1507
1608
|
for (let F of fractions) {
|
|
1508
|
-
let m = new
|
|
1609
|
+
let m = new monom_1.Monom();
|
|
1509
1610
|
m.coefficient = F.clone();
|
|
1510
1611
|
m.literalStr = letters[i] || '';
|
|
1511
1612
|
this.add(m);
|
|
@@ -1515,7 +1616,7 @@ class Polynom {
|
|
|
1515
1616
|
else {
|
|
1516
1617
|
let n = fractions.length - 1;
|
|
1517
1618
|
for (let F of fractions) {
|
|
1518
|
-
let m = new
|
|
1619
|
+
let m = new monom_1.Monom();
|
|
1519
1620
|
m.coefficient = F.clone();
|
|
1520
1621
|
m.literalStr = `${inputStr}^${n}`;
|
|
1521
1622
|
this.add(m);
|
|
@@ -1529,7 +1630,7 @@ class Polynom {
|
|
|
1529
1630
|
}
|
|
1530
1631
|
};
|
|
1531
1632
|
shutingYardToReducedPolynom = (inputStr) => {
|
|
1532
|
-
const SY = new
|
|
1633
|
+
const SY = new shutingyard_1.Shutingyard().parse(inputStr);
|
|
1533
1634
|
const rpn = SY.rpn;
|
|
1534
1635
|
let m1;
|
|
1535
1636
|
let m2;
|
|
@@ -1537,7 +1638,7 @@ class Polynom {
|
|
|
1537
1638
|
for (const element of rpn) {
|
|
1538
1639
|
if (element.tokenType === 'coefficient' || element.tokenType === 'variable') {
|
|
1539
1640
|
tempPolynom = new Polynom().zero();
|
|
1540
|
-
tempPolynom.monoms = [new
|
|
1641
|
+
tempPolynom.monoms = [new monom_1.Monom(element.token)];
|
|
1541
1642
|
stack.push(tempPolynom.clone());
|
|
1542
1643
|
}
|
|
1543
1644
|
else if (element.tokenType === 'operation') {
|
|
@@ -1573,13 +1674,13 @@ class Polynom {
|
|
|
1573
1674
|
};
|
|
1574
1675
|
zero = () => {
|
|
1575
1676
|
this._monoms = [];
|
|
1576
|
-
this._monoms.push(new
|
|
1677
|
+
this._monoms.push(new monom_1.Monom().zero());
|
|
1577
1678
|
this._rawString = '0';
|
|
1578
1679
|
return this;
|
|
1579
1680
|
};
|
|
1580
1681
|
one = () => {
|
|
1581
1682
|
this._monoms = [];
|
|
1582
|
-
this._monoms.push(new
|
|
1683
|
+
this._monoms.push(new monom_1.Monom().one());
|
|
1583
1684
|
this._rawString = '1';
|
|
1584
1685
|
return this;
|
|
1585
1686
|
};
|
|
@@ -1588,96 +1689,52 @@ class Polynom {
|
|
|
1588
1689
|
this._rawString = '';
|
|
1589
1690
|
return this;
|
|
1590
1691
|
};
|
|
1591
|
-
_randomizeDefaults = {
|
|
1592
|
-
degree: 2,
|
|
1593
|
-
unit: true,
|
|
1594
|
-
fractions: false,
|
|
1595
|
-
factorable: false,
|
|
1596
|
-
letters: 'x',
|
|
1597
|
-
allowNullMonom: false,
|
|
1598
|
-
numberOfMonoms: false
|
|
1599
|
-
};
|
|
1600
|
-
get randomizeDefaults() {
|
|
1601
|
-
return this._randomizeDefaults;
|
|
1602
|
-
}
|
|
1603
|
-
set randomizeDefaults(value) {
|
|
1604
|
-
this._randomizeDefaults = value;
|
|
1605
|
-
}
|
|
1606
|
-
randomize = (config) => {
|
|
1607
|
-
let P = new Polynom();
|
|
1608
|
-
if (config === undefined) {
|
|
1609
|
-
config = {};
|
|
1610
|
-
}
|
|
1611
|
-
for (let k in this._randomizeDefaults) {
|
|
1612
|
-
if (config[k] === undefined) {
|
|
1613
|
-
config[k] = this._randomizeDefaults[k];
|
|
1614
|
-
}
|
|
1615
|
-
}
|
|
1616
|
-
return P;
|
|
1617
|
-
};
|
|
1618
|
-
rndFactorable = (degree = 2, unit = false, letters = 'x') => {
|
|
1619
|
-
this._factors = [];
|
|
1620
|
-
for (let i = 0; i < degree; i++) {
|
|
1621
|
-
let factorUnit = unit === true || i >= unit, p = _random_random__WEBPACK_IMPORTED_MODULE_3__.Random.polynom({
|
|
1622
|
-
degree: 1,
|
|
1623
|
-
unit: factorUnit,
|
|
1624
|
-
fraction: false,
|
|
1625
|
-
letters
|
|
1626
|
-
});
|
|
1627
|
-
this._factors.push(p);
|
|
1628
|
-
}
|
|
1629
|
-
this.empty().monoms = this._factors[0].monoms;
|
|
1630
|
-
for (let i = 1; i < this._factors.length; i++) {
|
|
1631
|
-
this.multiply(this._factors[i]);
|
|
1632
|
-
}
|
|
1633
|
-
return this;
|
|
1634
|
-
};
|
|
1635
1692
|
opposed = () => {
|
|
1636
1693
|
this._monoms = this._monoms.map(m => m.opposed());
|
|
1637
1694
|
return this;
|
|
1638
1695
|
};
|
|
1639
1696
|
add = (...values) => {
|
|
1640
1697
|
for (let value of values) {
|
|
1641
|
-
if (value
|
|
1698
|
+
if (value instanceof Polynom) {
|
|
1642
1699
|
this._monoms = this._monoms.concat(value.monoms);
|
|
1643
1700
|
}
|
|
1644
|
-
else if (value.
|
|
1701
|
+
else if (value instanceof monom_1.Monom) {
|
|
1645
1702
|
this._monoms.push(value.clone());
|
|
1646
1703
|
}
|
|
1647
1704
|
else if (Number.isSafeInteger(value)) {
|
|
1648
|
-
this._monoms.push(new
|
|
1705
|
+
this._monoms.push(new monom_1.Monom(value.toString()));
|
|
1649
1706
|
}
|
|
1650
1707
|
else {
|
|
1651
|
-
this._monoms.push(new
|
|
1708
|
+
this._monoms.push(new monom_1.Monom(value));
|
|
1652
1709
|
}
|
|
1653
1710
|
}
|
|
1654
1711
|
return this.reduce();
|
|
1655
1712
|
};
|
|
1656
1713
|
subtract = (...values) => {
|
|
1657
1714
|
for (let value of values) {
|
|
1658
|
-
if (value
|
|
1715
|
+
if (value instanceof Polynom) {
|
|
1659
1716
|
this._monoms = this._monoms.concat(value.clone().opposed().monoms);
|
|
1660
1717
|
}
|
|
1661
|
-
else if (value.
|
|
1718
|
+
else if (value instanceof monom_1.Monom) {
|
|
1662
1719
|
this._monoms.push(value.clone().opposed());
|
|
1663
1720
|
}
|
|
1664
1721
|
else if (Number.isSafeInteger(value)) {
|
|
1665
|
-
this._monoms.push(new
|
|
1722
|
+
this._monoms.push(new monom_1.Monom(value.toString()).opposed());
|
|
1666
1723
|
}
|
|
1667
1724
|
else {
|
|
1668
|
-
this._monoms.push(new
|
|
1725
|
+
this._monoms.push(new monom_1.Monom(value).opposed());
|
|
1669
1726
|
}
|
|
1670
1727
|
}
|
|
1671
1728
|
return this.reduce();
|
|
1672
1729
|
};
|
|
1673
1730
|
multiply = (value) => {
|
|
1674
|
-
if (value
|
|
1731
|
+
if (value instanceof Polynom) {
|
|
1675
1732
|
return this.multiplyByPolynom(value);
|
|
1676
1733
|
}
|
|
1677
|
-
else if (value.
|
|
1734
|
+
else if (value instanceof coefficients_1.Fraction) {
|
|
1678
1735
|
return this.multiplyByFraction(value);
|
|
1679
1736
|
}
|
|
1680
|
-
else if (value.
|
|
1737
|
+
else if (value instanceof monom_1.Monom) {
|
|
1681
1738
|
return this.multiplyByMonom(value);
|
|
1682
1739
|
}
|
|
1683
1740
|
else if (Number.isSafeInteger(value)) {
|
|
@@ -1689,7 +1746,7 @@ class Polynom {
|
|
|
1689
1746
|
const M = [];
|
|
1690
1747
|
for (const m1 of this._monoms) {
|
|
1691
1748
|
for (const m2 of P.monoms) {
|
|
1692
|
-
M.push(
|
|
1749
|
+
M.push(monom_1.Monom.xmultiply(m1, m2));
|
|
1693
1750
|
}
|
|
1694
1751
|
}
|
|
1695
1752
|
this._monoms = M;
|
|
@@ -1702,7 +1759,7 @@ class Polynom {
|
|
|
1702
1759
|
return this.reduce();
|
|
1703
1760
|
};
|
|
1704
1761
|
multiplyByInteger = (nb) => {
|
|
1705
|
-
return this.multiplyByFraction(new
|
|
1762
|
+
return this.multiplyByFraction(new coefficients_1.Fraction(nb));
|
|
1706
1763
|
};
|
|
1707
1764
|
multiplyByMonom = (M) => {
|
|
1708
1765
|
for (const m of this._monoms) {
|
|
@@ -1720,9 +1777,9 @@ class Polynom {
|
|
|
1720
1777
|
const maxMP = P.monomByDegree(undefined, letter);
|
|
1721
1778
|
const degreeP = P.degree(letter);
|
|
1722
1779
|
let newM;
|
|
1723
|
-
let MaxIteration = this.degree(letter)
|
|
1724
|
-
while (reminder.degree(letter) >= degreeP && MaxIteration
|
|
1725
|
-
MaxIteration
|
|
1780
|
+
let MaxIteration = this.degree(letter).clone().multiply(2);
|
|
1781
|
+
while (reminder.degree(letter) >= degreeP && MaxIteration.isPositive()) {
|
|
1782
|
+
MaxIteration.subtract(1);
|
|
1726
1783
|
newM = reminder.monomByDegree(undefined, letter).clone().divide(maxMP);
|
|
1727
1784
|
if (newM.isZero()) {
|
|
1728
1785
|
break;
|
|
@@ -1741,7 +1798,7 @@ class Polynom {
|
|
|
1741
1798
|
}
|
|
1742
1799
|
};
|
|
1743
1800
|
divideByInteger = (nb) => {
|
|
1744
|
-
const nbF = new
|
|
1801
|
+
const nbF = new coefficients_1.Fraction(nb);
|
|
1745
1802
|
for (const m of this._monoms) {
|
|
1746
1803
|
m.coefficient.divide(nbF);
|
|
1747
1804
|
}
|
|
@@ -1777,7 +1834,7 @@ class Polynom {
|
|
|
1777
1834
|
const cP2 = P.clone().reduce().reorder();
|
|
1778
1835
|
switch (sign) {
|
|
1779
1836
|
case '=':
|
|
1780
|
-
if (cP1.length !== cP2.length || cP1.degree()
|
|
1837
|
+
if (cP1.length !== cP2.length || cP1.degree().isNotEqual(cP2.degree())) {
|
|
1781
1838
|
return false;
|
|
1782
1839
|
}
|
|
1783
1840
|
for (const i in cP1.monoms) {
|
|
@@ -1901,14 +1958,14 @@ class Polynom {
|
|
|
1901
1958
|
};
|
|
1902
1959
|
reorder = (letter = 'x') => {
|
|
1903
1960
|
this._monoms.sort(function (a, b) {
|
|
1904
|
-
return b.degree(letter)
|
|
1961
|
+
return b.degree(letter).clone().subtract(a.degree(letter)).value;
|
|
1905
1962
|
});
|
|
1906
1963
|
return this.reduce();
|
|
1907
1964
|
};
|
|
1908
1965
|
degree = (letter) => {
|
|
1909
|
-
let d =
|
|
1966
|
+
let d = new coefficients_1.Fraction().zero();
|
|
1910
1967
|
for (const m of this._monoms) {
|
|
1911
|
-
d =
|
|
1968
|
+
d = coefficients_1.Fraction.max(m.degree(letter).value, d);
|
|
1912
1969
|
}
|
|
1913
1970
|
return d;
|
|
1914
1971
|
};
|
|
@@ -1923,7 +1980,7 @@ class Polynom {
|
|
|
1923
1980
|
let pow;
|
|
1924
1981
|
const resultPolynom = new Polynom().zero();
|
|
1925
1982
|
for (const m of this.monoms) {
|
|
1926
|
-
if (m.literal[letter] === undefined || m.literal[letter]
|
|
1983
|
+
if (m.literal[letter] === undefined || m.literal[letter].isZero()) {
|
|
1927
1984
|
resultPolynom.add(m.clone());
|
|
1928
1985
|
}
|
|
1929
1986
|
else {
|
|
@@ -1936,7 +1993,7 @@ class Polynom {
|
|
|
1936
1993
|
return this;
|
|
1937
1994
|
};
|
|
1938
1995
|
evaluate = (values) => {
|
|
1939
|
-
const r = new
|
|
1996
|
+
const r = new coefficients_1.Fraction().zero();
|
|
1940
1997
|
this._monoms.forEach(monom => {
|
|
1941
1998
|
r.add(monom.evaluate(values));
|
|
1942
1999
|
});
|
|
@@ -1962,59 +2019,10 @@ class Polynom {
|
|
|
1962
2019
|
letter = 'x';
|
|
1963
2020
|
}
|
|
1964
2021
|
let valuesA = {}, valuesB = {};
|
|
1965
|
-
valuesA[letter] = a;
|
|
1966
|
-
valuesB[letter] = b;
|
|
2022
|
+
valuesA[letter] = new coefficients_1.Fraction(a);
|
|
2023
|
+
valuesB[letter] = new coefficients_1.Fraction(b);
|
|
1967
2024
|
return primitive.evaluate(valuesB).subtract(primitive.evaluate(valuesA));
|
|
1968
2025
|
};
|
|
1969
|
-
factorize_OLD = (maxValue) => {
|
|
1970
|
-
this._factors = [];
|
|
1971
|
-
let P = this.clone(), nbFactorsFound = 0;
|
|
1972
|
-
if (P.monomByDegree().coefficient.numerator < 0) {
|
|
1973
|
-
this._factors.push(new Polynom('-1'));
|
|
1974
|
-
}
|
|
1975
|
-
let M = P.commonMonom();
|
|
1976
|
-
if (!M.isOne()) {
|
|
1977
|
-
let commonPolynom = new Polynom();
|
|
1978
|
-
commonPolynom.monoms = [M];
|
|
1979
|
-
if (this._factors.length === 0) {
|
|
1980
|
-
this._factors.push(commonPolynom);
|
|
1981
|
-
}
|
|
1982
|
-
else {
|
|
1983
|
-
this._factors = [];
|
|
1984
|
-
this._factors.push(commonPolynom.opposed());
|
|
1985
|
-
}
|
|
1986
|
-
P = P.euclidian(commonPolynom).quotient;
|
|
1987
|
-
nbFactorsFound = commonPolynom.degree();
|
|
1988
|
-
}
|
|
1989
|
-
if (P.degree() <= 1) {
|
|
1990
|
-
this._factors.push(P.clone());
|
|
1991
|
-
}
|
|
1992
|
-
else {
|
|
1993
|
-
let Q = new _coefficients_fraction__WEBPACK_IMPORTED_MODULE_4__["default"](), F, degree = P.degree();
|
|
1994
|
-
maxValue = maxValue === undefined ? 20 : maxValue;
|
|
1995
|
-
for (let a = 1; a <= maxValue; a++) {
|
|
1996
|
-
for (let b = -maxValue; b <= maxValue; b++) {
|
|
1997
|
-
Q.parse(-b, a);
|
|
1998
|
-
if (P.evaluate({ x: Q })) {
|
|
1999
|
-
F = new Polynom(`${a}x+${b}`);
|
|
2000
|
-
while (P.evaluate({ x: Q }).value === 0) {
|
|
2001
|
-
this._factors.push(F.clone());
|
|
2002
|
-
nbFactorsFound++;
|
|
2003
|
-
P = P.euclidian(F).quotient;
|
|
2004
|
-
}
|
|
2005
|
-
}
|
|
2006
|
-
if (nbFactorsFound > degree) {
|
|
2007
|
-
return this;
|
|
2008
|
-
}
|
|
2009
|
-
}
|
|
2010
|
-
}
|
|
2011
|
-
if (P.degree() > 1) {
|
|
2012
|
-
this._factors.push(P.clone());
|
|
2013
|
-
return this;
|
|
2014
|
-
}
|
|
2015
|
-
}
|
|
2016
|
-
return this;
|
|
2017
|
-
};
|
|
2018
2026
|
factorize = (letter) => {
|
|
2019
2027
|
let factors = [];
|
|
2020
2028
|
let P = this.clone().reorder(), M = P.commonMonom(), tempPolynom;
|
|
@@ -2024,7 +2032,7 @@ class Polynom {
|
|
|
2024
2032
|
factors = [tempPolynom.clone()];
|
|
2025
2033
|
P = P.euclidian(tempPolynom).quotient;
|
|
2026
2034
|
}
|
|
2027
|
-
let securityLoop = P.degree()
|
|
2035
|
+
let securityLoop = P.degree().clone().multiply(2).value;
|
|
2028
2036
|
while (securityLoop >= 0) {
|
|
2029
2037
|
securityLoop--;
|
|
2030
2038
|
if (P.monoms.length < 2) {
|
|
@@ -2107,14 +2115,14 @@ class Polynom {
|
|
|
2107
2115
|
a = this.monomByDegree(2, letter);
|
|
2108
2116
|
b = this.monomByDegree(1, letter);
|
|
2109
2117
|
c = this.monomByDegree(0, letter);
|
|
2110
|
-
if (a.
|
|
2118
|
+
if (a.isLiteralSquare() && c.isLiteralSquare()) {
|
|
2111
2119
|
if (b.clone().pow(2).isSameAs(a.clone().multiply(c))) {
|
|
2112
2120
|
let xPolynom = new Polynom('x', a.coefficient, b.coefficient, c.coefficient);
|
|
2113
2121
|
let xFactors = xPolynom._factorize2ndDegree('x');
|
|
2114
2122
|
let factors = [], xyzPolynom;
|
|
2115
2123
|
if (xFactors.length >= 2) {
|
|
2116
2124
|
for (let p of xFactors) {
|
|
2117
|
-
if (p.degree()
|
|
2125
|
+
if (p.degree().isZero()) {
|
|
2118
2126
|
factors.push(p.clone());
|
|
2119
2127
|
}
|
|
2120
2128
|
else {
|
|
@@ -2136,7 +2144,7 @@ class Polynom {
|
|
|
2136
2144
|
};
|
|
2137
2145
|
getZeroes = () => {
|
|
2138
2146
|
const Z = [];
|
|
2139
|
-
switch (this.degree()) {
|
|
2147
|
+
switch (this.degree().value) {
|
|
2140
2148
|
case 0:
|
|
2141
2149
|
if (this._monoms[0].coefficient.value === 0) {
|
|
2142
2150
|
return [true];
|
|
@@ -2146,7 +2154,7 @@ class Polynom {
|
|
|
2146
2154
|
}
|
|
2147
2155
|
case 1:
|
|
2148
2156
|
if (this._monoms.length === 1) {
|
|
2149
|
-
return [new
|
|
2157
|
+
return [new coefficients_1.Fraction().zero()];
|
|
2150
2158
|
}
|
|
2151
2159
|
else {
|
|
2152
2160
|
const P = this.clone().reduce().reorder();
|
|
@@ -2158,14 +2166,14 @@ class Polynom {
|
|
|
2158
2166
|
}
|
|
2159
2167
|
let zeroes = [], zeroesAsTex = [];
|
|
2160
2168
|
for (let P of this._factors) {
|
|
2161
|
-
if (P.degree()
|
|
2169
|
+
if (P.degree().greater(2)) {
|
|
2162
2170
|
}
|
|
2163
|
-
else if (P.degree() === 2) {
|
|
2171
|
+
else if (P.degree().value === 2) {
|
|
2164
2172
|
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));
|
|
2165
2173
|
if (D.value > 0) {
|
|
2166
2174
|
let x1 = (-(B.value) + Math.sqrt(D.value)) / (2 * A.value), x2 = (-(B.value) - Math.sqrt(D.value)) / (2 * A.value);
|
|
2167
|
-
zeroes.push(new
|
|
2168
|
-
zeroes.push(new
|
|
2175
|
+
zeroes.push(new coefficients_1.Fraction(x1.toFixed(3)).reduce());
|
|
2176
|
+
zeroes.push(new coefficients_1.Fraction(x2.toFixed(3)).reduce());
|
|
2169
2177
|
}
|
|
2170
2178
|
else if (D.value === 0) {
|
|
2171
2179
|
}
|
|
@@ -2195,11 +2203,11 @@ class Polynom {
|
|
|
2195
2203
|
}
|
|
2196
2204
|
const M = this.clone().reduce();
|
|
2197
2205
|
for (const m of M._monoms) {
|
|
2198
|
-
if (m.degree(letter)
|
|
2206
|
+
if (m.degree(letter).isEqual(degree)) {
|
|
2199
2207
|
return m.clone();
|
|
2200
2208
|
}
|
|
2201
2209
|
}
|
|
2202
|
-
return new
|
|
2210
|
+
return new monom_1.Monom().zero();
|
|
2203
2211
|
};
|
|
2204
2212
|
monomsByDegree = (degree, letter) => {
|
|
2205
2213
|
if (degree === undefined) {
|
|
@@ -2221,7 +2229,7 @@ class Polynom {
|
|
|
2221
2229
|
return m.clone();
|
|
2222
2230
|
}
|
|
2223
2231
|
}
|
|
2224
|
-
return new
|
|
2232
|
+
return new monom_1.Monom().zero();
|
|
2225
2233
|
};
|
|
2226
2234
|
getDenominators = () => {
|
|
2227
2235
|
const denominators = [];
|
|
@@ -2238,91 +2246,35 @@ class Polynom {
|
|
|
2238
2246
|
return numerators;
|
|
2239
2247
|
};
|
|
2240
2248
|
lcmDenominator = () => {
|
|
2241
|
-
return
|
|
2249
|
+
return numeric_1.Numeric.lcm(...this.getDenominators());
|
|
2242
2250
|
};
|
|
2243
2251
|
gcdDenominator = () => {
|
|
2244
|
-
return
|
|
2252
|
+
return numeric_1.Numeric.gcd(...this.getDenominators());
|
|
2245
2253
|
};
|
|
2246
2254
|
lcmNumerator = () => {
|
|
2247
|
-
return
|
|
2255
|
+
return numeric_1.Numeric.lcm(...this.getNumerators());
|
|
2248
2256
|
};
|
|
2249
2257
|
gcdNumerator = () => {
|
|
2250
|
-
return
|
|
2258
|
+
return numeric_1.Numeric.gcd(...this.getNumerators());
|
|
2251
2259
|
};
|
|
2252
2260
|
commonMonom = () => {
|
|
2253
|
-
let M = new
|
|
2261
|
+
let M = new monom_1.Monom().one(), numerator, denominator, degree = this.degree();
|
|
2254
2262
|
numerator = this.gcdNumerator();
|
|
2255
2263
|
denominator = this.gcdDenominator();
|
|
2256
|
-
M.coefficient = new
|
|
2264
|
+
M.coefficient = new coefficients_1.Fraction(numerator, denominator);
|
|
2257
2265
|
for (let L of this.variables) {
|
|
2258
2266
|
M.setLetter(L, degree);
|
|
2259
2267
|
for (let m of this._monoms) {
|
|
2260
|
-
M.setLetter(L,
|
|
2261
|
-
if (M.degree(L)
|
|
2268
|
+
M.setLetter(L, coefficients_1.Fraction.min(m.degree(L), M.degree(L)));
|
|
2269
|
+
if (M.degree(L).isZero()) {
|
|
2262
2270
|
break;
|
|
2263
2271
|
}
|
|
2264
2272
|
}
|
|
2265
2273
|
}
|
|
2266
2274
|
return M;
|
|
2267
2275
|
};
|
|
2268
|
-
makeItComplicate = (complexity = 1) => {
|
|
2269
|
-
this._texString = '';
|
|
2270
|
-
if (this.degree() < 1) {
|
|
2271
|
-
return this;
|
|
2272
|
-
}
|
|
2273
|
-
const mDegree = _random_random__WEBPACK_IMPORTED_MODULE_3__.Random.number(0, this.degree() - 1);
|
|
2274
|
-
return this;
|
|
2275
|
-
};
|
|
2276
|
-
factorizePartial = (forceSign) => {
|
|
2277
|
-
this._texString = '';
|
|
2278
|
-
if (this.length <= 1) {
|
|
2279
|
-
return this;
|
|
2280
|
-
}
|
|
2281
|
-
let mMain, mCheck, mFactor, pFactor, g, sign;
|
|
2282
|
-
for (let i = 0; i < this.length; i++) {
|
|
2283
|
-
mMain = this._monoms[i].clone();
|
|
2284
|
-
for (let j = i + 1; j < this.length; j++) {
|
|
2285
|
-
mCheck = this._monoms[j].clone();
|
|
2286
|
-
g = _numeric__WEBPACK_IMPORTED_MODULE_2__["default"].gcd(mMain.coefficient.numerator, mCheck.coefficient.numerator);
|
|
2287
|
-
if (g !== 1) {
|
|
2288
|
-
mFactor = _monom__WEBPACK_IMPORTED_MODULE_0__["default"].lcm(mMain, mCheck);
|
|
2289
|
-
sign = mMain.coefficient.sign() === 1 ? '+' : '-';
|
|
2290
|
-
this._texString = `${forceSign === true ? sign : (sign === '+' ? '' : sign)}${mFactor.tex}`;
|
|
2291
|
-
pFactor = new Polynom().add(mMain.divide(mFactor)).add(mCheck.divide(mFactor));
|
|
2292
|
-
this._texString += pFactor.genDisplay('tex', false, true);
|
|
2293
|
-
this._texString += this.clone().subtract(pFactor.clone().multiply(mFactor)).genDisplay('tex', true, false);
|
|
2294
|
-
return this;
|
|
2295
|
-
}
|
|
2296
|
-
}
|
|
2297
|
-
}
|
|
2298
|
-
this._texString = this.genDisplay('tex', forceSign);
|
|
2299
|
-
return this;
|
|
2300
|
-
};
|
|
2301
|
-
minify = () => {
|
|
2302
|
-
this.multiply(this.lcmDenominator()).divide(this.gcdNumerator()).reduce();
|
|
2303
|
-
return this.reduce();
|
|
2304
|
-
};
|
|
2305
|
-
canDivide = (P, letter = 'x') => {
|
|
2306
|
-
const d = P.degree();
|
|
2307
|
-
const evalValue = {};
|
|
2308
|
-
if (d === 0) {
|
|
2309
|
-
return !P.isZero;
|
|
2310
|
-
}
|
|
2311
|
-
if (d === 1) {
|
|
2312
|
-
const z = P.getZeroes();
|
|
2313
|
-
if (z[0] === true || z[0] === false) {
|
|
2314
|
-
return false;
|
|
2315
|
-
}
|
|
2316
|
-
evalValue[letter] = z[0];
|
|
2317
|
-
return this.evaluate(evalValue).value === 0;
|
|
2318
|
-
}
|
|
2319
|
-
if (d > 1) {
|
|
2320
|
-
console.log('Currently, only first degree polynom are supported');
|
|
2321
|
-
return false;
|
|
2322
|
-
}
|
|
2323
|
-
return false;
|
|
2324
|
-
};
|
|
2325
2276
|
}
|
|
2277
|
+
exports.Polynom = Polynom;
|
|
2326
2278
|
|
|
2327
2279
|
|
|
2328
2280
|
/***/ }),
|
|
@@ -2331,21 +2283,20 @@ class Polynom {
|
|
|
2331
2283
|
/*!***************************************!*\
|
|
2332
2284
|
!*** ./src/maths/algebra/rational.ts ***!
|
|
2333
2285
|
\***************************************/
|
|
2334
|
-
/***/ ((__unused_webpack_module,
|
|
2286
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2335
2287
|
|
|
2336
|
-
__webpack_require__.r(__webpack_exports__);
|
|
2337
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2338
|
-
/* harmony export */ "default": () => (/* binding */ Rational)
|
|
2339
|
-
/* harmony export */ });
|
|
2340
|
-
/* harmony import */ var _polynom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts");
|
|
2341
2288
|
|
|
2289
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2290
|
+
exports.Rational = void 0;
|
|
2291
|
+
const polynom_1 = __webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts");
|
|
2292
|
+
const fraction_1 = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
2342
2293
|
class Rational {
|
|
2343
2294
|
_rawString;
|
|
2344
2295
|
_numerator;
|
|
2345
2296
|
_denominator;
|
|
2346
2297
|
constructor(numerator, denominator) {
|
|
2347
|
-
this._numerator = numerator ? numerator.clone() : new
|
|
2348
|
-
this._denominator = denominator ? denominator.clone() : new
|
|
2298
|
+
this._numerator = numerator ? numerator.clone() : new polynom_1.Polynom();
|
|
2299
|
+
this._denominator = denominator ? denominator.clone() : new polynom_1.Polynom();
|
|
2349
2300
|
}
|
|
2350
2301
|
clone = () => {
|
|
2351
2302
|
this._numerator = this._numerator.clone();
|
|
@@ -2426,21 +2377,22 @@ class Rational {
|
|
|
2426
2377
|
if (value === Infinity || value === -Infinity) {
|
|
2427
2378
|
let N = this._numerator.monomByDegree(this._numerator.degree(letter), letter), D = this._denominator.monomByDegree(this._denominator.degree(letter), letter);
|
|
2428
2379
|
N.divide(D);
|
|
2429
|
-
if (N.degree(letter)
|
|
2430
|
-
return N.coefficient.sign() * (Math.pow((value > 0 ? 1 : -1), N.degree(letter) % 2)) === 1 ? Infinity : -Infinity;
|
|
2380
|
+
if (N.degree(letter).isStrictlyPositive()) {
|
|
2381
|
+
return N.coefficient.sign() * (Math.pow((value > 0 ? 1 : -1), N.degree(letter).value % 2)) === 1 ? Infinity : -Infinity;
|
|
2431
2382
|
}
|
|
2432
|
-
if (N.degree(letter)
|
|
2383
|
+
if (N.degree(letter).isZero()) {
|
|
2433
2384
|
return N.coefficient;
|
|
2434
2385
|
}
|
|
2435
|
-
if (N.degree(letter)
|
|
2436
|
-
return N.coefficient.sign() * (Math.pow(-1, N.degree(letter) % 2)) === 1 ? 0 : -0;
|
|
2386
|
+
if (N.degree(letter).isStrictlyPositive()) {
|
|
2387
|
+
return N.coefficient.sign() * (Math.pow(-1, N.degree(letter).value % 2)) === 1 ? 0 : -0;
|
|
2437
2388
|
}
|
|
2438
2389
|
}
|
|
2439
2390
|
else {
|
|
2440
|
-
return this._numerator.evaluate({ letter: value }).divide(this._denominator.evaluate({ letter: value }));
|
|
2391
|
+
return this._numerator.evaluate({ letter: new fraction_1.Fraction(value) }).divide(this._denominator.evaluate({ letter: new fraction_1.Fraction(value) }));
|
|
2441
2392
|
}
|
|
2442
2393
|
};
|
|
2443
2394
|
}
|
|
2395
|
+
exports.Rational = Rational;
|
|
2444
2396
|
|
|
2445
2397
|
|
|
2446
2398
|
/***/ }),
|
|
@@ -2449,14 +2401,12 @@ class Rational {
|
|
|
2449
2401
|
/*!********************************************!*\
|
|
2450
2402
|
!*** ./src/maths/coefficients/fraction.ts ***!
|
|
2451
2403
|
\********************************************/
|
|
2452
|
-
/***/ ((__unused_webpack_module,
|
|
2404
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2453
2405
|
|
|
2454
|
-
__webpack_require__.r(__webpack_exports__);
|
|
2455
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2456
|
-
/* harmony export */ "default": () => (/* binding */ Fraction)
|
|
2457
|
-
/* harmony export */ });
|
|
2458
|
-
/* harmony import */ var _numeric__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
2459
2406
|
|
|
2407
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2408
|
+
exports.Fraction = void 0;
|
|
2409
|
+
const numeric_1 = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
2460
2410
|
class Fraction {
|
|
2461
2411
|
_numerator;
|
|
2462
2412
|
_denominator;
|
|
@@ -2605,13 +2555,23 @@ class Fraction {
|
|
|
2605
2555
|
return this;
|
|
2606
2556
|
};
|
|
2607
2557
|
add = (F) => {
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2558
|
+
if (F instanceof Fraction) {
|
|
2559
|
+
let N = this._numerator, D = this._denominator;
|
|
2560
|
+
this._numerator = N * F.denominator + F.numerator * D;
|
|
2561
|
+
this._denominator = D * F.denominator;
|
|
2562
|
+
}
|
|
2563
|
+
else {
|
|
2564
|
+
return this.add(new Fraction(F));
|
|
2565
|
+
}
|
|
2611
2566
|
return this.reduce();
|
|
2612
2567
|
};
|
|
2613
2568
|
subtract = (F) => {
|
|
2614
|
-
|
|
2569
|
+
if (F instanceof Fraction) {
|
|
2570
|
+
return this.add(F.clone().opposed());
|
|
2571
|
+
}
|
|
2572
|
+
else {
|
|
2573
|
+
return this.add(-F);
|
|
2574
|
+
}
|
|
2615
2575
|
};
|
|
2616
2576
|
multiply = (F) => {
|
|
2617
2577
|
let Q = new Fraction(F);
|
|
@@ -2636,6 +2596,9 @@ class Fraction {
|
|
|
2636
2596
|
return this;
|
|
2637
2597
|
};
|
|
2638
2598
|
pow = (p) => {
|
|
2599
|
+
if (p instanceof Fraction) {
|
|
2600
|
+
return this.pow(p.value);
|
|
2601
|
+
}
|
|
2639
2602
|
if (!Number.isSafeInteger(p)) {
|
|
2640
2603
|
return this.invalid();
|
|
2641
2604
|
}
|
|
@@ -2667,8 +2630,28 @@ class Fraction {
|
|
|
2667
2630
|
this._denominator = Math.abs(this._denominator);
|
|
2668
2631
|
return this;
|
|
2669
2632
|
};
|
|
2633
|
+
static max = (...fractions) => {
|
|
2634
|
+
let M = new Fraction(fractions[0]);
|
|
2635
|
+
for (let m of fractions) {
|
|
2636
|
+
let compare = new Fraction(m);
|
|
2637
|
+
if (compare.greater(M)) {
|
|
2638
|
+
M = compare.clone();
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
return M;
|
|
2642
|
+
};
|
|
2643
|
+
static min = (...fractions) => {
|
|
2644
|
+
let M = new Fraction(fractions[0]);
|
|
2645
|
+
for (let m of fractions) {
|
|
2646
|
+
let compare = new Fraction(m);
|
|
2647
|
+
if (compare.lesser(M)) {
|
|
2648
|
+
M = compare.clone();
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
return M;
|
|
2652
|
+
};
|
|
2670
2653
|
reduce = () => {
|
|
2671
|
-
let g =
|
|
2654
|
+
let g = numeric_1.Numeric.gcd(this._numerator, this._denominator);
|
|
2672
2655
|
this._numerator = this._numerator / g;
|
|
2673
2656
|
this._denominator = this._denominator / g;
|
|
2674
2657
|
if (this._denominator < 0) {
|
|
@@ -2688,19 +2671,26 @@ class Fraction {
|
|
|
2688
2671
|
if (sign === undefined) {
|
|
2689
2672
|
sign = '=';
|
|
2690
2673
|
}
|
|
2674
|
+
let compareFraction;
|
|
2675
|
+
if (F instanceof Fraction) {
|
|
2676
|
+
compareFraction = F.clone();
|
|
2677
|
+
}
|
|
2678
|
+
else {
|
|
2679
|
+
compareFraction = new Fraction(F);
|
|
2680
|
+
}
|
|
2691
2681
|
switch (sign) {
|
|
2692
2682
|
case '>':
|
|
2693
|
-
return this.value >
|
|
2683
|
+
return this.value > compareFraction.value;
|
|
2694
2684
|
case ">=" || 0 || 0:
|
|
2695
|
-
return this.value >=
|
|
2685
|
+
return this.value >= compareFraction.value;
|
|
2696
2686
|
case "<":
|
|
2697
|
-
return this.value <
|
|
2687
|
+
return this.value < compareFraction.value;
|
|
2698
2688
|
case "<=" || 0 || 0:
|
|
2699
|
-
return this.value <=
|
|
2689
|
+
return this.value <= compareFraction.value;
|
|
2700
2690
|
case "=":
|
|
2701
|
-
return this.value ===
|
|
2691
|
+
return this.value === compareFraction.value;
|
|
2702
2692
|
case "<>":
|
|
2703
|
-
return this.value !==
|
|
2693
|
+
return this.value !== compareFraction.value;
|
|
2704
2694
|
default:
|
|
2705
2695
|
return false;
|
|
2706
2696
|
}
|
|
@@ -2720,7 +2710,7 @@ class Fraction {
|
|
|
2720
2710
|
isEqual = (than) => {
|
|
2721
2711
|
return this.compare(than, '=');
|
|
2722
2712
|
};
|
|
2723
|
-
|
|
2713
|
+
isNotEqual = (than) => {
|
|
2724
2714
|
return this.compare(than, '<>');
|
|
2725
2715
|
};
|
|
2726
2716
|
isOpposed = (p) => {
|
|
@@ -2732,15 +2722,27 @@ class Fraction {
|
|
|
2732
2722
|
isZero = () => {
|
|
2733
2723
|
return this._numerator === 0;
|
|
2734
2724
|
};
|
|
2725
|
+
isNotZero = () => {
|
|
2726
|
+
return this._numerator !== 0;
|
|
2727
|
+
};
|
|
2735
2728
|
isOne = () => {
|
|
2736
2729
|
return this._numerator === 1 && this._denominator === 1;
|
|
2737
2730
|
};
|
|
2731
|
+
isNegativeOne = () => {
|
|
2732
|
+
return this._numerator === -1 && this._denominator === 1;
|
|
2733
|
+
};
|
|
2738
2734
|
isPositive = () => {
|
|
2739
2735
|
return this.sign() === 1;
|
|
2740
2736
|
};
|
|
2741
2737
|
isNegative = () => {
|
|
2742
2738
|
return this.sign() === -1;
|
|
2743
2739
|
};
|
|
2740
|
+
isStrictlyPositive = () => {
|
|
2741
|
+
return this.value > 0;
|
|
2742
|
+
};
|
|
2743
|
+
isStrictlyNegative = () => {
|
|
2744
|
+
return this.value < 0;
|
|
2745
|
+
};
|
|
2744
2746
|
isNaN = () => {
|
|
2745
2747
|
return isNaN(this._numerator);
|
|
2746
2748
|
};
|
|
@@ -2754,7 +2756,19 @@ class Fraction {
|
|
|
2754
2756
|
return Math.sqrt(this._numerator) % 1 === 0 && Math.sqrt(this._denominator) % 1 === 0;
|
|
2755
2757
|
};
|
|
2756
2758
|
isReduced = () => {
|
|
2757
|
-
return Math.abs(
|
|
2759
|
+
return Math.abs(numeric_1.Numeric.gcd(this._numerator, this._denominator)) === 1;
|
|
2760
|
+
};
|
|
2761
|
+
isNatural = () => {
|
|
2762
|
+
return this.clone().reduce().denominator === 1;
|
|
2763
|
+
};
|
|
2764
|
+
isRational = () => {
|
|
2765
|
+
return !this.isNatural();
|
|
2766
|
+
};
|
|
2767
|
+
isEven = () => {
|
|
2768
|
+
return this.isNatural() && this.value % 2 === 0;
|
|
2769
|
+
};
|
|
2770
|
+
isOdd = () => {
|
|
2771
|
+
return this.isNatural() && this.value % 2 === 1;
|
|
2758
2772
|
};
|
|
2759
2773
|
sign = () => {
|
|
2760
2774
|
return (this._numerator * this._denominator >= 0) ? 1 : -1;
|
|
@@ -2768,6 +2782,31 @@ class Fraction {
|
|
|
2768
2782
|
return true;
|
|
2769
2783
|
};
|
|
2770
2784
|
}
|
|
2785
|
+
exports.Fraction = Fraction;
|
|
2786
|
+
|
|
2787
|
+
|
|
2788
|
+
/***/ }),
|
|
2789
|
+
|
|
2790
|
+
/***/ "./src/maths/coefficients/index.ts":
|
|
2791
|
+
/*!*****************************************!*\
|
|
2792
|
+
!*** ./src/maths/coefficients/index.ts ***!
|
|
2793
|
+
\*****************************************/
|
|
2794
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2795
|
+
|
|
2796
|
+
|
|
2797
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2798
|
+
if (k2 === undefined) k2 = k;
|
|
2799
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
2800
|
+
}) : (function(o, m, k, k2) {
|
|
2801
|
+
if (k2 === undefined) k2 = k;
|
|
2802
|
+
o[k2] = m[k];
|
|
2803
|
+
}));
|
|
2804
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
2805
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
2806
|
+
};
|
|
2807
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2808
|
+
__exportStar(__webpack_require__(/*! ./fraction */ "./src/maths/coefficients/fraction.ts"), exports);
|
|
2809
|
+
__exportStar(__webpack_require__(/*! ./nthroot */ "./src/maths/coefficients/nthroot.ts"), exports);
|
|
2771
2810
|
|
|
2772
2811
|
|
|
2773
2812
|
/***/ }),
|
|
@@ -2776,12 +2815,11 @@ class Fraction {
|
|
|
2776
2815
|
/*!*******************************************!*\
|
|
2777
2816
|
!*** ./src/maths/coefficients/nthroot.ts ***!
|
|
2778
2817
|
\*******************************************/
|
|
2779
|
-
/***/ ((__unused_webpack_module,
|
|
2818
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
2780
2819
|
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
/* harmony export */ });
|
|
2820
|
+
|
|
2821
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2822
|
+
exports.Nthroot = void 0;
|
|
2785
2823
|
class Nthroot {
|
|
2786
2824
|
_radical;
|
|
2787
2825
|
_nth;
|
|
@@ -2873,6 +2911,7 @@ class Nthroot {
|
|
|
2873
2911
|
return !(this._radical === 1 || this._radical === 0 || this._isValid === false);
|
|
2874
2912
|
};
|
|
2875
2913
|
}
|
|
2914
|
+
exports.Nthroot = Nthroot;
|
|
2876
2915
|
|
|
2877
2916
|
|
|
2878
2917
|
/***/ }),
|
|
@@ -2881,23 +2920,20 @@ class Nthroot {
|
|
|
2881
2920
|
/*!**************************************!*\
|
|
2882
2921
|
!*** ./src/maths/geometry/circle.ts ***!
|
|
2883
2922
|
\**************************************/
|
|
2884
|
-
/***/ ((__unused_webpack_module,
|
|
2923
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2885
2924
|
|
|
2886
|
-
__webpack_require__.r(__webpack_exports__);
|
|
2887
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2888
|
-
/* harmony export */ "default": () => (/* binding */ Circle)
|
|
2889
|
-
/* harmony export */ });
|
|
2890
|
-
/* harmony import */ var _point__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts");
|
|
2891
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
2892
|
-
/* harmony import */ var _algebra_equation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../algebra/equation */ "./src/maths/algebra/equation.ts");
|
|
2893
|
-
/* harmony import */ var _algebra_polynom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../algebra/polynom */ "./src/maths/algebra/polynom.ts");
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
2925
|
|
|
2926
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2927
|
+
exports.Circle = void 0;
|
|
2928
|
+
const point_1 = __webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts");
|
|
2929
|
+
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
2930
|
+
const algebra_1 = __webpack_require__(/*! ../algebra */ "./src/maths/algebra/index.ts");
|
|
2931
|
+
const vector_1 = __webpack_require__(/*! ./vector */ "./src/maths/geometry/vector.ts");
|
|
2898
2932
|
class Circle {
|
|
2899
2933
|
_center;
|
|
2900
2934
|
_radius;
|
|
2935
|
+
_squareRadius;
|
|
2936
|
+
_cartesian;
|
|
2901
2937
|
_exists;
|
|
2902
2938
|
constructor(...values) {
|
|
2903
2939
|
this._exists = false;
|
|
@@ -2905,11 +2941,23 @@ class Circle {
|
|
|
2905
2941
|
this.parse(...values);
|
|
2906
2942
|
}
|
|
2907
2943
|
}
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2944
|
+
get center() {
|
|
2945
|
+
return this._center;
|
|
2946
|
+
}
|
|
2947
|
+
get radius() {
|
|
2948
|
+
if (this._squareRadius.isSquare()) {
|
|
2949
|
+
return {
|
|
2950
|
+
tex: this._squareRadius.clone().sqrt().tex,
|
|
2951
|
+
display: this._squareRadius.clone().sqrt().display,
|
|
2952
|
+
};
|
|
2912
2953
|
}
|
|
2954
|
+
else {
|
|
2955
|
+
return {
|
|
2956
|
+
tex: `\\sqrt{${this._squareRadius.tex}}`,
|
|
2957
|
+
display: `sqrt(${this._squareRadius.display})`
|
|
2958
|
+
};
|
|
2959
|
+
}
|
|
2960
|
+
return this._squareRadius;
|
|
2913
2961
|
}
|
|
2914
2962
|
get tex() {
|
|
2915
2963
|
let cx, cy;
|
|
@@ -2917,21 +2965,112 @@ class Circle {
|
|
|
2917
2965
|
cx = 'x^2';
|
|
2918
2966
|
}
|
|
2919
2967
|
else {
|
|
2920
|
-
cx = `\\left(x
|
|
2968
|
+
cx = `\\left(x${this._center.x.isNegative() ? '+' : '-'}${this._center.x.clone().abs().tex}\\right)^2`;
|
|
2921
2969
|
}
|
|
2922
2970
|
if (this._center.y.isZero()) {
|
|
2923
2971
|
cy = 'y^2';
|
|
2924
2972
|
}
|
|
2925
2973
|
else {
|
|
2926
|
-
cy = `\\left(y
|
|
2974
|
+
cy = `\\left(y${this._center.y.isNegative() ? '+' : '-'}${this._center.y.clone().abs().tex}\\right)^2`;
|
|
2927
2975
|
}
|
|
2928
|
-
return `${cx}+${cy}=${this.
|
|
2976
|
+
return `${cx}+${cy}=${this._squareRadius.tex}`;
|
|
2929
2977
|
}
|
|
2930
2978
|
get developed() {
|
|
2931
|
-
|
|
2932
|
-
|
|
2979
|
+
return this._cartesian.tex;
|
|
2980
|
+
}
|
|
2981
|
+
get display() {
|
|
2982
|
+
return this._cartesian.display;
|
|
2983
|
+
}
|
|
2984
|
+
get cartesian() {
|
|
2985
|
+
return this._cartesian;
|
|
2986
|
+
}
|
|
2987
|
+
parse(...values) {
|
|
2988
|
+
if (values.length === 1 && typeof values[0] === 'string') {
|
|
2989
|
+
this.checkCircle(new algebra_1.Equation(values[0]));
|
|
2990
|
+
}
|
|
2991
|
+
else if (values.length >= 2) {
|
|
2992
|
+
this._center = new point_1.Point(values[0]);
|
|
2993
|
+
if (values[1] instanceof point_1.Point) {
|
|
2994
|
+
this._squareRadius = new vector_1.Vector(this._center, values[1]).normSquare;
|
|
2995
|
+
}
|
|
2996
|
+
else {
|
|
2997
|
+
if (values[2] === true) {
|
|
2998
|
+
this._squareRadius = new coefficients_1.Fraction(values[1]);
|
|
2999
|
+
}
|
|
3000
|
+
else {
|
|
3001
|
+
this._radius = new coefficients_1.Fraction(values[1]);
|
|
3002
|
+
this._squareRadius = this._radius.clone().pow(2);
|
|
3003
|
+
}
|
|
3004
|
+
}
|
|
3005
|
+
this._cartesian = (new algebra_1.Equation(new algebra_1.Polynom(`(x-(${this._center.x.display}))^2+(y-(${this._center.y.display}))^2`), new algebra_1.Polynom(`${this._squareRadius.display}`))).moveLeft();
|
|
3006
|
+
}
|
|
2933
3007
|
}
|
|
3008
|
+
checkCircle = (P) => {
|
|
3009
|
+
if (P.degree('x').value === 2 && P.degree('y').value === 2) {
|
|
3010
|
+
let x2 = P.left.monomByDegree(2, 'x'), y2 = P.left.monomByDegree(2, 'y'), x1, y1, c;
|
|
3011
|
+
if (x2.coefficient.isEqual(y2.coefficient)) {
|
|
3012
|
+
P.divide(x2.coefficient);
|
|
3013
|
+
x1 = P.left.monomByDegree(1, 'x');
|
|
3014
|
+
y1 = P.left.monomByDegree(1, 'y');
|
|
3015
|
+
c = P.left.monomByDegree(0);
|
|
3016
|
+
this._center = new point_1.Point(x1.coefficient.clone().divide(2).opposed(), y1.coefficient.clone().divide(2).opposed());
|
|
3017
|
+
this._squareRadius = c.coefficient.clone().opposed()
|
|
3018
|
+
.add(this._center.x.clone().pow(2))
|
|
3019
|
+
.add(this._center.y.clone().pow(2));
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
3022
|
+
return false;
|
|
3023
|
+
};
|
|
3024
|
+
relativePosition = (L) => {
|
|
3025
|
+
let distance = L.distanceTo(this.center), radius = Math.sqrt(this._squareRadius.value);
|
|
3026
|
+
if (distance.value - radius > 0.0000000001) {
|
|
3027
|
+
return 0;
|
|
3028
|
+
}
|
|
3029
|
+
else if (Math.abs(distance.value - radius) < 0.0000000001) {
|
|
3030
|
+
return 1;
|
|
3031
|
+
}
|
|
3032
|
+
else {
|
|
3033
|
+
return 2;
|
|
3034
|
+
}
|
|
3035
|
+
};
|
|
3036
|
+
lineIntersection = (L) => {
|
|
3037
|
+
let P1, P2;
|
|
3038
|
+
const equ = this._cartesian.clone(), yLine = L.equation.clone().isolate('y');
|
|
3039
|
+
if (yLine instanceof algebra_1.Equation) {
|
|
3040
|
+
equ.replaceBy('y', yLine.right);
|
|
3041
|
+
equ.solve();
|
|
3042
|
+
}
|
|
3043
|
+
return [];
|
|
3044
|
+
};
|
|
2934
3045
|
}
|
|
3046
|
+
exports.Circle = Circle;
|
|
3047
|
+
|
|
3048
|
+
|
|
3049
|
+
/***/ }),
|
|
3050
|
+
|
|
3051
|
+
/***/ "./src/maths/geometry/index.ts":
|
|
3052
|
+
/*!*************************************!*\
|
|
3053
|
+
!*** ./src/maths/geometry/index.ts ***!
|
|
3054
|
+
\*************************************/
|
|
3055
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3056
|
+
|
|
3057
|
+
|
|
3058
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3059
|
+
if (k2 === undefined) k2 = k;
|
|
3060
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
3061
|
+
}) : (function(o, m, k, k2) {
|
|
3062
|
+
if (k2 === undefined) k2 = k;
|
|
3063
|
+
o[k2] = m[k];
|
|
3064
|
+
}));
|
|
3065
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
3066
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
3067
|
+
};
|
|
3068
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3069
|
+
__exportStar(__webpack_require__(/*! ./vector */ "./src/maths/geometry/vector.ts"), exports);
|
|
3070
|
+
__exportStar(__webpack_require__(/*! ./triangle */ "./src/maths/geometry/triangle.ts"), exports);
|
|
3071
|
+
__exportStar(__webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts"), exports);
|
|
3072
|
+
__exportStar(__webpack_require__(/*! ./circle */ "./src/maths/geometry/circle.ts"), exports);
|
|
3073
|
+
__exportStar(__webpack_require__(/*! ./line */ "./src/maths/geometry/line.ts"), exports);
|
|
2935
3074
|
|
|
2936
3075
|
|
|
2937
3076
|
/***/ }),
|
|
@@ -2940,24 +3079,22 @@ class Circle {
|
|
|
2940
3079
|
/*!************************************!*\
|
|
2941
3080
|
!*** ./src/maths/geometry/line.ts ***!
|
|
2942
3081
|
\************************************/
|
|
2943
|
-
/***/ ((__unused_webpack_module,
|
|
3082
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2944
3083
|
|
|
2945
|
-
__webpack_require__.r(__webpack_exports__);
|
|
2946
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2947
|
-
/* harmony export */ "default": () => (/* binding */ Line)
|
|
2948
|
-
/* harmony export */ });
|
|
2949
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
2950
|
-
/* harmony import */ var _vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vector */ "./src/maths/geometry/vector.ts");
|
|
2951
|
-
/* harmony import */ var _point__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts");
|
|
2952
|
-
/* harmony import */ var _algebra_polynom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../algebra/polynom */ "./src/maths/algebra/polynom.ts");
|
|
2953
|
-
/* harmony import */ var _numeric__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
2954
|
-
/* harmony import */ var _algebra_equation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../algebra/equation */ "./src/maths/algebra/equation.ts");
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
3084
|
|
|
3085
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3086
|
+
exports.Line = void 0;
|
|
3087
|
+
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
3088
|
+
const vector_1 = __webpack_require__(/*! ./vector */ "./src/maths/geometry/vector.ts");
|
|
3089
|
+
const point_1 = __webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts");
|
|
3090
|
+
const algebra_1 = __webpack_require__(/*! ../algebra */ "./src/maths/algebra/index.ts");
|
|
3091
|
+
const numeric_1 = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
3092
|
+
var LinePropriety;
|
|
3093
|
+
(function (LinePropriety) {
|
|
3094
|
+
LinePropriety[LinePropriety["None"] = 0] = "None";
|
|
3095
|
+
LinePropriety[LinePropriety["Parallel"] = 1] = "Parallel";
|
|
3096
|
+
LinePropriety[LinePropriety["Perpendicular"] = 2] = "Perpendicular";
|
|
3097
|
+
})(LinePropriety || (LinePropriety = {}));
|
|
2961
3098
|
class Line {
|
|
2962
3099
|
_a;
|
|
2963
3100
|
_b;
|
|
@@ -2966,17 +3103,25 @@ class Line {
|
|
|
2966
3103
|
_d;
|
|
2967
3104
|
_n;
|
|
2968
3105
|
_exists;
|
|
3106
|
+
_referencePropriety;
|
|
3107
|
+
_referenceLine;
|
|
3108
|
+
static PERPENDICULAR = LinePropriety.Perpendicular;
|
|
3109
|
+
static PARALLEL = LinePropriety.Parallel;
|
|
2969
3110
|
constructor(...values) {
|
|
2970
3111
|
this._exists = false;
|
|
2971
|
-
if (values
|
|
3112
|
+
if (values.length > 0) {
|
|
2972
3113
|
this.parse(...values);
|
|
2973
3114
|
}
|
|
2974
3115
|
return this;
|
|
2975
3116
|
}
|
|
2976
|
-
get isLine() {
|
|
2977
|
-
|
|
3117
|
+
get isLine() {
|
|
3118
|
+
return true;
|
|
3119
|
+
}
|
|
3120
|
+
get exists() {
|
|
3121
|
+
return this._exists;
|
|
3122
|
+
}
|
|
2978
3123
|
get equation() {
|
|
2979
|
-
return new
|
|
3124
|
+
return new algebra_1.Equation(new algebra_1.Polynom().parse('xy', this._a, this._b, this._c), new algebra_1.Polynom('0')).simplify();
|
|
2980
3125
|
}
|
|
2981
3126
|
get tex() {
|
|
2982
3127
|
let canonical = this.equation;
|
|
@@ -2985,8 +3130,8 @@ class Line {
|
|
|
2985
3130
|
}
|
|
2986
3131
|
return {
|
|
2987
3132
|
canonical: canonical.tex,
|
|
2988
|
-
mxh: this.slope.isInfinity() ? 'x=' + this.OA.x.tex : 'y=' + new
|
|
2989
|
-
parametric: `${
|
|
3133
|
+
mxh: this.slope.isInfinity() ? 'x=' + this.OA.x.tex : 'y=' + new algebra_1.Polynom().parse('x', this.slope, this.height).tex,
|
|
3134
|
+
parametric: `${point_1.Point.pmatrix('x', 'y')} = ${point_1.Point.pmatrix(this._OA.x, this._OA.y)} + k\\cdot ${point_1.Point.pmatrix(this._d.x, this._d.y)}`
|
|
2990
3135
|
};
|
|
2991
3136
|
}
|
|
2992
3137
|
get a() {
|
|
@@ -3020,7 +3165,10 @@ class Line {
|
|
|
3020
3165
|
return this._n;
|
|
3021
3166
|
}
|
|
3022
3167
|
get normal() {
|
|
3023
|
-
return new
|
|
3168
|
+
return new vector_1.Vector(this._a, this._b);
|
|
3169
|
+
}
|
|
3170
|
+
get director() {
|
|
3171
|
+
return this._d.clone();
|
|
3024
3172
|
}
|
|
3025
3173
|
set d(value) {
|
|
3026
3174
|
this._d = value;
|
|
@@ -3033,49 +3181,71 @@ class Line {
|
|
|
3033
3181
|
}
|
|
3034
3182
|
parse = (...values) => {
|
|
3035
3183
|
this._exists = false;
|
|
3036
|
-
if (values.length ===
|
|
3037
|
-
return this
|
|
3038
|
-
}
|
|
3039
|
-
else if (values.length === 2) {
|
|
3040
|
-
if (values[0].isPoint && values[1].isVector) {
|
|
3041
|
-
return this.parseByPointAndVector(values[0], values[1]);
|
|
3042
|
-
}
|
|
3043
|
-
else if (values[0].isPoint && values[1].isPoint) {
|
|
3044
|
-
return this.parseByPointAndVector(values[0], new _vector__WEBPACK_IMPORTED_MODULE_1__["default"](values[0], values[1]));
|
|
3045
|
-
}
|
|
3184
|
+
if (values.length === 0) {
|
|
3185
|
+
return this;
|
|
3046
3186
|
}
|
|
3047
|
-
|
|
3048
|
-
if (values[0]
|
|
3187
|
+
if (values.length === 1) {
|
|
3188
|
+
if (values[0] instanceof Line) {
|
|
3049
3189
|
return values[0].clone();
|
|
3050
3190
|
}
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
for (let elem of ['x', 'y']) {
|
|
3059
|
-
if (letters.has(elem)) {
|
|
3060
|
-
letters.delete(elem);
|
|
3061
|
-
}
|
|
3191
|
+
else if (values[0] instanceof algebra_1.Equation) {
|
|
3192
|
+
return this.parseEquation(values[0]);
|
|
3193
|
+
}
|
|
3194
|
+
else if (typeof values[0] === "string") {
|
|
3195
|
+
try {
|
|
3196
|
+
let E = new algebra_1.Equation(values[0]);
|
|
3197
|
+
return this.parse(E);
|
|
3062
3198
|
}
|
|
3063
|
-
|
|
3064
|
-
console.log('Extra variable in the equation.');
|
|
3199
|
+
catch (e) {
|
|
3065
3200
|
return this;
|
|
3066
3201
|
}
|
|
3067
|
-
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3204
|
+
if (values.length === 2) {
|
|
3205
|
+
if (values[0] instanceof point_1.Point && values[1] instanceof vector_1.Vector) {
|
|
3206
|
+
return this.parseByPointAndVector(values[0], values[1]);
|
|
3207
|
+
}
|
|
3208
|
+
else if (values[0] instanceof point_1.Point && values[1] instanceof point_1.Point) {
|
|
3209
|
+
return this.parseByPointAndVector(values[0], new vector_1.Vector(values[0], values[1]));
|
|
3210
|
+
}
|
|
3211
|
+
else if (values[0] instanceof vector_1.Vector && values[1] instanceof point_1.Point) {
|
|
3212
|
+
return this.parseByPointAndNormal(values[1], values[0]);
|
|
3213
|
+
}
|
|
3214
|
+
}
|
|
3215
|
+
if (values.length === 3) {
|
|
3216
|
+
if ((values[0] instanceof coefficients_1.Fraction || typeof values[0] === 'number')
|
|
3217
|
+
&&
|
|
3218
|
+
(values[1] instanceof coefficients_1.Fraction || typeof values[1] === 'number')
|
|
3219
|
+
&&
|
|
3220
|
+
(values[2] instanceof coefficients_1.Fraction || typeof values[2] === 'number')) {
|
|
3221
|
+
return this.parseByCoefficient(values[0], values[1], values[2]);
|
|
3068
3222
|
}
|
|
3069
3223
|
}
|
|
3070
3224
|
console.log('Someting wrong happend while creating the line');
|
|
3071
3225
|
return this;
|
|
3072
3226
|
};
|
|
3227
|
+
parseEquation = (equ) => {
|
|
3228
|
+
equ.reorder(true);
|
|
3229
|
+
let letters = new Set(equ.letters());
|
|
3230
|
+
if (!(letters.has('x') || letters.has('y'))) {
|
|
3231
|
+
return this;
|
|
3232
|
+
}
|
|
3233
|
+
for (let elem of ['x', 'y']) {
|
|
3234
|
+
if (letters.has(elem)) {
|
|
3235
|
+
letters.delete(elem);
|
|
3236
|
+
}
|
|
3237
|
+
}
|
|
3238
|
+
if (letters.size > 0) {
|
|
3239
|
+
return this;
|
|
3240
|
+
}
|
|
3241
|
+
return this.parseByCoefficient(equ.left.monomByLetter('x').coefficient, equ.left.monomByLetter('y').coefficient, equ.left.monomByDegree(0).coefficient);
|
|
3242
|
+
};
|
|
3073
3243
|
parseByCoefficient = (a, b, c) => {
|
|
3074
|
-
this._a = new
|
|
3075
|
-
this._b = new
|
|
3076
|
-
this._c = new
|
|
3077
|
-
this._d = new
|
|
3078
|
-
this._OA = new
|
|
3244
|
+
this._a = new coefficients_1.Fraction(a);
|
|
3245
|
+
this._b = new coefficients_1.Fraction(b);
|
|
3246
|
+
this._c = new coefficients_1.Fraction(c);
|
|
3247
|
+
this._d = new vector_1.Vector(this._b.clone(), this._a.clone().opposed());
|
|
3248
|
+
this._OA = new point_1.Point(new coefficients_1.Fraction().zero(), this._c.clone());
|
|
3079
3249
|
this._n = this._d.clone().normal();
|
|
3080
3250
|
this._exists = true;
|
|
3081
3251
|
return this;
|
|
@@ -3088,6 +3258,23 @@ class Line {
|
|
|
3088
3258
|
this._exists = true;
|
|
3089
3259
|
return this;
|
|
3090
3260
|
};
|
|
3261
|
+
parseByPointAndNormal = (P, n) => {
|
|
3262
|
+
return this.parseByCoefficient(n.x, n.y, P.x.clone().multiply(n.x)
|
|
3263
|
+
.add(P.y.clone().multiply(n.y)).opposed());
|
|
3264
|
+
};
|
|
3265
|
+
parseByPointAndLine = (P, L, orientation) => {
|
|
3266
|
+
if (orientation === undefined) {
|
|
3267
|
+
orientation = LinePropriety.Parallel;
|
|
3268
|
+
}
|
|
3269
|
+
if (orientation === LinePropriety.Parallel) {
|
|
3270
|
+
return this.parseByPointAndNormal(P, L.normal);
|
|
3271
|
+
}
|
|
3272
|
+
else if (orientation === LinePropriety.Perpendicular) {
|
|
3273
|
+
return this.parseByPointAndNormal(P, L.director);
|
|
3274
|
+
}
|
|
3275
|
+
this._exists = false;
|
|
3276
|
+
return this;
|
|
3277
|
+
};
|
|
3091
3278
|
clone = () => {
|
|
3092
3279
|
this._a = this._a.clone();
|
|
3093
3280
|
this._b = this._b.clone();
|
|
@@ -3095,22 +3282,23 @@ class Line {
|
|
|
3095
3282
|
this._d = this._d.clone();
|
|
3096
3283
|
this._OA = this._OA.clone();
|
|
3097
3284
|
this._n = this._n.clone();
|
|
3285
|
+
this._exists = this.exists;
|
|
3098
3286
|
return this;
|
|
3099
3287
|
};
|
|
3100
3288
|
isParellelTo = (line) => {
|
|
3101
|
-
return this.slope.isEqual(line.slope) && this.height.
|
|
3289
|
+
return this.slope.isEqual(line.slope) && this.height.isNotEqual(line.height);
|
|
3102
3290
|
};
|
|
3103
3291
|
isSameAs = (line) => {
|
|
3104
3292
|
return this.slope.isEqual(line.slope) && this.height.isEqual(line.height);
|
|
3105
3293
|
};
|
|
3106
3294
|
simplifyDirection = () => {
|
|
3107
|
-
let lcm =
|
|
3295
|
+
let lcm = numeric_1.Numeric.lcm(this._d.x.denominator, this._d.y.denominator), gcd = numeric_1.Numeric.gcd(this._d.x.numerator, this._d.y.numerator);
|
|
3108
3296
|
this._d.x.multiply(lcm).divide(gcd);
|
|
3109
3297
|
this._d.y.multiply(lcm).divide(gcd);
|
|
3110
3298
|
return this;
|
|
3111
3299
|
};
|
|
3112
3300
|
intersection = (line) => {
|
|
3113
|
-
let Pt = new
|
|
3301
|
+
let Pt = new point_1.Point(), isParallel = false, isSame = false, hasIntersection = true;
|
|
3114
3302
|
if (this._b.isZero() || line.b.isZero()) {
|
|
3115
3303
|
}
|
|
3116
3304
|
if (this.isParellelTo(line)) {
|
|
@@ -3144,7 +3332,7 @@ class Line {
|
|
|
3144
3332
|
return {
|
|
3145
3333
|
value: NaN,
|
|
3146
3334
|
tex: 'Not a line',
|
|
3147
|
-
fraction: new
|
|
3335
|
+
fraction: new coefficients_1.Fraction().infinite()
|
|
3148
3336
|
};
|
|
3149
3337
|
}
|
|
3150
3338
|
let value = numerator.value / Math.sqrt(d2.value), F = numerator.clone().divide(d2.clone().sqrt());
|
|
@@ -3171,6 +3359,20 @@ class Line {
|
|
|
3171
3359
|
}
|
|
3172
3360
|
return false;
|
|
3173
3361
|
}
|
|
3362
|
+
getValueAtX = (value) => {
|
|
3363
|
+
const equ = this.equation.clone().isolate('y');
|
|
3364
|
+
if (equ instanceof algebra_1.Equation) {
|
|
3365
|
+
return equ.right.evaluate({ x: value });
|
|
3366
|
+
}
|
|
3367
|
+
return;
|
|
3368
|
+
};
|
|
3369
|
+
getValueAtY = (value) => {
|
|
3370
|
+
const equ = this.equation.clone().isolate('x');
|
|
3371
|
+
if (equ instanceof algebra_1.Equation) {
|
|
3372
|
+
return equ.right.evaluate({ y: value });
|
|
3373
|
+
}
|
|
3374
|
+
return;
|
|
3375
|
+
};
|
|
3174
3376
|
canonicalAsFloatCoefficient(decimals) {
|
|
3175
3377
|
if (decimals === undefined) {
|
|
3176
3378
|
decimals = 2;
|
|
@@ -3202,6 +3404,7 @@ class Line {
|
|
|
3202
3404
|
return canonical + '=0';
|
|
3203
3405
|
}
|
|
3204
3406
|
}
|
|
3407
|
+
exports.Line = Line;
|
|
3205
3408
|
|
|
3206
3409
|
|
|
3207
3410
|
/***/ }),
|
|
@@ -3210,21 +3413,19 @@ class Line {
|
|
|
3210
3413
|
/*!*************************************!*\
|
|
3211
3414
|
!*** ./src/maths/geometry/point.ts ***!
|
|
3212
3415
|
\*************************************/
|
|
3213
|
-
/***/ ((__unused_webpack_module,
|
|
3416
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3214
3417
|
|
|
3215
|
-
__webpack_require__.r(__webpack_exports__);
|
|
3216
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3217
|
-
/* harmony export */ "default": () => (/* binding */ Point)
|
|
3218
|
-
/* harmony export */ });
|
|
3219
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
3220
3418
|
|
|
3419
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3420
|
+
exports.Point = void 0;
|
|
3421
|
+
const fraction_1 = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
3221
3422
|
class Point {
|
|
3222
3423
|
_x;
|
|
3223
3424
|
_y;
|
|
3224
3425
|
_exist;
|
|
3225
3426
|
constructor(...values) {
|
|
3226
|
-
this._x = new
|
|
3227
|
-
this._y = new
|
|
3427
|
+
this._x = new fraction_1.Fraction().zero();
|
|
3428
|
+
this._y = new fraction_1.Fraction().zero();
|
|
3228
3429
|
if (values !== undefined) {
|
|
3229
3430
|
this.parse(...values);
|
|
3230
3431
|
}
|
|
@@ -3252,6 +3453,12 @@ class Point {
|
|
|
3252
3453
|
pts.push(this._y.tex);
|
|
3253
3454
|
return `\\left(${pts.join(';')}\\right)`;
|
|
3254
3455
|
}
|
|
3456
|
+
get display() {
|
|
3457
|
+
let pts = [];
|
|
3458
|
+
pts.push(this._x.tex);
|
|
3459
|
+
pts.push(this._y.tex);
|
|
3460
|
+
return `(${pts.join(';')})`;
|
|
3461
|
+
}
|
|
3255
3462
|
parse = (...values) => {
|
|
3256
3463
|
this.zero();
|
|
3257
3464
|
if (values.length === 0) {
|
|
@@ -3266,22 +3473,22 @@ class Point {
|
|
|
3266
3473
|
if (typeof values[0] === 'string') {
|
|
3267
3474
|
let xy = values[0].split(',');
|
|
3268
3475
|
if (xy.length === 2) {
|
|
3269
|
-
this._x = new
|
|
3270
|
-
this._y = new
|
|
3476
|
+
this._x = new fraction_1.Fraction(xy[0]).reduce();
|
|
3477
|
+
this._y = new fraction_1.Fraction(xy[1]).reduce();
|
|
3271
3478
|
return this;
|
|
3272
3479
|
}
|
|
3273
3480
|
}
|
|
3274
3481
|
if (values[0].x !== undefined && values[0].y !== undefined) {
|
|
3275
|
-
this._x = new
|
|
3276
|
-
this._y = new
|
|
3482
|
+
this._x = new fraction_1.Fraction(values[0].x).reduce();
|
|
3483
|
+
this._y = new fraction_1.Fraction(values[0].y).reduce();
|
|
3277
3484
|
}
|
|
3278
3485
|
else {
|
|
3279
3486
|
return this.zero();
|
|
3280
3487
|
}
|
|
3281
3488
|
}
|
|
3282
3489
|
if (values.length === 2) {
|
|
3283
|
-
this._x = new
|
|
3284
|
-
this._y = new
|
|
3490
|
+
this._x = new fraction_1.Fraction(values[0]).reduce();
|
|
3491
|
+
this._y = new fraction_1.Fraction(values[1]).reduce();
|
|
3285
3492
|
}
|
|
3286
3493
|
return this;
|
|
3287
3494
|
};
|
|
@@ -3291,8 +3498,8 @@ class Point {
|
|
|
3291
3498
|
return this;
|
|
3292
3499
|
};
|
|
3293
3500
|
zero = () => {
|
|
3294
|
-
this._x = new
|
|
3295
|
-
this._y = new
|
|
3501
|
+
this._x = new fraction_1.Fraction(null);
|
|
3502
|
+
this._y = new fraction_1.Fraction(null);
|
|
3296
3503
|
return this;
|
|
3297
3504
|
};
|
|
3298
3505
|
origin = () => {
|
|
@@ -3319,6 +3526,7 @@ class Point {
|
|
|
3319
3526
|
}
|
|
3320
3527
|
};
|
|
3321
3528
|
}
|
|
3529
|
+
exports.Point = Point;
|
|
3322
3530
|
|
|
3323
3531
|
|
|
3324
3532
|
/***/ }),
|
|
@@ -3327,22 +3535,16 @@ class Point {
|
|
|
3327
3535
|
/*!****************************************!*\
|
|
3328
3536
|
!*** ./src/maths/geometry/triangle.ts ***!
|
|
3329
3537
|
\****************************************/
|
|
3330
|
-
/***/ ((__unused_webpack_module,
|
|
3538
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3331
3539
|
|
|
3332
|
-
__webpack_require__.r(__webpack_exports__);
|
|
3333
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3334
|
-
/* harmony export */ "default": () => (/* binding */ Triangle)
|
|
3335
|
-
/* harmony export */ });
|
|
3336
|
-
/* harmony import */ var _point__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts");
|
|
3337
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
3338
|
-
/* harmony import */ var _vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vector */ "./src/maths/geometry/vector.ts");
|
|
3339
|
-
/* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./line */ "./src/maths/geometry/line.ts");
|
|
3340
|
-
/* harmony import */ var _algebra_equation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../algebra/equation */ "./src/maths/algebra/equation.ts");
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
3540
|
|
|
3541
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3542
|
+
exports.Triangle = void 0;
|
|
3543
|
+
const point_1 = __webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts");
|
|
3544
|
+
const fraction_1 = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
3545
|
+
const vector_1 = __webpack_require__(/*! ./vector */ "./src/maths/geometry/vector.ts");
|
|
3546
|
+
const line_1 = __webpack_require__(/*! ./line */ "./src/maths/geometry/line.ts");
|
|
3547
|
+
const equation_1 = __webpack_require__(/*! ../algebra/equation */ "./src/maths/algebra/equation.ts");
|
|
3346
3548
|
class Triangle {
|
|
3347
3549
|
_A;
|
|
3348
3550
|
_B;
|
|
@@ -3413,12 +3615,12 @@ class Triangle {
|
|
|
3413
3615
|
}
|
|
3414
3616
|
parse = (...values) => {
|
|
3415
3617
|
if (values.length === 6) {
|
|
3416
|
-
let v = values.map((x) => new
|
|
3417
|
-
return this.parse(new
|
|
3618
|
+
let v = values.map((x) => new fraction_1.Fraction(x));
|
|
3619
|
+
return this.parse(new point_1.Point(v[0], v[1]), new point_1.Point(v[2], v[3]), new point_1.Point(v[4], v[5]));
|
|
3418
3620
|
}
|
|
3419
3621
|
else if (values.length === 3) {
|
|
3420
3622
|
if (values.filter((x) => typeof x === 'string').length === 3) {
|
|
3421
|
-
return this.parse(...values.map((x) => new
|
|
3623
|
+
return this.parse(...values.map((x) => new line_1.Line(x)));
|
|
3422
3624
|
}
|
|
3423
3625
|
else if (values.filter((x) => x.isLine === true).length === 3) {
|
|
3424
3626
|
this._lines = {
|
|
@@ -3450,15 +3652,15 @@ class Triangle {
|
|
|
3450
3652
|
}
|
|
3451
3653
|
else {
|
|
3452
3654
|
if (values.filter((x) => x.isPoint === true).length < 3) {
|
|
3453
|
-
return this.parse(new
|
|
3655
|
+
return this.parse(new point_1.Point(values[0]), new point_1.Point(values[1]), new point_1.Point(values[2]));
|
|
3454
3656
|
}
|
|
3455
3657
|
this._A = values[0].clone();
|
|
3456
3658
|
this._B = values[1].clone();
|
|
3457
3659
|
this._C = values[2].clone();
|
|
3458
3660
|
this._lines = {
|
|
3459
|
-
'AB': new
|
|
3460
|
-
'BC': new
|
|
3461
|
-
'AC': new
|
|
3661
|
+
'AB': new line_1.Line(this._A, this._B),
|
|
3662
|
+
'BC': new line_1.Line(this._B, this._C),
|
|
3663
|
+
'AC': new line_1.Line(this._A, this._C)
|
|
3462
3664
|
};
|
|
3463
3665
|
}
|
|
3464
3666
|
}
|
|
@@ -3484,9 +3686,9 @@ class Triangle {
|
|
|
3484
3686
|
};
|
|
3485
3687
|
_updateTriangle = () => {
|
|
3486
3688
|
this._middles = {
|
|
3487
|
-
'AB': new
|
|
3488
|
-
'AC': new
|
|
3489
|
-
'BC': new
|
|
3689
|
+
'AB': new point_1.Point().middleOf(this._A, this._B),
|
|
3690
|
+
'AC': new point_1.Point().middleOf(this._A, this._C),
|
|
3691
|
+
'BC': new point_1.Point().middleOf(this._B, this._C)
|
|
3490
3692
|
};
|
|
3491
3693
|
this._remarquables = this._calculateRemarquableLines();
|
|
3492
3694
|
};
|
|
@@ -3502,26 +3704,26 @@ class Triangle {
|
|
|
3502
3704
|
return this._A;
|
|
3503
3705
|
};
|
|
3504
3706
|
getSegment = (ptName1, ptName2) => {
|
|
3505
|
-
return new
|
|
3707
|
+
return new vector_1.Vector(this.getPointByName(ptName1), this.getPointByName(ptName2));
|
|
3506
3708
|
};
|
|
3507
3709
|
_calculateRemarquableLines = () => {
|
|
3508
3710
|
let remarquables = {
|
|
3509
3711
|
'medians': {
|
|
3510
|
-
'A': new
|
|
3511
|
-
'B': new
|
|
3512
|
-
'C': new
|
|
3712
|
+
'A': new line_1.Line(this._A, this._middles.BC),
|
|
3713
|
+
'B': new line_1.Line(this._B, this._middles.AC),
|
|
3714
|
+
'C': new line_1.Line(this._C, this._middles.AB),
|
|
3513
3715
|
'intersection': null
|
|
3514
3716
|
},
|
|
3515
3717
|
'mediators': {
|
|
3516
|
-
'AB': new
|
|
3517
|
-
'AC': new
|
|
3518
|
-
'BC': new
|
|
3718
|
+
'AB': new line_1.Line(this._middles.AB, new vector_1.Vector(this._A, this._B).normal()),
|
|
3719
|
+
'AC': new line_1.Line(this._middles.AC, new vector_1.Vector(this._A, this._C).normal()),
|
|
3720
|
+
'BC': new line_1.Line(this._middles.BC, new vector_1.Vector(this._B, this._C).normal()),
|
|
3519
3721
|
'intersection': null
|
|
3520
3722
|
},
|
|
3521
3723
|
'heights': {
|
|
3522
|
-
'A': new
|
|
3523
|
-
'B': new
|
|
3524
|
-
'C': new
|
|
3724
|
+
'A': new line_1.Line(this._A, new vector_1.Vector(this._B, this._C).normal()),
|
|
3725
|
+
'B': new line_1.Line(this._B, new vector_1.Vector(this._A, this._C).normal()),
|
|
3726
|
+
'C': new line_1.Line(this._C, new vector_1.Vector(this._A, this._B).normal()),
|
|
3525
3727
|
'intersection': null
|
|
3526
3728
|
},
|
|
3527
3729
|
'bisectors': {
|
|
@@ -3551,7 +3753,7 @@ class Triangle {
|
|
|
3551
3753
|
d1 = tlines.BC;
|
|
3552
3754
|
d2 = tlines.AC;
|
|
3553
3755
|
}
|
|
3554
|
-
let b1 = new
|
|
3756
|
+
let b1 = new line_1.Line(new equation_1.Equation(d1.equation.left.clone().multiply(d2.n.simplify().norm), d2.equation.left.clone().multiply(d1.n.simplify().norm)).reorder(true).simplify()), b2 = new line_1.Line(new equation_1.Equation(d1.equation.left.clone().multiply(d2.n.simplify().norm), d2.equation.left.clone().multiply(d1.n.simplify().norm).opposed()).reorder(true).simplify());
|
|
3555
3757
|
if (pt === 'A') {
|
|
3556
3758
|
return b1.hitSegment(this.B, this.C) ? b1 : b2;
|
|
3557
3759
|
}
|
|
@@ -3564,6 +3766,7 @@ class Triangle {
|
|
|
3564
3766
|
return b1;
|
|
3565
3767
|
};
|
|
3566
3768
|
}
|
|
3769
|
+
exports.Triangle = Triangle;
|
|
3567
3770
|
|
|
3568
3771
|
|
|
3569
3772
|
/***/ }),
|
|
@@ -3572,30 +3775,24 @@ class Triangle {
|
|
|
3572
3775
|
/*!**************************************!*\
|
|
3573
3776
|
!*** ./src/maths/geometry/vector.ts ***!
|
|
3574
3777
|
\**************************************/
|
|
3575
|
-
/***/ ((__unused_webpack_module,
|
|
3778
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3576
3779
|
|
|
3577
|
-
__webpack_require__.r(__webpack_exports__);
|
|
3578
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3579
|
-
/* harmony export */ "default": () => (/* binding */ Vector)
|
|
3580
|
-
/* harmony export */ });
|
|
3581
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
3582
|
-
/* harmony import */ var _numeric__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
3583
|
-
|
|
3584
3780
|
|
|
3781
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3782
|
+
exports.Vector = void 0;
|
|
3783
|
+
const fraction_1 = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
3784
|
+
const numeric_1 = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
3585
3785
|
class Vector {
|
|
3586
3786
|
_x;
|
|
3587
3787
|
_y;
|
|
3588
3788
|
constructor(...values) {
|
|
3589
|
-
this._x = new
|
|
3590
|
-
this._y = new
|
|
3789
|
+
this._x = new fraction_1.Fraction().zero();
|
|
3790
|
+
this._y = new fraction_1.Fraction().zero();
|
|
3591
3791
|
if (values !== undefined) {
|
|
3592
3792
|
this.parse(...values);
|
|
3593
3793
|
}
|
|
3594
3794
|
}
|
|
3595
3795
|
;
|
|
3596
|
-
get isVector() {
|
|
3597
|
-
return true;
|
|
3598
|
-
}
|
|
3599
3796
|
get x() {
|
|
3600
3797
|
return this._x;
|
|
3601
3798
|
}
|
|
@@ -3623,7 +3820,7 @@ class Vector {
|
|
|
3623
3820
|
return this;
|
|
3624
3821
|
}
|
|
3625
3822
|
if (values.length === 1) {
|
|
3626
|
-
if (values[0]
|
|
3823
|
+
if (values[0] instanceof Vector) {
|
|
3627
3824
|
return values[0].clone();
|
|
3628
3825
|
}
|
|
3629
3826
|
else {
|
|
@@ -3637,10 +3834,10 @@ class Vector {
|
|
|
3637
3834
|
return this;
|
|
3638
3835
|
}
|
|
3639
3836
|
if (values[0].isFraction || !isNaN(values[0])) {
|
|
3640
|
-
this._x = new
|
|
3837
|
+
this._x = new fraction_1.Fraction(values[0]);
|
|
3641
3838
|
}
|
|
3642
3839
|
if (values[1].isFraction || !isNaN(values[1])) {
|
|
3643
|
-
this._y = new
|
|
3840
|
+
this._y = new fraction_1.Fraction(values[1]);
|
|
3644
3841
|
}
|
|
3645
3842
|
}
|
|
3646
3843
|
return this;
|
|
@@ -3662,19 +3859,19 @@ class Vector {
|
|
|
3662
3859
|
};
|
|
3663
3860
|
zero = () => {
|
|
3664
3861
|
this.reset();
|
|
3665
|
-
this._x = new
|
|
3666
|
-
this._y = new
|
|
3862
|
+
this._x = new fraction_1.Fraction(null);
|
|
3863
|
+
this._y = new fraction_1.Fraction(null);
|
|
3667
3864
|
return this;
|
|
3668
3865
|
};
|
|
3669
3866
|
one = () => {
|
|
3670
|
-
this._x = new
|
|
3671
|
-
this._y = new
|
|
3867
|
+
this._x = new fraction_1.Fraction();
|
|
3868
|
+
this._y = new fraction_1.Fraction();
|
|
3672
3869
|
return this;
|
|
3673
3870
|
};
|
|
3674
3871
|
_parseString = (value) => {
|
|
3675
3872
|
let components = value.split(/[,;\s]/g);
|
|
3676
|
-
this.x = new
|
|
3677
|
-
this.y = new
|
|
3873
|
+
this.x = new fraction_1.Fraction(components[0] || null);
|
|
3874
|
+
this.y = new fraction_1.Fraction(components[1] || null);
|
|
3678
3875
|
return this;
|
|
3679
3876
|
};
|
|
3680
3877
|
opposed = () => {
|
|
@@ -3706,17 +3903,17 @@ class Vector {
|
|
|
3706
3903
|
return this.scalarProductWithVector(v).isZero();
|
|
3707
3904
|
};
|
|
3708
3905
|
multiplyByScalar = (k) => {
|
|
3709
|
-
let scalar = new
|
|
3906
|
+
let scalar = new fraction_1.Fraction(k);
|
|
3710
3907
|
this._x.multiply(scalar);
|
|
3711
3908
|
this._y.multiply(scalar);
|
|
3712
3909
|
return this;
|
|
3713
3910
|
};
|
|
3714
3911
|
divideByScalar = (k) => {
|
|
3715
|
-
return this.multiplyByScalar(new
|
|
3912
|
+
return this.multiplyByScalar(new fraction_1.Fraction(k).invert());
|
|
3716
3913
|
};
|
|
3717
3914
|
simplify = () => {
|
|
3718
|
-
return this.multiplyByScalar(
|
|
3719
|
-
.divideByScalar(
|
|
3915
|
+
return this.multiplyByScalar(numeric_1.Numeric.lcm(this._x.denominator, this._y.denominator))
|
|
3916
|
+
.divideByScalar(numeric_1.Numeric.gcd(this._x.numerator, this._y.numerator));
|
|
3720
3917
|
};
|
|
3721
3918
|
angleWith = (V, sharp, radian) => {
|
|
3722
3919
|
let scalar = this.scalarProductWithVector(V).value, toDegree = radian ? 1 : 180 / Math.PI;
|
|
@@ -3726,6 +3923,7 @@ class Vector {
|
|
|
3726
3923
|
return toDegree * Math.acos(scalar / (this.norm * V.norm));
|
|
3727
3924
|
};
|
|
3728
3925
|
}
|
|
3926
|
+
exports.Vector = Vector;
|
|
3729
3927
|
|
|
3730
3928
|
|
|
3731
3929
|
/***/ }),
|
|
@@ -3734,12 +3932,11 @@ class Vector {
|
|
|
3734
3932
|
/*!******************************!*\
|
|
3735
3933
|
!*** ./src/maths/numeric.ts ***!
|
|
3736
3934
|
\******************************/
|
|
3737
|
-
/***/ ((__unused_webpack_module,
|
|
3935
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
3738
3936
|
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
/* harmony export */ });
|
|
3937
|
+
|
|
3938
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3939
|
+
exports.Numeric = void 0;
|
|
3743
3940
|
class Numeric {
|
|
3744
3941
|
static round(value, decimals = 2) {
|
|
3745
3942
|
return Number(Math.round(Number(value + 'e' + decimals)) + 'e-' + decimals);
|
|
@@ -3801,49 +3998,62 @@ class Numeric {
|
|
|
3801
3998
|
});
|
|
3802
3999
|
}
|
|
3803
4000
|
}
|
|
4001
|
+
exports.Numeric = Numeric;
|
|
3804
4002
|
|
|
3805
4003
|
|
|
3806
4004
|
/***/ }),
|
|
3807
4005
|
|
|
3808
|
-
/***/ "./src/maths/random/
|
|
3809
|
-
|
|
3810
|
-
!*** ./src/maths/random/
|
|
3811
|
-
|
|
3812
|
-
/***/ ((__unused_webpack_module,
|
|
4006
|
+
/***/ "./src/maths/random/index.ts":
|
|
4007
|
+
/*!***********************************!*\
|
|
4008
|
+
!*** ./src/maths/random/index.ts ***!
|
|
4009
|
+
\***********************************/
|
|
4010
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3813
4011
|
|
|
3814
|
-
__webpack_require__.r(__webpack_exports__);
|
|
3815
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3816
|
-
/* harmony export */ "Random": () => (/* binding */ Random)
|
|
3817
|
-
/* harmony export */ });
|
|
3818
|
-
/* harmony import */ var _rndPolynom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./rndPolynom */ "./src/maths/random/rndPolynom.ts");
|
|
3819
|
-
/* harmony import */ var _rndMonom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rndMonom */ "./src/maths/random/rndMonom.ts");
|
|
3820
|
-
/* harmony import */ var _rndHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./rndHelpers */ "./src/maths/random/rndHelpers.ts");
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
4012
|
|
|
4013
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4014
|
+
if (k2 === undefined) k2 = k;
|
|
4015
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
4016
|
+
}) : (function(o, m, k, k2) {
|
|
4017
|
+
if (k2 === undefined) k2 = k;
|
|
4018
|
+
o[k2] = m[k];
|
|
4019
|
+
}));
|
|
4020
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
4021
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
4022
|
+
};
|
|
4023
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4024
|
+
exports.Random = void 0;
|
|
4025
|
+
const rndPolynom_1 = __webpack_require__(/*! ./rndPolynom */ "./src/maths/random/rndPolynom.ts");
|
|
4026
|
+
const rndMonom_1 = __webpack_require__(/*! ./rndMonom */ "./src/maths/random/rndMonom.ts");
|
|
4027
|
+
const rndHelpers_1 = __webpack_require__(/*! ./rndHelpers */ "./src/maths/random/rndHelpers.ts");
|
|
4028
|
+
const rndFraction_1 = __webpack_require__(/*! ./rndFraction */ "./src/maths/random/rndFraction.ts");
|
|
4029
|
+
__exportStar(__webpack_require__(/*! ./rndTypes */ "./src/maths/random/rndTypes.ts"), exports);
|
|
3824
4030
|
var Random;
|
|
3825
4031
|
(function (Random) {
|
|
3826
4032
|
function polynom(config) {
|
|
3827
|
-
return new
|
|
4033
|
+
return (new rndPolynom_1.rndPolynom(config)).generate();
|
|
3828
4034
|
}
|
|
3829
4035
|
Random.polynom = polynom;
|
|
3830
4036
|
function monom(config) {
|
|
3831
|
-
return new
|
|
4037
|
+
return (new rndMonom_1.rndMonom(config)).generate();
|
|
3832
4038
|
}
|
|
3833
4039
|
Random.monom = monom;
|
|
3834
|
-
function
|
|
4040
|
+
function fraction(config) {
|
|
4041
|
+
return (new rndFraction_1.rndFraction(config)).generate();
|
|
4042
|
+
}
|
|
4043
|
+
Random.fraction = fraction;
|
|
4044
|
+
function number(from, to) { return rndHelpers_1.rndHelpers.randomInt(from, to); }
|
|
3835
4045
|
Random.number = number;
|
|
3836
|
-
function numberSym(max, allowZero) { return
|
|
4046
|
+
function numberSym(max, allowZero) { return rndHelpers_1.rndHelpers.randomIntSym(max, allowZero); }
|
|
3837
4047
|
Random.numberSym = numberSym;
|
|
3838
|
-
function bool(percent) { return
|
|
4048
|
+
function bool(percent) { return rndHelpers_1.rndHelpers.randomBool(percent); }
|
|
3839
4049
|
Random.bool = bool;
|
|
3840
|
-
function array(arr, number) { return
|
|
4050
|
+
function array(arr, number) { return rndHelpers_1.rndHelpers.randomArray(arr, number); }
|
|
3841
4051
|
Random.array = array;
|
|
3842
|
-
function item(arr) { return
|
|
4052
|
+
function item(arr) { return rndHelpers_1.rndHelpers.randomItem(arr); }
|
|
3843
4053
|
Random.item = item;
|
|
3844
|
-
function shuffle(arr) {
|
|
4054
|
+
function shuffle(arr) { rndHelpers_1.rndHelpers.shuffleArray(arr); }
|
|
3845
4055
|
Random.shuffle = shuffle;
|
|
3846
|
-
})(Random || (Random = {}));
|
|
4056
|
+
})(Random = exports.Random || (exports.Random = {}));
|
|
3847
4057
|
|
|
3848
4058
|
|
|
3849
4059
|
/***/ }),
|
|
@@ -3852,12 +4062,11 @@ var Random;
|
|
|
3852
4062
|
/*!****************************************!*\
|
|
3853
4063
|
!*** ./src/maths/random/randomCore.ts ***!
|
|
3854
4064
|
\****************************************/
|
|
3855
|
-
/***/ ((__unused_webpack_module,
|
|
4065
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
3856
4066
|
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
/* harmony export */ });
|
|
4067
|
+
|
|
4068
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4069
|
+
exports.randomCore = void 0;
|
|
3861
4070
|
class randomCore {
|
|
3862
4071
|
_config;
|
|
3863
4072
|
_defaultConfig;
|
|
@@ -3875,6 +4084,46 @@ class randomCore {
|
|
|
3875
4084
|
return this;
|
|
3876
4085
|
};
|
|
3877
4086
|
}
|
|
4087
|
+
exports.randomCore = randomCore;
|
|
4088
|
+
|
|
4089
|
+
|
|
4090
|
+
/***/ }),
|
|
4091
|
+
|
|
4092
|
+
/***/ "./src/maths/random/rndFraction.ts":
|
|
4093
|
+
/*!*****************************************!*\
|
|
4094
|
+
!*** ./src/maths/random/rndFraction.ts ***!
|
|
4095
|
+
\*****************************************/
|
|
4096
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
4097
|
+
|
|
4098
|
+
|
|
4099
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4100
|
+
exports.rndFraction = void 0;
|
|
4101
|
+
const randomCore_1 = __webpack_require__(/*! ./randomCore */ "./src/maths/random/randomCore.ts");
|
|
4102
|
+
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
4103
|
+
const index_1 = __webpack_require__(/*! ./index */ "./src/maths/random/index.ts");
|
|
4104
|
+
class rndFraction extends randomCore_1.randomCore {
|
|
4105
|
+
constructor(userConfig) {
|
|
4106
|
+
super();
|
|
4107
|
+
this._defaultConfig = {
|
|
4108
|
+
negative: true,
|
|
4109
|
+
reduced: true,
|
|
4110
|
+
zero: true
|
|
4111
|
+
};
|
|
4112
|
+
this._config = this.mergeConfig(userConfig, this._defaultConfig);
|
|
4113
|
+
}
|
|
4114
|
+
generate = () => {
|
|
4115
|
+
let Q = new coefficients_1.Fraction();
|
|
4116
|
+
if (this._config.negative) {
|
|
4117
|
+
Q.numerator = index_1.Random.numberSym(10, this._config.zero);
|
|
4118
|
+
}
|
|
4119
|
+
else {
|
|
4120
|
+
Q.numerator = index_1.Random.number(this._config.zero ? 0 : 1, 10);
|
|
4121
|
+
}
|
|
4122
|
+
Q.denominator = index_1.Random.number(1, 10);
|
|
4123
|
+
return this._config.reduced ? Q.reduce() : Q;
|
|
4124
|
+
};
|
|
4125
|
+
}
|
|
4126
|
+
exports.rndFraction = rndFraction;
|
|
3878
4127
|
|
|
3879
4128
|
|
|
3880
4129
|
/***/ }),
|
|
@@ -3883,12 +4132,11 @@ class randomCore {
|
|
|
3883
4132
|
/*!****************************************!*\
|
|
3884
4133
|
!*** ./src/maths/random/rndHelpers.ts ***!
|
|
3885
4134
|
\****************************************/
|
|
3886
|
-
/***/ ((__unused_webpack_module,
|
|
4135
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
3887
4136
|
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
/* harmony export */ });
|
|
4137
|
+
|
|
4138
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4139
|
+
exports.rndHelpers = void 0;
|
|
3892
4140
|
class rndHelpers {
|
|
3893
4141
|
static randomBool(percent = 0.5) {
|
|
3894
4142
|
return Math.random() < percent;
|
|
@@ -3933,6 +4181,7 @@ class rndHelpers {
|
|
|
3933
4181
|
return shuffleArray;
|
|
3934
4182
|
}
|
|
3935
4183
|
}
|
|
4184
|
+
exports.rndHelpers = rndHelpers;
|
|
3936
4185
|
|
|
3937
4186
|
|
|
3938
4187
|
/***/ }),
|
|
@@ -3941,19 +4190,15 @@ class rndHelpers {
|
|
|
3941
4190
|
/*!**************************************!*\
|
|
3942
4191
|
!*** ./src/maths/random/rndMonom.ts ***!
|
|
3943
4192
|
\**************************************/
|
|
3944
|
-
/***/ ((__unused_webpack_module,
|
|
4193
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3945
4194
|
|
|
3946
|
-
__webpack_require__.r(__webpack_exports__);
|
|
3947
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3948
|
-
/* harmony export */ "default": () => (/* binding */ rndMonom)
|
|
3949
|
-
/* harmony export */ });
|
|
3950
|
-
/* harmony import */ var _randomCore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./randomCore */ "./src/maths/random/randomCore.ts");
|
|
3951
|
-
/* harmony import */ var _random__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./random */ "./src/maths/random/random.ts");
|
|
3952
|
-
/* harmony import */ var _algebra_monom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../algebra/monom */ "./src/maths/algebra/monom.ts");
|
|
3953
|
-
|
|
3954
4195
|
|
|
3955
|
-
|
|
3956
|
-
|
|
4196
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4197
|
+
exports.rndMonom = void 0;
|
|
4198
|
+
const randomCore_1 = __webpack_require__(/*! ./randomCore */ "./src/maths/random/randomCore.ts");
|
|
4199
|
+
const index_1 = __webpack_require__(/*! ./index */ "./src/maths/random/index.ts");
|
|
4200
|
+
const monom_1 = __webpack_require__(/*! ../algebra/monom */ "./src/maths/algebra/monom.ts");
|
|
4201
|
+
class rndMonom extends randomCore_1.randomCore {
|
|
3957
4202
|
constructor(userConfig) {
|
|
3958
4203
|
super();
|
|
3959
4204
|
this._defaultConfig = {
|
|
@@ -3965,15 +4210,18 @@ class rndMonom extends _randomCore__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
3965
4210
|
this._config = this.mergeConfig(userConfig, this._defaultConfig);
|
|
3966
4211
|
}
|
|
3967
4212
|
generate = () => {
|
|
3968
|
-
let M = new
|
|
3969
|
-
M.coefficient
|
|
4213
|
+
let M = new monom_1.Monom();
|
|
4214
|
+
M.coefficient = index_1.Random.fraction({
|
|
4215
|
+
zero: this._config.zero,
|
|
4216
|
+
reduced: true
|
|
4217
|
+
});
|
|
3970
4218
|
if (this._config.letters.length > 1) {
|
|
3971
4219
|
for (let L of this._config.letters.split('')) {
|
|
3972
4220
|
M.setLetter(L, 0);
|
|
3973
4221
|
}
|
|
3974
4222
|
for (let i = 0; i < this._config.degree; i++) {
|
|
3975
|
-
const L =
|
|
3976
|
-
M.setLetter(L, M.degree(L)
|
|
4223
|
+
const L = index_1.Random.item(this._config.letters.split(""));
|
|
4224
|
+
M.setLetter(L, M.degree(L).clone().add(1));
|
|
3977
4225
|
}
|
|
3978
4226
|
}
|
|
3979
4227
|
else {
|
|
@@ -3982,6 +4230,7 @@ class rndMonom extends _randomCore__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
3982
4230
|
return M;
|
|
3983
4231
|
};
|
|
3984
4232
|
}
|
|
4233
|
+
exports.rndMonom = rndMonom;
|
|
3985
4234
|
|
|
3986
4235
|
|
|
3987
4236
|
/***/ }),
|
|
@@ -3990,21 +4239,16 @@ class rndMonom extends _randomCore__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
3990
4239
|
/*!****************************************!*\
|
|
3991
4240
|
!*** ./src/maths/random/rndPolynom.ts ***!
|
|
3992
4241
|
\****************************************/
|
|
3993
|
-
/***/ ((__unused_webpack_module,
|
|
4242
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3994
4243
|
|
|
3995
|
-
__webpack_require__.r(__webpack_exports__);
|
|
3996
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3997
|
-
/* harmony export */ "default": () => (/* binding */ rndPolynom)
|
|
3998
|
-
/* harmony export */ });
|
|
3999
|
-
/* harmony import */ var _randomCore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./randomCore */ "./src/maths/random/randomCore.ts");
|
|
4000
|
-
/* harmony import */ var _rndMonom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rndMonom */ "./src/maths/random/rndMonom.ts");
|
|
4001
|
-
/* harmony import */ var _random__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./random */ "./src/maths/random/random.ts");
|
|
4002
|
-
/* harmony import */ var _algebra_polynom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../algebra/polynom */ "./src/maths/algebra/polynom.ts");
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
4244
|
|
|
4007
|
-
|
|
4245
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4246
|
+
exports.rndPolynom = void 0;
|
|
4247
|
+
const randomCore_1 = __webpack_require__(/*! ./randomCore */ "./src/maths/random/randomCore.ts");
|
|
4248
|
+
const rndMonom_1 = __webpack_require__(/*! ./rndMonom */ "./src/maths/random/rndMonom.ts");
|
|
4249
|
+
const index_1 = __webpack_require__(/*! ./index */ "./src/maths/random/index.ts");
|
|
4250
|
+
const algebra_1 = __webpack_require__(/*! ../algebra */ "./src/maths/algebra/index.ts");
|
|
4251
|
+
class rndPolynom extends randomCore_1.randomCore {
|
|
4008
4252
|
constructor(userConfig) {
|
|
4009
4253
|
super();
|
|
4010
4254
|
this._defaultConfig = {
|
|
@@ -4020,9 +4264,12 @@ class rndPolynom extends _randomCore__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
4020
4264
|
this._config = this.mergeConfig(userConfig, this._defaultConfig);
|
|
4021
4265
|
}
|
|
4022
4266
|
generate = () => {
|
|
4023
|
-
|
|
4267
|
+
if (this._config.factorable && this._config.degree > 1) {
|
|
4268
|
+
return this.factorable();
|
|
4269
|
+
}
|
|
4270
|
+
let P = new algebra_1.Polynom().empty(), M;
|
|
4024
4271
|
for (let i = this._config.degree; i >= 0; i--) {
|
|
4025
|
-
M = new
|
|
4272
|
+
M = new rndMonom_1.rndMonom({
|
|
4026
4273
|
letters: this._config.letters,
|
|
4027
4274
|
degree: i,
|
|
4028
4275
|
fraction: this._config.fraction,
|
|
@@ -4034,16 +4281,34 @@ class rndPolynom extends _randomCore__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
4034
4281
|
P.add(M);
|
|
4035
4282
|
}
|
|
4036
4283
|
if (this._config.numberOfMonoms > 0 && this._config.numberOfMonoms < P.length) {
|
|
4037
|
-
|
|
4038
|
-
P.monoms = _random__WEBPACK_IMPORTED_MODULE_2__.Random.array(P.monoms, this._config.numberOfMonoms);
|
|
4284
|
+
P.monoms = index_1.Random.array(P.monoms, this._config.numberOfMonoms);
|
|
4039
4285
|
}
|
|
4040
4286
|
return P;
|
|
4041
4287
|
};
|
|
4042
4288
|
factorable = () => {
|
|
4043
|
-
let P = new
|
|
4289
|
+
let P = new algebra_1.Polynom().one();
|
|
4290
|
+
let _factorableConfig = { ...this._config };
|
|
4291
|
+
_factorableConfig.degree = 1;
|
|
4292
|
+
_factorableConfig.factorable = false;
|
|
4293
|
+
for (let i = 0; i < this._config.degree; i++) {
|
|
4294
|
+
P.multiply(index_1.Random.polynom(_factorableConfig));
|
|
4295
|
+
}
|
|
4044
4296
|
return P;
|
|
4045
4297
|
};
|
|
4046
4298
|
}
|
|
4299
|
+
exports.rndPolynom = rndPolynom;
|
|
4300
|
+
|
|
4301
|
+
|
|
4302
|
+
/***/ }),
|
|
4303
|
+
|
|
4304
|
+
/***/ "./src/maths/random/rndTypes.ts":
|
|
4305
|
+
/*!**************************************!*\
|
|
4306
|
+
!*** ./src/maths/random/rndTypes.ts ***!
|
|
4307
|
+
\**************************************/
|
|
4308
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
4309
|
+
|
|
4310
|
+
|
|
4311
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4047
4312
|
|
|
4048
4313
|
|
|
4049
4314
|
/***/ }),
|
|
@@ -4052,12 +4317,11 @@ class rndPolynom extends _randomCore__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
4052
4317
|
/*!**********************************!*\
|
|
4053
4318
|
!*** ./src/maths/shutingyard.ts ***!
|
|
4054
4319
|
\**********************************/
|
|
4055
|
-
/***/ ((__unused_webpack_module,
|
|
4320
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
4056
4321
|
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
/* harmony export */ });
|
|
4322
|
+
|
|
4323
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4324
|
+
exports.Shutingyard = void 0;
|
|
4061
4325
|
class Shutingyard {
|
|
4062
4326
|
_rpn = [];
|
|
4063
4327
|
_mode;
|
|
@@ -4287,6 +4551,7 @@ class Shutingyard {
|
|
|
4287
4551
|
return this._rpn;
|
|
4288
4552
|
}
|
|
4289
4553
|
}
|
|
4554
|
+
exports.Shutingyard = Shutingyard;
|
|
4290
4555
|
|
|
4291
4556
|
|
|
4292
4557
|
/***/ })
|
|
@@ -4311,99 +4576,46 @@ class Shutingyard {
|
|
|
4311
4576
|
/******/ };
|
|
4312
4577
|
/******/
|
|
4313
4578
|
/******/ // Execute the module function
|
|
4314
|
-
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
4579
|
+
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
4315
4580
|
/******/
|
|
4316
4581
|
/******/ // Return the exports of the module
|
|
4317
4582
|
/******/ return module.exports;
|
|
4318
4583
|
/******/ }
|
|
4319
4584
|
/******/
|
|
4320
4585
|
/************************************************************************/
|
|
4321
|
-
/******/ /* webpack/runtime/define property getters */
|
|
4322
|
-
/******/ (() => {
|
|
4323
|
-
/******/ // define getter functions for harmony exports
|
|
4324
|
-
/******/ __webpack_require__.d = (exports, definition) => {
|
|
4325
|
-
/******/ for(var key in definition) {
|
|
4326
|
-
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
4327
|
-
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
4328
|
-
/******/ }
|
|
4329
|
-
/******/ }
|
|
4330
|
-
/******/ };
|
|
4331
|
-
/******/ })();
|
|
4332
|
-
/******/
|
|
4333
|
-
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
4334
|
-
/******/ (() => {
|
|
4335
|
-
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
4336
|
-
/******/ })();
|
|
4337
|
-
/******/
|
|
4338
|
-
/******/ /* webpack/runtime/make namespace object */
|
|
4339
|
-
/******/ (() => {
|
|
4340
|
-
/******/ // define __esModule on exports
|
|
4341
|
-
/******/ __webpack_require__.r = (exports) => {
|
|
4342
|
-
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
4343
|
-
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4344
|
-
/******/ }
|
|
4345
|
-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
4346
|
-
/******/ };
|
|
4347
|
-
/******/ })();
|
|
4348
|
-
/******/
|
|
4349
|
-
/************************************************************************/
|
|
4350
4586
|
var __webpack_exports__ = {};
|
|
4351
4587
|
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
4352
4588
|
(() => {
|
|
4589
|
+
var exports = __webpack_exports__;
|
|
4353
4590
|
/*!*********************!*\
|
|
4354
4591
|
!*** ./src/main.ts ***!
|
|
4355
4592
|
\*********************/
|
|
4356
|
-
__webpack_require__.r(__webpack_exports__);
|
|
4357
|
-
/* harmony import */ var _maths_numeric__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./maths/numeric */ "./src/maths/numeric.ts");
|
|
4358
|
-
/* harmony import */ var _maths_shutingyard__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./maths/shutingyard */ "./src/maths/shutingyard.ts");
|
|
4359
|
-
/* harmony import */ var _maths_coefficients_fraction__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./maths/coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
4360
|
-
/* harmony import */ var _maths_coefficients_nthroot__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./maths/coefficients/nthroot */ "./src/maths/coefficients/nthroot.ts");
|
|
4361
|
-
/* harmony import */ var _maths_algebra_monom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./maths/algebra/monom */ "./src/maths/algebra/monom.ts");
|
|
4362
|
-
/* harmony import */ var _maths_algebra_polynom__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./maths/algebra/polynom */ "./src/maths/algebra/polynom.ts");
|
|
4363
|
-
/* harmony import */ var _maths_algebra_equation__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./maths/algebra/equation */ "./src/maths/algebra/equation.ts");
|
|
4364
|
-
/* harmony import */ var _maths_algebra_linearSystem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./maths/algebra/linearSystem */ "./src/maths/algebra/linearSystem.ts");
|
|
4365
|
-
/* harmony import */ var _maths_geometry_line__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./maths/geometry/line */ "./src/maths/geometry/line.ts");
|
|
4366
|
-
/* harmony import */ var _maths_geometry_circle__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./maths/geometry/circle */ "./src/maths/geometry/circle.ts");
|
|
4367
|
-
/* harmony import */ var _maths_algebra_logicalset__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./maths/algebra/logicalset */ "./src/maths/algebra/logicalset.ts");
|
|
4368
|
-
/* harmony import */ var _maths_algebra_rational__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./maths/algebra/rational */ "./src/maths/algebra/rational.ts");
|
|
4369
|
-
/* harmony import */ var _maths_random_random__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./maths/random/random */ "./src/maths/random/random.ts");
|
|
4370
|
-
/* harmony import */ var _maths_geometry_triangle__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./maths/geometry/triangle */ "./src/maths/geometry/triangle.ts");
|
|
4371
|
-
/* harmony import */ var _maths_geometry_point__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./maths/geometry/point */ "./src/maths/geometry/point.ts");
|
|
4372
|
-
/* harmony import */ var _maths_geometry_vector__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./maths/geometry/vector */ "./src/maths/geometry/vector.ts");
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
4593
|
|
|
4594
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4595
|
+
const numeric_1 = __webpack_require__(/*! ./maths/numeric */ "./src/maths/numeric.ts");
|
|
4596
|
+
const shutingyard_1 = __webpack_require__(/*! ./maths/shutingyard */ "./src/maths/shutingyard.ts");
|
|
4597
|
+
const random_1 = __webpack_require__(/*! ./maths/random */ "./src/maths/random/index.ts");
|
|
4598
|
+
const coefficients_1 = __webpack_require__(/*! ./maths/coefficients */ "./src/maths/coefficients/index.ts");
|
|
4599
|
+
const algebra_1 = __webpack_require__(/*! ./maths/algebra */ "./src/maths/algebra/index.ts");
|
|
4600
|
+
const geometry_1 = __webpack_require__(/*! ./maths/geometry */ "./src/maths/geometry/index.ts");
|
|
4389
4601
|
window.Pi = {
|
|
4390
|
-
ShutingYard:
|
|
4391
|
-
Numeric:
|
|
4392
|
-
Fraction:
|
|
4393
|
-
Root:
|
|
4394
|
-
Monom:
|
|
4395
|
-
Polynom:
|
|
4396
|
-
Equation:
|
|
4397
|
-
LinearSystem:
|
|
4398
|
-
Rational:
|
|
4399
|
-
Logicalset:
|
|
4400
|
-
Random:
|
|
4602
|
+
ShutingYard: shutingyard_1.Shutingyard,
|
|
4603
|
+
Numeric: numeric_1.Numeric,
|
|
4604
|
+
Fraction: coefficients_1.Fraction,
|
|
4605
|
+
Root: coefficients_1.Nthroot,
|
|
4606
|
+
Monom: algebra_1.Monom,
|
|
4607
|
+
Polynom: algebra_1.Polynom,
|
|
4608
|
+
Equation: algebra_1.Equation,
|
|
4609
|
+
LinearSystem: algebra_1.LinearSystem,
|
|
4610
|
+
Rational: algebra_1.Rational,
|
|
4611
|
+
Logicalset: algebra_1.Logicalset,
|
|
4612
|
+
Random: random_1.Random,
|
|
4401
4613
|
Geometry: {
|
|
4402
|
-
Vector:
|
|
4403
|
-
Point:
|
|
4404
|
-
Line:
|
|
4405
|
-
Triangle:
|
|
4406
|
-
Circle:
|
|
4614
|
+
Vector: geometry_1.Vector,
|
|
4615
|
+
Point: geometry_1.Point,
|
|
4616
|
+
Line: geometry_1.Line,
|
|
4617
|
+
Triangle: geometry_1.Triangle,
|
|
4618
|
+
Circle: geometry_1.Circle
|
|
4407
4619
|
}
|
|
4408
4620
|
};
|
|
4409
4621
|
|