pimath 0.1.6 → 0.1.7
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/pimath.js +1274 -1011
- package/package.json +1 -1
- package/types/algebra/logicalset.d.ts +25 -0
- package/types/algebra/logicalset.d.ts.map +1 -0
- package/types/index.d.ts +5 -1
- package/types/index.d.ts.map +1 -1
package/dist/pimath.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var ki = Object.defineProperty;
|
|
2
|
+
var li = (o) => {
|
|
3
3
|
throw TypeError(o);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var a = (o, e, t) =>
|
|
7
|
-
var i = (o, e, t) => (
|
|
8
|
-
function
|
|
9
|
-
const e =
|
|
10
|
-
let s,
|
|
5
|
+
var Ci = (o, e, t) => e in o ? ki(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
6
|
+
var a = (o, e, t) => Ci(o, typeof e != "symbol" ? e + "" : e, t), Ht = (o, e, t) => e.has(o) || li("Cannot " + t);
|
|
7
|
+
var i = (o, e, t) => (Ht(o, e, "read from private field"), t ? t.call(o) : e.get(o)), d = (o, e, t) => e.has(o) ? li("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), h = (o, e, t, s) => (Ht(o, e, "write to private field"), s ? s.call(o, t) : e.set(o, t), t), q = (o, e, t) => (Ht(o, e, "access private method"), t);
|
|
8
|
+
function $i(o) {
|
|
9
|
+
const e = ui(o), t = [];
|
|
10
|
+
let s, n;
|
|
11
11
|
for (; e.length > 0; )
|
|
12
|
-
s = e.shift() ?? 1,
|
|
12
|
+
s = e.shift() ?? 1, n = (e.length > 0 ? e.pop() : +s) ?? 1, t.push([s, n]);
|
|
13
13
|
return t;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
const e =
|
|
15
|
+
function Ii(...o) {
|
|
16
|
+
const e = ni(...o);
|
|
17
17
|
return o.map((t) => t / e);
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function ui(o) {
|
|
20
20
|
const e = Math.abs(o), t = Math.sqrt(e), s = [];
|
|
21
|
-
for (let
|
|
22
|
-
o %
|
|
23
|
-
return s.sort(function(
|
|
24
|
-
return
|
|
21
|
+
for (let n = 1; n <= t; n++)
|
|
22
|
+
o % n === 0 && (s.push(n), s.push(e / n));
|
|
23
|
+
return s.sort(function(n, r) {
|
|
24
|
+
return n - r;
|
|
25
25
|
}), [...new Set(s)];
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
const e = function(
|
|
29
|
-
return
|
|
27
|
+
function ni(...o) {
|
|
28
|
+
const e = function(n, r) {
|
|
29
|
+
return r === 0 ? n : e(r, n % r);
|
|
30
30
|
};
|
|
31
31
|
let t = 1, s = 2;
|
|
32
32
|
if (o.length === 0)
|
|
@@ -39,53 +39,53 @@ function _t(...o) {
|
|
|
39
39
|
;
|
|
40
40
|
return Math.abs(t);
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function Bi(...o) {
|
|
43
43
|
return o.reduce(function(e, t) {
|
|
44
|
-
return Math.abs(e * t /
|
|
44
|
+
return Math.abs(e * t / ni(e, t));
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function Si(o, e = 3) {
|
|
48
48
|
return +o.toFixed(e);
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function Pi(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 Ri(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 zi(o, e) {
|
|
60
60
|
const t = [], s = e === !0 ? +o : o ** 2;
|
|
61
|
-
for (let
|
|
62
|
-
for (let
|
|
63
|
-
|
|
61
|
+
for (let n = 0; n <= o; n++)
|
|
62
|
+
for (let r = 0; r <= o; r++)
|
|
63
|
+
n ** 2 + r ** 2 === s && t.push([n, r, o]);
|
|
64
64
|
return t;
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function Li(o, e = 2) {
|
|
67
67
|
return +`${Math.round(+`${o}e${e}`)}e-${e}`;
|
|
68
68
|
}
|
|
69
69
|
const G = {
|
|
70
|
-
decompose:
|
|
71
|
-
dividers:
|
|
72
|
-
divideNumbersByGCD:
|
|
73
|
-
gcd:
|
|
74
|
-
lcm:
|
|
75
|
-
numberCorrection:
|
|
76
|
-
periodic:
|
|
77
|
-
primes:
|
|
78
|
-
pythagoreanTripletsWithTarget:
|
|
79
|
-
round:
|
|
70
|
+
decompose: $i,
|
|
71
|
+
dividers: ui,
|
|
72
|
+
divideNumbersByGCD: Ii,
|
|
73
|
+
gcd: ni,
|
|
74
|
+
lcm: Bi,
|
|
75
|
+
numberCorrection: Si,
|
|
76
|
+
periodic: Pi,
|
|
77
|
+
primes: Ri,
|
|
78
|
+
pythagoreanTripletsWithTarget: zi,
|
|
79
|
+
round: Li
|
|
80
80
|
};
|
|
81
|
-
var w, b,
|
|
81
|
+
var w, b, ht, Pe;
|
|
82
82
|
const $ = class $ {
|
|
83
83
|
constructor(e, t) {
|
|
84
84
|
// #region Class fields (2)
|
|
85
85
|
d(this, w, 1);
|
|
86
86
|
d(this, b, 1);
|
|
87
|
-
d(this,
|
|
88
|
-
d(this,
|
|
87
|
+
d(this, ht, !1);
|
|
88
|
+
d(this, Pe, "frac");
|
|
89
89
|
// ------------------------------------------
|
|
90
90
|
/**
|
|
91
91
|
* Parse the value to get the numerator and denominator
|
|
@@ -100,7 +100,7 @@ const $ = class $ {
|
|
|
100
100
|
case "string":
|
|
101
101
|
if (s = e.split("/"), s.length > 2)
|
|
102
102
|
throw new Error(`The given value is not a valid fraction (${e})`);
|
|
103
|
-
if (s.map((
|
|
103
|
+
if (s.map((n) => n === "" || isNaN(Number(n))).includes(!0))
|
|
104
104
|
throw new Error(`The given value is not a valid fraction (${e})`);
|
|
105
105
|
if (s.length === 1)
|
|
106
106
|
return this.parse(+s[0]);
|
|
@@ -110,8 +110,8 @@ const $ = class $ {
|
|
|
110
110
|
if (Number.isSafeInteger(e))
|
|
111
111
|
h(this, w, +e), t === void 0 || !Number.isSafeInteger(t) ? h(this, b, 1) : h(this, b, +t);
|
|
112
112
|
else {
|
|
113
|
-
const [,
|
|
114
|
-
t === void 0 ? (h(this, w, e * Math.pow(10,
|
|
113
|
+
const [, n] = e.toString().split("."), r = n ? n.length : 0;
|
|
114
|
+
t === void 0 ? (h(this, w, e * Math.pow(10, r)), h(this, b, Math.pow(10, r))) : Number.isSafeInteger(t) && (h(this, w, e * Math.pow(10, r) - Math.floor(e * Math.pow(10, r - t))), this.denominator = Math.pow(10, r) - Math.pow(10, r - t)), this.reduce();
|
|
115
115
|
}
|
|
116
116
|
break;
|
|
117
117
|
case "object":
|
|
@@ -175,8 +175,8 @@ const $ = class $ {
|
|
|
175
175
|
const t = new $(e);
|
|
176
176
|
if (t.numerator === 0)
|
|
177
177
|
return new $().infinite();
|
|
178
|
-
const s = +i(this, w),
|
|
179
|
-
return h(this, w, s * t.denominator), h(this, b,
|
|
178
|
+
const s = +i(this, w), n = +i(this, b);
|
|
179
|
+
return h(this, w, s * t.denominator), h(this, b, n * t.numerator), this.reduce();
|
|
180
180
|
});
|
|
181
181
|
a(this, "infinite", () => (h(this, w, 1 / 0), h(this, b, 1), this));
|
|
182
182
|
a(this, "invalid", () => (h(this, w, NaN), h(this, b, 1), this));
|
|
@@ -184,7 +184,7 @@ const $ = class $ {
|
|
|
184
184
|
const e = +i(this, w);
|
|
185
185
|
return h(this, w, +i(this, b)), h(this, b, e), this;
|
|
186
186
|
});
|
|
187
|
-
a(this, "isApproximative", () => i(this,
|
|
187
|
+
a(this, "isApproximative", () => i(this, ht) || i(this, w).toString().length >= 15 && i(this, b).toString().length >= 15);
|
|
188
188
|
a(this, "isEqual", (e) => this.compare(e, "="));
|
|
189
189
|
a(this, "isEven", () => this.isRelative() && this.value % 2 === 0);
|
|
190
190
|
a(this, "isExact", () => !this.isApproximative());
|
|
@@ -242,8 +242,8 @@ const $ = class $ {
|
|
|
242
242
|
throw new Error("The root of a negative number must be odd.");
|
|
243
243
|
const t = this.sign();
|
|
244
244
|
this.abs(), this.reduce();
|
|
245
|
-
const s = Math.floor(Math.pow(i(this, w), Math.abs(1 / e))),
|
|
246
|
-
return h(this, w, Math.pow(i(this, w), Math.abs(1 / e))), h(this, b, Math.pow(i(this, b), Math.abs(1 / e))), (s !== i(this, w) ||
|
|
245
|
+
const s = Math.floor(Math.pow(i(this, w), Math.abs(1 / e))), n = Math.floor(Math.pow(i(this, b), Math.abs(1 / e)));
|
|
246
|
+
return h(this, w, Math.pow(i(this, w), Math.abs(1 / e))), h(this, b, Math.pow(i(this, b), Math.abs(1 / e))), (s !== i(this, w) || n !== i(this, b)) && (h(this, w, i(this, w) / i(this, b)), h(this, b, 1), h(this, ht, !0)), this.multiply(t), this;
|
|
247
247
|
});
|
|
248
248
|
a(this, "sign", () => i(this, w) * i(this, b) >= 0 ? 1 : -1);
|
|
249
249
|
a(this, "sqrt", () => this.root(2));
|
|
@@ -272,17 +272,17 @@ const $ = class $ {
|
|
|
272
272
|
h(this, w, e);
|
|
273
273
|
}
|
|
274
274
|
get tfrac() {
|
|
275
|
-
return h(this,
|
|
275
|
+
return h(this, Pe, "tfrac"), this;
|
|
276
276
|
}
|
|
277
277
|
get dfrac() {
|
|
278
|
-
return h(this,
|
|
278
|
+
return h(this, Pe, "dfrac"), this;
|
|
279
279
|
}
|
|
280
280
|
get frac() {
|
|
281
|
-
return h(this,
|
|
281
|
+
return h(this, Pe, "frac"), this;
|
|
282
282
|
}
|
|
283
283
|
// Display getter
|
|
284
284
|
get tex() {
|
|
285
|
-
return this.isInfinity() ? `${this.sign() === 1 ? "+" : "-"}\\infty` : this.isExact() ? i(this, b) === 1 ? `${i(this, w)}` : i(this, w) < 0 ? `-\\${i(this,
|
|
285
|
+
return this.isInfinity() ? `${this.sign() === 1 ? "+" : "-"}\\infty` : this.isExact() ? i(this, b) === 1 ? `${i(this, w)}` : i(this, w) < 0 ? `-\\${i(this, Pe)}{ ${-i(this, w)} }{ ${i(this, b)} }` : `\\${i(this, Pe)}{ ${i(this, w)} }{ ${i(this, b)} }` : this.value.toFixed(3);
|
|
286
286
|
}
|
|
287
287
|
get texWithSign() {
|
|
288
288
|
return this.isPositive() ? `+${this.tex}` : this.tex;
|
|
@@ -292,7 +292,7 @@ const $ = class $ {
|
|
|
292
292
|
}
|
|
293
293
|
// #endregion Getters And Setters (11)
|
|
294
294
|
};
|
|
295
|
-
w = new WeakMap(), b = new WeakMap(),
|
|
295
|
+
w = new WeakMap(), b = new WeakMap(), ht = new WeakMap(), Pe = new WeakMap(), a($, "average", (...e) => {
|
|
296
296
|
const t = new $().zero();
|
|
297
297
|
for (const s of e)
|
|
298
298
|
t.add(s);
|
|
@@ -300,74 +300,74 @@ w = new WeakMap(), b = new WeakMap(), ot = new WeakMap(), Be = new WeakMap(), a(
|
|
|
300
300
|
}), a($, "max", (...e) => {
|
|
301
301
|
let t = new $(e[0]);
|
|
302
302
|
for (const s of e) {
|
|
303
|
-
const
|
|
304
|
-
|
|
303
|
+
const n = new $(s);
|
|
304
|
+
n.isGreater(t) && (t = n.clone());
|
|
305
305
|
}
|
|
306
306
|
return t;
|
|
307
307
|
}), a($, "min", (...e) => {
|
|
308
308
|
let t = new $(e[0]);
|
|
309
309
|
for (const s of e) {
|
|
310
|
-
const
|
|
311
|
-
|
|
310
|
+
const n = new $(s);
|
|
311
|
+
n.isLesser(t) && (t = n.clone());
|
|
312
312
|
}
|
|
313
313
|
return t;
|
|
314
314
|
}), a($, "sort", (e, t) => {
|
|
315
|
-
const
|
|
316
|
-
return t &&
|
|
315
|
+
const n = e.map((r) => r instanceof $ ? r : new $(r)).sort((r, l) => r.value - l.value);
|
|
316
|
+
return t && n.reverse(), n;
|
|
317
317
|
}), a($, "unique", (e) => {
|
|
318
318
|
const t = {}, s = [];
|
|
319
|
-
return e.forEach((
|
|
320
|
-
|
|
319
|
+
return e.forEach((n) => {
|
|
320
|
+
n instanceof $ || (n = new $(n)), t[n.clone().reduce().tex] || (s.push(n.clone()), t[n.tex] = !0);
|
|
321
321
|
}), s;
|
|
322
322
|
}), a($, "xMultiply", (...e) => {
|
|
323
323
|
const t = new $();
|
|
324
324
|
for (const s of e) {
|
|
325
|
-
const
|
|
326
|
-
t.numerator = t.numerator *
|
|
325
|
+
const n = new $(s);
|
|
326
|
+
t.numerator = t.numerator * n.numerator, t.denominator = t.denominator * n.denominator;
|
|
327
327
|
}
|
|
328
328
|
return t;
|
|
329
329
|
});
|
|
330
330
|
let c = $;
|
|
331
|
-
var
|
|
332
|
-
class
|
|
331
|
+
var V, J, se, Xe;
|
|
332
|
+
class pt {
|
|
333
333
|
constructor(...e) {
|
|
334
|
-
d(this,
|
|
334
|
+
d(this, V);
|
|
335
335
|
d(this, J);
|
|
336
336
|
d(this, se);
|
|
337
|
-
d(this,
|
|
337
|
+
d(this, Xe);
|
|
338
338
|
// ------------------------------------------
|
|
339
339
|
// Creation / parsing functions
|
|
340
340
|
// ------------------------------------------
|
|
341
|
-
a(this, "parse", (e, t, s) => (h(this, se, s ?? 1), h(this, J, t ?? 2), h(this,
|
|
341
|
+
a(this, "parse", (e, t, s) => (h(this, se, s ?? 1), h(this, J, t ?? 2), h(this, V, e), i(this, J) % 2 === 0 && i(this, V) < 0 && h(this, Xe, !1), this));
|
|
342
342
|
// ------------------------------------------
|
|
343
343
|
// Mathematical operations
|
|
344
344
|
// ------------------------------------------
|
|
345
345
|
a(this, "reduce", () => {
|
|
346
|
-
let e = Math.floor(Math.pow(i(this,
|
|
346
|
+
let e = Math.floor(Math.pow(i(this, V), 1 / i(this, J)));
|
|
347
347
|
for (; e > 1; ) {
|
|
348
|
-
if (i(this,
|
|
349
|
-
h(this, se, i(this, se) * e), h(this,
|
|
348
|
+
if (i(this, V) % Math.pow(e, i(this, J)) === 0) {
|
|
349
|
+
h(this, se, i(this, se) * e), h(this, V, i(this, V) / Math.pow(e, i(this, J))), e = Math.floor(Math.pow(i(this, V), 1 / i(this, J)));
|
|
350
350
|
continue;
|
|
351
351
|
}
|
|
352
352
|
e--;
|
|
353
353
|
}
|
|
354
354
|
return this;
|
|
355
355
|
});
|
|
356
|
-
a(this, "multiply", (e) => (h(this,
|
|
356
|
+
a(this, "multiply", (e) => (h(this, V, i(this, V) * e.radical), this.reduce()));
|
|
357
357
|
// ------------------------------------------
|
|
358
358
|
// Help functions
|
|
359
359
|
// ------------------------------------------
|
|
360
|
-
a(this, "hasRadical", () => !(i(this,
|
|
361
|
-
h(this,
|
|
360
|
+
a(this, "hasRadical", () => !(i(this, V) === 1 || i(this, V) === 0 || !i(this, Xe)));
|
|
361
|
+
h(this, V, 1), h(this, se, 1), h(this, J, 2), h(this, Xe, !0), e.length > 0 && this.parse(e[0], e[1], e[2]);
|
|
362
362
|
}
|
|
363
363
|
// ------------------------------------------
|
|
364
364
|
// Getter and setter
|
|
365
365
|
// ------------------------------------------
|
|
366
366
|
get radical() {
|
|
367
|
-
return i(this,
|
|
367
|
+
return i(this, V);
|
|
368
368
|
}
|
|
369
369
|
set radical(e) {
|
|
370
|
-
h(this,
|
|
370
|
+
h(this, V, e);
|
|
371
371
|
}
|
|
372
372
|
get nth() {
|
|
373
373
|
return i(this, J);
|
|
@@ -383,127 +383,127 @@ class ft {
|
|
|
383
383
|
}
|
|
384
384
|
get tex() {
|
|
385
385
|
let e;
|
|
386
|
-
return i(this, se) === 1 ? e = "" : i(this, se) === -1 ? e = "-" : e = i(this, se).toString(), i(this,
|
|
386
|
+
return i(this, se) === 1 ? e = "" : i(this, se) === -1 ? e = "-" : e = i(this, se).toString(), i(this, V) === 1 ? `${i(this, se)}` : i(this, J) === 2 ? `${e}\\sqrt{${i(this, V)}}` : `${e}\\sqrt[${i(this, J)}]{${i(this, V)}}`;
|
|
387
387
|
}
|
|
388
388
|
get display() {
|
|
389
389
|
let e;
|
|
390
|
-
return i(this, se) === 1 ? e = "" : i(this, se) === -1 ? e = "-" : e = i(this, se).toString(), i(this,
|
|
390
|
+
return i(this, se) === 1 ? e = "" : i(this, se) === -1 ? e = "-" : e = i(this, se).toString(), i(this, V) === 1 ? `${i(this, se)}` : i(this, J) === 2 ? `${e}sqrt{${i(this, V)}}` : `${e}root(${i(this, J)}){${i(this, V)}}`;
|
|
391
391
|
}
|
|
392
392
|
get value() {
|
|
393
|
-
return i(this, se) * Math.pow(i(this,
|
|
393
|
+
return i(this, se) * Math.pow(i(this, V), 1 / i(this, J));
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
|
-
|
|
397
|
-
var
|
|
396
|
+
V = new WeakMap(), J = new WeakMap(), se = new WeakMap(), Xe = new WeakMap();
|
|
397
|
+
var Di = Object.defineProperty, fi = (o) => {
|
|
398
398
|
throw TypeError(o);
|
|
399
|
-
},
|
|
400
|
-
const
|
|
399
|
+
}, Vi = (o, e, t) => e in o ? Di(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, Xt = (o, e, t) => Vi(o, typeof e != "symbol" ? e + "" : e, t), di = (o, e, t) => e.has(o) || fi("Cannot " + t), K = (o, e, t) => (di(o, e, "read from private field"), t ? t.call(o) : e.get(o)), st = (o, e, t) => e.has(o) ? fi("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), be = (o, e, t, s) => (di(o, e, "write to private field"), e.set(o, t), t);
|
|
400
|
+
const ri = {
|
|
401
401
|
pi: Math.PI,
|
|
402
402
|
e: Math.exp(1)
|
|
403
403
|
};
|
|
404
|
-
var
|
|
405
|
-
function
|
|
404
|
+
var p = /* @__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))(p || {}), Ve = /* @__PURE__ */ ((o) => (o.EXPRESSION = "expression", o.POLYNOM = "polynom", o.SET = "set", o.NUMERIC = "numeric", o))(Ve || {});
|
|
405
|
+
function Zi(o, e) {
|
|
406
406
|
if (o.length <= 1)
|
|
407
407
|
return o;
|
|
408
|
-
const t = Object.keys(e).filter((E) => e[E].type ===
|
|
408
|
+
const t = Object.keys(e).filter((E) => e[E].type === p.FUNCTION).map((E) => E);
|
|
409
409
|
t.sort((E, L) => L.length - E.length);
|
|
410
|
-
const s = new RegExp(`^(${t.join("|")})\\(`),
|
|
411
|
-
|
|
412
|
-
const
|
|
413
|
-
let u = "", f,
|
|
410
|
+
const s = new RegExp(`^(${t.join("|")})\\(`), n = Object.keys(ri);
|
|
411
|
+
n.sort((E, L) => L.length - E.length);
|
|
412
|
+
const r = new RegExp(`^(${n.join("|")})`), l = /^(\d+(\.\d+)?)/;
|
|
413
|
+
let u = "", f, m, g;
|
|
414
414
|
for (; o.length > 0; ) {
|
|
415
|
-
if (f =
|
|
415
|
+
if (f = m, g = void 0, t.length > 0 && s.exec(o)) {
|
|
416
416
|
const E = t.find((L) => o.startsWith(L));
|
|
417
|
-
E && (g = E + "(", o = o.slice(E.length + 1),
|
|
418
|
-
} else if (
|
|
419
|
-
const E =
|
|
420
|
-
E && (g = E, o = o.slice(E.length),
|
|
417
|
+
E && (g = E + "(", o = o.slice(E.length + 1), m = p.FUNCTION);
|
|
418
|
+
} else if (n.length > 0 && r.exec(o)) {
|
|
419
|
+
const E = n.find((L) => o.startsWith(L));
|
|
420
|
+
E && (g = E, o = o.slice(E.length), m = p.CONSTANT);
|
|
421
421
|
} else if (l.exec(o)) {
|
|
422
422
|
const E = l.exec(o);
|
|
423
|
-
E && (g = E[0], o = o.slice(E[0].length),
|
|
423
|
+
E && (g = E[0], o = o.slice(E[0].length), m = p.COEFFICIENT);
|
|
424
424
|
} else
|
|
425
425
|
switch (g = o[0], o = o.slice(1), g) {
|
|
426
426
|
case "(":
|
|
427
|
-
|
|
427
|
+
m = p.LEFT_PARENTHESIS;
|
|
428
428
|
break;
|
|
429
429
|
case ")":
|
|
430
|
-
|
|
430
|
+
m = p.RIGHT_PARENTHESIS;
|
|
431
431
|
break;
|
|
432
432
|
case ",":
|
|
433
|
-
|
|
433
|
+
m = p.FUNCTION_ARGUMENT;
|
|
434
434
|
break;
|
|
435
435
|
case "+":
|
|
436
436
|
case "-":
|
|
437
437
|
case "*":
|
|
438
438
|
case "/":
|
|
439
439
|
case "^":
|
|
440
|
-
|
|
440
|
+
m = p.OPERATION;
|
|
441
441
|
break;
|
|
442
442
|
default:
|
|
443
|
-
|
|
443
|
+
m = p.VARIABLE;
|
|
444
444
|
}
|
|
445
|
-
if (g === void 0 ||
|
|
445
|
+
if (g === void 0 || m === void 0)
|
|
446
446
|
throw new Error("The token is undefined");
|
|
447
|
-
u +=
|
|
447
|
+
u += Fi(f, m), u += g;
|
|
448
448
|
}
|
|
449
449
|
return u;
|
|
450
450
|
}
|
|
451
|
-
function
|
|
452
|
-
return o === void 0 || o ===
|
|
451
|
+
function Fi(o, e) {
|
|
452
|
+
return o === void 0 || o === p.OPERATION || e === p.OPERATION || o === p.LEFT_PARENTHESIS || o === p.FUNCTION || o === p.FUNCTION_ARGUMENT || e === p.RIGHT_PARENTHESIS || e === p.FUNCTION_ARGUMENT ? "" : "*";
|
|
453
453
|
}
|
|
454
|
-
const
|
|
455
|
-
"^": { precedence: 4, associative: "right", type:
|
|
456
|
-
"*": { precedence: 3, associative: "left", type:
|
|
457
|
-
"/": { precedence: 3, associative: "left", type:
|
|
458
|
-
"+": { precedence: 2, associative: "left", type:
|
|
459
|
-
"-": { precedence: 2, associative: "left", type:
|
|
460
|
-
},
|
|
461
|
-
"^": { precedence: 4, associative: "right", type:
|
|
462
|
-
"*": { precedence: 3, associative: "left", type:
|
|
463
|
-
"/": { precedence: 3, associative: "left", type:
|
|
464
|
-
"+": { precedence: 2, associative: "left", type:
|
|
465
|
-
"-": { precedence: 2, associative: "left", type:
|
|
466
|
-
"%": { precedence: 3, associative: "right", type:
|
|
467
|
-
sin: { precedence: 4, associative: "right", type:
|
|
468
|
-
cos: { precedence: 4, associative: "right", type:
|
|
469
|
-
tan: { precedence: 4, associative: "right", type:
|
|
470
|
-
sqrt: { precedence: 4, associative: "right", type:
|
|
471
|
-
nthrt: { precedence: 4, associative: "right", type:
|
|
472
|
-
",": { precedence: 2, associative: "left", type:
|
|
473
|
-
},
|
|
474
|
-
"^": { precedence: 4, associative: "right", type:
|
|
475
|
-
"*": { precedence: 3, associative: "left", type:
|
|
476
|
-
"/": { precedence: 3, associative: "left", type:
|
|
477
|
-
"+": { precedence: 2, associative: "left", type:
|
|
478
|
-
"-": { precedence: 2, associative: "left", type:
|
|
479
|
-
"%": { precedence: 3, associative: "right", type:
|
|
480
|
-
sin: { precedence: 4, associative: "right", type:
|
|
481
|
-
cos: { precedence: 4, associative: "right", type:
|
|
482
|
-
tan: { precedence: 4, associative: "right", type:
|
|
483
|
-
sqrt: { precedence: 4, associative: "right", type:
|
|
484
|
-
nthrt: { precedence: 4, associative: "right", type:
|
|
485
|
-
ln: { precedence: 4, associative: "right", type:
|
|
486
|
-
log: { precedence: 4, associative: "right", type:
|
|
487
|
-
},
|
|
488
|
-
"&": { precedence: 3, associative: "left", type:
|
|
489
|
-
"|": { precedence: 3, associative: "left", type:
|
|
490
|
-
"!": { precedence: 4, associative: "right", type:
|
|
491
|
-
"-": { precedence: 2, associative: "left", type:
|
|
454
|
+
const ji = {
|
|
455
|
+
"^": { precedence: 4, associative: "right", type: p.OPERATION },
|
|
456
|
+
"*": { precedence: 3, associative: "left", type: p.OPERATION },
|
|
457
|
+
"/": { precedence: 3, associative: "left", type: p.OPERATION },
|
|
458
|
+
"+": { precedence: 2, associative: "left", type: p.OPERATION },
|
|
459
|
+
"-": { precedence: 2, associative: "left", type: p.OPERATION }
|
|
460
|
+
}, Ui = {
|
|
461
|
+
"^": { precedence: 4, associative: "right", type: p.OPERATION },
|
|
462
|
+
"*": { precedence: 3, associative: "left", type: p.OPERATION },
|
|
463
|
+
"/": { precedence: 3, associative: "left", type: p.OPERATION },
|
|
464
|
+
"+": { precedence: 2, associative: "left", type: p.OPERATION },
|
|
465
|
+
"-": { precedence: 2, associative: "left", type: p.OPERATION },
|
|
466
|
+
"%": { precedence: 3, associative: "right", type: p.OPERATION },
|
|
467
|
+
sin: { precedence: 4, associative: "right", type: p.FUNCTION },
|
|
468
|
+
cos: { precedence: 4, associative: "right", type: p.FUNCTION },
|
|
469
|
+
tan: { precedence: 4, associative: "right", type: p.FUNCTION },
|
|
470
|
+
sqrt: { precedence: 4, associative: "right", type: p.FUNCTION },
|
|
471
|
+
nthrt: { precedence: 4, associative: "right", type: p.FUNCTION },
|
|
472
|
+
",": { precedence: 2, associative: "left", type: p.FUNCTION_ARGUMENT }
|
|
473
|
+
}, Gi = {
|
|
474
|
+
"^": { precedence: 4, associative: "right", type: p.OPERATION },
|
|
475
|
+
"*": { precedence: 3, associative: "left", type: p.OPERATION },
|
|
476
|
+
"/": { precedence: 3, associative: "left", type: p.OPERATION },
|
|
477
|
+
"+": { precedence: 2, associative: "left", type: p.OPERATION },
|
|
478
|
+
"-": { precedence: 2, associative: "left", type: p.OPERATION },
|
|
479
|
+
"%": { precedence: 3, associative: "right", type: p.OPERATION },
|
|
480
|
+
sin: { precedence: 4, associative: "right", type: p.FUNCTION },
|
|
481
|
+
cos: { precedence: 4, associative: "right", type: p.FUNCTION },
|
|
482
|
+
tan: { precedence: 4, associative: "right", type: p.FUNCTION },
|
|
483
|
+
sqrt: { precedence: 4, associative: "right", type: p.FUNCTION },
|
|
484
|
+
nthrt: { precedence: 4, associative: "right", type: p.FUNCTION },
|
|
485
|
+
ln: { precedence: 4, associative: "right", type: p.FUNCTION },
|
|
486
|
+
log: { precedence: 4, associative: "right", type: p.FUNCTION }
|
|
487
|
+
}, Wi = {
|
|
488
|
+
"&": { precedence: 3, associative: "left", type: p.OPERATION },
|
|
489
|
+
"|": { precedence: 3, associative: "left", type: p.OPERATION },
|
|
490
|
+
"!": { precedence: 4, associative: "right", type: p.OPERATION },
|
|
491
|
+
"-": { precedence: 2, associative: "left", type: p.OPERATION }
|
|
492
492
|
};
|
|
493
|
-
var
|
|
494
|
-
class
|
|
493
|
+
var Ge, nt, ie, mt, Le;
|
|
494
|
+
class Gt {
|
|
495
495
|
constructor(e) {
|
|
496
|
-
|
|
496
|
+
st(this, Ge), st(this, nt, []), st(this, ie, {}), st(this, mt, []), st(this, Le), be(this, Ge, typeof e > "u" ? Ve.POLYNOM : e), this.tokenConfigInitialization();
|
|
497
497
|
}
|
|
498
498
|
// Getter
|
|
499
499
|
get rpn() {
|
|
500
|
-
return K(this,
|
|
500
|
+
return K(this, nt);
|
|
501
501
|
}
|
|
502
502
|
get rpnToken() {
|
|
503
|
-
return K(this,
|
|
503
|
+
return K(this, nt).map((e) => e.token);
|
|
504
504
|
}
|
|
505
505
|
tokenConfigInitialization() {
|
|
506
|
-
return K(this,
|
|
506
|
+
return K(this, Ge) === Ve.SET ? (be(this, ie, Wi), be(this, Le, !1)) : K(this, Ge) === Ve.NUMERIC ? (be(this, ie, Gi), be(this, Le, !0)) : K(this, Ge) === Ve.EXPRESSION ? (be(this, ie, Ui), be(this, Le, !0)) : (be(this, ie, ji), be(this, Le, !0)), be(this, mt, Object.keys(K(this, ie)).sort((e, t) => t.length - e.length)), K(this, ie);
|
|
507
507
|
}
|
|
508
508
|
/**
|
|
509
509
|
* Get the next token to analyse.
|
|
@@ -511,37 +511,37 @@ class li {
|
|
|
511
511
|
* @param start (number) CUrrent position in the expr string.
|
|
512
512
|
*/
|
|
513
513
|
NextToken(e, t) {
|
|
514
|
-
let s,
|
|
515
|
-
if (s = "",
|
|
516
|
-
s = "(",
|
|
514
|
+
let s, n;
|
|
515
|
+
if (s = "", n = void 0, e[t] === "(")
|
|
516
|
+
s = "(", n = p.LEFT_PARENTHESIS;
|
|
517
517
|
else if (e[t] === ")")
|
|
518
|
-
s = ")",
|
|
518
|
+
s = ")", n = p.RIGHT_PARENTHESIS;
|
|
519
519
|
else if (e[t] === ",")
|
|
520
|
-
s = ",",
|
|
520
|
+
s = ",", n = p.FUNCTION_ARGUMENT;
|
|
521
521
|
else {
|
|
522
|
-
for (const
|
|
523
|
-
if (e.substring(t, t +
|
|
524
|
-
s +=
|
|
522
|
+
for (const r of K(this, mt))
|
|
523
|
+
if (e.substring(t, t + r.length) === r) {
|
|
524
|
+
s += r, n = K(this, ie)[r].type;
|
|
525
525
|
break;
|
|
526
526
|
}
|
|
527
|
-
for (const
|
|
528
|
-
if (e.substring(t, t +
|
|
529
|
-
s +=
|
|
527
|
+
for (const r in ri)
|
|
528
|
+
if (e.substring(t, t + r.length) === r) {
|
|
529
|
+
s += r, n = p.CONSTANT;
|
|
530
530
|
break;
|
|
531
531
|
}
|
|
532
532
|
if (s === "")
|
|
533
533
|
if (/[0-9.]/.exec(e[t])) {
|
|
534
|
-
const
|
|
535
|
-
s =
|
|
534
|
+
const r = /^([0-9.]+)/.exec(e.substring(t));
|
|
535
|
+
s = r ? r[0] : "", n = p.COEFFICIENT;
|
|
536
536
|
} else if (/[a-zA-Z]/.exec(e[t])) {
|
|
537
|
-
const
|
|
538
|
-
s =
|
|
537
|
+
const r = /^([a-zA-Z])/.exec(e.substring(t));
|
|
538
|
+
s = r ? r[0] : "", n = p.VARIABLE;
|
|
539
539
|
} else
|
|
540
|
-
console.log("Unidentified token", e[t], e, t), s = e[t],
|
|
540
|
+
console.log("Unidentified token", e[t], e, t), s = e[t], n = p.MONOM;
|
|
541
541
|
}
|
|
542
|
-
if (
|
|
542
|
+
if (n === void 0)
|
|
543
543
|
throw new Error(`Token type is undefined for token ${s}`);
|
|
544
|
-
return [s, t + s.length,
|
|
544
|
+
return [s, t + s.length, n];
|
|
545
545
|
}
|
|
546
546
|
/**
|
|
547
547
|
* Parse an expression using the shutting yard tree algorithms
|
|
@@ -550,88 +550,188 @@ class li {
|
|
|
550
550
|
* @param uniformize
|
|
551
551
|
*/
|
|
552
552
|
parse(e, t) {
|
|
553
|
-
const s = [],
|
|
554
|
-
let
|
|
555
|
-
(t ?? K(this,
|
|
553
|
+
const s = [], n = [];
|
|
554
|
+
let r = "", l = 0, u;
|
|
555
|
+
(t ?? K(this, Le)) && (e = Zi(e, K(this, ie)));
|
|
556
556
|
const f = 50;
|
|
557
|
-
let
|
|
557
|
+
let m = 50, g;
|
|
558
558
|
for (; l < e.length; ) {
|
|
559
|
-
if (
|
|
559
|
+
if (m--, m === 0) {
|
|
560
560
|
console.log("SECURITY LEVEL 1 EXIT");
|
|
561
561
|
break;
|
|
562
562
|
}
|
|
563
|
-
switch ([
|
|
564
|
-
case
|
|
565
|
-
case
|
|
566
|
-
case
|
|
567
|
-
case
|
|
563
|
+
switch ([r, l, u] = this.NextToken(e, l), u) {
|
|
564
|
+
case p.MONOM:
|
|
565
|
+
case p.COEFFICIENT:
|
|
566
|
+
case p.VARIABLE:
|
|
567
|
+
case p.CONSTANT:
|
|
568
568
|
s.push({
|
|
569
|
-
token:
|
|
569
|
+
token: r,
|
|
570
570
|
tokenType: u
|
|
571
571
|
});
|
|
572
572
|
break;
|
|
573
|
-
case
|
|
574
|
-
if (
|
|
575
|
-
let E =
|
|
573
|
+
case p.OPERATION:
|
|
574
|
+
if (n.length > 0) {
|
|
575
|
+
let E = n[n.length - 1];
|
|
576
576
|
for (g = +f; E.token in K(this, ie) && //either o1 is left-associative and its precedence is less than or equal to that of o2,
|
|
577
|
-
(K(this, ie)[
|
|
578
|
-
K(this, ie)[
|
|
577
|
+
(K(this, ie)[r].associative === "left" && K(this, ie)[r].precedence <= K(this, ie)[E.token].precedence || //or o1 is right associative, and has precedence less than that of o2,
|
|
578
|
+
K(this, ie)[r].associative === "right" && K(this, ie)[r].precedence < K(this, ie)[E.token].precedence); ) {
|
|
579
579
|
if (g--, g === 0) {
|
|
580
580
|
console.log("SECURITY LEVEL 2 OPERATION EXIT");
|
|
581
581
|
break;
|
|
582
582
|
}
|
|
583
|
-
if (s.push(
|
|
583
|
+
if (s.push(n.pop() ?? { token: "", tokenType: p.OPERATION }), n.length === 0)
|
|
584
584
|
break;
|
|
585
|
-
E =
|
|
585
|
+
E = n[n.length - 1];
|
|
586
586
|
}
|
|
587
587
|
}
|
|
588
|
-
|
|
588
|
+
n.push({ token: r, tokenType: u });
|
|
589
589
|
break;
|
|
590
|
-
case
|
|
591
|
-
for (g = +f;
|
|
590
|
+
case p.FUNCTION_ARGUMENT:
|
|
591
|
+
for (g = +f; n[n.length - 1].token !== "(" && n.length > 0; ) {
|
|
592
592
|
if (g--, g === 0) {
|
|
593
593
|
console.log("SECURITY LEVEL 2 FUNCTION ARGUMENT EXIT");
|
|
594
594
|
break;
|
|
595
595
|
}
|
|
596
|
-
s.push(
|
|
596
|
+
s.push(n.pop() ?? { token: r, tokenType: u });
|
|
597
597
|
}
|
|
598
598
|
break;
|
|
599
|
-
case
|
|
600
|
-
|
|
599
|
+
case p.LEFT_PARENTHESIS:
|
|
600
|
+
n.push({ token: r, tokenType: u }), e[l] === "-" && s.push({ token: "0", tokenType: p.COEFFICIENT });
|
|
601
601
|
break;
|
|
602
|
-
case
|
|
603
|
-
for (g = +f;
|
|
602
|
+
case p.RIGHT_PARENTHESIS:
|
|
603
|
+
for (g = +f; n[n.length - 1].token !== "(" && n.length > 1; ) {
|
|
604
604
|
if (g--, g === 0) {
|
|
605
605
|
console.log("SECURITY LEVEL 2 CLOSING PARENTHESIS EXIT");
|
|
606
606
|
break;
|
|
607
607
|
}
|
|
608
|
-
s.push(
|
|
608
|
+
s.push(n.pop() ?? { token: r, tokenType: u });
|
|
609
609
|
}
|
|
610
|
-
|
|
610
|
+
n.pop();
|
|
611
611
|
break;
|
|
612
|
-
case
|
|
613
|
-
|
|
612
|
+
case p.FUNCTION:
|
|
613
|
+
n.push({ token: r, tokenType: u });
|
|
614
614
|
break;
|
|
615
615
|
default:
|
|
616
|
-
throw new Error(`Token type ${
|
|
616
|
+
throw new Error(`Token type ${r} is not handled`);
|
|
617
617
|
}
|
|
618
618
|
}
|
|
619
|
-
return be(this,
|
|
619
|
+
return be(this, nt, s.concat(n.reverse())), this;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
Ge = /* @__PURE__ */ new WeakMap(), nt = /* @__PURE__ */ new WeakMap(), ie = /* @__PURE__ */ new WeakMap(), mt = /* @__PURE__ */ new WeakMap(), Le = /* @__PURE__ */ new WeakMap();
|
|
623
|
+
class Hi {
|
|
624
|
+
constructor(e, t) {
|
|
625
|
+
Xt(this, "_rpn"), Xt(this, "_expression"), Xt(this, "_isValid"), this._expression = e;
|
|
626
|
+
try {
|
|
627
|
+
this._rpn = new Gt(Ve.NUMERIC).parse(e, t).rpn;
|
|
628
|
+
} catch {
|
|
629
|
+
throw this._rpn = null, this._isValid = !1, new Error(`There was a problem parsing: ${e}`);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
get rpn() {
|
|
633
|
+
return this._rpn ?? [];
|
|
634
|
+
}
|
|
635
|
+
get isValid() {
|
|
636
|
+
if (this._isValid === void 0)
|
|
637
|
+
try {
|
|
638
|
+
this.evaluate({ x: 2 });
|
|
639
|
+
} catch {
|
|
640
|
+
this._isValid = !1;
|
|
641
|
+
}
|
|
642
|
+
return this._isValid ?? !1;
|
|
643
|
+
}
|
|
644
|
+
set isValid(e) {
|
|
645
|
+
this._isValid = e;
|
|
646
|
+
}
|
|
647
|
+
get expression() {
|
|
648
|
+
return this._expression;
|
|
649
|
+
}
|
|
650
|
+
evaluate(e) {
|
|
651
|
+
const t = [];
|
|
652
|
+
if (this._rpn === null)
|
|
653
|
+
return this._isValid = !1, 0;
|
|
654
|
+
this._isValid = !0;
|
|
655
|
+
for (const s of this._rpn)
|
|
656
|
+
if (s.tokenType === p.COEFFICIENT)
|
|
657
|
+
if (!isNaN(+s.token))
|
|
658
|
+
t.push(+s.token);
|
|
659
|
+
else {
|
|
660
|
+
const n = s.token.split("/");
|
|
661
|
+
if (n.length !== 2)
|
|
662
|
+
throw this._isValid = !1, new Error("This coefficient is not a fraction");
|
|
663
|
+
t.push(+n[0] / +n[1]);
|
|
664
|
+
}
|
|
665
|
+
else if (s.tokenType === p.VARIABLE && e !== void 0)
|
|
666
|
+
Object.hasOwn(e, s.token) && t.push(+e[s.token]);
|
|
667
|
+
else if (s.tokenType === p.CONSTANT)
|
|
668
|
+
t.push(ri[s.token]);
|
|
669
|
+
else if (s.tokenType === p.OPERATION) {
|
|
670
|
+
if (s.token === "*") {
|
|
671
|
+
const n = t.pop(), r = t.pop();
|
|
672
|
+
if (r === void 0 || n === void 0)
|
|
673
|
+
throw this._isValid = !1, new Error(`The multiplication factors ${r ?? "a"} or ${n ?? "b"} are not defined`);
|
|
674
|
+
t.push(r * n);
|
|
675
|
+
} else if (s.token === "/") {
|
|
676
|
+
const n = t.pop(), r = t.pop();
|
|
677
|
+
if (r === void 0 || n === void 0)
|
|
678
|
+
throw this._isValid = !1, new Error(`The division values ${r ?? "a"} or ${n ?? "b"} are not defined`);
|
|
679
|
+
t.push(r / n);
|
|
680
|
+
} else if (s.token === "+") {
|
|
681
|
+
const n = t.pop(), r = t.pop();
|
|
682
|
+
if (r === void 0 || n === void 0)
|
|
683
|
+
throw this._isValid = !1, new Error(`The addition values ${r ?? "a"} or ${n ?? "b"} are not defined`);
|
|
684
|
+
t.push(+r + +n);
|
|
685
|
+
} else if (s.token === "-") {
|
|
686
|
+
const n = t.pop(), r = t.pop() ?? 0;
|
|
687
|
+
if (n === void 0)
|
|
688
|
+
throw this._isValid = !1, new Error("The subtraction value b is not defined");
|
|
689
|
+
t.push(r - n);
|
|
690
|
+
} else if (s.token === "^") {
|
|
691
|
+
const n = t.pop(), r = t.pop();
|
|
692
|
+
if (r === void 0 || n === void 0)
|
|
693
|
+
throw this._isValid = !1, new Error(`The base value ${r ?? "a"} or exponent ${n ?? "b"} are not defined`);
|
|
694
|
+
t.push(Math.pow(r, n));
|
|
695
|
+
}
|
|
696
|
+
} else if (s.tokenType === p.FUNCTION) {
|
|
697
|
+
const n = t.pop();
|
|
698
|
+
if (n === void 0)
|
|
699
|
+
throw this._isValid = !1, new Error(`The parameters for ${s.token} is not defined`);
|
|
700
|
+
if (s.token === "sin")
|
|
701
|
+
t.push(Math.sin(n));
|
|
702
|
+
else if (s.token === "cos")
|
|
703
|
+
t.push(Math.cos(n));
|
|
704
|
+
else if (s.token === "tan")
|
|
705
|
+
t.push(Math.tan(n));
|
|
706
|
+
else if (s.token === "sqrt")
|
|
707
|
+
t.push(Math.sqrt(n));
|
|
708
|
+
else if (s.token === "nthrt") {
|
|
709
|
+
const r = t.pop();
|
|
710
|
+
if (r === void 0)
|
|
711
|
+
throw this._isValid = !1, new Error("The nthrt function requires two parameters");
|
|
712
|
+
n % 2 === 0 && r < 0 ? t.push(NaN) : t.push((r < 0 ? -1 : 1) * Math.pow(Math.abs(r), 1 / n));
|
|
713
|
+
} else s.token === "ln" ? t.push(Math.log(n)) : s.token === "log" && t.push(Math.log10(n));
|
|
714
|
+
}
|
|
715
|
+
if (t.length === 1)
|
|
716
|
+
return this._numberCorrection(t[0]);
|
|
717
|
+
throw new Error(`There was a problem parsing: ${this._expression}`);
|
|
718
|
+
}
|
|
719
|
+
_numberCorrection(e, t = 8) {
|
|
720
|
+
return +e.toFixed(t);
|
|
620
721
|
}
|
|
621
722
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
const P = class P {
|
|
723
|
+
var T, v, Ye, gt, Re, Et, Nt;
|
|
724
|
+
const I = class I {
|
|
625
725
|
constructor(e) {
|
|
626
|
-
d(this,
|
|
627
|
-
d(this,
|
|
726
|
+
d(this, Ye);
|
|
727
|
+
d(this, T);
|
|
628
728
|
d(this, v);
|
|
629
729
|
/**
|
|
630
730
|
* Clone the current Monom.
|
|
631
731
|
*/
|
|
632
732
|
a(this, "clone", () => {
|
|
633
|
-
const e = new
|
|
634
|
-
e.coefficient = i(this,
|
|
733
|
+
const e = new I();
|
|
734
|
+
e.coefficient = i(this, T).clone();
|
|
635
735
|
for (const t in i(this, v))
|
|
636
736
|
e.setLetter(t, i(this, v)[t].clone());
|
|
637
737
|
return e;
|
|
@@ -642,8 +742,8 @@ const P = class P {
|
|
|
642
742
|
*/
|
|
643
743
|
a(this, "add", (...e) => {
|
|
644
744
|
for (const t of e) {
|
|
645
|
-
const s = t instanceof
|
|
646
|
-
this.isSameAs(s) ? (this.isZero() &&
|
|
745
|
+
const s = t instanceof I ? t : new I(t);
|
|
746
|
+
this.isSameAs(s) ? (this.isZero() && q(this, Ye, gt).call(this, s), i(this, T).add(s.coefficient)) : console.log("Add monom: " + this.display + " is not similar with ", s.display);
|
|
647
747
|
}
|
|
648
748
|
return this;
|
|
649
749
|
});
|
|
@@ -660,9 +760,9 @@ const P = class P {
|
|
|
660
760
|
a(this, "derivative", (e) => {
|
|
661
761
|
if (e === void 0 && (e = "x"), this.hasVariable(e)) {
|
|
662
762
|
const t = i(this, v)[e].clone(), s = this.clone();
|
|
663
|
-
return i(s, v)[e].subtract(1), i(s,
|
|
763
|
+
return i(s, v)[e].subtract(1), i(s, T).multiply(new c(t.clone())), s;
|
|
664
764
|
} else
|
|
665
|
-
return new
|
|
765
|
+
return new I().zero();
|
|
666
766
|
});
|
|
667
767
|
/**
|
|
668
768
|
* Divide the current monoms by multiple monoms
|
|
@@ -670,10 +770,10 @@ const P = class P {
|
|
|
670
770
|
*/
|
|
671
771
|
a(this, "divide", (...e) => {
|
|
672
772
|
for (const t of e) {
|
|
673
|
-
const s = t instanceof
|
|
674
|
-
i(this,
|
|
675
|
-
for (const
|
|
676
|
-
i(this, v)[
|
|
773
|
+
const s = t instanceof I ? t : new I(t);
|
|
774
|
+
i(this, T).divide(s.coefficient);
|
|
775
|
+
for (const n in s.literal)
|
|
776
|
+
i(this, v)[n] = this.hasVariable(n) ? i(this, v)[n].subtract(s.literal[n]) : s.literal[n].clone().opposite(), i(this, v)[n].isZero() && this.removeVariable(n);
|
|
677
777
|
}
|
|
678
778
|
return this;
|
|
679
779
|
});
|
|
@@ -686,30 +786,30 @@ const P = class P {
|
|
|
686
786
|
if (t === !0) {
|
|
687
787
|
if (e instanceof c)
|
|
688
788
|
return i(this, Re).call(this, e.value);
|
|
689
|
-
if (e instanceof
|
|
789
|
+
if (e instanceof pt)
|
|
690
790
|
return new c().invalid();
|
|
691
791
|
if (typeof e == "number")
|
|
692
792
|
return i(this, Re).call(this, e);
|
|
693
793
|
if (typeof e == "object") {
|
|
694
|
-
const
|
|
695
|
-
for (const
|
|
696
|
-
r
|
|
697
|
-
return i(this, Re).call(this,
|
|
794
|
+
const n = {};
|
|
795
|
+
for (const r in e)
|
|
796
|
+
n[r] = new c(e[r]).value;
|
|
797
|
+
return i(this, Re).call(this, n);
|
|
698
798
|
}
|
|
699
799
|
}
|
|
700
800
|
const s = this.coefficient.clone();
|
|
701
801
|
if (typeof e == "number" || e instanceof c) {
|
|
702
|
-
const
|
|
703
|
-
return
|
|
802
|
+
const n = {};
|
|
803
|
+
return n[this.variables[0]] = new c(e), this.evaluate(n);
|
|
704
804
|
}
|
|
705
|
-
if (e instanceof
|
|
805
|
+
if (e instanceof pt)
|
|
706
806
|
return new c().invalid();
|
|
707
807
|
if (typeof e == "object") {
|
|
708
808
|
if (this.variables.length === 0)
|
|
709
809
|
return this.coefficient;
|
|
710
|
-
for (const
|
|
711
|
-
const
|
|
712
|
-
s.multiply(
|
|
810
|
+
for (const n in i(this, v)) {
|
|
811
|
+
const r = new c(e[n]);
|
|
812
|
+
s.multiply(r.pow(i(this, v)[n]));
|
|
713
813
|
}
|
|
714
814
|
}
|
|
715
815
|
return s;
|
|
@@ -721,7 +821,7 @@ const P = class P {
|
|
|
721
821
|
*/
|
|
722
822
|
a(this, "hasVariable", (e) => Object.hasOwn(i(this, v), e ?? "x"));
|
|
723
823
|
a(this, "inverse", () => {
|
|
724
|
-
i(this,
|
|
824
|
+
i(this, T).opposite();
|
|
725
825
|
for (const e in i(this, v))
|
|
726
826
|
i(this, v)[e].opposite();
|
|
727
827
|
return this;
|
|
@@ -738,7 +838,7 @@ const P = class P {
|
|
|
738
838
|
* Determine if two monoms are equals
|
|
739
839
|
* @param M
|
|
740
840
|
*/
|
|
741
|
-
a(this, "isEqual", (e) => this.isSameAs(e) && i(this,
|
|
841
|
+
a(this, "isEqual", (e) => this.isSameAs(e) && i(this, T).isEqual(e.coefficient));
|
|
742
842
|
a(this, "isLiteralSquare", () => {
|
|
743
843
|
for (const e in this.literal)
|
|
744
844
|
if (this.literal[e].isRational() || this.literal[e].isEven())
|
|
@@ -748,20 +848,20 @@ const P = class P {
|
|
|
748
848
|
/**
|
|
749
849
|
* Determine if the monom is one
|
|
750
850
|
*/
|
|
751
|
-
a(this, "isOne", () => i(this,
|
|
851
|
+
a(this, "isOne", () => i(this, T).value === 1 && this.variables.length === 0);
|
|
752
852
|
/**
|
|
753
853
|
* Determine if two monoms are similar
|
|
754
854
|
* @param M
|
|
755
855
|
*/
|
|
756
856
|
a(this, "isSameAs", (e) => {
|
|
757
|
-
const t = this.variables, s = e.variables,
|
|
857
|
+
const t = this.variables, s = e.variables, n = t.concat(s.filter((r) => !t.includes(r)));
|
|
758
858
|
if (this.isZero() || e.isZero() || t.length === 0 && s.length === 0)
|
|
759
859
|
return !0;
|
|
760
860
|
if (t.length !== s.length)
|
|
761
861
|
return !1;
|
|
762
862
|
if (!this.isZero() && !e.isZero()) {
|
|
763
|
-
for (const
|
|
764
|
-
if (!this.hasVariable(
|
|
863
|
+
for (const r of n)
|
|
864
|
+
if (!this.hasVariable(r) || !e.hasVariable(r) || !i(this, v)[r].isEqual(e.literal[r]))
|
|
765
865
|
return !1;
|
|
766
866
|
}
|
|
767
867
|
return !0;
|
|
@@ -770,35 +870,35 @@ const P = class P {
|
|
|
770
870
|
/**
|
|
771
871
|
* Determine if the monom is null
|
|
772
872
|
*/
|
|
773
|
-
a(this, "isZero", () => i(this,
|
|
873
|
+
a(this, "isZero", () => i(this, T).value === 0);
|
|
774
874
|
/**
|
|
775
875
|
* Multiple multiple monoms to the current monom
|
|
776
876
|
* @param M (Monom[]) The monoms to multiply to.
|
|
777
877
|
*/
|
|
778
878
|
a(this, "multiply", (...e) => {
|
|
779
879
|
for (const t of e) {
|
|
780
|
-
const s = t instanceof
|
|
781
|
-
i(this,
|
|
782
|
-
for (const
|
|
783
|
-
this.hasVariable(
|
|
880
|
+
const s = t instanceof I ? t : new I(t);
|
|
881
|
+
i(this, T).multiply(s.coefficient);
|
|
882
|
+
for (const n in s.literal)
|
|
883
|
+
this.hasVariable(n) ? i(this, v)[n].add(s.literal[n]) : i(this, v)[n] = s.literal[n].clone();
|
|
784
884
|
}
|
|
785
885
|
return this;
|
|
786
886
|
});
|
|
787
887
|
/**
|
|
788
888
|
* Create a one value monom
|
|
789
889
|
*/
|
|
790
|
-
a(this, "one", () => (h(this,
|
|
890
|
+
a(this, "one", () => (h(this, T, new c().one()), h(this, v, {}), this));
|
|
791
891
|
/**
|
|
792
892
|
* Get the opposite
|
|
793
893
|
* Returns a monom.
|
|
794
894
|
*/
|
|
795
|
-
a(this, "opposite", () => (i(this,
|
|
895
|
+
a(this, "opposite", () => (i(this, T).opposite(), this));
|
|
796
896
|
/**
|
|
797
897
|
* Get the pow of a monom.
|
|
798
898
|
* @param nb (number) : Mathematical pow
|
|
799
899
|
*/
|
|
800
900
|
a(this, "pow", (e) => {
|
|
801
|
-
i(this,
|
|
901
|
+
i(this, T).pow(e);
|
|
802
902
|
for (const t in i(this, v))
|
|
803
903
|
i(this, v)[t].multiply(e);
|
|
804
904
|
return this;
|
|
@@ -834,7 +934,7 @@ const P = class P {
|
|
|
834
934
|
*/
|
|
835
935
|
a(this, "sqrt", () => {
|
|
836
936
|
if (this.isSquare()) {
|
|
837
|
-
i(this,
|
|
937
|
+
i(this, T).sqrt();
|
|
838
938
|
for (const e in i(this, v))
|
|
839
939
|
i(this, v)[e].clone().divide(2);
|
|
840
940
|
}
|
|
@@ -846,75 +946,75 @@ const P = class P {
|
|
|
846
946
|
*/
|
|
847
947
|
a(this, "subtract", (...e) => {
|
|
848
948
|
for (const t of e) {
|
|
849
|
-
const s = t instanceof
|
|
850
|
-
this.isSameAs(s) ? (this.isZero() &&
|
|
949
|
+
const s = t instanceof I ? t : new I(t);
|
|
950
|
+
this.isSameAs(s) ? (this.isZero() && q(this, Ye, gt).call(this, s), i(this, T).add(s.clone().coefficient.opposite())) : console.log("Subtract: Is not similar: ", s.display);
|
|
851
951
|
}
|
|
852
952
|
return this;
|
|
853
953
|
});
|
|
854
954
|
/**
|
|
855
955
|
* Create a zero value monom
|
|
856
956
|
*/
|
|
857
|
-
a(this, "zero", () => (h(this,
|
|
957
|
+
a(this, "zero", () => (h(this, T, new c().zero()), h(this, v, {}), this));
|
|
858
958
|
d(this, Re, (e) => {
|
|
859
959
|
let t = this.coefficient.value;
|
|
860
960
|
if (typeof e == "number") {
|
|
861
|
-
const s = {},
|
|
862
|
-
return s[
|
|
961
|
+
const s = {}, n = this.variables[0];
|
|
962
|
+
return s[n] = e, i(this, Re).call(this, s);
|
|
863
963
|
}
|
|
864
964
|
if (e instanceof c) {
|
|
865
965
|
const s = {};
|
|
866
966
|
return s[this.variables[0]] = new c(e).value, i(this, Re).call(this, s);
|
|
867
967
|
}
|
|
868
|
-
if (e instanceof
|
|
968
|
+
if (e instanceof pt)
|
|
869
969
|
return NaN;
|
|
870
970
|
if (typeof e == "object") {
|
|
871
971
|
if (this.variables.length === 0)
|
|
872
972
|
return this.coefficient.value;
|
|
873
973
|
for (const s in i(this, v)) {
|
|
874
|
-
const
|
|
875
|
-
|
|
974
|
+
const n = e[s];
|
|
975
|
+
n instanceof c ? t *= n.value ** i(this, v)[s].value : t *= n ** i(this, v)[s].value;
|
|
876
976
|
}
|
|
877
977
|
}
|
|
878
978
|
return t;
|
|
879
979
|
});
|
|
880
|
-
d(this,
|
|
881
|
-
const s = new
|
|
980
|
+
d(this, Et, (e) => {
|
|
981
|
+
const s = new Gt().parse(e).rpn, n = [];
|
|
882
982
|
if (s.length === 0)
|
|
883
983
|
return this.zero(), this;
|
|
884
984
|
if (s.length === 1) {
|
|
885
|
-
const
|
|
886
|
-
return this.one(),
|
|
985
|
+
const r = s[0];
|
|
986
|
+
return this.one(), r.tokenType === p.COEFFICIENT ? this.coefficient = new c(r.token) : r.tokenType === p.VARIABLE && this.setLetter(r.token, 1), this;
|
|
887
987
|
} else
|
|
888
|
-
for (const
|
|
889
|
-
i(this,
|
|
890
|
-
return this.one(), this.multiply(
|
|
988
|
+
for (const r of s)
|
|
989
|
+
i(this, Nt).call(this, n, r);
|
|
990
|
+
return this.one(), this.multiply(n[0]), this;
|
|
891
991
|
});
|
|
892
|
-
d(this,
|
|
992
|
+
d(this, Nt, (e, t) => {
|
|
893
993
|
var f;
|
|
894
|
-
let s,
|
|
895
|
-
if (t.tokenType ===
|
|
896
|
-
e.push(new
|
|
897
|
-
else if (t.tokenType ===
|
|
898
|
-
const
|
|
899
|
-
|
|
900
|
-
} else if (t.tokenType ===
|
|
994
|
+
let s, n, r, l, u;
|
|
995
|
+
if (t.tokenType === p.COEFFICIENT)
|
|
996
|
+
e.push(new I(new c(t.token)));
|
|
997
|
+
else if (t.tokenType === p.VARIABLE) {
|
|
998
|
+
const m = new I().one();
|
|
999
|
+
m.setLetter(t.token, 1), e.push(m.clone());
|
|
1000
|
+
} else if (t.tokenType === p.OPERATION)
|
|
901
1001
|
switch (t.token) {
|
|
902
1002
|
case "-":
|
|
903
|
-
|
|
1003
|
+
n = e.pop() ?? new I().zero(), s = e.pop() ?? new I().zero(), e.push(s.subtract(n));
|
|
904
1004
|
break;
|
|
905
1005
|
case "*":
|
|
906
|
-
|
|
1006
|
+
n = e.pop() ?? new I().one(), s = e.pop() ?? new I().one(), e.push(s.multiply(n));
|
|
907
1007
|
break;
|
|
908
1008
|
case "/":
|
|
909
|
-
|
|
1009
|
+
n = e.pop() ?? new I().one(), s = e.pop() ?? new I().one(), e.push(s.divide(n));
|
|
910
1010
|
break;
|
|
911
1011
|
case "^": {
|
|
912
|
-
u = ((f = e.pop()) == null ? void 0 : f.coefficient) ?? new c().one(),
|
|
1012
|
+
u = ((f = e.pop()) == null ? void 0 : f.coefficient) ?? new c().one(), r = e.pop() ?? new I().one(), l = r.variables[0], l && r.setLetter(l, u), e.push(r);
|
|
913
1013
|
break;
|
|
914
1014
|
}
|
|
915
1015
|
}
|
|
916
1016
|
});
|
|
917
|
-
return h(this,
|
|
1017
|
+
return h(this, T, new c().zero()), h(this, v, {}), e !== void 0 && this.parse(e), this;
|
|
918
1018
|
}
|
|
919
1019
|
// -----------------------------------------
|
|
920
1020
|
/**
|
|
@@ -922,21 +1022,21 @@ const P = class P {
|
|
|
922
1022
|
* @param inputStr
|
|
923
1023
|
*/
|
|
924
1024
|
parse(e) {
|
|
925
|
-
return h(this,
|
|
1025
|
+
return h(this, T, new c()), h(this, v, {}), typeof e == "string" ? i(this, Et).call(this, e) : typeof e == "number" ? h(this, T, new c(e)) : e instanceof c ? h(this, T, e.clone()) : e instanceof I && (h(this, T, i(e, T).clone()), q(this, Ye, gt).call(this, e)), this;
|
|
926
1026
|
}
|
|
927
1027
|
/**
|
|
928
1028
|
* Get the coefficient \\(k\\) of the Monom \\(k\\cdot x^{n}\\)
|
|
929
1029
|
* @returns {Fraction}
|
|
930
1030
|
*/
|
|
931
1031
|
get coefficient() {
|
|
932
|
-
return i(this,
|
|
1032
|
+
return i(this, T);
|
|
933
1033
|
}
|
|
934
1034
|
/**
|
|
935
1035
|
* Set the coefficient \\(k\\) value of the monom
|
|
936
1036
|
* @param {Fraction | number | string} F
|
|
937
1037
|
*/
|
|
938
1038
|
set coefficient(e) {
|
|
939
|
-
h(this,
|
|
1039
|
+
h(this, T, new c(e));
|
|
940
1040
|
}
|
|
941
1041
|
// Display getter
|
|
942
1042
|
/**
|
|
@@ -947,7 +1047,7 @@ const P = class P {
|
|
|
947
1047
|
const t = Object.keys(i(this, v)).sort();
|
|
948
1048
|
for (const s of t)
|
|
949
1049
|
i(this, v)[s].isNotZero() && (e += s, i(this, v)[s].isNotEqual(1) && (e += `^(${i(this, v)[s].display})`));
|
|
950
|
-
return e === "" ? i(this,
|
|
1050
|
+
return e === "" ? i(this, T).value != 0 ? i(this, T).display : "" : i(this, T).value === 1 ? e : i(this, T).value === -1 ? `-${e}` : i(this, T).value === 0 ? "0" : `${i(this, T).display}${e}`;
|
|
951
1051
|
}
|
|
952
1052
|
get dividers() {
|
|
953
1053
|
if (!this.coefficient.isRelative())
|
|
@@ -958,30 +1058,30 @@ const P = class P {
|
|
|
958
1058
|
return [this.clone()];
|
|
959
1059
|
const e = G.dividers(Math.abs(this.coefficient.numerator));
|
|
960
1060
|
let t = [];
|
|
961
|
-
for (const
|
|
962
|
-
t = this._getLiteralDividers(t,
|
|
1061
|
+
for (const n in this.literal)
|
|
1062
|
+
t = this._getLiteralDividers(t, n);
|
|
963
1063
|
const s = [];
|
|
964
1064
|
if (t.length > 0 && e.length > 0)
|
|
965
|
-
for (const
|
|
966
|
-
for (const
|
|
967
|
-
const l = new
|
|
968
|
-
l.coefficient = new c(
|
|
1065
|
+
for (const n of e)
|
|
1066
|
+
for (const r of t) {
|
|
1067
|
+
const l = new I();
|
|
1068
|
+
l.coefficient = new c(n), l.literal = r, s.push(l);
|
|
969
1069
|
}
|
|
970
1070
|
else if (e.length === 0)
|
|
971
|
-
for (const
|
|
972
|
-
const
|
|
973
|
-
|
|
1071
|
+
for (const n of t) {
|
|
1072
|
+
const r = new I();
|
|
1073
|
+
r.coefficient = new c().one(), r.literal = n, s.push(r);
|
|
974
1074
|
}
|
|
975
1075
|
else
|
|
976
|
-
for (const
|
|
977
|
-
const
|
|
978
|
-
|
|
1076
|
+
for (const n of e) {
|
|
1077
|
+
const r = new I();
|
|
1078
|
+
r.coefficient = new c(n), s.push(r);
|
|
979
1079
|
}
|
|
980
|
-
return s.length === 0 ? [new
|
|
1080
|
+
return s.length === 0 ? [new I().one()] : s;
|
|
981
1081
|
}
|
|
982
1082
|
integrate(e, t, s) {
|
|
983
|
-
const
|
|
984
|
-
return
|
|
1083
|
+
const n = this.primitive(s);
|
|
1084
|
+
return n.evaluate(t).subtract(n.evaluate(e));
|
|
985
1085
|
}
|
|
986
1086
|
/**
|
|
987
1087
|
* Get the literal part of \\(x^{n_1}y^{n_2}\\) as dictionary \\[\\begin{array}{ll}x&=n_1\\\\y&=n_2\\end{array}\\]
|
|
@@ -1026,7 +1126,7 @@ const P = class P {
|
|
|
1026
1126
|
const t = Object.keys(i(this, v)).sort();
|
|
1027
1127
|
for (const s of t)
|
|
1028
1128
|
i(this, v)[s].isNotZero() && (e += (e === "" ? "" : "*") + s, i(this, v)[s].isNotEqual(1) && (e += `^(${i(this, v)[s].display})`));
|
|
1029
|
-
return e === "" ? i(this,
|
|
1129
|
+
return e === "" ? i(this, T).value != 0 ? i(this, T).display : "" : i(this, T).value === 1 ? e : i(this, T).value === -1 ? `-${e}` : i(this, T).value === 0 ? "0" : `${i(this, T).display}*${e}`;
|
|
1030
1130
|
}
|
|
1031
1131
|
removeVariable(e) {
|
|
1032
1132
|
delete i(this, v)[e];
|
|
@@ -1039,7 +1139,7 @@ const P = class P {
|
|
|
1039
1139
|
const t = Object.keys(i(this, v)).sort();
|
|
1040
1140
|
for (const s of t)
|
|
1041
1141
|
i(this, v)[s].isNotZero() && (e += s, i(this, v)[s].isNotEqual(1) && (e += `^{ ${i(this, v)[s].tfrac.tex} }`));
|
|
1042
|
-
return e === "" ? i(this,
|
|
1142
|
+
return e === "" ? i(this, T).value != 0 ? i(this, T).frac.tex : "0" : i(this, T).value === 1 ? e : i(this, T).value === -1 ? `-${e}` : i(this, T).value === 0 ? "0" : `${i(this, T).frac.tex}${e}`;
|
|
1043
1143
|
}
|
|
1044
1144
|
// Getter helpers.
|
|
1045
1145
|
/**
|
|
@@ -1055,84 +1155,84 @@ const P = class P {
|
|
|
1055
1155
|
}
|
|
1056
1156
|
_getLiteralDividers(e, t) {
|
|
1057
1157
|
const s = [];
|
|
1058
|
-
for (let
|
|
1158
|
+
for (let n = 0; n <= this.literal[t].value; n++)
|
|
1059
1159
|
if (e.length === 0) {
|
|
1060
|
-
const
|
|
1061
|
-
|
|
1160
|
+
const r = {};
|
|
1161
|
+
r[t] = new c(n), s.push(r);
|
|
1062
1162
|
} else
|
|
1063
|
-
for (const
|
|
1163
|
+
for (const r of e) {
|
|
1064
1164
|
const l = {};
|
|
1065
|
-
for (const u in
|
|
1066
|
-
l[u] =
|
|
1067
|
-
l[t] = new c(
|
|
1165
|
+
for (const u in r)
|
|
1166
|
+
l[u] = r[u];
|
|
1167
|
+
l[t] = new c(n), s.push(l);
|
|
1068
1168
|
}
|
|
1069
1169
|
return s;
|
|
1070
1170
|
}
|
|
1071
1171
|
// #endregion Private methods (5)
|
|
1072
1172
|
};
|
|
1073
|
-
|
|
1173
|
+
T = new WeakMap(), v = new WeakMap(), Ye = new WeakSet(), gt = function(e) {
|
|
1074
1174
|
for (const t in e.literal)
|
|
1075
1175
|
i(this, v)[t] = e.literal[t].clone();
|
|
1076
|
-
}, Re = new WeakMap(),
|
|
1077
|
-
for (const
|
|
1078
|
-
if (
|
|
1079
|
-
return new
|
|
1080
|
-
const t = new
|
|
1081
|
-
t.coefficient = new c(s,
|
|
1082
|
-
for (const
|
|
1176
|
+
}, Re = new WeakMap(), Et = new WeakMap(), Nt = new WeakMap(), a(I, "gcd", (...e) => {
|
|
1177
|
+
for (const r of e)
|
|
1178
|
+
if (r.containsRationalPower())
|
|
1179
|
+
return new I().zero();
|
|
1180
|
+
const t = new I(), s = G.gcd(...e.map((r) => r.coefficient.numerator)), n = G.lcm(...e.map((r) => r.coefficient.denominator));
|
|
1181
|
+
t.coefficient = new c(s, n).reduce();
|
|
1182
|
+
for (const r of e) {
|
|
1083
1183
|
for (const l in t.literal)
|
|
1084
|
-
l in
|
|
1085
|
-
for (const l in
|
|
1086
|
-
!t.hasVariable(l) &&
|
|
1184
|
+
l in r.literal || t.literal[l].zero();
|
|
1185
|
+
for (const l in r.literal)
|
|
1186
|
+
!t.hasVariable(l) && r.literal[l].isStrictlyPositive() ? t.literal[l] = r.literal[l].clone() : t.literal[l] = new c(Math.min(r.literal[l].value, t.literal[l].value));
|
|
1087
1187
|
}
|
|
1088
1188
|
return t;
|
|
1089
1189
|
}), /**
|
|
1090
1190
|
* Multiply two monoms and return a NEW monom.
|
|
1091
1191
|
* @param monoms
|
|
1092
1192
|
*/
|
|
1093
|
-
a(
|
|
1094
|
-
const t = new
|
|
1193
|
+
a(I, "xMultiply", (...e) => {
|
|
1194
|
+
const t = new I().one();
|
|
1095
1195
|
for (const s of e)
|
|
1096
1196
|
t.multiply(s);
|
|
1097
1197
|
return t;
|
|
1098
1198
|
});
|
|
1099
|
-
let
|
|
1100
|
-
var ue,
|
|
1101
|
-
const
|
|
1199
|
+
let k = I;
|
|
1200
|
+
var ue, Ze, B, ye, rt, pi, mi, gi, Qt, yi;
|
|
1201
|
+
const hi = class hi {
|
|
1102
1202
|
constructor(e, t, s = "x") {
|
|
1103
|
-
d(this,
|
|
1203
|
+
d(this, B);
|
|
1104
1204
|
d(this, ue);
|
|
1105
|
-
d(this,
|
|
1106
|
-
if (h(this,
|
|
1107
|
-
const
|
|
1108
|
-
h(this, ue,
|
|
1205
|
+
d(this, Ze);
|
|
1206
|
+
if (h(this, Ze, s), Object.hasOwn(e, "moveLeft")) {
|
|
1207
|
+
const n = e;
|
|
1208
|
+
h(this, ue, n.left.clone().subtract(n.right));
|
|
1109
1209
|
} else
|
|
1110
1210
|
h(this, ue, e.clone().subtract(t ?? 0));
|
|
1111
1211
|
}
|
|
1112
1212
|
solve() {
|
|
1113
1213
|
if (i(this, ue).degree().isOne())
|
|
1114
|
-
return
|
|
1214
|
+
return q(this, B, pi).call(this);
|
|
1115
1215
|
if (i(this, ue).degree().value === 2)
|
|
1116
|
-
return
|
|
1117
|
-
const e =
|
|
1216
|
+
return q(this, B, mi).call(this);
|
|
1217
|
+
const e = q(this, B, yi).call(this);
|
|
1118
1218
|
if (e.length > 0)
|
|
1119
1219
|
return e;
|
|
1120
1220
|
if (i(this, ue).degree().value === 3)
|
|
1121
|
-
return
|
|
1221
|
+
return q(this, B, Qt).call(this);
|
|
1122
1222
|
throw new Error("The equation degree is too high.");
|
|
1123
1223
|
}
|
|
1124
1224
|
solveAsCardan() {
|
|
1125
1225
|
if (i(this, ue).degree().value !== 3)
|
|
1126
1226
|
throw new Error("The equation is not cubic.");
|
|
1127
|
-
return
|
|
1227
|
+
return q(this, B, Qt).call(this);
|
|
1128
1228
|
}
|
|
1129
1229
|
};
|
|
1130
|
-
ue = new WeakMap(),
|
|
1230
|
+
ue = new WeakMap(), Ze = new WeakMap(), B = new WeakSet(), ye = function(e) {
|
|
1131
1231
|
if (e instanceof c && e.isApproximative())
|
|
1132
|
-
return
|
|
1232
|
+
return q(this, B, rt).call(this, e.value);
|
|
1133
1233
|
const t = new c(e);
|
|
1134
1234
|
return {
|
|
1135
|
-
variable: i(this,
|
|
1235
|
+
variable: i(this, Ze),
|
|
1136
1236
|
exact: t,
|
|
1137
1237
|
value: t.value,
|
|
1138
1238
|
tex: t.tex,
|
|
@@ -1140,81 +1240,81 @@ ue = new WeakMap(), De = new WeakMap(), S = new WeakSet(), ye = function(e) {
|
|
|
1140
1240
|
};
|
|
1141
1241
|
}, rt = function(e, t) {
|
|
1142
1242
|
return {
|
|
1143
|
-
variable: i(this,
|
|
1243
|
+
variable: i(this, Ze),
|
|
1144
1244
|
exact: !1,
|
|
1145
1245
|
value: +e.toFixed(10),
|
|
1146
1246
|
tex: (t == null ? void 0 : t.tex) ?? "",
|
|
1147
1247
|
display: (t == null ? void 0 : t.display) ?? ""
|
|
1148
1248
|
};
|
|
1149
|
-
},
|
|
1249
|
+
}, pi = function() {
|
|
1150
1250
|
const e = i(this, ue).monomByDegree(0).coefficient.clone().opposite().divide(i(this, ue).monomByDegree(1).coefficient);
|
|
1151
1251
|
return [
|
|
1152
|
-
|
|
1252
|
+
q(this, B, ye).call(this, e)
|
|
1153
1253
|
];
|
|
1154
|
-
},
|
|
1155
|
-
const e = i(this, ue), t = e.monomByDegree(2).coefficient, s = e.monomByDegree(1).coefficient,
|
|
1156
|
-
if (
|
|
1254
|
+
}, mi = function() {
|
|
1255
|
+
const e = i(this, ue), t = e.monomByDegree(2).coefficient, s = e.monomByDegree(1).coefficient, n = e.monomByDegree(0).coefficient, r = s.clone().pow(2).subtract(t.clone().multiply(n).multiply(4));
|
|
1256
|
+
if (r.isNegative())
|
|
1157
1257
|
return [];
|
|
1158
|
-
if (
|
|
1159
|
-
const l =
|
|
1160
|
-
return l.isZero() ? [
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
].sort((
|
|
1164
|
-
}
|
|
1165
|
-
return
|
|
1166
|
-
},
|
|
1167
|
-
const
|
|
1168
|
-
function L(pe, ce,
|
|
1169
|
-
return `\\frac{ ${ce} ${
|
|
1170
|
-
}
|
|
1171
|
-
function te(pe, ce,
|
|
1172
|
-
return `(${ce}${
|
|
1258
|
+
if (r.isSquare()) {
|
|
1259
|
+
const l = r.sqrt(), u = s.clone().opposite().add(l).divide(t.clone().multiply(2)), f = s.clone().opposite().subtract(l).divide(t.clone().multiply(2));
|
|
1260
|
+
return l.isZero() ? [q(this, B, ye).call(this, u)] : [
|
|
1261
|
+
q(this, B, ye).call(this, u),
|
|
1262
|
+
q(this, B, ye).call(this, f)
|
|
1263
|
+
].sort((m, g) => m.value - g.value);
|
|
1264
|
+
}
|
|
1265
|
+
return q(this, B, gi).call(this, t, s, r);
|
|
1266
|
+
}, gi = function(e, t, s) {
|
|
1267
|
+
const n = G.dividers(s.value).filter((pe) => Math.sqrt(pe) % 1 === 0).map((pe) => Math.sqrt(pe)).pop() ?? 1, r = G.gcd(2 * e.value, t.value, n) * (e.isNegative() ? -1 : 1), l = t.clone().divide(r).opposite(), u = e.clone().divide(r).multiply(2), f = s.clone().divide(n ** 2), m = Math.abs(n / r), g = n === 1 ? "-" : `-${m} `, E = n === 1 ? "+" : `+${m} `;
|
|
1268
|
+
function L(pe, ce, it, Wt) {
|
|
1269
|
+
return `\\frac{ ${ce} ${it}\\sqrt{ ${Wt} } }{ ${pe} }`;
|
|
1270
|
+
}
|
|
1271
|
+
function te(pe, ce, it, Wt) {
|
|
1272
|
+
return `(${ce}${it}sqrt(${Wt}))/${pe}`;
|
|
1173
1273
|
}
|
|
1174
1274
|
const ae = s.value ** 0.5, le = (-t.value - ae) / (2 * e.value), ge = (-t.value + ae) / (2 * e.value);
|
|
1175
1275
|
return [
|
|
1176
|
-
|
|
1276
|
+
q(this, B, rt).call(this, le, {
|
|
1177
1277
|
tex: L(u.tex, l.tex, g.toString(), f.tex),
|
|
1178
1278
|
display: te(u.display, l.display, g.toString(), f.display)
|
|
1179
1279
|
}),
|
|
1180
|
-
|
|
1280
|
+
q(this, B, rt).call(this, ge, {
|
|
1181
1281
|
tex: L(u.tex, l.tex, E.toString(), f.tex),
|
|
1182
1282
|
display: te(u.display, l.display, E.toString(), f.display)
|
|
1183
1283
|
})
|
|
1184
1284
|
].sort((pe, ce) => pe.value - ce.value);
|
|
1185
|
-
},
|
|
1186
|
-
const e = i(this, ue), t = e.monomByDegree(3).coefficient, s = e.monomByDegree(2).coefficient,
|
|
1285
|
+
}, Qt = function() {
|
|
1286
|
+
const e = i(this, ue), t = e.monomByDegree(3).coefficient, s = e.monomByDegree(2).coefficient, n = e.monomByDegree(1).coefficient, r = e.monomByDegree(0).coefficient, l = s.clone().divide(t), u = n.clone().divide(t), f = r.clone().divide(t), m = u.clone().subtract(l.clone().pow(2).divide(3)), g = f.clone().subtract(l.clone().multiply(u).divide(3)).add(l.clone().pow(3).multiply(2).divide(27)), E = g.clone().opposite(), L = m.clone().opposite().pow(3).divide(27), te = E.clone().pow(2).subtract(L.clone().multiply(4)).opposite();
|
|
1187
1287
|
if (te.isNegative()) {
|
|
1188
1288
|
const ae = g.clone().opposite().add(te.clone().opposite().sqrt()).divide(2).root(3), le = g.clone().opposite().subtract(te.clone().opposite().sqrt()).divide(2).root(3), ge = ae.clone().add(le).subtract(l.clone().divide(3));
|
|
1189
|
-
return [
|
|
1289
|
+
return [q(this, B, ye).call(this, ge)];
|
|
1190
1290
|
}
|
|
1191
1291
|
if (te.isZero()) {
|
|
1192
1292
|
const ae = g.clone().opposite().divide(2).root(3), le = ae.clone().opposite().subtract(l.clone().divide(3)), ge = ae.clone().multiply(2).subtract(l.clone().divide(3));
|
|
1193
|
-
return le.isEqual(ge) ? [
|
|
1194
|
-
|
|
1195
|
-
|
|
1293
|
+
return le.isEqual(ge) ? [q(this, B, ye).call(this, le)] : [
|
|
1294
|
+
q(this, B, ye).call(this, ge),
|
|
1295
|
+
q(this, B, ye).call(this, le)
|
|
1196
1296
|
].sort((pe, ce) => pe.value - ce.value);
|
|
1197
1297
|
}
|
|
1198
1298
|
if (te.isPositive()) {
|
|
1199
|
-
const ae = [], le =
|
|
1299
|
+
const ae = [], le = m.value, ge = g.value, pe = l.value;
|
|
1200
1300
|
for (let ce = 0; ce < 3; ce++)
|
|
1201
1301
|
ae.push(2 * Math.sqrt(-le / 3) * Math.cos(Math.acos(3 * ge / (2 * le) * Math.sqrt(-3 / le)) / 3 + 2 * Math.PI * ce / 3) - pe / 3);
|
|
1202
|
-
return ae.map((ce) =>
|
|
1302
|
+
return ae.map((ce) => q(this, B, rt).call(this, ce)).sort((ce, it) => ce.value - it.value);
|
|
1203
1303
|
}
|
|
1204
1304
|
return [];
|
|
1205
|
-
},
|
|
1305
|
+
}, yi = function() {
|
|
1206
1306
|
let e = i(this, ue).clone(), t = [];
|
|
1207
1307
|
const s = e.lcmDenominator();
|
|
1208
1308
|
s !== 1 && e.multiply(s);
|
|
1209
|
-
const
|
|
1210
|
-
let
|
|
1211
|
-
for (;
|
|
1212
|
-
t.length === 0 && t.push(
|
|
1213
|
-
const l = G.dividers(
|
|
1309
|
+
const n = e.monomByDegree().coefficient;
|
|
1310
|
+
let r = e.monomByDegree(0).coefficient;
|
|
1311
|
+
for (; r.isZero(); )
|
|
1312
|
+
t.length === 0 && t.push(q(this, B, ye).call(this, 0)), e = e.divide("x"), r = e.monomByDegree(0).coefficient;
|
|
1313
|
+
const l = G.dividers(n.value), u = G.dividers(r.value);
|
|
1214
1314
|
for (const g of l)
|
|
1215
1315
|
for (const E of u) {
|
|
1216
1316
|
const L = new c(E, g);
|
|
1217
|
-
e.evaluate(L).isZero() && !t.find((te) => te.value === L.value) && t.push(
|
|
1317
|
+
e.evaluate(L).isZero() && !t.find((te) => te.value === L.value) && t.push(q(this, B, ye).call(this, L)), L.opposite(), e.evaluate(L).isZero() && !t.find((te) => te.value === L.value) && t.push(q(this, B, ye).call(this, L));
|
|
1218
1318
|
}
|
|
1219
1319
|
for (const g of t) {
|
|
1220
1320
|
if (g.exact !== !1 && g.exact.isZero())
|
|
@@ -1229,16 +1329,16 @@ ue = new WeakMap(), De = new WeakMap(), S = new WeakSet(), ye = function(e) {
|
|
|
1229
1329
|
return [];
|
|
1230
1330
|
const f = e.clone().parse("0");
|
|
1231
1331
|
console.log(e.display), console.log(f.display);
|
|
1232
|
-
const
|
|
1233
|
-
return t = t.concat(
|
|
1332
|
+
const m = new hi(e, e.clone().parse("0"), i(this, Ze));
|
|
1333
|
+
return t = t.concat(m.solve()), t.sort((g, E) => g.value - E.value);
|
|
1234
1334
|
};
|
|
1235
|
-
let
|
|
1236
|
-
var
|
|
1335
|
+
let wt = hi;
|
|
1336
|
+
var Fe, y, Qe, at, Tt, Ot, At, qt, lt, Mt, kt, Ct, $t, wi, It, Ke, Bt;
|
|
1237
1337
|
const C = class C {
|
|
1238
1338
|
constructor(e, ...t) {
|
|
1239
|
-
d(this,
|
|
1339
|
+
d(this, $t);
|
|
1240
1340
|
// #region Class fields (8)
|
|
1241
|
-
d(this,
|
|
1341
|
+
d(this, Fe);
|
|
1242
1342
|
d(this, y);
|
|
1243
1343
|
// #endregion Constructors (7)
|
|
1244
1344
|
// #region Properties and methods (49)
|
|
@@ -1248,13 +1348,13 @@ const C = class C {
|
|
|
1248
1348
|
* @param values
|
|
1249
1349
|
*/
|
|
1250
1350
|
a(this, "parse", (e, ...t) => {
|
|
1251
|
-
if (h(this, y, []), h(this,
|
|
1252
|
-
return
|
|
1253
|
-
if ((typeof e == "number" || e instanceof c || e instanceof
|
|
1254
|
-
i(this, y).push(new
|
|
1255
|
-
else if (e instanceof
|
|
1256
|
-
i(this, y).push(new
|
|
1257
|
-
i(this, y).push(new
|
|
1351
|
+
if (h(this, y, []), h(this, Fe, []), typeof e == "string")
|
|
1352
|
+
return q(this, $t, wi).call(this, e, ...t);
|
|
1353
|
+
if ((typeof e == "number" || e instanceof c || e instanceof k) && t.length === 0)
|
|
1354
|
+
i(this, y).push(new k(e));
|
|
1355
|
+
else if (e instanceof k && t.length > 0)
|
|
1356
|
+
i(this, y).push(new k(e)), t.forEach((s) => {
|
|
1357
|
+
i(this, y).push(new k(s));
|
|
1258
1358
|
});
|
|
1259
1359
|
else if (e instanceof C)
|
|
1260
1360
|
for (const s of e.monoms)
|
|
@@ -1272,16 +1372,16 @@ const C = class C {
|
|
|
1272
1372
|
});
|
|
1273
1373
|
a(this, "add", (...e) => {
|
|
1274
1374
|
for (const t of e)
|
|
1275
|
-
t instanceof C ? h(this, y, i(this, y).concat(t.monoms)) : t instanceof
|
|
1375
|
+
t instanceof C ? h(this, y, i(this, y).concat(t.monoms)) : t instanceof k ? i(this, y).push(t.clone()) : typeof t == "number" && Number.isSafeInteger(t) ? i(this, y).push(new k(t.toString())) : i(this, y).push(new k(t));
|
|
1276
1376
|
return this.reduce();
|
|
1277
1377
|
});
|
|
1278
1378
|
a(this, "commonMonom", () => {
|
|
1279
|
-
const e = new
|
|
1379
|
+
const e = new k().one(), t = this.gcdNumerator(), s = this.gcdDenominator(), n = this.degree();
|
|
1280
1380
|
e.coefficient = new c(t, s);
|
|
1281
|
-
for (const
|
|
1282
|
-
e.setLetter(
|
|
1381
|
+
for (const r of this.variables) {
|
|
1382
|
+
e.setLetter(r, n);
|
|
1283
1383
|
for (const l of i(this, y))
|
|
1284
|
-
if (e.setLetter(
|
|
1384
|
+
if (e.setLetter(r, c.min(l.degree(r), e.degree(r))), e.degree(r).isZero())
|
|
1285
1385
|
break;
|
|
1286
1386
|
}
|
|
1287
1387
|
return e;
|
|
@@ -1300,14 +1400,14 @@ const C = class C {
|
|
|
1300
1400
|
});
|
|
1301
1401
|
a(this, "divide", (e) => {
|
|
1302
1402
|
if (e instanceof c)
|
|
1303
|
-
return i(this,
|
|
1403
|
+
return i(this, at).call(this, e);
|
|
1304
1404
|
if (typeof e == "number" && Number.isSafeInteger(e))
|
|
1305
|
-
return i(this,
|
|
1306
|
-
if (e instanceof
|
|
1405
|
+
return i(this, Tt).call(this, e);
|
|
1406
|
+
if (e instanceof k)
|
|
1307
1407
|
return this.divide(new C(e));
|
|
1308
1408
|
if (e instanceof C) {
|
|
1309
1409
|
if (e.monoms.length === 1 && e.variables.length === 0)
|
|
1310
|
-
return i(this,
|
|
1410
|
+
return i(this, at).call(this, e.monoms[0].coefficient);
|
|
1311
1411
|
{
|
|
1312
1412
|
const { quotient: t, reminder: s } = this.euclidean(e);
|
|
1313
1413
|
if (s.isZero())
|
|
@@ -1324,24 +1424,24 @@ const C = class C {
|
|
|
1324
1424
|
* returns {quotient: Polynom, reminder: Polynom}
|
|
1325
1425
|
*/
|
|
1326
1426
|
a(this, "euclidean", (e) => {
|
|
1327
|
-
const t = e.variables[0], s = new C().zero(),
|
|
1427
|
+
const t = e.variables[0], s = new C().zero(), n = this.clone().reorder(t);
|
|
1328
1428
|
if (e.variables.length === 0)
|
|
1329
1429
|
return {
|
|
1330
1430
|
quotient: this.clone().divide(e).reduce(),
|
|
1331
1431
|
reminder: new C().zero()
|
|
1332
1432
|
};
|
|
1333
|
-
const
|
|
1433
|
+
const r = e.monomByDegree(void 0, t), l = e.degree(t);
|
|
1334
1434
|
let u, f = this.degree(t).value * 2;
|
|
1335
|
-
for (;
|
|
1435
|
+
for (; n.degree(t).isGeq(l) && f > 0 && (f--, u = n.monomByDegree(void 0, t).clone().divide(r), !(!u.isZero() && (s.add(u), n.subtract(e.clone().multiply(u)).reduce(), u.degree(t).isZero()))); )
|
|
1336
1436
|
;
|
|
1337
|
-
return s.reduce(),
|
|
1437
|
+
return s.reduce(), n.reduce(), { quotient: s, reminder: n };
|
|
1338
1438
|
});
|
|
1339
1439
|
a(this, "evaluate", (e, t) => {
|
|
1340
1440
|
if (t)
|
|
1341
|
-
return i(this,
|
|
1441
|
+
return i(this, Ot).call(this, e);
|
|
1342
1442
|
const s = new c().zero();
|
|
1343
|
-
return i(this, y).forEach((
|
|
1344
|
-
s.add(
|
|
1443
|
+
return i(this, y).forEach((n) => {
|
|
1444
|
+
s.add(n.evaluate(e, t));
|
|
1345
1445
|
}), s;
|
|
1346
1446
|
});
|
|
1347
1447
|
// -------------------------------------
|
|
@@ -1351,14 +1451,14 @@ const C = class C {
|
|
|
1351
1451
|
*/
|
|
1352
1452
|
a(this, "factorize", (e) => {
|
|
1353
1453
|
let t = [], s = this.clone().reorder();
|
|
1354
|
-
const
|
|
1355
|
-
if (s.monomByDegree().coefficient.isStrictlyNegative() &&
|
|
1356
|
-
const u = new C(
|
|
1454
|
+
const n = s.commonMonom();
|
|
1455
|
+
if (s.monomByDegree().coefficient.isStrictlyNegative() && n.coefficient.isStrictlyPositive() && !n.isOne() && n.opposite(), !n.isOne()) {
|
|
1456
|
+
const u = new C(n);
|
|
1357
1457
|
t = [u.clone()], s = s.euclidean(u).quotient;
|
|
1358
1458
|
}
|
|
1359
|
-
let
|
|
1360
|
-
for (;
|
|
1361
|
-
if (
|
|
1459
|
+
let r = s.degree().clone().multiply(2).value, l = 1;
|
|
1460
|
+
for (; r >= 0; )
|
|
1461
|
+
if (r--, s.monoms.length < 2) {
|
|
1362
1462
|
s.isOne() || (t.push(s.clone()), s.one());
|
|
1363
1463
|
break;
|
|
1364
1464
|
} else if (s.degree(e).isOne()) {
|
|
@@ -1371,15 +1471,15 @@ const C = class C {
|
|
|
1371
1471
|
if (!s.isDividableBy(f))
|
|
1372
1472
|
u.shift();
|
|
1373
1473
|
else {
|
|
1374
|
-
const
|
|
1375
|
-
t.push(f), s =
|
|
1474
|
+
const m = s.euclidean(f);
|
|
1475
|
+
t.push(f), s = m.quotient.clone(), u = u.filter((g) => {
|
|
1376
1476
|
const E = s.monoms[0], L = s.monoms[s.monoms.length - 1], te = g.monoms[0], ae = g.monoms[g.monoms.length - 1];
|
|
1377
1477
|
return L.isDivisible(ae) ? E.isDivisible(te) : !1;
|
|
1378
1478
|
});
|
|
1379
1479
|
}
|
|
1380
1480
|
}
|
|
1381
1481
|
}
|
|
1382
|
-
return s.isOne() || t.push(s.clone()), h(this,
|
|
1482
|
+
return s.isOne() || t.push(s.clone()), h(this, Fe, t), i(this, Fe);
|
|
1383
1483
|
});
|
|
1384
1484
|
a(this, "gcdDenominator", () => G.gcd(...this.getDenominators()));
|
|
1385
1485
|
a(this, "gcdNumerator", () => G.gcd(...this.getNumerators()));
|
|
@@ -1396,10 +1496,10 @@ const C = class C {
|
|
|
1396
1496
|
e.push(t.coefficient.numerator);
|
|
1397
1497
|
return e;
|
|
1398
1498
|
});
|
|
1399
|
-
a(this, "getZeroes", () => new
|
|
1499
|
+
a(this, "getZeroes", () => new wt(this.clone()).solve());
|
|
1400
1500
|
a(this, "integrate", (e, t, s = "x") => {
|
|
1401
|
-
const
|
|
1402
|
-
return
|
|
1501
|
+
const n = this.primitive(s), r = {}, l = {};
|
|
1502
|
+
return r[s] = new c(e), l[s] = new c(t), n.evaluate(l).subtract(n.evaluate(r));
|
|
1403
1503
|
});
|
|
1404
1504
|
a(this, "isDeveloped", (e) => {
|
|
1405
1505
|
let t;
|
|
@@ -1422,8 +1522,8 @@ const C = class C {
|
|
|
1422
1522
|
return t.isZero();
|
|
1423
1523
|
}
|
|
1424
1524
|
});
|
|
1425
|
-
a(this, "isEqual", (e) => i(this,
|
|
1426
|
-
a(this, "isOppositeAt", (e) => i(this,
|
|
1525
|
+
a(this, "isEqual", (e) => i(this, Qe).call(this, e, "="));
|
|
1526
|
+
a(this, "isOppositeAt", (e) => i(this, Qe).call(this, e.clone().opposite(), "="));
|
|
1427
1527
|
a(this, "isReduced", (e) => {
|
|
1428
1528
|
if (!this.isDeveloped(e))
|
|
1429
1529
|
return !1;
|
|
@@ -1435,7 +1535,7 @@ const C = class C {
|
|
|
1435
1535
|
return !1;
|
|
1436
1536
|
return !1;
|
|
1437
1537
|
});
|
|
1438
|
-
a(this, "isSameAs", (e) => i(this,
|
|
1538
|
+
a(this, "isSameAs", (e) => i(this, Qe).call(this, e, "same"));
|
|
1439
1539
|
a(this, "lcmDenominator", () => G.lcm(...this.getDenominators()));
|
|
1440
1540
|
a(this, "lcmNumerator", () => G.lcm(...this.getNumerators()));
|
|
1441
1541
|
a(this, "letters", () => {
|
|
@@ -1445,21 +1545,21 @@ const C = class C {
|
|
|
1445
1545
|
return [...e];
|
|
1446
1546
|
});
|
|
1447
1547
|
a(this, "limitToInfinity", (e) => {
|
|
1448
|
-
const t = this.monomByDegree(void 0, e), s = t.coefficient.sign(),
|
|
1449
|
-
return
|
|
1548
|
+
const t = this.monomByDegree(void 0, e), s = t.coefficient.sign(), n = t.degree(e);
|
|
1549
|
+
return n.isStrictlyPositive() ? s === 1 ? new c().infinite() : new c().infinite().opposite() : n.isZero() ? t.coefficient : new c().zero();
|
|
1450
1550
|
});
|
|
1451
1551
|
a(this, "limitToNegativeInfinity", (e) => {
|
|
1452
|
-
const t = this.monomByDegree(void 0, e), s = t.coefficient.sign(),
|
|
1453
|
-
return
|
|
1552
|
+
const t = this.monomByDegree(void 0, e), s = t.coefficient.sign(), n = t.degree(e);
|
|
1553
|
+
return n.isStrictlyPositive() ? s === -1 ? new c().infinite() : new c().infinite().opposite() : n.isZero() ? t.coefficient : new c().zero();
|
|
1454
1554
|
});
|
|
1455
1555
|
a(this, "monomByDegree", (e, t) => {
|
|
1456
1556
|
if (e === void 0)
|
|
1457
1557
|
return this.monomByDegree(this.degree(t), t);
|
|
1458
1558
|
const s = this.clone().reduce();
|
|
1459
|
-
for (const
|
|
1460
|
-
if (
|
|
1461
|
-
return
|
|
1462
|
-
return new
|
|
1559
|
+
for (const n of i(s, y))
|
|
1560
|
+
if (n.degree(t).isEqual(e))
|
|
1561
|
+
return n.clone();
|
|
1562
|
+
return new k().zero();
|
|
1463
1563
|
});
|
|
1464
1564
|
// Used in LinearSystem.tex
|
|
1465
1565
|
a(this, "monomByLetter", (e) => {
|
|
@@ -1467,18 +1567,18 @@ const C = class C {
|
|
|
1467
1567
|
for (const s of i(t, y))
|
|
1468
1568
|
if (s.hasVariable(e))
|
|
1469
1569
|
return s.clone();
|
|
1470
|
-
return new
|
|
1570
|
+
return new k().zero();
|
|
1471
1571
|
});
|
|
1472
1572
|
a(this, "monomsByDegree", (e, t) => {
|
|
1473
1573
|
if (e === void 0)
|
|
1474
1574
|
return this.monomsByDegree(this.degree(t));
|
|
1475
|
-
const s = [],
|
|
1476
|
-
for (const
|
|
1477
|
-
|
|
1575
|
+
const s = [], n = this.clone().reduce();
|
|
1576
|
+
for (const r of i(n, y))
|
|
1577
|
+
r.degree(t) === e && s.push(r.clone());
|
|
1478
1578
|
return s;
|
|
1479
1579
|
});
|
|
1480
|
-
a(this, "multiply", (e) => e instanceof C ? i(this,
|
|
1481
|
-
a(this, "one", () => (h(this, y, []), i(this, y).push(new
|
|
1580
|
+
a(this, "multiply", (e) => e instanceof C ? i(this, Ct).call(this, e) : e instanceof c ? i(this, lt).call(this, e) : e instanceof k ? i(this, kt).call(this, e) : Number.isSafeInteger(e) && typeof e == "number" ? i(this, Mt).call(this, e) : this);
|
|
1581
|
+
a(this, "one", () => (h(this, y, []), i(this, y).push(new k().one()), this));
|
|
1482
1582
|
// ------------------------------------------
|
|
1483
1583
|
a(this, "opposite", () => (h(this, y, i(this, y).map((e) => e.opposite())), this));
|
|
1484
1584
|
a(this, "pow", (e) => {
|
|
@@ -1503,7 +1603,7 @@ const C = class C {
|
|
|
1503
1603
|
let e = 0;
|
|
1504
1604
|
for (; e < i(this, y).length; ) {
|
|
1505
1605
|
for (let t = e + 1; t < i(this, y).length; t++)
|
|
1506
|
-
i(this, y)[e].isSameAs(i(this, y)[t]) && (i(this, y)[e].add(i(this, y)[t]), i(this, y).splice(t, 1), i(this, y)[e].isZero() && (i(this, y)[e] = new
|
|
1606
|
+
i(this, y)[e].isSameAs(i(this, y)[t]) && (i(this, y)[e].add(i(this, y)[t]), i(this, y).splice(t, 1), i(this, y)[e].isZero() && (i(this, y)[e] = new k().zero()), t--);
|
|
1507
1607
|
e++;
|
|
1508
1608
|
}
|
|
1509
1609
|
h(this, y, i(this, y).filter((t) => !t.coefficient.isZero()));
|
|
@@ -1513,16 +1613,16 @@ const C = class C {
|
|
|
1513
1613
|
});
|
|
1514
1614
|
a(this, "reorder", (e = "x", t) => {
|
|
1515
1615
|
t === void 0 && (t = !1);
|
|
1516
|
-
const s = this.variables.filter((
|
|
1517
|
-
return i(this, y).sort(function(
|
|
1518
|
-
const l =
|
|
1616
|
+
const s = this.variables.filter((n) => n !== e);
|
|
1617
|
+
return i(this, y).sort(function(n, r) {
|
|
1618
|
+
const l = n.degree(e).value, u = r.degree(e).value;
|
|
1519
1619
|
if (l !== u)
|
|
1520
1620
|
return t ? l - u : u - l;
|
|
1521
1621
|
if (s.length > 0)
|
|
1522
1622
|
for (const f of s) {
|
|
1523
|
-
const
|
|
1524
|
-
if (
|
|
1525
|
-
return t ?
|
|
1623
|
+
const m = n.degree(f).value, g = r.degree(f).value;
|
|
1624
|
+
if (m !== g)
|
|
1625
|
+
return t ? m - g : g - m;
|
|
1526
1626
|
}
|
|
1527
1627
|
return 0;
|
|
1528
1628
|
}), this;
|
|
@@ -1534,134 +1634,134 @@ const C = class C {
|
|
|
1534
1634
|
*/
|
|
1535
1635
|
a(this, "replaceBy", (e, t) => {
|
|
1536
1636
|
let s;
|
|
1537
|
-
const
|
|
1538
|
-
for (const
|
|
1539
|
-
!
|
|
1540
|
-
return h(this, y,
|
|
1637
|
+
const n = new C().zero();
|
|
1638
|
+
for (const r of this.monoms)
|
|
1639
|
+
!r.hasVariable(e) || r.literal[e].isZero() ? n.add(r.clone()) : (s = r.literal[e].clone(), r.removeVariable(e), n.add(t.clone().pow(Math.abs(s.numerator)).multiply(r)));
|
|
1640
|
+
return h(this, y, n.reduce().monoms), this;
|
|
1541
1641
|
});
|
|
1542
1642
|
a(this, "subtract", (...e) => {
|
|
1543
1643
|
for (const t of e)
|
|
1544
|
-
t instanceof C ? this.add(t.clone().opposite()) : t instanceof
|
|
1644
|
+
t instanceof C ? this.add(t.clone().opposite()) : t instanceof k ? i(this, y).push(t.clone().opposite()) : i(this, y).push(new k(t).opposite());
|
|
1545
1645
|
return this.reduce();
|
|
1546
1646
|
});
|
|
1547
1647
|
/**
|
|
1548
1648
|
* Set the polynom to zero.
|
|
1549
1649
|
* @returns {this}
|
|
1550
1650
|
*/
|
|
1551
|
-
a(this, "zero", () => (h(this, y, []), i(this, y).push(new
|
|
1651
|
+
a(this, "zero", () => (h(this, y, []), i(this, y).push(new k().zero()), this));
|
|
1552
1652
|
// #endregion Getters And Setters (22)
|
|
1553
1653
|
// #region Private methods (15)
|
|
1554
|
-
d(this,
|
|
1654
|
+
d(this, Qe, (e, t) => {
|
|
1555
1655
|
t === void 0 && (t = "=");
|
|
1556
|
-
const s = this.clone().reduce().reorder(),
|
|
1656
|
+
const s = this.clone().reduce().reorder(), n = e.clone().reduce().reorder();
|
|
1557
1657
|
switch (t) {
|
|
1558
1658
|
case "=":
|
|
1559
|
-
return s.length !==
|
|
1659
|
+
return s.length !== n.length || !s.degree().isEqual(n.degree()) ? !1 : s.monoms.every((r, l) => r.isEqual(n.monoms[l]));
|
|
1560
1660
|
case "same":
|
|
1561
|
-
return s.length !==
|
|
1661
|
+
return s.length !== n.length || !s.degree().isEqual(n.degree()) ? !1 : s.monoms.every((r, l) => r.isSameAs(n.monoms[l]));
|
|
1562
1662
|
default:
|
|
1563
1663
|
return !1;
|
|
1564
1664
|
}
|
|
1565
1665
|
});
|
|
1566
|
-
d(this,
|
|
1666
|
+
d(this, at, (e) => {
|
|
1567
1667
|
for (const t of i(this, y))
|
|
1568
1668
|
t.coefficient.divide(e);
|
|
1569
1669
|
return this;
|
|
1570
1670
|
});
|
|
1571
|
-
d(this,
|
|
1671
|
+
d(this, Tt, (e) => {
|
|
1572
1672
|
const t = new c(e);
|
|
1573
1673
|
for (const s of i(this, y))
|
|
1574
1674
|
s.coefficient.divide(t);
|
|
1575
1675
|
return this;
|
|
1576
1676
|
});
|
|
1577
|
-
d(this,
|
|
1677
|
+
d(this, Ot, (e) => {
|
|
1578
1678
|
let t = 0;
|
|
1579
1679
|
return i(this, y).forEach((s) => {
|
|
1580
1680
|
t += s.evaluate(e, !0);
|
|
1581
1681
|
}), t;
|
|
1582
1682
|
});
|
|
1583
|
-
d(this,
|
|
1683
|
+
d(this, At, (e) => {
|
|
1584
1684
|
var E;
|
|
1585
|
-
let t, s,
|
|
1685
|
+
let t, s, n, r, l, u, f, m, g;
|
|
1586
1686
|
if (this.numberOfVars === 1)
|
|
1587
|
-
return
|
|
1687
|
+
return n = this.monomByDegree(2, e).coefficient, r = this.monomByDegree(1, e).coefficient, l = this.monomByDegree(0, e).coefficient, u = r.clone().pow(2).subtract(n.clone().multiply(l).multiply(4)), u.isZero() ? (f = r.clone().opposite().divide(n.clone().multiply(2)), t = new C(e).subtract(f.display).multiply(f.denominator), s = new C(e).subtract(f.display).multiply(f.denominator), g = n.divide(f.denominator).divide(f.denominator), g.isOne() ? [t, s] : [new C(g.display), t, s]) : u.isPositive() && u.isSquare() ? (f = r.clone().opposite().add(u.clone().sqrt()).divide(n.clone().multiply(2)), m = r.clone().opposite().subtract(u.clone().sqrt()).divide(n.clone().multiply(2)), g = n.divide(f.denominator).divide(m.denominator), g.isOne() ? [
|
|
1588
1688
|
new C(e).subtract(f.display).multiply(f.denominator),
|
|
1589
|
-
new C(e).subtract(
|
|
1689
|
+
new C(e).subtract(m.display).multiply(m.denominator)
|
|
1590
1690
|
] : [
|
|
1591
1691
|
new C(g.display),
|
|
1592
1692
|
new C(e).subtract(f.display).multiply(f.denominator),
|
|
1593
|
-
new C(e).subtract(
|
|
1693
|
+
new C(e).subtract(m.display).multiply(m.denominator)
|
|
1594
1694
|
]) : [this.clone()];
|
|
1595
|
-
if (
|
|
1596
|
-
const L = new C("x",
|
|
1695
|
+
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))) {
|
|
1696
|
+
const L = new C("x", n.coefficient, r.coefficient, l.coefficient), te = i(E = L, At).call(E, "x"), ae = [];
|
|
1597
1697
|
let le;
|
|
1598
1698
|
if (te.length >= 2) {
|
|
1599
1699
|
for (const ge of te)
|
|
1600
|
-
ge.degree().isZero() ? ae.push(ge.clone()) : (le = ge.clone(), le.monoms[0].literal =
|
|
1700
|
+
ge.degree().isZero() ? ae.push(ge.clone()) : (le = ge.clone(), le.monoms[0].literal = n.literalSqrt, le.monoms[1].literal = l.literalSqrt, ae.push(le.clone()));
|
|
1601
1701
|
return ae;
|
|
1602
1702
|
}
|
|
1603
1703
|
}
|
|
1604
1704
|
return [this.clone()];
|
|
1605
1705
|
});
|
|
1606
1706
|
d(this, qt, (e, t, s) => {
|
|
1607
|
-
const
|
|
1608
|
-
return
|
|
1609
|
-
u.degree(s).isLeq(t) &&
|
|
1707
|
+
const n = e.monoms[0].dividers, r = e.monoms[e.monoms.length - 1].dividers, l = [];
|
|
1708
|
+
return n.forEach((u) => {
|
|
1709
|
+
u.degree(s).isLeq(t) && r.forEach((f) => {
|
|
1610
1710
|
u.degree(s).isNotEqual(f.degree(s)) && (l.push(new C(u, f)), l.push(new C(u, f.clone().opposite())));
|
|
1611
1711
|
});
|
|
1612
1712
|
}), l;
|
|
1613
1713
|
});
|
|
1614
|
-
d(this,
|
|
1714
|
+
d(this, lt, (e) => {
|
|
1615
1715
|
for (const t of i(this, y))
|
|
1616
1716
|
t.coefficient.multiply(e);
|
|
1617
1717
|
return this.reduce();
|
|
1618
1718
|
});
|
|
1619
|
-
d(this,
|
|
1620
|
-
d(this,
|
|
1719
|
+
d(this, Mt, (e) => i(this, lt).call(this, new c(e)));
|
|
1720
|
+
d(this, kt, (e) => {
|
|
1621
1721
|
for (const t of i(this, y))
|
|
1622
1722
|
t.multiply(e);
|
|
1623
1723
|
return this.reduce();
|
|
1624
1724
|
});
|
|
1625
|
-
d(this,
|
|
1725
|
+
d(this, Ct, (e) => {
|
|
1626
1726
|
const t = [];
|
|
1627
1727
|
for (const s of i(this, y))
|
|
1628
|
-
for (const
|
|
1629
|
-
t.push(
|
|
1728
|
+
for (const n of e.monoms)
|
|
1729
|
+
t.push(k.xMultiply(s, n));
|
|
1630
1730
|
return h(this, y, t), this.reduce();
|
|
1631
1731
|
});
|
|
1632
|
-
d(this,
|
|
1732
|
+
d(this, It, (e, t) => {
|
|
1633
1733
|
switch (t.tokenType) {
|
|
1634
|
-
case
|
|
1734
|
+
case p.COEFFICIENT:
|
|
1635
1735
|
e.push(new C(t.token));
|
|
1636
1736
|
break;
|
|
1637
|
-
case
|
|
1638
|
-
e.push(new C().add(new
|
|
1737
|
+
case p.VARIABLE:
|
|
1738
|
+
e.push(new C().add(new k(t.token)));
|
|
1639
1739
|
break;
|
|
1640
|
-
case
|
|
1740
|
+
case p.CONSTANT:
|
|
1641
1741
|
console.log("Actually, not supported - will be added later !");
|
|
1642
1742
|
break;
|
|
1643
|
-
case
|
|
1743
|
+
case p.OPERATION:
|
|
1644
1744
|
if (e.length >= 2) {
|
|
1645
|
-
const s = e.pop(),
|
|
1646
|
-
if (
|
|
1745
|
+
const s = e.pop(), n = e.pop();
|
|
1746
|
+
if (n === void 0 || s === void 0)
|
|
1647
1747
|
break;
|
|
1648
1748
|
if (t.token === "+")
|
|
1649
|
-
e.push(
|
|
1749
|
+
e.push(n.add(s));
|
|
1650
1750
|
else if (t.token === "-")
|
|
1651
|
-
e.push(
|
|
1751
|
+
e.push(n.subtract(s));
|
|
1652
1752
|
else if (t.token === "*")
|
|
1653
|
-
e.push(
|
|
1753
|
+
e.push(n.multiply(s));
|
|
1654
1754
|
else if (t.token === "/")
|
|
1655
|
-
s.degree().isStrictlyPositive() ? console.log("divide by a polynom -> should create a rational polynom !") : e.push(
|
|
1755
|
+
s.degree().isStrictlyPositive() ? console.log("divide by a polynom -> should create a rational polynom !") : e.push(n.divide(s.monoms[0].coefficient));
|
|
1656
1756
|
else if (t.token === "^")
|
|
1657
1757
|
if (s.degree().isStrictlyPositive())
|
|
1658
|
-
console.error("Cannot elevate a polynom with another polynom !",
|
|
1758
|
+
console.error("Cannot elevate a polynom with another polynom !", n.tex, s.tex);
|
|
1659
1759
|
else if (s.monoms[0].coefficient.isRelative())
|
|
1660
|
-
e.push(
|
|
1661
|
-
else if (
|
|
1662
|
-
for (const
|
|
1663
|
-
|
|
1664
|
-
e.push(
|
|
1760
|
+
e.push(n.pow(s.monoms[0].coefficient.value));
|
|
1761
|
+
else if (n.monoms.length === 1 && n.monoms[0].coefficient.isOne()) {
|
|
1762
|
+
for (const r in n.monoms[0].literal)
|
|
1763
|
+
n.monoms[0].literal[r].multiply(s.monoms[0].coefficient);
|
|
1764
|
+
e.push(n);
|
|
1665
1765
|
} else
|
|
1666
1766
|
console.error("Cannot have power with fraction");
|
|
1667
1767
|
} else if (t.token === "-") {
|
|
@@ -1670,37 +1770,37 @@ const C = class C {
|
|
|
1670
1770
|
} else
|
|
1671
1771
|
throw new Error("Error parsing the polynom");
|
|
1672
1772
|
break;
|
|
1673
|
-
case
|
|
1773
|
+
case p.MONOM:
|
|
1674
1774
|
console.error("The monom token should not appear here");
|
|
1675
1775
|
break;
|
|
1676
|
-
case
|
|
1776
|
+
case p.FUNCTION:
|
|
1677
1777
|
console.error("The function token should not appear here - might be introduced later.");
|
|
1678
1778
|
break;
|
|
1679
1779
|
}
|
|
1680
1780
|
});
|
|
1681
|
-
d(this,
|
|
1682
|
-
let
|
|
1781
|
+
d(this, Ke, (e, t, s, n) => {
|
|
1782
|
+
let r = "";
|
|
1683
1783
|
for (const l of i(this, y)) {
|
|
1684
1784
|
if (l.coefficient.value === 0)
|
|
1685
1785
|
continue;
|
|
1686
1786
|
let u;
|
|
1687
|
-
|
|
1787
|
+
n ? u = l.plotFunction : u = e === "tex" ? l.tex : l.display, r += `${l.coefficient.sign() === 1 && (r !== "" || t === !0) ? "+" : ""}${u}`;
|
|
1688
1788
|
}
|
|
1689
|
-
return s === !0 && this.length > 1 && (e === "tex" ?
|
|
1789
|
+
return s === !0 && this.length > 1 && (e === "tex" ? r = `\\left( ${r} \\right)` : r = `(${r})`), r === "" && (r = "0"), r;
|
|
1690
1790
|
});
|
|
1691
1791
|
/**
|
|
1692
1792
|
* Main parse using a shutting yard class
|
|
1693
1793
|
* @param inputStr
|
|
1694
1794
|
*/
|
|
1695
|
-
d(this,
|
|
1696
|
-
const s = new
|
|
1795
|
+
d(this, Bt, (e) => {
|
|
1796
|
+
const s = new Gt().parse(e).rpn;
|
|
1697
1797
|
this.zero();
|
|
1698
|
-
const
|
|
1699
|
-
for (const
|
|
1700
|
-
i(this,
|
|
1701
|
-
return
|
|
1798
|
+
const n = [];
|
|
1799
|
+
for (const r of s)
|
|
1800
|
+
i(this, It).call(this, n, r);
|
|
1801
|
+
return n.length === 1 && this.add(n[0]), this.reorder();
|
|
1702
1802
|
});
|
|
1703
|
-
return h(this, y, []), h(this,
|
|
1803
|
+
return h(this, y, []), h(this, Fe, []), e !== void 0 && this.parse(e, ...t), this;
|
|
1704
1804
|
}
|
|
1705
1805
|
hasVariable(e) {
|
|
1706
1806
|
return this.variables.includes(e);
|
|
@@ -1723,7 +1823,7 @@ const C = class C {
|
|
|
1723
1823
|
// #region Getters And Setters (22)
|
|
1724
1824
|
// ------------------------------------------
|
|
1725
1825
|
get display() {
|
|
1726
|
-
return i(this,
|
|
1826
|
+
return i(this, Ke).call(this);
|
|
1727
1827
|
}
|
|
1728
1828
|
get isMultiVariable() {
|
|
1729
1829
|
return i(this, y).some((e) => e.variables.length > 1);
|
|
@@ -1742,10 +1842,10 @@ const C = class C {
|
|
|
1742
1842
|
return this.variables.length;
|
|
1743
1843
|
}
|
|
1744
1844
|
get plotFunction() {
|
|
1745
|
-
return i(this,
|
|
1845
|
+
return i(this, Ke).call(this, "tex", !1, !1, !0);
|
|
1746
1846
|
}
|
|
1747
1847
|
get tex() {
|
|
1748
|
-
return i(this,
|
|
1848
|
+
return i(this, Ke).call(this, "tex");
|
|
1749
1849
|
}
|
|
1750
1850
|
get variables() {
|
|
1751
1851
|
let e = [];
|
|
@@ -1758,53 +1858,53 @@ const C = class C {
|
|
|
1758
1858
|
}
|
|
1759
1859
|
// #endregion Private methods (15)
|
|
1760
1860
|
};
|
|
1761
|
-
|
|
1861
|
+
Fe = new WeakMap(), y = new WeakMap(), Qe = new WeakMap(), at = new WeakMap(), Tt = new WeakMap(), Ot = new WeakMap(), At = new WeakMap(), qt = new WeakMap(), lt = new WeakMap(), Mt = new WeakMap(), kt = new WeakMap(), Ct = new WeakMap(), $t = new WeakSet(), wi = function(e, ...t) {
|
|
1762
1862
|
if (t.length === 0) {
|
|
1763
1863
|
if (e = "" + e, e !== "" && !isNaN(Number(e))) {
|
|
1764
1864
|
this.empty();
|
|
1765
|
-
const s = new
|
|
1865
|
+
const s = new k(e);
|
|
1766
1866
|
return this.add(s), this;
|
|
1767
1867
|
}
|
|
1768
|
-
return i(this,
|
|
1868
|
+
return i(this, Bt).call(this, e);
|
|
1769
1869
|
} else if (/^[a-z]+/.test(e)) {
|
|
1770
1870
|
this.empty();
|
|
1771
|
-
const s = t.map((
|
|
1871
|
+
const s = t.map((n) => new c(n));
|
|
1772
1872
|
if (e.length > 1) {
|
|
1773
|
-
const
|
|
1774
|
-
let
|
|
1873
|
+
const n = e.split("");
|
|
1874
|
+
let r = 0;
|
|
1775
1875
|
for (const l of s) {
|
|
1776
|
-
const u = new
|
|
1777
|
-
u.coefficient = l.clone(), u.literalStr = r
|
|
1876
|
+
const u = new k();
|
|
1877
|
+
u.coefficient = l.clone(), u.literalStr = n[r] || "", this.add(u), r++;
|
|
1778
1878
|
}
|
|
1779
1879
|
} else {
|
|
1780
|
-
let
|
|
1781
|
-
for (const
|
|
1782
|
-
const l = new
|
|
1783
|
-
l.coefficient =
|
|
1880
|
+
let n = s.length - 1;
|
|
1881
|
+
for (const r of s) {
|
|
1882
|
+
const l = new k();
|
|
1883
|
+
l.coefficient = r.clone(), l.literalStr = `${e}^${n}`, this.add(l), n--;
|
|
1784
1884
|
}
|
|
1785
1885
|
}
|
|
1786
1886
|
return this;
|
|
1787
1887
|
} else
|
|
1788
1888
|
return this.zero();
|
|
1789
|
-
},
|
|
1790
|
-
let
|
|
1791
|
-
function
|
|
1889
|
+
}, It = new WeakMap(), Ke = new WeakMap(), Bt = new WeakMap();
|
|
1890
|
+
let A = C;
|
|
1891
|
+
function ci(o, e = !0) {
|
|
1792
1892
|
return e ? `\\left( ${o} \\right)` : `(${o})`;
|
|
1793
1893
|
}
|
|
1794
|
-
var Ee,
|
|
1894
|
+
var Ee, Je, Ne, Te;
|
|
1795
1895
|
const we = class we {
|
|
1796
1896
|
constructor(e, t) {
|
|
1797
1897
|
d(this, Ee);
|
|
1798
|
-
d(this,
|
|
1898
|
+
d(this, Je, !1);
|
|
1799
1899
|
d(this, Ne);
|
|
1800
|
-
d(this,
|
|
1900
|
+
d(this, Te);
|
|
1801
1901
|
if (e instanceof we)
|
|
1802
|
-
h(this, Ne, e.polynom.clone()), h(this,
|
|
1902
|
+
h(this, Ne, e.polynom.clone()), h(this, Te, e.power.clone());
|
|
1803
1903
|
else if (typeof e == "string" && t === void 0) {
|
|
1804
|
-
const [s,
|
|
1805
|
-
h(this, Ne, new
|
|
1904
|
+
const [s, n = "1"] = e.split("^");
|
|
1905
|
+
h(this, Ne, new A(s)), h(this, Te, new c(n.replace("(", "").replace(")", "")));
|
|
1806
1906
|
} else
|
|
1807
|
-
h(this, Ne, new
|
|
1907
|
+
h(this, Ne, new A(e)), h(this, Te, new c(t ?? 1));
|
|
1808
1908
|
return h(this, Ee, 1), this;
|
|
1809
1909
|
}
|
|
1810
1910
|
parse() {
|
|
@@ -1823,7 +1923,7 @@ const we = class we {
|
|
|
1823
1923
|
return h(this, Ee, 0), this;
|
|
1824
1924
|
}
|
|
1825
1925
|
get asSingle() {
|
|
1826
|
-
return h(this,
|
|
1926
|
+
return h(this, Je, !0), this;
|
|
1827
1927
|
}
|
|
1828
1928
|
degree(e) {
|
|
1829
1929
|
return this.polynom.degree(e).multiply(this.power);
|
|
@@ -1842,13 +1942,13 @@ const we = class we {
|
|
|
1842
1942
|
}
|
|
1843
1943
|
get display() {
|
|
1844
1944
|
const e = this.power.numerator, t = this.power.denominator;
|
|
1845
|
-
let s,
|
|
1846
|
-
return i(this, Ee) === 0 && t > 1 ? (s = `${t === 2 ? "sqrt" : `root(${t})`}(${this.polynom.display})`,
|
|
1945
|
+
let s, n;
|
|
1946
|
+
return i(this, Ee) === 0 && t > 1 ? (s = `${t === 2 ? "sqrt" : `root(${t})`}(${this.polynom.display})`, n = Math.abs(e) === 1 ? "" : `^(${Math.abs(e)})`) : (s = i(this, Je) && this.power.isOne() ? this.polynom.display : ci(this.polynom.display, !1), n = t === 1 && Math.abs(e) === 1 ? "" : `^(${this.power.display})`), s = `${s}${n}`, i(this, Ee) === 0 && e < 0 && (s = `1/(${s})`), s;
|
|
1847
1947
|
}
|
|
1848
1948
|
divide(e) {
|
|
1849
1949
|
if (e instanceof we && this.isSameAs(e))
|
|
1850
1950
|
return this.power.subtract(e.power), this;
|
|
1851
|
-
const t = new
|
|
1951
|
+
const t = new A(e);
|
|
1852
1952
|
if (this.isSameAs(t))
|
|
1853
1953
|
return this.power.subtract(1), this;
|
|
1854
1954
|
throw new Error("The two factors must be the same");
|
|
@@ -1870,7 +1970,7 @@ const we = class we {
|
|
|
1870
1970
|
}
|
|
1871
1971
|
isSameAs(e) {
|
|
1872
1972
|
let t;
|
|
1873
|
-
return e instanceof we ? t = e.polynom : e instanceof
|
|
1973
|
+
return e instanceof we ? t = e.polynom : e instanceof A ? t = e : t = new A(e), this.polynom.isEqual(t);
|
|
1874
1974
|
}
|
|
1875
1975
|
isZero() {
|
|
1876
1976
|
return this.polynom.isZero();
|
|
@@ -1878,13 +1978,13 @@ const we = class we {
|
|
|
1878
1978
|
multiply(e) {
|
|
1879
1979
|
if (e instanceof we && this.isSameAs(e))
|
|
1880
1980
|
return this.power.add(e.power), this;
|
|
1881
|
-
const t = new
|
|
1981
|
+
const t = new A(e);
|
|
1882
1982
|
if (this.isSameAs(t))
|
|
1883
1983
|
return this.power.add(1), this;
|
|
1884
1984
|
throw new Error("The two factors must be the same");
|
|
1885
1985
|
}
|
|
1886
1986
|
one() {
|
|
1887
|
-
return i(this, Ne).one(), i(this,
|
|
1987
|
+
return i(this, Ne).one(), i(this, Te).one(), this;
|
|
1888
1988
|
}
|
|
1889
1989
|
opposite() {
|
|
1890
1990
|
throw new Error("Method not implemented.");
|
|
@@ -1899,10 +1999,10 @@ const we = class we {
|
|
|
1899
1999
|
return this.power.multiply(e), this;
|
|
1900
2000
|
}
|
|
1901
2001
|
get power() {
|
|
1902
|
-
return i(this,
|
|
2002
|
+
return i(this, Te);
|
|
1903
2003
|
}
|
|
1904
2004
|
set power(e) {
|
|
1905
|
-
h(this,
|
|
2005
|
+
h(this, Te, new c(e));
|
|
1906
2006
|
}
|
|
1907
2007
|
primitive() {
|
|
1908
2008
|
throw new Error("Method not implemented.");
|
|
@@ -1921,44 +2021,44 @@ const we = class we {
|
|
|
1921
2021
|
}
|
|
1922
2022
|
get tex() {
|
|
1923
2023
|
const e = this.power.numerator, t = this.power.denominator;
|
|
1924
|
-
let s,
|
|
1925
|
-
return i(this, Ee) === 0 && t > 1 ? (s = `\\sqrt${t === 2 ? "" : `[ ${t} ]`}{ ${this.polynom.tex} }`,
|
|
2024
|
+
let s, n;
|
|
2025
|
+
return i(this, Ee) === 0 && t > 1 ? (s = `\\sqrt${t === 2 ? "" : `[ ${t} ]`}{ ${this.polynom.tex} }`, n = Math.abs(e) === 1 ? "" : `^{ ${Math.abs(e)} }`) : (s = i(this, Je) && this.power.isOne() ? this.polynom.tex : ci(this.polynom.tex), n = t === 1 && Math.abs(e) === 1 ? "" : `^{ ${this.power.tex} }`), s = `${s}${n}`, i(this, Ee) === 0 && e < 0 && (s = `\\frac{ 1 }{ ${s} }`), s;
|
|
1926
2026
|
}
|
|
1927
2027
|
get variables() {
|
|
1928
2028
|
return this.polynom.variables;
|
|
1929
2029
|
}
|
|
1930
2030
|
zero() {
|
|
1931
|
-
return i(this, Ne).zero(), i(this,
|
|
2031
|
+
return i(this, Ne).zero(), i(this, Te).one(), this;
|
|
1932
2032
|
}
|
|
1933
2033
|
};
|
|
1934
|
-
Ee = new WeakMap(),
|
|
2034
|
+
Ee = new WeakMap(), Je = new WeakMap(), Ne = new WeakMap(), Te = new WeakMap();
|
|
1935
2035
|
let fe = we;
|
|
1936
|
-
var
|
|
2036
|
+
var We = /* @__PURE__ */ ((o) => (o[o.ROOT = 0] = "ROOT", o[o.POWER = 1] = "POWER", o))(We || {}), O, M, ne, St, _e, Pt;
|
|
1937
2037
|
const xe = class xe {
|
|
1938
2038
|
constructor(e, t, s) {
|
|
1939
2039
|
// Left part of the equation
|
|
1940
|
-
d(this,
|
|
2040
|
+
d(this, O);
|
|
1941
2041
|
// Right part of the equation
|
|
1942
|
-
d(this,
|
|
2042
|
+
d(this, M);
|
|
1943
2043
|
// Signe of the equation
|
|
1944
|
-
d(this,
|
|
2044
|
+
d(this, ne);
|
|
1945
2045
|
// #endregion Constructors (3)
|
|
1946
2046
|
// #region Properties and methods (26)
|
|
1947
2047
|
// ------------------------------------------
|
|
1948
2048
|
a(this, "parse", (e) => {
|
|
1949
|
-
const t = i(this,
|
|
2049
|
+
const t = i(this, St).call(this, e);
|
|
1950
2050
|
if (t === !1)
|
|
1951
2051
|
throw new Error("The equation is not valid (no sign found)");
|
|
1952
2052
|
const s = e.split(t);
|
|
1953
|
-
return this.create(new
|
|
2053
|
+
return this.create(new A(s[0]), new A(s[1]), i(this, _e).call(this, t));
|
|
1954
2054
|
});
|
|
1955
|
-
a(this, "create", (e, t, s) => (h(this,
|
|
1956
|
-
a(this, "clone", () => new xe(i(this,
|
|
2055
|
+
a(this, "create", (e, t, s) => (h(this, O, e), h(this, M, t), h(this, ne, i(this, _e).call(this, s ?? "=")), this));
|
|
2056
|
+
a(this, "clone", () => new xe(i(this, O).clone(), i(this, M).clone(), i(this, ne)));
|
|
1957
2057
|
/**
|
|
1958
2058
|
* Get the degree of the equation
|
|
1959
2059
|
* @param letter
|
|
1960
2060
|
*/
|
|
1961
|
-
a(this, "degree", (e) => c.max(i(this,
|
|
2061
|
+
a(this, "degree", (e) => c.max(i(this, O).degree(e), i(this, M).degree(e)));
|
|
1962
2062
|
/**
|
|
1963
2063
|
* divide an equation by a given value (transformed as a fraction)
|
|
1964
2064
|
*
|
|
@@ -1989,7 +2089,7 @@ const xe = class xe {
|
|
|
1989
2089
|
/**
|
|
1990
2090
|
* Determine if the equation contains more than one letter/variable.
|
|
1991
2091
|
*/
|
|
1992
|
-
a(this, "isMultiVariable", () => i(this,
|
|
2092
|
+
a(this, "isMultiVariable", () => i(this, O).isMultiVariable || i(this, M).isMultiVariable);
|
|
1993
2093
|
// -----------------------------------------------
|
|
1994
2094
|
// Equations helpers
|
|
1995
2095
|
a(this, "isEqualTo", (e) => {
|
|
@@ -2004,49 +2104,49 @@ const xe = class xe {
|
|
|
2004
2104
|
if (!this.degree(e).isOne() || this.isMultiVariable())
|
|
2005
2105
|
return !1;
|
|
2006
2106
|
let t;
|
|
2007
|
-
i(this,
|
|
2008
|
-
const s = [...i(this,
|
|
2009
|
-
for (const
|
|
2010
|
-
|
|
2011
|
-
if (i(this,
|
|
2107
|
+
i(this, O).subtract(i(this, M)), i(this, M).zero();
|
|
2108
|
+
const s = [...i(this, O).monoms];
|
|
2109
|
+
for (const r of s)
|
|
2110
|
+
r.hasVariable(e) || (t = r.clone(), i(this, O).subtract(t), i(this, M).subtract(t));
|
|
2111
|
+
if (i(this, O).length !== 1)
|
|
2012
2112
|
return !1;
|
|
2013
|
-
const
|
|
2014
|
-
return i(this,
|
|
2113
|
+
const n = i(this, O).monoms[0].coefficient.clone();
|
|
2114
|
+
return i(this, O).divide(n), i(this, M).divide(n), this;
|
|
2015
2115
|
});
|
|
2016
2116
|
// -----------------------------------------------
|
|
2017
2117
|
// Equations operations
|
|
2018
2118
|
// -----------------------------------------------
|
|
2019
|
-
a(this, "letters", () => [.../* @__PURE__ */ new Set([...i(this,
|
|
2119
|
+
a(this, "letters", () => [.../* @__PURE__ */ new Set([...i(this, O).letters(), ...i(this, M).letters()])]);
|
|
2020
2120
|
// -----------------------------------------------
|
|
2021
2121
|
/**
|
|
2022
2122
|
* Reorder will move all monoms containing a letter on the left, all the other on the right.
|
|
2023
2123
|
*/
|
|
2024
|
-
a(this, "moveLeft", () => (i(this,
|
|
2124
|
+
a(this, "moveLeft", () => (i(this, O).subtract(i(this, M)), i(this, M).zero(), this));
|
|
2025
2125
|
/**
|
|
2026
2126
|
* Multiple an equation by a fraction value.
|
|
2027
2127
|
* @param value
|
|
2028
2128
|
*/
|
|
2029
2129
|
a(this, "multiply", (e) => {
|
|
2030
2130
|
const t = new c(e);
|
|
2031
|
-
return i(this,
|
|
2131
|
+
return i(this, O).multiply(t), i(this, M).multiply(t), i(this, ne) !== "=" && t.sign() === -1 && i(this, Pt).call(this), this;
|
|
2032
2132
|
});
|
|
2033
|
-
a(this, "opposite", () => (h(this,
|
|
2034
|
-
a(this, "reorder", (e) => (i(this,
|
|
2133
|
+
a(this, "opposite", () => (h(this, O, i(this, O).opposite()), h(this, M, i(this, M).opposite()), this));
|
|
2134
|
+
a(this, "reorder", (e) => (i(this, O).subtract(i(this, M)), i(this, M).zero(), i(this, O).reorder(), e ? this : (i(this, O).monoms.filter((t) => t.degree().isZero()).forEach((t) => {
|
|
2035
2135
|
const s = t.clone();
|
|
2036
|
-
i(this,
|
|
2037
|
-
}), i(this,
|
|
2136
|
+
i(this, O).subtract(s), i(this, M).subtract(s);
|
|
2137
|
+
}), i(this, O).reorder(), i(this, M).reorder(), this)));
|
|
2038
2138
|
// ------------------------------------------
|
|
2039
|
-
a(this, "replaceBy", (e, t) => (i(this,
|
|
2139
|
+
a(this, "replaceBy", (e, t) => (i(this, O).replaceBy(e, t), i(this, M).replaceBy(e, t), this));
|
|
2040
2140
|
/**
|
|
2041
2141
|
* Multiply by the lcm denominator and divide by the gcm numerators.
|
|
2042
2142
|
*/
|
|
2043
|
-
a(this, "simplify", () => (this.multiply(G.lcm(...i(this,
|
|
2143
|
+
a(this, "simplify", () => (this.multiply(G.lcm(...i(this, O).getDenominators(), ...i(this, M).getDenominators())), this.divide(G.gcd(...i(this, O).getNumerators(), ...i(this, M).getNumerators())), this));
|
|
2044
2144
|
// -----------------------------------------------
|
|
2045
|
-
a(this, "solve", () => new
|
|
2145
|
+
a(this, "solve", () => new wt(this.clone()).solve());
|
|
2046
2146
|
a(this, "test", (e) => this.left.evaluate(e).isEqual(this.right.evaluate(e)));
|
|
2047
2147
|
// #endregion Getters And Setters (13)
|
|
2048
2148
|
// #region Private methods (6)
|
|
2049
|
-
d(this,
|
|
2149
|
+
d(this, St, (e) => {
|
|
2050
2150
|
if (e.includes("geq"))
|
|
2051
2151
|
return e.includes("\\geq") ? "\\geq" : "geq";
|
|
2052
2152
|
if (e.includes("leq"))
|
|
@@ -2069,13 +2169,13 @@ const xe = class xe {
|
|
|
2069
2169
|
});
|
|
2070
2170
|
// -----------------------------------------------
|
|
2071
2171
|
// Equations solving algorithms
|
|
2072
|
-
d(this,
|
|
2073
|
-
d(this,
|
|
2074
|
-
if (h(this,
|
|
2172
|
+
d(this, _e, (e) => e === void 0 ? "=" : e.includes("geq") || e.includes(">=") || e.includes("=>") ? ">=" : e.includes(">") ? ">" : e.includes("leq") || e.includes("<=") || e.includes("=<") ? "<=" : e.includes("<") ? "<" : "=");
|
|
2173
|
+
d(this, Pt, () => i(this, ne) === "=" ? this : i(this, ne).includes("<") ? (i(this, ne).replace("<", ">"), this) : i(this, ne).includes(">") ? (i(this, ne).replace(">", "<"), this) : this);
|
|
2174
|
+
if (h(this, O, new A().zero()), h(this, M, new A().zero()), h(this, ne, "="), e !== void 0 && t === void 0) {
|
|
2075
2175
|
if (e instanceof xe)
|
|
2076
2176
|
return e.clone();
|
|
2077
2177
|
typeof e == "string" && this.parse(e);
|
|
2078
|
-
} else e !== void 0 && t !== void 0 && (this.left = new
|
|
2178
|
+
} else e !== void 0 && t !== void 0 && (this.left = new A(e), this.right = new A(t));
|
|
2079
2179
|
return s !== void 0 && (this.sign = s), this;
|
|
2080
2180
|
}
|
|
2081
2181
|
/**
|
|
@@ -2088,11 +2188,11 @@ const xe = class xe {
|
|
|
2088
2188
|
*/
|
|
2089
2189
|
add(e) {
|
|
2090
2190
|
if (e instanceof xe)
|
|
2091
|
-
return i(this,
|
|
2191
|
+
return i(this, O).add(e.left), i(this, M).add(e.right), this;
|
|
2092
2192
|
if (typeof e == "string" && !xe.isEquationString(e))
|
|
2093
2193
|
return this.add(new xe(e));
|
|
2094
|
-
const t = new
|
|
2095
|
-
return i(this,
|
|
2194
|
+
const t = new A(e);
|
|
2195
|
+
return i(this, O).add(t), i(this, M).add(t), this;
|
|
2096
2196
|
}
|
|
2097
2197
|
/**
|
|
2098
2198
|
* Create an Equation using two polynoms.
|
|
@@ -2101,86 +2201,86 @@ const xe = class xe {
|
|
|
2101
2201
|
* @param asNumeric
|
|
2102
2202
|
*/
|
|
2103
2203
|
evaluate(e, t) {
|
|
2104
|
-
const s = i(this,
|
|
2105
|
-
return t ? s ===
|
|
2204
|
+
const s = i(this, O).evaluate(e, t), n = i(this, M).evaluate(e, t);
|
|
2205
|
+
return t ? s === n : s.isEqual(n);
|
|
2106
2206
|
}
|
|
2107
2207
|
isEqual(e) {
|
|
2108
2208
|
const t = new xe(e);
|
|
2109
|
-
return t.left.isEqual(i(this,
|
|
2209
|
+
return t.left.isEqual(i(this, O)) && t.right.isEqual(i(this, M));
|
|
2110
2210
|
}
|
|
2111
2211
|
pow(e) {
|
|
2112
|
-
return i(this,
|
|
2212
|
+
return i(this, O).pow(e), i(this, M).pow(e), this;
|
|
2113
2213
|
}
|
|
2114
2214
|
reduce() {
|
|
2115
|
-
return this.moveLeft(), i(this,
|
|
2215
|
+
return this.moveLeft(), i(this, O).reduce(), this.simplify(), i(this, O).monoms[0].coefficient.isNegative() && this.multiply(-1), this;
|
|
2116
2216
|
}
|
|
2117
2217
|
split() {
|
|
2118
|
-
return [i(this,
|
|
2218
|
+
return [i(this, O).clone(), i(this, M).clone()];
|
|
2119
2219
|
}
|
|
2120
2220
|
subtract(e) {
|
|
2121
2221
|
if (e instanceof xe)
|
|
2122
|
-
return i(this,
|
|
2222
|
+
return i(this, O).subtract(e.left), i(this, M).subtract(e.right), this;
|
|
2123
2223
|
if (typeof e == "string" && !xe.isEquationString(e))
|
|
2124
2224
|
return this.subtract(new xe(e));
|
|
2125
|
-
const t = new
|
|
2126
|
-
return i(this,
|
|
2225
|
+
const t = new A(e);
|
|
2226
|
+
return i(this, O).subtract(t), i(this, M).subtract(t), this;
|
|
2127
2227
|
}
|
|
2128
2228
|
static isEquationString(e) {
|
|
2129
2229
|
return e.includes("=") || e.includes("<") || e.includes(">") || e.includes("<=") || e.includes(">=");
|
|
2130
2230
|
}
|
|
2131
2231
|
static makeSolutionsUnique(e, t) {
|
|
2132
|
-
const s = [],
|
|
2133
|
-
return t === !0 &&
|
|
2232
|
+
const s = [], n = e.filter((r) => s.includes(r.tex) ? !1 : (s.push(r.tex), !0));
|
|
2233
|
+
return t === !0 && n.sort((r, l) => r.value - l.value), n;
|
|
2134
2234
|
}
|
|
2135
2235
|
// #endregion Properties and methods (26)
|
|
2136
2236
|
// #region Getters And Setters (13)
|
|
2137
2237
|
get display() {
|
|
2138
|
-
return `${i(this,
|
|
2238
|
+
return `${i(this, O).display}${this.signAsTex}${i(this, M).display}`;
|
|
2139
2239
|
}
|
|
2140
2240
|
// Getter and setter
|
|
2141
2241
|
get left() {
|
|
2142
|
-
return i(this,
|
|
2242
|
+
return i(this, O);
|
|
2143
2243
|
}
|
|
2144
2244
|
set left(e) {
|
|
2145
|
-
h(this,
|
|
2245
|
+
h(this, O, e);
|
|
2146
2246
|
}
|
|
2147
2247
|
get numberOfVars() {
|
|
2148
2248
|
return this.variables.length;
|
|
2149
2249
|
}
|
|
2150
2250
|
get right() {
|
|
2151
|
-
return i(this,
|
|
2251
|
+
return i(this, M);
|
|
2152
2252
|
}
|
|
2153
2253
|
set right(e) {
|
|
2154
|
-
h(this,
|
|
2254
|
+
h(this, M, e);
|
|
2155
2255
|
}
|
|
2156
2256
|
// ------------------------------------------
|
|
2157
2257
|
get sign() {
|
|
2158
|
-
return i(this,
|
|
2258
|
+
return i(this, ne);
|
|
2159
2259
|
}
|
|
2160
2260
|
set sign(e) {
|
|
2161
|
-
h(this,
|
|
2261
|
+
h(this, ne, i(this, _e).call(this, e));
|
|
2162
2262
|
}
|
|
2163
2263
|
get signAsTex() {
|
|
2164
|
-
return i(this,
|
|
2264
|
+
return i(this, ne) === ">=" ? "\\geq" : i(this, ne) === "<=" ? "\\leq" : i(this, ne);
|
|
2165
2265
|
}
|
|
2166
2266
|
get tex() {
|
|
2167
|
-
return `${i(this,
|
|
2267
|
+
return `${i(this, O).tex}${this.signAsTex}${i(this, M).tex}`;
|
|
2168
2268
|
}
|
|
2169
2269
|
get variables() {
|
|
2170
|
-
return [...new Set(i(this,
|
|
2270
|
+
return [...new Set(i(this, M).variables.concat(i(this, O).variables))];
|
|
2171
2271
|
}
|
|
2172
2272
|
// #endregion Private methods (6)
|
|
2173
2273
|
};
|
|
2174
|
-
|
|
2274
|
+
O = new WeakMap(), M = new WeakMap(), ne = new WeakMap(), St = new WeakMap(), _e = new WeakMap(), Pt = new WeakMap();
|
|
2175
2275
|
let H = xe;
|
|
2176
|
-
var N,
|
|
2276
|
+
var N, je, ct, Jt;
|
|
2177
2277
|
const me = class me {
|
|
2178
2278
|
// #endregion Class fields (1)
|
|
2179
2279
|
// #region Constructors (1)
|
|
2180
2280
|
constructor(...e) {
|
|
2181
2281
|
// #region Class fields (1)
|
|
2182
2282
|
d(this, N, []);
|
|
2183
|
-
d(this,
|
|
2283
|
+
d(this, je, We.POWER);
|
|
2184
2284
|
return this.parse(...e), this;
|
|
2185
2285
|
}
|
|
2186
2286
|
// #endregion Constructors (1)
|
|
@@ -2189,12 +2289,12 @@ const me = class me {
|
|
|
2189
2289
|
return e.length === 0 ? this : (h(this, N, []), e.forEach((t) => {
|
|
2190
2290
|
if (typeof t == "string") {
|
|
2191
2291
|
const s = t.split(")(").join(")*(").split("*");
|
|
2192
|
-
i(this, N).push(...s.map((
|
|
2292
|
+
i(this, N).push(...s.map((n) => new fe(n)));
|
|
2193
2293
|
} else t instanceof me ? i(this, N).push(...t.factors.map((s) => s.clone())) : i(this, N).push(new fe(t));
|
|
2194
2294
|
}), this);
|
|
2195
2295
|
}
|
|
2196
2296
|
fromPolynom(e, t) {
|
|
2197
|
-
return h(this, N, new
|
|
2297
|
+
return h(this, N, new A(e).factorize(t).map((s) => new fe(s))), this;
|
|
2198
2298
|
}
|
|
2199
2299
|
clone() {
|
|
2200
2300
|
return new me(...i(this, N).map((e) => e.clone()));
|
|
@@ -2202,11 +2302,11 @@ const me = class me {
|
|
|
2202
2302
|
add(...e) {
|
|
2203
2303
|
let t = [this, ...e];
|
|
2204
2304
|
const s = me.gcd(...t);
|
|
2205
|
-
t = t.map((
|
|
2206
|
-
const
|
|
2207
|
-
return t.forEach((
|
|
2305
|
+
t = t.map((r) => r.divide(s).reduce());
|
|
2306
|
+
const n = new A("0");
|
|
2307
|
+
return t.forEach((r) => n.add(r.develop())), h(this, N, [
|
|
2208
2308
|
...s.factors,
|
|
2209
|
-
new fe(
|
|
2309
|
+
new fe(n)
|
|
2210
2310
|
]), this;
|
|
2211
2311
|
}
|
|
2212
2312
|
degree(e) {
|
|
@@ -2214,16 +2314,16 @@ const me = class me {
|
|
|
2214
2314
|
}
|
|
2215
2315
|
derivative() {
|
|
2216
2316
|
const e = [], t = i(this, N).length;
|
|
2217
|
-
for (let
|
|
2218
|
-
const
|
|
2219
|
-
e.push(new me(...
|
|
2317
|
+
for (let n = 0; n < t; n++) {
|
|
2318
|
+
const r = i(this, N).slice(), l = r.splice(n, 1)[0];
|
|
2319
|
+
e.push(new me(...r).multiply(new me(...l.derivative())));
|
|
2220
2320
|
}
|
|
2221
|
-
e.forEach((
|
|
2321
|
+
e.forEach((n) => n.reduce());
|
|
2222
2322
|
const s = e.shift();
|
|
2223
2323
|
return s !== void 0 && h(this, N, s.factors), this.add(...e);
|
|
2224
2324
|
}
|
|
2225
2325
|
develop() {
|
|
2226
|
-
const e = new
|
|
2326
|
+
const e = new A("1");
|
|
2227
2327
|
return i(this, N).forEach((t) => {
|
|
2228
2328
|
e.multiply(t.develop());
|
|
2229
2329
|
}), e;
|
|
@@ -2232,7 +2332,7 @@ const me = class me {
|
|
|
2232
2332
|
return h(this, N, i(this, N).concat(e.clone().factors.map((t) => t.inverse()))), this;
|
|
2233
2333
|
}
|
|
2234
2334
|
evaluate(e, t) {
|
|
2235
|
-
return t ? i(this, N).reduce((s,
|
|
2335
|
+
return t ? i(this, N).reduce((s, n) => s * n.evaluate(e, t), 1) : i(this, N).reduce((s, n) => s.multiply(n.evaluate(e)), new c("1"));
|
|
2236
2336
|
}
|
|
2237
2337
|
hasVariable(e) {
|
|
2238
2338
|
return i(this, N).some((t) => t.hasVariable(e));
|
|
@@ -2241,8 +2341,8 @@ const me = class me {
|
|
|
2241
2341
|
return h(this, N, i(this, N).map((e) => e.inverse())), this;
|
|
2242
2342
|
}
|
|
2243
2343
|
isEqual(e) {
|
|
2244
|
-
const t = me.gcd(this, e), s = this.clone().divide(t).reduce(),
|
|
2245
|
-
return s.isOne() &&
|
|
2344
|
+
const t = me.gcd(this, e), s = this.clone().divide(t).reduce(), n = e.clone().divide(t).reduce();
|
|
2345
|
+
return s.isOne() && n.isOne();
|
|
2246
2346
|
}
|
|
2247
2347
|
isOne() {
|
|
2248
2348
|
return i(this, N).every((e) => e.isOne());
|
|
@@ -2269,10 +2369,10 @@ const me = class me {
|
|
|
2269
2369
|
throw new Error("Method not implemented.");
|
|
2270
2370
|
}
|
|
2271
2371
|
reduce() {
|
|
2272
|
-
const e =
|
|
2372
|
+
const e = Yt(this);
|
|
2273
2373
|
return h(this, N, Object.values(e).map((t) => {
|
|
2274
|
-
const s = t[0].polynom,
|
|
2275
|
-
return new fe(s,
|
|
2374
|
+
const s = t[0].polynom, n = t.reduce((r, l) => r.add(l.power), new c("0"));
|
|
2375
|
+
return new fe(s, n.reduce());
|
|
2276
2376
|
}).filter((t) => !t.power.isZero())), this;
|
|
2277
2377
|
}
|
|
2278
2378
|
root(e) {
|
|
@@ -2297,11 +2397,11 @@ const me = class me {
|
|
|
2297
2397
|
if (e.length === 1)
|
|
2298
2398
|
return e[0];
|
|
2299
2399
|
if (e.length === 2)
|
|
2300
|
-
return
|
|
2400
|
+
return q(s = me, ct, Jt).call(s, e[0], e[1]);
|
|
2301
2401
|
let t = e[0];
|
|
2302
|
-
return e.shift(), e.forEach((
|
|
2303
|
-
var
|
|
2304
|
-
return t =
|
|
2402
|
+
return e.shift(), e.forEach((n) => {
|
|
2403
|
+
var r;
|
|
2404
|
+
return t = q(r = me, ct, Jt).call(r, t, n);
|
|
2305
2405
|
}), t;
|
|
2306
2406
|
}
|
|
2307
2407
|
// #endregion Properties and methods (25)
|
|
@@ -2316,10 +2416,10 @@ const me = class me {
|
|
|
2316
2416
|
return i(this, N).reduce((e, t) => e.concat(t.variables), []);
|
|
2317
2417
|
}
|
|
2318
2418
|
get asRoot() {
|
|
2319
|
-
return h(this,
|
|
2419
|
+
return h(this, je, We.ROOT), this;
|
|
2320
2420
|
}
|
|
2321
2421
|
get asPower() {
|
|
2322
|
-
return h(this,
|
|
2422
|
+
return h(this, je, We.POWER), this;
|
|
2323
2423
|
}
|
|
2324
2424
|
get numerator() {
|
|
2325
2425
|
return i(this, N).filter((e) => e.power.isPositive());
|
|
@@ -2329,57 +2429,57 @@ const me = class me {
|
|
|
2329
2429
|
}
|
|
2330
2430
|
get display() {
|
|
2331
2431
|
let e = [], t = [];
|
|
2332
|
-
if (i(this,
|
|
2333
|
-
return e.length === 1 ? e[0].asSingle.display : e.map((
|
|
2334
|
-
const s = e.length === 1 ? e[0].asSingle.display : e.map((
|
|
2335
|
-
return `(${s})/(${
|
|
2432
|
+
if (i(this, je) === We.ROOT ? (e = this.numerator, t = this.denominator.map((r) => r.clone().inverse())) : e = i(this, N), e.length === 0 && (e = [new fe("1")]), t.length === 0)
|
|
2433
|
+
return e.length === 1 ? e[0].asSingle.display : e.map((r) => r.display).join("");
|
|
2434
|
+
const s = 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("");
|
|
2435
|
+
return `(${s})/(${n})`;
|
|
2336
2436
|
}
|
|
2337
2437
|
get tex() {
|
|
2338
2438
|
let e = [], t = [];
|
|
2339
|
-
if (i(this,
|
|
2340
|
-
return e.length === 1 ? e[0].asSingle.tex : e.map((
|
|
2341
|
-
const s = e.length === 1 ? e[0].asSingle.tex : e.map((
|
|
2342
|
-
return `\\frac{ ${s} }{ ${
|
|
2439
|
+
if (i(this, je) === We.ROOT ? (e = this.numerator, t = this.denominator.map((r) => r.clone().inverse())) : e = i(this, N), e.length === 0 && (e = [new fe("1")]), t.length === 0)
|
|
2440
|
+
return e.length === 1 ? e[0].asSingle.tex : e.map((r) => r.tex).join("");
|
|
2441
|
+
const s = 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("");
|
|
2442
|
+
return `\\frac{ ${s} }{ ${n} }`;
|
|
2343
2443
|
}
|
|
2344
2444
|
// #endregion Private methods (1)
|
|
2345
2445
|
};
|
|
2346
|
-
N = new WeakMap(),
|
|
2347
|
-
const s =
|
|
2348
|
-
const f = s[u].reduce((g, E) => g.add(E.power), new c("0")),
|
|
2349
|
-
return new fe(u, c.min(f,
|
|
2446
|
+
N = new WeakMap(), je = new WeakMap(), ct = new WeakSet(), Jt = function(e, t) {
|
|
2447
|
+
const s = Yt(e), n = Yt(t), l = Object.keys(s).filter((u) => Object.hasOwn(n, u)).map((u) => {
|
|
2448
|
+
const f = s[u].reduce((g, E) => g.add(E.power), new c("0")), m = n[u].reduce((g, E) => g.add(E.power), new c("0"));
|
|
2449
|
+
return new fe(u, c.min(f, m));
|
|
2350
2450
|
});
|
|
2351
2451
|
return new me(...l);
|
|
2352
|
-
}, d(me,
|
|
2353
|
-
let
|
|
2354
|
-
function
|
|
2355
|
-
const e = new c().one(), t = o.factors.reduce((s,
|
|
2356
|
-
if (
|
|
2357
|
-
return
|
|
2358
|
-
const
|
|
2359
|
-
return Object.hasOwn(s,
|
|
2452
|
+
}, d(me, ct);
|
|
2453
|
+
let Kt = me;
|
|
2454
|
+
function Yt(o) {
|
|
2455
|
+
const e = new c().one(), t = o.factors.reduce((s, n) => {
|
|
2456
|
+
if (n.polynom.degree().isZero())
|
|
2457
|
+
return n.polynom.monoms.length > 0 && e.multiply(n.polynom.monoms[0].coefficient), s;
|
|
2458
|
+
const r = n.polynom.display;
|
|
2459
|
+
return Object.hasOwn(s, r) ? s[r].push(n) : s[r] = [n], s;
|
|
2360
2460
|
}, {});
|
|
2361
2461
|
return e.isOne() || (t[e.display] = [new fe(e.display, 1)]), t;
|
|
2362
2462
|
}
|
|
2363
|
-
var
|
|
2364
|
-
const
|
|
2463
|
+
var z, Ce, Rt, zt;
|
|
2464
|
+
const He = class He {
|
|
2365
2465
|
constructor(...e) {
|
|
2366
|
-
d(this,
|
|
2466
|
+
d(this, z);
|
|
2367
2467
|
// Determine the letters in the linear system, usually ['x', 'y']
|
|
2368
|
-
d(this,
|
|
2369
|
-
a(this, "parse", (...e) => (h(this,
|
|
2370
|
-
a(this, "clone", () => new
|
|
2468
|
+
d(this, Ce);
|
|
2469
|
+
a(this, "parse", (...e) => (h(this, z, e.map((t) => new H(t))), i(this, Rt).call(this), this));
|
|
2470
|
+
a(this, "clone", () => new He().parse(...i(this, z).map((e) => e.clone())));
|
|
2371
2471
|
a(this, "buildTex", (e, t) => {
|
|
2372
|
-
let s,
|
|
2472
|
+
let s, n, r = [];
|
|
2373
2473
|
const l = [];
|
|
2374
2474
|
for (const f of e)
|
|
2375
|
-
|
|
2376
|
-
|
|
2475
|
+
r = r.concat(f.letters());
|
|
2476
|
+
r = [...new Set(r)], r.sort();
|
|
2377
2477
|
for (let f = 0; f < e.length; f++) {
|
|
2378
|
-
const
|
|
2478
|
+
const m = e[f];
|
|
2379
2479
|
s = [];
|
|
2380
|
-
for (const g of
|
|
2381
|
-
|
|
2382
|
-
if (s.push("="), s.push(
|
|
2480
|
+
for (const g of r)
|
|
2481
|
+
n = m.left.monomByLetter(g), s.length === 0 ? s.push(n.isZero() ? "" : n.tex) : s.push(n.isZero() ? "" : (n.coefficient.sign() === 1 ? "+" : "") + n.tex);
|
|
2482
|
+
if (s.push("="), s.push(m.right.tex), (t == null ? void 0 : t[f]) !== void 0) {
|
|
2383
2483
|
s[s.length - 1] = s[s.length - 1] + " \\phantom{\\quad}";
|
|
2384
2484
|
for (const g of t[f])
|
|
2385
2485
|
s.push(`\\ \\cdot\\ ${g.startsWith("-") ? "\\left(" + g + "\\right)" : g}`);
|
|
@@ -2387,116 +2487,116 @@ const Ge = class Ge {
|
|
|
2387
2487
|
l.push(s.join("&"));
|
|
2388
2488
|
}
|
|
2389
2489
|
let u = 0;
|
|
2390
|
-
return t !== void 0 && t.length > 0 && (u = t[0].length), `\\left\\{\\begin{array}{${"r".repeat(
|
|
2490
|
+
return t !== void 0 && t.length > 0 && (u = t[0].length), `\\left\\{\\begin{array}{${"r".repeat(r.length)}cl ${"|l".repeat(u)}}${l.join("\\\\ ")}\\end{array}\\right.`;
|
|
2391
2491
|
});
|
|
2392
|
-
a(this, "mergeEquations", (e, t, s,
|
|
2393
|
-
const
|
|
2394
|
-
return
|
|
2492
|
+
a(this, "mergeEquations", (e, t, s, n) => {
|
|
2493
|
+
const r = e.clone().multiply(new c(s)), l = t.clone().multiply(new c(n));
|
|
2494
|
+
return r.left.add(l.left), r.right.add(l.right), r;
|
|
2395
2495
|
});
|
|
2396
2496
|
// ------------------------------------------
|
|
2397
2497
|
a(this, "reorder", () => {
|
|
2398
|
-
for (const e of i(this,
|
|
2498
|
+
for (const e of i(this, z))
|
|
2399
2499
|
e.reorder();
|
|
2400
2500
|
return this;
|
|
2401
2501
|
});
|
|
2402
2502
|
a(this, "solveMatrix", () => {
|
|
2403
|
-
const [e, t] = this.matrix, s = e.map((
|
|
2404
|
-
for (let
|
|
2405
|
-
const
|
|
2406
|
-
s[
|
|
2503
|
+
const [e, t] = this.matrix, s = e.map((n, r) => [...n, t[r]]);
|
|
2504
|
+
for (let n = 0; n < e.length; n++) {
|
|
2505
|
+
const r = s[n][n].clone();
|
|
2506
|
+
s[n] = s[n].map((l) => l.divide(r));
|
|
2407
2507
|
for (let l = 0; l < e.length; l++) {
|
|
2408
|
-
if (l ===
|
|
2508
|
+
if (l === n)
|
|
2409
2509
|
continue;
|
|
2410
|
-
const u = s[l][
|
|
2510
|
+
const u = s[l][n].clone().opposite();
|
|
2411
2511
|
for (let f = 0; f < s[l].length; f++)
|
|
2412
|
-
s[l][f].add(s[
|
|
2512
|
+
s[l][f].add(s[n][f].clone().multiply(u));
|
|
2413
2513
|
if (s[l].slice(0, s[l].length - 1).every((f) => f.isZero()))
|
|
2414
2514
|
return s[l][s[l].length - 1].isZero() ? [new c().infinite()] : [];
|
|
2415
2515
|
}
|
|
2416
2516
|
}
|
|
2417
|
-
return s.map((
|
|
2517
|
+
return s.map((n) => n[n.length - 1]);
|
|
2418
2518
|
});
|
|
2419
|
-
d(this,
|
|
2420
|
-
d(this,
|
|
2519
|
+
d(this, Rt, () => (h(this, Ce, i(this, z).reduce((e, t) => [.../* @__PURE__ */ new Set([...e, ...t.variables])], [])), i(this, Ce).sort(), this));
|
|
2520
|
+
d(this, zt, () => {
|
|
2421
2521
|
const e = [], t = [];
|
|
2422
|
-
for (const s of i(this,
|
|
2423
|
-
const
|
|
2522
|
+
for (const s of i(this, z)) {
|
|
2523
|
+
const n = [], r = s.clone().reorder();
|
|
2424
2524
|
for (const l of this.variables) {
|
|
2425
|
-
const u =
|
|
2426
|
-
|
|
2525
|
+
const u = r.left.monomByLetter(l);
|
|
2526
|
+
n.push(u.coefficient);
|
|
2427
2527
|
}
|
|
2428
|
-
t.push(
|
|
2528
|
+
t.push(r.right.monoms[0].coefficient), e.push(n);
|
|
2429
2529
|
}
|
|
2430
2530
|
return [e, t];
|
|
2431
2531
|
});
|
|
2432
|
-
return h(this,
|
|
2532
|
+
return h(this, z, []), h(this, Ce, []), e.length > 0 && this.parse(...e), this;
|
|
2433
2533
|
}
|
|
2434
2534
|
static fromMatrix(e, t = "xyz") {
|
|
2435
2535
|
const s = e[0].length;
|
|
2436
|
-
if (e.some((
|
|
2536
|
+
if (e.some((r) => r.length !== s))
|
|
2437
2537
|
throw new Error("All rows must have the same number of columns");
|
|
2438
|
-
const
|
|
2439
|
-
return new
|
|
2440
|
-
...e.map((
|
|
2441
|
-
const l = new
|
|
2538
|
+
const n = t.split("").splice(0, s - 1);
|
|
2539
|
+
return new He(
|
|
2540
|
+
...e.map((r) => {
|
|
2541
|
+
const l = new A(n.join(""), ...r);
|
|
2442
2542
|
return new H(l, 0);
|
|
2443
2543
|
})
|
|
2444
2544
|
);
|
|
2445
2545
|
}
|
|
2446
2546
|
add(e, t) {
|
|
2447
|
-
if (e instanceof
|
|
2547
|
+
if (e instanceof He) {
|
|
2448
2548
|
const s = e.equations.length;
|
|
2449
|
-
if (s !== i(this,
|
|
2549
|
+
if (s !== i(this, z).length)
|
|
2450
2550
|
throw new Error("The number of equations must be the same");
|
|
2451
|
-
for (let
|
|
2452
|
-
i(this,
|
|
2551
|
+
for (let n = 0; n < s; n++)
|
|
2552
|
+
i(this, z)[n].add(e.equations[n]);
|
|
2453
2553
|
} else {
|
|
2454
|
-
if (t === void 0 || t < 0 || t >= i(this,
|
|
2554
|
+
if (t === void 0 || t < 0 || t >= i(this, z).length)
|
|
2455
2555
|
throw new Error("Index out of range");
|
|
2456
2556
|
const s = new H(e);
|
|
2457
|
-
i(this,
|
|
2557
|
+
i(this, z)[t].add(s);
|
|
2458
2558
|
}
|
|
2459
2559
|
return this;
|
|
2460
2560
|
}
|
|
2461
2561
|
degree(e) {
|
|
2462
|
-
return c.max(...i(this,
|
|
2562
|
+
return c.max(...i(this, z).map((t) => t.degree(e)));
|
|
2463
2563
|
}
|
|
2464
2564
|
get display() {
|
|
2465
2565
|
return this.tex + "as display";
|
|
2466
2566
|
}
|
|
2467
2567
|
// ------------------------------------------
|
|
2468
2568
|
get equations() {
|
|
2469
|
-
return i(this,
|
|
2569
|
+
return i(this, z);
|
|
2470
2570
|
}
|
|
2471
2571
|
set equations(e) {
|
|
2472
|
-
h(this,
|
|
2572
|
+
h(this, z, e);
|
|
2473
2573
|
}
|
|
2474
2574
|
evaluate(e, t) {
|
|
2475
2575
|
throw new Error("Method not implemented.");
|
|
2476
2576
|
}
|
|
2477
2577
|
hasVariable(e) {
|
|
2478
|
-
return i(this,
|
|
2578
|
+
return i(this, Ce).includes(e);
|
|
2479
2579
|
}
|
|
2480
2580
|
isEqual(e) {
|
|
2481
2581
|
return this.equations.every((t, s) => t.isEqual(e.equations[s]));
|
|
2482
2582
|
}
|
|
2483
2583
|
get isSolvable() {
|
|
2484
|
-
return this.variables.length === i(this,
|
|
2584
|
+
return this.variables.length === i(this, z).length;
|
|
2485
2585
|
}
|
|
2486
2586
|
get matrix() {
|
|
2487
|
-
return i(this,
|
|
2587
|
+
return i(this, zt).call(this);
|
|
2488
2588
|
}
|
|
2489
2589
|
multiply(e, t) {
|
|
2490
2590
|
if (Array.isArray(e)) {
|
|
2491
|
-
if (e.length !== i(this,
|
|
2591
|
+
if (e.length !== i(this, z).length)
|
|
2492
2592
|
throw new Error("The number of values must be the same as the number of equations");
|
|
2493
2593
|
for (let s = 0; s < e.length; s++)
|
|
2494
|
-
i(this,
|
|
2594
|
+
i(this, z)[s].multiply(e[s]);
|
|
2495
2595
|
return this;
|
|
2496
2596
|
}
|
|
2497
|
-
if (t === void 0 || t < 0 || t >= i(this,
|
|
2597
|
+
if (t === void 0 || t < 0 || t >= i(this, z).length)
|
|
2498
2598
|
throw new Error("Index out of range");
|
|
2499
|
-
return i(this,
|
|
2599
|
+
return i(this, z)[t].multiply(e), this;
|
|
2500
2600
|
}
|
|
2501
2601
|
reduce() {
|
|
2502
2602
|
throw new Error("Method not implemented.");
|
|
@@ -2505,17 +2605,17 @@ const Ge = class Ge {
|
|
|
2505
2605
|
return [];
|
|
2506
2606
|
}
|
|
2507
2607
|
subtract(e, t) {
|
|
2508
|
-
if (e instanceof
|
|
2608
|
+
if (e instanceof He) {
|
|
2509
2609
|
const s = e.equations.length;
|
|
2510
|
-
if (s !== i(this,
|
|
2610
|
+
if (s !== i(this, z).length)
|
|
2511
2611
|
throw new Error("The number of equations must be the same");
|
|
2512
|
-
for (let
|
|
2513
|
-
i(this,
|
|
2612
|
+
for (let n = 0; n < s; n++)
|
|
2613
|
+
i(this, z)[n].subtract(e.equations[n]);
|
|
2514
2614
|
} else {
|
|
2515
|
-
if (t === void 0 || t < 0 || t >= i(this,
|
|
2615
|
+
if (t === void 0 || t < 0 || t >= i(this, z).length)
|
|
2516
2616
|
throw new Error("Index out of range");
|
|
2517
2617
|
const s = new H(e);
|
|
2518
|
-
i(this,
|
|
2618
|
+
i(this, z)[t].subtract(s);
|
|
2519
2619
|
}
|
|
2520
2620
|
return this;
|
|
2521
2621
|
}
|
|
@@ -2524,35 +2624,35 @@ const Ge = class Ge {
|
|
|
2524
2624
|
return this.buildTex(e.equations);
|
|
2525
2625
|
}
|
|
2526
2626
|
get variables() {
|
|
2527
|
-
return i(this,
|
|
2627
|
+
return i(this, Ce);
|
|
2528
2628
|
}
|
|
2529
2629
|
set variables(e) {
|
|
2530
2630
|
const t = typeof e == "string" ? e.split("") : [...e];
|
|
2531
|
-
t.sort(), h(this,
|
|
2631
|
+
t.sort(), h(this, Ce, t);
|
|
2532
2632
|
}
|
|
2533
2633
|
};
|
|
2534
|
-
|
|
2535
|
-
let
|
|
2536
|
-
function
|
|
2634
|
+
z = new WeakMap(), Ce = new WeakMap(), Rt = new WeakMap(), zt = new WeakMap();
|
|
2635
|
+
let _t = He;
|
|
2636
|
+
function Xi(o, e) {
|
|
2537
2637
|
return o.dimension === e.dimension && o.array.every(
|
|
2538
2638
|
(t, s) => e.array[s].isEqual(t)
|
|
2539
2639
|
);
|
|
2540
2640
|
}
|
|
2541
|
-
function
|
|
2641
|
+
function Yi(o, e) {
|
|
2542
2642
|
if (o.dimension !== e.dimension)
|
|
2543
2643
|
return !1;
|
|
2544
2644
|
const t = e.array[0].value / o.array[0].value;
|
|
2545
2645
|
return o.array.every(
|
|
2546
|
-
(s,
|
|
2646
|
+
(s, n) => e.array[n].value === s.value * t
|
|
2547
2647
|
);
|
|
2548
2648
|
}
|
|
2549
|
-
function
|
|
2649
|
+
function Qi(o, e) {
|
|
2550
2650
|
return o.dimension !== e.dimension ? new c().invalid() : o.array.reduce(
|
|
2551
|
-
(t, s,
|
|
2651
|
+
(t, s, n) => t.add(s.clone().multiply(e.array[n])),
|
|
2552
2652
|
new c(0)
|
|
2553
2653
|
);
|
|
2554
2654
|
}
|
|
2555
|
-
function
|
|
2655
|
+
function Ki(...o) {
|
|
2556
2656
|
return o.some((e) => e.dimension !== o[0].dimension) ? new c().invalid() : o[0].dimension === 2 && o.length !== 2 ? new c().invalid() : o[0].dimension === 3 && o.length !== 3 ? new c().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(
|
|
2557
2657
|
o[1].array[1].clone().multiply(o[2].array[2]).subtract(o[1].array[2].clone().multiply(o[2].array[1]))
|
|
2558
2658
|
).subtract(
|
|
@@ -2561,29 +2661,29 @@ function Ui(...o) {
|
|
|
2561
2661
|
)
|
|
2562
2662
|
).add(o[0].array[2].clone().multiply(o[1].array[0].clone().multiply(o[2].array[1]).subtract(o[1].array[1].clone().multiply(o[2].array[0]))));
|
|
2563
2663
|
}
|
|
2564
|
-
var
|
|
2664
|
+
var Z, ze;
|
|
2565
2665
|
const Se = class Se {
|
|
2566
2666
|
constructor(...e) {
|
|
2567
|
-
d(this,
|
|
2667
|
+
d(this, Z, []);
|
|
2568
2668
|
d(this, ze, !1);
|
|
2569
|
-
a(this, "zero", () => (i(this,
|
|
2669
|
+
a(this, "zero", () => (i(this, Z).forEach((e) => e.zero()), this));
|
|
2570
2670
|
a(this, "one", () => (this.zero(), this.x.one(), this));
|
|
2571
|
-
a(this, "opposite", () => (i(this,
|
|
2572
|
-
a(this, "add", (e) => (i(this,
|
|
2671
|
+
a(this, "opposite", () => (i(this, Z).forEach((e) => e.opposite()), this));
|
|
2672
|
+
a(this, "add", (e) => (i(this, Z).forEach((t, s) => t.add(e.array[s])), this));
|
|
2573
2673
|
a(this, "subtract", (e) => this.add(e.clone().opposite()));
|
|
2574
2674
|
a(this, "unit", () => {
|
|
2575
2675
|
const e = this.norm;
|
|
2576
2676
|
return e === 0 ? this : this.divideByScalar(e);
|
|
2577
2677
|
});
|
|
2578
|
-
a(this, "dot", (e) =>
|
|
2678
|
+
a(this, "dot", (e) => Qi(this, e));
|
|
2579
2679
|
a(this, "normal", () => {
|
|
2580
2680
|
if (this.dimension >= 3)
|
|
2581
2681
|
throw new Error("Normal vector can only be determined in 2D");
|
|
2582
2682
|
const e = this.x.clone().opposite(), t = this.y.clone();
|
|
2583
|
-
return i(this,
|
|
2683
|
+
return i(this, Z)[0] = t, i(this, Z)[1] = e, this;
|
|
2584
2684
|
});
|
|
2585
|
-
a(this, "isEqual", (e) =>
|
|
2586
|
-
a(this, "isColinearTo", (e) =>
|
|
2685
|
+
a(this, "isEqual", (e) => Xi(this, e));
|
|
2686
|
+
a(this, "isColinearTo", (e) => Yi(this, e));
|
|
2587
2687
|
a(this, "isNormalTo", (e) => this.dot(e).isZero());
|
|
2588
2688
|
a(this, "multiplyByScalar", (e) => {
|
|
2589
2689
|
const t = new c(e);
|
|
@@ -2598,13 +2698,13 @@ const Se = class Se {
|
|
|
2598
2698
|
this.x.isNegative() ? -1 : 1
|
|
2599
2699
|
));
|
|
2600
2700
|
a(this, "angle", (e, t, s) => {
|
|
2601
|
-
let
|
|
2602
|
-
return t && (
|
|
2701
|
+
let n = this.dot(e).value;
|
|
2702
|
+
return t && (n = Math.abs(n)), (s ? 1 : 180 / Math.PI) * Math.acos(n / (this.norm * e.norm));
|
|
2603
2703
|
});
|
|
2604
2704
|
a(this, "fromString", (e) => {
|
|
2605
2705
|
e.startsWith("(") && (e = e.substring(1)), e.endsWith(")") && (e = e.substring(0, e.length - 1));
|
|
2606
2706
|
const t = e.split(/[,;\s]/g).filter((s) => s.trim() !== "");
|
|
2607
|
-
return t.length < 2 ? this : (h(this,
|
|
2707
|
+
return t.length < 2 ? this : (h(this, Z, t.map((s) => new c(s))), this);
|
|
2608
2708
|
});
|
|
2609
2709
|
e.length > 0 && this.parse(...e);
|
|
2610
2710
|
}
|
|
@@ -2612,32 +2712,32 @@ const Se = class Se {
|
|
|
2612
2712
|
// Getter and setter
|
|
2613
2713
|
// ------------------------------------------
|
|
2614
2714
|
get array() {
|
|
2615
|
-
return i(this,
|
|
2715
|
+
return i(this, Z);
|
|
2616
2716
|
}
|
|
2617
2717
|
set array(e) {
|
|
2618
|
-
h(this,
|
|
2718
|
+
h(this, Z, e);
|
|
2619
2719
|
}
|
|
2620
2720
|
get x() {
|
|
2621
|
-
return i(this,
|
|
2721
|
+
return i(this, Z)[0];
|
|
2622
2722
|
}
|
|
2623
2723
|
set x(e) {
|
|
2624
|
-
i(this,
|
|
2724
|
+
i(this, Z)[0] = new c(e);
|
|
2625
2725
|
}
|
|
2626
2726
|
get y() {
|
|
2627
|
-
return i(this,
|
|
2727
|
+
return i(this, Z)[1];
|
|
2628
2728
|
}
|
|
2629
2729
|
set y(e) {
|
|
2630
|
-
i(this,
|
|
2730
|
+
i(this, Z)[1] = new c(e);
|
|
2631
2731
|
}
|
|
2632
2732
|
get z() {
|
|
2633
2733
|
if (this.dimension < 3)
|
|
2634
2734
|
throw new Error("Vector is not 3D");
|
|
2635
|
-
return i(this,
|
|
2735
|
+
return i(this, Z)[2];
|
|
2636
2736
|
}
|
|
2637
2737
|
set z(e) {
|
|
2638
2738
|
if (this.dimension < 3)
|
|
2639
2739
|
throw new Error("Vector is not 3D");
|
|
2640
|
-
i(this,
|
|
2740
|
+
i(this, Z)[2] = new c(e);
|
|
2641
2741
|
}
|
|
2642
2742
|
get asPoint() {
|
|
2643
2743
|
return i(this, ze);
|
|
@@ -2661,10 +2761,10 @@ const Se = class Se {
|
|
|
2661
2761
|
if (e < 2)
|
|
2662
2762
|
throw new Error("Dimension must be at least 2");
|
|
2663
2763
|
if (e < this.dimension)
|
|
2664
|
-
h(this,
|
|
2764
|
+
h(this, Z, i(this, Z).slice(0, e));
|
|
2665
2765
|
else if (e > this.dimension)
|
|
2666
2766
|
for (let t = this.dimension; t < e; t++)
|
|
2667
|
-
i(this,
|
|
2767
|
+
i(this, Z).push(new c(0));
|
|
2668
2768
|
return this;
|
|
2669
2769
|
}
|
|
2670
2770
|
get dimension() {
|
|
@@ -2700,23 +2800,23 @@ const Se = class Se {
|
|
|
2700
2800
|
if (t instanceof Se && s instanceof Se) {
|
|
2701
2801
|
if (t.dimension !== s.dimension)
|
|
2702
2802
|
throw new Error("Vectors must have the same dimension");
|
|
2703
|
-
return h(this,
|
|
2803
|
+
return h(this, Z, s.array.map((n, r) => n.clone().subtract(t.array[r]))), this;
|
|
2704
2804
|
}
|
|
2705
2805
|
}
|
|
2706
|
-
return h(this,
|
|
2806
|
+
return h(this, Z, e.map((t) => new c(t))), this;
|
|
2707
2807
|
}
|
|
2708
2808
|
clone() {
|
|
2709
2809
|
const e = new Se();
|
|
2710
2810
|
return e.array = this.copy(), e.asPoint = this.asPoint, e;
|
|
2711
2811
|
}
|
|
2712
2812
|
copy() {
|
|
2713
|
-
return i(this,
|
|
2813
|
+
return i(this, Z).map((e) => e.clone());
|
|
2714
2814
|
}
|
|
2715
2815
|
middleOf(e, t) {
|
|
2716
2816
|
if (e.dimension !== t.dimension)
|
|
2717
2817
|
throw new Error("Vectors must be the same dimension");
|
|
2718
|
-
return this.array = [], e.array.forEach((s,
|
|
2719
|
-
this.array.push(s.clone().add(t.array[
|
|
2818
|
+
return this.array = [], e.array.forEach((s, n) => {
|
|
2819
|
+
this.array.push(s.clone().add(t.array[n]).divide(2));
|
|
2720
2820
|
}), this;
|
|
2721
2821
|
}
|
|
2722
2822
|
translate(...e) {
|
|
@@ -2746,9 +2846,9 @@ const Se = class Se {
|
|
|
2746
2846
|
};
|
|
2747
2847
|
}
|
|
2748
2848
|
};
|
|
2749
|
-
|
|
2849
|
+
Z = new WeakMap(), ze = new WeakMap();
|
|
2750
2850
|
let x = Se;
|
|
2751
|
-
function
|
|
2851
|
+
function vi(o = 0.5) {
|
|
2752
2852
|
return Math.random() < o;
|
|
2753
2853
|
}
|
|
2754
2854
|
function de(o, e, t) {
|
|
@@ -2766,23 +2866,23 @@ function de(o, e, t) {
|
|
|
2766
2866
|
return s;
|
|
2767
2867
|
}
|
|
2768
2868
|
function X(o, e) {
|
|
2769
|
-
return e === !1 ?
|
|
2869
|
+
return e === !1 ? vi() ? de(1, o) : -de(1, o) : de(-o, o);
|
|
2770
2870
|
}
|
|
2771
|
-
function
|
|
2871
|
+
function Ji(o) {
|
|
2772
2872
|
let e = G.primes();
|
|
2773
|
-
return o !== void 0 && (e = e.filter((t) => t < o)),
|
|
2873
|
+
return o !== void 0 && (e = e.filter((t) => t < o)), oi(e);
|
|
2774
2874
|
}
|
|
2775
|
-
function
|
|
2776
|
-
return e === void 0 && (e = 1), o.length <= 0 ? Object.values(o) :
|
|
2875
|
+
function _i(o, e) {
|
|
2876
|
+
return e === void 0 && (e = 1), o.length <= 0 ? Object.values(o) : bi(o).slice(0, e);
|
|
2777
2877
|
}
|
|
2778
|
-
function
|
|
2878
|
+
function oi(o) {
|
|
2779
2879
|
return o.length === 0 ? null : o[de(0, o.length - 1)];
|
|
2780
2880
|
}
|
|
2781
|
-
function
|
|
2881
|
+
function bi(o) {
|
|
2782
2882
|
const e = Object.values(o);
|
|
2783
2883
|
for (let t = e.length - 1; t > 0; t--) {
|
|
2784
|
-
const s = Math.floor(Math.random() * (t + 1)),
|
|
2785
|
-
e[t] = e[s], e[s] =
|
|
2884
|
+
const s = Math.floor(Math.random() * (t + 1)), n = e[t];
|
|
2885
|
+
e[t] = e[s], e[s] = n;
|
|
2786
2886
|
}
|
|
2787
2887
|
return e;
|
|
2788
2888
|
}
|
|
@@ -2812,24 +2912,24 @@ class j extends x {
|
|
|
2812
2912
|
return e.array = this.copy(), e.asPoint = !0, e;
|
|
2813
2913
|
}
|
|
2814
2914
|
}
|
|
2815
|
-
var
|
|
2816
|
-
const
|
|
2915
|
+
var xi = /* @__PURE__ */ ((o) => (o.None = "none", o.Parallel = "parallel", o.Perpendicular = "perpendicular", o.Tangent = "tangent", o))(xi || {}), $e, S, P, U, re, Y, Ie, ve;
|
|
2916
|
+
const De = class De {
|
|
2817
2917
|
/**
|
|
2818
2918
|
* Value can be a mix of:
|
|
2819
2919
|
*
|
|
2820
2920
|
* @param values
|
|
2821
2921
|
*/
|
|
2822
2922
|
constructor(...e) {
|
|
2823
|
-
d(this,
|
|
2923
|
+
d(this, $e);
|
|
2824
2924
|
// ax + by + c = 0
|
|
2825
|
-
d(this,
|
|
2826
|
-
d(this,
|
|
2925
|
+
d(this, S);
|
|
2926
|
+
d(this, P);
|
|
2827
2927
|
d(this, U);
|
|
2828
|
-
d(this,
|
|
2928
|
+
d(this, re);
|
|
2829
2929
|
d(this, Y);
|
|
2830
|
-
d(this,
|
|
2930
|
+
d(this, Ie);
|
|
2831
2931
|
d(this, ve, "canonical");
|
|
2832
|
-
a(this, "randomPoint", (e) => i(this, Y).clone().multiplyByScalar(X(e === void 0 || e <= 1 ? 3 : e, !1)).add(i(this,
|
|
2932
|
+
a(this, "randomPoint", (e) => i(this, Y).clone().multiplyByScalar(X(e === void 0 || e <= 1 ? 3 : e, !1)).add(i(this, re)));
|
|
2833
2933
|
a(this, "randomNearPoint", (e) => {
|
|
2834
2934
|
const t = this.randomPoint(e);
|
|
2835
2935
|
let s = 10;
|
|
@@ -2849,7 +2949,7 @@ const Le = class Le {
|
|
|
2849
2949
|
if (e.length === 0)
|
|
2850
2950
|
return this;
|
|
2851
2951
|
if (e.length === 1) {
|
|
2852
|
-
if (e[0] instanceof
|
|
2952
|
+
if (e[0] instanceof De)
|
|
2853
2953
|
return e[0].clone();
|
|
2854
2954
|
if (e[0] instanceof H)
|
|
2855
2955
|
return this.fromEquation(e[0]);
|
|
@@ -2875,7 +2975,7 @@ const Le = class Le {
|
|
|
2875
2975
|
if (e[2] === "parallel")
|
|
2876
2976
|
return this.fromPointAndDirection(e[0], e[1]);
|
|
2877
2977
|
}
|
|
2878
|
-
return e[0] instanceof x && e[1] instanceof
|
|
2978
|
+
return e[0] instanceof x && e[1] instanceof De ? e[2] === "parallel" || e[2] === null ? this.fromPointAndLine(
|
|
2879
2979
|
e[0],
|
|
2880
2980
|
e[1],
|
|
2881
2981
|
"parallel"
|
|
@@ -2902,46 +3002,46 @@ const Le = class Le {
|
|
|
2902
3002
|
t.has(s) && t.delete(s);
|
|
2903
3003
|
return t.size > 0 ? this : this.fromCoefficient(e.left.monomByLetter("x").coefficient, e.left.monomByLetter("y").coefficient, e.left.monomByDegree(0).coefficient);
|
|
2904
3004
|
});
|
|
2905
|
-
a(this, "fromCoefficient", (e, t, s) => (h(this,
|
|
3005
|
+
a(this, "fromCoefficient", (e, t, s) => (h(this, S, new c(e)), h(this, P, new c(t)), h(this, U, new c(s)), h(this, Y, new x(i(this, P).clone(), i(this, S).clone().opposite())), h(this, re, new x(new c().zero(), i(this, U).clone())), h(this, Ie, i(this, Y).clone().normal()), this));
|
|
2906
3006
|
a(this, "fromPointAndDirection", (e, t) => (this.fromCoefficient(
|
|
2907
3007
|
t.y,
|
|
2908
3008
|
t.x.clone().opposite(),
|
|
2909
3009
|
e.x.clone().multiply(t.y).subtract(e.y.clone().multiply(t.x)).opposite()
|
|
2910
|
-
), h(this,
|
|
3010
|
+
), h(this, re, e.clone()), h(this, Y, t.clone()), h(this, Ie, i(this, Y).clone().normal()), this));
|
|
2911
3011
|
a(this, "fromPointAndNormal", (e, t) => this.fromCoefficient(
|
|
2912
3012
|
t.x,
|
|
2913
3013
|
t.y,
|
|
2914
3014
|
e.x.clone().multiply(t.x).add(e.y.clone().multiply(t.y)).opposite()
|
|
2915
3015
|
));
|
|
2916
3016
|
a(this, "fromPointAndLine", (e, t, s) => (s === void 0 && (s = "parallel"), s === "parallel" ? this.fromPointAndNormal(e, t.normal) : s === "perpendicular" ? this.fromPointAndNormal(e, t.director) : this));
|
|
2917
|
-
a(this, "clone", () => (h(this,
|
|
3017
|
+
a(this, "clone", () => (h(this, S, i(this, S).clone()), h(this, P, i(this, P).clone()), h(this, U, i(this, U).clone()), h(this, Y, i(this, Y).clone()), h(this, re, i(this, re).clone()), h(this, Ie, i(this, Ie).clone()), this));
|
|
2918
3018
|
// ------------------------------------------
|
|
2919
3019
|
// Mathematical operations
|
|
2920
3020
|
// ------------------------------------------
|
|
2921
|
-
a(this, "isOnLine", (e) => i(this,
|
|
2922
|
-
i(this,
|
|
3021
|
+
a(this, "isOnLine", (e) => i(this, S).clone().multiply(e.x).add(
|
|
3022
|
+
i(this, P).clone().multiply(e.y)
|
|
2923
3023
|
).add(i(this, U)).isZero());
|
|
2924
3024
|
a(this, "isParallelTo", (e) => this.slope.isEqual(e.slope) && this.height.isNotEqual(e.height));
|
|
2925
3025
|
a(this, "isSameAs", (e) => this.slope.isEqual(e.slope) && this.height.isEqual(e.height));
|
|
2926
3026
|
a(this, "isPerpendicularTo", (e) => this.d.isNormalTo(e.d));
|
|
2927
3027
|
a(this, "isVertical", () => this.slope.isInfinity());
|
|
2928
3028
|
a(this, "simplify", () => {
|
|
2929
|
-
const e = G.lcm(i(this,
|
|
3029
|
+
const e = G.lcm(i(this, S).denominator, i(this, P).denominator, i(this, U).denominator), t = G.gcd(i(this, S).numerator, i(this, P).numerator, i(this, U).numerator);
|
|
2930
3030
|
return this.fromCoefficient(
|
|
2931
|
-
i(this,
|
|
2932
|
-
i(this,
|
|
3031
|
+
i(this, S).clone().multiply(e).divide(t),
|
|
3032
|
+
i(this, P).clone().multiply(e).divide(t),
|
|
2933
3033
|
i(this, U).clone().multiply(e).divide(t)
|
|
2934
3034
|
), this;
|
|
2935
3035
|
});
|
|
2936
3036
|
a(this, "simplifyDirection", () => (i(this, Y).simplify(), this));
|
|
2937
3037
|
a(this, "intersection", (e) => {
|
|
2938
3038
|
const t = new x();
|
|
2939
|
-
let s = !1,
|
|
2940
|
-
return i(this,
|
|
3039
|
+
let s = !1, n = !1;
|
|
3040
|
+
return i(this, P).isZero() || e.b.isZero(), this.isParallelTo(e) ? (t.x = new c().invalid(), t.y = new c().invalid(), s = !0) : this.isSameAs(e) ? (t.x = new c().invalid(), t.y = new c().invalid(), n = !0) : (t.x = i(this, P).clone().multiply(e.c).subtract(i(this, U).clone().multiply(e.b)).divide(i(this, S).clone().multiply(e.b).subtract(i(this, P).clone().multiply(e.a))), t.y = i(this, S).clone().multiply(e.c).subtract(i(this, U).clone().multiply(e.a)).divide(i(this, P).clone().multiply(e.a).subtract(i(this, S).clone().multiply(e.b)))), {
|
|
2941
3041
|
point: t,
|
|
2942
|
-
hasIntersection: !(s ||
|
|
3042
|
+
hasIntersection: !(s || n),
|
|
2943
3043
|
isParallel: s,
|
|
2944
|
-
isSame:
|
|
3044
|
+
isSame: n
|
|
2945
3045
|
};
|
|
2946
3046
|
});
|
|
2947
3047
|
a(this, "getValueAtX", (e) => {
|
|
@@ -2952,21 +3052,21 @@ const Le = class Le {
|
|
|
2952
3052
|
const t = this.getEquation().isolate("x"), s = new c(e);
|
|
2953
3053
|
return t instanceof H ? t.right.evaluate({ y: s }) : new c().invalid();
|
|
2954
3054
|
});
|
|
2955
|
-
return h(this,
|
|
3055
|
+
return h(this, S, new c().zero()), h(this, P, new c().zero()), h(this, U, new c().zero()), h(this, re, new x()), h(this, Y, new x()), h(this, Ie, new x()), h(this, $e, !0), e.length > 0 && this.parse(...e), this;
|
|
2956
3056
|
}
|
|
2957
3057
|
get a() {
|
|
2958
|
-
return i(this,
|
|
3058
|
+
return i(this, S);
|
|
2959
3059
|
}
|
|
2960
3060
|
// ------------------------------------------
|
|
2961
3061
|
// Getter and setter
|
|
2962
3062
|
set a(e) {
|
|
2963
|
-
h(this,
|
|
3063
|
+
h(this, S, e);
|
|
2964
3064
|
}
|
|
2965
3065
|
get b() {
|
|
2966
|
-
return i(this,
|
|
3066
|
+
return i(this, P);
|
|
2967
3067
|
}
|
|
2968
3068
|
set b(e) {
|
|
2969
|
-
h(this,
|
|
3069
|
+
h(this, P, e);
|
|
2970
3070
|
}
|
|
2971
3071
|
get c() {
|
|
2972
3072
|
return i(this, U);
|
|
@@ -2975,10 +3075,10 @@ const Le = class Le {
|
|
|
2975
3075
|
h(this, U, e);
|
|
2976
3076
|
}
|
|
2977
3077
|
get OA() {
|
|
2978
|
-
return i(this,
|
|
3078
|
+
return i(this, re);
|
|
2979
3079
|
}
|
|
2980
3080
|
set OA(e) {
|
|
2981
|
-
h(this,
|
|
3081
|
+
h(this, re, e);
|
|
2982
3082
|
}
|
|
2983
3083
|
get d() {
|
|
2984
3084
|
return i(this, Y);
|
|
@@ -2987,12 +3087,12 @@ const Le = class Le {
|
|
|
2987
3087
|
h(this, Y, e);
|
|
2988
3088
|
}
|
|
2989
3089
|
get n() {
|
|
2990
|
-
return i(this,
|
|
3090
|
+
return i(this, Ie);
|
|
2991
3091
|
}
|
|
2992
3092
|
// ------------------------------------------
|
|
2993
3093
|
getEquation() {
|
|
2994
|
-
const e = new H(new
|
|
2995
|
-
return i(this,
|
|
3094
|
+
const e = new H(new A().parse("xy", i(this, S), i(this, P), i(this, U)), new A("0"));
|
|
3095
|
+
return i(this, $e) ? e.simplify() : e;
|
|
2996
3096
|
}
|
|
2997
3097
|
// get system(): { x: Equation, y: Equation } {
|
|
2998
3098
|
// const e1 = new Equation(
|
|
@@ -3028,26 +3128,26 @@ const Le = class Le {
|
|
|
3028
3128
|
case "equation":
|
|
3029
3129
|
return this.getEquation().reorder().tex;
|
|
3030
3130
|
case "mxh":
|
|
3031
|
-
return this.slope.isInfinity() ? "x=" + this.OA.x.tex : "y=" + new
|
|
3131
|
+
return this.slope.isInfinity() ? "x=" + this.OA.x.tex : "y=" + new A().parse("x", this.slope, this.height).tex;
|
|
3032
3132
|
case "parametric":
|
|
3033
3133
|
case "system": {
|
|
3034
3134
|
const t = i(this, Y).clone();
|
|
3035
|
-
return i(this,
|
|
3036
|
-
x &= ${new
|
|
3037
|
-
y &= ${new
|
|
3135
|
+
return i(this, $e) && t.simplify(), e === "parametric" ? `${x.asTex("x", "y")} = ${x.asTex(i(this, re).x.tex, i(this, re).y.tex)} + k\\cdot ${x.asTex(t.x.tex, t.y.tex)}` : `\\left\\{\\begin{aligned}
|
|
3136
|
+
x &= ${new A(i(this, re).x).add(new k(i(this, Y).x).multiply(new k("k"))).reorder("k", !0).tex}\\\\
|
|
3137
|
+
y &= ${new A(i(this, re).y).add(new k(i(this, Y).y).multiply(new k("k"))).reorder("k", !0).tex}
|
|
3038
3138
|
\\end{aligned}\\right.`;
|
|
3039
3139
|
}
|
|
3040
3140
|
default: {
|
|
3041
3141
|
const t = this.getEquation();
|
|
3042
|
-
return i(this,
|
|
3142
|
+
return i(this, S).isNegative() && t.multiply(-1), t.tex;
|
|
3043
3143
|
}
|
|
3044
3144
|
}
|
|
3045
3145
|
}
|
|
3046
3146
|
get reduceBeforeDisplay() {
|
|
3047
|
-
return i(this,
|
|
3147
|
+
return i(this, $e);
|
|
3048
3148
|
}
|
|
3049
3149
|
set reduceBeforeDisplay(e) {
|
|
3050
|
-
h(this,
|
|
3150
|
+
h(this, $e, e);
|
|
3051
3151
|
}
|
|
3052
3152
|
get display() {
|
|
3053
3153
|
const e = i(this, ve);
|
|
@@ -3055,54 +3155,54 @@ const Le = class Le {
|
|
|
3055
3155
|
case "equation":
|
|
3056
3156
|
return this.getEquation().reorder().display;
|
|
3057
3157
|
case "mxh":
|
|
3058
|
-
return this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new
|
|
3158
|
+
return this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new A().parse("x", this.slope, this.height).display;
|
|
3059
3159
|
case "parametric": {
|
|
3060
3160
|
const t = i(this, Y).clone();
|
|
3061
|
-
return i(this,
|
|
3161
|
+
return i(this, $e) && t.simplify(), `((x,y))=((${i(this, re).x.display},${i(this, re).y.display}))+k((${t.x.display},${t.y.display}))`;
|
|
3062
3162
|
}
|
|
3063
3163
|
default: {
|
|
3064
3164
|
const t = this.getEquation();
|
|
3065
|
-
return i(this,
|
|
3165
|
+
return i(this, S).isNegative() && t.multiply(-1), t.display;
|
|
3066
3166
|
}
|
|
3067
3167
|
}
|
|
3068
3168
|
}
|
|
3069
3169
|
get normal() {
|
|
3070
|
-
return new x(i(this,
|
|
3170
|
+
return new x(i(this, S), i(this, P));
|
|
3071
3171
|
}
|
|
3072
3172
|
get director() {
|
|
3073
3173
|
return i(this, Y).clone();
|
|
3074
3174
|
}
|
|
3075
3175
|
get slope() {
|
|
3076
|
-
return i(this,
|
|
3176
|
+
return i(this, S).clone().opposite().divide(i(this, P));
|
|
3077
3177
|
}
|
|
3078
3178
|
get height() {
|
|
3079
|
-
return i(this, U).clone().opposite().divide(i(this,
|
|
3179
|
+
return i(this, U).clone().opposite().divide(i(this, P));
|
|
3080
3180
|
}
|
|
3081
3181
|
fromPoints(e, t) {
|
|
3082
3182
|
return this.fromPointAndDirection(e, new x(e, t));
|
|
3083
3183
|
}
|
|
3084
3184
|
distanceTo(e) {
|
|
3085
|
-
const t = e.x.clone().multiply(i(this,
|
|
3185
|
+
const t = e.x.clone().multiply(i(this, S)).add(e.y.clone().multiply(i(this, P))).add(i(this, U)).abs(), s = this.normal.normSquare;
|
|
3086
3186
|
if (s.isZero())
|
|
3087
3187
|
return {
|
|
3088
3188
|
value: NaN,
|
|
3089
3189
|
tex: "Not a line",
|
|
3090
3190
|
fraction: new c().infinite()
|
|
3091
3191
|
};
|
|
3092
|
-
const
|
|
3192
|
+
const n = t.value / Math.sqrt(s.value), r = t.clone().divide(s.clone().sqrt());
|
|
3093
3193
|
return s.isSquare() ? {
|
|
3094
|
-
value:
|
|
3095
|
-
tex:
|
|
3096
|
-
fraction:
|
|
3194
|
+
value: n,
|
|
3195
|
+
tex: r.tex,
|
|
3196
|
+
fraction: r
|
|
3097
3197
|
} : {
|
|
3098
|
-
value:
|
|
3198
|
+
value: n,
|
|
3099
3199
|
tex: `\\frac{${t.tex}}{\\sqrt{${s.tex}}}`,
|
|
3100
|
-
fraction:
|
|
3200
|
+
fraction: r
|
|
3101
3201
|
};
|
|
3102
3202
|
}
|
|
3103
3203
|
hitSegment(e, t) {
|
|
3104
3204
|
const s = this.intersection(
|
|
3105
|
-
new
|
|
3205
|
+
new De(e, t)
|
|
3106
3206
|
);
|
|
3107
3207
|
return s.hasIntersection ? s.point.x.value >= Math.min(e.x.value, t.x.value) && s.point.x.value <= Math.max(e.x.value, t.x.value) && s.point.y.value >= Math.min(e.y.value, t.y.value) && s.point.y.value <= Math.max(e.y.value, t.y.value) : !1;
|
|
3108
3208
|
}
|
|
@@ -3112,19 +3212,19 @@ const Le = class Le {
|
|
|
3112
3212
|
canonicalAsFloatCoefficient(e) {
|
|
3113
3213
|
e === void 0 && (e = 2);
|
|
3114
3214
|
let t = "";
|
|
3115
|
-
return i(this,
|
|
3215
|
+
return i(this, S).isZero() || (i(this, S).isOne() ? t = "x" : i(this, S).clone().opposite().isOne() ? t = "-x" : t = i(this, S).value.toFixed(e) + "x"), i(this, P).isZero() || (i(this, P).isPositive() && (t += "+"), t += i(this, P).value.toFixed(e) + "y"), i(this, U).isZero() || (i(this, U).isPositive() && (t += "+"), t += i(this, U).value.toFixed(e)), t + "=0";
|
|
3116
3216
|
}
|
|
3117
3217
|
};
|
|
3118
|
-
|
|
3119
|
-
a(
|
|
3120
|
-
let D =
|
|
3121
|
-
var oe, F,
|
|
3122
|
-
const
|
|
3218
|
+
$e = new WeakMap(), S = new WeakMap(), P = new WeakMap(), U = new WeakMap(), re = new WeakMap(), Y = new WeakMap(), Ie = new WeakMap(), ve = new WeakMap(), // A line is defined as the canonical form
|
|
3219
|
+
a(De, "PERPENDICULAR", "perpendicular"), a(De, "PARALLEL", "parallel");
|
|
3220
|
+
let D = De;
|
|
3221
|
+
var oe, F, Oe, Lt, Dt, Vt, he, Ei, yt, Ni, Ti, Oi, ei;
|
|
3222
|
+
const Zt = class Zt {
|
|
3123
3223
|
constructor(...e) {
|
|
3124
3224
|
d(this, he);
|
|
3125
3225
|
d(this, oe);
|
|
3126
3226
|
d(this, F);
|
|
3127
|
-
d(this,
|
|
3227
|
+
d(this, Oe);
|
|
3128
3228
|
/**
|
|
3129
3229
|
* Get the relative position between circle and line. It corresponds to the number of intersection.
|
|
3130
3230
|
* @param {Line} L
|
|
@@ -3138,42 +3238,42 @@ const Dt = class Dt {
|
|
|
3138
3238
|
});
|
|
3139
3239
|
a(this, "lineIntersection", (e) => {
|
|
3140
3240
|
const t = [];
|
|
3141
|
-
if (i(this,
|
|
3241
|
+
if (i(this, Oe) === void 0)
|
|
3142
3242
|
return [];
|
|
3143
|
-
const s = i(this,
|
|
3144
|
-
return
|
|
3243
|
+
const s = i(this, Oe).clone(), n = e.getEquation().clone().isolate("x"), r = e.getEquation().clone().isolate("y");
|
|
3244
|
+
return n instanceof H && r instanceof H && (s.replaceBy("y", r.right).simplify(), s.solve()), t;
|
|
3145
3245
|
});
|
|
3146
|
-
a(this, "tangents", (e) => e instanceof c ? i(this,
|
|
3246
|
+
a(this, "tangents", (e) => e instanceof c ? i(this, Vt).call(this, e) : this.isPointOnCircle(e) ? i(this, Lt).call(this, e) : i(this, oe) !== void 0 && i(this, oe).distanceTo(e).value > this.radius.value ? i(this, Dt).call(this, e) : (console.log("No tangents as the point is inside !"), []));
|
|
3147
3247
|
a(this, "isPointOnCircle", (e) => {
|
|
3148
3248
|
var t;
|
|
3149
|
-
return ((t = i(this,
|
|
3249
|
+
return ((t = i(this, Oe)) == null ? void 0 : t.test({ x: e.x, y: e.y })) ?? !1;
|
|
3150
3250
|
});
|
|
3151
3251
|
a(this, "getPointsOnCircle", (e) => {
|
|
3152
3252
|
const t = G.pythagoreanTripletsWithTarget(this.squareRadius.value, !0), s = [];
|
|
3153
|
-
return t.forEach((
|
|
3154
|
-
for (const
|
|
3253
|
+
return t.forEach((n) => {
|
|
3254
|
+
for (const r of [[1, 1], [-1, 1], [-1, -1], [1, -1]])
|
|
3155
3255
|
s.push(
|
|
3156
3256
|
new j(
|
|
3157
|
-
this.center.x.clone().add(
|
|
3158
|
-
this.center.y.clone().add(
|
|
3257
|
+
this.center.x.clone().add(r[0] * n[0]),
|
|
3258
|
+
this.center.y.clone().add(r[1] * n[1])
|
|
3159
3259
|
)
|
|
3160
3260
|
);
|
|
3161
3261
|
}), s;
|
|
3162
3262
|
});
|
|
3163
|
-
d(this,
|
|
3263
|
+
d(this, Lt, (e) => {
|
|
3164
3264
|
const t = new x(this.center, e);
|
|
3165
|
-
return [new D(e, t,
|
|
3265
|
+
return [new D(e, t, xi.Perpendicular)];
|
|
3166
3266
|
});
|
|
3167
|
-
d(this,
|
|
3168
|
-
const t = this.center.x.clone().subtract(e.x), s = this.center.y.clone().subtract(e.y),
|
|
3169
|
-
return
|
|
3170
|
-
let
|
|
3267
|
+
d(this, Dt, (e) => {
|
|
3268
|
+
const t = this.center.x.clone().subtract(e.x), s = this.center.y.clone().subtract(e.y), n = new A("x"), r = new A("x^2+1");
|
|
3269
|
+
return n.multiply(t).subtract(s).pow(2), r.multiply(this.squareRadius), new H(n, r).solve().map((f) => {
|
|
3270
|
+
let m;
|
|
3171
3271
|
const g = new H("y", "x");
|
|
3172
|
-
return f.exact instanceof c ? (
|
|
3272
|
+
return f.exact instanceof c ? (m = e.x.clone().opposite().multiply(f.exact).add(e.y), g.right.multiply(f.exact).add(m)) : (m = e.x.clone().opposite().multiply(f.value).add(e.y), g.right.multiply(f.value).add(m)), new D(g);
|
|
3173
3273
|
});
|
|
3174
3274
|
});
|
|
3175
|
-
d(this,
|
|
3176
|
-
const t = e.numerator, s = -e.denominator,
|
|
3275
|
+
d(this, Vt, (e) => {
|
|
3276
|
+
const t = e.numerator, s = -e.denominator, n = this.center.x.clone(), r = this.center.y.clone(), l = this.squareRadius.clone().multiply(e.numerator ** 2 + e.denominator ** 2), u = n.clone().multiply(t).opposite().subtract(r.clone().multiply(s)).add(l.clone().sqrt()), f = n.clone().multiply(t).opposite().subtract(r.clone().multiply(s)).subtract(l.clone().sqrt());
|
|
3177
3277
|
return [new D(t, s, u), new D(t, s, f)];
|
|
3178
3278
|
});
|
|
3179
3279
|
e.length > 0 && this.parse(...e);
|
|
@@ -3185,9 +3285,9 @@ const Dt = class Dt {
|
|
|
3185
3285
|
return i(this, F) ?? new c(0);
|
|
3186
3286
|
}
|
|
3187
3287
|
get cartesian() {
|
|
3188
|
-
if (i(this,
|
|
3288
|
+
if (i(this, Oe) === void 0)
|
|
3189
3289
|
throw new Error("Cartesian equation not defined");
|
|
3190
|
-
return i(this,
|
|
3290
|
+
return i(this, Oe);
|
|
3191
3291
|
}
|
|
3192
3292
|
get radius() {
|
|
3193
3293
|
return i(this, F) === void 0 ? { tex: "", display: "", value: 0 } : i(this, F).isSquare() ? {
|
|
@@ -3212,17 +3312,17 @@ const Dt = class Dt {
|
|
|
3212
3312
|
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}`;
|
|
3213
3313
|
}
|
|
3214
3314
|
clone() {
|
|
3215
|
-
return new
|
|
3315
|
+
return new Zt(
|
|
3216
3316
|
this.center.clone(),
|
|
3217
3317
|
this.squareRadius.clone(),
|
|
3218
3318
|
!0
|
|
3219
3319
|
);
|
|
3220
3320
|
}
|
|
3221
3321
|
setRadius(e, t) {
|
|
3222
|
-
return t ? h(this, F, new c(e)) : h(this, F, new c(e).pow(2)),
|
|
3322
|
+
return t ? h(this, F, new c(e)) : h(this, F, new c(e).pow(2)), q(this, he, yt).call(this), this;
|
|
3223
3323
|
}
|
|
3224
3324
|
parse(...e) {
|
|
3225
|
-
return
|
|
3325
|
+
return q(this, he, Ei).call(this), typeof e[0] == "string" ? q(this, he, ei).call(this, new H(e[0])) : e[0] instanceof H ? q(this, he, ei).call(this, e[0]) : e[0] instanceof Zt ? q(this, he, Ni).call(this, e[0]) : e[0] instanceof j && e.length > 1 && (e[1] instanceof j ? e[2] instanceof j || q(this, he, Oi).call(this, e[0], e[1]) : (e[1] instanceof c || typeof e[1] == "number") && q(this, he, Ti).call(this, e[0], e[1], typeof e[2] == "boolean" ? e[2] : !1)), q(this, he, yt).call(this), this;
|
|
3226
3326
|
}
|
|
3227
3327
|
// private _parseThroughtThreePoints(A: Point, B: Point, C: Point): this {
|
|
3228
3328
|
// const T = new Triangle(A, B, C), mAB = T.remarquables.mediators.AB.clone(),
|
|
@@ -3231,37 +3331,37 @@ const Dt = class Dt {
|
|
|
3231
3331
|
// return this
|
|
3232
3332
|
// }
|
|
3233
3333
|
};
|
|
3234
|
-
oe = new WeakMap(), F = new WeakMap(),
|
|
3235
|
-
return h(this, oe, void 0), h(this, F, void 0), h(this,
|
|
3236
|
-
},
|
|
3237
|
-
h(this,
|
|
3238
|
-
new
|
|
3239
|
-
new
|
|
3334
|
+
oe = new WeakMap(), F = new WeakMap(), Oe = new WeakMap(), Lt = new WeakMap(), Dt = new WeakMap(), Vt = new WeakMap(), he = new WeakSet(), Ei = function() {
|
|
3335
|
+
return h(this, oe, void 0), h(this, F, void 0), h(this, Oe, void 0), this;
|
|
3336
|
+
}, yt = function() {
|
|
3337
|
+
h(this, Oe, new H(
|
|
3338
|
+
new A(`(x-(${this.center.x.display}))^2+(y-(${this.center.y.display}))^2`),
|
|
3339
|
+
new A(this.squareRadius.display)
|
|
3240
3340
|
).moveLeft());
|
|
3241
|
-
},
|
|
3242
|
-
return h(this, oe, e.center.clone()), h(this, F, e.squareRadius.clone()),
|
|
3243
|
-
},
|
|
3341
|
+
}, Ni = function(e) {
|
|
3342
|
+
return h(this, oe, e.center.clone()), h(this, F, e.squareRadius.clone()), q(this, he, yt).call(this), this;
|
|
3343
|
+
}, Ti = function(e, t, s) {
|
|
3244
3344
|
return h(this, oe, e.clone()), s ? h(this, F, new c(t)) : h(this, F, new c(t).pow(2)), this;
|
|
3245
|
-
},
|
|
3345
|
+
}, Oi = function(e, t) {
|
|
3246
3346
|
return h(this, oe, e.clone()), h(this, F, new x(i(this, oe), t).normSquare), this;
|
|
3247
|
-
},
|
|
3347
|
+
}, ei = function(e) {
|
|
3248
3348
|
if (e.moveLeft(), e.degree("x").value === 2 && e.degree("y").value === 2) {
|
|
3249
3349
|
const t = e.left.monomByDegree(2, "x"), s = e.left.monomByDegree(2, "y");
|
|
3250
|
-
let
|
|
3251
|
-
t.coefficient.isEqual(s.coefficient) ? (e.divide(t.coefficient),
|
|
3350
|
+
let n, r, l;
|
|
3351
|
+
t.coefficient.isEqual(s.coefficient) ? (e.divide(t.coefficient), n = e.left.monomByDegree(1, "x"), r = e.left.monomByDegree(1, "y"), l = e.left.monomByDegree(0), h(this, oe, new j(n.coefficient.clone().divide(2).opposite(), r.coefficient.clone().divide(2).opposite())), h(this, F, l.coefficient.clone().opposite().add(i(this, oe).x.clone().pow(2)).add(i(this, oe).y.clone().pow(2)))) : (h(this, oe, void 0), h(this, F, void 0));
|
|
3252
3352
|
}
|
|
3253
3353
|
return this;
|
|
3254
3354
|
};
|
|
3255
|
-
let
|
|
3256
|
-
var Q, _, ee,
|
|
3257
|
-
const
|
|
3355
|
+
let vt = Zt;
|
|
3356
|
+
var Q, _, ee, et, Ae, ut, Ft, ft, Be, jt, tt;
|
|
3357
|
+
const Ut = class Ut {
|
|
3258
3358
|
constructor(...e) {
|
|
3259
3359
|
d(this, Q);
|
|
3260
3360
|
d(this, _);
|
|
3261
3361
|
d(this, ee);
|
|
3262
|
-
d(this,
|
|
3263
|
-
d(this,
|
|
3264
|
-
d(this,
|
|
3362
|
+
d(this, et);
|
|
3363
|
+
d(this, Ae);
|
|
3364
|
+
d(this, ut);
|
|
3265
3365
|
// ------------------------------------------
|
|
3266
3366
|
// Creation / parsing functions
|
|
3267
3367
|
// ------------------------------------------
|
|
@@ -3286,34 +3386,34 @@ const Ft = class Ft {
|
|
|
3286
3386
|
if (e.every((t) => typeof t == "string"))
|
|
3287
3387
|
return this.parse(...e.map((t) => new D(t)));
|
|
3288
3388
|
if (e.every((t) => t instanceof D)) {
|
|
3289
|
-
const t = e[0].clone(), s = e[1].clone(),
|
|
3290
|
-
h(this,
|
|
3291
|
-
let
|
|
3292
|
-
if (
|
|
3293
|
-
h(this, _,
|
|
3389
|
+
const t = e[0].clone(), s = e[1].clone(), n = e[2].clone();
|
|
3390
|
+
h(this, et, { AB: t, BC: s, AC: n });
|
|
3391
|
+
let r = t.intersection(s);
|
|
3392
|
+
if (r.hasIntersection)
|
|
3393
|
+
h(this, _, r.point.clone());
|
|
3294
3394
|
else
|
|
3295
3395
|
throw new Error("Lines do not intersect !");
|
|
3296
|
-
if (
|
|
3297
|
-
h(this, ee,
|
|
3396
|
+
if (r = s.intersection(n), r.hasIntersection)
|
|
3397
|
+
h(this, ee, r.point.clone());
|
|
3298
3398
|
else
|
|
3299
3399
|
throw new Error("Lines do not intersect !");
|
|
3300
|
-
if (
|
|
3301
|
-
h(this, Q,
|
|
3400
|
+
if (r = n.intersection(t), r.hasIntersection)
|
|
3401
|
+
h(this, Q, r.point.clone());
|
|
3302
3402
|
else
|
|
3303
3403
|
throw new Error("Lines do not intersect !");
|
|
3304
|
-
} else e.every((t) => t instanceof j) && (h(this, Q, e[0].clone()), h(this, _, e[1].clone()), h(this, ee, e[2].clone()), h(this,
|
|
3404
|
+
} else e.every((t) => t instanceof j) && (h(this, Q, e[0].clone()), h(this, _, e[1].clone()), h(this, ee, e[2].clone()), h(this, et, {
|
|
3305
3405
|
AB: new D(i(this, Q), i(this, _)),
|
|
3306
3406
|
BC: new D(i(this, _), i(this, ee)),
|
|
3307
3407
|
AC: new D(i(this, Q), i(this, ee))
|
|
3308
3408
|
}));
|
|
3309
|
-
} else if (e.length === 1 && e[0] instanceof
|
|
3409
|
+
} else if (e.length === 1 && e[0] instanceof Ut)
|
|
3310
3410
|
return e[0].clone();
|
|
3311
|
-
return i(this,
|
|
3411
|
+
return i(this, Ft).call(this), this;
|
|
3312
3412
|
});
|
|
3313
3413
|
/**
|
|
3314
3414
|
* Clone the Triangle class
|
|
3315
3415
|
*/
|
|
3316
|
-
a(this, "clone", () => new
|
|
3416
|
+
a(this, "clone", () => new Ut(
|
|
3317
3417
|
i(this, Q).clone(),
|
|
3318
3418
|
i(this, _).clone(),
|
|
3319
3419
|
i(this, ee).clone()
|
|
@@ -3324,18 +3424,18 @@ const Ft = class Ft {
|
|
|
3324
3424
|
/**
|
|
3325
3425
|
* Generate the Line object for the three segments of the triangle
|
|
3326
3426
|
*/
|
|
3327
|
-
d(this,
|
|
3328
|
-
h(this,
|
|
3427
|
+
d(this, Ft, () => {
|
|
3428
|
+
h(this, Ae, {
|
|
3329
3429
|
AB: new j().middleOf(i(this, Q), i(this, _)),
|
|
3330
3430
|
AC: new j().middleOf(i(this, Q), i(this, ee)),
|
|
3331
3431
|
BC: new j().middleOf(i(this, _), i(this, ee))
|
|
3332
|
-
}), h(this,
|
|
3432
|
+
}), h(this, ut, i(this, jt).call(this));
|
|
3333
3433
|
});
|
|
3334
3434
|
/**
|
|
3335
3435
|
* Get the Vector2D class for the given name
|
|
3336
3436
|
* @param ptName
|
|
3337
3437
|
*/
|
|
3338
|
-
d(this,
|
|
3438
|
+
d(this, ft, (e) => {
|
|
3339
3439
|
switch (e.toUpperCase()) {
|
|
3340
3440
|
case "A":
|
|
3341
3441
|
return i(this, Q);
|
|
@@ -3351,52 +3451,52 @@ const Ft = class Ft {
|
|
|
3351
3451
|
* @param ptName1
|
|
3352
3452
|
* @param ptName2
|
|
3353
3453
|
*/
|
|
3354
|
-
d(this,
|
|
3355
|
-
i(this,
|
|
3356
|
-
i(this,
|
|
3454
|
+
d(this, Be, (e, t) => new x(
|
|
3455
|
+
i(this, ft).call(this, e),
|
|
3456
|
+
i(this, ft).call(this, t)
|
|
3357
3457
|
));
|
|
3358
|
-
d(this,
|
|
3458
|
+
d(this, jt, () => {
|
|
3359
3459
|
const e = {
|
|
3360
|
-
A: new D(i(this, Q), i(this,
|
|
3361
|
-
B: new D(i(this, _), i(this,
|
|
3362
|
-
C: new D(i(this, ee), i(this,
|
|
3460
|
+
A: new D(i(this, Q), i(this, Ae).BC),
|
|
3461
|
+
B: new D(i(this, _), i(this, Ae).AC),
|
|
3462
|
+
C: new D(i(this, ee), i(this, Ae).AB),
|
|
3363
3463
|
intersection: null
|
|
3364
3464
|
}, t = {
|
|
3365
|
-
AB: new D(i(this,
|
|
3366
|
-
AC: new D(i(this,
|
|
3367
|
-
BC: new D(i(this,
|
|
3465
|
+
AB: new D(i(this, Ae).AB, new x(i(this, Q), i(this, _)).normal()),
|
|
3466
|
+
AC: new D(i(this, Ae).AC, new x(i(this, Q), i(this, ee)).normal()),
|
|
3467
|
+
BC: new D(i(this, Ae).BC, new x(i(this, _), i(this, ee)).normal()),
|
|
3368
3468
|
intersection: null
|
|
3369
3469
|
}, s = {
|
|
3370
3470
|
A: new D(i(this, Q), new x(i(this, _), i(this, ee)).normal()),
|
|
3371
3471
|
B: new D(i(this, _), new x(i(this, Q), i(this, ee)).normal()),
|
|
3372
3472
|
C: new D(i(this, ee), new x(i(this, Q), i(this, _)).normal()),
|
|
3373
3473
|
intersection: null
|
|
3374
|
-
},
|
|
3375
|
-
A:
|
|
3376
|
-
B:
|
|
3377
|
-
C:
|
|
3474
|
+
}, n = i(this, tt).call(this, "A"), r = i(this, tt).call(this, "B"), l = i(this, tt).call(this, "C"), u = {
|
|
3475
|
+
A: n.internal,
|
|
3476
|
+
B: r.internal,
|
|
3477
|
+
C: r.internal,
|
|
3378
3478
|
intersection: null
|
|
3379
3479
|
}, f = {
|
|
3380
|
-
A:
|
|
3381
|
-
B:
|
|
3480
|
+
A: n.external,
|
|
3481
|
+
B: r.external,
|
|
3382
3482
|
C: l.external,
|
|
3383
3483
|
intersection: null
|
|
3384
|
-
},
|
|
3484
|
+
}, m = {
|
|
3385
3485
|
medians: e,
|
|
3386
3486
|
mediators: t,
|
|
3387
3487
|
heights: s,
|
|
3388
3488
|
bisectors: u,
|
|
3389
3489
|
externalBisectors: f
|
|
3390
3490
|
};
|
|
3391
|
-
return
|
|
3491
|
+
return m.medians.intersection = m.medians.A.intersection(m.medians.B).point, m.mediators.intersection = m.mediators.AB.intersection(m.mediators.BC).point, m.heights.intersection = m.heights.A.intersection(m.heights.B).point, m.bisectors.intersection = m.bisectors.A.intersection(m.bisectors.B).point, m;
|
|
3392
3492
|
});
|
|
3393
|
-
d(this,
|
|
3493
|
+
d(this, tt, (e) => {
|
|
3394
3494
|
const t = this.lines;
|
|
3395
|
-
let s,
|
|
3396
|
-
if (e === "A" ? (s = t.AB,
|
|
3495
|
+
let s, n;
|
|
3496
|
+
if (e === "A" ? (s = t.AB, n = t.AC) : e === "B" ? (s = t.AB, n = t.BC) : e === "C" && (s = t.BC, n = t.AC), s === void 0 || n === void 0)
|
|
3397
3497
|
throw new Error(`The point ${e} does not exist`);
|
|
3398
|
-
const
|
|
3399
|
-
return e === "A" ?
|
|
3498
|
+
const r = s.n.simplify().norm, l = n.n.simplify().norm, u = s.getEquation().multiply(l), f = n.getEquation().multiply(r), m = new D(u.clone().subtract(f).simplify()), g = new D(f.clone().subtract(u).simplify());
|
|
3499
|
+
return e === "A" ? m.hitSegment(this.B, this.C) ? { internal: m, external: g } : { internal: g, external: m } : e === "B" ? m.hitSegment(this.A, this.C) ? { internal: m, external: g } : { internal: g, external: m } : e === "C" ? m.hitSegment(this.B, this.A) ? { internal: m, external: g } : { internal: g, external: m } : { internal: m, external: g };
|
|
3400
3500
|
});
|
|
3401
3501
|
return e.length > 0 && this.parse(...e), this;
|
|
3402
3502
|
}
|
|
@@ -3413,22 +3513,22 @@ const Ft = class Ft {
|
|
|
3413
3513
|
return i(this, ee);
|
|
3414
3514
|
}
|
|
3415
3515
|
get AB() {
|
|
3416
|
-
return i(this,
|
|
3516
|
+
return i(this, Be).call(this, "A", "B");
|
|
3417
3517
|
}
|
|
3418
3518
|
get BA() {
|
|
3419
|
-
return i(this,
|
|
3519
|
+
return i(this, Be).call(this, "B", "A");
|
|
3420
3520
|
}
|
|
3421
3521
|
get BC() {
|
|
3422
|
-
return i(this,
|
|
3522
|
+
return i(this, Be).call(this, "B", "C");
|
|
3423
3523
|
}
|
|
3424
3524
|
get CB() {
|
|
3425
|
-
return i(this,
|
|
3525
|
+
return i(this, Be).call(this, "C", "B");
|
|
3426
3526
|
}
|
|
3427
3527
|
get AC() {
|
|
3428
|
-
return i(this,
|
|
3528
|
+
return i(this, Be).call(this, "A", "C");
|
|
3429
3529
|
}
|
|
3430
3530
|
get CA() {
|
|
3431
|
-
return i(this,
|
|
3531
|
+
return i(this, Be).call(this, "C", "A");
|
|
3432
3532
|
}
|
|
3433
3533
|
get isRectangle() {
|
|
3434
3534
|
return !!(this.AB.isNormalTo(this.BC) || this.AB.isNormalTo(this.AC) || this.BC.isNormalTo(this.AC));
|
|
@@ -3440,21 +3540,21 @@ const Ft = class Ft {
|
|
|
3440
3540
|
return this.AB.normSquare.isEqual(this.BC.normSquare) || this.AB.normSquare.isEqual(this.AC.normSquare) || this.BC.normSquare.isEqual(this.AC.normSquare);
|
|
3441
3541
|
}
|
|
3442
3542
|
get lines() {
|
|
3443
|
-
return i(this,
|
|
3543
|
+
return i(this, et);
|
|
3444
3544
|
}
|
|
3445
3545
|
get remarquables() {
|
|
3446
|
-
return i(this,
|
|
3546
|
+
return i(this, ut);
|
|
3447
3547
|
}
|
|
3448
3548
|
};
|
|
3449
|
-
Q = new WeakMap(), _ = new WeakMap(), ee = new WeakMap(),
|
|
3450
|
-
let
|
|
3451
|
-
var
|
|
3452
|
-
const
|
|
3549
|
+
Q = new WeakMap(), _ = new WeakMap(), ee = new WeakMap(), et = new WeakMap(), Ae = new WeakMap(), ut = new WeakMap(), Ft = new WeakMap(), ft = new WeakMap(), Be = new WeakMap(), jt = new WeakMap(), tt = new WeakMap();
|
|
3550
|
+
let ti = Ut;
|
|
3551
|
+
var R, W;
|
|
3552
|
+
const ot = class ot {
|
|
3453
3553
|
constructor(e, t) {
|
|
3454
3554
|
// ax + by + c = 0
|
|
3455
|
-
d(this,
|
|
3555
|
+
d(this, R, new j());
|
|
3456
3556
|
d(this, W, new x());
|
|
3457
|
-
a(this, "clone", () => (h(this, W, i(this, W).clone()), h(this,
|
|
3557
|
+
a(this, "clone", () => (h(this, W, i(this, W).clone()), h(this, R, i(this, R).clone()), this));
|
|
3458
3558
|
// ------------------------------------------
|
|
3459
3559
|
// Mathematical operations
|
|
3460
3560
|
// ------------------------------------------
|
|
@@ -3494,23 +3594,23 @@ const nt = class nt {
|
|
|
3494
3594
|
// return new Fraction().invalid()
|
|
3495
3595
|
// }
|
|
3496
3596
|
a(this, "randomPoint", (e = 5) => {
|
|
3497
|
-
const t = i(this,
|
|
3597
|
+
const t = i(this, R).clone(), s = new c(X(e, !1));
|
|
3498
3598
|
return new j(
|
|
3499
3599
|
t.x.clone().add(i(this, W).x.clone().multiply(s)),
|
|
3500
3600
|
t.y.clone().add(i(this, W).y.clone().multiply(s)),
|
|
3501
3601
|
t.z.clone().add(i(this, W).z.clone().multiply(s))
|
|
3502
3602
|
);
|
|
3503
3603
|
});
|
|
3504
|
-
return h(this,
|
|
3604
|
+
return h(this, R, e.clone()), h(this, W, t.asPoint ? new x(e, t) : t.clone()), this;
|
|
3505
3605
|
}
|
|
3506
3606
|
get OA() {
|
|
3507
|
-
return i(this,
|
|
3607
|
+
return i(this, R);
|
|
3508
3608
|
}
|
|
3509
3609
|
set OA(e) {
|
|
3510
|
-
h(this,
|
|
3610
|
+
h(this, R, e);
|
|
3511
3611
|
}
|
|
3512
3612
|
get point() {
|
|
3513
|
-
return i(this,
|
|
3613
|
+
return i(this, R).clone();
|
|
3514
3614
|
}
|
|
3515
3615
|
get d() {
|
|
3516
3616
|
return i(this, W);
|
|
@@ -3520,28 +3620,28 @@ const nt = class nt {
|
|
|
3520
3620
|
}
|
|
3521
3621
|
get tex() {
|
|
3522
3622
|
return {
|
|
3523
|
-
parametric: `${x.asTex("x", "y", "z")} = ${x.asTex(i(this,
|
|
3623
|
+
parametric: `${x.asTex("x", "y", "z")} = ${x.asTex(i(this, R).x.tex, i(this, R).y.tex, i(this, R).z.tex)} + k\\cdot ${x.asTex(i(this, W).x.tex, i(this, W).y.tex, i(this, W).z.tex)}`,
|
|
3524
3624
|
system: `\\left\\{\\begin{aligned}
|
|
3525
|
-
x &= ${new
|
|
3526
|
-
y &= ${new
|
|
3527
|
-
z &= ${new
|
|
3625
|
+
x &= ${new A(i(this, R).x).add(new k(i(this, W).x).multiply(new k("k"))).reorder("k", !0).tex}\\\\
|
|
3626
|
+
y &= ${new A(i(this, R).y).add(new k(i(this, W).y).multiply(new k("k"))).reorder("k", !0).tex}\\\\
|
|
3627
|
+
z &= ${new A(i(this, R).z).add(new k(i(this, W).z).multiply(new k("k"))).reorder("k", !0).tex}
|
|
3528
3628
|
\\end{aligned}\\right.`,
|
|
3529
|
-
cartesian: `\\frac{ ${new
|
|
3629
|
+
cartesian: `\\frac{ ${new A("x", 1, i(this, R).x.clone().opposite()).tex} }{ ${this.direction.x.tex} } = \\frac{ ${new A("y", 1, i(this, R).y.clone().opposite()).tex} }{ ${this.direction.y.tex} } = \\frac{ ${new A("z", 1, i(this, R).z.clone().opposite()).tex} }{ ${this.direction.z.tex} }`
|
|
3530
3630
|
};
|
|
3531
3631
|
}
|
|
3532
3632
|
get display() {
|
|
3533
|
-
const e = i(this,
|
|
3633
|
+
const e = i(this, R).x.display, t = i(this, R).y.display, s = i(this, R).z.display, n = this.direction.simplify(), r = n.x.display, l = n.y.display, u = n.z.display;
|
|
3534
3634
|
return {
|
|
3535
|
-
parametric: `${x.asDisplay("x", "y", "z")} = ${x.asDisplay(i(this,
|
|
3635
|
+
parametric: `${x.asDisplay("x", "y", "z")} = ${x.asDisplay(i(this, R).x.display, i(this, R).y.display, i(this, R).z.display)} + k\\cdot ${x.asDisplay(i(this, W).x.display, i(this, W).y.display, i(this, W).z.display)}`,
|
|
3536
3636
|
system: "",
|
|
3537
|
-
cartesian: `(x-${e})/${
|
|
3637
|
+
cartesian: `(x-${e})/${r} = (y-${t})/${l} = (z-${s})/${u}`
|
|
3538
3638
|
};
|
|
3539
3639
|
}
|
|
3540
3640
|
get direction() {
|
|
3541
3641
|
return i(this, W).clone();
|
|
3542
3642
|
}
|
|
3543
3643
|
distanceTo(e) {
|
|
3544
|
-
const t = new x(i(this,
|
|
3644
|
+
const t = new x(i(this, R), e), s = this.direction, n = this.direction.normSquare, r = t.cross(s).normSquare, l = r.clone().divide(n), u = l.clone().sqrt();
|
|
3545
3645
|
return console.log("CROSS", t.cross(s).display), {
|
|
3546
3646
|
value: Math.sqrt(l.value),
|
|
3547
3647
|
fraction: l.clone().sqrt(),
|
|
@@ -3550,97 +3650,97 @@ const nt = class nt {
|
|
|
3550
3650
|
}
|
|
3551
3651
|
hitSegment(e, t) {
|
|
3552
3652
|
const s = this.intersection(
|
|
3553
|
-
new
|
|
3653
|
+
new ot(e, t)
|
|
3554
3654
|
);
|
|
3555
3655
|
return s.hasIntersection ? s.point.x.value >= Math.min(e.x.value, t.x.value) && s.point.x.value <= Math.max(e.x.value, t.x.value) && s.point.y.value >= Math.min(e.y.value, t.y.value) && s.point.y.value <= Math.max(e.y.value, t.y.value) && s.point.z.value >= Math.min(e.z.value, t.z.value) && s.point.z.value <= Math.max(e.z.value, t.z.value) : !1;
|
|
3556
3656
|
}
|
|
3557
3657
|
};
|
|
3558
|
-
|
|
3559
|
-
a(
|
|
3560
|
-
let
|
|
3561
|
-
var
|
|
3562
|
-
const
|
|
3658
|
+
R = new WeakMap(), W = new WeakMap(), // A line is defined as the canonical form
|
|
3659
|
+
a(ot, "PERPENDICULAR", "perpendicular"), a(ot, "PARALLEL", "parallel");
|
|
3660
|
+
let bt = ot;
|
|
3661
|
+
var qe, Ue;
|
|
3662
|
+
const ai = class ai {
|
|
3563
3663
|
constructor(e) {
|
|
3564
|
-
d(this,
|
|
3565
|
-
d(this,
|
|
3664
|
+
d(this, qe, new x(0, 0, 1));
|
|
3665
|
+
d(this, Ue, new j(0, 0, 0));
|
|
3566
3666
|
return e && this.parse(e), this;
|
|
3567
3667
|
}
|
|
3568
3668
|
get normal() {
|
|
3569
|
-
return i(this,
|
|
3669
|
+
return i(this, qe);
|
|
3570
3670
|
}
|
|
3571
3671
|
set normal(e) {
|
|
3572
|
-
h(this,
|
|
3672
|
+
h(this, qe, e), i(this, qe).asPoint = !1;
|
|
3573
3673
|
}
|
|
3574
3674
|
get point() {
|
|
3575
|
-
return i(this,
|
|
3675
|
+
return i(this, Ue);
|
|
3576
3676
|
}
|
|
3577
3677
|
set point(e) {
|
|
3578
|
-
h(this,
|
|
3678
|
+
h(this, Ue, e), i(this, Ue).asPoint = !0;
|
|
3579
3679
|
}
|
|
3580
3680
|
get a() {
|
|
3581
|
-
return i(this,
|
|
3681
|
+
return i(this, qe).x;
|
|
3582
3682
|
}
|
|
3583
3683
|
get b() {
|
|
3584
|
-
return i(this,
|
|
3684
|
+
return i(this, qe).y;
|
|
3585
3685
|
}
|
|
3586
3686
|
get c() {
|
|
3587
|
-
return i(this,
|
|
3687
|
+
return i(this, qe).z;
|
|
3588
3688
|
}
|
|
3589
3689
|
get d() {
|
|
3590
|
-
return i(this,
|
|
3690
|
+
return i(this, qe).dot(i(this, Ue)).opposite();
|
|
3591
3691
|
}
|
|
3592
3692
|
get tex() {
|
|
3593
3693
|
return new H(
|
|
3594
|
-
new
|
|
3595
|
-
new
|
|
3694
|
+
new A("xyz", this.a, this.b, this.c, this.d),
|
|
3695
|
+
new A(0)
|
|
3596
3696
|
).reduce().tex;
|
|
3597
3697
|
}
|
|
3598
3698
|
parse(e) {
|
|
3599
|
-
var t, s,
|
|
3699
|
+
var t, s, n;
|
|
3600
3700
|
if (e.point && e.normal) {
|
|
3601
3701
|
this.point = e.point, this.normal = e.normal;
|
|
3602
3702
|
return;
|
|
3603
3703
|
}
|
|
3604
3704
|
if (e.point && ((t = e.directions) == null ? void 0 : t.length) === 2) {
|
|
3605
3705
|
this.point = e.point;
|
|
3606
|
-
const [
|
|
3607
|
-
this.normal =
|
|
3706
|
+
const [r, l] = e.directions;
|
|
3707
|
+
this.normal = r.cross(l);
|
|
3608
3708
|
return;
|
|
3609
3709
|
}
|
|
3610
3710
|
if (e.equation) {
|
|
3611
|
-
const
|
|
3612
|
-
this.normal = new x(l, u, f), l.isNotZero() ? this.point = new j(
|
|
3711
|
+
const r = e.equation.moveLeft().reduce().left, l = r.monomByLetter("x").coefficient, u = r.monomByLetter("y").coefficient, f = r.monomByLetter("z").coefficient, m = r.monomByDegree(0).coefficient;
|
|
3712
|
+
this.normal = new x(l, u, f), l.isNotZero() ? this.point = new j(m.clone().divide(l).opposite(), 0, 0) : u.isNotZero() ? this.point = new j(0, m.clone().divide(u).opposite(), 0) : this.point = new j(0, 0, m.clone().divide(f).opposite());
|
|
3613
3713
|
return;
|
|
3614
3714
|
}
|
|
3615
|
-
if (((s = e.points) == null ? void 0 : s.length) === 3 && e.points.every((
|
|
3616
|
-
const
|
|
3617
|
-
this.normal = f.cross(
|
|
3715
|
+
if (((s = e.points) == null ? void 0 : s.length) === 3 && e.points.every((r) => r instanceof x)) {
|
|
3716
|
+
const r = e.points[0], l = e.points[1], u = e.points[2], f = new x(r, l), m = new x(r, u);
|
|
3717
|
+
this.normal = f.cross(m), this.point = r;
|
|
3618
3718
|
return;
|
|
3619
3719
|
}
|
|
3620
|
-
if (((
|
|
3621
|
-
const [
|
|
3622
|
-
this.normal = new x(
|
|
3720
|
+
if (((n = e.coefficients) == null ? void 0 : n.length) === 4) {
|
|
3721
|
+
const [r, l, u, f] = e.coefficients;
|
|
3722
|
+
this.normal = new x(r, l, u), this.point = new j(0, 0, -f);
|
|
3623
3723
|
return;
|
|
3624
3724
|
}
|
|
3625
3725
|
}
|
|
3626
3726
|
angle(e, t, s) {
|
|
3627
|
-
if (e instanceof
|
|
3727
|
+
if (e instanceof ai)
|
|
3628
3728
|
return this.normal.angle(e.normal, t, s);
|
|
3629
|
-
let
|
|
3729
|
+
let n;
|
|
3630
3730
|
if (e instanceof x) {
|
|
3631
3731
|
if (e.dimension !== 3)
|
|
3632
3732
|
throw new Error("Vector is not 3D");
|
|
3633
|
-
|
|
3733
|
+
n = e;
|
|
3634
3734
|
} else
|
|
3635
|
-
|
|
3636
|
-
return (s ? Math.PI / 2 : 90) - this.normal.angle(
|
|
3735
|
+
n = e.direction;
|
|
3736
|
+
return (s ? Math.PI / 2 : 90) - this.normal.angle(n, !0, s);
|
|
3637
3737
|
}
|
|
3638
3738
|
distanceTo(e) {
|
|
3639
3739
|
return this.normal.dot(e).add(this.d).abs().value / this.normal.norm;
|
|
3640
3740
|
}
|
|
3641
3741
|
intersectWithLine(e) {
|
|
3642
|
-
const { point: t, direction: s } = e,
|
|
3643
|
-
return t.clone().add(s.clone().multiplyByScalar(
|
|
3742
|
+
const { point: t, direction: s } = e, n = this.normal.dot(t).add(this.d).divide(this.normal.dot(s).opposite());
|
|
3743
|
+
return t.clone().add(s.clone().multiplyByScalar(n));
|
|
3644
3744
|
}
|
|
3645
3745
|
intersectWithPlane(e) {
|
|
3646
3746
|
throw this.normal.cross(e.normal), new j(0, 0, 0), new Error("Intersection with plane not yet implemented !");
|
|
@@ -3649,10 +3749,10 @@ const ii = class ii {
|
|
|
3649
3749
|
return this.normal.dot(e).add(this.d).isZero();
|
|
3650
3750
|
}
|
|
3651
3751
|
};
|
|
3652
|
-
|
|
3653
|
-
let
|
|
3752
|
+
qe = new WeakMap(), Ue = new WeakMap();
|
|
3753
|
+
let ii = ai;
|
|
3654
3754
|
var Me;
|
|
3655
|
-
class
|
|
3755
|
+
class es {
|
|
3656
3756
|
constructor(...e) {
|
|
3657
3757
|
d(this, Me, []);
|
|
3658
3758
|
return h(this, Me, e), this;
|
|
@@ -3672,11 +3772,11 @@ class Hi {
|
|
|
3672
3772
|
determinant() {
|
|
3673
3773
|
if (!this.isSquare())
|
|
3674
3774
|
throw new Error("Matrix is not square");
|
|
3675
|
-
return
|
|
3775
|
+
return Ki(...this.values);
|
|
3676
3776
|
}
|
|
3677
3777
|
}
|
|
3678
3778
|
Me = new WeakMap();
|
|
3679
|
-
function
|
|
3779
|
+
function xt(o) {
|
|
3680
3780
|
const e = Object.assign(
|
|
3681
3781
|
{
|
|
3682
3782
|
negative: !0,
|
|
@@ -3696,7 +3796,7 @@ function vt(o) {
|
|
|
3696
3796
|
}
|
|
3697
3797
|
return e.reduced ? t.reduce() : t;
|
|
3698
3798
|
}
|
|
3699
|
-
function
|
|
3799
|
+
function Ai(o) {
|
|
3700
3800
|
const e = Object.assign(
|
|
3701
3801
|
{
|
|
3702
3802
|
letters: "x",
|
|
@@ -3705,8 +3805,8 @@ function Ei(o) {
|
|
|
3705
3805
|
zero: !1
|
|
3706
3806
|
},
|
|
3707
3807
|
o
|
|
3708
|
-
), t = new
|
|
3709
|
-
if (t.coefficient =
|
|
3808
|
+
), t = new k();
|
|
3809
|
+
if (t.coefficient = xt({
|
|
3710
3810
|
zero: e.zero,
|
|
3711
3811
|
reduced: !0,
|
|
3712
3812
|
natural: !e.fraction
|
|
@@ -3714,14 +3814,14 @@ function Ei(o) {
|
|
|
3714
3814
|
for (const s of e.letters.split(""))
|
|
3715
3815
|
t.setLetter(s, 0);
|
|
3716
3816
|
for (let s = 0; s < e.degree; s++) {
|
|
3717
|
-
const
|
|
3718
|
-
t.setLetter(
|
|
3817
|
+
const n = oi(e.letters.split(""));
|
|
3818
|
+
t.setLetter(n, t.degree(n).clone().add(1));
|
|
3719
3819
|
}
|
|
3720
3820
|
} else
|
|
3721
3821
|
t.setLetter(e.letters, e.degree);
|
|
3722
3822
|
return t;
|
|
3723
3823
|
}
|
|
3724
|
-
const
|
|
3824
|
+
const ts = {
|
|
3725
3825
|
letters: "x",
|
|
3726
3826
|
degree: 2,
|
|
3727
3827
|
fraction: !1,
|
|
@@ -3732,27 +3832,27 @@ const Xi = {
|
|
|
3732
3832
|
numberOfMonoms: 0,
|
|
3733
3833
|
positive: !0
|
|
3734
3834
|
};
|
|
3735
|
-
function
|
|
3835
|
+
function qi(o) {
|
|
3736
3836
|
const e = Object.assign(
|
|
3737
|
-
|
|
3837
|
+
ts,
|
|
3738
3838
|
o
|
|
3739
|
-
), t = new
|
|
3839
|
+
), t = new A().empty();
|
|
3740
3840
|
let s;
|
|
3741
|
-
for (let
|
|
3742
|
-
s =
|
|
3841
|
+
for (let n = e.degree; n >= 0; n--)
|
|
3842
|
+
s = Ai({
|
|
3743
3843
|
letters: e.letters,
|
|
3744
|
-
degree:
|
|
3844
|
+
degree: n,
|
|
3745
3845
|
fraction: e.fraction,
|
|
3746
|
-
zero:
|
|
3747
|
-
}), e.unit && e.degree ===
|
|
3846
|
+
zero: n === e.degree ? !1 : e.allowNullMonom
|
|
3847
|
+
}), e.unit && e.degree === n && s.coefficient.one(), t.add(s);
|
|
3748
3848
|
if (e.positive && t.monomByDegree().coefficient.isNegative() && t.monomByDegree().coefficient.opposite(), e.numberOfMonoms && e.numberOfMonoms > 0 && e.numberOfMonoms < t.length)
|
|
3749
3849
|
for (; t.length > e.numberOfMonoms; ) {
|
|
3750
|
-
const
|
|
3751
|
-
t.monoms.splice(
|
|
3850
|
+
const n = de(1, t.length - 1);
|
|
3851
|
+
t.monoms.splice(n, 1);
|
|
3752
3852
|
}
|
|
3753
3853
|
return t;
|
|
3754
3854
|
}
|
|
3755
|
-
function
|
|
3855
|
+
function is(o) {
|
|
3756
3856
|
const e = Object.assign(
|
|
3757
3857
|
{
|
|
3758
3858
|
letters: "x",
|
|
@@ -3772,20 +3872,20 @@ function Yi(o) {
|
|
|
3772
3872
|
}
|
|
3773
3873
|
},
|
|
3774
3874
|
o
|
|
3775
|
-
), t = new
|
|
3875
|
+
), t = new A().one();
|
|
3776
3876
|
for (let s = 0; s < e.degree; s++) {
|
|
3777
|
-
const
|
|
3877
|
+
const n = qi({
|
|
3778
3878
|
degree: 1,
|
|
3779
3879
|
unit: e.unit,
|
|
3780
3880
|
fraction: e.fraction,
|
|
3781
3881
|
letters: e.letters,
|
|
3782
3882
|
zero: e.zero
|
|
3783
3883
|
});
|
|
3784
|
-
t.multiply(
|
|
3884
|
+
t.multiply(n);
|
|
3785
3885
|
}
|
|
3786
3886
|
return new H(t, 0);
|
|
3787
3887
|
}
|
|
3788
|
-
function
|
|
3888
|
+
function Mi(o) {
|
|
3789
3889
|
const e = Object.assign(
|
|
3790
3890
|
{
|
|
3791
3891
|
axis: !0,
|
|
@@ -3794,10 +3894,10 @@ function Oi(o) {
|
|
|
3794
3894
|
quadrant: null
|
|
3795
3895
|
},
|
|
3796
3896
|
o
|
|
3797
|
-
), t = e.axis === "x", s = e.axis === "y",
|
|
3798
|
-
return Number(e.quadrant) === 1 && (
|
|
3897
|
+
), t = e.axis === "x", s = e.axis === "y", n = e.fraction ? xt({ max: e.max, zero: t }) : new c(X(e.max, t)), r = e.fraction ? xt({ max: e.max, zero: s }) : new c(X(e.max, s));
|
|
3898
|
+
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 j(n, r);
|
|
3799
3899
|
}
|
|
3800
|
-
function
|
|
3900
|
+
function ss(o) {
|
|
3801
3901
|
const e = Object.assign(
|
|
3802
3902
|
{
|
|
3803
3903
|
center: {
|
|
@@ -3807,11 +3907,11 @@ function Qi(o) {
|
|
|
3807
3907
|
pointsOnCircle: 8
|
|
3808
3908
|
},
|
|
3809
3909
|
o
|
|
3810
|
-
), t =
|
|
3811
|
-
let s,
|
|
3812
|
-
return e.pointsOnCircle === 8 ? (s = de(1, 3),
|
|
3910
|
+
), t = Mi(e.center);
|
|
3911
|
+
let s, n;
|
|
3912
|
+
return e.pointsOnCircle === 8 ? (s = de(1, 3), n = s ** 2 + (s + 1) ** 2) : n = de(1, 20), new vt(t, n, !0);
|
|
3813
3913
|
}
|
|
3814
|
-
function
|
|
3914
|
+
function ns(o) {
|
|
3815
3915
|
const e = Object.assign(
|
|
3816
3916
|
{
|
|
3817
3917
|
A: {
|
|
@@ -3828,7 +3928,7 @@ function Ki(o) {
|
|
|
3828
3928
|
t.x = X(10), t.y = X(10);
|
|
3829
3929
|
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 D(new x(e.A.x, e.A.y), t);
|
|
3830
3930
|
}
|
|
3831
|
-
function
|
|
3931
|
+
function rs(o) {
|
|
3832
3932
|
const e = Object.assign(
|
|
3833
3933
|
{
|
|
3834
3934
|
A: {
|
|
@@ -3844,47 +3944,210 @@ function Ji(o) {
|
|
|
3844
3944
|
},
|
|
3845
3945
|
o
|
|
3846
3946
|
), t = new j(e.A.x, e.A.y, e.A.z), s = new x(e.direction.x, e.direction.y, e.direction.z);
|
|
3847
|
-
return new
|
|
3947
|
+
return new bt(t, s);
|
|
3848
3948
|
}
|
|
3849
|
-
const
|
|
3850
|
-
equation: (o) =>
|
|
3851
|
-
polynom: (o) =>
|
|
3852
|
-
monom: (o) =>
|
|
3853
|
-
fraction: (o) =>
|
|
3949
|
+
const os = {
|
|
3950
|
+
equation: (o) => is(o),
|
|
3951
|
+
polynom: (o) => qi(o),
|
|
3952
|
+
monom: (o) => Ai(o),
|
|
3953
|
+
fraction: (o) => xt(o),
|
|
3854
3954
|
number: (o, e, t) => de(o, e, t),
|
|
3855
3955
|
numberSym: (o, e) => X(o, e),
|
|
3856
|
-
prime: (o) =>
|
|
3857
|
-
bool: (o) =>
|
|
3858
|
-
array: (o, e) =>
|
|
3859
|
-
item: (o) =>
|
|
3860
|
-
shuffle: (o) =>
|
|
3861
|
-
line: (o) =>
|
|
3862
|
-
line3: (o) =>
|
|
3863
|
-
point: (o) =>
|
|
3864
|
-
circle: (o) =>
|
|
3865
|
-
}
|
|
3956
|
+
prime: (o) => Ji(o),
|
|
3957
|
+
bool: (o) => vi(o),
|
|
3958
|
+
array: (o, e) => _i(o, e),
|
|
3959
|
+
item: (o) => oi(o),
|
|
3960
|
+
shuffle: (o) => bi(o),
|
|
3961
|
+
line: (o) => ns(o),
|
|
3962
|
+
line3: (o) => rs(o),
|
|
3963
|
+
point: (o) => Mi(o),
|
|
3964
|
+
circle: (o) => ss(o)
|
|
3965
|
+
};
|
|
3966
|
+
var ke, dt, si;
|
|
3967
|
+
class hs {
|
|
3968
|
+
/**
|
|
3969
|
+
*
|
|
3970
|
+
* @param {string} value (optional) Default polynom to parse on class creation
|
|
3971
|
+
*/
|
|
3972
|
+
constructor(e) {
|
|
3973
|
+
d(this, dt);
|
|
3974
|
+
d(this, ke);
|
|
3975
|
+
a(this, "parse", (e) => (h(this, ke, new Gt(Ve.SET).parse(e).rpn), this));
|
|
3976
|
+
return h(this, ke, []), e !== void 0 && this.parse(e), this;
|
|
3977
|
+
}
|
|
3978
|
+
evaluate(e) {
|
|
3979
|
+
this.variables.forEach((s) => {
|
|
3980
|
+
Object.hasOwn(e, s) || (e[s] = !1);
|
|
3981
|
+
});
|
|
3982
|
+
const t = [];
|
|
3983
|
+
for (const s of i(this, ke))
|
|
3984
|
+
if (console.log(s), s.tokenType === "variable")
|
|
3985
|
+
t.push(e[s.token]);
|
|
3986
|
+
else if (s.tokenType === "operation")
|
|
3987
|
+
if (s.token === "!")
|
|
3988
|
+
if (t.length >= 1) {
|
|
3989
|
+
const n = t.pop();
|
|
3990
|
+
t.push(!n);
|
|
3991
|
+
} else
|
|
3992
|
+
return !1;
|
|
3993
|
+
else {
|
|
3994
|
+
const n = t.pop(), r = t.pop();
|
|
3995
|
+
if (n !== void 0 && r !== void 0)
|
|
3996
|
+
switch (s.token) {
|
|
3997
|
+
case "&":
|
|
3998
|
+
t.push(n && r);
|
|
3999
|
+
break;
|
|
4000
|
+
case "|":
|
|
4001
|
+
t.push(n || r);
|
|
4002
|
+
break;
|
|
4003
|
+
case "-":
|
|
4004
|
+
return !1;
|
|
4005
|
+
}
|
|
4006
|
+
else
|
|
4007
|
+
return !1;
|
|
4008
|
+
}
|
|
4009
|
+
return t.length === 1 && t[0];
|
|
4010
|
+
}
|
|
4011
|
+
get rpn() {
|
|
4012
|
+
return i(this, ke);
|
|
4013
|
+
}
|
|
4014
|
+
get tex() {
|
|
4015
|
+
const e = [];
|
|
4016
|
+
for (const t of i(this, ke))
|
|
4017
|
+
if (t.tokenType === "variable")
|
|
4018
|
+
e.push(t);
|
|
4019
|
+
else
|
|
4020
|
+
switch (t.token) {
|
|
4021
|
+
case "&":
|
|
4022
|
+
if (e.length >= 2) {
|
|
4023
|
+
const s = e.pop(), n = e.pop();
|
|
4024
|
+
s && n && (n.tokenType === "mix" && (n.token = `( ${n.token} )`), s.tokenType === "mix" && (s.token = `( ${s.token} )`), e.push({ token: `${n.token} \\cap ${s.token}`, tokenType: "mix" }));
|
|
4025
|
+
}
|
|
4026
|
+
break;
|
|
4027
|
+
case "|":
|
|
4028
|
+
if (e.length >= 2) {
|
|
4029
|
+
const s = e.pop(), n = e.pop();
|
|
4030
|
+
s && n && (n.tokenType === "mix" && (n.token = `( ${n.token} )`), s.tokenType === "mix" && (s.token = `( ${s.token} )`), e.push({ token: `${n.token} \\cup ${s.token}`, tokenType: "mix" }));
|
|
4031
|
+
}
|
|
4032
|
+
break;
|
|
4033
|
+
case "-":
|
|
4034
|
+
if (e.length >= 2) {
|
|
4035
|
+
const s = e.pop(), n = e.pop();
|
|
4036
|
+
s && n && (n.tokenType === "mix" && (n.token = `( ${n.token} )`), s.tokenType === "mix" && (s.token = `( ${s.token} )`), e.push({ token: `${n.token} \\setminus ${s.token}`, tokenType: "mix" }));
|
|
4037
|
+
}
|
|
4038
|
+
break;
|
|
4039
|
+
case "!":
|
|
4040
|
+
if (e.length >= 1) {
|
|
4041
|
+
const s = e.pop();
|
|
4042
|
+
s && e.push({ token: `\\overline{ ${s.token} }`, tokenType: "variable" });
|
|
4043
|
+
}
|
|
4044
|
+
break;
|
|
4045
|
+
}
|
|
4046
|
+
return e[0].token;
|
|
4047
|
+
}
|
|
4048
|
+
get variables() {
|
|
4049
|
+
return i(this, ke).filter((e) => e.tokenType === "variable").map((e) => e.token);
|
|
4050
|
+
}
|
|
4051
|
+
vennAB() {
|
|
4052
|
+
return q(this, dt, si).call(this, {
|
|
4053
|
+
A: ["A", "AB"],
|
|
4054
|
+
B: ["B", "AB"]
|
|
4055
|
+
}, ["A", "B", "AB", "E"]);
|
|
4056
|
+
}
|
|
4057
|
+
vennABC() {
|
|
4058
|
+
return q(this, dt, si).call(this, {
|
|
4059
|
+
A: ["A", "AB", "AC", "ABC"],
|
|
4060
|
+
B: ["B", "AB", "BC", "ABC"],
|
|
4061
|
+
C: ["C", "AC", "BC", "ABC"]
|
|
4062
|
+
}, ["A", "B", "C", "AB", "AC", "BC", "ABC", "E"]);
|
|
4063
|
+
}
|
|
4064
|
+
}
|
|
4065
|
+
ke = new WeakMap(), dt = new WeakSet(), si = function(e, t) {
|
|
4066
|
+
const s = [];
|
|
4067
|
+
let n;
|
|
4068
|
+
if (t === void 0) {
|
|
4069
|
+
n = /* @__PURE__ */ new Set();
|
|
4070
|
+
for (const r in e)
|
|
4071
|
+
n = /* @__PURE__ */ new Set([
|
|
4072
|
+
...n,
|
|
4073
|
+
...e[r] ?? []
|
|
4074
|
+
]);
|
|
4075
|
+
} else
|
|
4076
|
+
n = new Set(t);
|
|
4077
|
+
for (const r of i(this, ke))
|
|
4078
|
+
if (r.tokenType === "variable")
|
|
4079
|
+
e[r.token] === void 0 ? s.push(/* @__PURE__ */ new Set()) : s.push(new Set(e[r.token]));
|
|
4080
|
+
else
|
|
4081
|
+
switch (r.token) {
|
|
4082
|
+
case "&":
|
|
4083
|
+
if (s.length >= 2) {
|
|
4084
|
+
const l = s.pop(), u = s.pop();
|
|
4085
|
+
u && l && s.push(new Set([...u].filter((f) => l.has(f))));
|
|
4086
|
+
}
|
|
4087
|
+
break;
|
|
4088
|
+
case "|":
|
|
4089
|
+
if (s.length >= 2) {
|
|
4090
|
+
const l = s.pop(), u = s.pop();
|
|
4091
|
+
u && l && s.push(/* @__PURE__ */ new Set([...u, ...l]));
|
|
4092
|
+
}
|
|
4093
|
+
break;
|
|
4094
|
+
case "-":
|
|
4095
|
+
if (s.length >= 2) {
|
|
4096
|
+
const l = s.pop(), u = s.pop();
|
|
4097
|
+
u && l && s.push(new Set([...u].filter((f) => !l.has(f))));
|
|
4098
|
+
}
|
|
4099
|
+
break;
|
|
4100
|
+
case "!":
|
|
4101
|
+
if (s.length >= 1) {
|
|
4102
|
+
const l = s.pop();
|
|
4103
|
+
l && s.push(new Set([...n].filter((u) => !l.has(u))));
|
|
4104
|
+
}
|
|
4105
|
+
break;
|
|
4106
|
+
}
|
|
4107
|
+
return [...s[0]].sort();
|
|
4108
|
+
};
|
|
4109
|
+
const as = {
|
|
3866
4110
|
Vector: x,
|
|
3867
4111
|
Point: j,
|
|
3868
4112
|
Line: D,
|
|
3869
|
-
Triangle:
|
|
3870
|
-
Circle:
|
|
3871
|
-
Line3:
|
|
3872
|
-
Plane3:
|
|
3873
|
-
},
|
|
4113
|
+
Triangle: ti,
|
|
4114
|
+
Circle: vt,
|
|
4115
|
+
Line3: bt,
|
|
4116
|
+
Plane3: ii
|
|
4117
|
+
}, cs = {
|
|
3874
4118
|
Numeric: G,
|
|
3875
4119
|
Fraction: c,
|
|
3876
|
-
Root:
|
|
3877
|
-
Monom:
|
|
3878
|
-
Polynom:
|
|
4120
|
+
Root: pt,
|
|
4121
|
+
Monom: k,
|
|
4122
|
+
Polynom: A,
|
|
3879
4123
|
Equation: H,
|
|
3880
|
-
Matrix:
|
|
3881
|
-
LinearSystem:
|
|
4124
|
+
Matrix: es,
|
|
4125
|
+
LinearSystem: _t,
|
|
3882
4126
|
Factor: fe,
|
|
3883
|
-
PolyFactor:
|
|
3884
|
-
|
|
3885
|
-
Random:
|
|
3886
|
-
Geometry:
|
|
4127
|
+
PolyFactor: Kt,
|
|
4128
|
+
LogicalSet: hs,
|
|
4129
|
+
Random: os,
|
|
4130
|
+
Geometry: as,
|
|
4131
|
+
NumExp: Hi
|
|
3887
4132
|
};
|
|
3888
4133
|
export {
|
|
3889
|
-
|
|
4134
|
+
vt as Circle,
|
|
4135
|
+
H as Equation,
|
|
4136
|
+
fe as Factor,
|
|
4137
|
+
c as Fraction,
|
|
4138
|
+
D as Line,
|
|
4139
|
+
bt as Line3,
|
|
4140
|
+
_t as LinearSystem,
|
|
4141
|
+
hs as LogicalSet,
|
|
4142
|
+
es as Matrix,
|
|
4143
|
+
k as Monom,
|
|
4144
|
+
pt as NthRoot,
|
|
4145
|
+
Hi as NumExp,
|
|
4146
|
+
ii as Plane3,
|
|
4147
|
+
j as Point,
|
|
4148
|
+
Kt as PolyFactor,
|
|
4149
|
+
A as Polynom,
|
|
4150
|
+
ti as Triangle,
|
|
4151
|
+
x as Vector,
|
|
4152
|
+
cs as default
|
|
3890
4153
|
};
|