pimath 0.0.34 → 0.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pi.js +217 -279
- package/dist/pi.js.map +1 -1
- package/dist/pi.min.js +1 -1
- package/dist/pi.min.js.map +1 -1
- package/docs/modules/random.Random.html +1 -1
- package/esm/index.d.ts +41 -0
- package/esm/index.js +47 -0
- package/esm/index.js.map +1 -0
- package/esm/main.d.ts +41 -1
- package/esm/main.js +33 -21
- package/esm/main.js.map +1 -1
- package/esm/maths/algebra/equation.d.ts +1 -1
- package/esm/maths/algebra/equation.js +8 -7
- package/esm/maths/algebra/equation.js.map +1 -1
- package/esm/maths/algebra/linearSystem.d.ts +1 -1
- package/esm/maths/algebra/linearSystem.js +7 -7
- package/esm/maths/algebra/linearSystem.js.map +1 -1
- package/esm/maths/algebra/monom.d.ts +1 -4
- package/esm/maths/algebra/monom.js +28 -28
- package/esm/maths/algebra/monom.js.map +1 -1
- package/esm/maths/algebra/polynom.d.ts +3 -3
- package/esm/maths/algebra/polynom.js +23 -23
- package/esm/maths/algebra/polynom.js.map +1 -1
- package/esm/maths/algebra/rational.d.ts +1 -1
- package/esm/maths/algebra/rational.js +2 -2
- package/esm/maths/algebra/rational.js.map +1 -1
- package/esm/maths/expressions/numexp.js +2 -2
- package/esm/maths/expressions/numexp.js.map +1 -1
- package/esm/maths/expressions/polynomexp.bkp.d.ts +2 -2
- package/esm/maths/expressions/polynomexp.bkp.js +6 -6
- package/esm/maths/expressions/polynomexp.bkp.js.map +1 -1
- package/esm/maths/expressions/polynomexp.d.ts +2 -2
- package/esm/maths/expressions/polynomexp.js +5 -5
- package/esm/maths/expressions/polynomexp.js.map +1 -1
- package/esm/maths/geometry/circle.d.ts +2 -2
- package/esm/maths/geometry/circle.js +16 -15
- package/esm/maths/geometry/circle.js.map +1 -1
- package/esm/maths/geometry/line.d.ts +2 -2
- package/esm/maths/geometry/line.js +19 -18
- package/esm/maths/geometry/line.js.map +1 -1
- package/esm/maths/geometry/point.d.ts +1 -1
- package/esm/maths/geometry/point.js +12 -12
- package/esm/maths/geometry/point.js.map +1 -1
- package/esm/maths/geometry/triangle.d.ts +1 -1
- package/esm/maths/geometry/triangle.js.map +1 -1
- package/esm/maths/geometry/vector.d.ts +1 -1
- package/esm/maths/geometry/vector.js.map +1 -1
- package/esm/maths/{random/index.d.ts → randomization/random.d.ts} +3 -2
- package/esm/maths/{random/index.js → randomization/random.js} +6 -2
- package/esm/maths/randomization/random.js.map +1 -0
- package/esm/maths/{random → randomization}/randomCore.d.ts +0 -0
- package/esm/maths/{random → randomization}/randomCore.js +0 -0
- package/esm/maths/randomization/randomCore.js.map +1 -0
- package/esm/maths/{random → randomization}/rndFraction.d.ts +1 -1
- package/esm/maths/{random → randomization}/rndFraction.js +6 -6
- package/esm/maths/randomization/rndFraction.js.map +1 -0
- package/esm/maths/{random → randomization}/rndHelpers.d.ts +0 -0
- package/esm/maths/{random → randomization}/rndHelpers.js +0 -0
- package/esm/maths/randomization/rndHelpers.js.map +1 -0
- package/esm/maths/{random → randomization}/rndMonom.d.ts +1 -1
- package/esm/maths/{random → randomization}/rndMonom.js +6 -6
- package/esm/maths/randomization/rndMonom.js.map +1 -0
- package/esm/maths/{random → randomization}/rndPolynom.d.ts +1 -1
- package/esm/maths/{random → randomization}/rndPolynom.js +6 -6
- package/esm/maths/randomization/rndPolynom.js.map +1 -0
- package/esm/maths/{random → randomization}/rndTypes.d.ts +0 -0
- package/esm/maths/{random → randomization}/rndTypes.js +0 -0
- package/esm/maths/randomization/rndTypes.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +44 -0
- package/src/maths/algebra/equation.ts +2 -1
- package/src/maths/algebra/linearSystem.ts +2 -2
- package/src/maths/algebra/monom.ts +1 -1
- package/src/maths/algebra/polynom.ts +136 -136
- package/src/maths/algebra/rational.ts +1 -1
- package/src/maths/expressions/numexp.ts +1 -1
- package/src/maths/expressions/polynomexp.bkp.ts +2 -2
- package/src/maths/expressions/polynomexp.ts +2 -2
- package/src/maths/geometry/circle.ts +4 -2
- package/src/maths/geometry/line.ts +3 -2
- package/src/maths/geometry/point.ts +1 -1
- package/src/maths/geometry/triangle.ts +1 -1
- package/src/maths/geometry/vector.ts +1 -1
- package/src/maths/{random/index.ts → randomization/random.ts} +3 -2
- package/src/maths/{random → randomization}/randomCore.ts +0 -0
- package/src/maths/{random → randomization}/rndFraction.ts +2 -2
- package/src/maths/{random → randomization}/rndHelpers.ts +0 -0
- package/src/maths/{random → randomization}/rndMonom.ts +2 -2
- package/src/maths/{random → randomization}/rndPolynom.ts +3 -3
- package/src/maths/{random → randomization}/rndTypes.ts +0 -0
- package/tests/algebra/monom.test.ts +1 -1
- package/tests/algebra/polynom.test.ts +8 -9
- package/webpack-production-min.config.js +1 -1
- package/webpack-production.config.js +1 -1
- package/webpack.config.js +1 -1
- package/esm/maths/algebra/index.d.ts +0 -7
- package/esm/maths/algebra/index.js +0 -20
- package/esm/maths/algebra/index.js.map +0 -1
- package/esm/maths/coefficients/index.d.ts +0 -2
- package/esm/maths/coefficients/index.js +0 -15
- package/esm/maths/coefficients/index.js.map +0 -1
- package/esm/maths/geometry/index.d.ts +0 -5
- package/esm/maths/geometry/index.js +0 -18
- package/esm/maths/geometry/index.js.map +0 -1
- package/esm/maths/random/index.js.map +0 -1
- package/esm/maths/random/randomCore.js.map +0 -1
- package/esm/maths/random/rndFraction.js.map +0 -1
- package/esm/maths/random/rndHelpers.js.map +0 -1
- package/esm/maths/random/rndMonom.js.map +0 -1
- package/esm/maths/random/rndPolynom.js.map +0 -1
- package/esm/maths/random/rndTypes.js.map +0 -1
- package/src/main.ts +0 -42
- package/src/maths/algebra/index.ts +0 -7
- package/src/maths/coefficients/index.ts +0 -2
- package/src/maths/geometry/index.ts +0 -5
package/dist/pi.js
CHANGED
|
@@ -2,6 +2,60 @@
|
|
|
2
2
|
/******/ "use strict";
|
|
3
3
|
/******/ var __webpack_modules__ = ({
|
|
4
4
|
|
|
5
|
+
/***/ 607:
|
|
6
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
var __webpack_unused_export__;
|
|
9
|
+
|
|
10
|
+
__webpack_unused_export__ = ({ value: true });
|
|
11
|
+
exports.l = void 0;
|
|
12
|
+
const numeric_1 = __webpack_require__(956);
|
|
13
|
+
const numexp_1 = __webpack_require__(735);
|
|
14
|
+
const shutingyard_1 = __webpack_require__(505);
|
|
15
|
+
const random_1 = __webpack_require__(330);
|
|
16
|
+
const fraction_1 = __webpack_require__(506);
|
|
17
|
+
const nthroot_1 = __webpack_require__(923);
|
|
18
|
+
const monom_1 = __webpack_require__(937);
|
|
19
|
+
const polynom_1 = __webpack_require__(38);
|
|
20
|
+
const equation_1 = __webpack_require__(760);
|
|
21
|
+
const linearSystem_1 = __webpack_require__(554);
|
|
22
|
+
const rational_1 = __webpack_require__(107);
|
|
23
|
+
const logicalset_1 = __webpack_require__(236);
|
|
24
|
+
const polynomexp_1 = __webpack_require__(75);
|
|
25
|
+
const vector_1 = __webpack_require__(586);
|
|
26
|
+
const line_1 = __webpack_require__(9);
|
|
27
|
+
const triangle_1 = __webpack_require__(164);
|
|
28
|
+
const circle_1 = __webpack_require__(699);
|
|
29
|
+
const point_1 = __webpack_require__(557);
|
|
30
|
+
// Expose as global
|
|
31
|
+
exports.l = {
|
|
32
|
+
ShutingYard: shutingyard_1.Shutingyard,
|
|
33
|
+
Numeric: numeric_1.Numeric,
|
|
34
|
+
NumExp: numexp_1.NumExp,
|
|
35
|
+
Fraction: fraction_1.Fraction,
|
|
36
|
+
Root: nthroot_1.Nthroot,
|
|
37
|
+
Monom: monom_1.Monom,
|
|
38
|
+
Polynom: polynom_1.Polynom,
|
|
39
|
+
Equation: equation_1.Equation,
|
|
40
|
+
LinearSystem: linearSystem_1.LinearSystem,
|
|
41
|
+
Rational: rational_1.Rational,
|
|
42
|
+
Logicalset: logicalset_1.Logicalset,
|
|
43
|
+
Random: random_1.Random,
|
|
44
|
+
PolynomExpFactor: polynomexp_1.PolynomExpFactor,
|
|
45
|
+
PolynomExpProduct: polynomexp_1.PolynomExpProduct,
|
|
46
|
+
Geometry: {
|
|
47
|
+
Vector: vector_1.Vector,
|
|
48
|
+
Point: point_1.Point,
|
|
49
|
+
Line: line_1.Line,
|
|
50
|
+
Triangle: triangle_1.Triangle,
|
|
51
|
+
Circle: circle_1.Circle
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
window.Pi = exports.l;
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
/***/ }),
|
|
58
|
+
|
|
5
59
|
/***/ 760:
|
|
6
60
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
7
61
|
|
|
@@ -10,7 +64,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
10
64
|
exports.Equation = void 0;
|
|
11
65
|
const polynom_1 = __webpack_require__(38);
|
|
12
66
|
const numeric_1 = __webpack_require__(956);
|
|
13
|
-
const
|
|
67
|
+
const fraction_1 = __webpack_require__(506);
|
|
68
|
+
const nthroot_1 = __webpack_require__(923);
|
|
14
69
|
class Equation {
|
|
15
70
|
/**
|
|
16
71
|
* Create an Equation using two polynoms.
|
|
@@ -143,7 +198,7 @@ class Equation {
|
|
|
143
198
|
*/
|
|
144
199
|
this.multiply = (value) => {
|
|
145
200
|
// Make sure we have a fraction.
|
|
146
|
-
let F = new
|
|
201
|
+
let F = new fraction_1.Fraction(value);
|
|
147
202
|
// Multiply each part of the equation by the fraction
|
|
148
203
|
this._left.multiply(F);
|
|
149
204
|
this._right.multiply(F);
|
|
@@ -169,7 +224,7 @@ class Equation {
|
|
|
169
224
|
*/
|
|
170
225
|
this.divide = (value) => {
|
|
171
226
|
// Make sure we have a fraction.
|
|
172
|
-
let F = new
|
|
227
|
+
let F = new fraction_1.Fraction(value);
|
|
173
228
|
if (F.isZero()) {
|
|
174
229
|
return this;
|
|
175
230
|
}
|
|
@@ -182,7 +237,7 @@ class Equation {
|
|
|
182
237
|
* @param letter
|
|
183
238
|
*/
|
|
184
239
|
this.degree = (letter) => {
|
|
185
|
-
return
|
|
240
|
+
return fraction_1.Fraction.max(this._left.degree(letter), this._right.degree(letter));
|
|
186
241
|
};
|
|
187
242
|
/**
|
|
188
243
|
* Determine if the equation contains more than one letter/variable.
|
|
@@ -405,7 +460,7 @@ class Equation {
|
|
|
405
460
|
];
|
|
406
461
|
}
|
|
407
462
|
else {
|
|
408
|
-
nthDelta = new
|
|
463
|
+
nthDelta = new nthroot_1.Nthroot(delta).reduce();
|
|
409
464
|
if (nthDelta.hasRadical()) {
|
|
410
465
|
// -b +- coeff\sqrt{radical}
|
|
411
466
|
// -------------------------
|
|
@@ -477,7 +532,7 @@ class Equation {
|
|
|
477
532
|
}
|
|
478
533
|
else {
|
|
479
534
|
// -b +- d / 2a
|
|
480
|
-
const S1 = new
|
|
535
|
+
const S1 = new fraction_1.Fraction(-b - nthDelta.coefficient, 2 * a).reduce(), S2 = new fraction_1.Fraction(-b + nthDelta.coefficient, 2 * a).reduce();
|
|
481
536
|
this._solutions = [
|
|
482
537
|
{
|
|
483
538
|
tex: S1.dfrac,
|
|
@@ -494,7 +549,7 @@ class Equation {
|
|
|
494
549
|
}
|
|
495
550
|
}
|
|
496
551
|
else if (delta === 0) {
|
|
497
|
-
const sol = new
|
|
552
|
+
const sol = new fraction_1.Fraction(-b, 2 * a).reduce();
|
|
498
553
|
this._solutions = [{
|
|
499
554
|
tex: sol.dfrac,
|
|
500
555
|
value: sol.value,
|
|
@@ -700,36 +755,6 @@ class Equation {
|
|
|
700
755
|
exports.Equation = Equation;
|
|
701
756
|
|
|
702
757
|
|
|
703
|
-
/***/ }),
|
|
704
|
-
|
|
705
|
-
/***/ 667:
|
|
706
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
710
|
-
if (k2 === undefined) k2 = k;
|
|
711
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
712
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
713
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
714
|
-
}
|
|
715
|
-
Object.defineProperty(o, k2, desc);
|
|
716
|
-
}) : (function(o, m, k, k2) {
|
|
717
|
-
if (k2 === undefined) k2 = k;
|
|
718
|
-
o[k2] = m[k];
|
|
719
|
-
}));
|
|
720
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
721
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
722
|
-
};
|
|
723
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
724
|
-
__exportStar(__webpack_require__(760), exports);
|
|
725
|
-
__exportStar(__webpack_require__(554), exports);
|
|
726
|
-
__exportStar(__webpack_require__(236), exports);
|
|
727
|
-
__exportStar(__webpack_require__(937), exports);
|
|
728
|
-
__exportStar(__webpack_require__(38), exports);
|
|
729
|
-
__exportStar(__webpack_require__(107), exports);
|
|
730
|
-
__exportStar(__webpack_require__(75), exports);
|
|
731
|
-
|
|
732
|
-
|
|
733
758
|
/***/ }),
|
|
734
759
|
|
|
735
760
|
/***/ 554:
|
|
@@ -738,10 +763,10 @@ __exportStar(__webpack_require__(75), exports);
|
|
|
738
763
|
|
|
739
764
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
740
765
|
exports.LinearSystem = void 0;
|
|
741
|
-
const coefficients_1 = __webpack_require__(534);
|
|
742
766
|
const equation_1 = __webpack_require__(760);
|
|
743
767
|
const polynom_1 = __webpack_require__(38);
|
|
744
|
-
const random_1 = __webpack_require__(
|
|
768
|
+
const random_1 = __webpack_require__(330);
|
|
769
|
+
const fraction_1 = __webpack_require__(506);
|
|
745
770
|
// TODO: Must check and rework
|
|
746
771
|
class LinearSystem {
|
|
747
772
|
constructor(...equationStrings) {
|
|
@@ -790,7 +815,7 @@ class LinearSystem {
|
|
|
790
815
|
// Convert the numbers to fractions if necessary
|
|
791
816
|
for (let s of solutions) {
|
|
792
817
|
if (typeof s === "number") {
|
|
793
|
-
solutionsF.push(new
|
|
818
|
+
solutionsF.push(new fraction_1.Fraction(s.toString()));
|
|
794
819
|
}
|
|
795
820
|
else {
|
|
796
821
|
solutionsF.push(s.clone());
|
|
@@ -804,7 +829,7 @@ class LinearSystem {
|
|
|
804
829
|
return this;
|
|
805
830
|
};
|
|
806
831
|
this._generateOneEquation = (...solutions) => {
|
|
807
|
-
let coeff = [], leftValue = new
|
|
832
|
+
let coeff = [], leftValue = new fraction_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;
|
|
808
833
|
for (let i = 0; i < solutions.length; i++) {
|
|
809
834
|
coeff.push(random_1.Random.numberSym(5));
|
|
810
835
|
leftValue.add(solutions[i].clone().multiply(coeff[i]));
|
|
@@ -815,7 +840,7 @@ class LinearSystem {
|
|
|
815
840
|
// Must check if it's not a linear combination
|
|
816
841
|
equ = new equation_1.Equation(`${equString}=${leftValue.display}`);
|
|
817
842
|
if (equ.right.monoms[0].coefficient.denominator != 1) {
|
|
818
|
-
equ.multiply(new
|
|
843
|
+
equ.multiply(new fraction_1.Fraction(equ.right.monoms[0].coefficient.denominator, 1));
|
|
819
844
|
}
|
|
820
845
|
if (this._checkIfLinerCombination(equ)) {
|
|
821
846
|
return equ;
|
|
@@ -826,7 +851,7 @@ class LinearSystem {
|
|
|
826
851
|
};
|
|
827
852
|
this.mergeEquations = (eq1, eq2, factor1, factor2) => {
|
|
828
853
|
// Set and clone the equations.
|
|
829
|
-
let eq1multiplied = eq1.clone().multiply(new
|
|
854
|
+
let eq1multiplied = eq1.clone().multiply(new fraction_1.Fraction(factor1)), eq2multiplied = eq2.clone().multiply(new fraction_1.Fraction(factor2));
|
|
830
855
|
// Add both equations together.
|
|
831
856
|
eq1multiplied.left.add(eq2multiplied.left);
|
|
832
857
|
eq1multiplied.right.add(eq2multiplied.right);
|
|
@@ -988,7 +1013,7 @@ class LinearSystem {
|
|
|
988
1013
|
let E = this._resolutionSteps[this._resolutionSteps.length - 1].equations[0];
|
|
989
1014
|
E.solve();
|
|
990
1015
|
return {
|
|
991
|
-
value: new
|
|
1016
|
+
value: new fraction_1.Fraction(E.solutions[0].value),
|
|
992
1017
|
isReal: E.isReal,
|
|
993
1018
|
isVarnothing: E.isVarnothing
|
|
994
1019
|
};
|
|
@@ -1172,9 +1197,9 @@ exports.Monom = void 0;
|
|
|
1172
1197
|
/***
|
|
1173
1198
|
* Monom class
|
|
1174
1199
|
*/
|
|
1175
|
-
const coefficients_1 = __webpack_require__(534);
|
|
1176
1200
|
const numeric_1 = __webpack_require__(956);
|
|
1177
1201
|
const shutingyard_1 = __webpack_require__(505);
|
|
1202
|
+
const fraction_1 = __webpack_require__(506);
|
|
1178
1203
|
class Monom {
|
|
1179
1204
|
/**
|
|
1180
1205
|
* Create a Monom
|
|
@@ -1195,10 +1220,10 @@ class Monom {
|
|
|
1195
1220
|
this._shutingYardToReducedMonom(inputStr);
|
|
1196
1221
|
}
|
|
1197
1222
|
else if (typeof inputStr === 'number') {
|
|
1198
|
-
this._coefficient = new
|
|
1223
|
+
this._coefficient = new fraction_1.Fraction(inputStr);
|
|
1199
1224
|
this._literal = {};
|
|
1200
1225
|
}
|
|
1201
|
-
else if (inputStr instanceof
|
|
1226
|
+
else if (inputStr instanceof fraction_1.Fraction) {
|
|
1202
1227
|
this._coefficient = inputStr.clone();
|
|
1203
1228
|
this._literal = {};
|
|
1204
1229
|
}
|
|
@@ -1221,7 +1246,7 @@ class Monom {
|
|
|
1221
1246
|
const element = rpn[0];
|
|
1222
1247
|
this.one();
|
|
1223
1248
|
if (element.tokenType === 'coefficient') {
|
|
1224
|
-
this.coefficient = new
|
|
1249
|
+
this.coefficient = new fraction_1.Fraction(element.token);
|
|
1225
1250
|
}
|
|
1226
1251
|
else if (element.tokenType === 'variable') {
|
|
1227
1252
|
this.setLetter(element.token, 1);
|
|
@@ -1268,7 +1293,7 @@ class Monom {
|
|
|
1268
1293
|
* Create a zero value monom
|
|
1269
1294
|
*/
|
|
1270
1295
|
this.zero = () => {
|
|
1271
|
-
this._coefficient = new
|
|
1296
|
+
this._coefficient = new fraction_1.Fraction().zero();
|
|
1272
1297
|
this._literal = {};
|
|
1273
1298
|
return this;
|
|
1274
1299
|
};
|
|
@@ -1276,7 +1301,7 @@ class Monom {
|
|
|
1276
1301
|
* Create a one value monom
|
|
1277
1302
|
*/
|
|
1278
1303
|
this.one = () => {
|
|
1279
|
-
this._coefficient = new
|
|
1304
|
+
this._coefficient = new fraction_1.Fraction().one();
|
|
1280
1305
|
this._literal = {};
|
|
1281
1306
|
return this;
|
|
1282
1307
|
};
|
|
@@ -1521,7 +1546,7 @@ class Monom {
|
|
|
1521
1546
|
* @param pow (number) Power of the setLetter (must be positive integer.
|
|
1522
1547
|
*/
|
|
1523
1548
|
this.setLetter = (letter, pow) => {
|
|
1524
|
-
if (pow instanceof
|
|
1549
|
+
if (pow instanceof fraction_1.Fraction) {
|
|
1525
1550
|
// Set the power of the letter to zero => remove it
|
|
1526
1551
|
if (this.hasLetter(letter) && pow.isZero()) {
|
|
1527
1552
|
delete this._literal[letter];
|
|
@@ -1529,7 +1554,7 @@ class Monom {
|
|
|
1529
1554
|
this._literal[letter] = pow.clone();
|
|
1530
1555
|
}
|
|
1531
1556
|
else {
|
|
1532
|
-
this.setLetter(letter, new
|
|
1557
|
+
this.setLetter(letter, new fraction_1.Fraction(pow));
|
|
1533
1558
|
}
|
|
1534
1559
|
};
|
|
1535
1560
|
/**
|
|
@@ -1538,7 +1563,7 @@ class Monom {
|
|
|
1538
1563
|
*/
|
|
1539
1564
|
this.degree = (letter) => {
|
|
1540
1565
|
if (this.variables.length === 0) {
|
|
1541
|
-
return new
|
|
1566
|
+
return new fraction_1.Fraction().zero();
|
|
1542
1567
|
}
|
|
1543
1568
|
if (letter === undefined) {
|
|
1544
1569
|
// Not setLetter given -> we get the global monom degree (sum of all the letters).
|
|
@@ -1546,7 +1571,7 @@ class Monom {
|
|
|
1546
1571
|
}
|
|
1547
1572
|
else {
|
|
1548
1573
|
// A setLetter is given -> get the corresponding power.
|
|
1549
|
-
return this._literal[letter] === undefined ? new
|
|
1574
|
+
return this._literal[letter] === undefined ? new fraction_1.Fraction().zero() : this._literal[letter].clone();
|
|
1550
1575
|
}
|
|
1551
1576
|
};
|
|
1552
1577
|
/**
|
|
@@ -1555,17 +1580,17 @@ class Monom {
|
|
|
1555
1580
|
*/
|
|
1556
1581
|
this.evaluate = (values) => {
|
|
1557
1582
|
let r = this.coefficient.clone();
|
|
1558
|
-
if (typeof values === 'number' || values instanceof
|
|
1583
|
+
if (typeof values === 'number' || values instanceof fraction_1.Fraction) {
|
|
1559
1584
|
let tmpValues = {};
|
|
1560
|
-
tmpValues[this.variables[0]] = new
|
|
1585
|
+
tmpValues[this.variables[0]] = new fraction_1.Fraction(values);
|
|
1561
1586
|
return this.evaluate(tmpValues);
|
|
1562
1587
|
}
|
|
1563
1588
|
if (typeof values === 'object') {
|
|
1564
1589
|
for (let L in this._literal) {
|
|
1565
1590
|
if (values[L] === undefined) {
|
|
1566
|
-
return new
|
|
1591
|
+
return new fraction_1.Fraction().zero();
|
|
1567
1592
|
}
|
|
1568
|
-
let value = new
|
|
1593
|
+
let value = new fraction_1.Fraction(values[L]);
|
|
1569
1594
|
r.multiply(value.pow(this._literal[L]));
|
|
1570
1595
|
}
|
|
1571
1596
|
}
|
|
@@ -1585,7 +1610,7 @@ class Monom {
|
|
|
1585
1610
|
// Subtract one to the degree.
|
|
1586
1611
|
dM._literal[letter].subtract(1);
|
|
1587
1612
|
// Multiply the coefficient by the previous degree
|
|
1588
|
-
dM._coefficient.multiply(new
|
|
1613
|
+
dM._coefficient.multiply(new fraction_1.Fraction(d.clone()));
|
|
1589
1614
|
return dM;
|
|
1590
1615
|
}
|
|
1591
1616
|
else {
|
|
@@ -1608,7 +1633,7 @@ class Monom {
|
|
|
1608
1633
|
// There is no letter.
|
|
1609
1634
|
// The coefficient might be zero (=> x) or a number a (=> ax)
|
|
1610
1635
|
if (M.coefficient.isZero()) {
|
|
1611
|
-
M.coefficient = new
|
|
1636
|
+
M.coefficient = new fraction_1.Fraction().one();
|
|
1612
1637
|
}
|
|
1613
1638
|
M.setLetter(letter, 1);
|
|
1614
1639
|
}
|
|
@@ -1670,7 +1695,7 @@ class Monom {
|
|
|
1670
1695
|
* @param {Fraction | number | string} F
|
|
1671
1696
|
*/
|
|
1672
1697
|
set coefficient(F) {
|
|
1673
|
-
this._coefficient = new
|
|
1698
|
+
this._coefficient = new fraction_1.Fraction(F);
|
|
1674
1699
|
}
|
|
1675
1700
|
/**
|
|
1676
1701
|
* Get the literal part of \\(x^{n_1}y^{n_2}\\) as dictionary \\[\\begin{array}{ll}x&=n_1\\\\y&=n_2\\end{array}\\]
|
|
@@ -1713,7 +1738,7 @@ class Monom {
|
|
|
1713
1738
|
for (const v of [...inputStr.matchAll(/([a-z])\^([+-]?[0-9]+)/g)]) {
|
|
1714
1739
|
// Create the default letter entry if necessary.
|
|
1715
1740
|
if (!(v[1] in this._literal)) {
|
|
1716
|
-
this._literal[v[1]] = new
|
|
1741
|
+
this._literal[v[1]] = new fraction_1.Fraction().zero();
|
|
1717
1742
|
}
|
|
1718
1743
|
// Add the new value.
|
|
1719
1744
|
// TODO: actually, it adds only numeric value
|
|
@@ -1723,7 +1748,7 @@ class Monom {
|
|
|
1723
1748
|
for (const v of [...inputStr.matchAll(/([a-z](?!\^))/g)]) {
|
|
1724
1749
|
// Match all single letters
|
|
1725
1750
|
if (!(v[1] in this._literal)) {
|
|
1726
|
-
this._literal[v[1]] = new
|
|
1751
|
+
this._literal[v[1]] = new fraction_1.Fraction().zero();
|
|
1727
1752
|
}
|
|
1728
1753
|
// Add one to the value.
|
|
1729
1754
|
this._literal[v[1]].add(1);
|
|
@@ -1800,7 +1825,7 @@ class Monom {
|
|
|
1800
1825
|
for (let N of dividers) {
|
|
1801
1826
|
for (let L of literals) {
|
|
1802
1827
|
let M = new Monom();
|
|
1803
|
-
M.coefficient = new
|
|
1828
|
+
M.coefficient = new fraction_1.Fraction(N);
|
|
1804
1829
|
M.literal = L;
|
|
1805
1830
|
monomDividers.push(M);
|
|
1806
1831
|
}
|
|
@@ -1809,7 +1834,7 @@ class Monom {
|
|
|
1809
1834
|
else if (dividers.length === 0) {
|
|
1810
1835
|
for (let L of literals) {
|
|
1811
1836
|
let M = new Monom();
|
|
1812
|
-
M.coefficient = new
|
|
1837
|
+
M.coefficient = new fraction_1.Fraction().one();
|
|
1813
1838
|
M.literal = L;
|
|
1814
1839
|
monomDividers.push(M);
|
|
1815
1840
|
}
|
|
@@ -1817,7 +1842,7 @@ class Monom {
|
|
|
1817
1842
|
else {
|
|
1818
1843
|
for (let N of dividers) {
|
|
1819
1844
|
let M = new Monom();
|
|
1820
|
-
M.coefficient = new
|
|
1845
|
+
M.coefficient = new fraction_1.Fraction(N);
|
|
1821
1846
|
monomDividers.push(M);
|
|
1822
1847
|
}
|
|
1823
1848
|
}
|
|
@@ -1829,7 +1854,7 @@ class Monom {
|
|
|
1829
1854
|
for (let d = 0; d <= this.literal[letter].value; d++) {
|
|
1830
1855
|
if (arr.length === 0) {
|
|
1831
1856
|
let litt = {};
|
|
1832
|
-
litt[letter] = new
|
|
1857
|
+
litt[letter] = new fraction_1.Fraction(d);
|
|
1833
1858
|
tmpList.push(litt);
|
|
1834
1859
|
}
|
|
1835
1860
|
else {
|
|
@@ -1838,7 +1863,7 @@ class Monom {
|
|
|
1838
1863
|
for (let currentLetter in item) {
|
|
1839
1864
|
litt[currentLetter] = item[currentLetter];
|
|
1840
1865
|
}
|
|
1841
|
-
litt[letter] = new
|
|
1866
|
+
litt[letter] = new fraction_1.Fraction(d);
|
|
1842
1867
|
tmpList.push(litt);
|
|
1843
1868
|
}
|
|
1844
1869
|
}
|
|
@@ -1913,7 +1938,7 @@ exports.Monom = Monom;
|
|
|
1913
1938
|
Monom.addToken = (stack, element) => {
|
|
1914
1939
|
let q1, q2, m, letter, pow;
|
|
1915
1940
|
if (element.tokenType === shutingyard_1.ShutingyardType.COEFFICIENT) {
|
|
1916
|
-
stack.push(new Monom(new
|
|
1941
|
+
stack.push(new Monom(new fraction_1.Fraction(element.token)));
|
|
1917
1942
|
}
|
|
1918
1943
|
else if (element.tokenType === shutingyard_1.ShutingyardType.VARIABLE) {
|
|
1919
1944
|
let M = new Monom().one();
|
|
@@ -1942,7 +1967,7 @@ Monom.addToken = (stack, element) => {
|
|
|
1942
1967
|
break;
|
|
1943
1968
|
case '^':
|
|
1944
1969
|
// get the two last elements in the stack
|
|
1945
|
-
pow = (stack.pop().coefficient) || new
|
|
1970
|
+
pow = (stack.pop().coefficient) || new fraction_1.Fraction().one();
|
|
1946
1971
|
m = (stack.pop()) || new Monom().one();
|
|
1947
1972
|
letter = m.variables[0];
|
|
1948
1973
|
if (letter !== undefined) {
|
|
@@ -1970,7 +1995,7 @@ Monom.lcm = (...monoms) => {
|
|
|
1970
1995
|
}
|
|
1971
1996
|
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);
|
|
1972
1997
|
// Get the coefficient.
|
|
1973
|
-
M.coefficient = new
|
|
1998
|
+
M.coefficient = new fraction_1.Fraction(n, d).reduce();
|
|
1974
1999
|
// Set the literal parts - go through each monoms literal parts and get only the lowest degree of each letters.
|
|
1975
2000
|
for (let m of monoms) {
|
|
1976
2001
|
// Remove the inexistant letters from the resulting monom
|
|
@@ -1984,7 +2009,7 @@ Monom.lcm = (...monoms) => {
|
|
|
1984
2009
|
M.literal[letter] = m.literal[letter].clone();
|
|
1985
2010
|
}
|
|
1986
2011
|
else {
|
|
1987
|
-
M.literal[letter] = new
|
|
2012
|
+
M.literal[letter] = new fraction_1.Fraction(Math.min(m.literal[letter].value, M.literal[letter].value));
|
|
1988
2013
|
}
|
|
1989
2014
|
}
|
|
1990
2015
|
}
|
|
@@ -2017,7 +2042,7 @@ exports.Polynom = void 0;
|
|
|
2017
2042
|
const monom_1 = __webpack_require__(937);
|
|
2018
2043
|
const shutingyard_1 = __webpack_require__(505);
|
|
2019
2044
|
const numeric_1 = __webpack_require__(956);
|
|
2020
|
-
const
|
|
2045
|
+
const fraction_1 = __webpack_require__(506);
|
|
2021
2046
|
/**
|
|
2022
2047
|
* Polynom class can handle polynoms, reorder, resolve, ...
|
|
2023
2048
|
* ```
|
|
@@ -2044,7 +2069,7 @@ class Polynom {
|
|
|
2044
2069
|
if (typeof inputStr === 'string') {
|
|
2045
2070
|
return this._parseString(inputStr, ...values);
|
|
2046
2071
|
}
|
|
2047
|
-
else if (typeof inputStr === 'number' || inputStr instanceof
|
|
2072
|
+
else if (typeof inputStr === 'number' || inputStr instanceof fraction_1.Fraction || inputStr instanceof monom_1.Monom) {
|
|
2048
2073
|
this._monoms.push(new monom_1.Monom(inputStr));
|
|
2049
2074
|
}
|
|
2050
2075
|
else if (inputStr instanceof Polynom) {
|
|
@@ -2195,7 +2220,7 @@ class Polynom {
|
|
|
2195
2220
|
if (value instanceof Polynom) {
|
|
2196
2221
|
return this.multiplyByPolynom(value);
|
|
2197
2222
|
}
|
|
2198
|
-
else if (value instanceof
|
|
2223
|
+
else if (value instanceof fraction_1.Fraction) {
|
|
2199
2224
|
return this.multiplyByFraction(value);
|
|
2200
2225
|
}
|
|
2201
2226
|
else if (value instanceof monom_1.Monom) {
|
|
@@ -2242,7 +2267,7 @@ class Polynom {
|
|
|
2242
2267
|
return { quotient, reminder };
|
|
2243
2268
|
};
|
|
2244
2269
|
this.divide = (value) => {
|
|
2245
|
-
if (value instanceof
|
|
2270
|
+
if (value instanceof fraction_1.Fraction) {
|
|
2246
2271
|
return this.divideByFraction(value);
|
|
2247
2272
|
}
|
|
2248
2273
|
else if (typeof value === 'number' && Number.isSafeInteger(value)) {
|
|
@@ -2430,9 +2455,9 @@ class Polynom {
|
|
|
2430
2455
|
return this.reduce();
|
|
2431
2456
|
};
|
|
2432
2457
|
this.degree = (letter) => {
|
|
2433
|
-
let d = new
|
|
2458
|
+
let d = new fraction_1.Fraction().zero();
|
|
2434
2459
|
for (const m of this._monoms) {
|
|
2435
|
-
d =
|
|
2460
|
+
d = fraction_1.Fraction.max(m.degree(letter).value, d);
|
|
2436
2461
|
}
|
|
2437
2462
|
return d;
|
|
2438
2463
|
};
|
|
@@ -2470,7 +2495,7 @@ class Polynom {
|
|
|
2470
2495
|
};
|
|
2471
2496
|
// Evaluate a polynom.
|
|
2472
2497
|
this.evaluate = (values) => {
|
|
2473
|
-
const r = new
|
|
2498
|
+
const r = new fraction_1.Fraction().zero();
|
|
2474
2499
|
this._monoms.forEach(monom => {
|
|
2475
2500
|
//console.log('Evaluate polynom: ', monom.display, values, monom.evaluate(values).display);
|
|
2476
2501
|
r.add(monom.evaluate(values));
|
|
@@ -2499,8 +2524,8 @@ class Polynom {
|
|
|
2499
2524
|
letter = 'x';
|
|
2500
2525
|
}
|
|
2501
2526
|
let valuesA = {}, valuesB = {};
|
|
2502
|
-
valuesA[letter] = new
|
|
2503
|
-
valuesB[letter] = new
|
|
2527
|
+
valuesA[letter] = new fraction_1.Fraction(a);
|
|
2528
|
+
valuesB[letter] = new fraction_1.Fraction(b);
|
|
2504
2529
|
return primitive.evaluate(valuesB).subtract(primitive.evaluate(valuesA));
|
|
2505
2530
|
};
|
|
2506
2531
|
// -------------------------------------
|
|
@@ -2570,7 +2595,7 @@ class Polynom {
|
|
|
2570
2595
|
case 1:
|
|
2571
2596
|
// There is only one monoms,
|
|
2572
2597
|
if (this._monoms.length === 1) {
|
|
2573
|
-
return [new
|
|
2598
|
+
return [new fraction_1.Fraction().zero()];
|
|
2574
2599
|
}
|
|
2575
2600
|
else {
|
|
2576
2601
|
const P = this.clone().reduce().reorder();
|
|
@@ -2593,8 +2618,8 @@ class Polynom {
|
|
|
2593
2618
|
if (D.value > 0) {
|
|
2594
2619
|
/*console.log('Two zeroes for ', P.tex); */
|
|
2595
2620
|
let x1 = (-(B.value) + Math.sqrt(D.value)) / (2 * A.value), x2 = (-(B.value) - Math.sqrt(D.value)) / (2 * A.value);
|
|
2596
|
-
zeroes.push(new
|
|
2597
|
-
zeroes.push(new
|
|
2621
|
+
zeroes.push(new fraction_1.Fraction(x1.toFixed(3)).reduce());
|
|
2622
|
+
zeroes.push(new fraction_1.Fraction(x2.toFixed(3)).reduce());
|
|
2598
2623
|
}
|
|
2599
2624
|
else if (D.value === 0) {
|
|
2600
2625
|
/*console.log('One zero for ', P.tex); */
|
|
@@ -2698,12 +2723,12 @@ class Polynom {
|
|
|
2698
2723
|
let M = new monom_1.Monom().one(), numerator, denominator, degree = this.degree();
|
|
2699
2724
|
numerator = this.gcdNumerator();
|
|
2700
2725
|
denominator = this.gcdDenominator();
|
|
2701
|
-
M.coefficient = new
|
|
2726
|
+
M.coefficient = new fraction_1.Fraction(numerator, denominator);
|
|
2702
2727
|
for (let L of this.variables) {
|
|
2703
2728
|
// Initialize the setLetter with the max degree
|
|
2704
2729
|
M.setLetter(L, degree);
|
|
2705
2730
|
for (let m of this._monoms) {
|
|
2706
|
-
M.setLetter(L,
|
|
2731
|
+
M.setLetter(L, fraction_1.Fraction.min(m.degree(L), M.degree(L)));
|
|
2707
2732
|
if (M.degree(L).isZero()) {
|
|
2708
2733
|
break;
|
|
2709
2734
|
}
|
|
@@ -2804,7 +2829,7 @@ class Polynom {
|
|
|
2804
2829
|
return this.reduce();
|
|
2805
2830
|
};
|
|
2806
2831
|
this.multiplyByInteger = (nb) => {
|
|
2807
|
-
return this.multiplyByFraction(new
|
|
2832
|
+
return this.multiplyByFraction(new fraction_1.Fraction(nb));
|
|
2808
2833
|
};
|
|
2809
2834
|
this.multiplyByMonom = (M) => {
|
|
2810
2835
|
for (const m of this._monoms) {
|
|
@@ -2813,7 +2838,7 @@ class Polynom {
|
|
|
2813
2838
|
return this.reduce();
|
|
2814
2839
|
};
|
|
2815
2840
|
this.divideByInteger = (nb) => {
|
|
2816
|
-
const nbF = new
|
|
2841
|
+
const nbF = new fraction_1.Fraction(nb);
|
|
2817
2842
|
for (const m of this._monoms) {
|
|
2818
2843
|
m.coefficient.divide(nbF);
|
|
2819
2844
|
}
|
|
@@ -3013,6 +3038,12 @@ class Polynom {
|
|
|
3013
3038
|
get numberOfVars() {
|
|
3014
3039
|
return this.variables.length;
|
|
3015
3040
|
}
|
|
3041
|
+
isZero() {
|
|
3042
|
+
return (this._monoms.length === 1 && this._monoms[0].coefficient.isZero()) || this._monoms.length === 0;
|
|
3043
|
+
}
|
|
3044
|
+
isOne() {
|
|
3045
|
+
return this._monoms.length === 1 && this._monoms[0].coefficient.isOne();
|
|
3046
|
+
}
|
|
3016
3047
|
_parseString(inputStr, ...values) {
|
|
3017
3048
|
if (values === undefined || values.length === 0) {
|
|
3018
3049
|
inputStr = '' + inputStr;
|
|
@@ -3033,7 +3064,7 @@ class Polynom {
|
|
|
3033
3064
|
else if (/^[a-z]/.test(inputStr)) {
|
|
3034
3065
|
// We assume the inputStr contains only letters.
|
|
3035
3066
|
this.empty();
|
|
3036
|
-
let fractions = values.map(x => new
|
|
3067
|
+
let fractions = values.map(x => new fraction_1.Fraction(x));
|
|
3037
3068
|
// Multiple setLetter version
|
|
3038
3069
|
if (inputStr.length > 1) {
|
|
3039
3070
|
// TODO: check that the number of values given correspond to the letters (+1 eventually)
|
|
@@ -3063,12 +3094,6 @@ class Polynom {
|
|
|
3063
3094
|
return this.zero();
|
|
3064
3095
|
}
|
|
3065
3096
|
}
|
|
3066
|
-
isZero() {
|
|
3067
|
-
return (this._monoms.length === 1 && this._monoms[0].coefficient.isZero()) || this._monoms.length === 0;
|
|
3068
|
-
}
|
|
3069
|
-
isOne() {
|
|
3070
|
-
return this._monoms.length === 1 && this._monoms[0].coefficient.isOne();
|
|
3071
|
-
}
|
|
3072
3097
|
}
|
|
3073
3098
|
exports.Polynom = Polynom;
|
|
3074
3099
|
Polynom.addToken = (stack, element) => {
|
|
@@ -3162,7 +3187,7 @@ Polynom.addToken = (stack, element) => {
|
|
|
3162
3187
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3163
3188
|
exports.Rational = void 0;
|
|
3164
3189
|
const polynom_1 = __webpack_require__(38);
|
|
3165
|
-
const
|
|
3190
|
+
const fraction_1 = __webpack_require__(506);
|
|
3166
3191
|
/**
|
|
3167
3192
|
* Rational class can handle rational polynoms
|
|
3168
3193
|
*/
|
|
@@ -3255,7 +3280,7 @@ class Rational {
|
|
|
3255
3280
|
}
|
|
3256
3281
|
}
|
|
3257
3282
|
else {
|
|
3258
|
-
return this._numerator.evaluate({ letter: new
|
|
3283
|
+
return this._numerator.evaluate({ letter: new fraction_1.Fraction(value) }).divide(this._denominator.evaluate({ letter: new fraction_1.Fraction(value) }));
|
|
3259
3284
|
}
|
|
3260
3285
|
};
|
|
3261
3286
|
this._numerator = numerator ? numerator.clone() : new polynom_1.Polynom();
|
|
@@ -3739,32 +3764,7 @@ Fraction.min = (...fractions) => {
|
|
|
3739
3764
|
|
|
3740
3765
|
/***/ }),
|
|
3741
3766
|
|
|
3742
|
-
/***/
|
|
3743
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3747
|
-
if (k2 === undefined) k2 = k;
|
|
3748
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
3749
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
3750
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
3751
|
-
}
|
|
3752
|
-
Object.defineProperty(o, k2, desc);
|
|
3753
|
-
}) : (function(o, m, k, k2) {
|
|
3754
|
-
if (k2 === undefined) k2 = k;
|
|
3755
|
-
o[k2] = m[k];
|
|
3756
|
-
}));
|
|
3757
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
3758
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
3759
|
-
};
|
|
3760
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3761
|
-
__exportStar(__webpack_require__(506), exports);
|
|
3762
|
-
__exportStar(__webpack_require__(330), exports);
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
/***/ }),
|
|
3766
|
-
|
|
3767
|
-
/***/ 330:
|
|
3767
|
+
/***/ 923:
|
|
3768
3768
|
/***/ ((__unused_webpack_module, exports) => {
|
|
3769
3769
|
|
|
3770
3770
|
|
|
@@ -3891,7 +3891,7 @@ exports.Nthroot = Nthroot;
|
|
|
3891
3891
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3892
3892
|
exports.NumExp = void 0;
|
|
3893
3893
|
const shutingyard_1 = __webpack_require__(505);
|
|
3894
|
-
const
|
|
3894
|
+
const fraction_1 = __webpack_require__(506);
|
|
3895
3895
|
class NumExp {
|
|
3896
3896
|
constructor(value) {
|
|
3897
3897
|
this._expression = value;
|
|
@@ -3965,7 +3965,7 @@ class NumExp {
|
|
|
3965
3965
|
this._addToStack(stack, +element.token);
|
|
3966
3966
|
}
|
|
3967
3967
|
else {
|
|
3968
|
-
this._addToStack(stack, new
|
|
3968
|
+
this._addToStack(stack, new fraction_1.Fraction(element.token).value);
|
|
3969
3969
|
}
|
|
3970
3970
|
}
|
|
3971
3971
|
else if (element.tokenType === shutingyard_1.ShutingyardType.VARIABLE) {
|
|
@@ -4051,12 +4051,12 @@ exports.NumExp = NumExp;
|
|
|
4051
4051
|
|
|
4052
4052
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4053
4053
|
exports.PolynomExpProduct = exports.PolynomExpFactor = void 0;
|
|
4054
|
-
const
|
|
4055
|
-
const
|
|
4054
|
+
const polynom_1 = __webpack_require__(38);
|
|
4055
|
+
const fraction_1 = __webpack_require__(506);
|
|
4056
4056
|
class PolynomExpFactor {
|
|
4057
4057
|
constructor(polynom, degree, mathFunction) {
|
|
4058
|
-
this._polynom = new
|
|
4059
|
-
this._degree = new
|
|
4058
|
+
this._polynom = new polynom_1.Polynom(polynom);
|
|
4059
|
+
this._degree = new fraction_1.Fraction(degree === undefined ? 1 : degree);
|
|
4060
4060
|
this._fn = mathFunction;
|
|
4061
4061
|
this._powerAsInteger = true;
|
|
4062
4062
|
this._forceParenthesis = true;
|
|
@@ -4217,7 +4217,7 @@ class PolynomExpProduct {
|
|
|
4217
4217
|
}
|
|
4218
4218
|
reduce() {
|
|
4219
4219
|
let coefficients = this._factors.filter(factor => factor.isCoefficient), polynoms = this._factors.filter(factor => !factor.isCoefficient);
|
|
4220
|
-
let result = new
|
|
4220
|
+
let result = new fraction_1.Fraction().one();
|
|
4221
4221
|
if (coefficients.length > 1) {
|
|
4222
4222
|
for (const factor of coefficients) {
|
|
4223
4223
|
if (factor.degree.isPositive()) {
|
|
@@ -4304,12 +4304,13 @@ exports.PolynomExpProduct = PolynomExpProduct;
|
|
|
4304
4304
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4305
4305
|
exports.Circle = void 0;
|
|
4306
4306
|
const point_1 = __webpack_require__(557);
|
|
4307
|
-
const coefficients_1 = __webpack_require__(534);
|
|
4308
|
-
const algebra_1 = __webpack_require__(667);
|
|
4309
4307
|
const line_1 = __webpack_require__(9);
|
|
4310
4308
|
const vector_1 = __webpack_require__(586);
|
|
4311
4309
|
const triangle_1 = __webpack_require__(164);
|
|
4312
4310
|
const numeric_1 = __webpack_require__(956);
|
|
4311
|
+
const fraction_1 = __webpack_require__(506);
|
|
4312
|
+
const equation_1 = __webpack_require__(760);
|
|
4313
|
+
const polynom_1 = __webpack_require__(38);
|
|
4313
4314
|
class Circle {
|
|
4314
4315
|
constructor(...values) {
|
|
4315
4316
|
/**
|
|
@@ -4335,21 +4336,21 @@ class Circle {
|
|
|
4335
4336
|
return [];
|
|
4336
4337
|
}
|
|
4337
4338
|
const equX = this._cartesian.clone(), lineX = L.equation.clone().isolate('x'), lineY = L.equation.clone().isolate('y');
|
|
4338
|
-
if (lineX instanceof
|
|
4339
|
+
if (lineX instanceof equation_1.Equation && lineY instanceof equation_1.Equation) {
|
|
4339
4340
|
equX.replaceBy('y', lineY.right).simplify();
|
|
4340
4341
|
equX.solve();
|
|
4341
4342
|
for (let x of equX.solutions) {
|
|
4342
4343
|
if (x.exact === false && isNaN(x.value)) {
|
|
4343
4344
|
continue;
|
|
4344
4345
|
}
|
|
4345
|
-
solX = new
|
|
4346
|
+
solX = new fraction_1.Fraction(x.exact === false ? x.value : x.exact);
|
|
4346
4347
|
intersectionPoints.push(new point_1.Point(solX.clone(), lineY.right.evaluate(solX)));
|
|
4347
4348
|
}
|
|
4348
4349
|
}
|
|
4349
4350
|
return intersectionPoints;
|
|
4350
4351
|
};
|
|
4351
4352
|
this.tangents = (P) => {
|
|
4352
|
-
if (P instanceof
|
|
4353
|
+
if (P instanceof fraction_1.Fraction) {
|
|
4353
4354
|
return this._tangentsWithSlope(P);
|
|
4354
4355
|
}
|
|
4355
4356
|
else if (this.isPointOnCircle(P)) {
|
|
@@ -4399,15 +4400,15 @@ class Circle {
|
|
|
4399
4400
|
// Centre: cx, cy, radius: r
|
|
4400
4401
|
// (m.cx - cy -m.px + py)^2 = r^2 * (m^2 + 1)
|
|
4401
4402
|
// (m(cx-py) - (cy - py))^2 = r^2 * (m^2 + 1)
|
|
4402
|
-
let cx_px = this.center.x.clone().subtract(P.x), cy_py = this.center.y.clone().subtract(P.y), polyLeft = new
|
|
4403
|
+
let cx_px = this.center.x.clone().subtract(P.x), cy_py = this.center.y.clone().subtract(P.y), polyLeft = new polynom_1.Polynom('x'), polyRight = new polynom_1.Polynom('x^2+1');
|
|
4403
4404
|
polyLeft.multiply(cx_px).subtract(cy_py).pow(2);
|
|
4404
4405
|
polyRight.multiply(this.squareRadius);
|
|
4405
|
-
let equ = new
|
|
4406
|
+
let equ = new equation_1.Equation(polyLeft, polyRight);
|
|
4406
4407
|
equ.moveLeft().simplify().solve();
|
|
4407
4408
|
return equ.solutions.map(sol => {
|
|
4408
4409
|
// h = -m px + py
|
|
4409
|
-
let h, equ = new
|
|
4410
|
-
if (sol.exact instanceof
|
|
4410
|
+
let h, equ = new equation_1.Equation('y', 'x');
|
|
4411
|
+
if (sol.exact instanceof fraction_1.Fraction) {
|
|
4411
4412
|
h = P.x.clone().opposed().multiply(sol.exact).add(P.y);
|
|
4412
4413
|
equ.right.multiply(sol.exact).add(h);
|
|
4413
4414
|
}
|
|
@@ -4511,9 +4512,9 @@ class Circle {
|
|
|
4511
4512
|
// three values: Point, Fraction, Boolean (center, square radius, true)
|
|
4512
4513
|
this._reset();
|
|
4513
4514
|
if (typeof values[0] === 'string') {
|
|
4514
|
-
this._parseEquation(new
|
|
4515
|
+
this._parseEquation(new equation_1.Equation(values[0]));
|
|
4515
4516
|
}
|
|
4516
|
-
else if (values[0] instanceof
|
|
4517
|
+
else if (values[0] instanceof equation_1.Equation) {
|
|
4517
4518
|
this._parseEquation(values[0]);
|
|
4518
4519
|
}
|
|
4519
4520
|
else if (values[0] instanceof Circle) {
|
|
@@ -4528,7 +4529,7 @@ class Circle {
|
|
|
4528
4529
|
this._parseCenterAndPointThrough(values[0], values[1]);
|
|
4529
4530
|
}
|
|
4530
4531
|
}
|
|
4531
|
-
else if (values[1] instanceof
|
|
4532
|
+
else if (values[1] instanceof fraction_1.Fraction || typeof values[1] === 'number') {
|
|
4532
4533
|
this._parseCenterAndRadius(values[0], values[1], (typeof values[2] === "boolean") ? values[2] : false);
|
|
4533
4534
|
}
|
|
4534
4535
|
}
|
|
@@ -4543,7 +4544,7 @@ class Circle {
|
|
|
4543
4544
|
return this;
|
|
4544
4545
|
}
|
|
4545
4546
|
_calculateCartesian() {
|
|
4546
|
-
this._cartesian = (new
|
|
4547
|
+
this._cartesian = (new equation_1.Equation(new polynom_1.Polynom(`(x-(${this._center.x.display}))^2+(y-(${this._center.y.display}))^2`), new polynom_1.Polynom(`${this._squareRadius.display}`))).moveLeft();
|
|
4547
4548
|
}
|
|
4548
4549
|
_parseCopyCircle(circle) {
|
|
4549
4550
|
this._center = circle.center.clone();
|
|
@@ -4555,10 +4556,10 @@ class Circle {
|
|
|
4555
4556
|
_parseCenterAndRadius(center, radius, square) {
|
|
4556
4557
|
this._center = center.clone();
|
|
4557
4558
|
if (square) {
|
|
4558
|
-
this._squareRadius = (new
|
|
4559
|
+
this._squareRadius = (new fraction_1.Fraction(radius));
|
|
4559
4560
|
}
|
|
4560
4561
|
else {
|
|
4561
|
-
this._squareRadius = new
|
|
4562
|
+
this._squareRadius = new fraction_1.Fraction(radius).pow(2);
|
|
4562
4563
|
}
|
|
4563
4564
|
this._exists = true;
|
|
4564
4565
|
return this;
|
|
@@ -4607,34 +4608,6 @@ class Circle {
|
|
|
4607
4608
|
exports.Circle = Circle;
|
|
4608
4609
|
|
|
4609
4610
|
|
|
4610
|
-
/***/ }),
|
|
4611
|
-
|
|
4612
|
-
/***/ 272:
|
|
4613
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4617
|
-
if (k2 === undefined) k2 = k;
|
|
4618
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4619
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
4620
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
4621
|
-
}
|
|
4622
|
-
Object.defineProperty(o, k2, desc);
|
|
4623
|
-
}) : (function(o, m, k, k2) {
|
|
4624
|
-
if (k2 === undefined) k2 = k;
|
|
4625
|
-
o[k2] = m[k];
|
|
4626
|
-
}));
|
|
4627
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
4628
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
4629
|
-
};
|
|
4630
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4631
|
-
__exportStar(__webpack_require__(586), exports);
|
|
4632
|
-
__exportStar(__webpack_require__(164), exports);
|
|
4633
|
-
__exportStar(__webpack_require__(557), exports);
|
|
4634
|
-
__exportStar(__webpack_require__(699), exports);
|
|
4635
|
-
__exportStar(__webpack_require__(9), exports);
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
4611
|
/***/ }),
|
|
4639
4612
|
|
|
4640
4613
|
/***/ 9:
|
|
@@ -4646,11 +4619,12 @@ __exportStar(__webpack_require__(9), exports);
|
|
|
4646
4619
|
*/
|
|
4647
4620
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4648
4621
|
exports.Line = exports.LinePropriety = void 0;
|
|
4649
|
-
const coefficients_1 = __webpack_require__(534);
|
|
4650
4622
|
const vector_1 = __webpack_require__(586);
|
|
4651
4623
|
const point_1 = __webpack_require__(557);
|
|
4652
|
-
const algebra_1 = __webpack_require__(667);
|
|
4653
4624
|
const numeric_1 = __webpack_require__(956);
|
|
4625
|
+
const fraction_1 = __webpack_require__(506);
|
|
4626
|
+
const equation_1 = __webpack_require__(760);
|
|
4627
|
+
const polynom_1 = __webpack_require__(38);
|
|
4654
4628
|
var LinePropriety;
|
|
4655
4629
|
(function (LinePropriety) {
|
|
4656
4630
|
LinePropriety[LinePropriety["None"] = 0] = "None";
|
|
@@ -4680,14 +4654,14 @@ class Line {
|
|
|
4680
4654
|
// Already a Line
|
|
4681
4655
|
return values[0].clone();
|
|
4682
4656
|
}
|
|
4683
|
-
else if (values[0] instanceof
|
|
4657
|
+
else if (values[0] instanceof equation_1.Equation) {
|
|
4684
4658
|
// It's an Equation
|
|
4685
4659
|
return this.parseEquation(values[0]);
|
|
4686
4660
|
}
|
|
4687
4661
|
else if (typeof values[0] === "string") {
|
|
4688
4662
|
// It's a string - create an Equation from it.
|
|
4689
4663
|
try {
|
|
4690
|
-
let E = new
|
|
4664
|
+
let E = new equation_1.Equation(values[0]);
|
|
4691
4665
|
return this.parse(E);
|
|
4692
4666
|
}
|
|
4693
4667
|
catch (e) {
|
|
@@ -4707,11 +4681,11 @@ class Line {
|
|
|
4707
4681
|
}
|
|
4708
4682
|
}
|
|
4709
4683
|
if (values.length === 3) {
|
|
4710
|
-
if ((values[0] instanceof
|
|
4684
|
+
if ((values[0] instanceof fraction_1.Fraction || typeof values[0] === 'number')
|
|
4711
4685
|
&&
|
|
4712
|
-
(values[1] instanceof
|
|
4686
|
+
(values[1] instanceof fraction_1.Fraction || typeof values[1] === 'number')
|
|
4713
4687
|
&&
|
|
4714
|
-
(values[2] instanceof
|
|
4688
|
+
(values[2] instanceof fraction_1.Fraction || typeof values[2] === 'number')) {
|
|
4715
4689
|
return this.parseByCoefficient(values[0], values[1], values[2]);
|
|
4716
4690
|
}
|
|
4717
4691
|
else if (values[0] instanceof point_1.Point && values[1] instanceof vector_1.Vector) {
|
|
@@ -4749,11 +4723,11 @@ class Line {
|
|
|
4749
4723
|
return this.parseByCoefficient(equ.left.monomByLetter('x').coefficient, equ.left.monomByLetter('y').coefficient, equ.left.monomByDegree(0).coefficient);
|
|
4750
4724
|
};
|
|
4751
4725
|
this.parseByCoefficient = (a, b, c) => {
|
|
4752
|
-
this._a = new
|
|
4753
|
-
this._b = new
|
|
4754
|
-
this._c = new
|
|
4726
|
+
this._a = new fraction_1.Fraction(a);
|
|
4727
|
+
this._b = new fraction_1.Fraction(b);
|
|
4728
|
+
this._c = new fraction_1.Fraction(c);
|
|
4755
4729
|
this._d = new vector_1.Vector(this._b.clone(), this._a.clone().opposed());
|
|
4756
|
-
this._OA = new point_1.Point(new
|
|
4730
|
+
this._OA = new point_1.Point(new fraction_1.Fraction().zero(), this._c.clone());
|
|
4757
4731
|
this._n = this._d.clone().normal();
|
|
4758
4732
|
this._exists = true;
|
|
4759
4733
|
return this;
|
|
@@ -4870,15 +4844,15 @@ class Line {
|
|
|
4870
4844
|
};
|
|
4871
4845
|
};
|
|
4872
4846
|
this.getValueAtX = (value) => {
|
|
4873
|
-
const equ = this.equation.clone().isolate('y'), F = new
|
|
4874
|
-
if (equ instanceof
|
|
4847
|
+
const equ = this.equation.clone().isolate('y'), F = new fraction_1.Fraction(value);
|
|
4848
|
+
if (equ instanceof equation_1.Equation) {
|
|
4875
4849
|
return equ.right.evaluate({ x: F });
|
|
4876
4850
|
}
|
|
4877
4851
|
return;
|
|
4878
4852
|
};
|
|
4879
4853
|
this.getValueAtY = (value) => {
|
|
4880
|
-
const equ = this.equation.clone().isolate('x'), F = new
|
|
4881
|
-
if (equ instanceof
|
|
4854
|
+
const equ = this.equation.clone().isolate('x'), F = new fraction_1.Fraction(value);
|
|
4855
|
+
if (equ instanceof equation_1.Equation) {
|
|
4882
4856
|
return equ.right.evaluate({ y: F });
|
|
4883
4857
|
}
|
|
4884
4858
|
return;
|
|
@@ -4896,7 +4870,7 @@ class Line {
|
|
|
4896
4870
|
// Getter and setter
|
|
4897
4871
|
// ------------------------------------------
|
|
4898
4872
|
get equation() {
|
|
4899
|
-
return new
|
|
4873
|
+
return new equation_1.Equation(new polynom_1.Polynom().parse('xy', this._a, this._b, this._c), new polynom_1.Polynom('0')).simplify();
|
|
4900
4874
|
}
|
|
4901
4875
|
get tex() {
|
|
4902
4876
|
// canonical => ax + by + c = 0
|
|
@@ -4909,7 +4883,7 @@ class Line {
|
|
|
4909
4883
|
}
|
|
4910
4884
|
return {
|
|
4911
4885
|
canonical: canonical.tex,
|
|
4912
|
-
mxh: this.slope.isInfinity() ? 'x=' + this.OA.x.tex : 'y=' + new
|
|
4886
|
+
mxh: this.slope.isInfinity() ? 'x=' + this.OA.x.tex : 'y=' + new polynom_1.Polynom().parse('x', this.slope, this.height).tex,
|
|
4913
4887
|
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)}`
|
|
4914
4888
|
};
|
|
4915
4889
|
}
|
|
@@ -4967,7 +4941,7 @@ class Line {
|
|
|
4967
4941
|
return {
|
|
4968
4942
|
value: NaN,
|
|
4969
4943
|
tex: 'Not a line',
|
|
4970
|
-
fraction: new
|
|
4944
|
+
fraction: new fraction_1.Fraction().infinite()
|
|
4971
4945
|
};
|
|
4972
4946
|
}
|
|
4973
4947
|
// The denominator is a perfect square - simplify the tex result
|
|
@@ -5049,9 +5023,9 @@ exports.Point = void 0;
|
|
|
5049
5023
|
* Vector module contains everything necessary to handle 2d or 3d vectors.
|
|
5050
5024
|
* @module Vector
|
|
5051
5025
|
*/
|
|
5052
|
-
const coefficients_1 = __webpack_require__(534);
|
|
5053
5026
|
const line_1 = __webpack_require__(9);
|
|
5054
5027
|
const vector_1 = __webpack_require__(586);
|
|
5028
|
+
const fraction_1 = __webpack_require__(506);
|
|
5055
5029
|
/**
|
|
5056
5030
|
* Helper class - a way to identify an object {x: number, y: number}
|
|
5057
5031
|
*/
|
|
@@ -5081,15 +5055,15 @@ class Point {
|
|
|
5081
5055
|
if (typeof values[0] === 'string') {
|
|
5082
5056
|
let xy = values[0].split(',');
|
|
5083
5057
|
if (xy.length === 2) {
|
|
5084
|
-
this._x = new
|
|
5085
|
-
this._y = new
|
|
5058
|
+
this._x = new fraction_1.Fraction(xy[0]).reduce();
|
|
5059
|
+
this._y = new fraction_1.Fraction(xy[1]).reduce();
|
|
5086
5060
|
return this;
|
|
5087
5061
|
}
|
|
5088
5062
|
}
|
|
5089
5063
|
// Value given as an object with {x: value, y: value}
|
|
5090
5064
|
if (values[0] instanceof PointXY) {
|
|
5091
|
-
this._x = new
|
|
5092
|
-
this._y = new
|
|
5065
|
+
this._x = new fraction_1.Fraction(values[0].x).reduce();
|
|
5066
|
+
this._y = new fraction_1.Fraction(values[0].y).reduce();
|
|
5093
5067
|
return this;
|
|
5094
5068
|
}
|
|
5095
5069
|
else {
|
|
@@ -5097,8 +5071,8 @@ class Point {
|
|
|
5097
5071
|
}
|
|
5098
5072
|
}
|
|
5099
5073
|
if (values.length === 2) {
|
|
5100
|
-
this._x = new
|
|
5101
|
-
this._y = new
|
|
5074
|
+
this._x = new fraction_1.Fraction(values[0]).reduce();
|
|
5075
|
+
this._y = new fraction_1.Fraction(values[1]).reduce();
|
|
5102
5076
|
return this;
|
|
5103
5077
|
}
|
|
5104
5078
|
return this;
|
|
@@ -5109,8 +5083,8 @@ class Point {
|
|
|
5109
5083
|
return this;
|
|
5110
5084
|
};
|
|
5111
5085
|
this.zero = () => {
|
|
5112
|
-
this._x = new
|
|
5113
|
-
this._y = new
|
|
5086
|
+
this._x = new fraction_1.Fraction(null);
|
|
5087
|
+
this._y = new fraction_1.Fraction(null);
|
|
5114
5088
|
return this;
|
|
5115
5089
|
};
|
|
5116
5090
|
this.origin = () => {
|
|
@@ -5132,7 +5106,7 @@ class Point {
|
|
|
5132
5106
|
return `\\left(${pts.join(';')}\\right)`;
|
|
5133
5107
|
};
|
|
5134
5108
|
this.distanceTo = (item) => {
|
|
5135
|
-
let value = 0, fraction = new
|
|
5109
|
+
let value = 0, fraction = new fraction_1.Fraction(), tex = '';
|
|
5136
5110
|
if (item instanceof line_1.Line) {
|
|
5137
5111
|
return item.distanceTo(this);
|
|
5138
5112
|
}
|
|
@@ -5148,8 +5122,8 @@ class Point {
|
|
|
5148
5122
|
const keyList = list.map(x => x.key);
|
|
5149
5123
|
return keyList.includes(this.key);
|
|
5150
5124
|
};
|
|
5151
|
-
this._x = new
|
|
5152
|
-
this._y = new
|
|
5125
|
+
this._x = new fraction_1.Fraction().zero();
|
|
5126
|
+
this._y = new fraction_1.Fraction().zero();
|
|
5153
5127
|
if (values !== undefined) {
|
|
5154
5128
|
this.parse(...values);
|
|
5155
5129
|
}
|
|
@@ -5780,7 +5754,7 @@ exports.Numeric = Numeric;
|
|
|
5780
5754
|
|
|
5781
5755
|
/***/ }),
|
|
5782
5756
|
|
|
5783
|
-
/***/
|
|
5757
|
+
/***/ 330:
|
|
5784
5758
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
5785
5759
|
|
|
5786
5760
|
|
|
@@ -5800,11 +5774,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
5800
5774
|
};
|
|
5801
5775
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5802
5776
|
exports.Random = void 0;
|
|
5803
|
-
const rndPolynom_1 = __webpack_require__(
|
|
5804
|
-
const rndMonom_1 = __webpack_require__(
|
|
5805
|
-
const rndHelpers_1 = __webpack_require__(
|
|
5806
|
-
const rndFraction_1 = __webpack_require__(
|
|
5807
|
-
__exportStar(__webpack_require__(
|
|
5777
|
+
const rndPolynom_1 = __webpack_require__(22);
|
|
5778
|
+
const rndMonom_1 = __webpack_require__(793);
|
|
5779
|
+
const rndHelpers_1 = __webpack_require__(140);
|
|
5780
|
+
const rndFraction_1 = __webpack_require__(754);
|
|
5781
|
+
__exportStar(__webpack_require__(230), exports);
|
|
5808
5782
|
var Random;
|
|
5809
5783
|
(function (Random) {
|
|
5810
5784
|
function polynom(config) {
|
|
@@ -5848,7 +5822,7 @@ var Random;
|
|
|
5848
5822
|
|
|
5849
5823
|
/***/ }),
|
|
5850
5824
|
|
|
5851
|
-
/***/
|
|
5825
|
+
/***/ 373:
|
|
5852
5826
|
/***/ ((__unused_webpack_module, exports) => {
|
|
5853
5827
|
|
|
5854
5828
|
|
|
@@ -5876,15 +5850,15 @@ exports.randomCore = randomCore;
|
|
|
5876
5850
|
|
|
5877
5851
|
/***/ }),
|
|
5878
5852
|
|
|
5879
|
-
/***/
|
|
5853
|
+
/***/ 754:
|
|
5880
5854
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
5881
5855
|
|
|
5882
5856
|
|
|
5883
5857
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5884
5858
|
exports.rndFraction = void 0;
|
|
5885
|
-
const randomCore_1 = __webpack_require__(
|
|
5886
|
-
const
|
|
5887
|
-
const
|
|
5859
|
+
const randomCore_1 = __webpack_require__(373);
|
|
5860
|
+
const random_1 = __webpack_require__(330);
|
|
5861
|
+
const fraction_1 = __webpack_require__(506);
|
|
5888
5862
|
/**
|
|
5889
5863
|
* Create a random monom based on a based configuration
|
|
5890
5864
|
*/
|
|
@@ -5892,18 +5866,18 @@ class rndFraction extends randomCore_1.randomCore {
|
|
|
5892
5866
|
constructor(userConfig) {
|
|
5893
5867
|
super();
|
|
5894
5868
|
this.generate = () => {
|
|
5895
|
-
let Q = new
|
|
5869
|
+
let Q = new fraction_1.Fraction();
|
|
5896
5870
|
if (this._config.negative) {
|
|
5897
|
-
Q.numerator =
|
|
5871
|
+
Q.numerator = random_1.Random.numberSym(this._config.max, this._config.zero);
|
|
5898
5872
|
}
|
|
5899
5873
|
else {
|
|
5900
|
-
Q.numerator =
|
|
5874
|
+
Q.numerator = random_1.Random.number(this._config.zero ? 0 : 1, this._config.max);
|
|
5901
5875
|
}
|
|
5902
5876
|
if (this._config.natural) {
|
|
5903
5877
|
Q.denominator = 1;
|
|
5904
5878
|
}
|
|
5905
5879
|
else {
|
|
5906
|
-
Q.denominator =
|
|
5880
|
+
Q.denominator = random_1.Random.number(1, this._config.max);
|
|
5907
5881
|
}
|
|
5908
5882
|
return this._config.reduced ? Q.reduce() : Q;
|
|
5909
5883
|
};
|
|
@@ -5922,7 +5896,7 @@ exports.rndFraction = rndFraction;
|
|
|
5922
5896
|
|
|
5923
5897
|
/***/ }),
|
|
5924
5898
|
|
|
5925
|
-
/***/
|
|
5899
|
+
/***/ 140:
|
|
5926
5900
|
/***/ ((__unused_webpack_module, exports) => {
|
|
5927
5901
|
|
|
5928
5902
|
|
|
@@ -5997,15 +5971,15 @@ exports.rndHelpers = rndHelpers;
|
|
|
5997
5971
|
|
|
5998
5972
|
/***/ }),
|
|
5999
5973
|
|
|
6000
|
-
/***/
|
|
5974
|
+
/***/ 793:
|
|
6001
5975
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
6002
5976
|
|
|
6003
5977
|
|
|
6004
5978
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
6005
5979
|
exports.rndMonom = void 0;
|
|
6006
|
-
const randomCore_1 = __webpack_require__(
|
|
6007
|
-
const
|
|
6008
|
-
const
|
|
5980
|
+
const randomCore_1 = __webpack_require__(373);
|
|
5981
|
+
const random_1 = __webpack_require__(330);
|
|
5982
|
+
const monom_1 = __webpack_require__(937);
|
|
6009
5983
|
/**
|
|
6010
5984
|
* Create a random monom based on a based configuration
|
|
6011
5985
|
*/
|
|
@@ -6014,17 +5988,17 @@ class rndMonom extends randomCore_1.randomCore {
|
|
|
6014
5988
|
super();
|
|
6015
5989
|
this.generate = () => {
|
|
6016
5990
|
// Create a monom instance
|
|
6017
|
-
let M = new
|
|
5991
|
+
let M = new monom_1.Monom();
|
|
6018
5992
|
// Generate the coefficient
|
|
6019
5993
|
if (typeof this._config.fraction === "boolean") {
|
|
6020
|
-
M.coefficient =
|
|
5994
|
+
M.coefficient = random_1.Random.fraction({
|
|
6021
5995
|
zero: this._config.zero,
|
|
6022
5996
|
reduced: true,
|
|
6023
5997
|
natural: !this._config.fraction
|
|
6024
5998
|
});
|
|
6025
5999
|
}
|
|
6026
6000
|
else {
|
|
6027
|
-
M.coefficient =
|
|
6001
|
+
M.coefficient = random_1.Random.fraction(this._config.fraction);
|
|
6028
6002
|
}
|
|
6029
6003
|
// Calculate the degree of the monom
|
|
6030
6004
|
if (this._config.letters.length > 1) {
|
|
@@ -6033,7 +6007,7 @@ class rndMonom extends randomCore_1.randomCore {
|
|
|
6033
6007
|
M.setLetter(L, 0);
|
|
6034
6008
|
}
|
|
6035
6009
|
for (let i = 0; i < this._config.degree; i++) {
|
|
6036
|
-
const L =
|
|
6010
|
+
const L = random_1.Random.item(this._config.letters.split(""));
|
|
6037
6011
|
M.setLetter(L, M.degree(L).clone().add(1));
|
|
6038
6012
|
}
|
|
6039
6013
|
}
|
|
@@ -6056,16 +6030,16 @@ exports.rndMonom = rndMonom;
|
|
|
6056
6030
|
|
|
6057
6031
|
/***/ }),
|
|
6058
6032
|
|
|
6059
|
-
/***/
|
|
6033
|
+
/***/ 22:
|
|
6060
6034
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
6061
6035
|
|
|
6062
6036
|
|
|
6063
6037
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
6064
6038
|
exports.rndPolynom = void 0;
|
|
6065
|
-
const randomCore_1 = __webpack_require__(
|
|
6066
|
-
const rndMonom_1 = __webpack_require__(
|
|
6067
|
-
const
|
|
6068
|
-
const
|
|
6039
|
+
const randomCore_1 = __webpack_require__(373);
|
|
6040
|
+
const rndMonom_1 = __webpack_require__(793);
|
|
6041
|
+
const random_1 = __webpack_require__(330);
|
|
6042
|
+
const polynom_1 = __webpack_require__(38);
|
|
6069
6043
|
/**
|
|
6070
6044
|
* Random polynoms
|
|
6071
6045
|
*/
|
|
@@ -6077,7 +6051,7 @@ class rndPolynom extends randomCore_1.randomCore {
|
|
|
6077
6051
|
return this.factorable();
|
|
6078
6052
|
}
|
|
6079
6053
|
// Create the polynom
|
|
6080
|
-
let P = new
|
|
6054
|
+
let P = new polynom_1.Polynom().empty(), M;
|
|
6081
6055
|
for (let i = this._config.degree; i >= 0; i--) {
|
|
6082
6056
|
// Create monom of corresponding degree.
|
|
6083
6057
|
M = new rndMonom_1.rndMonom({
|
|
@@ -6101,18 +6075,18 @@ class rndPolynom extends randomCore_1.randomCore {
|
|
|
6101
6075
|
if (this._config.numberOfMonoms > 0 && this._config.numberOfMonoms < P.length) {
|
|
6102
6076
|
// Get the greatest degree monom
|
|
6103
6077
|
let M = P.monomByDegree().clone();
|
|
6104
|
-
P.monoms =
|
|
6078
|
+
P.monoms = random_1.Random.array(P.monoms.slice(1), this._config.numberOfMonoms - 1);
|
|
6105
6079
|
P.add(M).reorder().reduce();
|
|
6106
6080
|
}
|
|
6107
6081
|
return P;
|
|
6108
6082
|
};
|
|
6109
6083
|
this.factorable = () => {
|
|
6110
|
-
let P = new
|
|
6084
|
+
let P = new polynom_1.Polynom().one();
|
|
6111
6085
|
let _factorableConfig = { ...this._config };
|
|
6112
6086
|
_factorableConfig.degree = 1;
|
|
6113
6087
|
_factorableConfig.factorable = false;
|
|
6114
6088
|
for (let i = 0; i < this._config.degree; i++) {
|
|
6115
|
-
P.multiply(
|
|
6089
|
+
P.multiply(random_1.Random.polynom(_factorableConfig));
|
|
6116
6090
|
}
|
|
6117
6091
|
return P;
|
|
6118
6092
|
};
|
|
@@ -6137,7 +6111,7 @@ exports.rndPolynom = rndPolynom;
|
|
|
6137
6111
|
|
|
6138
6112
|
/***/ }),
|
|
6139
6113
|
|
|
6140
|
-
/***/
|
|
6114
|
+
/***/ 230:
|
|
6141
6115
|
/***/ ((__unused_webpack_module, exports) => {
|
|
6142
6116
|
|
|
6143
6117
|
|
|
@@ -6484,48 +6458,12 @@ exports.Shutingyard = Shutingyard;
|
|
|
6484
6458
|
/******/ }
|
|
6485
6459
|
/******/
|
|
6486
6460
|
/************************************************************************/
|
|
6487
|
-
|
|
6488
|
-
//
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
var
|
|
6492
|
-
|
|
6493
|
-
__webpack_unused_export__ = ({ value: true });
|
|
6494
|
-
const numeric_1 = __webpack_require__(956);
|
|
6495
|
-
const numexp_1 = __webpack_require__(735);
|
|
6496
|
-
const shutingyard_1 = __webpack_require__(505);
|
|
6497
|
-
const random_1 = __webpack_require__(984);
|
|
6498
|
-
const coefficients_1 = __webpack_require__(534);
|
|
6499
|
-
const algebra_1 = __webpack_require__(667);
|
|
6500
|
-
const geometry_1 = __webpack_require__(272);
|
|
6501
|
-
// Expose as global
|
|
6502
|
-
// export let Pi = {
|
|
6503
|
-
window.Pi = {
|
|
6504
|
-
ShutingYard: shutingyard_1.Shutingyard,
|
|
6505
|
-
Numeric: numeric_1.Numeric,
|
|
6506
|
-
NumExp: numexp_1.NumExp,
|
|
6507
|
-
Fraction: coefficients_1.Fraction,
|
|
6508
|
-
Root: coefficients_1.Nthroot,
|
|
6509
|
-
Monom: algebra_1.Monom,
|
|
6510
|
-
Polynom: algebra_1.Polynom,
|
|
6511
|
-
Equation: algebra_1.Equation,
|
|
6512
|
-
LinearSystem: algebra_1.LinearSystem,
|
|
6513
|
-
Rational: algebra_1.Rational,
|
|
6514
|
-
Logicalset: algebra_1.Logicalset,
|
|
6515
|
-
Random: random_1.Random,
|
|
6516
|
-
PolynomExpFactor: algebra_1.PolynomExpFactor,
|
|
6517
|
-
PolynomExpProduct: algebra_1.PolynomExpProduct,
|
|
6518
|
-
Geometry: {
|
|
6519
|
-
Vector: geometry_1.Vector,
|
|
6520
|
-
Point: geometry_1.Point,
|
|
6521
|
-
Line: geometry_1.Line,
|
|
6522
|
-
Triangle: geometry_1.Triangle,
|
|
6523
|
-
Circle: geometry_1.Circle
|
|
6524
|
-
}
|
|
6525
|
-
};
|
|
6526
|
-
|
|
6527
|
-
})();
|
|
6528
|
-
|
|
6461
|
+
/******/
|
|
6462
|
+
/******/ // startup
|
|
6463
|
+
/******/ // Load entry module and return exports
|
|
6464
|
+
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
6465
|
+
/******/ var __webpack_exports__ = __webpack_require__(607);
|
|
6466
|
+
/******/
|
|
6529
6467
|
/******/ })()
|
|
6530
6468
|
;
|
|
6531
6469
|
//# sourceMappingURL=pi.js.map
|