pimath 0.1.23 → 0.1.24
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/algebra/polyFactor.d.ts +5 -4
- package/dist/pimath.js +728 -682
- package/dist/pimath.js.map +1 -1
- package/package.json +1 -1
package/dist/pimath.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Ri = Object.defineProperty;
|
|
2
2
|
var yi = (o) => {
|
|
3
3
|
throw TypeError(o);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var a = (o, e, t) =>
|
|
7
|
-
var s = (o, e, t) => (
|
|
8
|
-
function
|
|
5
|
+
var zi = (o, e, t) => e in o ? Ri(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
6
|
+
var a = (o, e, t) => zi(o, typeof e != "symbol" ? e + "" : e, t), _t = (o, e, t) => e.has(o) || yi("Cannot " + t);
|
|
7
|
+
var s = (o, e, t) => (_t(o, e, "read from private field"), t ? t.call(o) : e.get(o)), p = (o, e, t) => e.has(o) ? yi("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), h = (o, e, t, i) => (_t(o, e, "write to private field"), i ? i.call(o, t) : e.set(o, t), t), A = (o, e, t) => (_t(o, e, "access private method"), t);
|
|
8
|
+
function Li(o) {
|
|
9
9
|
const e = vi(o), t = [];
|
|
10
10
|
let i, n;
|
|
11
11
|
for (; e.length > 0; )
|
|
12
12
|
i = e.shift() ?? 1, n = (e.length > 0 ? e.pop() : +i) ?? 1, t.push([i, n]);
|
|
13
13
|
return t;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function Di(...o) {
|
|
16
16
|
const e = fi(...o);
|
|
17
17
|
return o.map((t) => t / e);
|
|
18
18
|
}
|
|
@@ -39,49 +39,49 @@ function fi(...o) {
|
|
|
39
39
|
;
|
|
40
40
|
return Math.abs(t);
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function Vi(...o) {
|
|
43
43
|
return o.reduce(function(e, t) {
|
|
44
44
|
return Math.abs(e * t / fi(e, t));
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function Zi(o, e = 3) {
|
|
48
48
|
return +o.toFixed(e);
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function Fi(o) {
|
|
51
51
|
if (Number.isSafeInteger(o) || o.toString().split(".")[0].length < 10)
|
|
52
52
|
return 0;
|
|
53
53
|
throw new Error("Periodic value: Not implemented yet");
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function ji(o) {
|
|
56
56
|
const e = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973];
|
|
57
57
|
return o === void 0 ? e : e.slice(0, Math.min(e.length, o));
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function Ui(o, e) {
|
|
60
60
|
const t = [], i = e === !0 ? +o : o ** 2;
|
|
61
61
|
for (let n = 0; n <= o; n++)
|
|
62
62
|
for (let r = 0; r <= o; r++)
|
|
63
63
|
n ** 2 + r ** 2 === i && t.push([n, r, o]);
|
|
64
64
|
return t;
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function Wi(o, e = 2) {
|
|
67
67
|
return +`${Math.round(+`${o}e${e}`)}e-${e}`;
|
|
68
68
|
}
|
|
69
|
-
const
|
|
70
|
-
decompose:
|
|
69
|
+
const W = {
|
|
70
|
+
decompose: Li,
|
|
71
71
|
dividers: vi,
|
|
72
|
-
divideNumbersByGCD:
|
|
72
|
+
divideNumbersByGCD: Di,
|
|
73
73
|
gcd: fi,
|
|
74
|
-
lcm:
|
|
75
|
-
numberCorrection:
|
|
76
|
-
periodic:
|
|
77
|
-
primes:
|
|
78
|
-
pythagoreanTripletsWithTarget:
|
|
79
|
-
round:
|
|
74
|
+
lcm: Vi,
|
|
75
|
+
numberCorrection: Zi,
|
|
76
|
+
periodic: Fi,
|
|
77
|
+
primes: ji,
|
|
78
|
+
pythagoreanTripletsWithTarget: Ui,
|
|
79
|
+
round: Wi
|
|
80
80
|
};
|
|
81
|
-
var
|
|
81
|
+
var ft, b, w, ze;
|
|
82
82
|
const $ = class $ {
|
|
83
83
|
constructor(e, t) {
|
|
84
|
-
p(this,
|
|
84
|
+
p(this, ft, !1);
|
|
85
85
|
p(this, b, 1);
|
|
86
86
|
p(this, w, 1);
|
|
87
87
|
p(this, ze, "frac");
|
|
@@ -181,7 +181,7 @@ const $ = class $ {
|
|
|
181
181
|
const e = +s(this, w);
|
|
182
182
|
return h(this, w, +s(this, b)), h(this, b, e), this;
|
|
183
183
|
});
|
|
184
|
-
a(this, "isApproximative", () => s(this,
|
|
184
|
+
a(this, "isApproximative", () => s(this, ft) || s(this, w).toString().length >= 15 && s(this, b).toString().length >= 15);
|
|
185
185
|
a(this, "isEqual", (e) => this.compare(e, "="));
|
|
186
186
|
a(this, "isEven", () => this.isRelative() && this.value % 2 === 0);
|
|
187
187
|
a(this, "isExact", () => !this.isApproximative());
|
|
@@ -205,7 +205,7 @@ const $ = class $ {
|
|
|
205
205
|
a(this, "isOpposite", (e) => this.isEqual(e.clone().opposite()));
|
|
206
206
|
a(this, "isPositive", () => this.sign() === 1);
|
|
207
207
|
a(this, "isRational", () => !this.isRelative());
|
|
208
|
-
a(this, "isReduced", () => Math.abs(
|
|
208
|
+
a(this, "isReduced", () => Math.abs(W.gcd(s(this, w), s(this, b))) === 1);
|
|
209
209
|
a(this, "isRelative", () => this.clone().reduce().denominator === 1);
|
|
210
210
|
a(this, "isSquare", () => Math.sqrt(s(this, w)) % 1 === 0 && Math.sqrt(s(this, b)) % 1 === 0);
|
|
211
211
|
a(this, "isStrictlyNegative", () => this.value < 0);
|
|
@@ -227,7 +227,7 @@ const $ = class $ {
|
|
|
227
227
|
});
|
|
228
228
|
// ------------------------------------------
|
|
229
229
|
a(this, "reduce", () => {
|
|
230
|
-
const e =
|
|
230
|
+
const e = W.gcd(s(this, w), s(this, b));
|
|
231
231
|
return h(this, w, s(this, w) / e), h(this, b, s(this, b) / e), s(this, b) < 0 && (h(this, b, -s(this, b)), h(this, w, -s(this, w))), this;
|
|
232
232
|
});
|
|
233
233
|
a(this, "root", (e) => {
|
|
@@ -240,7 +240,7 @@ const $ = class $ {
|
|
|
240
240
|
const t = this.sign();
|
|
241
241
|
this.abs(), this.reduce();
|
|
242
242
|
const i = Math.floor(Math.pow(s(this, w), Math.abs(1 / e))), n = Math.floor(Math.pow(s(this, b), Math.abs(1 / e)));
|
|
243
|
-
return h(this, w, Math.pow(s(this, w), Math.abs(1 / e))), h(this, b, Math.pow(s(this, b), Math.abs(1 / e))), (i !== s(this, w) || n !== s(this, b)) && (h(this, w, s(this, w) / s(this, b)), h(this, b, 1), h(this,
|
|
243
|
+
return h(this, w, Math.pow(s(this, w), Math.abs(1 / e))), h(this, b, Math.pow(s(this, b), Math.abs(1 / e))), (i !== s(this, w) || n !== s(this, b)) && (h(this, w, s(this, w) / s(this, b)), h(this, b, 1), h(this, ft, !0)), this.multiply(t), this;
|
|
244
244
|
});
|
|
245
245
|
// ------------------------------------------
|
|
246
246
|
// Getter and setter
|
|
@@ -287,7 +287,7 @@ const $ = class $ {
|
|
|
287
287
|
return e === 0 ? 0 : e;
|
|
288
288
|
}
|
|
289
289
|
};
|
|
290
|
-
|
|
290
|
+
ft = new WeakMap(), b = new WeakMap(), w = new WeakMap(), ze = new WeakMap(), a($, "average", (...e) => {
|
|
291
291
|
const t = new $().zero();
|
|
292
292
|
for (const i of e)
|
|
293
293
|
t.add(i);
|
|
@@ -325,25 +325,25 @@ a($, "unique", (e) => {
|
|
|
325
325
|
return t;
|
|
326
326
|
});
|
|
327
327
|
let u = $;
|
|
328
|
-
var Z,
|
|
329
|
-
class
|
|
328
|
+
var Z, te, ne, Ye;
|
|
329
|
+
class bt {
|
|
330
330
|
constructor(...e) {
|
|
331
331
|
p(this, Z);
|
|
332
|
-
p(this,
|
|
333
|
-
p(this,
|
|
334
|
-
p(this,
|
|
332
|
+
p(this, te);
|
|
333
|
+
p(this, ne);
|
|
334
|
+
p(this, Ye);
|
|
335
335
|
// ------------------------------------------
|
|
336
336
|
// Creation / parsing functions
|
|
337
337
|
// ------------------------------------------
|
|
338
|
-
a(this, "parse", (e, t, i) => (h(this,
|
|
338
|
+
a(this, "parse", (e, t, i) => (h(this, ne, i ?? 1), h(this, te, t ?? 2), h(this, Z, e), s(this, te) % 2 === 0 && s(this, Z) < 0 && h(this, Ye, !1), this));
|
|
339
339
|
// ------------------------------------------
|
|
340
340
|
// Mathematical operations
|
|
341
341
|
// ------------------------------------------
|
|
342
342
|
a(this, "reduce", () => {
|
|
343
|
-
let e = Math.floor(Math.pow(s(this, Z), 1 / s(this,
|
|
343
|
+
let e = Math.floor(Math.pow(s(this, Z), 1 / s(this, te)));
|
|
344
344
|
for (; e > 1; ) {
|
|
345
|
-
if (s(this, Z) % Math.pow(e, s(this,
|
|
346
|
-
h(this,
|
|
345
|
+
if (s(this, Z) % Math.pow(e, s(this, te)) === 0) {
|
|
346
|
+
h(this, ne, s(this, ne) * e), h(this, Z, s(this, Z) / Math.pow(e, s(this, te))), e = Math.floor(Math.pow(s(this, Z), 1 / s(this, te)));
|
|
347
347
|
continue;
|
|
348
348
|
}
|
|
349
349
|
e--;
|
|
@@ -354,8 +354,8 @@ class vt {
|
|
|
354
354
|
// ------------------------------------------
|
|
355
355
|
// Help functions
|
|
356
356
|
// ------------------------------------------
|
|
357
|
-
a(this, "hasRadical", () => !(s(this, Z) === 1 || s(this, Z) === 0 || !s(this,
|
|
358
|
-
h(this, Z, 1), h(this,
|
|
357
|
+
a(this, "hasRadical", () => !(s(this, Z) === 1 || s(this, Z) === 0 || !s(this, Ye)));
|
|
358
|
+
h(this, Z, 1), h(this, ne, 1), h(this, te, 2), h(this, Ye, !0), e.length > 0 && this.parse(e[0], e[1], e[2]);
|
|
359
359
|
}
|
|
360
360
|
// ------------------------------------------
|
|
361
361
|
// Getter and setter
|
|
@@ -367,31 +367,31 @@ class vt {
|
|
|
367
367
|
h(this, Z, e);
|
|
368
368
|
}
|
|
369
369
|
get nth() {
|
|
370
|
-
return s(this,
|
|
370
|
+
return s(this, te);
|
|
371
371
|
}
|
|
372
372
|
set nth(e) {
|
|
373
|
-
Number.isSafeInteger(e) && e >= 2 ? h(this,
|
|
373
|
+
Number.isSafeInteger(e) && e >= 2 ? h(this, te, e) : (console.log("Error setting the nth root"), h(this, te, 2));
|
|
374
374
|
}
|
|
375
375
|
get coefficient() {
|
|
376
|
-
return s(this,
|
|
376
|
+
return s(this, ne);
|
|
377
377
|
}
|
|
378
378
|
set coefficient(e) {
|
|
379
|
-
h(this,
|
|
379
|
+
h(this, ne, e);
|
|
380
380
|
}
|
|
381
381
|
get tex() {
|
|
382
382
|
let e;
|
|
383
|
-
return s(this,
|
|
383
|
+
return s(this, ne) === 1 ? e = "" : s(this, ne) === -1 ? e = "-" : e = s(this, ne).toString(), s(this, Z) === 1 ? `${s(this, ne)}` : s(this, te) === 2 ? `${e}\\sqrt{${s(this, Z)}}` : `${e}\\sqrt[${s(this, te)}]{${s(this, Z)}}`;
|
|
384
384
|
}
|
|
385
385
|
get display() {
|
|
386
386
|
let e;
|
|
387
|
-
return s(this,
|
|
387
|
+
return s(this, ne) === 1 ? e = "" : s(this, ne) === -1 ? e = "-" : e = s(this, ne).toString(), s(this, Z) === 1 ? `${s(this, ne)}` : s(this, te) === 2 ? `${e}sqrt{${s(this, Z)}}` : `${e}root(${s(this, te)}){${s(this, Z)}}`;
|
|
388
388
|
}
|
|
389
389
|
get value() {
|
|
390
|
-
return s(this,
|
|
390
|
+
return s(this, ne) * Math.pow(s(this, Z), 1 / s(this, te));
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
|
-
Z = new WeakMap(),
|
|
394
|
-
var fe, je, P,
|
|
393
|
+
Z = new WeakMap(), te = new WeakMap(), ne = new WeakMap(), Ye = new WeakMap();
|
|
394
|
+
var fe, je, P, at, ye, bi, ti, xi, Ei, Ni;
|
|
395
395
|
const mi = class mi {
|
|
396
396
|
constructor(e, t, i = "x") {
|
|
397
397
|
p(this, P);
|
|
@@ -405,23 +405,23 @@ const mi = class mi {
|
|
|
405
405
|
}
|
|
406
406
|
solve() {
|
|
407
407
|
if (s(this, fe).degree().isOne())
|
|
408
|
-
return
|
|
408
|
+
return A(this, P, xi).call(this);
|
|
409
409
|
if (s(this, fe).degree().value === 2)
|
|
410
|
-
return
|
|
411
|
-
const e =
|
|
410
|
+
return A(this, P, Ei).call(this);
|
|
411
|
+
const e = A(this, P, bi).call(this);
|
|
412
412
|
if (e.length > 0)
|
|
413
413
|
return e;
|
|
414
414
|
if (s(this, fe).degree().value === 3)
|
|
415
|
-
return
|
|
415
|
+
return A(this, P, ti).call(this);
|
|
416
416
|
throw new Error("The equation degree is too high.");
|
|
417
417
|
}
|
|
418
418
|
solveAsCardan() {
|
|
419
419
|
if (s(this, fe).degree().value !== 3)
|
|
420
420
|
throw new Error("The equation is not cubic.");
|
|
421
|
-
return
|
|
421
|
+
return A(this, P, ti).call(this);
|
|
422
422
|
}
|
|
423
423
|
};
|
|
424
|
-
fe = new WeakMap(), je = new WeakMap(), P = new WeakSet(),
|
|
424
|
+
fe = new WeakMap(), je = new WeakMap(), P = new WeakSet(), at = function(e, t) {
|
|
425
425
|
return {
|
|
426
426
|
variable: s(this, je),
|
|
427
427
|
exact: !1,
|
|
@@ -431,7 +431,7 @@ fe = new WeakMap(), je = new WeakMap(), P = new WeakSet(), ot = function(e, t) {
|
|
|
431
431
|
};
|
|
432
432
|
}, ye = function(e) {
|
|
433
433
|
if (e instanceof u && e.isApproximative())
|
|
434
|
-
return
|
|
434
|
+
return A(this, P, at).call(this, e.value);
|
|
435
435
|
const t = new u(e);
|
|
436
436
|
return {
|
|
437
437
|
variable: s(this, je),
|
|
@@ -447,12 +447,12 @@ fe = new WeakMap(), je = new WeakMap(), P = new WeakSet(), ot = function(e, t) {
|
|
|
447
447
|
const n = e.monomByDegree().coefficient;
|
|
448
448
|
let r = e.monomByDegree(0).coefficient;
|
|
449
449
|
for (; r.isZero(); )
|
|
450
|
-
t.length === 0 && t.push(
|
|
451
|
-
const l =
|
|
450
|
+
t.length === 0 && t.push(A(this, P, ye).call(this, 0)), e = e.divide("x"), r = e.monomByDegree(0).coefficient;
|
|
451
|
+
const l = W.dividers(n.value), c = W.dividers(r.value);
|
|
452
452
|
for (const f of l)
|
|
453
453
|
for (const g of c) {
|
|
454
|
-
const
|
|
455
|
-
e.evaluate(
|
|
454
|
+
const x = new u(g, f);
|
|
455
|
+
e.evaluate(x).isZero() && !t.find((V) => V.value === x.value) && t.push(A(this, P, ye).call(this, x)), x.opposite(), e.evaluate(x).isZero() && !t.find((V) => V.value === x.value) && t.push(A(this, P, ye).call(this, x));
|
|
456
456
|
}
|
|
457
457
|
for (const f of t) {
|
|
458
458
|
if (f.exact !== !1 && f.exact.isZero())
|
|
@@ -468,29 +468,29 @@ fe = new WeakMap(), je = new WeakMap(), P = new WeakSet(), ot = function(e, t) {
|
|
|
468
468
|
const d = new mi(e, e.clone().parse("0"), s(this, je));
|
|
469
469
|
return t = t.concat(d.solve()), t.sort((f, g) => f.value - g.value);
|
|
470
470
|
}, ti = function() {
|
|
471
|
-
const e = s(this, fe), t = e.monomByDegree(3).coefficient, i = e.monomByDegree(2).coefficient, n = e.monomByDegree(1).coefficient, r = e.monomByDegree(0).coefficient, l = i.clone().divide(t), c = n.clone().divide(t), d = r.clone().divide(t), f = c.clone().subtract(l.clone().pow(2).divide(3)), g = d.clone().subtract(l.clone().multiply(c).divide(3)).add(l.clone().pow(3).multiply(2).divide(27)),
|
|
471
|
+
const e = s(this, fe), t = e.monomByDegree(3).coefficient, i = e.monomByDegree(2).coefficient, n = e.monomByDegree(1).coefficient, r = e.monomByDegree(0).coefficient, l = i.clone().divide(t), c = n.clone().divide(t), d = r.clone().divide(t), f = c.clone().subtract(l.clone().pow(2).divide(3)), g = d.clone().subtract(l.clone().multiply(c).divide(3)).add(l.clone().pow(3).multiply(2).divide(27)), x = g.clone().opposite(), V = f.clone().opposite().pow(3).divide(27), pe = x.clone().pow(2).subtract(V.clone().multiply(4)).opposite();
|
|
472
472
|
if (pe.isNegative()) {
|
|
473
|
-
const
|
|
474
|
-
return [
|
|
473
|
+
const le = g.clone().opposite().add(pe.clone().opposite().sqrt()).divide(2).root(3), ce = g.clone().opposite().subtract(pe.clone().opposite().sqrt()).divide(2).root(3), ge = le.clone().add(ce).subtract(l.clone().divide(3));
|
|
474
|
+
return [A(this, P, ye).call(this, ge)];
|
|
475
475
|
}
|
|
476
476
|
if (pe.isZero()) {
|
|
477
|
-
const
|
|
478
|
-
return
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
].sort((me,
|
|
477
|
+
const le = g.clone().opposite().divide(2).root(3), ce = le.clone().opposite().subtract(l.clone().divide(3)), ge = le.clone().multiply(2).subtract(l.clone().divide(3));
|
|
478
|
+
return ce.isEqual(ge) ? [A(this, P, ye).call(this, ce)] : [
|
|
479
|
+
A(this, P, ye).call(this, ge),
|
|
480
|
+
A(this, P, ye).call(this, ce)
|
|
481
|
+
].sort((me, ue) => me.value - ue.value);
|
|
482
482
|
}
|
|
483
483
|
if (pe.isPositive()) {
|
|
484
|
-
const
|
|
485
|
-
for (let
|
|
486
|
-
|
|
487
|
-
return
|
|
484
|
+
const le = [], ce = f.value, ge = g.value, me = l.value;
|
|
485
|
+
for (let ue = 0; ue < 3; ue++)
|
|
486
|
+
le.push(2 * Math.sqrt(-ce / 3) * Math.cos(Math.acos(3 * ge / (2 * ce) * Math.sqrt(-3 / ce)) / 3 + 2 * Math.PI * ue / 3) - me / 3);
|
|
487
|
+
return le.map((ue) => A(this, P, at).call(this, ue)).sort((ue, rt) => ue.value - rt.value);
|
|
488
488
|
}
|
|
489
489
|
return [];
|
|
490
490
|
}, xi = function() {
|
|
491
491
|
const e = s(this, fe).monomByDegree(0).coefficient.clone().opposite().divide(s(this, fe).monomByDegree(1).coefficient);
|
|
492
492
|
return [
|
|
493
|
-
|
|
493
|
+
A(this, P, ye).call(this, e)
|
|
494
494
|
];
|
|
495
495
|
}, Ei = function() {
|
|
496
496
|
const e = s(this, fe), t = e.monomByDegree(2).coefficient, i = e.monomByDegree(1).coefficient, n = e.monomByDegree(0).coefficient, r = i.clone().pow(2).subtract(t.clone().multiply(n).multiply(4));
|
|
@@ -498,60 +498,60 @@ fe = new WeakMap(), je = new WeakMap(), P = new WeakSet(), ot = function(e, t) {
|
|
|
498
498
|
return [];
|
|
499
499
|
if (r.isSquare()) {
|
|
500
500
|
const l = r.sqrt(), c = i.clone().opposite().add(l).divide(t.clone().multiply(2)), d = i.clone().opposite().subtract(l).divide(t.clone().multiply(2));
|
|
501
|
-
return l.isZero() ? [
|
|
502
|
-
|
|
503
|
-
|
|
501
|
+
return l.isZero() ? [A(this, P, ye).call(this, c)] : [
|
|
502
|
+
A(this, P, ye).call(this, c),
|
|
503
|
+
A(this, P, ye).call(this, d)
|
|
504
504
|
].sort((f, g) => f.value - g.value);
|
|
505
505
|
}
|
|
506
|
-
return
|
|
506
|
+
return A(this, P, Ni).call(this, t, i, r);
|
|
507
507
|
}, Ni = function(e, t, i) {
|
|
508
|
-
const n =
|
|
509
|
-
function V(me,
|
|
510
|
-
return `\\frac{ ${
|
|
508
|
+
const n = W.dividers(i.value).filter((me) => Math.sqrt(me) % 1 === 0).map((me) => Math.sqrt(me)).pop() ?? 1, r = W.gcd(2 * e.value, t.value, n) * (e.isNegative() ? -1 : 1), l = t.clone().divide(r).opposite(), c = e.clone().divide(r).multiply(2), d = i.clone().divide(n ** 2), f = Math.abs(n / r), g = n === 1 ? "-" : `-${f} `, x = n === 1 ? "+" : `+${f} `;
|
|
509
|
+
function V(me, ue, rt, Jt) {
|
|
510
|
+
return `\\frac{ ${ue} ${rt}\\sqrt{ ${Jt} } }{ ${me} }`;
|
|
511
511
|
}
|
|
512
|
-
function pe(me,
|
|
513
|
-
return `(${
|
|
512
|
+
function pe(me, ue, rt, Jt) {
|
|
513
|
+
return `(${ue}${rt}sqrt(${Jt}))/${me}`;
|
|
514
514
|
}
|
|
515
|
-
const
|
|
515
|
+
const le = i.value ** 0.5, ce = (-t.value - le) / (2 * e.value), ge = (-t.value + le) / (2 * e.value);
|
|
516
516
|
return [
|
|
517
|
-
|
|
517
|
+
A(this, P, at).call(this, ce, {
|
|
518
518
|
tex: V(c.tex, l.tex, g.toString(), d.tex),
|
|
519
519
|
display: pe(c.display, l.display, g.toString(), d.display)
|
|
520
520
|
}),
|
|
521
|
-
|
|
522
|
-
tex: V(c.tex, l.tex,
|
|
523
|
-
display: pe(c.display, l.display,
|
|
521
|
+
A(this, P, at).call(this, ge, {
|
|
522
|
+
tex: V(c.tex, l.tex, x.toString(), d.tex),
|
|
523
|
+
display: pe(c.display, l.display, x.toString(), d.display)
|
|
524
524
|
})
|
|
525
|
-
].sort((me,
|
|
525
|
+
].sort((me, ue) => me.value - ue.value);
|
|
526
526
|
};
|
|
527
|
-
let
|
|
528
|
-
var Gi = Object.defineProperty,
|
|
527
|
+
let Ot = mi;
|
|
528
|
+
var Gi = Object.defineProperty, Oi = (o) => {
|
|
529
529
|
throw TypeError(o);
|
|
530
|
-
},
|
|
530
|
+
}, Hi = (o, e, t) => e in o ? Gi(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, ei = (o, e, t) => Hi(o, typeof e != "symbol" ? e + "" : e, t), Ti = (o, e, t) => e.has(o) || Oi("Cannot " + t), ee = (o, e, t) => (Ti(o, e, "read from private field"), t ? t.call(o) : e.get(o)), ot = (o, e, t) => e.has(o) ? Oi("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), xe = (o, e, t, i) => (Ti(o, e, "write to private field"), e.set(o, t), t);
|
|
531
531
|
const di = {
|
|
532
532
|
pi: Math.PI,
|
|
533
533
|
e: Math.exp(1)
|
|
534
534
|
};
|
|
535
535
|
var m = /* @__PURE__ */ ((o) => (o.VARIABLE = "variable", o.COEFFICIENT = "coefficient", o.OPERATION = "operation", o.CONSTANT = "constant", o.FUNCTION = "function", o.FUNCTION_ARGUMENT = "function-argument", o.MONOM = "monom", o.LEFT_PARENTHESIS = "(", o.RIGHT_PARENTHESIS = ")", o))(m || {}), Fe = /* @__PURE__ */ ((o) => (o.EXPRESSION = "expression", o.POLYNOM = "polynom", o.SET = "set", o.NUMERIC = "numeric", o))(Fe || {});
|
|
536
|
-
function
|
|
536
|
+
function Xi(o, e) {
|
|
537
537
|
if (o.length <= 1)
|
|
538
538
|
return o;
|
|
539
|
-
const t = Object.keys(e).filter((
|
|
540
|
-
t.sort((
|
|
539
|
+
const t = Object.keys(e).filter((x) => e[x].type === m.FUNCTION).map((x) => x);
|
|
540
|
+
t.sort((x, V) => V.length - x.length);
|
|
541
541
|
const i = new RegExp(`^(${t.join("|")})\\(`), n = Object.keys(di);
|
|
542
|
-
n.sort((
|
|
542
|
+
n.sort((x, V) => V.length - x.length);
|
|
543
543
|
const r = new RegExp(`^(${n.join("|")})`), l = /^(\d+(\.\d+)?)/;
|
|
544
544
|
let c = "", d, f, g;
|
|
545
545
|
for (; o.length > 0; ) {
|
|
546
546
|
if (d = f, g = void 0, t.length > 0 && i.exec(o)) {
|
|
547
|
-
const
|
|
548
|
-
|
|
547
|
+
const x = t.find((V) => o.startsWith(V));
|
|
548
|
+
x && (g = x + "(", o = o.slice(x.length + 1), f = m.FUNCTION);
|
|
549
549
|
} else if (n.length > 0 && r.exec(o)) {
|
|
550
|
-
const
|
|
551
|
-
|
|
550
|
+
const x = n.find((V) => o.startsWith(V));
|
|
551
|
+
x && (g = x, o = o.slice(x.length), f = m.CONSTANT);
|
|
552
552
|
} else if (l.exec(o)) {
|
|
553
|
-
const
|
|
554
|
-
|
|
553
|
+
const x = l.exec(o);
|
|
554
|
+
x && (g = x[0], o = o.slice(x[0].length), f = m.COEFFICIENT);
|
|
555
555
|
} else
|
|
556
556
|
switch (g = o[0], o = o.slice(1), g) {
|
|
557
557
|
case "(":
|
|
@@ -575,20 +575,20 @@ function Hi(o, e) {
|
|
|
575
575
|
}
|
|
576
576
|
if (g === void 0 || f === void 0)
|
|
577
577
|
throw new Error("The token is undefined");
|
|
578
|
-
c +=
|
|
578
|
+
c += Yi(d, f), c += g;
|
|
579
579
|
}
|
|
580
580
|
return c;
|
|
581
581
|
}
|
|
582
|
-
function
|
|
582
|
+
function Yi(o, e) {
|
|
583
583
|
return o === void 0 || o === m.OPERATION || e === m.OPERATION || o === m.LEFT_PARENTHESIS || o === m.FUNCTION || o === m.FUNCTION_ARGUMENT || e === m.RIGHT_PARENTHESIS || e === m.FUNCTION_ARGUMENT ? "" : "*";
|
|
584
584
|
}
|
|
585
|
-
const
|
|
585
|
+
const Qi = {
|
|
586
586
|
"^": { precedence: 4, associative: "right", type: m.OPERATION },
|
|
587
587
|
"*": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
588
588
|
"/": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
589
589
|
"+": { precedence: 2, associative: "left", type: m.OPERATION },
|
|
590
590
|
"-": { precedence: 2, associative: "left", type: m.OPERATION }
|
|
591
|
-
},
|
|
591
|
+
}, Ki = {
|
|
592
592
|
"^": { precedence: 4, associative: "right", type: m.OPERATION },
|
|
593
593
|
"*": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
594
594
|
"/": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
@@ -601,7 +601,7 @@ const Yi = {
|
|
|
601
601
|
sqrt: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
602
602
|
nthrt: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
603
603
|
",": { precedence: 2, associative: "left", type: m.FUNCTION_ARGUMENT }
|
|
604
|
-
},
|
|
604
|
+
}, Ji = {
|
|
605
605
|
"^": { precedence: 4, associative: "right", type: m.OPERATION },
|
|
606
606
|
"*": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
607
607
|
"/": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
@@ -615,26 +615,26 @@ const Yi = {
|
|
|
615
615
|
nthrt: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
616
616
|
ln: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
617
617
|
log: { precedence: 4, associative: "right", type: m.FUNCTION }
|
|
618
|
-
},
|
|
618
|
+
}, _i = {
|
|
619
619
|
"&": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
620
620
|
"|": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
621
621
|
"!": { precedence: 4, associative: "right", type: m.OPERATION },
|
|
622
622
|
"-": { precedence: 2, associative: "left", type: m.OPERATION }
|
|
623
623
|
};
|
|
624
|
-
var
|
|
625
|
-
class
|
|
624
|
+
var He, lt, se, xt, Ve;
|
|
625
|
+
class Kt {
|
|
626
626
|
constructor(e) {
|
|
627
|
-
|
|
627
|
+
ot(this, He), ot(this, lt, []), ot(this, se, {}), ot(this, xt, []), ot(this, Ve), xe(this, He, typeof e > "u" ? Fe.POLYNOM : e), this.tokenConfigInitialization();
|
|
628
628
|
}
|
|
629
629
|
// Getter
|
|
630
630
|
get rpn() {
|
|
631
|
-
return
|
|
631
|
+
return ee(this, lt);
|
|
632
632
|
}
|
|
633
633
|
get rpnToken() {
|
|
634
|
-
return
|
|
634
|
+
return ee(this, lt).map((e) => e.token);
|
|
635
635
|
}
|
|
636
636
|
tokenConfigInitialization() {
|
|
637
|
-
return
|
|
637
|
+
return ee(this, He) === Fe.SET ? (xe(this, se, _i), xe(this, Ve, !1)) : ee(this, He) === Fe.NUMERIC ? (xe(this, se, Ji), xe(this, Ve, !0)) : ee(this, He) === Fe.EXPRESSION ? (xe(this, se, Ki), xe(this, Ve, !0)) : (xe(this, se, Qi), xe(this, Ve, !0)), xe(this, xt, Object.keys(ee(this, se)).sort((e, t) => t.length - e.length)), ee(this, se);
|
|
638
638
|
}
|
|
639
639
|
/**
|
|
640
640
|
* Get the next token to analyse.
|
|
@@ -650,9 +650,9 @@ class Qt {
|
|
|
650
650
|
else if (e[t] === ",")
|
|
651
651
|
i = ",", n = m.FUNCTION_ARGUMENT;
|
|
652
652
|
else {
|
|
653
|
-
for (const r of
|
|
653
|
+
for (const r of ee(this, xt))
|
|
654
654
|
if (e.substring(t, t + r.length) === r) {
|
|
655
|
-
i += r, n =
|
|
655
|
+
i += r, n = ee(this, se)[r].type;
|
|
656
656
|
break;
|
|
657
657
|
}
|
|
658
658
|
for (const r in di)
|
|
@@ -683,7 +683,7 @@ class Qt {
|
|
|
683
683
|
parse(e, t) {
|
|
684
684
|
const i = [], n = [];
|
|
685
685
|
let r = "", l = 0, c;
|
|
686
|
-
(t ??
|
|
686
|
+
(t ?? ee(this, Ve)) && (e = Xi(e, ee(this, se)));
|
|
687
687
|
const d = 50;
|
|
688
688
|
let f = 50, g;
|
|
689
689
|
for (; l < e.length; ) {
|
|
@@ -703,17 +703,17 @@ class Qt {
|
|
|
703
703
|
break;
|
|
704
704
|
case m.OPERATION:
|
|
705
705
|
if (n.length > 0) {
|
|
706
|
-
let
|
|
707
|
-
for (g = +d;
|
|
708
|
-
(
|
|
709
|
-
|
|
706
|
+
let x = n[n.length - 1];
|
|
707
|
+
for (g = +d; x.token in ee(this, se) && //either o1 is left-associative and its precedence is less than or equal to that of o2,
|
|
708
|
+
(ee(this, se)[r].associative === "left" && ee(this, se)[r].precedence <= ee(this, se)[x.token].precedence || //or o1 is right associative, and has precedence less than that of o2,
|
|
709
|
+
ee(this, se)[r].associative === "right" && ee(this, se)[r].precedence < ee(this, se)[x.token].precedence); ) {
|
|
710
710
|
if (g--, g === 0) {
|
|
711
711
|
console.log("SECURITY LEVEL 2 OPERATION EXIT");
|
|
712
712
|
break;
|
|
713
713
|
}
|
|
714
714
|
if (i.push(n.pop() ?? { token: "", tokenType: m.OPERATION }), n.length === 0)
|
|
715
715
|
break;
|
|
716
|
-
|
|
716
|
+
x = n[n.length - 1];
|
|
717
717
|
}
|
|
718
718
|
}
|
|
719
719
|
n.push({ token: r, tokenType: c });
|
|
@@ -747,15 +747,15 @@ class Qt {
|
|
|
747
747
|
throw new Error(`Token type ${r} is not handled`);
|
|
748
748
|
}
|
|
749
749
|
}
|
|
750
|
-
return xe(this,
|
|
750
|
+
return xe(this, lt, i.concat(n.reverse())), this;
|
|
751
751
|
}
|
|
752
752
|
}
|
|
753
|
-
|
|
754
|
-
class
|
|
753
|
+
He = /* @__PURE__ */ new WeakMap(), lt = /* @__PURE__ */ new WeakMap(), se = /* @__PURE__ */ new WeakMap(), xt = /* @__PURE__ */ new WeakMap(), Ve = /* @__PURE__ */ new WeakMap();
|
|
754
|
+
class es {
|
|
755
755
|
constructor(e, t) {
|
|
756
|
-
|
|
756
|
+
ei(this, "_rpn"), ei(this, "_expression"), ei(this, "_isValid"), this._expression = e;
|
|
757
757
|
try {
|
|
758
|
-
this._rpn = new
|
|
758
|
+
this._rpn = new Kt(Fe.NUMERIC).parse(e, t).rpn;
|
|
759
759
|
} catch {
|
|
760
760
|
throw this._rpn = null, this._isValid = !1, new Error(`There was a problem parsing: ${e}`);
|
|
761
761
|
}
|
|
@@ -851,18 +851,18 @@ class _i {
|
|
|
851
851
|
return +e.toFixed(t);
|
|
852
852
|
}
|
|
853
853
|
}
|
|
854
|
-
var
|
|
854
|
+
var O, v, Qe, Et, Le, Mt, kt;
|
|
855
855
|
const I = class I {
|
|
856
856
|
constructor(e) {
|
|
857
|
-
p(this,
|
|
858
|
-
p(this,
|
|
857
|
+
p(this, Qe);
|
|
858
|
+
p(this, O);
|
|
859
859
|
p(this, v);
|
|
860
860
|
/**
|
|
861
861
|
* Clone the current Monom.
|
|
862
862
|
*/
|
|
863
863
|
a(this, "clone", () => {
|
|
864
864
|
const e = new I();
|
|
865
|
-
e.coefficient = s(this,
|
|
865
|
+
e.coefficient = s(this, O).clone();
|
|
866
866
|
for (const t in s(this, v))
|
|
867
867
|
e.setLetter(t, s(this, v)[t].clone());
|
|
868
868
|
return e;
|
|
@@ -874,7 +874,7 @@ const I = class I {
|
|
|
874
874
|
a(this, "add", (...e) => {
|
|
875
875
|
for (const t of e) {
|
|
876
876
|
const i = t instanceof I ? t : new I(t);
|
|
877
|
-
this.isSameAs(i) ? (this.isZero() &&
|
|
877
|
+
this.isSameAs(i) ? (this.isZero() && A(this, Qe, Et).call(this, i), s(this, O).add(i.coefficient)) : console.log("Add monom: " + this.display + " is not similar with ", i.display);
|
|
878
878
|
}
|
|
879
879
|
return this;
|
|
880
880
|
});
|
|
@@ -891,7 +891,7 @@ const I = class I {
|
|
|
891
891
|
a(this, "derivative", (e) => {
|
|
892
892
|
if (e === void 0 && (e = "x"), this.hasVariable(e)) {
|
|
893
893
|
const t = s(this, v)[e].clone(), i = this.clone();
|
|
894
|
-
return s(i, v)[e].subtract(1), s(i,
|
|
894
|
+
return s(i, v)[e].subtract(1), s(i, O).multiply(new u(t.clone())), i;
|
|
895
895
|
} else
|
|
896
896
|
return new I().zero();
|
|
897
897
|
});
|
|
@@ -902,7 +902,7 @@ const I = class I {
|
|
|
902
902
|
a(this, "divide", (...e) => {
|
|
903
903
|
for (const t of e) {
|
|
904
904
|
const i = t instanceof I ? t : new I(t);
|
|
905
|
-
s(this,
|
|
905
|
+
s(this, O).divide(i.coefficient);
|
|
906
906
|
for (const n in i.literal)
|
|
907
907
|
s(this, v)[n] = this.hasVariable(n) ? s(this, v)[n].subtract(i.literal[n]) : i.literal[n].clone().opposite(), s(this, v)[n].isZero() && this.removeVariable(n);
|
|
908
908
|
}
|
|
@@ -917,7 +917,7 @@ const I = class I {
|
|
|
917
917
|
if (t === !0) {
|
|
918
918
|
if (e instanceof u)
|
|
919
919
|
return s(this, Le).call(this, e.value);
|
|
920
|
-
if (e instanceof
|
|
920
|
+
if (e instanceof bt)
|
|
921
921
|
return new u().invalid();
|
|
922
922
|
if (typeof e == "number")
|
|
923
923
|
return s(this, Le).call(this, e);
|
|
@@ -933,7 +933,7 @@ const I = class I {
|
|
|
933
933
|
const n = {};
|
|
934
934
|
return n[this.variables[0]] = new u(e), this.evaluate(n);
|
|
935
935
|
}
|
|
936
|
-
if (e instanceof
|
|
936
|
+
if (e instanceof bt)
|
|
937
937
|
return new u().invalid();
|
|
938
938
|
if (typeof e == "object") {
|
|
939
939
|
if (this.variables.length === 0)
|
|
@@ -952,7 +952,7 @@ const I = class I {
|
|
|
952
952
|
*/
|
|
953
953
|
a(this, "hasVariable", (e) => Object.hasOwn(s(this, v), e ?? "x"));
|
|
954
954
|
a(this, "inverse", () => {
|
|
955
|
-
s(this,
|
|
955
|
+
s(this, O).opposite();
|
|
956
956
|
for (const e in s(this, v))
|
|
957
957
|
s(this, v)[e].opposite();
|
|
958
958
|
return this;
|
|
@@ -969,7 +969,7 @@ const I = class I {
|
|
|
969
969
|
* Determine if two monoms are equals
|
|
970
970
|
* @param M
|
|
971
971
|
*/
|
|
972
|
-
a(this, "isEqual", (e) => this.isSameAs(e) && s(this,
|
|
972
|
+
a(this, "isEqual", (e) => this.isSameAs(e) && s(this, O).isEqual(e.coefficient));
|
|
973
973
|
a(this, "isLiteralSquare", () => {
|
|
974
974
|
for (const e in this.literal)
|
|
975
975
|
if (this.literal[e].isRational() || this.literal[e].isEven())
|
|
@@ -979,7 +979,7 @@ const I = class I {
|
|
|
979
979
|
/**
|
|
980
980
|
* Determine if the monom is one
|
|
981
981
|
*/
|
|
982
|
-
a(this, "isOne", () => s(this,
|
|
982
|
+
a(this, "isOne", () => s(this, O).value === 1 && this.variables.length === 0);
|
|
983
983
|
/**
|
|
984
984
|
* Determine if two monoms are similar
|
|
985
985
|
* @param M
|
|
@@ -1001,7 +1001,7 @@ const I = class I {
|
|
|
1001
1001
|
/**
|
|
1002
1002
|
* Determine if the monom is null
|
|
1003
1003
|
*/
|
|
1004
|
-
a(this, "isZero", () => s(this,
|
|
1004
|
+
a(this, "isZero", () => s(this, O).value === 0);
|
|
1005
1005
|
/**
|
|
1006
1006
|
* Multiple multiple monoms to the current monom
|
|
1007
1007
|
* @param M (Monom[]) The monoms to multiply to.
|
|
@@ -1009,7 +1009,7 @@ const I = class I {
|
|
|
1009
1009
|
a(this, "multiply", (...e) => {
|
|
1010
1010
|
for (const t of e) {
|
|
1011
1011
|
const i = t instanceof I ? t : new I(t);
|
|
1012
|
-
s(this,
|
|
1012
|
+
s(this, O).multiply(i.coefficient);
|
|
1013
1013
|
for (const n in i.literal)
|
|
1014
1014
|
this.hasVariable(n) ? s(this, v)[n].add(i.literal[n]) : s(this, v)[n] = i.literal[n].clone();
|
|
1015
1015
|
}
|
|
@@ -1018,18 +1018,18 @@ const I = class I {
|
|
|
1018
1018
|
/**
|
|
1019
1019
|
* Create a one value monom
|
|
1020
1020
|
*/
|
|
1021
|
-
a(this, "one", () => (h(this,
|
|
1021
|
+
a(this, "one", () => (h(this, O, new u().one()), h(this, v, {}), this));
|
|
1022
1022
|
/**
|
|
1023
1023
|
* Get the opposite
|
|
1024
1024
|
* Returns a monom.
|
|
1025
1025
|
*/
|
|
1026
|
-
a(this, "opposite", () => (s(this,
|
|
1026
|
+
a(this, "opposite", () => (s(this, O).opposite(), this));
|
|
1027
1027
|
/**
|
|
1028
1028
|
* Get the pow of a monom.
|
|
1029
1029
|
* @param nb (number) : Mathematical pow
|
|
1030
1030
|
*/
|
|
1031
1031
|
a(this, "pow", (e) => {
|
|
1032
|
-
s(this,
|
|
1032
|
+
s(this, O).pow(e);
|
|
1033
1033
|
for (const t in s(this, v))
|
|
1034
1034
|
s(this, v)[t].multiply(e);
|
|
1035
1035
|
return this;
|
|
@@ -1063,7 +1063,7 @@ const I = class I {
|
|
|
1063
1063
|
*/
|
|
1064
1064
|
a(this, "sqrt", () => {
|
|
1065
1065
|
if (this.isSquare()) {
|
|
1066
|
-
s(this,
|
|
1066
|
+
s(this, O).sqrt();
|
|
1067
1067
|
for (const e in s(this, v))
|
|
1068
1068
|
s(this, v)[e].clone().divide(2);
|
|
1069
1069
|
}
|
|
@@ -1076,14 +1076,14 @@ const I = class I {
|
|
|
1076
1076
|
a(this, "subtract", (...e) => {
|
|
1077
1077
|
for (const t of e) {
|
|
1078
1078
|
const i = t instanceof I ? t : new I(t);
|
|
1079
|
-
this.isSameAs(i) ? (this.isZero() &&
|
|
1079
|
+
this.isSameAs(i) ? (this.isZero() && A(this, Qe, Et).call(this, i), s(this, O).add(i.clone().coefficient.opposite())) : console.log("Subtract: Is not similar: ", i.display);
|
|
1080
1080
|
}
|
|
1081
1081
|
return this;
|
|
1082
1082
|
});
|
|
1083
1083
|
/**
|
|
1084
1084
|
* Create a zero value monom
|
|
1085
1085
|
*/
|
|
1086
|
-
a(this, "zero", () => (h(this,
|
|
1086
|
+
a(this, "zero", () => (h(this, O, new u().zero()), h(this, v, {}), this));
|
|
1087
1087
|
p(this, Le, (e) => {
|
|
1088
1088
|
let t = this.coefficient.value;
|
|
1089
1089
|
if (typeof e == "number") {
|
|
@@ -1094,7 +1094,7 @@ const I = class I {
|
|
|
1094
1094
|
const i = {};
|
|
1095
1095
|
return i[this.variables[0]] = new u(e).value, s(this, Le).call(this, i);
|
|
1096
1096
|
}
|
|
1097
|
-
if (e instanceof
|
|
1097
|
+
if (e instanceof bt)
|
|
1098
1098
|
return NaN;
|
|
1099
1099
|
if (typeof e == "object") {
|
|
1100
1100
|
if (this.variables.length === 0)
|
|
@@ -1106,8 +1106,8 @@ const I = class I {
|
|
|
1106
1106
|
}
|
|
1107
1107
|
return t;
|
|
1108
1108
|
});
|
|
1109
|
-
p(this,
|
|
1110
|
-
const i = new
|
|
1109
|
+
p(this, Mt, (e) => {
|
|
1110
|
+
const i = new Kt().parse(e).rpn, n = [];
|
|
1111
1111
|
if (i.length === 0)
|
|
1112
1112
|
return this.zero(), this;
|
|
1113
1113
|
if (i.length === 1) {
|
|
@@ -1143,7 +1143,7 @@ const I = class I {
|
|
|
1143
1143
|
}
|
|
1144
1144
|
}
|
|
1145
1145
|
});
|
|
1146
|
-
return h(this,
|
|
1146
|
+
return h(this, O, new u().zero()), h(this, v, {}), e !== void 0 && this.parse(e), this;
|
|
1147
1147
|
}
|
|
1148
1148
|
// -----------------------------------------
|
|
1149
1149
|
/**
|
|
@@ -1151,21 +1151,21 @@ const I = class I {
|
|
|
1151
1151
|
* @param inputStr
|
|
1152
1152
|
*/
|
|
1153
1153
|
parse(e) {
|
|
1154
|
-
return h(this,
|
|
1154
|
+
return h(this, O, new u()), h(this, v, {}), typeof e == "string" ? s(this, Mt).call(this, e) : typeof e == "number" ? h(this, O, new u(e)) : e instanceof u ? h(this, O, e.clone()) : e instanceof I && (h(this, O, s(e, O).clone()), A(this, Qe, Et).call(this, e)), this;
|
|
1155
1155
|
}
|
|
1156
1156
|
/**
|
|
1157
1157
|
* Get the coefficient \\(k\\) of the Monom \\(k\\cdot x^{n}\\)
|
|
1158
1158
|
* @returns {Fraction}
|
|
1159
1159
|
*/
|
|
1160
1160
|
get coefficient() {
|
|
1161
|
-
return s(this,
|
|
1161
|
+
return s(this, O);
|
|
1162
1162
|
}
|
|
1163
1163
|
/**
|
|
1164
1164
|
* Set the coefficient \\(k\\) value of the monom
|
|
1165
1165
|
* @param {Fraction | number | string} F
|
|
1166
1166
|
*/
|
|
1167
1167
|
set coefficient(e) {
|
|
1168
|
-
h(this,
|
|
1168
|
+
h(this, O, new u(e));
|
|
1169
1169
|
}
|
|
1170
1170
|
// Display getter
|
|
1171
1171
|
/**
|
|
@@ -1176,7 +1176,7 @@ const I = class I {
|
|
|
1176
1176
|
const t = Object.keys(s(this, v)).sort();
|
|
1177
1177
|
for (const i of t)
|
|
1178
1178
|
s(this, v)[i].isNotZero() && (e += i, s(this, v)[i].isNotEqual(1) && (e += `^(${s(this, v)[i].display})`));
|
|
1179
|
-
return e === "" ? s(this,
|
|
1179
|
+
return e === "" ? s(this, O).value != 0 ? s(this, O).display : "" : s(this, O).value === 1 ? e : s(this, O).value === -1 ? `-${e}` : s(this, O).value === 0 ? "0" : `${s(this, O).display}${e}`;
|
|
1180
1180
|
}
|
|
1181
1181
|
get dividers() {
|
|
1182
1182
|
if (!this.coefficient.isRelative())
|
|
@@ -1185,7 +1185,7 @@ const I = class I {
|
|
|
1185
1185
|
return [this.clone()];
|
|
1186
1186
|
if (this.coefficient.numerator > 1e6)
|
|
1187
1187
|
return [this.clone()];
|
|
1188
|
-
const e =
|
|
1188
|
+
const e = W.dividers(Math.abs(this.coefficient.numerator));
|
|
1189
1189
|
let t = [];
|
|
1190
1190
|
for (const n in this.literal)
|
|
1191
1191
|
t = this._getLiteralDividers(t, n);
|
|
@@ -1255,7 +1255,7 @@ const I = class I {
|
|
|
1255
1255
|
const t = Object.keys(s(this, v)).sort();
|
|
1256
1256
|
for (const i of t)
|
|
1257
1257
|
s(this, v)[i].isNotZero() && (e += (e === "" ? "" : "*") + i, s(this, v)[i].isNotEqual(1) && (e += `^(${s(this, v)[i].display})`));
|
|
1258
|
-
return e === "" ? s(this,
|
|
1258
|
+
return e === "" ? s(this, O).value != 0 ? s(this, O).display : "" : s(this, O).value === 1 ? e : s(this, O).value === -1 ? `-${e}` : s(this, O).value === 0 ? "0" : `${s(this, O).display}*${e}`;
|
|
1259
1259
|
}
|
|
1260
1260
|
removeVariable(e) {
|
|
1261
1261
|
delete s(this, v)[e];
|
|
@@ -1268,7 +1268,7 @@ const I = class I {
|
|
|
1268
1268
|
const t = Object.keys(s(this, v)).sort();
|
|
1269
1269
|
for (const i of t)
|
|
1270
1270
|
s(this, v)[i].isNotZero() && (e += i, s(this, v)[i].isNotEqual(1) && (e += `^{ ${s(this, v)[i].tfrac.tex} }`));
|
|
1271
|
-
return e === "" ? s(this,
|
|
1271
|
+
return e === "" ? s(this, O).value != 0 ? s(this, O).frac.tex : "0" : s(this, O).value === 1 ? e : s(this, O).value === -1 ? `-${e}` : s(this, O).value === 0 ? "0" : `${s(this, O).frac.tex}${e}`;
|
|
1272
1272
|
}
|
|
1273
1273
|
// Getter helpers.
|
|
1274
1274
|
/**
|
|
@@ -1298,14 +1298,14 @@ const I = class I {
|
|
|
1298
1298
|
return i;
|
|
1299
1299
|
}
|
|
1300
1300
|
};
|
|
1301
|
-
|
|
1301
|
+
O = new WeakMap(), v = new WeakMap(), Qe = new WeakSet(), Et = function(e) {
|
|
1302
1302
|
for (const t in e.literal)
|
|
1303
1303
|
s(this, v)[t] = e.literal[t].clone();
|
|
1304
|
-
}, Le = new WeakMap(),
|
|
1304
|
+
}, Le = new WeakMap(), Mt = new WeakMap(), kt = new WeakMap(), a(I, "gcd", (...e) => {
|
|
1305
1305
|
for (const r of e)
|
|
1306
1306
|
if (r.containsRationalPower())
|
|
1307
1307
|
return new I().zero();
|
|
1308
|
-
const t = new I(), i =
|
|
1308
|
+
const t = new I(), i = W.gcd(...e.map((r) => r.coefficient.numerator)), n = W.lcm(...e.map((r) => r.coefficient.denominator));
|
|
1309
1309
|
t.coefficient = new u(i, n).reduce();
|
|
1310
1310
|
for (const r of e) {
|
|
1311
1311
|
for (const l in t.literal)
|
|
@@ -1324,21 +1324,21 @@ a(I, "xMultiply", (...e) => {
|
|
|
1324
1324
|
t.multiply(i);
|
|
1325
1325
|
return t;
|
|
1326
1326
|
});
|
|
1327
|
-
let
|
|
1327
|
+
let k = I;
|
|
1328
1328
|
function wi(o, e = !0) {
|
|
1329
1329
|
return e ? `\\left( ${o} \\right)` : `(${o})`;
|
|
1330
1330
|
}
|
|
1331
1331
|
function Re(o, e, t, i, n) {
|
|
1332
1332
|
return o.map((r, l) => i !== void 0 && l < i || n !== void 0 && l > n ? r : r === e ? t : r);
|
|
1333
1333
|
}
|
|
1334
|
-
var Ue, y,
|
|
1334
|
+
var Ue, y, Ke, dt, Je, pt, Ct, $t, It, _e, Pt, mt, Bt, St, Rt, zt, Ai, Lt, Dt;
|
|
1335
1335
|
const C = class C {
|
|
1336
1336
|
constructor(e, ...t) {
|
|
1337
|
-
p(this,
|
|
1337
|
+
p(this, zt);
|
|
1338
1338
|
p(this, Ue);
|
|
1339
1339
|
p(this, y);
|
|
1340
|
-
p(this,
|
|
1341
|
-
p(this,
|
|
1340
|
+
p(this, Ke);
|
|
1341
|
+
p(this, dt, !1);
|
|
1342
1342
|
/**
|
|
1343
1343
|
* Parse a string to a polynom.
|
|
1344
1344
|
* @param inputStr
|
|
@@ -1346,12 +1346,12 @@ const C = class C {
|
|
|
1346
1346
|
*/
|
|
1347
1347
|
a(this, "parse", (e, ...t) => {
|
|
1348
1348
|
if (h(this, y, []), h(this, Ue, []), typeof e == "string")
|
|
1349
|
-
return
|
|
1350
|
-
if ((typeof e == "number" || e instanceof u || e instanceof
|
|
1351
|
-
s(this, y).push(new
|
|
1352
|
-
else if (e instanceof
|
|
1353
|
-
s(this, y).push(new
|
|
1354
|
-
s(this, y).push(new
|
|
1349
|
+
return A(this, zt, Ai).call(this, e, ...t);
|
|
1350
|
+
if ((typeof e == "number" || e instanceof u || e instanceof k) && t.length === 0)
|
|
1351
|
+
s(this, y).push(new k(e));
|
|
1352
|
+
else if (e instanceof k && t.length > 0)
|
|
1353
|
+
s(this, y).push(new k(e)), t.forEach((i) => {
|
|
1354
|
+
s(this, y).push(new k(i));
|
|
1355
1355
|
});
|
|
1356
1356
|
else if (e instanceof C)
|
|
1357
1357
|
for (const i of e.monoms)
|
|
@@ -1369,11 +1369,11 @@ const C = class C {
|
|
|
1369
1369
|
});
|
|
1370
1370
|
a(this, "add", (...e) => {
|
|
1371
1371
|
for (const t of e)
|
|
1372
|
-
t instanceof C ? h(this, y, s(this, y).concat(t.monoms)) : t instanceof
|
|
1372
|
+
t instanceof C ? h(this, y, s(this, y).concat(t.monoms)) : t instanceof k ? s(this, y).push(t.clone()) : typeof t == "number" && Number.isSafeInteger(t) ? s(this, y).push(new k(t.toString())) : s(this, y).push(new k(t));
|
|
1373
1373
|
return this.reduce();
|
|
1374
1374
|
});
|
|
1375
1375
|
a(this, "commonMonom", () => {
|
|
1376
|
-
const e = new
|
|
1376
|
+
const e = new k().one(), t = this.gcdNumerator(), i = this.gcdDenominator(), n = this.degree();
|
|
1377
1377
|
e.coefficient = new u(t, i);
|
|
1378
1378
|
for (const r of this.variables) {
|
|
1379
1379
|
e.setLetter(r, n);
|
|
@@ -1397,14 +1397,14 @@ const C = class C {
|
|
|
1397
1397
|
});
|
|
1398
1398
|
a(this, "divide", (e) => {
|
|
1399
1399
|
if (e instanceof u)
|
|
1400
|
-
return s(this,
|
|
1400
|
+
return s(this, pt).call(this, e);
|
|
1401
1401
|
if (typeof e == "number" && Number.isSafeInteger(e))
|
|
1402
|
-
return s(this,
|
|
1403
|
-
if (e instanceof
|
|
1402
|
+
return s(this, Ct).call(this, e);
|
|
1403
|
+
if (e instanceof k)
|
|
1404
1404
|
return this.divide(new C(e));
|
|
1405
1405
|
if (e instanceof C) {
|
|
1406
1406
|
if (e.monoms.length === 1 && e.variables.length === 0)
|
|
1407
|
-
return s(this,
|
|
1407
|
+
return s(this, pt).call(this, e.monoms[0].coefficient);
|
|
1408
1408
|
{
|
|
1409
1409
|
const { quotient: t, reminder: i } = this.euclidean(e);
|
|
1410
1410
|
if (i.isZero())
|
|
@@ -1435,7 +1435,7 @@ const C = class C {
|
|
|
1435
1435
|
});
|
|
1436
1436
|
a(this, "evaluate", (e, t) => {
|
|
1437
1437
|
if (t)
|
|
1438
|
-
return s(this,
|
|
1438
|
+
return s(this, $t).call(this, e);
|
|
1439
1439
|
const i = new u().zero();
|
|
1440
1440
|
return s(this, y).forEach((n) => {
|
|
1441
1441
|
i.add(n.evaluate(e, t));
|
|
@@ -1462,7 +1462,7 @@ const C = class C {
|
|
|
1462
1462
|
t.push(i.clone()), i.one();
|
|
1463
1463
|
break;
|
|
1464
1464
|
} else {
|
|
1465
|
-
let c = s(this,
|
|
1465
|
+
let c = s(this, Pt).call(this, i, l, e ?? "x");
|
|
1466
1466
|
for (l = i.degree(e).value; c.length > 0; ) {
|
|
1467
1467
|
const d = c[0];
|
|
1468
1468
|
if (!i.isDividableBy(d))
|
|
@@ -1470,16 +1470,16 @@ const C = class C {
|
|
|
1470
1470
|
else {
|
|
1471
1471
|
const f = i.euclidean(d);
|
|
1472
1472
|
t.push(d), i = f.quotient.clone(), c = c.filter((g) => {
|
|
1473
|
-
const
|
|
1474
|
-
return V.isDivisible(
|
|
1473
|
+
const x = i.monoms[0], V = i.monoms[i.monoms.length - 1], pe = g.monoms[0], le = g.monoms[g.monoms.length - 1];
|
|
1474
|
+
return V.isDivisible(le) ? x.isDivisible(pe) : !1;
|
|
1475
1475
|
});
|
|
1476
1476
|
}
|
|
1477
1477
|
}
|
|
1478
1478
|
}
|
|
1479
1479
|
return i.isOne() || t.push(i.clone()), h(this, Ue, t), s(this, Ue);
|
|
1480
1480
|
});
|
|
1481
|
-
a(this, "gcdDenominator", () =>
|
|
1482
|
-
a(this, "gcdNumerator", () =>
|
|
1481
|
+
a(this, "gcdDenominator", () => W.gcd(...this.getDenominators()));
|
|
1482
|
+
a(this, "gcdNumerator", () => W.gcd(...this.getNumerators()));
|
|
1483
1483
|
// Next functions are used for for commonMonom, which is used in the factorize method.
|
|
1484
1484
|
a(this, "getDenominators", () => {
|
|
1485
1485
|
const e = [];
|
|
@@ -1493,7 +1493,7 @@ const C = class C {
|
|
|
1493
1493
|
e.push(t.coefficient.numerator);
|
|
1494
1494
|
return e;
|
|
1495
1495
|
});
|
|
1496
|
-
a(this, "getZeroes", () => this.degree().isZero() ? [] : (this.roots = new
|
|
1496
|
+
a(this, "getZeroes", () => this.degree().isZero() ? [] : (this.roots = new Ot(this.clone()).solve(), this.roots));
|
|
1497
1497
|
a(this, "integrate", (e, t, i = "x") => {
|
|
1498
1498
|
const n = this.primitive(i), r = {}, l = {};
|
|
1499
1499
|
return r[i] = new u(e), l[i] = new u(t), n.evaluate(l).subtract(n.evaluate(r));
|
|
@@ -1519,8 +1519,8 @@ const C = class C {
|
|
|
1519
1519
|
return t.isZero();
|
|
1520
1520
|
}
|
|
1521
1521
|
});
|
|
1522
|
-
a(this, "isEqual", (e) => s(this,
|
|
1523
|
-
a(this, "isOppositeAt", (e) => s(this,
|
|
1522
|
+
a(this, "isEqual", (e) => s(this, Je).call(this, e, "="));
|
|
1523
|
+
a(this, "isOppositeAt", (e) => s(this, Je).call(this, e.clone().opposite(), "="));
|
|
1524
1524
|
a(this, "isReduced", (e) => {
|
|
1525
1525
|
if (!this.isDeveloped(e))
|
|
1526
1526
|
return !1;
|
|
@@ -1532,9 +1532,9 @@ const C = class C {
|
|
|
1532
1532
|
return !1;
|
|
1533
1533
|
return !1;
|
|
1534
1534
|
});
|
|
1535
|
-
a(this, "isSameAs", (e) => s(this,
|
|
1536
|
-
a(this, "lcmDenominator", () =>
|
|
1537
|
-
a(this, "lcmNumerator", () =>
|
|
1535
|
+
a(this, "isSameAs", (e) => s(this, Je).call(this, e, "same"));
|
|
1536
|
+
a(this, "lcmDenominator", () => W.lcm(...this.getDenominators()));
|
|
1537
|
+
a(this, "lcmNumerator", () => W.lcm(...this.getNumerators()));
|
|
1538
1538
|
a(this, "letters", () => {
|
|
1539
1539
|
let e = /* @__PURE__ */ new Set();
|
|
1540
1540
|
for (const t of s(this, y))
|
|
@@ -1556,7 +1556,7 @@ const C = class C {
|
|
|
1556
1556
|
for (const n of s(i, y))
|
|
1557
1557
|
if (n.degree(t).isEqual(e))
|
|
1558
1558
|
return n.clone();
|
|
1559
|
-
return new
|
|
1559
|
+
return new k().zero();
|
|
1560
1560
|
});
|
|
1561
1561
|
// Used in LinearSystem.tex
|
|
1562
1562
|
a(this, "monomByLetter", (e) => {
|
|
@@ -1564,7 +1564,7 @@ const C = class C {
|
|
|
1564
1564
|
for (const i of s(t, y))
|
|
1565
1565
|
if (i.hasVariable(e))
|
|
1566
1566
|
return i.clone();
|
|
1567
|
-
return new
|
|
1567
|
+
return new k().zero();
|
|
1568
1568
|
});
|
|
1569
1569
|
a(this, "monomsByDegree", (e, t) => {
|
|
1570
1570
|
if (e === void 0)
|
|
@@ -1574,8 +1574,8 @@ const C = class C {
|
|
|
1574
1574
|
r.degree(t).isEqual(e) && i.push(r.clone());
|
|
1575
1575
|
return i;
|
|
1576
1576
|
});
|
|
1577
|
-
a(this, "multiply", (e) => e instanceof C ? s(this,
|
|
1578
|
-
a(this, "one", () => (h(this, y, []), s(this, y).push(new
|
|
1577
|
+
a(this, "multiply", (e) => e instanceof C ? s(this, Rt).call(this, e) : e instanceof u ? s(this, mt).call(this, e) : e instanceof k ? s(this, St).call(this, e) : Number.isSafeInteger(e) && typeof e == "number" ? s(this, Bt).call(this, e) : this);
|
|
1578
|
+
a(this, "one", () => (h(this, y, []), s(this, y).push(new k().one()), this));
|
|
1579
1579
|
// ------------------------------------------
|
|
1580
1580
|
a(this, "opposite", () => (h(this, y, s(this, y).map((e) => e.opposite())), this));
|
|
1581
1581
|
a(this, "pow", (e) => {
|
|
@@ -1600,7 +1600,7 @@ const C = class C {
|
|
|
1600
1600
|
let e = 0;
|
|
1601
1601
|
for (; e < s(this, y).length; ) {
|
|
1602
1602
|
for (let t = e + 1; t < s(this, y).length; t++)
|
|
1603
|
-
s(this, y)[e].isSameAs(s(this, y)[t]) && (s(this, y)[e].add(s(this, y)[t]), s(this, y).splice(t, 1), s(this, y)[e].isZero() && (s(this, y)[e] = new
|
|
1603
|
+
s(this, y)[e].isSameAs(s(this, y)[t]) && (s(this, y)[e].add(s(this, y)[t]), s(this, y).splice(t, 1), s(this, y)[e].isZero() && (s(this, y)[e] = new k().zero()), t--);
|
|
1604
1604
|
e++;
|
|
1605
1605
|
}
|
|
1606
1606
|
h(this, y, s(this, y).filter((t) => !t.coefficient.isZero()));
|
|
@@ -1639,15 +1639,15 @@ const C = class C {
|
|
|
1639
1639
|
});
|
|
1640
1640
|
a(this, "subtract", (...e) => {
|
|
1641
1641
|
for (const t of e)
|
|
1642
|
-
t instanceof C ? this.add(t.clone().opposite()) : t instanceof
|
|
1642
|
+
t instanceof C ? this.add(t.clone().opposite()) : t instanceof k ? s(this, y).push(t.clone().opposite()) : s(this, y).push(new k(t).opposite());
|
|
1643
1643
|
return this.reduce();
|
|
1644
1644
|
});
|
|
1645
1645
|
/**
|
|
1646
1646
|
* Set the polynom to zero.
|
|
1647
1647
|
* @returns {this}
|
|
1648
1648
|
*/
|
|
1649
|
-
a(this, "zero", () => (h(this, y, []), s(this, y).push(new
|
|
1650
|
-
p(this,
|
|
1649
|
+
a(this, "zero", () => (h(this, y, []), s(this, y).push(new k().zero()), this));
|
|
1650
|
+
p(this, Je, (e, t) => {
|
|
1651
1651
|
t === void 0 && (t = "=");
|
|
1652
1652
|
const i = this.clone().reduce().reorder(), n = e.clone().reduce().reorder();
|
|
1653
1653
|
switch (t) {
|
|
@@ -1659,25 +1659,25 @@ const C = class C {
|
|
|
1659
1659
|
return !1;
|
|
1660
1660
|
}
|
|
1661
1661
|
});
|
|
1662
|
-
p(this,
|
|
1662
|
+
p(this, pt, (e) => {
|
|
1663
1663
|
for (const t of s(this, y))
|
|
1664
1664
|
t.coefficient.divide(e);
|
|
1665
1665
|
return this;
|
|
1666
1666
|
});
|
|
1667
|
-
p(this,
|
|
1667
|
+
p(this, Ct, (e) => {
|
|
1668
1668
|
const t = new u(e);
|
|
1669
1669
|
for (const i of s(this, y))
|
|
1670
1670
|
i.coefficient.divide(t);
|
|
1671
1671
|
return this;
|
|
1672
1672
|
});
|
|
1673
|
-
p(this,
|
|
1673
|
+
p(this, $t, (e) => {
|
|
1674
1674
|
let t = 0;
|
|
1675
1675
|
return s(this, y).forEach((i) => {
|
|
1676
1676
|
t += i.evaluate(e, !0);
|
|
1677
1677
|
}), t;
|
|
1678
1678
|
});
|
|
1679
|
-
p(this,
|
|
1680
|
-
var
|
|
1679
|
+
p(this, It, (e) => {
|
|
1680
|
+
var x;
|
|
1681
1681
|
let t, i, n, r, l, c, d, f, g;
|
|
1682
1682
|
if (this.numberOfVars === 1)
|
|
1683
1683
|
return n = this.monomByDegree(2, e).coefficient, r = this.monomByDegree(1, e).coefficient, l = this.monomByDegree(0, e).coefficient, c = r.clone().pow(2).subtract(n.clone().multiply(l).multiply(4)), c.isZero() ? (d = r.clone().opposite().divide(n.clone().multiply(2)), t = new C(e).subtract(d.display).multiply(d.denominator), i = new C(e).subtract(d.display).multiply(d.denominator), g = n.divide(d.denominator).divide(d.denominator), g.isOne() ? [t, i] : [new C(g.display), t, i]) : c.isPositive() && c.isSquare() ? (d = r.clone().opposite().add(c.clone().sqrt()).divide(n.clone().multiply(2)), f = r.clone().opposite().subtract(c.clone().sqrt()).divide(n.clone().multiply(2)), g = n.divide(d.denominator).divide(f.denominator), g.isOne() ? [
|
|
@@ -1689,17 +1689,17 @@ const C = class C {
|
|
|
1689
1689
|
new C(e).subtract(f.display).multiply(f.denominator)
|
|
1690
1690
|
]) : [this.clone()];
|
|
1691
1691
|
if (n = this.monomByDegree(2, e), r = this.monomByDegree(1, e), l = this.monomByDegree(0, e), n.isLiteralSquare() && l.isLiteralSquare() && r.clone().pow(2).isSameAs(n.clone().multiply(l))) {
|
|
1692
|
-
const V = new C("x", n.coefficient, r.coefficient, l.coefficient), pe = s(
|
|
1693
|
-
let
|
|
1692
|
+
const V = new C("x", n.coefficient, r.coefficient, l.coefficient), pe = s(x = V, It).call(x, "x"), le = [];
|
|
1693
|
+
let ce;
|
|
1694
1694
|
if (pe.length >= 2) {
|
|
1695
1695
|
for (const ge of pe)
|
|
1696
|
-
ge.degree().isZero() ?
|
|
1697
|
-
return
|
|
1696
|
+
ge.degree().isZero() ? le.push(ge.clone()) : (ce = ge.clone(), ce.monoms[0].literal = n.literalSqrt, ce.monoms[1].literal = l.literalSqrt, le.push(ce.clone()));
|
|
1697
|
+
return le;
|
|
1698
1698
|
}
|
|
1699
1699
|
}
|
|
1700
1700
|
return [this.clone()];
|
|
1701
1701
|
});
|
|
1702
|
-
p(this,
|
|
1702
|
+
p(this, _e, (e, t, i, n) => {
|
|
1703
1703
|
let r = "";
|
|
1704
1704
|
for (const l of s(this, y)) {
|
|
1705
1705
|
if (l.coefficient.value === 0)
|
|
@@ -1709,7 +1709,7 @@ const C = class C {
|
|
|
1709
1709
|
}
|
|
1710
1710
|
return i === !0 && this.length > 1 && (e === "tex" ? r = `\\left( ${r} \\right)` : r = `(${r})`), r === "" && (r = "0"), r;
|
|
1711
1711
|
});
|
|
1712
|
-
p(this,
|
|
1712
|
+
p(this, Pt, (e, t, i) => {
|
|
1713
1713
|
const n = e.monoms[0].dividers, r = e.monoms[e.monoms.length - 1].dividers, l = [];
|
|
1714
1714
|
return n.forEach((c) => {
|
|
1715
1715
|
c.degree(i).isLeq(t) && r.forEach((d) => {
|
|
@@ -1717,43 +1717,43 @@ const C = class C {
|
|
|
1717
1717
|
});
|
|
1718
1718
|
}), l;
|
|
1719
1719
|
});
|
|
1720
|
-
p(this,
|
|
1720
|
+
p(this, mt, (e) => {
|
|
1721
1721
|
for (const t of s(this, y))
|
|
1722
1722
|
t.coefficient.multiply(e);
|
|
1723
1723
|
return this.reduce();
|
|
1724
1724
|
});
|
|
1725
|
-
p(this,
|
|
1726
|
-
p(this,
|
|
1725
|
+
p(this, Bt, (e) => s(this, mt).call(this, new u(e)));
|
|
1726
|
+
p(this, St, (e) => {
|
|
1727
1727
|
for (const t of s(this, y))
|
|
1728
1728
|
t.multiply(e);
|
|
1729
1729
|
return this.reduce();
|
|
1730
1730
|
});
|
|
1731
|
-
p(this,
|
|
1731
|
+
p(this, Rt, (e) => {
|
|
1732
1732
|
const t = [];
|
|
1733
1733
|
for (const i of s(this, y))
|
|
1734
1734
|
for (const n of e.monoms)
|
|
1735
|
-
t.push(
|
|
1735
|
+
t.push(k.xMultiply(i, n));
|
|
1736
1736
|
return h(this, y, t), this.reduce();
|
|
1737
1737
|
});
|
|
1738
1738
|
/**
|
|
1739
1739
|
* Main parse using a shutting yard class
|
|
1740
1740
|
* @param inputStr
|
|
1741
1741
|
*/
|
|
1742
|
-
p(this,
|
|
1743
|
-
const i = new
|
|
1742
|
+
p(this, Lt, (e) => {
|
|
1743
|
+
const i = new Kt().parse(e).rpn;
|
|
1744
1744
|
this.zero();
|
|
1745
1745
|
const n = [];
|
|
1746
1746
|
for (const r of i)
|
|
1747
|
-
s(this,
|
|
1747
|
+
s(this, Dt).call(this, n, r);
|
|
1748
1748
|
return n.length === 1 && this.add(n[0]), this.reorder();
|
|
1749
1749
|
});
|
|
1750
|
-
p(this,
|
|
1750
|
+
p(this, Dt, (e, t) => {
|
|
1751
1751
|
switch (t.tokenType) {
|
|
1752
1752
|
case m.COEFFICIENT:
|
|
1753
1753
|
e.push(new C(t.token));
|
|
1754
1754
|
break;
|
|
1755
1755
|
case m.VARIABLE:
|
|
1756
|
-
e.push(new C().add(new
|
|
1756
|
+
e.push(new C().add(new k(t.token)));
|
|
1757
1757
|
break;
|
|
1758
1758
|
case m.CONSTANT:
|
|
1759
1759
|
console.log("Actually, not supported - will be added later !");
|
|
@@ -1797,10 +1797,10 @@ const C = class C {
|
|
|
1797
1797
|
break;
|
|
1798
1798
|
}
|
|
1799
1799
|
});
|
|
1800
|
-
return h(this, y, []), h(this, Ue, []), h(this,
|
|
1800
|
+
return h(this, y, []), h(this, Ue, []), h(this, Ke, []), e !== void 0 && this.parse(e, ...t), this;
|
|
1801
1801
|
}
|
|
1802
1802
|
get display() {
|
|
1803
|
-
return s(this,
|
|
1803
|
+
return s(this, _e).call(this);
|
|
1804
1804
|
}
|
|
1805
1805
|
hasVariable(e) {
|
|
1806
1806
|
return this.variables.includes(e);
|
|
@@ -1830,16 +1830,16 @@ const C = class C {
|
|
|
1830
1830
|
return this.variables.length;
|
|
1831
1831
|
}
|
|
1832
1832
|
get plotFunction() {
|
|
1833
|
-
return s(this,
|
|
1833
|
+
return s(this, _e).call(this, "tex", !1, !1, !0);
|
|
1834
1834
|
}
|
|
1835
1835
|
root() {
|
|
1836
1836
|
throw new Error("Cannot take the root from a polynom");
|
|
1837
1837
|
}
|
|
1838
1838
|
get roots() {
|
|
1839
|
-
return s(this,
|
|
1839
|
+
return s(this, dt) ? s(this, Ke) : this.getZeroes();
|
|
1840
1840
|
}
|
|
1841
1841
|
set roots(e) {
|
|
1842
|
-
h(this,
|
|
1842
|
+
h(this, dt, !0), h(this, Ke, e);
|
|
1843
1843
|
}
|
|
1844
1844
|
sqrt() {
|
|
1845
1845
|
throw new Error("Cannot take the square root from a polynom");
|
|
@@ -1865,14 +1865,14 @@ const C = class C {
|
|
|
1865
1865
|
0,
|
|
1866
1866
|
l
|
|
1867
1867
|
)), r = g * 2 + 1, l = f === i.length - 1 ? n.length : t.findIndex((V) => V.value === i[f + 1].value) * 2 + 1;
|
|
1868
|
-
const
|
|
1869
|
-
c = this.evaluate(
|
|
1868
|
+
const x = f === i.length - 1 ? d.value + 1 : (d.value + i[f + 1].value) / 2;
|
|
1869
|
+
c = this.evaluate(x, !0) < 0 ? "-" : "+", n[r] = "z", n = Re(n, "", c, r, l), r = +l, l = n.length;
|
|
1870
1870
|
});
|
|
1871
1871
|
}
|
|
1872
1872
|
return { roots: t, signs: n };
|
|
1873
1873
|
}
|
|
1874
1874
|
get tex() {
|
|
1875
|
-
return s(this,
|
|
1875
|
+
return s(this, _e).call(this, "tex");
|
|
1876
1876
|
}
|
|
1877
1877
|
get variables() {
|
|
1878
1878
|
let e = [];
|
|
@@ -1884,14 +1884,14 @@ const C = class C {
|
|
|
1884
1884
|
return this.getZeroes();
|
|
1885
1885
|
}
|
|
1886
1886
|
};
|
|
1887
|
-
Ue = new WeakMap(), y = new WeakMap(),
|
|
1887
|
+
Ue = new WeakMap(), y = new WeakMap(), Ke = new WeakMap(), dt = new WeakMap(), Je = new WeakMap(), pt = new WeakMap(), Ct = new WeakMap(), $t = new WeakMap(), It = new WeakMap(), _e = new WeakMap(), Pt = new WeakMap(), mt = new WeakMap(), Bt = new WeakMap(), St = new WeakMap(), Rt = new WeakMap(), zt = new WeakSet(), Ai = function(e, ...t) {
|
|
1888
1888
|
if (t.length === 0) {
|
|
1889
1889
|
if (e = "" + e, e !== "" && !isNaN(Number(e))) {
|
|
1890
1890
|
this.empty();
|
|
1891
|
-
const i = new
|
|
1891
|
+
const i = new k(e);
|
|
1892
1892
|
return this.add(i), this;
|
|
1893
1893
|
}
|
|
1894
|
-
return s(this,
|
|
1894
|
+
return s(this, Lt).call(this, e);
|
|
1895
1895
|
} else if (/^[a-z]+/.test(e)) {
|
|
1896
1896
|
this.empty();
|
|
1897
1897
|
const i = t.map((n) => new u(n));
|
|
@@ -1899,45 +1899,45 @@ Ue = new WeakMap(), y = new WeakMap(), Qe = new WeakMap(), ut = new WeakMap(), K
|
|
|
1899
1899
|
const n = e.split("");
|
|
1900
1900
|
let r = 0;
|
|
1901
1901
|
for (const l of i) {
|
|
1902
|
-
const c = new
|
|
1902
|
+
const c = new k();
|
|
1903
1903
|
c.coefficient = l.clone(), c.literalStr = n[r] || "", this.add(c), r++;
|
|
1904
1904
|
}
|
|
1905
1905
|
} else {
|
|
1906
1906
|
let n = i.length - 1;
|
|
1907
1907
|
for (const r of i) {
|
|
1908
|
-
const l = new
|
|
1908
|
+
const l = new k();
|
|
1909
1909
|
l.coefficient = r.clone(), l.literalStr = `${e}^${n}`, this.add(l), n--;
|
|
1910
1910
|
}
|
|
1911
1911
|
}
|
|
1912
1912
|
return this;
|
|
1913
1913
|
} else
|
|
1914
1914
|
return this.zero();
|
|
1915
|
-
},
|
|
1916
|
-
let
|
|
1917
|
-
var
|
|
1915
|
+
}, Lt = new WeakMap(), Dt = new WeakMap();
|
|
1916
|
+
let T = C;
|
|
1917
|
+
var q, M, re, Vt, et, Zt;
|
|
1918
1918
|
const Ee = class Ee {
|
|
1919
1919
|
constructor(e, t, i) {
|
|
1920
1920
|
// Left part of the equation
|
|
1921
|
-
p(this,
|
|
1921
|
+
p(this, q);
|
|
1922
1922
|
// Right part of the equation
|
|
1923
|
-
p(this,
|
|
1923
|
+
p(this, M);
|
|
1924
1924
|
// Signe of the equation
|
|
1925
|
-
p(this,
|
|
1925
|
+
p(this, re);
|
|
1926
1926
|
// ------------------------------------------
|
|
1927
1927
|
a(this, "parse", (e) => {
|
|
1928
|
-
const t = s(this,
|
|
1928
|
+
const t = s(this, Vt).call(this, e);
|
|
1929
1929
|
if (t === !1)
|
|
1930
1930
|
throw new Error("The equation is not valid (no sign found)");
|
|
1931
1931
|
const i = e.split(t);
|
|
1932
|
-
return this.create(new
|
|
1932
|
+
return this.create(new T(i[0]), new T(i[1]), s(this, et).call(this, t));
|
|
1933
1933
|
});
|
|
1934
|
-
a(this, "create", (e, t, i) => (h(this,
|
|
1935
|
-
a(this, "clone", () => new Ee(s(this,
|
|
1934
|
+
a(this, "create", (e, t, i) => (h(this, q, e), h(this, M, t), h(this, re, s(this, et).call(this, i ?? "=")), this));
|
|
1935
|
+
a(this, "clone", () => new Ee(s(this, q).clone(), s(this, M).clone(), s(this, re)));
|
|
1936
1936
|
/**
|
|
1937
1937
|
* Get the degree of the equation
|
|
1938
1938
|
* @param letter
|
|
1939
1939
|
*/
|
|
1940
|
-
a(this, "degree", (e) => u.max(s(this,
|
|
1940
|
+
a(this, "degree", (e) => u.max(s(this, q).degree(e), s(this, M).degree(e)));
|
|
1941
1941
|
/**
|
|
1942
1942
|
* divide an equation by a given value (transformed as a fraction)
|
|
1943
1943
|
*
|
|
@@ -1968,7 +1968,7 @@ const Ee = class Ee {
|
|
|
1968
1968
|
/**
|
|
1969
1969
|
* Determine if the equation contains more than one letter/variable.
|
|
1970
1970
|
*/
|
|
1971
|
-
a(this, "isMultiVariable", () => s(this,
|
|
1971
|
+
a(this, "isMultiVariable", () => s(this, q).isMultiVariable || s(this, M).isMultiVariable);
|
|
1972
1972
|
// -----------------------------------------------
|
|
1973
1973
|
// Equations helpers
|
|
1974
1974
|
a(this, "isEqualTo", (e) => {
|
|
@@ -1983,47 +1983,47 @@ const Ee = class Ee {
|
|
|
1983
1983
|
if (!this.degree(e).isOne() || this.isMultiVariable())
|
|
1984
1984
|
return !1;
|
|
1985
1985
|
let t;
|
|
1986
|
-
s(this,
|
|
1987
|
-
const i = [...s(this,
|
|
1986
|
+
s(this, q).subtract(s(this, M)), s(this, M).zero();
|
|
1987
|
+
const i = [...s(this, q).monoms];
|
|
1988
1988
|
for (const r of i)
|
|
1989
|
-
r.hasVariable(e) || (t = r.clone(), s(this,
|
|
1990
|
-
if (s(this,
|
|
1989
|
+
r.hasVariable(e) || (t = r.clone(), s(this, q).subtract(t), s(this, M).subtract(t));
|
|
1990
|
+
if (s(this, q).length !== 1)
|
|
1991
1991
|
return !1;
|
|
1992
|
-
const n = s(this,
|
|
1993
|
-
return s(this,
|
|
1992
|
+
const n = s(this, q).monoms[0].coefficient.clone();
|
|
1993
|
+
return s(this, q).divide(n), s(this, M).divide(n), this;
|
|
1994
1994
|
});
|
|
1995
1995
|
// -----------------------------------------------
|
|
1996
1996
|
// Equations operations
|
|
1997
1997
|
// -----------------------------------------------
|
|
1998
|
-
a(this, "letters", () => [.../* @__PURE__ */ new Set([...s(this,
|
|
1998
|
+
a(this, "letters", () => [.../* @__PURE__ */ new Set([...s(this, q).letters(), ...s(this, M).letters()])]);
|
|
1999
1999
|
// -----------------------------------------------
|
|
2000
2000
|
/**
|
|
2001
2001
|
* Reorder will move all monoms containing a letter on the left, all the other on the right.
|
|
2002
2002
|
*/
|
|
2003
|
-
a(this, "moveLeft", () => (s(this,
|
|
2003
|
+
a(this, "moveLeft", () => (s(this, q).subtract(s(this, M)), s(this, M).zero(), this));
|
|
2004
2004
|
/**
|
|
2005
2005
|
* Multiple an equation by a fraction value.
|
|
2006
2006
|
* @param value
|
|
2007
2007
|
*/
|
|
2008
2008
|
a(this, "multiply", (e) => {
|
|
2009
2009
|
const t = new u(e);
|
|
2010
|
-
return s(this,
|
|
2010
|
+
return s(this, q).multiply(t), s(this, M).multiply(t), s(this, re) !== "=" && t.sign() === -1 && s(this, Zt).call(this), this;
|
|
2011
2011
|
});
|
|
2012
|
-
a(this, "opposite", () => (h(this,
|
|
2013
|
-
a(this, "reorder", (e) => (s(this,
|
|
2012
|
+
a(this, "opposite", () => (h(this, q, s(this, q).opposite()), h(this, M, s(this, M).opposite()), this));
|
|
2013
|
+
a(this, "reorder", (e) => (s(this, q).subtract(s(this, M)), s(this, M).zero(), s(this, q).reorder(), e ? this : (s(this, q).monoms.filter((t) => t.degree().isZero()).forEach((t) => {
|
|
2014
2014
|
const i = t.clone();
|
|
2015
|
-
s(this,
|
|
2016
|
-
}), s(this,
|
|
2015
|
+
s(this, q).subtract(i), s(this, M).subtract(i);
|
|
2016
|
+
}), s(this, q).reorder(), s(this, M).reorder(), this)));
|
|
2017
2017
|
// ------------------------------------------
|
|
2018
|
-
a(this, "replaceBy", (e, t) => (s(this,
|
|
2018
|
+
a(this, "replaceBy", (e, t) => (s(this, q).replaceBy(e, t), s(this, M).replaceBy(e, t), this));
|
|
2019
2019
|
/**
|
|
2020
2020
|
* Multiply by the lcm denominator and divide by the gcm numerators.
|
|
2021
2021
|
*/
|
|
2022
|
-
a(this, "simplify", () => (this.multiply(
|
|
2022
|
+
a(this, "simplify", () => (this.multiply(W.lcm(...s(this, q).getDenominators(), ...s(this, M).getDenominators())), this.divide(W.gcd(...s(this, q).getNumerators(), ...s(this, M).getNumerators())), this));
|
|
2023
2023
|
// -----------------------------------------------
|
|
2024
|
-
a(this, "solve", () => new
|
|
2024
|
+
a(this, "solve", () => new Ot(this.clone()).solve());
|
|
2025
2025
|
a(this, "test", (e) => this.left.evaluate(e).isEqual(this.right.evaluate(e)));
|
|
2026
|
-
p(this,
|
|
2026
|
+
p(this, Vt, (e) => {
|
|
2027
2027
|
if (e.includes("geq"))
|
|
2028
2028
|
return e.includes("\\geq") ? "\\geq" : "geq";
|
|
2029
2029
|
if (e.includes("leq"))
|
|
@@ -2046,13 +2046,13 @@ const Ee = class Ee {
|
|
|
2046
2046
|
});
|
|
2047
2047
|
// -----------------------------------------------
|
|
2048
2048
|
// Equations solving algorithms
|
|
2049
|
-
p(this,
|
|
2050
|
-
p(this,
|
|
2051
|
-
if (h(this,
|
|
2049
|
+
p(this, et, (e) => e === void 0 ? "=" : e.includes("geq") || e.includes(">=") || e.includes("=>") ? ">=" : e.includes(">") ? ">" : e.includes("leq") || e.includes("<=") || e.includes("=<") ? "<=" : e.includes("<") ? "<" : "=");
|
|
2050
|
+
p(this, Zt, () => s(this, re) === "=" ? this : s(this, re).includes("<") ? (s(this, re).replace("<", ">"), this) : s(this, re).includes(">") ? (s(this, re).replace(">", "<"), this) : this);
|
|
2051
|
+
if (h(this, q, new T().zero()), h(this, M, new T().zero()), h(this, re, "="), e !== void 0 && t === void 0) {
|
|
2052
2052
|
if (e instanceof Ee)
|
|
2053
2053
|
return e.clone();
|
|
2054
2054
|
typeof e == "string" && this.parse(e);
|
|
2055
|
-
} else e !== void 0 && t !== void 0 && (this.left = new
|
|
2055
|
+
} else e !== void 0 && t !== void 0 && (this.left = new T(e), this.right = new T(t));
|
|
2056
2056
|
return i !== void 0 && (this.sign = i), this;
|
|
2057
2057
|
}
|
|
2058
2058
|
/**
|
|
@@ -2065,11 +2065,11 @@ const Ee = class Ee {
|
|
|
2065
2065
|
*/
|
|
2066
2066
|
add(e) {
|
|
2067
2067
|
if (e instanceof Ee)
|
|
2068
|
-
return s(this,
|
|
2068
|
+
return s(this, q).add(e.left), s(this, M).add(e.right), this;
|
|
2069
2069
|
if (typeof e == "string" && !Ee.isEquationString(e))
|
|
2070
2070
|
return this.add(new Ee(e));
|
|
2071
|
-
const t = new
|
|
2072
|
-
return s(this,
|
|
2071
|
+
const t = new T(e);
|
|
2072
|
+
return s(this, q).add(t), s(this, M).add(t), this;
|
|
2073
2073
|
}
|
|
2074
2074
|
/**
|
|
2075
2075
|
* Create an Equation using two polynoms.
|
|
@@ -2078,29 +2078,29 @@ const Ee = class Ee {
|
|
|
2078
2078
|
* @param asNumeric
|
|
2079
2079
|
*/
|
|
2080
2080
|
evaluate(e, t) {
|
|
2081
|
-
const i = s(this,
|
|
2081
|
+
const i = s(this, q).evaluate(e, t), n = s(this, M).evaluate(e, t);
|
|
2082
2082
|
return t ? i === n : i.isEqual(n);
|
|
2083
2083
|
}
|
|
2084
2084
|
isEqual(e) {
|
|
2085
2085
|
const t = new Ee(e);
|
|
2086
|
-
return t.left.isEqual(s(this,
|
|
2086
|
+
return t.left.isEqual(s(this, q)) && t.right.isEqual(s(this, M));
|
|
2087
2087
|
}
|
|
2088
2088
|
pow(e) {
|
|
2089
|
-
return s(this,
|
|
2089
|
+
return s(this, q).pow(e), s(this, M).pow(e), this;
|
|
2090
2090
|
}
|
|
2091
2091
|
reduce() {
|
|
2092
|
-
return this.moveLeft(), s(this,
|
|
2092
|
+
return this.moveLeft(), s(this, q).reduce(), this.simplify(), s(this, q).monoms[0].coefficient.isNegative() && this.multiply(-1), this;
|
|
2093
2093
|
}
|
|
2094
2094
|
split() {
|
|
2095
|
-
return [s(this,
|
|
2095
|
+
return [s(this, q).clone(), s(this, M).clone()];
|
|
2096
2096
|
}
|
|
2097
2097
|
subtract(e) {
|
|
2098
2098
|
if (e instanceof Ee)
|
|
2099
|
-
return s(this,
|
|
2099
|
+
return s(this, q).subtract(e.left), s(this, M).subtract(e.right), this;
|
|
2100
2100
|
if (typeof e == "string" && !Ee.isEquationString(e))
|
|
2101
2101
|
return this.subtract(new Ee(e));
|
|
2102
|
-
const t = new
|
|
2103
|
-
return s(this,
|
|
2102
|
+
const t = new T(e);
|
|
2103
|
+
return s(this, q).subtract(t), s(this, M).subtract(t), this;
|
|
2104
2104
|
}
|
|
2105
2105
|
static isEquationString(e) {
|
|
2106
2106
|
return e.includes("=") || e.includes("<") || e.includes(">") || e.includes("<=") || e.includes(">=");
|
|
@@ -2110,57 +2110,57 @@ const Ee = class Ee {
|
|
|
2110
2110
|
return t === !0 && n.sort((r, l) => r.value - l.value), n;
|
|
2111
2111
|
}
|
|
2112
2112
|
get display() {
|
|
2113
|
-
return `${s(this,
|
|
2113
|
+
return `${s(this, q).display}${this.signAsTex}${s(this, M).display}`;
|
|
2114
2114
|
}
|
|
2115
2115
|
// Getter and setter
|
|
2116
2116
|
get left() {
|
|
2117
|
-
return s(this,
|
|
2117
|
+
return s(this, q);
|
|
2118
2118
|
}
|
|
2119
2119
|
set left(e) {
|
|
2120
|
-
h(this,
|
|
2120
|
+
h(this, q, e);
|
|
2121
2121
|
}
|
|
2122
2122
|
get numberOfVars() {
|
|
2123
2123
|
return this.variables.length;
|
|
2124
2124
|
}
|
|
2125
2125
|
get right() {
|
|
2126
|
-
return s(this,
|
|
2126
|
+
return s(this, M);
|
|
2127
2127
|
}
|
|
2128
2128
|
set right(e) {
|
|
2129
|
-
h(this,
|
|
2129
|
+
h(this, M, e);
|
|
2130
2130
|
}
|
|
2131
2131
|
// ------------------------------------------
|
|
2132
2132
|
get sign() {
|
|
2133
|
-
return s(this,
|
|
2133
|
+
return s(this, re);
|
|
2134
2134
|
}
|
|
2135
2135
|
set sign(e) {
|
|
2136
|
-
h(this,
|
|
2136
|
+
h(this, re, s(this, et).call(this, e));
|
|
2137
2137
|
}
|
|
2138
2138
|
get signAsTex() {
|
|
2139
|
-
return s(this,
|
|
2139
|
+
return s(this, re) === ">=" ? "\\geq" : s(this, re) === "<=" ? "\\leq" : s(this, re);
|
|
2140
2140
|
}
|
|
2141
2141
|
get tex() {
|
|
2142
|
-
return `${s(this,
|
|
2142
|
+
return `${s(this, q).tex}${this.signAsTex}${s(this, M).tex}`;
|
|
2143
2143
|
}
|
|
2144
2144
|
get variables() {
|
|
2145
|
-
return [...new Set(s(this,
|
|
2145
|
+
return [...new Set(s(this, M).variables.concat(s(this, q).variables))];
|
|
2146
2146
|
}
|
|
2147
2147
|
};
|
|
2148
|
-
|
|
2149
|
-
let
|
|
2150
|
-
var Ne,
|
|
2148
|
+
q = new WeakMap(), M = new WeakMap(), re = new WeakMap(), Vt = new WeakMap(), et = new WeakMap(), Zt = new WeakMap();
|
|
2149
|
+
let X = Ee;
|
|
2150
|
+
var Ne, Oe, Te, tt;
|
|
2151
2151
|
const ve = class ve {
|
|
2152
2152
|
constructor(e, t) {
|
|
2153
2153
|
p(this, Ne);
|
|
2154
|
+
p(this, Oe);
|
|
2154
2155
|
p(this, Te);
|
|
2155
|
-
p(this,
|
|
2156
|
-
p(this, et, !1);
|
|
2156
|
+
p(this, tt, !1);
|
|
2157
2157
|
if (e instanceof ve)
|
|
2158
|
-
h(this,
|
|
2158
|
+
h(this, Oe, e.polynom.clone()), h(this, Te, e.power.clone());
|
|
2159
2159
|
else if (typeof e == "string" && t === void 0) {
|
|
2160
2160
|
const [i, n = "1"] = e.split("^");
|
|
2161
|
-
h(this,
|
|
2161
|
+
h(this, Oe, new T(i)), h(this, Te, new u(n.replace("(", "").replace(")", "")));
|
|
2162
2162
|
} else
|
|
2163
|
-
h(this,
|
|
2163
|
+
h(this, Oe, new T(e)), h(this, Te, new u(t ?? 1));
|
|
2164
2164
|
return h(this, Ne, 1), this;
|
|
2165
2165
|
}
|
|
2166
2166
|
parse() {
|
|
@@ -2172,18 +2172,18 @@ const ve = class ve {
|
|
|
2172
2172
|
get tex() {
|
|
2173
2173
|
const e = this.power.numerator, t = this.power.denominator;
|
|
2174
2174
|
let i, n;
|
|
2175
|
-
return s(this, Ne) === 0 && t > 1 ? (i = `\\sqrt${t === 2 ? "" : `[ ${t} ]`}{ ${this.polynom.tex} }`, n = e === 1 ? "" : `^{ ${e} }`) : (i = s(this,
|
|
2175
|
+
return s(this, Ne) === 0 && t > 1 ? (i = `\\sqrt${t === 2 ? "" : `[ ${t} ]`}{ ${this.polynom.tex} }`, n = e === 1 ? "" : `^{ ${e} }`) : (i = s(this, tt) && this.power.isOne() ? this.polynom.tex : wi(this.polynom.tex), n = t === 1 && e === 1 ? "" : `^{ ${this.power.tex} }`), i = `${i}${n}`, s(this, Ne) === 0 && e < 0 && (i = `\\frac{ 1 }{ ${i} }`), i;
|
|
2176
2176
|
}
|
|
2177
2177
|
get display() {
|
|
2178
2178
|
const e = this.power.numerator, t = this.power.denominator;
|
|
2179
2179
|
let i, n;
|
|
2180
|
-
return s(this, Ne) === 0 && t > 1 ? (i = `${t === 2 ? "sqrt" : `root(${t})`}(${this.polynom.display})`, n = e === 1 ? "" : `^(${e})`) : (i = s(this,
|
|
2180
|
+
return s(this, Ne) === 0 && t > 1 ? (i = `${t === 2 ? "sqrt" : `root(${t})`}(${this.polynom.display})`, n = e === 1 ? "" : `^(${e})`) : (i = s(this, tt) && this.power.isOne() ? this.polynom.display : wi(this.polynom.display, !1), n = t === 1 && e === 1 ? "" : `^(${this.power.display})`), i = `${i}${n}`, s(this, Ne) === 0 && e < 0 && (i = `1/(${i})`), i;
|
|
2181
2181
|
}
|
|
2182
2182
|
add() {
|
|
2183
2183
|
throw new Error("Adding two factors is not possible");
|
|
2184
2184
|
}
|
|
2185
2185
|
get asSingle() {
|
|
2186
|
-
return h(this,
|
|
2186
|
+
return h(this, tt, !0), this;
|
|
2187
2187
|
}
|
|
2188
2188
|
degree(e) {
|
|
2189
2189
|
return this.polynom.degree(e).multiply(this.power);
|
|
@@ -2203,7 +2203,7 @@ const ve = class ve {
|
|
|
2203
2203
|
divide(e) {
|
|
2204
2204
|
if (e instanceof ve && this.isSameAs(e))
|
|
2205
2205
|
return this.power.subtract(e.power), this;
|
|
2206
|
-
const t = new
|
|
2206
|
+
const t = new T(e);
|
|
2207
2207
|
if (this.isSameAs(t))
|
|
2208
2208
|
return this.power.subtract(1), this;
|
|
2209
2209
|
throw new Error("The two factors must be the same");
|
|
@@ -2225,7 +2225,7 @@ const ve = class ve {
|
|
|
2225
2225
|
}
|
|
2226
2226
|
isSameAs(e) {
|
|
2227
2227
|
let t;
|
|
2228
|
-
return e instanceof ve ? t = e.polynom : e instanceof
|
|
2228
|
+
return e instanceof ve ? t = e.polynom : e instanceof T ? t = e : t = new T(e), this.polynom.isEqual(t);
|
|
2229
2229
|
}
|
|
2230
2230
|
isZero() {
|
|
2231
2231
|
return this.polynom.isZero();
|
|
@@ -2233,31 +2233,31 @@ const ve = class ve {
|
|
|
2233
2233
|
multiply(e) {
|
|
2234
2234
|
if (e instanceof ve && this.isSameAs(e))
|
|
2235
2235
|
return this.power.add(e.power), this;
|
|
2236
|
-
const t = new
|
|
2236
|
+
const t = new T(e);
|
|
2237
2237
|
if (this.isSameAs(t))
|
|
2238
2238
|
return this.power.add(1), this;
|
|
2239
2239
|
throw new Error("The two factors must be the same");
|
|
2240
2240
|
}
|
|
2241
2241
|
one() {
|
|
2242
|
-
return s(this,
|
|
2242
|
+
return s(this, Oe).one(), s(this, Te).one(), this;
|
|
2243
2243
|
}
|
|
2244
2244
|
opposite() {
|
|
2245
2245
|
throw new Error("Method not implemented.");
|
|
2246
2246
|
}
|
|
2247
2247
|
get polynom() {
|
|
2248
|
-
return s(this,
|
|
2248
|
+
return s(this, Oe);
|
|
2249
2249
|
}
|
|
2250
2250
|
set polynom(e) {
|
|
2251
|
-
h(this,
|
|
2251
|
+
h(this, Oe, e);
|
|
2252
2252
|
}
|
|
2253
2253
|
pow(e) {
|
|
2254
2254
|
return this.power.multiply(e), this;
|
|
2255
2255
|
}
|
|
2256
2256
|
get power() {
|
|
2257
|
-
return s(this,
|
|
2257
|
+
return s(this, Te);
|
|
2258
2258
|
}
|
|
2259
2259
|
set power(e) {
|
|
2260
|
-
h(this,
|
|
2260
|
+
h(this, Te, new u(e));
|
|
2261
2261
|
}
|
|
2262
2262
|
primitive() {
|
|
2263
2263
|
throw new Error("Method not implemented.");
|
|
@@ -2288,19 +2288,19 @@ const ve = class ve {
|
|
|
2288
2288
|
return h(this, Ne, 0), this;
|
|
2289
2289
|
}
|
|
2290
2290
|
zero() {
|
|
2291
|
-
return s(this,
|
|
2291
|
+
return s(this, Oe).zero(), s(this, Te).one(), this;
|
|
2292
2292
|
}
|
|
2293
2293
|
};
|
|
2294
|
-
Ne = new WeakMap(),
|
|
2295
|
-
let
|
|
2296
|
-
var
|
|
2297
|
-
const
|
|
2294
|
+
Ne = new WeakMap(), Oe = new WeakMap(), Te = new WeakMap(), tt = new WeakMap();
|
|
2295
|
+
let ie = ve;
|
|
2296
|
+
var ct = /* @__PURE__ */ ((o) => (o[o.ROOT = 0] = "ROOT", o[o.POWER = 1] = "POWER", o))(ct || {}), D, $e, Ft, jt;
|
|
2297
|
+
const Xe = class Xe {
|
|
2298
2298
|
constructor(...e) {
|
|
2299
2299
|
p(this, D);
|
|
2300
2300
|
// Determine the letters in the linear system, usually ['x', 'y']
|
|
2301
2301
|
p(this, $e);
|
|
2302
|
-
a(this, "parse", (...e) => (h(this, D, e.map((t) => new
|
|
2303
|
-
a(this, "clone", () => new
|
|
2302
|
+
a(this, "parse", (...e) => (h(this, D, e.map((t) => new X(t))), s(this, Ft).call(this), this));
|
|
2303
|
+
a(this, "clone", () => new Xe().parse(...s(this, D).map((e) => e.clone())));
|
|
2304
2304
|
a(this, "buildTex", (e, t) => {
|
|
2305
2305
|
let i, n, r = [];
|
|
2306
2306
|
const l = [];
|
|
@@ -2349,8 +2349,8 @@ const He = class He {
|
|
|
2349
2349
|
}
|
|
2350
2350
|
return i.map((n) => n[n.length - 1]);
|
|
2351
2351
|
});
|
|
2352
|
-
p(this,
|
|
2353
|
-
p(this,
|
|
2352
|
+
p(this, Ft, () => (h(this, $e, s(this, D).reduce((e, t) => [.../* @__PURE__ */ new Set([...e, ...t.variables])], [])), s(this, $e).sort(), this));
|
|
2353
|
+
p(this, jt, () => {
|
|
2354
2354
|
const e = [], t = [];
|
|
2355
2355
|
for (const i of s(this, D)) {
|
|
2356
2356
|
const n = [], r = i.clone().reorder();
|
|
@@ -2369,15 +2369,15 @@ const He = class He {
|
|
|
2369
2369
|
if (e.some((r) => r.length !== i))
|
|
2370
2370
|
throw new Error("All rows must have the same number of columns");
|
|
2371
2371
|
const n = t.split("").splice(0, i - 1);
|
|
2372
|
-
return new
|
|
2372
|
+
return new Xe(
|
|
2373
2373
|
...e.map((r) => {
|
|
2374
|
-
const l = new
|
|
2375
|
-
return new
|
|
2374
|
+
const l = new T(n.join(""), ...r);
|
|
2375
|
+
return new X(l, 0);
|
|
2376
2376
|
})
|
|
2377
2377
|
);
|
|
2378
2378
|
}
|
|
2379
2379
|
add(e, t) {
|
|
2380
|
-
if (e instanceof
|
|
2380
|
+
if (e instanceof Xe) {
|
|
2381
2381
|
const i = e.equations.length;
|
|
2382
2382
|
if (i !== s(this, D).length)
|
|
2383
2383
|
throw new Error("The number of equations must be the same");
|
|
@@ -2386,7 +2386,7 @@ const He = class He {
|
|
|
2386
2386
|
} else {
|
|
2387
2387
|
if (t === void 0 || t < 0 || t >= s(this, D).length)
|
|
2388
2388
|
throw new Error("Index out of range");
|
|
2389
|
-
const i = new
|
|
2389
|
+
const i = new X(e);
|
|
2390
2390
|
s(this, D)[t].add(i);
|
|
2391
2391
|
}
|
|
2392
2392
|
return this;
|
|
@@ -2417,7 +2417,7 @@ const He = class He {
|
|
|
2417
2417
|
return this.variables.length === s(this, D).length;
|
|
2418
2418
|
}
|
|
2419
2419
|
get matrix() {
|
|
2420
|
-
return s(this,
|
|
2420
|
+
return s(this, jt).call(this);
|
|
2421
2421
|
}
|
|
2422
2422
|
multiply(e, t) {
|
|
2423
2423
|
if (Array.isArray(e)) {
|
|
@@ -2438,7 +2438,7 @@ const He = class He {
|
|
|
2438
2438
|
return [];
|
|
2439
2439
|
}
|
|
2440
2440
|
subtract(e, t) {
|
|
2441
|
-
if (e instanceof
|
|
2441
|
+
if (e instanceof Xe) {
|
|
2442
2442
|
const i = e.equations.length;
|
|
2443
2443
|
if (i !== s(this, D).length)
|
|
2444
2444
|
throw new Error("The number of equations must be the same");
|
|
@@ -2447,7 +2447,7 @@ const He = class He {
|
|
|
2447
2447
|
} else {
|
|
2448
2448
|
if (t === void 0 || t < 0 || t >= s(this, D).length)
|
|
2449
2449
|
throw new Error("Index out of range");
|
|
2450
|
-
const i = new
|
|
2450
|
+
const i = new X(e);
|
|
2451
2451
|
s(this, D)[t].subtract(i);
|
|
2452
2452
|
}
|
|
2453
2453
|
return this;
|
|
@@ -2464,26 +2464,26 @@ const He = class He {
|
|
|
2464
2464
|
t.sort(), h(this, $e, t);
|
|
2465
2465
|
}
|
|
2466
2466
|
};
|
|
2467
|
-
D = new WeakMap(), $e = new WeakMap(),
|
|
2468
|
-
let ii =
|
|
2469
|
-
var
|
|
2470
|
-
class
|
|
2467
|
+
D = new WeakMap(), $e = new WeakMap(), Ft = new WeakMap(), jt = new WeakMap();
|
|
2468
|
+
let ii = Xe;
|
|
2469
|
+
var Ae, gt, si;
|
|
2470
|
+
class ts {
|
|
2471
2471
|
/**
|
|
2472
2472
|
*
|
|
2473
2473
|
* @param {string} value (optional) Default polynom to parse on class creation
|
|
2474
2474
|
*/
|
|
2475
2475
|
constructor(e) {
|
|
2476
|
-
p(this,
|
|
2477
|
-
p(this,
|
|
2478
|
-
a(this, "parse", (e) => (h(this,
|
|
2479
|
-
return h(this,
|
|
2476
|
+
p(this, gt);
|
|
2477
|
+
p(this, Ae);
|
|
2478
|
+
a(this, "parse", (e) => (h(this, Ae, new Kt(Fe.SET).parse(e).rpn), this));
|
|
2479
|
+
return h(this, Ae, []), e !== void 0 && this.parse(e), this;
|
|
2480
2480
|
}
|
|
2481
2481
|
evaluate(e) {
|
|
2482
2482
|
this.variables.forEach((i) => {
|
|
2483
2483
|
Object.hasOwn(e, i) || (e[i] = !1);
|
|
2484
2484
|
});
|
|
2485
2485
|
const t = [];
|
|
2486
|
-
for (const i of s(this,
|
|
2486
|
+
for (const i of s(this, Ae))
|
|
2487
2487
|
if (console.log(i), i.tokenType === "variable")
|
|
2488
2488
|
t.push(e[i.token]);
|
|
2489
2489
|
else if (i.tokenType === "operation")
|
|
@@ -2512,11 +2512,11 @@ class es {
|
|
|
2512
2512
|
return t.length === 1 && t[0];
|
|
2513
2513
|
}
|
|
2514
2514
|
get rpn() {
|
|
2515
|
-
return s(this,
|
|
2515
|
+
return s(this, Ae);
|
|
2516
2516
|
}
|
|
2517
2517
|
get tex() {
|
|
2518
2518
|
const e = [];
|
|
2519
|
-
for (const t of s(this,
|
|
2519
|
+
for (const t of s(this, Ae))
|
|
2520
2520
|
if (t.tokenType === "variable")
|
|
2521
2521
|
e.push(t);
|
|
2522
2522
|
else
|
|
@@ -2549,23 +2549,23 @@ class es {
|
|
|
2549
2549
|
return e[0].token;
|
|
2550
2550
|
}
|
|
2551
2551
|
get variables() {
|
|
2552
|
-
return s(this,
|
|
2552
|
+
return s(this, Ae).filter((e) => e.tokenType === "variable").map((e) => e.token);
|
|
2553
2553
|
}
|
|
2554
2554
|
vennAB() {
|
|
2555
|
-
return
|
|
2555
|
+
return A(this, gt, si).call(this, {
|
|
2556
2556
|
A: ["A", "AB"],
|
|
2557
2557
|
B: ["B", "AB"]
|
|
2558
2558
|
}, ["A", "B", "AB", "E"]);
|
|
2559
2559
|
}
|
|
2560
2560
|
vennABC() {
|
|
2561
|
-
return
|
|
2561
|
+
return A(this, gt, si).call(this, {
|
|
2562
2562
|
A: ["A", "AB", "AC", "ABC"],
|
|
2563
2563
|
B: ["B", "AB", "BC", "ABC"],
|
|
2564
2564
|
C: ["C", "AC", "BC", "ABC"]
|
|
2565
2565
|
}, ["A", "B", "C", "AB", "AC", "BC", "ABC", "E"]);
|
|
2566
2566
|
}
|
|
2567
2567
|
}
|
|
2568
|
-
|
|
2568
|
+
Ae = new WeakMap(), gt = new WeakSet(), si = function(e, t) {
|
|
2569
2569
|
const i = [];
|
|
2570
2570
|
let n;
|
|
2571
2571
|
if (t === void 0) {
|
|
@@ -2577,7 +2577,7 @@ Oe = new WeakMap(), pt = new WeakSet(), si = function(e, t) {
|
|
|
2577
2577
|
]);
|
|
2578
2578
|
} else
|
|
2579
2579
|
n = new Set(t);
|
|
2580
|
-
for (const r of s(this,
|
|
2580
|
+
for (const r of s(this, Ae))
|
|
2581
2581
|
if (r.tokenType === "variable")
|
|
2582
2582
|
e[r.token] === void 0 ? i.push(/* @__PURE__ */ new Set()) : i.push(new Set(e[r.token]));
|
|
2583
2583
|
else
|
|
@@ -2609,34 +2609,34 @@ Oe = new WeakMap(), pt = new WeakSet(), si = function(e, t) {
|
|
|
2609
2609
|
}
|
|
2610
2610
|
return [...i[0]].sort();
|
|
2611
2611
|
};
|
|
2612
|
-
var
|
|
2613
|
-
const
|
|
2612
|
+
var it, N, Ge, ri, qi, yt, oi;
|
|
2613
|
+
const G = class G {
|
|
2614
2614
|
constructor(...e) {
|
|
2615
|
-
p(this,
|
|
2616
|
-
p(this,
|
|
2617
|
-
p(this,
|
|
2615
|
+
p(this, yt);
|
|
2616
|
+
p(this, it, ct.POWER);
|
|
2617
|
+
p(this, N, []);
|
|
2618
2618
|
return this.parse(...e), this;
|
|
2619
2619
|
}
|
|
2620
2620
|
parse(...e) {
|
|
2621
|
-
return e.length === 0 ? this : (h(this,
|
|
2621
|
+
return e.length === 0 ? this : (h(this, N, []), e.forEach((t) => {
|
|
2622
2622
|
if (typeof t == "string") {
|
|
2623
2623
|
const i = t.split(")(").join(")*(").split("*");
|
|
2624
|
-
s(this,
|
|
2625
|
-
} else t instanceof
|
|
2624
|
+
s(this, N).push(...i.map((n) => new ie(n)));
|
|
2625
|
+
} else t instanceof G ? s(this, N).push(...t.factors.map((i) => i.clone())) : s(this, N).push(new ie(t));
|
|
2626
2626
|
}), this);
|
|
2627
2627
|
}
|
|
2628
2628
|
clone() {
|
|
2629
|
-
return new
|
|
2629
|
+
return new G(...s(this, N).map((e) => e.clone()));
|
|
2630
2630
|
}
|
|
2631
2631
|
get tex() {
|
|
2632
|
-
const { num: e, den: t } =
|
|
2632
|
+
const { num: e, den: t } = A(this, yt, oi).call(this);
|
|
2633
2633
|
if (t.length === 0)
|
|
2634
2634
|
return e.length === 1 ? e[0].asSingle.tex : e.map((r) => r.tex).join("");
|
|
2635
2635
|
const i = e.length === 1 ? e[0].asSingle.tex : e.map((r) => r.tex).join(""), n = t.length === 1 ? t[0].asSingle.tex : t.map((r) => r.tex).join("");
|
|
2636
2636
|
return `\\frac{ ${i} }{ ${n} }`;
|
|
2637
2637
|
}
|
|
2638
2638
|
get display() {
|
|
2639
|
-
const { num: e, den: t } =
|
|
2639
|
+
const { num: e, den: t } = A(this, yt, oi).call(this);
|
|
2640
2640
|
if (t.length === 0)
|
|
2641
2641
|
return e.length === 1 ? e[0].asSingle.display : e.map((r) => r.display).join("");
|
|
2642
2642
|
const i = e.length === 1 ? e[0].asSingle.display : e.map((r) => r.display).join(""), n = t.length === 1 ? t[0].asSingle.display : t.map((r) => r.display).join("");
|
|
@@ -2645,75 +2645,115 @@ const ue = class ue {
|
|
|
2645
2645
|
static gcd(...e) {
|
|
2646
2646
|
var i;
|
|
2647
2647
|
if (e.length === 0)
|
|
2648
|
-
return new
|
|
2648
|
+
return new G().one();
|
|
2649
2649
|
if (e.length === 1)
|
|
2650
2650
|
return e[0];
|
|
2651
2651
|
if (e.length === 2)
|
|
2652
|
-
return
|
|
2652
|
+
return A(i = G, Ge, ri).call(i, e[0], e[1]);
|
|
2653
2653
|
let t = e[0];
|
|
2654
2654
|
return e.shift(), e.forEach((n) => {
|
|
2655
2655
|
var r;
|
|
2656
|
-
return t =
|
|
2656
|
+
return t = A(r = G, Ge, ri).call(r, t, n);
|
|
2657
|
+
}), t;
|
|
2658
|
+
}
|
|
2659
|
+
static lcm(...e) {
|
|
2660
|
+
if (e.length === 0)
|
|
2661
|
+
return new G().one();
|
|
2662
|
+
if (e.length === 1)
|
|
2663
|
+
return e[0];
|
|
2664
|
+
let t = e[0];
|
|
2665
|
+
return e.shift(), e.forEach((i) => {
|
|
2666
|
+
var n;
|
|
2667
|
+
return t = A(n = G, Ge, qi).call(n, t, i);
|
|
2657
2668
|
}), t;
|
|
2658
2669
|
}
|
|
2659
2670
|
add(...e) {
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2671
|
+
const t = [this.numerator, ...e.map((c) => c.numerator)], i = [this.denominator, ...e.map((c) => c.denominator)];
|
|
2672
|
+
let n;
|
|
2673
|
+
if (i.some((c) => c.factors.length > 0)) {
|
|
2674
|
+
const c = G.lcm(...i);
|
|
2675
|
+
t.forEach((d, f) => {
|
|
2676
|
+
d.multiply(c.clone().divide(i[f]));
|
|
2677
|
+
}), n = c;
|
|
2678
|
+
}
|
|
2679
|
+
const r = G.gcd(...t), l = new T(0).add(
|
|
2680
|
+
...t.map((c) => c.divide(r).reduce().develop().factors[0].polynom)
|
|
2681
|
+
);
|
|
2682
|
+
return h(this, N, [
|
|
2683
|
+
...r.factors,
|
|
2684
|
+
new ie(l)
|
|
2685
|
+
]), n && this.divide(n), h(this, N, s(this, N).filter((c) => !c.power.isZero())), this;
|
|
2668
2686
|
}
|
|
2669
2687
|
get asPower() {
|
|
2670
|
-
return h(this,
|
|
2688
|
+
return h(this, it, ct.POWER), this;
|
|
2671
2689
|
}
|
|
2672
2690
|
get asRoot() {
|
|
2673
|
-
return h(this,
|
|
2691
|
+
return h(this, it, ct.ROOT), this;
|
|
2674
2692
|
}
|
|
2675
2693
|
degree(e) {
|
|
2676
|
-
return s(this,
|
|
2694
|
+
return s(this, N).reduce((t, i) => t.add(i.degree(e)), new u("0"));
|
|
2677
2695
|
}
|
|
2678
2696
|
get denominator() {
|
|
2679
|
-
return new
|
|
2697
|
+
return new G(
|
|
2698
|
+
...s(this, N).filter((e) => e.power.isNegative()).map((e) => e.clone().inverse())
|
|
2699
|
+
);
|
|
2680
2700
|
}
|
|
2681
2701
|
derivative() {
|
|
2682
|
-
const e = [], t = s(this,
|
|
2702
|
+
const e = [], t = s(this, N).length;
|
|
2683
2703
|
for (let n = 0; n < t; n++) {
|
|
2684
|
-
const r = s(this,
|
|
2685
|
-
e.push(new
|
|
2704
|
+
const r = s(this, N).slice(), l = r.splice(n, 1)[0];
|
|
2705
|
+
e.push(new G(...r).multiply(new G(...l.derivative())));
|
|
2686
2706
|
}
|
|
2687
2707
|
e.forEach((n) => n.reduce());
|
|
2688
2708
|
const i = e.shift();
|
|
2689
|
-
return i !== void 0 && h(this,
|
|
2709
|
+
return i !== void 0 && h(this, N, i.factors), this.add(...e);
|
|
2690
2710
|
}
|
|
2691
2711
|
develop() {
|
|
2692
|
-
const e = new
|
|
2693
|
-
return
|
|
2694
|
-
e.multiply(
|
|
2695
|
-
}),
|
|
2712
|
+
const e = new T("1"), t = new T("1");
|
|
2713
|
+
return this.numerator.factors.forEach((i) => {
|
|
2714
|
+
e.multiply(i.develop());
|
|
2715
|
+
}), this.denominator.factors.forEach((i) => {
|
|
2716
|
+
t.multiply(i.develop());
|
|
2717
|
+
}), new G().fromPolynom(e, t);
|
|
2696
2718
|
}
|
|
2697
2719
|
divide(e) {
|
|
2698
|
-
return h(this,
|
|
2720
|
+
return h(this, N, s(this, N).concat(e.clone().factors.map((t) => t.inverse()))), this;
|
|
2699
2721
|
}
|
|
2700
2722
|
evaluate(e, t) {
|
|
2701
|
-
return t ? s(this,
|
|
2723
|
+
return t ? s(this, N).reduce((i, n) => i * n.evaluate(e, t), 1) : s(this, N).reduce((i, n) => i.multiply(n.evaluate(e)), new u("1"));
|
|
2724
|
+
}
|
|
2725
|
+
factorize(e) {
|
|
2726
|
+
const t = [];
|
|
2727
|
+
s(this, N).forEach((l) => {
|
|
2728
|
+
const c = l.polynom.factorize(e);
|
|
2729
|
+
if (c.length > 1) {
|
|
2730
|
+
const d = l.power.clone();
|
|
2731
|
+
t.push(...c.map((f) => new ie(f, d)));
|
|
2732
|
+
} else
|
|
2733
|
+
t.push(l.clone());
|
|
2734
|
+
});
|
|
2735
|
+
const i = new G(...t), n = i.numerator.reduce(), r = i.denominator.reduce();
|
|
2736
|
+
return n.divide(r);
|
|
2702
2737
|
}
|
|
2703
2738
|
get factors() {
|
|
2704
|
-
return s(this,
|
|
2739
|
+
return s(this, N);
|
|
2705
2740
|
}
|
|
2706
2741
|
set factors(e) {
|
|
2707
|
-
h(this,
|
|
2708
|
-
}
|
|
2709
|
-
fromPolynom(e, t, i) {
|
|
2710
|
-
return h(this, E, new O(e).factorize(i).map((n) => new le(n))), t && new O(t).factorize(i).forEach((n) => s(this, E).push(new le(n, -1))), this;
|
|
2742
|
+
h(this, N, e);
|
|
2711
2743
|
}
|
|
2712
|
-
|
|
2713
|
-
|
|
2744
|
+
fromPolynom(e, t) {
|
|
2745
|
+
if (h(this, N, [new ie(new T(e))]), t) {
|
|
2746
|
+
const i = new T(t);
|
|
2747
|
+
if (i.isOne())
|
|
2748
|
+
return this;
|
|
2749
|
+
if (i.isZero())
|
|
2750
|
+
throw new Error("Cannot divide by zero");
|
|
2751
|
+
s(this, N).push(new ie(i, -1));
|
|
2752
|
+
}
|
|
2753
|
+
return this;
|
|
2714
2754
|
}
|
|
2715
2755
|
getZeroes() {
|
|
2716
|
-
const e = [].concat(...s(this,
|
|
2756
|
+
const e = [].concat(...s(this, N).map((t) => t.polynom.getZeroes()));
|
|
2717
2757
|
return e.sort((t, i) => t.value - i.value), e.filter(
|
|
2718
2758
|
(t, i, n) => i === n.findIndex(
|
|
2719
2759
|
(r) => r.value === t.value
|
|
@@ -2721,63 +2761,63 @@ const ue = class ue {
|
|
|
2721
2761
|
);
|
|
2722
2762
|
}
|
|
2723
2763
|
hasVariable(e) {
|
|
2724
|
-
return s(this,
|
|
2764
|
+
return s(this, N).some((t) => t.hasVariable(e));
|
|
2725
2765
|
}
|
|
2726
2766
|
inverse() {
|
|
2727
|
-
return h(this,
|
|
2767
|
+
return h(this, N, s(this, N).map((e) => e.inverse())), this;
|
|
2728
2768
|
}
|
|
2729
2769
|
isEqual(e) {
|
|
2730
|
-
const t =
|
|
2770
|
+
const t = G.gcd(this, e), i = this.clone().divide(t).reduce(), n = e.clone().divide(t).reduce();
|
|
2731
2771
|
return i.isOne() && n.isOne();
|
|
2732
2772
|
}
|
|
2733
2773
|
isOne() {
|
|
2734
|
-
return s(this,
|
|
2774
|
+
return s(this, N).every((e) => e.isOne());
|
|
2735
2775
|
}
|
|
2736
2776
|
isZero() {
|
|
2737
|
-
return s(this,
|
|
2777
|
+
return s(this, N).every((e) => e.isZero());
|
|
2738
2778
|
}
|
|
2739
2779
|
multiply(...e) {
|
|
2740
2780
|
return e.forEach((t) => {
|
|
2741
|
-
h(this,
|
|
2781
|
+
h(this, N, s(this, N).concat(t.clone().factors));
|
|
2742
2782
|
}), this;
|
|
2743
2783
|
}
|
|
2744
2784
|
get numerator() {
|
|
2745
|
-
return new
|
|
2785
|
+
return new G(...s(this, N).filter((e) => e.power.isPositive()));
|
|
2746
2786
|
}
|
|
2747
2787
|
one() {
|
|
2748
|
-
return h(this,
|
|
2788
|
+
return h(this, N, [new ie("1", "1")]), this;
|
|
2749
2789
|
}
|
|
2750
2790
|
opposite() {
|
|
2751
|
-
const e = s(this,
|
|
2752
|
-
return e >= 0 ? s(this,
|
|
2791
|
+
const e = s(this, N).findIndex((t) => t.display === "(-1)");
|
|
2792
|
+
return e >= 0 ? s(this, N).splice(e, 1) : s(this, N).push(new ie("-1", "1")), this;
|
|
2753
2793
|
}
|
|
2754
2794
|
pow(e) {
|
|
2755
|
-
return h(this,
|
|
2795
|
+
return h(this, N, s(this, N).map((t) => t.pow(e))), this;
|
|
2756
2796
|
}
|
|
2757
2797
|
primitive() {
|
|
2758
2798
|
throw new Error("Method not implemented.");
|
|
2759
2799
|
}
|
|
2760
2800
|
reduce() {
|
|
2761
|
-
const e =
|
|
2762
|
-
return h(this,
|
|
2801
|
+
const e = ht(this);
|
|
2802
|
+
return h(this, N, Object.values(e).map((t) => {
|
|
2763
2803
|
const i = t[0].polynom, n = t.reduce((r, l) => r.add(l.power), new u("0"));
|
|
2764
|
-
return new
|
|
2804
|
+
return new ie(i, n.reduce());
|
|
2765
2805
|
}).filter((t) => !t.power.isZero())), this;
|
|
2766
2806
|
}
|
|
2767
2807
|
root(e) {
|
|
2768
|
-
return h(this,
|
|
2808
|
+
return h(this, N, s(this, N).map((t) => t.root(e))), this;
|
|
2769
2809
|
}
|
|
2770
2810
|
sort() {
|
|
2771
|
-
return h(this,
|
|
2811
|
+
return h(this, N, s(this, N).sort((e, t) => e.degree().isLeq(t.degree()) ? -1 : 1)), this;
|
|
2772
2812
|
}
|
|
2773
2813
|
sqrt() {
|
|
2774
|
-
return h(this,
|
|
2814
|
+
return h(this, N, s(this, N).map((e) => e.sqrt())), this;
|
|
2775
2815
|
}
|
|
2776
2816
|
subtract(...e) {
|
|
2777
2817
|
return this.add(...e.map((t) => t.opposite()));
|
|
2778
2818
|
}
|
|
2779
2819
|
tableOfSigns() {
|
|
2780
|
-
const e = this.getZeroes(), t = this.factors.map((n) => ({ factor: new
|
|
2820
|
+
const e = this.getZeroes(), t = this.factors.map((n) => ({ factor: new ie(n), ...n.tableOfSigns(e) }));
|
|
2781
2821
|
return { signs: t.map((n) => n.signs).reduce((n, r) => (n.length === 0 ? n = r : r.forEach((l, c) => {
|
|
2782
2822
|
switch (l) {
|
|
2783
2823
|
case "d":
|
|
@@ -2796,38 +2836,44 @@ const ue = class ue {
|
|
|
2796
2836
|
}), n), []), roots: e, factors: t };
|
|
2797
2837
|
}
|
|
2798
2838
|
get variables() {
|
|
2799
|
-
return s(this,
|
|
2839
|
+
return s(this, N).reduce((e, t) => e.concat(t.variables), []);
|
|
2800
2840
|
}
|
|
2801
2841
|
zero() {
|
|
2802
|
-
return h(this,
|
|
2842
|
+
return h(this, N, [new ie("0", "1")]), this;
|
|
2803
2843
|
}
|
|
2804
2844
|
};
|
|
2805
|
-
|
|
2806
|
-
const i =
|
|
2807
|
-
const d = i[c].reduce((g,
|
|
2808
|
-
return new
|
|
2845
|
+
it = new WeakMap(), N = new WeakMap(), Ge = new WeakSet(), ri = function(e, t) {
|
|
2846
|
+
const i = ht(e), n = ht(t), l = Object.keys(i).filter((c) => Object.hasOwn(n, c)).map((c) => {
|
|
2847
|
+
const d = i[c].reduce((g, x) => g.add(x.power), new u("0")), f = n[c].reduce((g, x) => g.add(x.power), new u("0"));
|
|
2848
|
+
return new ie(c, u.min(d, f));
|
|
2809
2849
|
});
|
|
2810
|
-
return new
|
|
2811
|
-
},
|
|
2850
|
+
return new G(...l);
|
|
2851
|
+
}, qi = function(e, t) {
|
|
2852
|
+
const i = ht(e), n = ht(t), l = [.../* @__PURE__ */ new Set([...Object.keys(i), ...Object.keys(n)])].map((c) => {
|
|
2853
|
+
const d = Object.hasOwn(i, c) ? i[c].reduce((g, x) => g.add(x.power), new u("0")) : new u(0), f = Object.hasOwn(n, c) ? n[c].reduce((g, x) => g.add(x.power), new u("0")) : new u(0);
|
|
2854
|
+
return new ie(c, u.max(d, f));
|
|
2855
|
+
});
|
|
2856
|
+
return new G(...l);
|
|
2857
|
+
}, yt = new WeakSet(), oi = function() {
|
|
2812
2858
|
let e, t = [];
|
|
2813
|
-
return s(this,
|
|
2814
|
-
}, p(
|
|
2815
|
-
let ni =
|
|
2816
|
-
function
|
|
2859
|
+
return s(this, it) === ct.ROOT ? (e = this.numerator.factors, t = this.denominator.factors) : e = s(this, N), e.length === 0 && (e = [new ie("1")]), { num: e, den: t };
|
|
2860
|
+
}, p(G, Ge);
|
|
2861
|
+
let ni = G;
|
|
2862
|
+
function ht(o) {
|
|
2817
2863
|
const e = new u().one(), t = o.factors.reduce((i, n) => {
|
|
2818
2864
|
if (n.polynom.degree().isZero())
|
|
2819
2865
|
return n.polynom.monoms.length > 0 && e.multiply(n.polynom.monoms[0].coefficient), i;
|
|
2820
2866
|
const r = n.polynom.display;
|
|
2821
2867
|
return Object.hasOwn(i, r) ? i[r].push(n) : i[r] = [n], i;
|
|
2822
2868
|
}, {});
|
|
2823
|
-
return e.isOne() || (t[e.display] = [new
|
|
2869
|
+
return e.isOne() || (t[e.display] = [new ie(e.display, 1)]), t;
|
|
2824
2870
|
}
|
|
2825
|
-
function
|
|
2871
|
+
function is(o, e) {
|
|
2826
2872
|
return o.dimension === e.dimension && o.array.every(
|
|
2827
2873
|
(t, i) => e.array[i].isEqual(t)
|
|
2828
2874
|
);
|
|
2829
2875
|
}
|
|
2830
|
-
function
|
|
2876
|
+
function ss(o, e) {
|
|
2831
2877
|
if (o.dimension !== e.dimension)
|
|
2832
2878
|
return !1;
|
|
2833
2879
|
const t = e.array[0].value / o.array[0].value;
|
|
@@ -2835,13 +2881,13 @@ function is(o, e) {
|
|
|
2835
2881
|
(i, n) => e.array[n].value === i.value * t
|
|
2836
2882
|
);
|
|
2837
2883
|
}
|
|
2838
|
-
function
|
|
2884
|
+
function ns(o, e) {
|
|
2839
2885
|
return o.dimension !== e.dimension ? new u().invalid() : o.array.reduce(
|
|
2840
2886
|
(t, i, n) => t.add(i.clone().multiply(e.array[n])),
|
|
2841
2887
|
new u(0)
|
|
2842
2888
|
);
|
|
2843
2889
|
}
|
|
2844
|
-
function
|
|
2890
|
+
function rs(...o) {
|
|
2845
2891
|
return o.some((e) => e.dimension !== o[0].dimension) ? new u().invalid() : o[0].dimension === 2 && o.length !== 2 ? new u().invalid() : o[0].dimension === 3 && o.length !== 3 ? new u().invalid() : o[0].dimension === 2 ? o[0].array[0].clone().multiply(o[1].array[1]).subtract(o[0].array[1].clone().multiply(o[1].array[0])) : o[0].array[0].clone().multiply(
|
|
2846
2892
|
o[1].array[1].clone().multiply(o[2].array[2]).subtract(o[1].array[2].clone().multiply(o[2].array[1]))
|
|
2847
2893
|
).subtract(
|
|
@@ -2864,15 +2910,15 @@ const Se = class Se {
|
|
|
2864
2910
|
const e = this.norm;
|
|
2865
2911
|
return e === 0 ? this : this.divideByScalar(e);
|
|
2866
2912
|
});
|
|
2867
|
-
a(this, "dot", (e) =>
|
|
2913
|
+
a(this, "dot", (e) => ns(this, e));
|
|
2868
2914
|
a(this, "normal", () => {
|
|
2869
2915
|
if (this.dimension >= 3)
|
|
2870
2916
|
throw new Error("Normal vector can only be determined in 2D");
|
|
2871
2917
|
const e = this.x.clone().opposite(), t = this.y.clone();
|
|
2872
2918
|
return s(this, F)[0] = t, s(this, F)[1] = e, this;
|
|
2873
2919
|
});
|
|
2874
|
-
a(this, "isEqual", (e) =>
|
|
2875
|
-
a(this, "isColinearTo", (e) =>
|
|
2920
|
+
a(this, "isEqual", (e) => is(this, e));
|
|
2921
|
+
a(this, "isColinearTo", (e) => ss(this, e));
|
|
2876
2922
|
a(this, "isNormalTo", (e) => this.dot(e).isZero());
|
|
2877
2923
|
a(this, "multiplyByScalar", (e) => {
|
|
2878
2924
|
const t = new u(e);
|
|
@@ -2880,9 +2926,9 @@ const Se = class Se {
|
|
|
2880
2926
|
});
|
|
2881
2927
|
a(this, "divideByScalar", (e) => this.multiplyByScalar(new u(e).inverse()));
|
|
2882
2928
|
a(this, "simplify", () => this.multiplyByScalar(
|
|
2883
|
-
|
|
2929
|
+
W.lcm(...this.array.map((e) => e.denominator))
|
|
2884
2930
|
).divideByScalar(
|
|
2885
|
-
|
|
2931
|
+
W.gcd(...this.array.map((e) => e.numerator))
|
|
2886
2932
|
).multiplyByScalar(
|
|
2887
2933
|
this.x.isNegative() ? -1 : 1
|
|
2888
2934
|
));
|
|
@@ -3036,9 +3082,9 @@ const Se = class Se {
|
|
|
3036
3082
|
}
|
|
3037
3083
|
};
|
|
3038
3084
|
F = new WeakMap(), De = new WeakMap();
|
|
3039
|
-
let
|
|
3085
|
+
let E = Se;
|
|
3040
3086
|
var we = /* @__PURE__ */ ((o) => (o.None = "none", o.Parallel = "parallel", o.Perpendicular = "perpendicular", o.Tangent = "tangent", o))(we || {}), hi = /* @__PURE__ */ ((o) => (o.None = "none", o.Parallel = "parallel", o.Perpendicular = "perpendicular", o.Tangent = "tangent", o))(hi || {});
|
|
3041
|
-
function
|
|
3087
|
+
function Mi(o = 0.5) {
|
|
3042
3088
|
return Math.random() < o;
|
|
3043
3089
|
}
|
|
3044
3090
|
function de(o, e, t) {
|
|
@@ -3055,14 +3101,14 @@ function de(o, e, t) {
|
|
|
3055
3101
|
i = de(o, e);
|
|
3056
3102
|
return i;
|
|
3057
3103
|
}
|
|
3058
|
-
function
|
|
3059
|
-
return e === !1 ?
|
|
3104
|
+
function Q(o, e) {
|
|
3105
|
+
return e === !1 ? Mi() ? de(1, o) : -de(1, o) : de(-o, o);
|
|
3060
3106
|
}
|
|
3061
|
-
function
|
|
3062
|
-
let e =
|
|
3107
|
+
function os(o) {
|
|
3108
|
+
let e = W.primes();
|
|
3063
3109
|
return o !== void 0 && (e = e.filter((t) => t < o)), pi(e);
|
|
3064
3110
|
}
|
|
3065
|
-
function
|
|
3111
|
+
function hs(o, e) {
|
|
3066
3112
|
return e === void 0 && (e = 1), o.length <= 0 ? Object.values(o) : ki(o).slice(0, e);
|
|
3067
3113
|
}
|
|
3068
3114
|
function pi(o) {
|
|
@@ -3076,19 +3122,19 @@ function ki(o) {
|
|
|
3076
3122
|
}
|
|
3077
3123
|
return e;
|
|
3078
3124
|
}
|
|
3079
|
-
class B extends
|
|
3125
|
+
class B extends E {
|
|
3080
3126
|
constructor(...e) {
|
|
3081
3127
|
super(), e.length > 0 && this.parse(...e);
|
|
3082
3128
|
}
|
|
3083
3129
|
parse(...e) {
|
|
3084
3130
|
if (this.asPoint = !0, e.length === 1) {
|
|
3085
|
-
if (e[0] instanceof
|
|
3131
|
+
if (e[0] instanceof E)
|
|
3086
3132
|
return this.array = e[0].copy(), this;
|
|
3087
3133
|
if (typeof e[0] == "string")
|
|
3088
3134
|
return this.fromString(e[0]), this;
|
|
3089
3135
|
}
|
|
3090
3136
|
if (e.length > 1) {
|
|
3091
|
-
if (e.some((i) => i instanceof
|
|
3137
|
+
if (e.some((i) => i instanceof E))
|
|
3092
3138
|
throw new Error("Creating a point with multiple argument requires an input fraction");
|
|
3093
3139
|
const t = e.map((i) => new u(i));
|
|
3094
3140
|
if (t.some((i) => i.isNaN()))
|
|
@@ -3102,7 +3148,7 @@ class B extends x {
|
|
|
3102
3148
|
return e.array = this.copy(), e.asPoint = !0, e;
|
|
3103
3149
|
}
|
|
3104
3150
|
}
|
|
3105
|
-
var Ie, S, z, U,
|
|
3151
|
+
var Ie, S, z, U, oe, K, Pe, be;
|
|
3106
3152
|
const Ze = class Ze {
|
|
3107
3153
|
/**
|
|
3108
3154
|
* Value can be a mix of:
|
|
@@ -3115,19 +3161,19 @@ const Ze = class Ze {
|
|
|
3115
3161
|
p(this, S);
|
|
3116
3162
|
p(this, z);
|
|
3117
3163
|
p(this, U);
|
|
3118
|
-
p(this,
|
|
3119
|
-
p(this,
|
|
3164
|
+
p(this, oe);
|
|
3165
|
+
p(this, K);
|
|
3120
3166
|
p(this, Pe);
|
|
3121
3167
|
p(this, be, "canonical");
|
|
3122
3168
|
a(this, "randomPoint", (e) => {
|
|
3123
|
-
const t = s(this,
|
|
3169
|
+
const t = s(this, K).clone().multiplyByScalar(Q(e === void 0 || e <= 1 ? 3 : e, !1)).add(s(this, oe));
|
|
3124
3170
|
return t.asPoint = !0, t;
|
|
3125
3171
|
});
|
|
3126
3172
|
a(this, "randomNearPoint", (e) => {
|
|
3127
3173
|
const t = this.randomPoint(e);
|
|
3128
3174
|
let i = 10;
|
|
3129
3175
|
for (; this.isOnLine(t) && i > 0; )
|
|
3130
|
-
t.x.add(
|
|
3176
|
+
t.x.add(Q(1, !1)), t.y.add(Q(1, !1)), i--;
|
|
3131
3177
|
return t;
|
|
3132
3178
|
});
|
|
3133
3179
|
// ------------------------------------------
|
|
@@ -3144,31 +3190,31 @@ const Ze = class Ze {
|
|
|
3144
3190
|
if (e.length === 1) {
|
|
3145
3191
|
if (e[0] instanceof Ze)
|
|
3146
3192
|
return this.fromCoefficient(e[0].a, e[0].b, e[0].c);
|
|
3147
|
-
if (e[0] instanceof
|
|
3193
|
+
if (e[0] instanceof X)
|
|
3148
3194
|
return this.fromEquation(e[0]);
|
|
3149
3195
|
if (typeof e[0] == "string")
|
|
3150
3196
|
try {
|
|
3151
|
-
const t = new
|
|
3197
|
+
const t = new X(e[0]);
|
|
3152
3198
|
return this.parse(t);
|
|
3153
3199
|
} catch {
|
|
3154
3200
|
return this;
|
|
3155
3201
|
}
|
|
3156
3202
|
}
|
|
3157
|
-
if (e.length === 2 && e.every((t) => t instanceof
|
|
3203
|
+
if (e.length === 2 && e.every((t) => t instanceof E)) {
|
|
3158
3204
|
const t = e;
|
|
3159
3205
|
if (t[0].asPoint && t[1].asPoint)
|
|
3160
|
-
return this.fromPointAndDirection(t[0], new
|
|
3206
|
+
return this.fromPointAndDirection(t[0], new E(t[0], t[1]));
|
|
3161
3207
|
if (t[0].asPoint && !t[1].asPoint)
|
|
3162
3208
|
return this.fromPointAndDirection(t[0], t[1]);
|
|
3163
3209
|
}
|
|
3164
3210
|
if (e.length === 3) {
|
|
3165
|
-
if (e[0] instanceof
|
|
3211
|
+
if (e[0] instanceof E && e[1] instanceof E) {
|
|
3166
3212
|
if (e[2] === we.Perpendicular)
|
|
3167
3213
|
return this.fromPointAndNormal(e[0], e[1]);
|
|
3168
3214
|
if (e[2] === we.Parallel)
|
|
3169
3215
|
return this.fromPointAndDirection(e[0], e[1]);
|
|
3170
3216
|
}
|
|
3171
|
-
return e[0] instanceof
|
|
3217
|
+
return e[0] instanceof E && e[1] instanceof Ze ? e[2] === we.Parallel || e[2] === null ? this.fromPointAndLine(e[0], e[1], we.Parallel) : this.fromPointAndLine(e[0], e[1], we.Perpendicular) : this.fromCoefficient(
|
|
3172
3218
|
e[0],
|
|
3173
3219
|
e[1],
|
|
3174
3220
|
e[2]
|
|
@@ -3189,19 +3235,19 @@ const Ze = class Ze {
|
|
|
3189
3235
|
e.left.monomByDegree(0).coefficient
|
|
3190
3236
|
);
|
|
3191
3237
|
});
|
|
3192
|
-
a(this, "fromCoefficient", (e, t, i) => (h(this, S, new u(e)), h(this, z, new u(t)), h(this, U, new u(i)), h(this,
|
|
3238
|
+
a(this, "fromCoefficient", (e, t, i) => (h(this, S, new u(e)), h(this, z, new u(t)), h(this, U, new u(i)), h(this, K, new E(s(this, z).clone(), s(this, S).clone().opposite())), h(this, oe, new E(new u().zero(), s(this, U).clone())), h(this, Pe, s(this, K).clone().normal()), this));
|
|
3193
3239
|
a(this, "fromPointAndDirection", (e, t) => (this.fromCoefficient(
|
|
3194
3240
|
t.y,
|
|
3195
3241
|
t.x.clone().opposite(),
|
|
3196
3242
|
e.x.clone().multiply(t.y).subtract(e.y.clone().multiply(t.x)).opposite()
|
|
3197
|
-
), h(this,
|
|
3243
|
+
), h(this, oe, e.clone()), h(this, K, t.clone()), h(this, Pe, s(this, K).clone().normal()), this));
|
|
3198
3244
|
a(this, "fromPointAndNormal", (e, t) => this.fromCoefficient(
|
|
3199
3245
|
t.x,
|
|
3200
3246
|
t.y,
|
|
3201
3247
|
e.x.clone().multiply(t.x).add(e.y.clone().multiply(t.y)).opposite()
|
|
3202
3248
|
));
|
|
3203
3249
|
a(this, "fromPointAndLine", (e, t, i) => (i === void 0 && (i = we.Parallel), i === we.Parallel ? this.fromPointAndNormal(e, t.normal) : i === we.Perpendicular ? this.fromPointAndNormal(e, t.director) : this));
|
|
3204
|
-
a(this, "clone", () => (h(this, S, s(this, S).clone()), h(this, z, s(this, z).clone()), h(this, U, s(this, U).clone()), h(this,
|
|
3250
|
+
a(this, "clone", () => (h(this, S, s(this, S).clone()), h(this, z, s(this, z).clone()), h(this, U, s(this, U).clone()), h(this, K, s(this, K).clone()), h(this, oe, s(this, oe).clone()), h(this, Pe, s(this, Pe).clone()), this));
|
|
3205
3251
|
// ------------------------------------------
|
|
3206
3252
|
// Mathematical operations
|
|
3207
3253
|
// ------------------------------------------
|
|
@@ -3213,14 +3259,14 @@ const Ze = class Ze {
|
|
|
3213
3259
|
a(this, "isPerpendicularTo", (e) => this.d.isNormalTo(e.d));
|
|
3214
3260
|
a(this, "isVertical", () => this.slope.isInfinity());
|
|
3215
3261
|
a(this, "simplify", () => {
|
|
3216
|
-
const e =
|
|
3262
|
+
const e = W.lcm(s(this, S).denominator, s(this, z).denominator, s(this, U).denominator), t = W.gcd(s(this, S).numerator, s(this, z).numerator, s(this, U).numerator);
|
|
3217
3263
|
return this.fromCoefficient(
|
|
3218
3264
|
s(this, S).clone().multiply(e).divide(t),
|
|
3219
3265
|
s(this, z).clone().multiply(e).divide(t),
|
|
3220
3266
|
s(this, U).clone().multiply(e).divide(t)
|
|
3221
3267
|
), this;
|
|
3222
3268
|
});
|
|
3223
|
-
a(this, "simplifyDirection", () => (s(this,
|
|
3269
|
+
a(this, "simplifyDirection", () => (s(this, K).simplify(), this));
|
|
3224
3270
|
a(this, "intersection", (e) => {
|
|
3225
3271
|
const t = new B();
|
|
3226
3272
|
let i = !1, n = !1;
|
|
@@ -3233,13 +3279,13 @@ const Ze = class Ze {
|
|
|
3233
3279
|
});
|
|
3234
3280
|
a(this, "getValueAtX", (e) => {
|
|
3235
3281
|
const t = this.getEquation().isolate("y"), i = new u(e);
|
|
3236
|
-
return t instanceof
|
|
3282
|
+
return t instanceof X ? t.right.evaluate({ x: i }) : new u().invalid();
|
|
3237
3283
|
});
|
|
3238
3284
|
a(this, "getValueAtY", (e) => {
|
|
3239
3285
|
const t = this.getEquation().isolate("x"), i = new u(e);
|
|
3240
|
-
return t instanceof
|
|
3286
|
+
return t instanceof X ? t.right.evaluate({ y: i }) : new u().invalid();
|
|
3241
3287
|
});
|
|
3242
|
-
return h(this, S, new u().zero()), h(this, z, new u().zero()), h(this, U, new u().zero()), h(this,
|
|
3288
|
+
return h(this, S, new u().zero()), h(this, z, new u().zero()), h(this, U, new u().zero()), h(this, oe, new E()), h(this, K, new E()), h(this, Pe, new E()), h(this, Ie, !0), e.length > 0 && this.parse(...e), this;
|
|
3243
3289
|
}
|
|
3244
3290
|
get a() {
|
|
3245
3291
|
return s(this, S);
|
|
@@ -3262,23 +3308,23 @@ const Ze = class Ze {
|
|
|
3262
3308
|
h(this, U, e);
|
|
3263
3309
|
}
|
|
3264
3310
|
get OA() {
|
|
3265
|
-
return s(this,
|
|
3311
|
+
return s(this, oe);
|
|
3266
3312
|
}
|
|
3267
3313
|
set OA(e) {
|
|
3268
|
-
h(this,
|
|
3314
|
+
h(this, oe, e);
|
|
3269
3315
|
}
|
|
3270
3316
|
get d() {
|
|
3271
|
-
return s(this,
|
|
3317
|
+
return s(this, K);
|
|
3272
3318
|
}
|
|
3273
3319
|
set d(e) {
|
|
3274
|
-
h(this,
|
|
3320
|
+
h(this, K, e);
|
|
3275
3321
|
}
|
|
3276
3322
|
get n() {
|
|
3277
3323
|
return s(this, Pe);
|
|
3278
3324
|
}
|
|
3279
3325
|
// ------------------------------------------
|
|
3280
3326
|
getEquation() {
|
|
3281
|
-
const e = new
|
|
3327
|
+
const e = new X(new T().parse("xy", s(this, S), s(this, z), s(this, U)), new T("0"));
|
|
3282
3328
|
return s(this, Ie) ? e.simplify() : e;
|
|
3283
3329
|
}
|
|
3284
3330
|
// get system(): { x: Equation, y: Equation } {
|
|
@@ -3315,13 +3361,13 @@ const Ze = class Ze {
|
|
|
3315
3361
|
case "equation":
|
|
3316
3362
|
return this.getEquation().reorder().tex;
|
|
3317
3363
|
case "mxh":
|
|
3318
|
-
return this.slope.isInfinity() ? "x=" + this.OA.x.tex : "y=" + new
|
|
3364
|
+
return this.slope.isInfinity() ? "x=" + this.OA.x.tex : "y=" + new T().parse("x", this.slope, this.height).tex;
|
|
3319
3365
|
case "parametric":
|
|
3320
3366
|
case "system": {
|
|
3321
|
-
const t = s(this,
|
|
3322
|
-
return s(this, Ie) && t.simplify(), e === "parametric" ? `${
|
|
3323
|
-
x &= ${new
|
|
3324
|
-
y &= ${new
|
|
3367
|
+
const t = s(this, K).clone();
|
|
3368
|
+
return s(this, Ie) && t.simplify(), e === "parametric" ? `${E.asTex("x", "y")} = ${E.asTex(s(this, oe).x.tex, s(this, oe).y.tex)} + k\\cdot ${E.asTex(t.x.tex, t.y.tex)}` : `\\left\\{\\begin{aligned}
|
|
3369
|
+
x &= ${new T(s(this, oe).x).add(new k(s(this, K).x).multiply(new k("k"))).reorder("k", !0).tex}\\\\
|
|
3370
|
+
y &= ${new T(s(this, oe).y).add(new k(s(this, K).y).multiply(new k("k"))).reorder("k", !0).tex}
|
|
3325
3371
|
\\end{aligned}\\right.`;
|
|
3326
3372
|
}
|
|
3327
3373
|
default: {
|
|
@@ -3342,10 +3388,10 @@ const Ze = class Ze {
|
|
|
3342
3388
|
case "equation":
|
|
3343
3389
|
return this.getEquation().reorder().display;
|
|
3344
3390
|
case "mxh":
|
|
3345
|
-
return this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new
|
|
3391
|
+
return this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new T().parse("x", this.slope, this.height).display;
|
|
3346
3392
|
case "parametric": {
|
|
3347
|
-
const t = s(this,
|
|
3348
|
-
return s(this, Ie) && t.simplify(), `((x,y))=((${s(this,
|
|
3393
|
+
const t = s(this, K).clone();
|
|
3394
|
+
return s(this, Ie) && t.simplify(), `((x,y))=((${s(this, oe).x.display},${s(this, oe).y.display}))+k((${t.x.display},${t.y.display}))`;
|
|
3349
3395
|
}
|
|
3350
3396
|
default: {
|
|
3351
3397
|
const t = this.getEquation();
|
|
@@ -3354,10 +3400,10 @@ const Ze = class Ze {
|
|
|
3354
3400
|
}
|
|
3355
3401
|
}
|
|
3356
3402
|
get normal() {
|
|
3357
|
-
return new
|
|
3403
|
+
return new E(s(this, S), s(this, z));
|
|
3358
3404
|
}
|
|
3359
3405
|
get director() {
|
|
3360
|
-
return s(this,
|
|
3406
|
+
return s(this, K).clone();
|
|
3361
3407
|
}
|
|
3362
3408
|
get slope() {
|
|
3363
3409
|
return s(this, S).clone().opposite().divide(s(this, z));
|
|
@@ -3366,7 +3412,7 @@ const Ze = class Ze {
|
|
|
3366
3412
|
return s(this, U).clone().opposite().divide(s(this, z));
|
|
3367
3413
|
}
|
|
3368
3414
|
fromPoints(e, t) {
|
|
3369
|
-
return this.fromPointAndDirection(e, new
|
|
3415
|
+
return this.fromPointAndDirection(e, new E(e, t));
|
|
3370
3416
|
}
|
|
3371
3417
|
distanceTo(e) {
|
|
3372
3418
|
const t = e.x.clone().multiply(s(this, S)).add(e.y.clone().multiply(s(this, z))).add(s(this, U)).abs(), i = this.normal.normSquare;
|
|
@@ -3402,14 +3448,14 @@ const Ze = class Ze {
|
|
|
3402
3448
|
return s(this, S).isZero() || (s(this, S).isOne() ? t = "x" : s(this, S).clone().opposite().isOne() ? t = "-x" : t = s(this, S).value.toFixed(e) + "x"), s(this, z).isZero() || (s(this, z).isPositive() && (t += "+"), t += s(this, z).value.toFixed(e) + "y"), s(this, U).isZero() || (s(this, U).isPositive() && (t += "+"), t += s(this, U).value.toFixed(e)), t + "=0";
|
|
3403
3449
|
}
|
|
3404
3450
|
};
|
|
3405
|
-
Ie = new WeakMap(), S = new WeakMap(), z = new WeakMap(), U = new WeakMap(),
|
|
3451
|
+
Ie = new WeakMap(), S = new WeakMap(), z = new WeakMap(), U = new WeakMap(), oe = new WeakMap(), K = new WeakMap(), Pe = new WeakMap(), be = new WeakMap(), // A line is defined as the canonical form
|
|
3406
3452
|
a(Ze, "PERPENDICULAR", we.Perpendicular), a(Ze, "PARALLEL", we.Parallel);
|
|
3407
3453
|
let R = Ze;
|
|
3408
|
-
var
|
|
3409
|
-
const
|
|
3454
|
+
var he, j, qe, Ut, Wt, Gt, ae, Ci, Nt, $i, Ii, Pi, ai;
|
|
3455
|
+
const Ht = class Ht {
|
|
3410
3456
|
constructor(...e) {
|
|
3411
|
-
p(this,
|
|
3412
|
-
p(this,
|
|
3457
|
+
p(this, ae);
|
|
3458
|
+
p(this, he);
|
|
3413
3459
|
p(this, j);
|
|
3414
3460
|
p(this, qe);
|
|
3415
3461
|
/**
|
|
@@ -3418,9 +3464,9 @@ const Wt = class Wt {
|
|
|
3418
3464
|
* @returns {number}
|
|
3419
3465
|
*/
|
|
3420
3466
|
a(this, "relativePosition", (e) => {
|
|
3421
|
-
if (s(this,
|
|
3467
|
+
if (s(this, he) === void 0 || s(this, j) === void 0)
|
|
3422
3468
|
throw new Error("Circle not defined");
|
|
3423
|
-
const t = e.distanceTo(s(this,
|
|
3469
|
+
const t = e.distanceTo(s(this, he)), i = Math.sqrt(s(this, j).value);
|
|
3424
3470
|
return t.value - i > 1e-10 ? 0 : Math.abs(t.value - i) < 1e-10 ? 1 : 2;
|
|
3425
3471
|
});
|
|
3426
3472
|
a(this, "lineIntersection", (e) => {
|
|
@@ -3428,15 +3474,15 @@ const Wt = class Wt {
|
|
|
3428
3474
|
if (s(this, qe) === void 0)
|
|
3429
3475
|
return [];
|
|
3430
3476
|
const i = s(this, qe).clone(), n = e.getEquation().clone().isolate("x"), r = e.getEquation().clone().isolate("y");
|
|
3431
|
-
return n instanceof
|
|
3477
|
+
return n instanceof X && r instanceof X && (i.replaceBy("y", r.right).simplify(), i.solve()), t;
|
|
3432
3478
|
});
|
|
3433
|
-
a(this, "tangents", (e) => e instanceof u ? s(this, Gt).call(this, e) : this.isPointOnCircle(e) ? s(this,
|
|
3479
|
+
a(this, "tangents", (e) => e instanceof u ? s(this, Gt).call(this, e) : this.isPointOnCircle(e) ? s(this, Ut).call(this, e) : s(this, he) !== void 0 && s(this, he).distanceTo(e).value > this.radius.value ? s(this, Wt).call(this, e) : (console.log("No tangents as the point is inside !"), []));
|
|
3434
3480
|
a(this, "isPointOnCircle", (e) => {
|
|
3435
3481
|
var t;
|
|
3436
3482
|
return ((t = s(this, qe)) == null ? void 0 : t.test({ x: e.x, y: e.y })) ?? !1;
|
|
3437
3483
|
});
|
|
3438
3484
|
a(this, "getPointsOnCircle", (e) => {
|
|
3439
|
-
const t =
|
|
3485
|
+
const t = W.pythagoreanTripletsWithTarget(this.squareRadius.value, !0), i = [];
|
|
3440
3486
|
return t.forEach((n) => {
|
|
3441
3487
|
for (const r of [[1, 1], [-1, 1], [-1, -1], [1, -1]])
|
|
3442
3488
|
i.push(
|
|
@@ -3447,15 +3493,15 @@ const Wt = class Wt {
|
|
|
3447
3493
|
);
|
|
3448
3494
|
}), i;
|
|
3449
3495
|
});
|
|
3450
|
-
p(this,
|
|
3451
|
-
const t = new
|
|
3496
|
+
p(this, Ut, (e) => {
|
|
3497
|
+
const t = new E(this.center, e);
|
|
3452
3498
|
return [new R(e, t, we.Perpendicular)];
|
|
3453
3499
|
});
|
|
3454
|
-
p(this,
|
|
3455
|
-
const t = this.center.x.clone().subtract(e.x), i = this.center.y.clone().subtract(e.y), n = new
|
|
3456
|
-
return n.multiply(t).subtract(i).pow(2), r.multiply(this.squareRadius), new
|
|
3500
|
+
p(this, Wt, (e) => {
|
|
3501
|
+
const t = this.center.x.clone().subtract(e.x), i = this.center.y.clone().subtract(e.y), n = new T("x"), r = new T("x^2+1");
|
|
3502
|
+
return n.multiply(t).subtract(i).pow(2), r.multiply(this.squareRadius), new X(n, r).solve().map((d) => {
|
|
3457
3503
|
let f;
|
|
3458
|
-
const g = new
|
|
3504
|
+
const g = new X("y", "x");
|
|
3459
3505
|
return d.exact instanceof u ? (f = e.x.clone().opposite().multiply(d.exact).add(e.y), g.right.multiply(d.exact).add(f)) : (f = e.x.clone().opposite().multiply(d.value).add(e.y), g.right.multiply(d.value).add(f)), new R(g);
|
|
3460
3506
|
});
|
|
3461
3507
|
});
|
|
@@ -3466,7 +3512,7 @@ const Wt = class Wt {
|
|
|
3466
3512
|
e.length > 0 && this.parse(...e);
|
|
3467
3513
|
}
|
|
3468
3514
|
get center() {
|
|
3469
|
-
return s(this,
|
|
3515
|
+
return s(this, he) ?? new B();
|
|
3470
3516
|
}
|
|
3471
3517
|
get squareRadius() {
|
|
3472
3518
|
return s(this, j) ?? new u(0);
|
|
@@ -3499,17 +3545,17 @@ const Wt = class Wt {
|
|
|
3499
3545
|
return this.center.x.isZero() ? e = "x^2" : e = `(x${this.center.x.isNegative() ? "+" : "-"}${this.center.x.clone().abs().tex})^2`, this.center.y.isZero() ? t = "y^2" : t = `(y${this.center.y.isNegative() ? "+" : "-"}${this.center.y.clone().abs().tex})^2`, `${e}+${t}=${this.squareRadius.display}`;
|
|
3500
3546
|
}
|
|
3501
3547
|
clone() {
|
|
3502
|
-
return new
|
|
3548
|
+
return new Ht(
|
|
3503
3549
|
this.center.clone(),
|
|
3504
3550
|
this.squareRadius.clone(),
|
|
3505
3551
|
!0
|
|
3506
3552
|
);
|
|
3507
3553
|
}
|
|
3508
3554
|
setRadius(e, t) {
|
|
3509
|
-
return t ? h(this, j, new u(e)) : h(this, j, new u(e).pow(2)),
|
|
3555
|
+
return t ? h(this, j, new u(e)) : h(this, j, new u(e).pow(2)), A(this, ae, Nt).call(this), this;
|
|
3510
3556
|
}
|
|
3511
3557
|
parse(...e) {
|
|
3512
|
-
return
|
|
3558
|
+
return A(this, ae, Ci).call(this), typeof e[0] == "string" ? A(this, ae, ai).call(this, new X(e[0])) : e[0] instanceof X ? A(this, ae, ai).call(this, e[0]) : e[0] instanceof Ht ? A(this, ae, $i).call(this, e[0]) : e[0] instanceof B && e.length > 1 && (e[1] instanceof B ? e[2] instanceof B || A(this, ae, Pi).call(this, e[0], e[1]) : (e[1] instanceof u || typeof e[1] == "number") && A(this, ae, Ii).call(this, e[0], e[1], typeof e[2] == "boolean" ? e[2] : !1)), A(this, ae, Nt).call(this), this;
|
|
3513
3559
|
}
|
|
3514
3560
|
// private _parseThroughtThreePoints(A: Point, B: Point, C: Point): this {
|
|
3515
3561
|
// const T = new Triangle(A, B, C), mAB = T.remarquables.mediators.AB.clone(),
|
|
@@ -3518,35 +3564,35 @@ const Wt = class Wt {
|
|
|
3518
3564
|
// return this
|
|
3519
3565
|
// }
|
|
3520
3566
|
};
|
|
3521
|
-
|
|
3522
|
-
return h(this,
|
|
3523
|
-
},
|
|
3524
|
-
h(this, qe, new
|
|
3525
|
-
new
|
|
3526
|
-
new
|
|
3567
|
+
he = new WeakMap(), j = new WeakMap(), qe = new WeakMap(), Ut = new WeakMap(), Wt = new WeakMap(), Gt = new WeakMap(), ae = new WeakSet(), Ci = function() {
|
|
3568
|
+
return h(this, he, void 0), h(this, j, void 0), h(this, qe, void 0), this;
|
|
3569
|
+
}, Nt = function() {
|
|
3570
|
+
h(this, qe, new X(
|
|
3571
|
+
new T(`(x-(${this.center.x.display}))^2+(y-(${this.center.y.display}))^2`),
|
|
3572
|
+
new T(this.squareRadius.display)
|
|
3527
3573
|
).moveLeft());
|
|
3528
|
-
},
|
|
3529
|
-
return h(this,
|
|
3530
|
-
},
|
|
3531
|
-
return h(this,
|
|
3532
|
-
},
|
|
3533
|
-
return h(this,
|
|
3574
|
+
}, $i = function(e) {
|
|
3575
|
+
return h(this, he, e.center.clone()), h(this, j, e.squareRadius.clone()), A(this, ae, Nt).call(this), this;
|
|
3576
|
+
}, Ii = function(e, t, i) {
|
|
3577
|
+
return h(this, he, e.clone()), i ? h(this, j, new u(t)) : h(this, j, new u(t).pow(2)), this;
|
|
3578
|
+
}, Pi = function(e, t) {
|
|
3579
|
+
return h(this, he, e.clone()), h(this, j, new E(s(this, he), t).normSquare), this;
|
|
3534
3580
|
}, ai = function(e) {
|
|
3535
3581
|
if (e.moveLeft(), e.degree("x").value === 2 && e.degree("y").value === 2) {
|
|
3536
3582
|
const t = e.left.monomByDegree(2, "x"), i = e.left.monomByDegree(2, "y");
|
|
3537
3583
|
let n, r, l;
|
|
3538
|
-
t.coefficient.isEqual(i.coefficient) ? (e.divide(t.coefficient), n = e.left.monomByDegree(1, "x"), r = e.left.monomByDegree(1, "y"), l = e.left.monomByDegree(0), h(this,
|
|
3584
|
+
t.coefficient.isEqual(i.coefficient) ? (e.divide(t.coefficient), n = e.left.monomByDegree(1, "x"), r = e.left.monomByDegree(1, "y"), l = e.left.monomByDegree(0), h(this, he, new B(n.coefficient.clone().divide(2).opposite(), r.coefficient.clone().divide(2).opposite())), h(this, j, l.coefficient.clone().opposite().add(s(this, he).x.clone().pow(2)).add(s(this, he).y.clone().pow(2)))) : (h(this, he, void 0), h(this, j, void 0));
|
|
3539
3585
|
}
|
|
3540
3586
|
return this;
|
|
3541
3587
|
};
|
|
3542
|
-
let Tt =
|
|
3543
|
-
var L,
|
|
3544
|
-
const
|
|
3588
|
+
let Tt = Ht;
|
|
3589
|
+
var L, H;
|
|
3590
|
+
const ut = class ut {
|
|
3545
3591
|
constructor(e, t) {
|
|
3546
3592
|
// ax + by + c = 0
|
|
3547
3593
|
p(this, L, new B());
|
|
3548
|
-
p(this,
|
|
3549
|
-
a(this, "clone", () => (h(this,
|
|
3594
|
+
p(this, H, new E());
|
|
3595
|
+
a(this, "clone", () => (h(this, H, s(this, H).clone()), h(this, L, s(this, L).clone()), this));
|
|
3550
3596
|
// ------------------------------------------
|
|
3551
3597
|
// Mathematical operations
|
|
3552
3598
|
// ------------------------------------------
|
|
@@ -3586,14 +3632,14 @@ const lt = class lt {
|
|
|
3586
3632
|
// return new Fraction().invalid()
|
|
3587
3633
|
// }
|
|
3588
3634
|
a(this, "randomPoint", (e = 5) => {
|
|
3589
|
-
const t = s(this, L).clone(), i = new u(
|
|
3635
|
+
const t = s(this, L).clone(), i = new u(Q(e, !1));
|
|
3590
3636
|
return new B(
|
|
3591
|
-
t.x.clone().add(s(this,
|
|
3592
|
-
t.y.clone().add(s(this,
|
|
3593
|
-
t.z.clone().add(s(this,
|
|
3637
|
+
t.x.clone().add(s(this, H).x.clone().multiply(i)),
|
|
3638
|
+
t.y.clone().add(s(this, H).y.clone().multiply(i)),
|
|
3639
|
+
t.z.clone().add(s(this, H).z.clone().multiply(i))
|
|
3594
3640
|
);
|
|
3595
3641
|
});
|
|
3596
|
-
return h(this, L, e.clone()), h(this,
|
|
3642
|
+
return h(this, L, e.clone()), h(this, H, t.asPoint ? new E(e, t) : t.clone()), this;
|
|
3597
3643
|
}
|
|
3598
3644
|
get OA() {
|
|
3599
3645
|
return s(this, L);
|
|
@@ -3605,35 +3651,35 @@ const lt = class lt {
|
|
|
3605
3651
|
return s(this, L).clone();
|
|
3606
3652
|
}
|
|
3607
3653
|
get d() {
|
|
3608
|
-
return s(this,
|
|
3654
|
+
return s(this, H);
|
|
3609
3655
|
}
|
|
3610
3656
|
set d(e) {
|
|
3611
|
-
h(this,
|
|
3657
|
+
h(this, H, e);
|
|
3612
3658
|
}
|
|
3613
3659
|
get tex() {
|
|
3614
3660
|
return {
|
|
3615
|
-
parametric: `${
|
|
3661
|
+
parametric: `${E.asTex("x", "y", "z")} = ${E.asTex(s(this, L).x.tex, s(this, L).y.tex, s(this, L).z.tex)} + k\\cdot ${E.asTex(s(this, H).x.tex, s(this, H).y.tex, s(this, H).z.tex)}`,
|
|
3616
3662
|
system: `\\left\\{\\begin{aligned}
|
|
3617
|
-
x &= ${new
|
|
3618
|
-
y &= ${new
|
|
3619
|
-
z &= ${new
|
|
3663
|
+
x &= ${new T(s(this, L).x).add(new k(s(this, H).x).multiply(new k("k"))).reorder("k", !0).tex}\\\\
|
|
3664
|
+
y &= ${new T(s(this, L).y).add(new k(s(this, H).y).multiply(new k("k"))).reorder("k", !0).tex}\\\\
|
|
3665
|
+
z &= ${new T(s(this, L).z).add(new k(s(this, H).z).multiply(new k("k"))).reorder("k", !0).tex}
|
|
3620
3666
|
\\end{aligned}\\right.`,
|
|
3621
|
-
cartesian: `\\frac{ ${new
|
|
3667
|
+
cartesian: `\\frac{ ${new T("x", 1, s(this, L).x.clone().opposite()).tex} }{ ${this.direction.x.tex} } = \\frac{ ${new T("y", 1, s(this, L).y.clone().opposite()).tex} }{ ${this.direction.y.tex} } = \\frac{ ${new T("z", 1, s(this, L).z.clone().opposite()).tex} }{ ${this.direction.z.tex} }`
|
|
3622
3668
|
};
|
|
3623
3669
|
}
|
|
3624
3670
|
get display() {
|
|
3625
3671
|
const e = s(this, L).x.display, t = s(this, L).y.display, i = s(this, L).z.display, n = this.direction.simplify(), r = n.x.display, l = n.y.display, c = n.z.display;
|
|
3626
3672
|
return {
|
|
3627
|
-
parametric: `${
|
|
3673
|
+
parametric: `${E.asDisplay("x", "y", "z")} = ${E.asDisplay(s(this, L).x.display, s(this, L).y.display, s(this, L).z.display)} + k\\cdot ${E.asDisplay(s(this, H).x.display, s(this, H).y.display, s(this, H).z.display)}`,
|
|
3628
3674
|
system: "",
|
|
3629
3675
|
cartesian: `(x-${e})/${r} = (y-${t})/${l} = (z-${i})/${c}`
|
|
3630
3676
|
};
|
|
3631
3677
|
}
|
|
3632
3678
|
get direction() {
|
|
3633
|
-
return s(this,
|
|
3679
|
+
return s(this, H).clone();
|
|
3634
3680
|
}
|
|
3635
3681
|
distanceTo(e) {
|
|
3636
|
-
const t = new
|
|
3682
|
+
const t = new E(s(this, L), e), i = this.direction, n = this.direction.normSquare, r = t.cross(i).normSquare, l = r.clone().divide(n), c = l.clone().sqrt();
|
|
3637
3683
|
return console.log("CROSS", t.cross(i).display), {
|
|
3638
3684
|
value: Math.sqrt(l.value),
|
|
3639
3685
|
fraction: l.clone().sqrt(),
|
|
@@ -3642,74 +3688,74 @@ const lt = class lt {
|
|
|
3642
3688
|
}
|
|
3643
3689
|
hitSegment(e, t) {
|
|
3644
3690
|
const i = this.intersection(
|
|
3645
|
-
new
|
|
3691
|
+
new ut(e, t)
|
|
3646
3692
|
);
|
|
3647
3693
|
return i.hasIntersection ? i.point.x.value >= Math.min(e.x.value, t.x.value) && i.point.x.value <= Math.max(e.x.value, t.x.value) && i.point.y.value >= Math.min(e.y.value, t.y.value) && i.point.y.value <= Math.max(e.y.value, t.y.value) && i.point.z.value >= Math.min(e.z.value, t.z.value) && i.point.z.value <= Math.max(e.z.value, t.z.value) : !1;
|
|
3648
3694
|
}
|
|
3649
3695
|
};
|
|
3650
|
-
L = new WeakMap(),
|
|
3651
|
-
a(
|
|
3652
|
-
let At =
|
|
3653
|
-
var
|
|
3654
|
-
class
|
|
3696
|
+
L = new WeakMap(), H = new WeakMap(), // A line is defined as the canonical form
|
|
3697
|
+
a(ut, "PERPENDICULAR", hi.Perpendicular), a(ut, "PARALLEL", hi.Parallel);
|
|
3698
|
+
let At = ut;
|
|
3699
|
+
var Me;
|
|
3700
|
+
class as {
|
|
3655
3701
|
constructor(...e) {
|
|
3656
|
-
p(this,
|
|
3657
|
-
return h(this,
|
|
3702
|
+
p(this, Me, []);
|
|
3703
|
+
return h(this, Me, e), this;
|
|
3658
3704
|
}
|
|
3659
3705
|
get values() {
|
|
3660
|
-
return s(this,
|
|
3706
|
+
return s(this, Me);
|
|
3661
3707
|
}
|
|
3662
3708
|
get array() {
|
|
3663
|
-
return s(this,
|
|
3709
|
+
return s(this, Me).map((e) => e.array);
|
|
3664
3710
|
}
|
|
3665
3711
|
get dimension() {
|
|
3666
|
-
return [s(this,
|
|
3712
|
+
return [s(this, Me).length, s(this, Me)[0].dimension];
|
|
3667
3713
|
}
|
|
3668
3714
|
isSquare() {
|
|
3669
|
-
return s(this,
|
|
3715
|
+
return s(this, Me).length === s(this, Me)[0].dimension;
|
|
3670
3716
|
}
|
|
3671
3717
|
determinant() {
|
|
3672
3718
|
if (!this.isSquare())
|
|
3673
3719
|
throw new Error("Matrix is not square");
|
|
3674
|
-
return
|
|
3720
|
+
return rs(...this.values);
|
|
3675
3721
|
}
|
|
3676
3722
|
}
|
|
3677
|
-
|
|
3678
|
-
var
|
|
3723
|
+
Me = new WeakMap();
|
|
3724
|
+
var ke, We;
|
|
3679
3725
|
const gi = class gi {
|
|
3680
3726
|
constructor(e) {
|
|
3681
|
-
p(this,
|
|
3682
|
-
p(this,
|
|
3727
|
+
p(this, ke, new E(0, 0, 1));
|
|
3728
|
+
p(this, We, new B(0, 0, 0));
|
|
3683
3729
|
return e && this.parse(e), this;
|
|
3684
3730
|
}
|
|
3685
3731
|
get normal() {
|
|
3686
|
-
return s(this,
|
|
3732
|
+
return s(this, ke);
|
|
3687
3733
|
}
|
|
3688
3734
|
set normal(e) {
|
|
3689
|
-
h(this,
|
|
3735
|
+
h(this, ke, e), s(this, ke).asPoint = !1;
|
|
3690
3736
|
}
|
|
3691
3737
|
get point() {
|
|
3692
|
-
return s(this,
|
|
3738
|
+
return s(this, We);
|
|
3693
3739
|
}
|
|
3694
3740
|
set point(e) {
|
|
3695
|
-
h(this,
|
|
3741
|
+
h(this, We, e), s(this, We).asPoint = !0;
|
|
3696
3742
|
}
|
|
3697
3743
|
get a() {
|
|
3698
|
-
return s(this,
|
|
3744
|
+
return s(this, ke).x;
|
|
3699
3745
|
}
|
|
3700
3746
|
get b() {
|
|
3701
|
-
return s(this,
|
|
3747
|
+
return s(this, ke).y;
|
|
3702
3748
|
}
|
|
3703
3749
|
get c() {
|
|
3704
|
-
return s(this,
|
|
3750
|
+
return s(this, ke).z;
|
|
3705
3751
|
}
|
|
3706
3752
|
get d() {
|
|
3707
|
-
return s(this,
|
|
3753
|
+
return s(this, ke).dot(s(this, We)).opposite();
|
|
3708
3754
|
}
|
|
3709
3755
|
get tex() {
|
|
3710
|
-
return new
|
|
3711
|
-
new
|
|
3712
|
-
new
|
|
3756
|
+
return new X(
|
|
3757
|
+
new T("xyz", this.a, this.b, this.c, this.d),
|
|
3758
|
+
new T(0)
|
|
3713
3759
|
).reduce().tex;
|
|
3714
3760
|
}
|
|
3715
3761
|
parse(e) {
|
|
@@ -3726,17 +3772,17 @@ const gi = class gi {
|
|
|
3726
3772
|
}
|
|
3727
3773
|
if (e.equation) {
|
|
3728
3774
|
const r = e.equation.moveLeft().reduce().left, l = r.monomByLetter("x").coefficient, c = r.monomByLetter("y").coefficient, d = r.monomByLetter("z").coefficient, f = r.monomByDegree(0).coefficient;
|
|
3729
|
-
this.normal = new
|
|
3775
|
+
this.normal = new E(l, c, d), l.isNotZero() ? this.point = new B(f.clone().divide(l).opposite(), 0, 0) : c.isNotZero() ? this.point = new B(0, f.clone().divide(c).opposite(), 0) : this.point = new B(0, 0, f.clone().divide(d).opposite());
|
|
3730
3776
|
return;
|
|
3731
3777
|
}
|
|
3732
|
-
if (((i = e.points) == null ? void 0 : i.length) === 3 && e.points.every((r) => r instanceof
|
|
3733
|
-
const r = e.points[0], l = e.points[1], c = e.points[2], d = new
|
|
3778
|
+
if (((i = e.points) == null ? void 0 : i.length) === 3 && e.points.every((r) => r instanceof E)) {
|
|
3779
|
+
const r = e.points[0], l = e.points[1], c = e.points[2], d = new E(r, l), f = new E(r, c);
|
|
3734
3780
|
this.normal = d.cross(f), this.point = r;
|
|
3735
3781
|
return;
|
|
3736
3782
|
}
|
|
3737
3783
|
if (((n = e.coefficients) == null ? void 0 : n.length) === 4) {
|
|
3738
3784
|
const [r, l, c, d] = e.coefficients;
|
|
3739
|
-
this.normal = new
|
|
3785
|
+
this.normal = new E(r, l, c), this.point = new B(0, 0, -d);
|
|
3740
3786
|
return;
|
|
3741
3787
|
}
|
|
3742
3788
|
}
|
|
@@ -3744,7 +3790,7 @@ const gi = class gi {
|
|
|
3744
3790
|
if (e instanceof gi)
|
|
3745
3791
|
return this.normal.angle(e.normal, t, i);
|
|
3746
3792
|
let n;
|
|
3747
|
-
if (e instanceof
|
|
3793
|
+
if (e instanceof E) {
|
|
3748
3794
|
if (e.dimension !== 3)
|
|
3749
3795
|
throw new Error("Vector is not 3D");
|
|
3750
3796
|
n = e;
|
|
@@ -3766,15 +3812,15 @@ const gi = class gi {
|
|
|
3766
3812
|
return this.normal.dot(e).add(this.d).isZero();
|
|
3767
3813
|
}
|
|
3768
3814
|
};
|
|
3769
|
-
|
|
3815
|
+
ke = new WeakMap(), We = new WeakMap();
|
|
3770
3816
|
let li = gi;
|
|
3771
|
-
var
|
|
3772
|
-
const
|
|
3817
|
+
var Y, J, _, st, Ce, wt, Xt, vt, Be, Yt, nt;
|
|
3818
|
+
const Qt = class Qt {
|
|
3773
3819
|
constructor(...e) {
|
|
3774
|
-
p(this,
|
|
3775
|
-
p(this, K, new B());
|
|
3820
|
+
p(this, Y, new B());
|
|
3776
3821
|
p(this, J, new B());
|
|
3777
|
-
p(this,
|
|
3822
|
+
p(this, _, new B());
|
|
3823
|
+
p(this, st, {
|
|
3778
3824
|
AB: new R(),
|
|
3779
3825
|
AC: new R(),
|
|
3780
3826
|
BC: new R()
|
|
@@ -3784,7 +3830,7 @@ const Yt = class Yt {
|
|
|
3784
3830
|
AC: new B(),
|
|
3785
3831
|
BC: new B()
|
|
3786
3832
|
});
|
|
3787
|
-
p(this,
|
|
3833
|
+
p(this, wt, null);
|
|
3788
3834
|
// ------------------------------------------
|
|
3789
3835
|
// Creation / parsing functions
|
|
3790
3836
|
// ------------------------------------------
|
|
@@ -3801,9 +3847,9 @@ const Yt = class Yt {
|
|
|
3801
3847
|
if (t.some((i) => i.isNaN()))
|
|
3802
3848
|
throw new Error("One of the values is not a valid number");
|
|
3803
3849
|
return this.parse(
|
|
3804
|
-
new
|
|
3805
|
-
new
|
|
3806
|
-
new
|
|
3850
|
+
new E(t[0], t[1]),
|
|
3851
|
+
new E(t[2], t[3]),
|
|
3852
|
+
new E(t[4], t[5])
|
|
3807
3853
|
);
|
|
3808
3854
|
} else if (e.length === 3) {
|
|
3809
3855
|
if (e.every((t) => typeof t == "string"))
|
|
@@ -3812,36 +3858,36 @@ const Yt = class Yt {
|
|
|
3812
3858
|
);
|
|
3813
3859
|
if (e.every((t) => t instanceof R)) {
|
|
3814
3860
|
const t = e[0].clone(), i = e[1].clone(), n = e[2].clone();
|
|
3815
|
-
h(this,
|
|
3861
|
+
h(this, st, { AB: t, BC: i, AC: n });
|
|
3816
3862
|
let r = t.intersection(i);
|
|
3817
3863
|
if (r.hasIntersection)
|
|
3818
|
-
h(this,
|
|
3864
|
+
h(this, J, r.point.clone());
|
|
3819
3865
|
else
|
|
3820
3866
|
throw new Error("Lines do not intersect !");
|
|
3821
3867
|
if (r = i.intersection(n), r.hasIntersection)
|
|
3822
|
-
h(this,
|
|
3868
|
+
h(this, _, r.point.clone());
|
|
3823
3869
|
else
|
|
3824
3870
|
throw new Error("Lines do not intersect !");
|
|
3825
3871
|
if (r = n.intersection(t), r.hasIntersection)
|
|
3826
|
-
h(this,
|
|
3872
|
+
h(this, Y, r.point.clone());
|
|
3827
3873
|
else
|
|
3828
3874
|
throw new Error("Lines do not intersect !");
|
|
3829
|
-
} else e.every((t) => t instanceof B) && (h(this,
|
|
3830
|
-
AB: new R(s(this,
|
|
3831
|
-
BC: new R(s(this,
|
|
3832
|
-
AC: new R(s(this,
|
|
3875
|
+
} else e.every((t) => t instanceof B) && (h(this, Y, e[0].clone()), h(this, J, e[1].clone()), h(this, _, e[2].clone()), h(this, st, {
|
|
3876
|
+
AB: new R(s(this, Y), s(this, J)),
|
|
3877
|
+
BC: new R(s(this, J), s(this, _)),
|
|
3878
|
+
AC: new R(s(this, Y), s(this, _))
|
|
3833
3879
|
}));
|
|
3834
|
-
} else if (e.length === 1 && e[0] instanceof
|
|
3880
|
+
} else if (e.length === 1 && e[0] instanceof Qt)
|
|
3835
3881
|
return e[0].clone();
|
|
3836
|
-
return s(this,
|
|
3882
|
+
return s(this, Xt).call(this), this;
|
|
3837
3883
|
});
|
|
3838
3884
|
/**
|
|
3839
3885
|
* Clone the Triangle class
|
|
3840
3886
|
*/
|
|
3841
|
-
a(this, "clone", () => new
|
|
3842
|
-
s(this,
|
|
3843
|
-
s(this,
|
|
3844
|
-
s(this,
|
|
3887
|
+
a(this, "clone", () => new Qt(
|
|
3888
|
+
s(this, Y).clone(),
|
|
3889
|
+
s(this, J).clone(),
|
|
3890
|
+
s(this, _).clone()
|
|
3845
3891
|
));
|
|
3846
3892
|
// ------------------------------------------
|
|
3847
3893
|
// Triangle operations and properties
|
|
@@ -3849,54 +3895,54 @@ const Yt = class Yt {
|
|
|
3849
3895
|
/**
|
|
3850
3896
|
* Generate the Line object for the three segments of the triangle
|
|
3851
3897
|
*/
|
|
3852
|
-
p(this,
|
|
3853
|
-
s(this,
|
|
3854
|
-
AB: new B().middleOf(s(this,
|
|
3855
|
-
AC: new B().middleOf(s(this,
|
|
3856
|
-
BC: new B().middleOf(s(this,
|
|
3857
|
-
}), h(this,
|
|
3898
|
+
p(this, Xt, () => {
|
|
3899
|
+
s(this, Y).asPoint = !0, s(this, J).asPoint = !0, s(this, _).asPoint = !0, h(this, Ce, {
|
|
3900
|
+
AB: new B().middleOf(s(this, Y), s(this, J)),
|
|
3901
|
+
AC: new B().middleOf(s(this, Y), s(this, _)),
|
|
3902
|
+
BC: new B().middleOf(s(this, J), s(this, _))
|
|
3903
|
+
}), h(this, wt, s(this, Yt).call(this));
|
|
3858
3904
|
});
|
|
3859
3905
|
/**
|
|
3860
3906
|
* Get the Vector2D class for the given name
|
|
3861
3907
|
* @param ptName
|
|
3862
3908
|
*/
|
|
3863
|
-
p(this,
|
|
3909
|
+
p(this, vt, (e) => {
|
|
3864
3910
|
switch (e.toUpperCase()) {
|
|
3865
3911
|
case "A":
|
|
3866
|
-
return s(this,
|
|
3912
|
+
return s(this, Y);
|
|
3867
3913
|
case "B":
|
|
3868
|
-
return s(this, K);
|
|
3869
|
-
case "C":
|
|
3870
3914
|
return s(this, J);
|
|
3915
|
+
case "C":
|
|
3916
|
+
return s(this, _);
|
|
3871
3917
|
}
|
|
3872
|
-
return s(this,
|
|
3918
|
+
return s(this, Y);
|
|
3873
3919
|
});
|
|
3874
3920
|
/**
|
|
3875
3921
|
* Get the vector for the segment given by name.
|
|
3876
3922
|
* @param ptName1
|
|
3877
3923
|
* @param ptName2
|
|
3878
3924
|
*/
|
|
3879
|
-
p(this, Be, (e, t) => new
|
|
3880
|
-
s(this,
|
|
3881
|
-
s(this,
|
|
3925
|
+
p(this, Be, (e, t) => new E(
|
|
3926
|
+
s(this, vt).call(this, e),
|
|
3927
|
+
s(this, vt).call(this, t)
|
|
3882
3928
|
));
|
|
3883
|
-
p(this,
|
|
3929
|
+
p(this, Yt, () => {
|
|
3884
3930
|
const e = {
|
|
3885
|
-
A: new R().fromPoints(s(this,
|
|
3886
|
-
B: new R().fromPoints(s(this,
|
|
3887
|
-
C: new R().fromPoints(s(this,
|
|
3931
|
+
A: new R().fromPoints(s(this, Y), s(this, Ce).BC),
|
|
3932
|
+
B: new R().fromPoints(s(this, J), s(this, Ce).AC),
|
|
3933
|
+
C: new R().fromPoints(s(this, _), s(this, Ce).AB),
|
|
3888
3934
|
intersection: null
|
|
3889
3935
|
}, t = {
|
|
3890
|
-
AB: new R().fromPointAndNormal(s(this, Ce).AB, new
|
|
3891
|
-
AC: new R().fromPointAndNormal(s(this, Ce).AC, new
|
|
3892
|
-
BC: new R().fromPointAndNormal(s(this, Ce).BC, new
|
|
3936
|
+
AB: new R().fromPointAndNormal(s(this, Ce).AB, new E(s(this, Y), s(this, J)).normal()),
|
|
3937
|
+
AC: new R().fromPointAndNormal(s(this, Ce).AC, new E(s(this, Y), s(this, _)).normal()),
|
|
3938
|
+
BC: new R().fromPointAndNormal(s(this, Ce).BC, new E(s(this, J), s(this, _)).normal()),
|
|
3893
3939
|
intersection: null
|
|
3894
3940
|
}, i = {
|
|
3895
|
-
A: new R().fromPointAndNormal(s(this,
|
|
3896
|
-
B: new R().fromPointAndNormal(s(this,
|
|
3897
|
-
C: new R().fromPointAndNormal(s(this,
|
|
3941
|
+
A: new R().fromPointAndNormal(s(this, Y), new E(s(this, J), s(this, _)).normal()),
|
|
3942
|
+
B: new R().fromPointAndNormal(s(this, J), new E(s(this, Y), s(this, _)).normal()),
|
|
3943
|
+
C: new R().fromPointAndNormal(s(this, _), new E(s(this, Y), s(this, J)).normal()),
|
|
3898
3944
|
intersection: null
|
|
3899
|
-
}, n = s(this,
|
|
3945
|
+
}, n = s(this, nt).call(this, "A"), r = s(this, nt).call(this, "B"), l = s(this, nt).call(this, "C"), c = {
|
|
3900
3946
|
A: n.internal,
|
|
3901
3947
|
B: r.internal,
|
|
3902
3948
|
C: r.internal,
|
|
@@ -3915,7 +3961,7 @@ const Yt = class Yt {
|
|
|
3915
3961
|
};
|
|
3916
3962
|
return f.medians.intersection = f.medians.A.intersection(f.medians.B).point, f.mediators.intersection = f.mediators.AB.intersection(f.mediators.BC).point, f.heights.intersection = f.heights.A.intersection(f.heights.B).point, f.bisectors.intersection = f.bisectors.A.intersection(f.bisectors.B).point, f;
|
|
3917
3963
|
});
|
|
3918
|
-
p(this,
|
|
3964
|
+
p(this, nt, (e) => {
|
|
3919
3965
|
const t = this.lines;
|
|
3920
3966
|
let i, n;
|
|
3921
3967
|
if (e === "A" ? (i = t.AB, n = t.AC) : e === "B" ? (i = t.AB, n = t.BC) : e === "C" && (i = t.BC, n = t.AC), i === void 0 || n === void 0)
|
|
@@ -3929,13 +3975,13 @@ const Yt = class Yt {
|
|
|
3929
3975
|
// Getter and setters
|
|
3930
3976
|
// ------------------------------------------
|
|
3931
3977
|
get A() {
|
|
3932
|
-
return s(this,
|
|
3978
|
+
return s(this, Y);
|
|
3933
3979
|
}
|
|
3934
3980
|
get B() {
|
|
3935
|
-
return s(this,
|
|
3981
|
+
return s(this, J);
|
|
3936
3982
|
}
|
|
3937
3983
|
get C() {
|
|
3938
|
-
return s(this,
|
|
3984
|
+
return s(this, _);
|
|
3939
3985
|
}
|
|
3940
3986
|
get AB() {
|
|
3941
3987
|
return s(this, Be).call(this, "A", "B");
|
|
@@ -3965,15 +4011,15 @@ const Yt = class Yt {
|
|
|
3965
4011
|
return this.AB.normSquare.isEqual(this.BC.normSquare) || this.AB.normSquare.isEqual(this.AC.normSquare) || this.BC.normSquare.isEqual(this.AC.normSquare);
|
|
3966
4012
|
}
|
|
3967
4013
|
get lines() {
|
|
3968
|
-
return s(this,
|
|
4014
|
+
return s(this, st);
|
|
3969
4015
|
}
|
|
3970
4016
|
get remarquables() {
|
|
3971
|
-
return s(this,
|
|
4017
|
+
return s(this, wt);
|
|
3972
4018
|
}
|
|
3973
4019
|
};
|
|
3974
|
-
|
|
3975
|
-
let ci =
|
|
3976
|
-
function
|
|
4020
|
+
Y = new WeakMap(), J = new WeakMap(), _ = new WeakMap(), st = new WeakMap(), Ce = new WeakMap(), wt = new WeakMap(), Xt = new WeakMap(), vt = new WeakMap(), Be = new WeakMap(), Yt = new WeakMap(), nt = new WeakMap();
|
|
4021
|
+
let ci = Qt;
|
|
4022
|
+
function qt(o) {
|
|
3977
4023
|
const e = Object.assign(
|
|
3978
4024
|
{
|
|
3979
4025
|
negative: !0,
|
|
@@ -3984,7 +4030,7 @@ function Ot(o) {
|
|
|
3984
4030
|
},
|
|
3985
4031
|
o
|
|
3986
4032
|
), t = new u();
|
|
3987
|
-
if (e.negative ? t.numerator =
|
|
4033
|
+
if (e.negative ? t.numerator = Q(e.max, e.zero) : t.numerator = de(e.zero ? 0 : 1, e.max), e.natural)
|
|
3988
4034
|
t.denominator = 1;
|
|
3989
4035
|
else {
|
|
3990
4036
|
let i = 0;
|
|
@@ -3993,7 +4039,7 @@ function Ot(o) {
|
|
|
3993
4039
|
}
|
|
3994
4040
|
return e.reduced ? t.reduce() : t;
|
|
3995
4041
|
}
|
|
3996
|
-
function
|
|
4042
|
+
function Bi(o) {
|
|
3997
4043
|
const e = Object.assign(
|
|
3998
4044
|
{
|
|
3999
4045
|
letters: "x",
|
|
@@ -4002,8 +4048,8 @@ function Pi(o) {
|
|
|
4002
4048
|
zero: !1
|
|
4003
4049
|
},
|
|
4004
4050
|
o
|
|
4005
|
-
), t = new
|
|
4006
|
-
if (t.coefficient =
|
|
4051
|
+
), t = new k();
|
|
4052
|
+
if (t.coefficient = qt({
|
|
4007
4053
|
zero: e.zero,
|
|
4008
4054
|
reduced: !0,
|
|
4009
4055
|
natural: !e.fraction
|
|
@@ -4018,7 +4064,7 @@ function Pi(o) {
|
|
|
4018
4064
|
t.setLetter(e.letters, e.degree);
|
|
4019
4065
|
return t;
|
|
4020
4066
|
}
|
|
4021
|
-
const
|
|
4067
|
+
const ls = {
|
|
4022
4068
|
letters: "x",
|
|
4023
4069
|
degree: 2,
|
|
4024
4070
|
fraction: !1,
|
|
@@ -4029,14 +4075,14 @@ const as = {
|
|
|
4029
4075
|
numberOfMonoms: 0,
|
|
4030
4076
|
positive: !0
|
|
4031
4077
|
};
|
|
4032
|
-
function
|
|
4078
|
+
function Si(o) {
|
|
4033
4079
|
const e = Object.assign(
|
|
4034
|
-
|
|
4080
|
+
ls,
|
|
4035
4081
|
o
|
|
4036
|
-
), t = new
|
|
4082
|
+
), t = new T().empty();
|
|
4037
4083
|
let i;
|
|
4038
4084
|
for (let n = e.degree; n >= 0; n--)
|
|
4039
|
-
i =
|
|
4085
|
+
i = Bi({
|
|
4040
4086
|
letters: e.letters,
|
|
4041
4087
|
degree: n,
|
|
4042
4088
|
fraction: e.fraction,
|
|
@@ -4049,7 +4095,7 @@ function Bi(o) {
|
|
|
4049
4095
|
}
|
|
4050
4096
|
return t.reduce();
|
|
4051
4097
|
}
|
|
4052
|
-
function
|
|
4098
|
+
function cs(o) {
|
|
4053
4099
|
const e = Object.assign(
|
|
4054
4100
|
{
|
|
4055
4101
|
letters: "x",
|
|
@@ -4069,9 +4115,9 @@ function ls(o) {
|
|
|
4069
4115
|
}
|
|
4070
4116
|
},
|
|
4071
4117
|
o
|
|
4072
|
-
), t = new
|
|
4118
|
+
), t = new T().one();
|
|
4073
4119
|
for (let i = 0; i < e.degree; i++) {
|
|
4074
|
-
const n =
|
|
4120
|
+
const n = Si({
|
|
4075
4121
|
degree: 1,
|
|
4076
4122
|
unit: e.unit,
|
|
4077
4123
|
fraction: e.fraction,
|
|
@@ -4080,7 +4126,7 @@ function ls(o) {
|
|
|
4080
4126
|
});
|
|
4081
4127
|
t.multiply(n);
|
|
4082
4128
|
}
|
|
4083
|
-
return new
|
|
4129
|
+
return new X(t, 0);
|
|
4084
4130
|
}
|
|
4085
4131
|
function ui(o) {
|
|
4086
4132
|
const e = Object.assign(
|
|
@@ -4091,10 +4137,10 @@ function ui(o) {
|
|
|
4091
4137
|
quadrant: null
|
|
4092
4138
|
},
|
|
4093
4139
|
o
|
|
4094
|
-
), t = e.axis === "x", i = e.axis === "y", n = e.fraction ?
|
|
4140
|
+
), t = e.axis === "x", i = e.axis === "y", n = e.fraction ? qt({ max: e.max, zero: t }) : new u(Q(e.max, t)), r = e.fraction ? qt({ max: e.max, zero: i }) : new u(Q(e.max, i));
|
|
4095
4141
|
return Number(e.quadrant) === 1 && (n.abs(), r.abs()), Number(e.quadrant) === 2 && (n.isPositive() && n.opposite(), r.isNegative() && r.opposite()), Number(e.quadrant) === 3 && (n.isPositive() && n.opposite(), r.isPositive() && r.opposite()), Number(e.quadrant) === 4 && (n.isNegative() && n.opposite(), r.isPositive() && r.opposite()), new B(n, r);
|
|
4096
4142
|
}
|
|
4097
|
-
function
|
|
4143
|
+
function us(o) {
|
|
4098
4144
|
const e = Object.assign(
|
|
4099
4145
|
{
|
|
4100
4146
|
center: {
|
|
@@ -4108,76 +4154,76 @@ function cs(o) {
|
|
|
4108
4154
|
let i, n;
|
|
4109
4155
|
return e.pointsOnCircle === 8 ? (i = de(1, 3), n = i ** 2 + (i + 1) ** 2) : n = de(1, 20), new Tt(t, n, !0);
|
|
4110
4156
|
}
|
|
4111
|
-
function
|
|
4157
|
+
function fs(o) {
|
|
4112
4158
|
const e = Object.assign(
|
|
4113
4159
|
{
|
|
4114
4160
|
A: {
|
|
4115
|
-
x:
|
|
4116
|
-
y:
|
|
4161
|
+
x: Q(10),
|
|
4162
|
+
y: Q(10)
|
|
4117
4163
|
}
|
|
4118
4164
|
},
|
|
4119
4165
|
o
|
|
4120
|
-
), t = new
|
|
4121
|
-
|
|
4122
|
-
|
|
4166
|
+
), t = new E(
|
|
4167
|
+
Q(10),
|
|
4168
|
+
Q(10)
|
|
4123
4169
|
);
|
|
4124
4170
|
for (; t.isNull; )
|
|
4125
|
-
t.x =
|
|
4126
|
-
return e.slope === 1 ? t.x.sign() !== t.y.sign() && t.y.opposite() : e.slope === -1 && t.x.sign() !== t.y.sign() && t.y.opposite(), new R(new
|
|
4171
|
+
t.x = Q(10), t.y = Q(10);
|
|
4172
|
+
return e.slope === 1 ? t.x.sign() !== t.y.sign() && t.y.opposite() : e.slope === -1 && t.x.sign() !== t.y.sign() && t.y.opposite(), new R(new E(e.A.x, e.A.y), t);
|
|
4127
4173
|
}
|
|
4128
|
-
function
|
|
4174
|
+
function ds(o) {
|
|
4129
4175
|
const e = Object.assign(
|
|
4130
4176
|
{
|
|
4131
4177
|
A: {
|
|
4132
|
-
x:
|
|
4133
|
-
y:
|
|
4134
|
-
z:
|
|
4178
|
+
x: Q(10),
|
|
4179
|
+
y: Q(10),
|
|
4180
|
+
z: Q(10)
|
|
4135
4181
|
},
|
|
4136
4182
|
direction: {
|
|
4137
|
-
x:
|
|
4138
|
-
y:
|
|
4139
|
-
z:
|
|
4183
|
+
x: Q(10),
|
|
4184
|
+
y: Q(10),
|
|
4185
|
+
z: Q(10)
|
|
4140
4186
|
}
|
|
4141
4187
|
},
|
|
4142
4188
|
o
|
|
4143
|
-
), t = new B(e.A.x, e.A.y, e.A.z), i = new
|
|
4189
|
+
), t = new B(e.A.x, e.A.y, e.A.z), i = new E(e.direction.x, e.direction.y, e.direction.z);
|
|
4144
4190
|
return new At(t, i);
|
|
4145
4191
|
}
|
|
4146
|
-
const
|
|
4147
|
-
equation: (o) =>
|
|
4148
|
-
polynom: (o) =>
|
|
4149
|
-
monom: (o) =>
|
|
4150
|
-
fraction: (o) =>
|
|
4192
|
+
const ps = {
|
|
4193
|
+
equation: (o) => cs(o),
|
|
4194
|
+
polynom: (o) => Si(o),
|
|
4195
|
+
monom: (o) => Bi(o),
|
|
4196
|
+
fraction: (o) => qt(o),
|
|
4151
4197
|
number: (o, e, t) => de(o, e, t),
|
|
4152
|
-
numberSym: (o, e) =>
|
|
4153
|
-
prime: (o) =>
|
|
4154
|
-
bool: (o) =>
|
|
4155
|
-
array: (o, e) =>
|
|
4198
|
+
numberSym: (o, e) => Q(o, e),
|
|
4199
|
+
prime: (o) => os(o),
|
|
4200
|
+
bool: (o) => Mi(o),
|
|
4201
|
+
array: (o, e) => hs(o, e),
|
|
4156
4202
|
item: (o) => pi(o),
|
|
4157
4203
|
shuffle: (o) => ki(o),
|
|
4158
|
-
line: (o) =>
|
|
4159
|
-
line3: (o) =>
|
|
4204
|
+
line: (o) => fs(o),
|
|
4205
|
+
line3: (o) => ds(o),
|
|
4160
4206
|
vector: (o) => ui(o),
|
|
4161
4207
|
point: (o) => {
|
|
4162
4208
|
const e = ui(o);
|
|
4163
4209
|
return e.asPoint = !0, e;
|
|
4164
4210
|
},
|
|
4165
|
-
circle: (o) =>
|
|
4166
|
-
},
|
|
4167
|
-
Numeric:
|
|
4211
|
+
circle: (o) => us(o)
|
|
4212
|
+
}, gs = {
|
|
4213
|
+
Numeric: W,
|
|
4168
4214
|
Fraction: u,
|
|
4169
|
-
Root:
|
|
4170
|
-
Monom:
|
|
4171
|
-
Polynom:
|
|
4172
|
-
Equation:
|
|
4173
|
-
Matrix:
|
|
4215
|
+
Root: bt,
|
|
4216
|
+
Monom: k,
|
|
4217
|
+
Polynom: T,
|
|
4218
|
+
Equation: X,
|
|
4219
|
+
Matrix: as,
|
|
4174
4220
|
LinearSystem: ii,
|
|
4175
|
-
Factor:
|
|
4221
|
+
Factor: ie,
|
|
4176
4222
|
PolyFactor: ni,
|
|
4177
|
-
LogicalSet:
|
|
4178
|
-
Random:
|
|
4223
|
+
LogicalSet: ts,
|
|
4224
|
+
Random: ps,
|
|
4179
4225
|
Geometry: {
|
|
4180
|
-
Vector:
|
|
4226
|
+
Vector: E,
|
|
4181
4227
|
Point: B,
|
|
4182
4228
|
Line: R,
|
|
4183
4229
|
Triangle: ci,
|
|
@@ -4185,35 +4231,35 @@ const ds = {
|
|
|
4185
4231
|
Line3: At,
|
|
4186
4232
|
Plane3: li
|
|
4187
4233
|
},
|
|
4188
|
-
NumExp:
|
|
4234
|
+
NumExp: es
|
|
4189
4235
|
};
|
|
4190
4236
|
export {
|
|
4191
4237
|
Tt as Circle,
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4238
|
+
X as Equation,
|
|
4239
|
+
Ot as EquationSolver,
|
|
4240
|
+
ct as FACTOR_DISPLAY,
|
|
4241
|
+
ie as Factor,
|
|
4196
4242
|
u as Fraction,
|
|
4197
4243
|
R as Line,
|
|
4198
4244
|
At as Line3,
|
|
4199
4245
|
ii as LinearSystem,
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4246
|
+
ts as LogicalSet,
|
|
4247
|
+
as as Matrix,
|
|
4248
|
+
k as Monom,
|
|
4249
|
+
bt as NthRoot,
|
|
4250
|
+
es as NumExp,
|
|
4251
|
+
W as Numeric,
|
|
4206
4252
|
li as Plane3,
|
|
4207
4253
|
B as Point,
|
|
4208
4254
|
ni as PolyFactor,
|
|
4209
|
-
|
|
4210
|
-
|
|
4255
|
+
T as Polynom,
|
|
4256
|
+
ps as Random,
|
|
4211
4257
|
ci as Triangle,
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4258
|
+
E as Vector,
|
|
4259
|
+
ss as areVectorsColinears,
|
|
4260
|
+
is as areVectorsEquals,
|
|
4261
|
+
gs as default,
|
|
4262
|
+
rs as determinant,
|
|
4263
|
+
ns as dotProduct
|
|
4218
4264
|
};
|
|
4219
4265
|
//# sourceMappingURL=pimath.js.map
|