pimath 0.1.17 → 0.1.18
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 +640 -628
- package/package.json +1 -1
- package/types/algebra/factor.d.ts +5 -5
- package/types/algebra/factor.d.ts.map +1 -1
- package/types/algebra/polyFactor.d.ts +3 -3
- package/types/algebra/polyFactor.d.ts.map +1 -1
- package/types/geometry/triangle.d.ts +1 -1
- package/types/geometry/triangle.d.ts.map +1 -1
- package/types/randomization/algebra/rndPolynom.d.ts.map +1 -1
package/dist/pimath.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var Bi = Object.defineProperty;
|
|
2
|
+
var mi = (o) => {
|
|
3
3
|
throw TypeError(o);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var a = (o, e, t) =>
|
|
7
|
-
var s = (o, e, t) => (
|
|
8
|
-
function
|
|
9
|
-
const e =
|
|
5
|
+
var Si = (o, e, t) => e in o ? Bi(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
6
|
+
var a = (o, e, t) => Si(o, typeof e != "symbol" ? e + "" : e, t), Kt = (o, e, t) => e.has(o) || mi("Cannot " + t);
|
|
7
|
+
var s = (o, e, t) => (Kt(o, e, "read from private field"), t ? t.call(o) : e.get(o)), p = (o, e, t) => e.has(o) ? mi("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), h = (o, e, t, i) => (Kt(o, e, "write to private field"), i ? i.call(o, t) : e.set(o, t), t), O = (o, e, t) => (Kt(o, e, "access private method"), t);
|
|
8
|
+
function Ri(o) {
|
|
9
|
+
const e = yi(o), t = [];
|
|
10
10
|
let i, n;
|
|
11
11
|
for (; e.length > 0; )
|
|
12
12
|
i = e.shift() ?? 1, n = (e.length > 0 ? e.pop() : +i) ?? 1, t.push([i, n]);
|
|
13
13
|
return t;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
const e =
|
|
15
|
+
function zi(...o) {
|
|
16
|
+
const e = ci(...o);
|
|
17
17
|
return o.map((t) => t / e);
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function yi(o) {
|
|
20
20
|
const e = Math.abs(o), t = Math.sqrt(e), i = [];
|
|
21
21
|
for (let n = 1; n <= t; n++)
|
|
22
22
|
o % n === 0 && (i.push(n), i.push(e / n));
|
|
@@ -24,7 +24,7 @@ function mi(o) {
|
|
|
24
24
|
return n - r;
|
|
25
25
|
}), [...new Set(i)];
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function ci(...o) {
|
|
28
28
|
const e = function(n, r) {
|
|
29
29
|
return r === 0 ? n : e(r, n % r);
|
|
30
30
|
};
|
|
@@ -39,44 +39,44 @@ function ai(...o) {
|
|
|
39
39
|
;
|
|
40
40
|
return Math.abs(t);
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function Li(...o) {
|
|
43
43
|
return o.reduce(function(e, t) {
|
|
44
|
-
return Math.abs(e * t /
|
|
44
|
+
return Math.abs(e * t / ci(e, t));
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function Di(o, e = 3) {
|
|
48
48
|
return +o.toFixed(e);
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function Vi(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 Zi(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 Fi(o, e) {
|
|
60
60
|
const t = [], i = e === !0 ? +o : o ** 2;
|
|
61
61
|
for (let n = 0; n <= o; n++)
|
|
62
62
|
for (let r = 0; r <= o; r++)
|
|
63
63
|
n ** 2 + r ** 2 === i && t.push([n, r, o]);
|
|
64
64
|
return t;
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function ji(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: Ri,
|
|
71
|
+
dividers: yi,
|
|
72
|
+
divideNumbersByGCD: zi,
|
|
73
|
+
gcd: ci,
|
|
74
|
+
lcm: Li,
|
|
75
|
+
numberCorrection: Di,
|
|
76
|
+
periodic: Vi,
|
|
77
|
+
primes: Zi,
|
|
78
|
+
pythagoreanTripletsWithTarget: Fi,
|
|
79
|
+
round: ji
|
|
80
80
|
};
|
|
81
81
|
var lt, b, w, Re;
|
|
82
82
|
const $ = class $ {
|
|
@@ -325,17 +325,17 @@ a($, "unique", (e) => {
|
|
|
325
325
|
return t;
|
|
326
326
|
});
|
|
327
327
|
let u = $;
|
|
328
|
-
var Z, ee, ie,
|
|
329
|
-
class
|
|
328
|
+
var Z, ee, ie, He;
|
|
329
|
+
class wt {
|
|
330
330
|
constructor(...e) {
|
|
331
331
|
p(this, Z);
|
|
332
332
|
p(this, ee);
|
|
333
333
|
p(this, ie);
|
|
334
|
-
p(this,
|
|
334
|
+
p(this, He);
|
|
335
335
|
// ------------------------------------------
|
|
336
336
|
// Creation / parsing functions
|
|
337
337
|
// ------------------------------------------
|
|
338
|
-
a(this, "parse", (e, t, i) => (h(this, ie, i ?? 1), h(this, ee, t ?? 2), h(this, Z, e), s(this, ee) % 2 === 0 && s(this, Z) < 0 && h(this,
|
|
338
|
+
a(this, "parse", (e, t, i) => (h(this, ie, i ?? 1), h(this, ee, t ?? 2), h(this, Z, e), s(this, ee) % 2 === 0 && s(this, Z) < 0 && h(this, He, !1), this));
|
|
339
339
|
// ------------------------------------------
|
|
340
340
|
// Mathematical operations
|
|
341
341
|
// ------------------------------------------
|
|
@@ -354,8 +354,8 @@ class yt {
|
|
|
354
354
|
// ------------------------------------------
|
|
355
355
|
// Help functions
|
|
356
356
|
// ------------------------------------------
|
|
357
|
-
a(this, "hasRadical", () => !(s(this, Z) === 1 || s(this, Z) === 0 || !s(this,
|
|
358
|
-
h(this, Z, 1), h(this, ie, 1), h(this, ee, 2), h(this,
|
|
357
|
+
a(this, "hasRadical", () => !(s(this, Z) === 1 || s(this, Z) === 0 || !s(this, He)));
|
|
358
|
+
h(this, Z, 1), h(this, ie, 1), h(this, ee, 2), h(this, He, !0), e.length > 0 && this.parse(e[0], e[1], e[2]);
|
|
359
359
|
}
|
|
360
360
|
// ------------------------------------------
|
|
361
361
|
// Getter and setter
|
|
@@ -390,34 +390,34 @@ class yt {
|
|
|
390
390
|
return s(this, ie) * Math.pow(s(this, Z), 1 / s(this, ee));
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
|
-
Z = new WeakMap(), ee = new WeakMap(), ie = new WeakMap(),
|
|
394
|
-
var
|
|
393
|
+
Z = new WeakMap(), ee = new WeakMap(), ie = new WeakMap(), He = new WeakMap();
|
|
394
|
+
var Ui = Object.defineProperty, wi = (o) => {
|
|
395
395
|
throw TypeError(o);
|
|
396
|
-
},
|
|
397
|
-
const
|
|
396
|
+
}, Gi = (o, e, t) => e in o ? Ui(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, Jt = (o, e, t) => Gi(o, typeof e != "symbol" ? e + "" : e, t), vi = (o, e, t) => e.has(o) || wi("Cannot " + t), _ = (o, e, t) => (vi(o, e, "read from private field"), t ? t.call(o) : e.get(o)), nt = (o, e, t) => e.has(o) ? wi("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), be = (o, e, t, i) => (vi(o, e, "write to private field"), e.set(o, t), t);
|
|
397
|
+
const ui = {
|
|
398
398
|
pi: Math.PI,
|
|
399
399
|
e: Math.exp(1)
|
|
400
400
|
};
|
|
401
401
|
var m = /* @__PURE__ */ ((o) => (o.VARIABLE = "variable", o.COEFFICIENT = "coefficient", o.OPERATION = "operation", o.CONSTANT = "constant", o.FUNCTION = "function", o.FUNCTION_ARGUMENT = "function-argument", o.MONOM = "monom", o.LEFT_PARENTHESIS = "(", o.RIGHT_PARENTHESIS = ")", o))(m || {}), Ze = /* @__PURE__ */ ((o) => (o.EXPRESSION = "expression", o.POLYNOM = "polynom", o.SET = "set", o.NUMERIC = "numeric", o))(Ze || {});
|
|
402
|
-
function
|
|
402
|
+
function Wi(o, e) {
|
|
403
403
|
if (o.length <= 1)
|
|
404
404
|
return o;
|
|
405
|
-
const t = Object.keys(e).filter((
|
|
406
|
-
t.sort((
|
|
407
|
-
const i = new RegExp(`^(${t.join("|")})\\(`), n = Object.keys(
|
|
408
|
-
n.sort((
|
|
405
|
+
const t = Object.keys(e).filter((E) => e[E].type === m.FUNCTION).map((E) => E);
|
|
406
|
+
t.sort((E, V) => V.length - E.length);
|
|
407
|
+
const i = new RegExp(`^(${t.join("|")})\\(`), n = Object.keys(ui);
|
|
408
|
+
n.sort((E, V) => V.length - E.length);
|
|
409
409
|
const r = new RegExp(`^(${n.join("|")})`), l = /^(\d+(\.\d+)?)/;
|
|
410
410
|
let c = "", d, f, g;
|
|
411
411
|
for (; o.length > 0; ) {
|
|
412
412
|
if (d = f, g = void 0, t.length > 0 && i.exec(o)) {
|
|
413
|
-
const
|
|
414
|
-
|
|
413
|
+
const E = t.find((V) => o.startsWith(V));
|
|
414
|
+
E && (g = E + "(", o = o.slice(E.length + 1), f = m.FUNCTION);
|
|
415
415
|
} else if (n.length > 0 && r.exec(o)) {
|
|
416
|
-
const
|
|
417
|
-
|
|
416
|
+
const E = n.find((V) => o.startsWith(V));
|
|
417
|
+
E && (g = E, o = o.slice(E.length), f = m.CONSTANT);
|
|
418
418
|
} else if (l.exec(o)) {
|
|
419
|
-
const
|
|
420
|
-
|
|
419
|
+
const E = l.exec(o);
|
|
420
|
+
E && (g = E[0], o = o.slice(E[0].length), f = m.COEFFICIENT);
|
|
421
421
|
} else
|
|
422
422
|
switch (g = o[0], o = o.slice(1), g) {
|
|
423
423
|
case "(":
|
|
@@ -441,20 +441,20 @@ function Ui(o, e) {
|
|
|
441
441
|
}
|
|
442
442
|
if (g === void 0 || f === void 0)
|
|
443
443
|
throw new Error("The token is undefined");
|
|
444
|
-
c +=
|
|
444
|
+
c += Hi(d, f), c += g;
|
|
445
445
|
}
|
|
446
446
|
return c;
|
|
447
447
|
}
|
|
448
|
-
function
|
|
448
|
+
function Hi(o, e) {
|
|
449
449
|
return o === void 0 || o === m.OPERATION || e === m.OPERATION || o === m.LEFT_PARENTHESIS || o === m.FUNCTION || o === m.FUNCTION_ARGUMENT || e === m.RIGHT_PARENTHESIS || e === m.FUNCTION_ARGUMENT ? "" : "*";
|
|
450
450
|
}
|
|
451
|
-
const
|
|
451
|
+
const Xi = {
|
|
452
452
|
"^": { precedence: 4, associative: "right", type: m.OPERATION },
|
|
453
453
|
"*": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
454
454
|
"/": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
455
455
|
"+": { precedence: 2, associative: "left", type: m.OPERATION },
|
|
456
456
|
"-": { precedence: 2, associative: "left", type: m.OPERATION }
|
|
457
|
-
},
|
|
457
|
+
}, Yi = {
|
|
458
458
|
"^": { precedence: 4, associative: "right", type: m.OPERATION },
|
|
459
459
|
"*": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
460
460
|
"/": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
@@ -467,7 +467,7 @@ const Wi = {
|
|
|
467
467
|
sqrt: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
468
468
|
nthrt: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
469
469
|
",": { precedence: 2, associative: "left", type: m.FUNCTION_ARGUMENT }
|
|
470
|
-
},
|
|
470
|
+
}, Qi = {
|
|
471
471
|
"^": { precedence: 4, associative: "right", type: m.OPERATION },
|
|
472
472
|
"*": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
473
473
|
"/": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
@@ -481,26 +481,26 @@ const Wi = {
|
|
|
481
481
|
nthrt: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
482
482
|
ln: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
483
483
|
log: { precedence: 4, associative: "right", type: m.FUNCTION }
|
|
484
|
-
},
|
|
484
|
+
}, Ki = {
|
|
485
485
|
"&": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
486
486
|
"|": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
487
487
|
"!": { precedence: 4, associative: "right", type: m.OPERATION },
|
|
488
488
|
"-": { precedence: 2, associative: "left", type: m.OPERATION }
|
|
489
489
|
};
|
|
490
|
-
var
|
|
491
|
-
class
|
|
490
|
+
var Ge, rt, te, vt, De;
|
|
491
|
+
class Yt {
|
|
492
492
|
constructor(e) {
|
|
493
|
-
|
|
493
|
+
nt(this, Ge), nt(this, rt, []), nt(this, te, {}), nt(this, vt, []), nt(this, De), be(this, Ge, typeof e > "u" ? Ze.POLYNOM : e), this.tokenConfigInitialization();
|
|
494
494
|
}
|
|
495
495
|
// Getter
|
|
496
496
|
get rpn() {
|
|
497
|
-
return _(this,
|
|
497
|
+
return _(this, rt);
|
|
498
498
|
}
|
|
499
499
|
get rpnToken() {
|
|
500
|
-
return _(this,
|
|
500
|
+
return _(this, rt).map((e) => e.token);
|
|
501
501
|
}
|
|
502
502
|
tokenConfigInitialization() {
|
|
503
|
-
return _(this,
|
|
503
|
+
return _(this, Ge) === Ze.SET ? (be(this, te, Ki), be(this, De, !1)) : _(this, Ge) === Ze.NUMERIC ? (be(this, te, Qi), be(this, De, !0)) : _(this, Ge) === Ze.EXPRESSION ? (be(this, te, Yi), be(this, De, !0)) : (be(this, te, Xi), be(this, De, !0)), be(this, vt, Object.keys(_(this, te)).sort((e, t) => t.length - e.length)), _(this, te);
|
|
504
504
|
}
|
|
505
505
|
/**
|
|
506
506
|
* Get the next token to analyse.
|
|
@@ -516,12 +516,12 @@ class Xt {
|
|
|
516
516
|
else if (e[t] === ",")
|
|
517
517
|
i = ",", n = m.FUNCTION_ARGUMENT;
|
|
518
518
|
else {
|
|
519
|
-
for (const r of _(this,
|
|
519
|
+
for (const r of _(this, vt))
|
|
520
520
|
if (e.substring(t, t + r.length) === r) {
|
|
521
521
|
i += r, n = _(this, te)[r].type;
|
|
522
522
|
break;
|
|
523
523
|
}
|
|
524
|
-
for (const r in
|
|
524
|
+
for (const r in ui)
|
|
525
525
|
if (e.substring(t, t + r.length) === r) {
|
|
526
526
|
i += r, n = m.CONSTANT;
|
|
527
527
|
break;
|
|
@@ -549,7 +549,7 @@ class Xt {
|
|
|
549
549
|
parse(e, t) {
|
|
550
550
|
const i = [], n = [];
|
|
551
551
|
let r = "", l = 0, c;
|
|
552
|
-
(t ?? _(this, De)) && (e =
|
|
552
|
+
(t ?? _(this, De)) && (e = Wi(e, _(this, te)));
|
|
553
553
|
const d = 50;
|
|
554
554
|
let f = 50, g;
|
|
555
555
|
for (; l < e.length; ) {
|
|
@@ -569,17 +569,17 @@ class Xt {
|
|
|
569
569
|
break;
|
|
570
570
|
case m.OPERATION:
|
|
571
571
|
if (n.length > 0) {
|
|
572
|
-
let
|
|
573
|
-
for (g = +d;
|
|
574
|
-
(_(this, te)[r].associative === "left" && _(this, te)[r].precedence <= _(this, te)[
|
|
575
|
-
_(this, te)[r].associative === "right" && _(this, te)[r].precedence < _(this, te)[
|
|
572
|
+
let E = n[n.length - 1];
|
|
573
|
+
for (g = +d; E.token in _(this, te) && //either o1 is left-associative and its precedence is less than or equal to that of o2,
|
|
574
|
+
(_(this, te)[r].associative === "left" && _(this, te)[r].precedence <= _(this, te)[E.token].precedence || //or o1 is right associative, and has precedence less than that of o2,
|
|
575
|
+
_(this, te)[r].associative === "right" && _(this, te)[r].precedence < _(this, te)[E.token].precedence); ) {
|
|
576
576
|
if (g--, g === 0) {
|
|
577
577
|
console.log("SECURITY LEVEL 2 OPERATION EXIT");
|
|
578
578
|
break;
|
|
579
579
|
}
|
|
580
580
|
if (i.push(n.pop() ?? { token: "", tokenType: m.OPERATION }), n.length === 0)
|
|
581
581
|
break;
|
|
582
|
-
|
|
582
|
+
E = n[n.length - 1];
|
|
583
583
|
}
|
|
584
584
|
}
|
|
585
585
|
n.push({ token: r, tokenType: c });
|
|
@@ -613,15 +613,15 @@ class Xt {
|
|
|
613
613
|
throw new Error(`Token type ${r} is not handled`);
|
|
614
614
|
}
|
|
615
615
|
}
|
|
616
|
-
return be(this,
|
|
616
|
+
return be(this, rt, i.concat(n.reverse())), this;
|
|
617
617
|
}
|
|
618
618
|
}
|
|
619
|
-
|
|
620
|
-
class
|
|
619
|
+
Ge = /* @__PURE__ */ new WeakMap(), rt = /* @__PURE__ */ new WeakMap(), te = /* @__PURE__ */ new WeakMap(), vt = /* @__PURE__ */ new WeakMap(), De = /* @__PURE__ */ new WeakMap();
|
|
620
|
+
class Ji {
|
|
621
621
|
constructor(e, t) {
|
|
622
|
-
|
|
622
|
+
Jt(this, "_rpn"), Jt(this, "_expression"), Jt(this, "_isValid"), this._expression = e;
|
|
623
623
|
try {
|
|
624
|
-
this._rpn = new
|
|
624
|
+
this._rpn = new Yt(Ze.NUMERIC).parse(e, t).rpn;
|
|
625
625
|
} catch {
|
|
626
626
|
throw this._rpn = null, this._isValid = !1, new Error(`There was a problem parsing: ${e}`);
|
|
627
627
|
}
|
|
@@ -662,7 +662,7 @@ class Qi {
|
|
|
662
662
|
else if (i.tokenType === m.VARIABLE && e !== void 0)
|
|
663
663
|
Object.hasOwn(e, i.token) && t.push(+e[i.token]);
|
|
664
664
|
else if (i.tokenType === m.CONSTANT)
|
|
665
|
-
t.push(
|
|
665
|
+
t.push(ui[i.token]);
|
|
666
666
|
else if (i.tokenType === m.OPERATION) {
|
|
667
667
|
if (i.token === "*") {
|
|
668
668
|
const n = t.pop(), r = t.pop();
|
|
@@ -717,10 +717,10 @@ class Qi {
|
|
|
717
717
|
return +e.toFixed(t);
|
|
718
718
|
}
|
|
719
719
|
}
|
|
720
|
-
var T, v,
|
|
720
|
+
var T, v, Xe, bt, ze, Ot, qt;
|
|
721
721
|
const I = class I {
|
|
722
722
|
constructor(e) {
|
|
723
|
-
p(this,
|
|
723
|
+
p(this, Xe);
|
|
724
724
|
p(this, T);
|
|
725
725
|
p(this, v);
|
|
726
726
|
/**
|
|
@@ -740,7 +740,7 @@ const I = class I {
|
|
|
740
740
|
a(this, "add", (...e) => {
|
|
741
741
|
for (const t of e) {
|
|
742
742
|
const i = t instanceof I ? t : new I(t);
|
|
743
|
-
this.isSameAs(i) ? (this.isZero() &&
|
|
743
|
+
this.isSameAs(i) ? (this.isZero() && O(this, Xe, bt).call(this, i), s(this, T).add(i.coefficient)) : console.log("Add monom: " + this.display + " is not similar with ", i.display);
|
|
744
744
|
}
|
|
745
745
|
return this;
|
|
746
746
|
});
|
|
@@ -783,7 +783,7 @@ const I = class I {
|
|
|
783
783
|
if (t === !0) {
|
|
784
784
|
if (e instanceof u)
|
|
785
785
|
return s(this, ze).call(this, e.value);
|
|
786
|
-
if (e instanceof
|
|
786
|
+
if (e instanceof wt)
|
|
787
787
|
return new u().invalid();
|
|
788
788
|
if (typeof e == "number")
|
|
789
789
|
return s(this, ze).call(this, e);
|
|
@@ -799,7 +799,7 @@ const I = class I {
|
|
|
799
799
|
const n = {};
|
|
800
800
|
return n[this.variables[0]] = new u(e), this.evaluate(n);
|
|
801
801
|
}
|
|
802
|
-
if (e instanceof
|
|
802
|
+
if (e instanceof wt)
|
|
803
803
|
return new u().invalid();
|
|
804
804
|
if (typeof e == "object") {
|
|
805
805
|
if (this.variables.length === 0)
|
|
@@ -942,7 +942,7 @@ const I = class I {
|
|
|
942
942
|
a(this, "subtract", (...e) => {
|
|
943
943
|
for (const t of e) {
|
|
944
944
|
const i = t instanceof I ? t : new I(t);
|
|
945
|
-
this.isSameAs(i) ? (this.isZero() &&
|
|
945
|
+
this.isSameAs(i) ? (this.isZero() && O(this, Xe, bt).call(this, i), s(this, T).add(i.clone().coefficient.opposite())) : console.log("Subtract: Is not similar: ", i.display);
|
|
946
946
|
}
|
|
947
947
|
return this;
|
|
948
948
|
});
|
|
@@ -960,7 +960,7 @@ const I = class I {
|
|
|
960
960
|
const i = {};
|
|
961
961
|
return i[this.variables[0]] = new u(e).value, s(this, ze).call(this, i);
|
|
962
962
|
}
|
|
963
|
-
if (e instanceof
|
|
963
|
+
if (e instanceof wt)
|
|
964
964
|
return NaN;
|
|
965
965
|
if (typeof e == "object") {
|
|
966
966
|
if (this.variables.length === 0)
|
|
@@ -973,7 +973,7 @@ const I = class I {
|
|
|
973
973
|
return t;
|
|
974
974
|
});
|
|
975
975
|
p(this, Ot, (e) => {
|
|
976
|
-
const i = new
|
|
976
|
+
const i = new Yt().parse(e).rpn, n = [];
|
|
977
977
|
if (i.length === 0)
|
|
978
978
|
return this.zero(), this;
|
|
979
979
|
if (i.length === 1) {
|
|
@@ -981,10 +981,10 @@ const I = class I {
|
|
|
981
981
|
return this.one(), r.tokenType === m.COEFFICIENT ? this.coefficient = new u(r.token) : r.tokenType === m.VARIABLE && this.setLetter(r.token, 1), this;
|
|
982
982
|
} else
|
|
983
983
|
for (const r of i)
|
|
984
|
-
s(this,
|
|
984
|
+
s(this, qt).call(this, n, r);
|
|
985
985
|
return this.one(), this.multiply(n[0]), this;
|
|
986
986
|
});
|
|
987
|
-
p(this,
|
|
987
|
+
p(this, qt, (e, t) => {
|
|
988
988
|
var d;
|
|
989
989
|
let i, n, r, l, c;
|
|
990
990
|
if (t.tokenType === m.COEFFICIENT)
|
|
@@ -1017,7 +1017,7 @@ const I = class I {
|
|
|
1017
1017
|
* @param inputStr
|
|
1018
1018
|
*/
|
|
1019
1019
|
parse(e) {
|
|
1020
|
-
return h(this, T, new u()), h(this, v, {}), typeof e == "string" ? s(this, Ot).call(this, e) : typeof e == "number" ? h(this, T, new u(e)) : e instanceof u ? h(this, T, e.clone()) : e instanceof I && (h(this, T, s(e, T).clone()),
|
|
1020
|
+
return h(this, T, new u()), h(this, v, {}), typeof e == "string" ? s(this, Ot).call(this, e) : typeof e == "number" ? h(this, T, new u(e)) : e instanceof u ? h(this, T, e.clone()) : e instanceof I && (h(this, T, s(e, T).clone()), O(this, Xe, bt).call(this, e)), this;
|
|
1021
1021
|
}
|
|
1022
1022
|
/**
|
|
1023
1023
|
* Get the coefficient \\(k\\) of the Monom \\(k\\cdot x^{n}\\)
|
|
@@ -1164,10 +1164,10 @@ const I = class I {
|
|
|
1164
1164
|
return i;
|
|
1165
1165
|
}
|
|
1166
1166
|
};
|
|
1167
|
-
T = new WeakMap(), v = new WeakMap(),
|
|
1167
|
+
T = new WeakMap(), v = new WeakMap(), Xe = new WeakSet(), bt = function(e) {
|
|
1168
1168
|
for (const t in e.literal)
|
|
1169
1169
|
s(this, v)[t] = e.literal[t].clone();
|
|
1170
|
-
}, ze = new WeakMap(), Ot = new WeakMap(),
|
|
1170
|
+
}, ze = new WeakMap(), Ot = new WeakMap(), qt = new WeakMap(), a(I, "gcd", (...e) => {
|
|
1171
1171
|
for (const r of e)
|
|
1172
1172
|
if (r.containsRationalPower())
|
|
1173
1173
|
return new I().zero();
|
|
@@ -1190,38 +1190,38 @@ a(I, "xMultiply", (...e) => {
|
|
|
1190
1190
|
t.multiply(i);
|
|
1191
1191
|
return t;
|
|
1192
1192
|
});
|
|
1193
|
-
let
|
|
1194
|
-
var
|
|
1195
|
-
const
|
|
1193
|
+
let M = I;
|
|
1194
|
+
var ce, Fe, P, ot, ye, bi, ei, xi, Ei, Ni;
|
|
1195
|
+
const di = class di {
|
|
1196
1196
|
constructor(e, t, i = "x") {
|
|
1197
1197
|
p(this, P);
|
|
1198
|
-
p(this,
|
|
1198
|
+
p(this, ce);
|
|
1199
1199
|
p(this, Fe);
|
|
1200
1200
|
if (h(this, Fe, i), Object.hasOwn(e, "moveLeft")) {
|
|
1201
1201
|
const n = e;
|
|
1202
|
-
h(this,
|
|
1202
|
+
h(this, ce, n.left.clone().subtract(n.right));
|
|
1203
1203
|
} else
|
|
1204
|
-
h(this,
|
|
1204
|
+
h(this, ce, e.clone().subtract(t ?? 0));
|
|
1205
1205
|
}
|
|
1206
1206
|
solve() {
|
|
1207
|
-
if (s(this,
|
|
1208
|
-
return
|
|
1209
|
-
if (s(this,
|
|
1210
|
-
return
|
|
1211
|
-
const e =
|
|
1207
|
+
if (s(this, ce).degree().isOne())
|
|
1208
|
+
return O(this, P, xi).call(this);
|
|
1209
|
+
if (s(this, ce).degree().value === 2)
|
|
1210
|
+
return O(this, P, Ei).call(this);
|
|
1211
|
+
const e = O(this, P, bi).call(this);
|
|
1212
1212
|
if (e.length > 0)
|
|
1213
1213
|
return e;
|
|
1214
|
-
if (s(this,
|
|
1215
|
-
return
|
|
1214
|
+
if (s(this, ce).degree().value === 3)
|
|
1215
|
+
return O(this, P, ei).call(this);
|
|
1216
1216
|
throw new Error("The equation degree is too high.");
|
|
1217
1217
|
}
|
|
1218
1218
|
solveAsCardan() {
|
|
1219
|
-
if (s(this,
|
|
1219
|
+
if (s(this, ce).degree().value !== 3)
|
|
1220
1220
|
throw new Error("The equation is not cubic.");
|
|
1221
|
-
return
|
|
1221
|
+
return O(this, P, ei).call(this);
|
|
1222
1222
|
}
|
|
1223
1223
|
};
|
|
1224
|
-
|
|
1224
|
+
ce = new WeakMap(), Fe = new WeakMap(), P = new WeakSet(), ot = function(e, t) {
|
|
1225
1225
|
return {
|
|
1226
1226
|
variable: s(this, Fe),
|
|
1227
1227
|
exact: !1,
|
|
@@ -1231,7 +1231,7 @@ ue = new WeakMap(), Fe = new WeakMap(), P = new WeakSet(), ht = function(e, t) {
|
|
|
1231
1231
|
};
|
|
1232
1232
|
}, ye = function(e) {
|
|
1233
1233
|
if (e instanceof u && e.isApproximative())
|
|
1234
|
-
return
|
|
1234
|
+
return O(this, P, ot).call(this, e.value);
|
|
1235
1235
|
const t = new u(e);
|
|
1236
1236
|
return {
|
|
1237
1237
|
variable: s(this, Fe),
|
|
@@ -1240,24 +1240,24 @@ ue = new WeakMap(), Fe = new WeakMap(), P = new WeakSet(), ht = function(e, t) {
|
|
|
1240
1240
|
tex: t.tex,
|
|
1241
1241
|
display: t.display
|
|
1242
1242
|
};
|
|
1243
|
-
},
|
|
1244
|
-
let e = s(this,
|
|
1243
|
+
}, bi = function() {
|
|
1244
|
+
let e = s(this, ce).clone(), t = [];
|
|
1245
1245
|
const i = e.lcmDenominator();
|
|
1246
1246
|
i !== 1 && e.multiply(i);
|
|
1247
1247
|
const n = e.monomByDegree().coefficient;
|
|
1248
1248
|
let r = e.monomByDegree(0).coefficient;
|
|
1249
1249
|
for (; r.isZero(); )
|
|
1250
|
-
t.length === 0 && t.push(
|
|
1250
|
+
t.length === 0 && t.push(O(this, P, ye).call(this, 0)), e = e.divide("x"), r = e.monomByDegree(0).coefficient;
|
|
1251
1251
|
const l = G.dividers(n.value), c = G.dividers(r.value);
|
|
1252
1252
|
for (const f of l)
|
|
1253
1253
|
for (const g of c) {
|
|
1254
|
-
const
|
|
1255
|
-
e.evaluate(
|
|
1254
|
+
const E = new u(g, f);
|
|
1255
|
+
e.evaluate(E).isZero() && !t.find((V) => V.value === E.value) && t.push(O(this, P, ye).call(this, E)), E.opposite(), e.evaluate(E).isZero() && !t.find((V) => V.value === E.value) && t.push(O(this, P, ye).call(this, E));
|
|
1256
1256
|
}
|
|
1257
1257
|
for (const f of t) {
|
|
1258
1258
|
if (f.exact !== !1 && f.exact.isZero())
|
|
1259
1259
|
continue;
|
|
1260
|
-
const g = s(this,
|
|
1260
|
+
const g = s(this, ce).clone().parse("x", f.exact.denominator, -f.exact.numerator);
|
|
1261
1261
|
for (; e.isDividableBy(g); )
|
|
1262
1262
|
e = e.divide(g);
|
|
1263
1263
|
}
|
|
@@ -1265,79 +1265,79 @@ ue = new WeakMap(), Fe = new WeakMap(), P = new WeakSet(), ht = function(e, t) {
|
|
|
1265
1265
|
return t.sort((f, g) => f.value - g.value);
|
|
1266
1266
|
if (e.degree().value > 3)
|
|
1267
1267
|
return [];
|
|
1268
|
-
const d = new
|
|
1268
|
+
const d = new di(e, e.clone().parse("0"), s(this, Fe));
|
|
1269
1269
|
return t = t.concat(d.solve()), t.sort((f, g) => f.value - g.value);
|
|
1270
|
-
},
|
|
1271
|
-
const e = s(this,
|
|
1270
|
+
}, ei = function() {
|
|
1271
|
+
const e = s(this, ce), t = e.monomByDegree(3).coefficient, i = e.monomByDegree(2).coefficient, n = e.monomByDegree(1).coefficient, r = e.monomByDegree(0).coefficient, l = i.clone().divide(t), c = n.clone().divide(t), d = r.clone().divide(t), f = c.clone().subtract(l.clone().pow(2).divide(3)), g = d.clone().subtract(l.clone().multiply(c).divide(3)).add(l.clone().pow(3).multiply(2).divide(27)), E = g.clone().opposite(), V = f.clone().opposite().pow(3).divide(27), de = E.clone().pow(2).subtract(V.clone().multiply(4)).opposite();
|
|
1272
1272
|
if (de.isNegative()) {
|
|
1273
1273
|
const he = g.clone().opposite().add(de.clone().opposite().sqrt()).divide(2).root(3), ae = g.clone().opposite().subtract(de.clone().opposite().sqrt()).divide(2).root(3), ge = he.clone().add(ae).subtract(l.clone().divide(3));
|
|
1274
|
-
return [
|
|
1274
|
+
return [O(this, P, ye).call(this, ge)];
|
|
1275
1275
|
}
|
|
1276
1276
|
if (de.isZero()) {
|
|
1277
1277
|
const he = g.clone().opposite().divide(2).root(3), ae = he.clone().opposite().subtract(l.clone().divide(3)), ge = he.clone().multiply(2).subtract(l.clone().divide(3));
|
|
1278
|
-
return ae.isEqual(ge) ? [
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
].sort((pe,
|
|
1278
|
+
return ae.isEqual(ge) ? [O(this, P, ye).call(this, ae)] : [
|
|
1279
|
+
O(this, P, ye).call(this, ge),
|
|
1280
|
+
O(this, P, ye).call(this, ae)
|
|
1281
|
+
].sort((pe, le) => pe.value - le.value);
|
|
1282
1282
|
}
|
|
1283
1283
|
if (de.isPositive()) {
|
|
1284
1284
|
const he = [], ae = f.value, ge = g.value, pe = l.value;
|
|
1285
|
-
for (let
|
|
1286
|
-
he.push(2 * Math.sqrt(-ae / 3) * Math.cos(Math.acos(3 * ge / (2 * ae) * Math.sqrt(-3 / ae)) / 3 + 2 * Math.PI *
|
|
1287
|
-
return he.map((
|
|
1285
|
+
for (let le = 0; le < 3; le++)
|
|
1286
|
+
he.push(2 * Math.sqrt(-ae / 3) * Math.cos(Math.acos(3 * ge / (2 * ae) * Math.sqrt(-3 / ae)) / 3 + 2 * Math.PI * le / 3) - pe / 3);
|
|
1287
|
+
return he.map((le) => O(this, P, ot).call(this, le)).sort((le, st) => le.value - st.value);
|
|
1288
1288
|
}
|
|
1289
1289
|
return [];
|
|
1290
|
-
},
|
|
1291
|
-
const e = s(this,
|
|
1290
|
+
}, xi = function() {
|
|
1291
|
+
const e = s(this, ce).monomByDegree(0).coefficient.clone().opposite().divide(s(this, ce).monomByDegree(1).coefficient);
|
|
1292
1292
|
return [
|
|
1293
|
-
|
|
1293
|
+
O(this, P, ye).call(this, e)
|
|
1294
1294
|
];
|
|
1295
|
-
},
|
|
1296
|
-
const e = s(this,
|
|
1295
|
+
}, Ei = function() {
|
|
1296
|
+
const e = s(this, ce), t = e.monomByDegree(2).coefficient, i = e.monomByDegree(1).coefficient, n = e.monomByDegree(0).coefficient, r = i.clone().pow(2).subtract(t.clone().multiply(n).multiply(4));
|
|
1297
1297
|
if (r.isNegative())
|
|
1298
1298
|
return [];
|
|
1299
1299
|
if (r.isSquare()) {
|
|
1300
1300
|
const l = r.sqrt(), c = i.clone().opposite().add(l).divide(t.clone().multiply(2)), d = i.clone().opposite().subtract(l).divide(t.clone().multiply(2));
|
|
1301
|
-
return l.isZero() ? [
|
|
1302
|
-
|
|
1303
|
-
|
|
1301
|
+
return l.isZero() ? [O(this, P, ye).call(this, c)] : [
|
|
1302
|
+
O(this, P, ye).call(this, c),
|
|
1303
|
+
O(this, P, ye).call(this, d)
|
|
1304
1304
|
].sort((f, g) => f.value - g.value);
|
|
1305
1305
|
}
|
|
1306
|
-
return
|
|
1307
|
-
},
|
|
1308
|
-
const n = G.dividers(i.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(), c = e.clone().divide(r).multiply(2), d = i.clone().divide(n ** 2), f = Math.abs(n / r), g = n === 1 ? "-" : `-${f} `,
|
|
1309
|
-
function
|
|
1310
|
-
return `\\frac{ ${
|
|
1306
|
+
return O(this, P, Ni).call(this, t, i, r);
|
|
1307
|
+
}, Ni = function(e, t, i) {
|
|
1308
|
+
const n = G.dividers(i.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(), c = e.clone().divide(r).multiply(2), d = i.clone().divide(n ** 2), f = Math.abs(n / r), g = n === 1 ? "-" : `-${f} `, E = n === 1 ? "+" : `+${f} `;
|
|
1309
|
+
function V(pe, le, st, Qt) {
|
|
1310
|
+
return `\\frac{ ${le} ${st}\\sqrt{ ${Qt} } }{ ${pe} }`;
|
|
1311
1311
|
}
|
|
1312
|
-
function de(pe,
|
|
1313
|
-
return `(${
|
|
1312
|
+
function de(pe, le, st, Qt) {
|
|
1313
|
+
return `(${le}${st}sqrt(${Qt}))/${pe}`;
|
|
1314
1314
|
}
|
|
1315
1315
|
const he = i.value ** 0.5, ae = (-t.value - he) / (2 * e.value), ge = (-t.value + he) / (2 * e.value);
|
|
1316
1316
|
return [
|
|
1317
|
-
|
|
1318
|
-
tex:
|
|
1317
|
+
O(this, P, ot).call(this, ae, {
|
|
1318
|
+
tex: V(c.tex, l.tex, g.toString(), d.tex),
|
|
1319
1319
|
display: de(c.display, l.display, g.toString(), d.display)
|
|
1320
1320
|
}),
|
|
1321
|
-
|
|
1322
|
-
tex:
|
|
1323
|
-
display: de(c.display, l.display,
|
|
1321
|
+
O(this, P, ot).call(this, ge, {
|
|
1322
|
+
tex: V(c.tex, l.tex, E.toString(), d.tex),
|
|
1323
|
+
display: de(c.display, l.display, E.toString(), d.display)
|
|
1324
1324
|
})
|
|
1325
|
-
].sort((pe,
|
|
1325
|
+
].sort((pe, le) => pe.value - le.value);
|
|
1326
1326
|
};
|
|
1327
|
-
let
|
|
1328
|
-
function
|
|
1327
|
+
let Et = di;
|
|
1328
|
+
function gi(o, e = !0) {
|
|
1329
1329
|
return e ? `\\left( ${o} \\right)` : `(${o})`;
|
|
1330
1330
|
}
|
|
1331
1331
|
function Se(o, e, t, i, n) {
|
|
1332
1332
|
return o.map((r, l) => i !== void 0 && l < i || n !== void 0 && l > n ? r : r === e ? t : r);
|
|
1333
1333
|
}
|
|
1334
|
-
var je, y,
|
|
1334
|
+
var je, y, Ye, ct, Qe, ut, kt, Mt, Ct, Ke, $t, ft, It, Pt, Bt, St, Ti, Rt, zt;
|
|
1335
1335
|
const C = class C {
|
|
1336
1336
|
constructor(e, ...t) {
|
|
1337
|
-
p(this,
|
|
1337
|
+
p(this, St);
|
|
1338
1338
|
p(this, je);
|
|
1339
1339
|
p(this, y);
|
|
1340
|
-
p(this,
|
|
1340
|
+
p(this, Ye);
|
|
1341
1341
|
p(this, ct, !1);
|
|
1342
1342
|
/**
|
|
1343
1343
|
* Parse a string to a polynom.
|
|
@@ -1346,12 +1346,12 @@ const C = class C {
|
|
|
1346
1346
|
*/
|
|
1347
1347
|
a(this, "parse", (e, ...t) => {
|
|
1348
1348
|
if (h(this, y, []), h(this, je, []), typeof e == "string")
|
|
1349
|
-
return
|
|
1350
|
-
if ((typeof e == "number" || e instanceof u || e instanceof
|
|
1351
|
-
s(this, y).push(new
|
|
1352
|
-
else if (e instanceof
|
|
1353
|
-
s(this, y).push(new
|
|
1354
|
-
s(this, y).push(new
|
|
1349
|
+
return O(this, St, Ti).call(this, e, ...t);
|
|
1350
|
+
if ((typeof e == "number" || e instanceof u || e instanceof M) && t.length === 0)
|
|
1351
|
+
s(this, y).push(new M(e));
|
|
1352
|
+
else if (e instanceof M && t.length > 0)
|
|
1353
|
+
s(this, y).push(new M(e)), t.forEach((i) => {
|
|
1354
|
+
s(this, y).push(new M(i));
|
|
1355
1355
|
});
|
|
1356
1356
|
else if (e instanceof C)
|
|
1357
1357
|
for (const i of e.monoms)
|
|
@@ -1369,11 +1369,11 @@ const C = class C {
|
|
|
1369
1369
|
});
|
|
1370
1370
|
a(this, "add", (...e) => {
|
|
1371
1371
|
for (const t of e)
|
|
1372
|
-
t instanceof C ? h(this, y, s(this, y).concat(t.monoms)) : t instanceof
|
|
1372
|
+
t instanceof C ? h(this, y, s(this, y).concat(t.monoms)) : t instanceof M ? s(this, y).push(t.clone()) : typeof t == "number" && Number.isSafeInteger(t) ? s(this, y).push(new M(t.toString())) : s(this, y).push(new M(t));
|
|
1373
1373
|
return this.reduce();
|
|
1374
1374
|
});
|
|
1375
1375
|
a(this, "commonMonom", () => {
|
|
1376
|
-
const e = new
|
|
1376
|
+
const e = new M().one(), t = this.gcdNumerator(), i = this.gcdDenominator(), n = this.degree();
|
|
1377
1377
|
e.coefficient = new u(t, i);
|
|
1378
1378
|
for (const r of this.variables) {
|
|
1379
1379
|
e.setLetter(r, n);
|
|
@@ -1399,8 +1399,8 @@ const C = class C {
|
|
|
1399
1399
|
if (e instanceof u)
|
|
1400
1400
|
return s(this, ut).call(this, e);
|
|
1401
1401
|
if (typeof e == "number" && Number.isSafeInteger(e))
|
|
1402
|
-
return s(this,
|
|
1403
|
-
if (e instanceof
|
|
1402
|
+
return s(this, kt).call(this, e);
|
|
1403
|
+
if (e instanceof M)
|
|
1404
1404
|
return this.divide(new C(e));
|
|
1405
1405
|
if (e instanceof C) {
|
|
1406
1406
|
if (e.monoms.length === 1 && e.variables.length === 0)
|
|
@@ -1462,7 +1462,7 @@ const C = class C {
|
|
|
1462
1462
|
t.push(i.clone()), i.one();
|
|
1463
1463
|
break;
|
|
1464
1464
|
} else {
|
|
1465
|
-
let c = s(this,
|
|
1465
|
+
let c = s(this, $t).call(this, i, l, e ?? "x");
|
|
1466
1466
|
for (l = i.degree(e).value; c.length > 0; ) {
|
|
1467
1467
|
const d = c[0];
|
|
1468
1468
|
if (!i.isDividableBy(d))
|
|
@@ -1470,8 +1470,8 @@ const C = class C {
|
|
|
1470
1470
|
else {
|
|
1471
1471
|
const f = i.euclidean(d);
|
|
1472
1472
|
t.push(d), i = f.quotient.clone(), c = c.filter((g) => {
|
|
1473
|
-
const
|
|
1474
|
-
return
|
|
1473
|
+
const E = i.monoms[0], V = i.monoms[i.monoms.length - 1], de = g.monoms[0], he = g.monoms[g.monoms.length - 1];
|
|
1474
|
+
return V.isDivisible(he) ? E.isDivisible(de) : !1;
|
|
1475
1475
|
});
|
|
1476
1476
|
}
|
|
1477
1477
|
}
|
|
@@ -1493,7 +1493,7 @@ const C = class C {
|
|
|
1493
1493
|
e.push(t.coefficient.numerator);
|
|
1494
1494
|
return e;
|
|
1495
1495
|
});
|
|
1496
|
-
a(this, "getZeroes", () => this.degree().isZero() ? [] : (this.roots = new
|
|
1496
|
+
a(this, "getZeroes", () => this.degree().isZero() ? [] : (this.roots = new Et(this.clone()).solve(), this.roots));
|
|
1497
1497
|
a(this, "integrate", (e, t, i = "x") => {
|
|
1498
1498
|
const n = this.primitive(i), r = {}, l = {};
|
|
1499
1499
|
return r[i] = new u(e), l[i] = new u(t), n.evaluate(l).subtract(n.evaluate(r));
|
|
@@ -1519,8 +1519,8 @@ const C = class C {
|
|
|
1519
1519
|
return t.isZero();
|
|
1520
1520
|
}
|
|
1521
1521
|
});
|
|
1522
|
-
a(this, "isEqual", (e) => s(this,
|
|
1523
|
-
a(this, "isOppositeAt", (e) => s(this,
|
|
1522
|
+
a(this, "isEqual", (e) => s(this, Qe).call(this, e, "="));
|
|
1523
|
+
a(this, "isOppositeAt", (e) => s(this, Qe).call(this, e.clone().opposite(), "="));
|
|
1524
1524
|
a(this, "isReduced", (e) => {
|
|
1525
1525
|
if (!this.isDeveloped(e))
|
|
1526
1526
|
return !1;
|
|
@@ -1532,7 +1532,7 @@ const C = class C {
|
|
|
1532
1532
|
return !1;
|
|
1533
1533
|
return !1;
|
|
1534
1534
|
});
|
|
1535
|
-
a(this, "isSameAs", (e) => s(this,
|
|
1535
|
+
a(this, "isSameAs", (e) => s(this, Qe).call(this, e, "same"));
|
|
1536
1536
|
a(this, "lcmDenominator", () => G.lcm(...this.getDenominators()));
|
|
1537
1537
|
a(this, "lcmNumerator", () => G.lcm(...this.getNumerators()));
|
|
1538
1538
|
a(this, "letters", () => {
|
|
@@ -1556,7 +1556,7 @@ const C = class C {
|
|
|
1556
1556
|
for (const n of s(i, y))
|
|
1557
1557
|
if (n.degree(t).isEqual(e))
|
|
1558
1558
|
return n.clone();
|
|
1559
|
-
return new
|
|
1559
|
+
return new M().zero();
|
|
1560
1560
|
});
|
|
1561
1561
|
// Used in LinearSystem.tex
|
|
1562
1562
|
a(this, "monomByLetter", (e) => {
|
|
@@ -1564,7 +1564,7 @@ const C = class C {
|
|
|
1564
1564
|
for (const i of s(t, y))
|
|
1565
1565
|
if (i.hasVariable(e))
|
|
1566
1566
|
return i.clone();
|
|
1567
|
-
return new
|
|
1567
|
+
return new M().zero();
|
|
1568
1568
|
});
|
|
1569
1569
|
a(this, "monomsByDegree", (e, t) => {
|
|
1570
1570
|
if (e === void 0)
|
|
@@ -1574,8 +1574,8 @@ const C = class C {
|
|
|
1574
1574
|
r.degree(t).isEqual(e) && i.push(r.clone());
|
|
1575
1575
|
return i;
|
|
1576
1576
|
});
|
|
1577
|
-
a(this, "multiply", (e) => e instanceof C ? s(this,
|
|
1578
|
-
a(this, "one", () => (h(this, y, []), s(this, y).push(new
|
|
1577
|
+
a(this, "multiply", (e) => e instanceof C ? s(this, Bt).call(this, e) : e instanceof u ? s(this, ft).call(this, e) : e instanceof M ? s(this, Pt).call(this, e) : Number.isSafeInteger(e) && typeof e == "number" ? s(this, It).call(this, e) : this);
|
|
1578
|
+
a(this, "one", () => (h(this, y, []), s(this, y).push(new M().one()), this));
|
|
1579
1579
|
// ------------------------------------------
|
|
1580
1580
|
a(this, "opposite", () => (h(this, y, s(this, y).map((e) => e.opposite())), this));
|
|
1581
1581
|
a(this, "pow", (e) => {
|
|
@@ -1600,7 +1600,7 @@ const C = class C {
|
|
|
1600
1600
|
let e = 0;
|
|
1601
1601
|
for (; e < s(this, y).length; ) {
|
|
1602
1602
|
for (let t = e + 1; t < s(this, y).length; t++)
|
|
1603
|
-
s(this, y)[e].isSameAs(s(this, y)[t]) && (s(this, y)[e].add(s(this, y)[t]), s(this, y).splice(t, 1), s(this, y)[e].isZero() && (s(this, y)[e] = new
|
|
1603
|
+
s(this, y)[e].isSameAs(s(this, y)[t]) && (s(this, y)[e].add(s(this, y)[t]), s(this, y).splice(t, 1), s(this, y)[e].isZero() && (s(this, y)[e] = new M().zero()), t--);
|
|
1604
1604
|
e++;
|
|
1605
1605
|
}
|
|
1606
1606
|
h(this, y, s(this, y).filter((t) => !t.coefficient.isZero()));
|
|
@@ -1639,15 +1639,15 @@ const C = class C {
|
|
|
1639
1639
|
});
|
|
1640
1640
|
a(this, "subtract", (...e) => {
|
|
1641
1641
|
for (const t of e)
|
|
1642
|
-
t instanceof C ? this.add(t.clone().opposite()) : t instanceof
|
|
1642
|
+
t instanceof C ? this.add(t.clone().opposite()) : t instanceof M ? s(this, y).push(t.clone().opposite()) : s(this, y).push(new M(t).opposite());
|
|
1643
1643
|
return this.reduce();
|
|
1644
1644
|
});
|
|
1645
1645
|
/**
|
|
1646
1646
|
* Set the polynom to zero.
|
|
1647
1647
|
* @returns {this}
|
|
1648
1648
|
*/
|
|
1649
|
-
a(this, "zero", () => (h(this, y, []), s(this, y).push(new
|
|
1650
|
-
p(this,
|
|
1649
|
+
a(this, "zero", () => (h(this, y, []), s(this, y).push(new M().zero()), this));
|
|
1650
|
+
p(this, Qe, (e, t) => {
|
|
1651
1651
|
t === void 0 && (t = "=");
|
|
1652
1652
|
const i = this.clone().reduce().reorder(), n = e.clone().reduce().reorder();
|
|
1653
1653
|
switch (t) {
|
|
@@ -1664,7 +1664,7 @@ const C = class C {
|
|
|
1664
1664
|
t.coefficient.divide(e);
|
|
1665
1665
|
return this;
|
|
1666
1666
|
});
|
|
1667
|
-
p(this,
|
|
1667
|
+
p(this, kt, (e) => {
|
|
1668
1668
|
const t = new u(e);
|
|
1669
1669
|
for (const i of s(this, y))
|
|
1670
1670
|
i.coefficient.divide(t);
|
|
@@ -1676,8 +1676,8 @@ const C = class C {
|
|
|
1676
1676
|
t += i.evaluate(e, !0);
|
|
1677
1677
|
}), t;
|
|
1678
1678
|
});
|
|
1679
|
-
p(this,
|
|
1680
|
-
var
|
|
1679
|
+
p(this, Ct, (e) => {
|
|
1680
|
+
var E;
|
|
1681
1681
|
let t, i, n, r, l, c, d, f, g;
|
|
1682
1682
|
if (this.numberOfVars === 1)
|
|
1683
1683
|
return n = this.monomByDegree(2, e).coefficient, r = this.monomByDegree(1, e).coefficient, l = this.monomByDegree(0, e).coefficient, c = r.clone().pow(2).subtract(n.clone().multiply(l).multiply(4)), c.isZero() ? (d = r.clone().opposite().divide(n.clone().multiply(2)), t = new C(e).subtract(d.display).multiply(d.denominator), i = new C(e).subtract(d.display).multiply(d.denominator), g = n.divide(d.denominator).divide(d.denominator), g.isOne() ? [t, i] : [new C(g.display), t, i]) : c.isPositive() && c.isSquare() ? (d = r.clone().opposite().add(c.clone().sqrt()).divide(n.clone().multiply(2)), f = r.clone().opposite().subtract(c.clone().sqrt()).divide(n.clone().multiply(2)), g = n.divide(d.denominator).divide(f.denominator), g.isOne() ? [
|
|
@@ -1689,7 +1689,7 @@ const C = class C {
|
|
|
1689
1689
|
new C(e).subtract(f.display).multiply(f.denominator)
|
|
1690
1690
|
]) : [this.clone()];
|
|
1691
1691
|
if (n = this.monomByDegree(2, e), r = this.monomByDegree(1, e), l = this.monomByDegree(0, e), n.isLiteralSquare() && l.isLiteralSquare() && r.clone().pow(2).isSameAs(n.clone().multiply(l))) {
|
|
1692
|
-
const
|
|
1692
|
+
const V = new C("x", n.coefficient, r.coefficient, l.coefficient), de = s(E = V, Ct).call(E, "x"), he = [];
|
|
1693
1693
|
let ae;
|
|
1694
1694
|
if (de.length >= 2) {
|
|
1695
1695
|
for (const ge of de)
|
|
@@ -1699,7 +1699,7 @@ const C = class C {
|
|
|
1699
1699
|
}
|
|
1700
1700
|
return [this.clone()];
|
|
1701
1701
|
});
|
|
1702
|
-
p(this,
|
|
1702
|
+
p(this, Ke, (e, t, i, n) => {
|
|
1703
1703
|
let r = "";
|
|
1704
1704
|
for (const l of s(this, y)) {
|
|
1705
1705
|
if (l.coefficient.value === 0)
|
|
@@ -1709,7 +1709,7 @@ const C = class C {
|
|
|
1709
1709
|
}
|
|
1710
1710
|
return i === !0 && this.length > 1 && (e === "tex" ? r = `\\left( ${r} \\right)` : r = `(${r})`), r === "" && (r = "0"), r;
|
|
1711
1711
|
});
|
|
1712
|
-
p(this,
|
|
1712
|
+
p(this, $t, (e, t, i) => {
|
|
1713
1713
|
const n = e.monoms[0].dividers, r = e.monoms[e.monoms.length - 1].dividers, l = [];
|
|
1714
1714
|
return n.forEach((c) => {
|
|
1715
1715
|
c.degree(i).isLeq(t) && r.forEach((d) => {
|
|
@@ -1722,38 +1722,38 @@ const C = class C {
|
|
|
1722
1722
|
t.coefficient.multiply(e);
|
|
1723
1723
|
return this.reduce();
|
|
1724
1724
|
});
|
|
1725
|
-
p(this,
|
|
1726
|
-
p(this,
|
|
1725
|
+
p(this, It, (e) => s(this, ft).call(this, new u(e)));
|
|
1726
|
+
p(this, Pt, (e) => {
|
|
1727
1727
|
for (const t of s(this, y))
|
|
1728
1728
|
t.multiply(e);
|
|
1729
1729
|
return this.reduce();
|
|
1730
1730
|
});
|
|
1731
|
-
p(this,
|
|
1731
|
+
p(this, Bt, (e) => {
|
|
1732
1732
|
const t = [];
|
|
1733
1733
|
for (const i of s(this, y))
|
|
1734
1734
|
for (const n of e.monoms)
|
|
1735
|
-
t.push(
|
|
1735
|
+
t.push(M.xMultiply(i, n));
|
|
1736
1736
|
return h(this, y, t), this.reduce();
|
|
1737
1737
|
});
|
|
1738
1738
|
/**
|
|
1739
1739
|
* Main parse using a shutting yard class
|
|
1740
1740
|
* @param inputStr
|
|
1741
1741
|
*/
|
|
1742
|
-
p(this,
|
|
1743
|
-
const i = new
|
|
1742
|
+
p(this, Rt, (e) => {
|
|
1743
|
+
const i = new Yt().parse(e).rpn;
|
|
1744
1744
|
this.zero();
|
|
1745
1745
|
const n = [];
|
|
1746
1746
|
for (const r of i)
|
|
1747
|
-
s(this,
|
|
1747
|
+
s(this, zt).call(this, n, r);
|
|
1748
1748
|
return n.length === 1 && this.add(n[0]), this.reorder();
|
|
1749
1749
|
});
|
|
1750
|
-
p(this,
|
|
1750
|
+
p(this, zt, (e, t) => {
|
|
1751
1751
|
switch (t.tokenType) {
|
|
1752
1752
|
case m.COEFFICIENT:
|
|
1753
1753
|
e.push(new C(t.token));
|
|
1754
1754
|
break;
|
|
1755
1755
|
case m.VARIABLE:
|
|
1756
|
-
e.push(new C().add(new
|
|
1756
|
+
e.push(new C().add(new M(t.token)));
|
|
1757
1757
|
break;
|
|
1758
1758
|
case m.CONSTANT:
|
|
1759
1759
|
console.log("Actually, not supported - will be added later !");
|
|
@@ -1797,10 +1797,10 @@ const C = class C {
|
|
|
1797
1797
|
break;
|
|
1798
1798
|
}
|
|
1799
1799
|
});
|
|
1800
|
-
return h(this, y, []), h(this, je, []), h(this,
|
|
1800
|
+
return h(this, y, []), h(this, je, []), h(this, Ye, []), e !== void 0 && this.parse(e, ...t), this;
|
|
1801
1801
|
}
|
|
1802
1802
|
get display() {
|
|
1803
|
-
return s(this,
|
|
1803
|
+
return s(this, Ke).call(this);
|
|
1804
1804
|
}
|
|
1805
1805
|
hasVariable(e) {
|
|
1806
1806
|
return this.variables.includes(e);
|
|
@@ -1830,16 +1830,16 @@ const C = class C {
|
|
|
1830
1830
|
return this.variables.length;
|
|
1831
1831
|
}
|
|
1832
1832
|
get plotFunction() {
|
|
1833
|
-
return s(this,
|
|
1833
|
+
return s(this, Ke).call(this, "tex", !1, !1, !0);
|
|
1834
1834
|
}
|
|
1835
1835
|
root() {
|
|
1836
1836
|
throw new Error("Cannot take the root from a polynom");
|
|
1837
1837
|
}
|
|
1838
1838
|
get roots() {
|
|
1839
|
-
return s(this, ct) ? s(this,
|
|
1839
|
+
return s(this, ct) ? s(this, Ye) : this.getZeroes();
|
|
1840
1840
|
}
|
|
1841
1841
|
set roots(e) {
|
|
1842
|
-
h(this, ct, !0), h(this,
|
|
1842
|
+
h(this, ct, !0), h(this, Ye, e);
|
|
1843
1843
|
}
|
|
1844
1844
|
sqrt() {
|
|
1845
1845
|
throw new Error("Cannot take the square root from a polynom");
|
|
@@ -1857,22 +1857,22 @@ const C = class C {
|
|
|
1857
1857
|
} else {
|
|
1858
1858
|
let r = 0, l, c = "+";
|
|
1859
1859
|
i.forEach((d, f) => {
|
|
1860
|
-
const g = t.findIndex((
|
|
1860
|
+
const g = t.findIndex((V) => V.value === i[f].value);
|
|
1861
1861
|
f === 0 && (l = g * 2 + 1, n[l] = "z", n = Se(
|
|
1862
1862
|
n,
|
|
1863
1863
|
"",
|
|
1864
1864
|
this.evaluate(d.value - 1, !0) < 0 ? "-" : "+",
|
|
1865
1865
|
0,
|
|
1866
1866
|
l
|
|
1867
|
-
)), r = g * 2 + 1, l = f === i.length - 1 ? n.length : t.findIndex((
|
|
1868
|
-
const
|
|
1869
|
-
c = this.evaluate(
|
|
1867
|
+
)), r = g * 2 + 1, l = f === i.length - 1 ? n.length : t.findIndex((V) => V.value === i[f + 1].value) * 2 + 1;
|
|
1868
|
+
const E = f === i.length - 1 ? d.value + 1 : (d.value + i[f + 1].value) / 2;
|
|
1869
|
+
c = this.evaluate(E, !0) < 0 ? "-" : "+", n[r] = "z", n = Se(n, "", c, r, l), r = +l, l = n.length;
|
|
1870
1870
|
});
|
|
1871
1871
|
}
|
|
1872
1872
|
return { roots: t, signs: n };
|
|
1873
1873
|
}
|
|
1874
1874
|
get tex() {
|
|
1875
|
-
return s(this,
|
|
1875
|
+
return s(this, Ke).call(this, "tex");
|
|
1876
1876
|
}
|
|
1877
1877
|
get variables() {
|
|
1878
1878
|
let e = [];
|
|
@@ -1884,14 +1884,14 @@ const C = class C {
|
|
|
1884
1884
|
return this.getZeroes();
|
|
1885
1885
|
}
|
|
1886
1886
|
};
|
|
1887
|
-
je = new WeakMap(), y = new WeakMap(),
|
|
1887
|
+
je = new WeakMap(), y = new WeakMap(), Ye = new WeakMap(), ct = new WeakMap(), Qe = new WeakMap(), ut = new WeakMap(), kt = new WeakMap(), Mt = new WeakMap(), Ct = new WeakMap(), Ke = new WeakMap(), $t = new WeakMap(), ft = new WeakMap(), It = new WeakMap(), Pt = new WeakMap(), Bt = new WeakMap(), St = new WeakSet(), Ti = function(e, ...t) {
|
|
1888
1888
|
if (t.length === 0) {
|
|
1889
1889
|
if (e = "" + e, e !== "" && !isNaN(Number(e))) {
|
|
1890
1890
|
this.empty();
|
|
1891
|
-
const i = new
|
|
1891
|
+
const i = new M(e);
|
|
1892
1892
|
return this.add(i), this;
|
|
1893
1893
|
}
|
|
1894
|
-
return s(this,
|
|
1894
|
+
return s(this, Rt).call(this, e);
|
|
1895
1895
|
} else if (/^[a-z]+/.test(e)) {
|
|
1896
1896
|
this.empty();
|
|
1897
1897
|
const i = t.map((n) => new u(n));
|
|
@@ -1899,35 +1899,35 @@ je = new WeakMap(), y = new WeakMap(), Ke = new WeakMap(), ct = new WeakMap(), J
|
|
|
1899
1899
|
const n = e.split("");
|
|
1900
1900
|
let r = 0;
|
|
1901
1901
|
for (const l of i) {
|
|
1902
|
-
const c = new
|
|
1902
|
+
const c = new M();
|
|
1903
1903
|
c.coefficient = l.clone(), c.literalStr = n[r] || "", this.add(c), r++;
|
|
1904
1904
|
}
|
|
1905
1905
|
} else {
|
|
1906
1906
|
let n = i.length - 1;
|
|
1907
1907
|
for (const r of i) {
|
|
1908
|
-
const l = new
|
|
1908
|
+
const l = new M();
|
|
1909
1909
|
l.coefficient = r.clone(), l.literalStr = `${e}^${n}`, this.add(l), n--;
|
|
1910
1910
|
}
|
|
1911
1911
|
}
|
|
1912
1912
|
return this;
|
|
1913
1913
|
} else
|
|
1914
1914
|
return this.zero();
|
|
1915
|
-
},
|
|
1916
|
-
let
|
|
1917
|
-
var Ee,
|
|
1915
|
+
}, Rt = new WeakMap(), zt = new WeakMap();
|
|
1916
|
+
let q = C;
|
|
1917
|
+
var Ee, Ne, Te, Je;
|
|
1918
1918
|
const we = class we {
|
|
1919
1919
|
constructor(e, t) {
|
|
1920
1920
|
p(this, Ee);
|
|
1921
|
-
p(this, et, !1);
|
|
1922
1921
|
p(this, Ne);
|
|
1923
1922
|
p(this, Te);
|
|
1923
|
+
p(this, Je, !1);
|
|
1924
1924
|
if (e instanceof we)
|
|
1925
1925
|
h(this, Ne, e.polynom.clone()), h(this, Te, e.power.clone());
|
|
1926
1926
|
else if (typeof e == "string" && t === void 0) {
|
|
1927
1927
|
const [i, n = "1"] = e.split("^");
|
|
1928
|
-
h(this, Ne, new
|
|
1928
|
+
h(this, Ne, new q(i)), h(this, Te, new u(n.replace("(", "").replace(")", "")));
|
|
1929
1929
|
} else
|
|
1930
|
-
h(this, Ne, new
|
|
1930
|
+
h(this, Ne, new q(e)), h(this, Te, new u(t ?? 1));
|
|
1931
1931
|
return h(this, Ee, 1), this;
|
|
1932
1932
|
}
|
|
1933
1933
|
parse() {
|
|
@@ -1936,17 +1936,21 @@ const we = class we {
|
|
|
1936
1936
|
clone() {
|
|
1937
1937
|
return new we(this);
|
|
1938
1938
|
}
|
|
1939
|
-
|
|
1940
|
-
|
|
1939
|
+
get tex() {
|
|
1940
|
+
const e = this.power.numerator, t = this.power.denominator;
|
|
1941
|
+
let i, n;
|
|
1942
|
+
return s(this, Ee) === 0 && t > 1 ? (i = `\\sqrt${t === 2 ? "" : `[ ${t} ]`}{ ${this.polynom.tex} }`, n = e === 1 ? "" : `^{ ${e} }`) : (i = s(this, Je) && this.power.isOne() ? this.polynom.tex : gi(this.polynom.tex), n = t === 1 && e === 1 ? "" : `^{ ${this.power.tex} }`), i = `${i}${n}`, s(this, Ee) === 0 && e < 0 && (i = `\\frac{ 1 }{ ${i} }`), i;
|
|
1941
1943
|
}
|
|
1942
|
-
get
|
|
1943
|
-
|
|
1944
|
+
get display() {
|
|
1945
|
+
const e = this.power.numerator, t = this.power.denominator;
|
|
1946
|
+
let i, n;
|
|
1947
|
+
return s(this, Ee) === 0 && t > 1 ? (i = `${t === 2 ? "sqrt" : `root(${t})`}(${this.polynom.display})`, n = e === 1 ? "" : `^(${e})`) : (i = s(this, Je) && this.power.isOne() ? this.polynom.display : gi(this.polynom.display, !1), n = t === 1 && e === 1 ? "" : `^(${this.power.display})`), i = `${i}${n}`, s(this, Ee) === 0 && e < 0 && (i = `1/(${i})`), i;
|
|
1944
1948
|
}
|
|
1945
|
-
|
|
1946
|
-
|
|
1949
|
+
add() {
|
|
1950
|
+
throw new Error("Adding two factors is not possible");
|
|
1947
1951
|
}
|
|
1948
1952
|
get asSingle() {
|
|
1949
|
-
return h(this,
|
|
1953
|
+
return h(this, Je, !0), this;
|
|
1950
1954
|
}
|
|
1951
1955
|
degree(e) {
|
|
1952
1956
|
return this.polynom.degree(e).multiply(this.power);
|
|
@@ -1963,15 +1967,10 @@ const we = class we {
|
|
|
1963
1967
|
return this.polynom.clone().pow(this.power.value);
|
|
1964
1968
|
throw new Error("The power must be a natural number");
|
|
1965
1969
|
}
|
|
1966
|
-
get display() {
|
|
1967
|
-
const e = this.power.numerator, t = this.power.denominator;
|
|
1968
|
-
let i, n;
|
|
1969
|
-
return s(this, Ee) === 0 && t > 1 ? (i = `${t === 2 ? "sqrt" : `root(${t})`}(${this.polynom.display})`, n = Math.abs(e) === 1 ? "" : `^(${Math.abs(e)})`) : (i = s(this, et) && this.power.isOne() ? this.polynom.display : pi(this.polynom.display, !1), n = t === 1 && Math.abs(e) === 1 ? "" : `^(${this.power.display})`), i = `${i}${n}`, s(this, Ee) === 0 && e < 0 && (i = `1/(${i})`), i;
|
|
1970
|
-
}
|
|
1971
1970
|
divide(e) {
|
|
1972
1971
|
if (e instanceof we && this.isSameAs(e))
|
|
1973
1972
|
return this.power.subtract(e.power), this;
|
|
1974
|
-
const t = new
|
|
1973
|
+
const t = new q(e);
|
|
1975
1974
|
if (this.isSameAs(t))
|
|
1976
1975
|
return this.power.subtract(1), this;
|
|
1977
1976
|
throw new Error("The two factors must be the same");
|
|
@@ -1993,7 +1992,7 @@ const we = class we {
|
|
|
1993
1992
|
}
|
|
1994
1993
|
isSameAs(e) {
|
|
1995
1994
|
let t;
|
|
1996
|
-
return e instanceof we ? t = e.polynom : e instanceof
|
|
1995
|
+
return e instanceof we ? t = e.polynom : e instanceof q ? t = e : t = new q(e), this.polynom.isEqual(t);
|
|
1997
1996
|
}
|
|
1998
1997
|
isZero() {
|
|
1999
1998
|
return this.polynom.isZero();
|
|
@@ -2001,7 +2000,7 @@ const we = class we {
|
|
|
2001
2000
|
multiply(e) {
|
|
2002
2001
|
if (e instanceof we && this.isSameAs(e))
|
|
2003
2002
|
return this.power.add(e.power), this;
|
|
2004
|
-
const t = new
|
|
2003
|
+
const t = new q(e);
|
|
2005
2004
|
if (this.isSameAs(t))
|
|
2006
2005
|
return this.power.add(1), this;
|
|
2007
2006
|
throw new Error("The two factors must be the same");
|
|
@@ -2042,41 +2041,57 @@ const we = class we {
|
|
|
2042
2041
|
subtract() {
|
|
2043
2042
|
throw new Error("Subtracting two factors is not possible");
|
|
2044
2043
|
}
|
|
2045
|
-
|
|
2046
|
-
const
|
|
2047
|
-
|
|
2048
|
-
return s(this, Ee) === 0 && t > 1 ? (i = `\\sqrt${t === 2 ? "" : `[ ${t} ]`}{ ${this.polynom.tex} }`, n = Math.abs(e) === 1 ? "" : `^{ ${Math.abs(e)} }`) : (i = s(this, et) && this.power.isOne() ? this.polynom.tex : pi(this.polynom.tex), n = t === 1 && Math.abs(e) === 1 ? "" : `^{ ${this.power.tex} }`), i = `${i}${n}`, s(this, Ee) === 0 && e < 0 && (i = `\\frac{ 1 }{ ${i} }`), i;
|
|
2044
|
+
tableOfSigns(e) {
|
|
2045
|
+
const t = this.power.clone().reduce(), i = this.polynom.tableOfSigns(e);
|
|
2046
|
+
return t.isStrictlyNegative() && (i.signs = Se(i.signs, "z", "d")), t.denominator % 2 === 0 ? i.signs = Se(i.signs, "-", "h") : t.numerator % 2 === 0 && (i.signs = Se(i.signs, "-", "+")), { roots: i.roots, signs: i.signs };
|
|
2049
2047
|
}
|
|
2050
2048
|
get variables() {
|
|
2051
2049
|
return this.polynom.variables;
|
|
2052
2050
|
}
|
|
2051
|
+
get withPower() {
|
|
2052
|
+
return h(this, Ee, 1), this;
|
|
2053
|
+
}
|
|
2054
|
+
get withRoot() {
|
|
2055
|
+
return h(this, Ee, 0), this;
|
|
2056
|
+
}
|
|
2053
2057
|
zero() {
|
|
2054
2058
|
return s(this, Ne).zero(), s(this, Te).one(), this;
|
|
2055
2059
|
}
|
|
2056
|
-
tableOfSigns(e) {
|
|
2057
|
-
const t = this.power.clone().reduce(), i = this.polynom.tableOfSigns(e);
|
|
2058
|
-
return t.isStrictlyNegative() && (i.signs = Se(i.signs, "z", "d")), t.denominator % 2 === 0 ? i.signs = Se(i.signs, "-", "h") : t.numerator % 2 === 0 && (i.signs = Se(i.signs, "-", "+")), { roots: i.roots, signs: i.signs };
|
|
2059
|
-
}
|
|
2060
2060
|
};
|
|
2061
|
-
Ee = new WeakMap(),
|
|
2062
|
-
let
|
|
2063
|
-
var
|
|
2061
|
+
Ee = new WeakMap(), Ne = new WeakMap(), Te = new WeakMap(), Je = new WeakMap();
|
|
2062
|
+
let ue = we;
|
|
2063
|
+
var ht = /* @__PURE__ */ ((o) => (o[o.ROOT = 0] = "ROOT", o[o.POWER = 1] = "POWER", o))(ht || {}), _e, N, dt, ii, pt, si;
|
|
2064
2064
|
const me = class me {
|
|
2065
2065
|
constructor(...e) {
|
|
2066
|
-
p(this,
|
|
2067
|
-
p(this,
|
|
2066
|
+
p(this, pt);
|
|
2067
|
+
p(this, _e, ht.POWER);
|
|
2068
|
+
p(this, N, []);
|
|
2068
2069
|
return this.parse(...e), this;
|
|
2069
2070
|
}
|
|
2070
2071
|
parse(...e) {
|
|
2071
|
-
return e.length === 0 ? this : (h(this,
|
|
2072
|
+
return e.length === 0 ? this : (h(this, N, []), e.forEach((t) => {
|
|
2072
2073
|
if (typeof t == "string") {
|
|
2073
2074
|
const i = t.split(")(").join(")*(").split("*");
|
|
2074
|
-
s(this,
|
|
2075
|
-
} else t instanceof me ? s(this,
|
|
2075
|
+
s(this, N).push(...i.map((n) => new ue(n)));
|
|
2076
|
+
} else t instanceof me ? s(this, N).push(...t.factors.map((i) => i.clone())) : s(this, N).push(new ue(t));
|
|
2076
2077
|
}), this);
|
|
2077
2078
|
}
|
|
2078
2079
|
clone() {
|
|
2079
|
-
return new me(...s(this,
|
|
2080
|
+
return new me(...s(this, N).map((e) => e.clone()));
|
|
2081
|
+
}
|
|
2082
|
+
get tex() {
|
|
2083
|
+
const { num: e, den: t } = O(this, pt, si).call(this);
|
|
2084
|
+
if (t.length === 0)
|
|
2085
|
+
return e.length === 1 ? e[0].asSingle.tex : e.map((r) => r.tex).join("");
|
|
2086
|
+
const i = e.length === 1 ? e[0].asSingle.tex : e.map((r) => r.tex).join(""), n = t.length === 1 ? t[0].asSingle.tex : t.map((r) => r.tex).join("");
|
|
2087
|
+
return `\\frac{ ${i} }{ ${n} }`;
|
|
2088
|
+
}
|
|
2089
|
+
get display() {
|
|
2090
|
+
const { num: e, den: t } = O(this, pt, si).call(this);
|
|
2091
|
+
if (t.length === 0)
|
|
2092
|
+
return e.length === 1 ? e[0].asSingle.display : e.map((r) => r.display).join("");
|
|
2093
|
+
const i = e.length === 1 ? e[0].asSingle.display : e.map((r) => r.display).join(""), n = t.length === 1 ? t[0].asSingle.display : t.map((r) => r.display).join("");
|
|
2094
|
+
return `(${i})/(${n})`;
|
|
2080
2095
|
}
|
|
2081
2096
|
static gcd(...e) {
|
|
2082
2097
|
var i;
|
|
@@ -2085,78 +2100,71 @@ const me = class me {
|
|
|
2085
2100
|
if (e.length === 1)
|
|
2086
2101
|
return e[0];
|
|
2087
2102
|
if (e.length === 2)
|
|
2088
|
-
return
|
|
2103
|
+
return O(i = me, dt, ii).call(i, e[0], e[1]);
|
|
2089
2104
|
let t = e[0];
|
|
2090
2105
|
return e.shift(), e.forEach((n) => {
|
|
2091
2106
|
var r;
|
|
2092
|
-
return t =
|
|
2107
|
+
return t = O(r = me, dt, ii).call(r, t, n);
|
|
2093
2108
|
}), t;
|
|
2094
2109
|
}
|
|
2095
2110
|
add(...e) {
|
|
2096
2111
|
let t = [this, ...e];
|
|
2097
2112
|
const i = me.gcd(...t);
|
|
2098
2113
|
t = t.map((r) => r.divide(i).reduce());
|
|
2099
|
-
const n = new
|
|
2100
|
-
return t.forEach((r) => n.add(r.develop())), h(this,
|
|
2114
|
+
const n = new q("0");
|
|
2115
|
+
return t.forEach((r) => n.add(r.develop())), h(this, N, [
|
|
2101
2116
|
...i.factors,
|
|
2102
|
-
new
|
|
2117
|
+
new ue(n)
|
|
2103
2118
|
]), this;
|
|
2104
2119
|
}
|
|
2105
2120
|
get asPower() {
|
|
2106
|
-
return h(this,
|
|
2121
|
+
return h(this, _e, ht.POWER), this;
|
|
2107
2122
|
}
|
|
2108
2123
|
get asRoot() {
|
|
2109
|
-
return h(this,
|
|
2124
|
+
return h(this, _e, ht.ROOT), this;
|
|
2110
2125
|
}
|
|
2111
2126
|
degree(e) {
|
|
2112
|
-
return s(this,
|
|
2127
|
+
return s(this, N).reduce((t, i) => t.add(i.degree(e)), new u("0"));
|
|
2113
2128
|
}
|
|
2114
2129
|
get denominator() {
|
|
2115
|
-
return s(this,
|
|
2130
|
+
return s(this, N).filter((e) => e.power.isNegative());
|
|
2116
2131
|
}
|
|
2117
2132
|
derivative() {
|
|
2118
|
-
const e = [], t = s(this,
|
|
2133
|
+
const e = [], t = s(this, N).length;
|
|
2119
2134
|
for (let n = 0; n < t; n++) {
|
|
2120
|
-
const r = s(this,
|
|
2135
|
+
const r = s(this, N).slice(), l = r.splice(n, 1)[0];
|
|
2121
2136
|
e.push(new me(...r).multiply(new me(...l.derivative())));
|
|
2122
2137
|
}
|
|
2123
2138
|
e.forEach((n) => n.reduce());
|
|
2124
2139
|
const i = e.shift();
|
|
2125
|
-
return i !== void 0 && h(this,
|
|
2140
|
+
return i !== void 0 && h(this, N, i.factors), this.add(...e);
|
|
2126
2141
|
}
|
|
2127
2142
|
develop() {
|
|
2128
|
-
const e = new
|
|
2129
|
-
return s(this,
|
|
2143
|
+
const e = new q("1");
|
|
2144
|
+
return s(this, N).forEach((t) => {
|
|
2130
2145
|
e.multiply(t.develop());
|
|
2131
2146
|
}), e;
|
|
2132
2147
|
}
|
|
2133
|
-
get display() {
|
|
2134
|
-
let e = [], t = [];
|
|
2135
|
-
if (s(this, Ue) === He.ROOT ? (e = this.numerator, t = this.denominator.map((r) => r.clone().inverse())) : e = s(this, E), e.length === 0 && (e = [new le("1")]), t.length === 0)
|
|
2136
|
-
return e.length === 1 ? e[0].asSingle.display : e.map((r) => r.display).join("");
|
|
2137
|
-
const i = e.length === 1 ? e[0].asSingle.display : e.map((r) => r.display).join(""), n = t.length === 1 ? t[0].asSingle.display : t.map((r) => r.display).join("");
|
|
2138
|
-
return `(${i})/(${n})`;
|
|
2139
|
-
}
|
|
2140
2148
|
divide(e) {
|
|
2141
|
-
return h(this,
|
|
2149
|
+
return h(this, N, s(this, N).concat(e.clone().factors.map((t) => t.inverse()))), this;
|
|
2142
2150
|
}
|
|
2143
2151
|
evaluate(e, t) {
|
|
2144
|
-
return t ? s(this,
|
|
2145
|
-
}
|
|
2146
|
-
getFactors() {
|
|
2147
|
-
return s(this, E);
|
|
2152
|
+
return t ? s(this, N).reduce((i, n) => i * n.evaluate(e, t), 1) : s(this, N).reduce((i, n) => i.multiply(n.evaluate(e)), new u("1"));
|
|
2148
2153
|
}
|
|
2149
2154
|
get factors() {
|
|
2150
|
-
return s(this,
|
|
2155
|
+
return s(this, N);
|
|
2151
2156
|
}
|
|
2152
2157
|
set factors(e) {
|
|
2153
|
-
h(this,
|
|
2158
|
+
h(this, N, e);
|
|
2154
2159
|
}
|
|
2155
2160
|
fromPolynom(e, t) {
|
|
2156
|
-
return h(this,
|
|
2161
|
+
return h(this, N, new q(e).factorize(t).map((i) => new ue(i))), this;
|
|
2162
|
+
}
|
|
2163
|
+
getFactors() {
|
|
2164
|
+
return s(this, N);
|
|
2157
2165
|
}
|
|
2158
2166
|
getZeroes() {
|
|
2159
|
-
const e = [].concat(...s(this,
|
|
2167
|
+
const e = [].concat(...s(this, N).map((t) => t.polynom.getZeroes()));
|
|
2160
2168
|
return e.sort((t, i) => t.value - i.value), e.filter(
|
|
2161
2169
|
(t, i, n) => i === n.findIndex(
|
|
2162
2170
|
(r) => r.value === t.value
|
|
@@ -2164,63 +2172,63 @@ const me = class me {
|
|
|
2164
2172
|
);
|
|
2165
2173
|
}
|
|
2166
2174
|
hasVariable(e) {
|
|
2167
|
-
return s(this,
|
|
2175
|
+
return s(this, N).some((t) => t.hasVariable(e));
|
|
2168
2176
|
}
|
|
2169
2177
|
inverse() {
|
|
2170
|
-
return h(this,
|
|
2178
|
+
return h(this, N, s(this, N).map((e) => e.inverse())), this;
|
|
2171
2179
|
}
|
|
2172
2180
|
isEqual(e) {
|
|
2173
2181
|
const t = me.gcd(this, e), i = this.clone().divide(t).reduce(), n = e.clone().divide(t).reduce();
|
|
2174
2182
|
return i.isOne() && n.isOne();
|
|
2175
2183
|
}
|
|
2176
2184
|
isOne() {
|
|
2177
|
-
return s(this,
|
|
2185
|
+
return s(this, N).every((e) => e.isOne());
|
|
2178
2186
|
}
|
|
2179
2187
|
isZero() {
|
|
2180
|
-
return s(this,
|
|
2188
|
+
return s(this, N).every((e) => e.isZero());
|
|
2181
2189
|
}
|
|
2182
2190
|
multiply(...e) {
|
|
2183
2191
|
return e.forEach((t) => {
|
|
2184
|
-
h(this,
|
|
2192
|
+
h(this, N, s(this, N).concat(t.clone().factors));
|
|
2185
2193
|
}), this;
|
|
2186
2194
|
}
|
|
2187
2195
|
get numerator() {
|
|
2188
|
-
return s(this,
|
|
2196
|
+
return s(this, N).filter((e) => e.power.isPositive());
|
|
2189
2197
|
}
|
|
2190
2198
|
one() {
|
|
2191
|
-
return h(this,
|
|
2199
|
+
return h(this, N, [new ue("1", "1")]), this;
|
|
2192
2200
|
}
|
|
2193
2201
|
opposite() {
|
|
2194
|
-
const e = s(this,
|
|
2195
|
-
return e >= 0 ? s(this,
|
|
2202
|
+
const e = s(this, N).findIndex((t) => t.display === "(-1)");
|
|
2203
|
+
return e >= 0 ? s(this, N).splice(e, 1) : s(this, N).push(new ue("-1", "1")), this;
|
|
2196
2204
|
}
|
|
2197
2205
|
pow(e) {
|
|
2198
|
-
return h(this,
|
|
2206
|
+
return h(this, N, s(this, N).map((t) => t.pow(e))), this;
|
|
2199
2207
|
}
|
|
2200
2208
|
primitive() {
|
|
2201
2209
|
throw new Error("Method not implemented.");
|
|
2202
2210
|
}
|
|
2203
2211
|
reduce() {
|
|
2204
|
-
const e =
|
|
2205
|
-
return h(this,
|
|
2212
|
+
const e = _t(this);
|
|
2213
|
+
return h(this, N, Object.values(e).map((t) => {
|
|
2206
2214
|
const i = t[0].polynom, n = t.reduce((r, l) => r.add(l.power), new u("0"));
|
|
2207
|
-
return new
|
|
2215
|
+
return new ue(i, n.reduce());
|
|
2208
2216
|
}).filter((t) => !t.power.isZero())), this;
|
|
2209
2217
|
}
|
|
2210
2218
|
root(e) {
|
|
2211
|
-
return h(this,
|
|
2219
|
+
return h(this, N, s(this, N).map((t) => t.root(e))), this;
|
|
2212
2220
|
}
|
|
2213
2221
|
sort() {
|
|
2214
|
-
return h(this,
|
|
2222
|
+
return h(this, N, s(this, N).sort((e, t) => e.degree().isLeq(t.degree()) ? -1 : 1)), this;
|
|
2215
2223
|
}
|
|
2216
2224
|
sqrt() {
|
|
2217
|
-
return h(this,
|
|
2225
|
+
return h(this, N, s(this, N).map((e) => e.sqrt())), this;
|
|
2218
2226
|
}
|
|
2219
2227
|
subtract(...e) {
|
|
2220
2228
|
return this.add(...e.map((t) => t.opposite()));
|
|
2221
2229
|
}
|
|
2222
2230
|
tableOfSigns() {
|
|
2223
|
-
const e = this.getZeroes(), t = this.factors.map((n) => ({ factor: new
|
|
2231
|
+
const e = this.getZeroes(), t = this.factors.map((n) => ({ factor: new ue(n), ...n.tableOfSigns(e) }));
|
|
2224
2232
|
return { signs: t.map((n) => n.signs).reduce((n, r) => (n.length === 0 ? n = r : r.forEach((l, c) => {
|
|
2225
2233
|
switch (l) {
|
|
2226
2234
|
case "d":
|
|
@@ -2238,61 +2246,57 @@ const me = class me {
|
|
|
2238
2246
|
}
|
|
2239
2247
|
}), n), []), roots: e, factors: t };
|
|
2240
2248
|
}
|
|
2241
|
-
get tex() {
|
|
2242
|
-
let e = [], t = [];
|
|
2243
|
-
if (s(this, Ue) === He.ROOT ? (e = this.numerator, t = this.denominator.map((r) => r.clone().inverse())) : e = s(this, E), e.length === 0 && (e = [new le("1")]), t.length === 0)
|
|
2244
|
-
return e.length === 1 ? e[0].asSingle.tex : e.map((r) => r.tex).join("");
|
|
2245
|
-
const i = e.length === 1 ? e[0].asSingle.tex : e.map((r) => r.tex).join(""), n = t.length === 1 ? t[0].asSingle.tex : t.map((r) => r.tex).join("");
|
|
2246
|
-
return `\\frac{ ${i} }{ ${n} }`;
|
|
2247
|
-
}
|
|
2248
2249
|
get variables() {
|
|
2249
|
-
return s(this,
|
|
2250
|
+
return s(this, N).reduce((e, t) => e.concat(t.variables), []);
|
|
2250
2251
|
}
|
|
2251
2252
|
zero() {
|
|
2252
|
-
return h(this,
|
|
2253
|
+
return h(this, N, [new ue("0", "1")]), this;
|
|
2253
2254
|
}
|
|
2254
2255
|
};
|
|
2255
|
-
|
|
2256
|
-
const i =
|
|
2257
|
-
const d = i[c].reduce((g,
|
|
2258
|
-
return new
|
|
2256
|
+
_e = new WeakMap(), N = new WeakMap(), dt = new WeakSet(), ii = function(e, t) {
|
|
2257
|
+
const i = _t(e), n = _t(t), l = Object.keys(i).filter((c) => Object.hasOwn(n, c)).map((c) => {
|
|
2258
|
+
const d = i[c].reduce((g, E) => g.add(E.power), new u("0")), f = n[c].reduce((g, E) => g.add(E.power), new u("0"));
|
|
2259
|
+
return new ue(c, u.min(d, f));
|
|
2259
2260
|
});
|
|
2260
2261
|
return new me(...l);
|
|
2262
|
+
}, pt = new WeakSet(), si = function() {
|
|
2263
|
+
let e, t = [];
|
|
2264
|
+
return s(this, _e) === ht.ROOT ? (e = this.numerator, t = this.denominator.map((i) => i.clone().inverse())) : e = s(this, N), e.length === 0 && (e = [new ue("1")]), { num: e, den: t };
|
|
2261
2265
|
}, p(me, dt);
|
|
2262
|
-
let
|
|
2263
|
-
function
|
|
2266
|
+
let ti = me;
|
|
2267
|
+
function _t(o) {
|
|
2264
2268
|
const e = new u().one(), t = o.factors.reduce((i, n) => {
|
|
2265
2269
|
if (n.polynom.degree().isZero())
|
|
2266
2270
|
return n.polynom.monoms.length > 0 && e.multiply(n.polynom.monoms[0].coefficient), i;
|
|
2267
2271
|
const r = n.polynom.display;
|
|
2268
2272
|
return Object.hasOwn(i, r) ? i[r].push(n) : i[r] = [n], i;
|
|
2269
2273
|
}, {});
|
|
2270
|
-
return e.isOne() || (t[e.display] = [new
|
|
2274
|
+
return e.isOne() || (t[e.display] = [new ue(e.display, 1)]), t;
|
|
2271
2275
|
}
|
|
2272
|
-
var
|
|
2276
|
+
var A, k, se, Lt, et, Dt;
|
|
2273
2277
|
const xe = class xe {
|
|
2274
2278
|
constructor(e, t, i) {
|
|
2275
2279
|
// Left part of the equation
|
|
2276
|
-
p(this,
|
|
2280
|
+
p(this, A);
|
|
2277
2281
|
// Right part of the equation
|
|
2278
|
-
p(this,
|
|
2282
|
+
p(this, k);
|
|
2279
2283
|
// Signe of the equation
|
|
2280
2284
|
p(this, se);
|
|
2281
2285
|
// ------------------------------------------
|
|
2282
2286
|
a(this, "parse", (e) => {
|
|
2283
|
-
const t = s(this,
|
|
2287
|
+
const t = s(this, Lt).call(this, e);
|
|
2284
2288
|
if (t === !1)
|
|
2285
2289
|
throw new Error("The equation is not valid (no sign found)");
|
|
2286
2290
|
const i = e.split(t);
|
|
2287
|
-
return this.create(new
|
|
2291
|
+
return this.create(new q(i[0]), new q(i[1]), s(this, et).call(this, t));
|
|
2288
2292
|
});
|
|
2289
|
-
a(this, "create", (e, t, i) => (h(this,
|
|
2290
|
-
a(this, "clone", () => new xe(s(this,
|
|
2293
|
+
a(this, "create", (e, t, i) => (h(this, A, e), h(this, k, t), h(this, se, s(this, et).call(this, i ?? "=")), this));
|
|
2294
|
+
a(this, "clone", () => new xe(s(this, A).clone(), s(this, k).clone(), s(this, se)));
|
|
2291
2295
|
/**
|
|
2292
2296
|
* Get the degree of the equation
|
|
2293
2297
|
* @param letter
|
|
2294
2298
|
*/
|
|
2295
|
-
a(this, "degree", (e) => u.max(s(this,
|
|
2299
|
+
a(this, "degree", (e) => u.max(s(this, A).degree(e), s(this, k).degree(e)));
|
|
2296
2300
|
/**
|
|
2297
2301
|
* divide an equation by a given value (transformed as a fraction)
|
|
2298
2302
|
*
|
|
@@ -2323,7 +2327,7 @@ const xe = class xe {
|
|
|
2323
2327
|
/**
|
|
2324
2328
|
* Determine if the equation contains more than one letter/variable.
|
|
2325
2329
|
*/
|
|
2326
|
-
a(this, "isMultiVariable", () => s(this,
|
|
2330
|
+
a(this, "isMultiVariable", () => s(this, A).isMultiVariable || s(this, k).isMultiVariable);
|
|
2327
2331
|
// -----------------------------------------------
|
|
2328
2332
|
// Equations helpers
|
|
2329
2333
|
a(this, "isEqualTo", (e) => {
|
|
@@ -2338,47 +2342,47 @@ const xe = class xe {
|
|
|
2338
2342
|
if (!this.degree(e).isOne() || this.isMultiVariable())
|
|
2339
2343
|
return !1;
|
|
2340
2344
|
let t;
|
|
2341
|
-
s(this,
|
|
2342
|
-
const i = [...s(this,
|
|
2345
|
+
s(this, A).subtract(s(this, k)), s(this, k).zero();
|
|
2346
|
+
const i = [...s(this, A).monoms];
|
|
2343
2347
|
for (const r of i)
|
|
2344
|
-
r.hasVariable(e) || (t = r.clone(), s(this,
|
|
2345
|
-
if (s(this,
|
|
2348
|
+
r.hasVariable(e) || (t = r.clone(), s(this, A).subtract(t), s(this, k).subtract(t));
|
|
2349
|
+
if (s(this, A).length !== 1)
|
|
2346
2350
|
return !1;
|
|
2347
|
-
const n = s(this,
|
|
2348
|
-
return s(this,
|
|
2351
|
+
const n = s(this, A).monoms[0].coefficient.clone();
|
|
2352
|
+
return s(this, A).divide(n), s(this, k).divide(n), this;
|
|
2349
2353
|
});
|
|
2350
2354
|
// -----------------------------------------------
|
|
2351
2355
|
// Equations operations
|
|
2352
2356
|
// -----------------------------------------------
|
|
2353
|
-
a(this, "letters", () => [.../* @__PURE__ */ new Set([...s(this,
|
|
2357
|
+
a(this, "letters", () => [.../* @__PURE__ */ new Set([...s(this, A).letters(), ...s(this, k).letters()])]);
|
|
2354
2358
|
// -----------------------------------------------
|
|
2355
2359
|
/**
|
|
2356
2360
|
* Reorder will move all monoms containing a letter on the left, all the other on the right.
|
|
2357
2361
|
*/
|
|
2358
|
-
a(this, "moveLeft", () => (s(this,
|
|
2362
|
+
a(this, "moveLeft", () => (s(this, A).subtract(s(this, k)), s(this, k).zero(), this));
|
|
2359
2363
|
/**
|
|
2360
2364
|
* Multiple an equation by a fraction value.
|
|
2361
2365
|
* @param value
|
|
2362
2366
|
*/
|
|
2363
2367
|
a(this, "multiply", (e) => {
|
|
2364
2368
|
const t = new u(e);
|
|
2365
|
-
return s(this,
|
|
2369
|
+
return s(this, A).multiply(t), s(this, k).multiply(t), s(this, se) !== "=" && t.sign() === -1 && s(this, Dt).call(this), this;
|
|
2366
2370
|
});
|
|
2367
|
-
a(this, "opposite", () => (h(this,
|
|
2368
|
-
a(this, "reorder", (e) => (s(this,
|
|
2371
|
+
a(this, "opposite", () => (h(this, A, s(this, A).opposite()), h(this, k, s(this, k).opposite()), this));
|
|
2372
|
+
a(this, "reorder", (e) => (s(this, A).subtract(s(this, k)), s(this, k).zero(), s(this, A).reorder(), e ? this : (s(this, A).monoms.filter((t) => t.degree().isZero()).forEach((t) => {
|
|
2369
2373
|
const i = t.clone();
|
|
2370
|
-
s(this,
|
|
2371
|
-
}), s(this,
|
|
2374
|
+
s(this, A).subtract(i), s(this, k).subtract(i);
|
|
2375
|
+
}), s(this, A).reorder(), s(this, k).reorder(), this)));
|
|
2372
2376
|
// ------------------------------------------
|
|
2373
|
-
a(this, "replaceBy", (e, t) => (s(this,
|
|
2377
|
+
a(this, "replaceBy", (e, t) => (s(this, A).replaceBy(e, t), s(this, k).replaceBy(e, t), this));
|
|
2374
2378
|
/**
|
|
2375
2379
|
* Multiply by the lcm denominator and divide by the gcm numerators.
|
|
2376
2380
|
*/
|
|
2377
|
-
a(this, "simplify", () => (this.multiply(G.lcm(...s(this,
|
|
2381
|
+
a(this, "simplify", () => (this.multiply(G.lcm(...s(this, A).getDenominators(), ...s(this, k).getDenominators())), this.divide(G.gcd(...s(this, A).getNumerators(), ...s(this, k).getNumerators())), this));
|
|
2378
2382
|
// -----------------------------------------------
|
|
2379
|
-
a(this, "solve", () => new
|
|
2383
|
+
a(this, "solve", () => new Et(this.clone()).solve());
|
|
2380
2384
|
a(this, "test", (e) => this.left.evaluate(e).isEqual(this.right.evaluate(e)));
|
|
2381
|
-
p(this,
|
|
2385
|
+
p(this, Lt, (e) => {
|
|
2382
2386
|
if (e.includes("geq"))
|
|
2383
2387
|
return e.includes("\\geq") ? "\\geq" : "geq";
|
|
2384
2388
|
if (e.includes("leq"))
|
|
@@ -2401,13 +2405,13 @@ const xe = class xe {
|
|
|
2401
2405
|
});
|
|
2402
2406
|
// -----------------------------------------------
|
|
2403
2407
|
// Equations solving algorithms
|
|
2404
|
-
p(this,
|
|
2405
|
-
p(this,
|
|
2406
|
-
if (h(this,
|
|
2408
|
+
p(this, et, (e) => e === void 0 ? "=" : e.includes("geq") || e.includes(">=") || e.includes("=>") ? ">=" : e.includes(">") ? ">" : e.includes("leq") || e.includes("<=") || e.includes("=<") ? "<=" : e.includes("<") ? "<" : "=");
|
|
2409
|
+
p(this, Dt, () => s(this, se) === "=" ? this : s(this, se).includes("<") ? (s(this, se).replace("<", ">"), this) : s(this, se).includes(">") ? (s(this, se).replace(">", "<"), this) : this);
|
|
2410
|
+
if (h(this, A, new q().zero()), h(this, k, new q().zero()), h(this, se, "="), e !== void 0 && t === void 0) {
|
|
2407
2411
|
if (e instanceof xe)
|
|
2408
2412
|
return e.clone();
|
|
2409
2413
|
typeof e == "string" && this.parse(e);
|
|
2410
|
-
} else e !== void 0 && t !== void 0 && (this.left = new
|
|
2414
|
+
} else e !== void 0 && t !== void 0 && (this.left = new q(e), this.right = new q(t));
|
|
2411
2415
|
return i !== void 0 && (this.sign = i), this;
|
|
2412
2416
|
}
|
|
2413
2417
|
/**
|
|
@@ -2420,11 +2424,11 @@ const xe = class xe {
|
|
|
2420
2424
|
*/
|
|
2421
2425
|
add(e) {
|
|
2422
2426
|
if (e instanceof xe)
|
|
2423
|
-
return s(this,
|
|
2427
|
+
return s(this, A).add(e.left), s(this, k).add(e.right), this;
|
|
2424
2428
|
if (typeof e == "string" && !xe.isEquationString(e))
|
|
2425
2429
|
return this.add(new xe(e));
|
|
2426
|
-
const t = new
|
|
2427
|
-
return s(this,
|
|
2430
|
+
const t = new q(e);
|
|
2431
|
+
return s(this, A).add(t), s(this, k).add(t), this;
|
|
2428
2432
|
}
|
|
2429
2433
|
/**
|
|
2430
2434
|
* Create an Equation using two polynoms.
|
|
@@ -2433,29 +2437,29 @@ const xe = class xe {
|
|
|
2433
2437
|
* @param asNumeric
|
|
2434
2438
|
*/
|
|
2435
2439
|
evaluate(e, t) {
|
|
2436
|
-
const i = s(this,
|
|
2440
|
+
const i = s(this, A).evaluate(e, t), n = s(this, k).evaluate(e, t);
|
|
2437
2441
|
return t ? i === n : i.isEqual(n);
|
|
2438
2442
|
}
|
|
2439
2443
|
isEqual(e) {
|
|
2440
2444
|
const t = new xe(e);
|
|
2441
|
-
return t.left.isEqual(s(this,
|
|
2445
|
+
return t.left.isEqual(s(this, A)) && t.right.isEqual(s(this, k));
|
|
2442
2446
|
}
|
|
2443
2447
|
pow(e) {
|
|
2444
|
-
return s(this,
|
|
2448
|
+
return s(this, A).pow(e), s(this, k).pow(e), this;
|
|
2445
2449
|
}
|
|
2446
2450
|
reduce() {
|
|
2447
|
-
return this.moveLeft(), s(this,
|
|
2451
|
+
return this.moveLeft(), s(this, A).reduce(), this.simplify(), s(this, A).monoms[0].coefficient.isNegative() && this.multiply(-1), this;
|
|
2448
2452
|
}
|
|
2449
2453
|
split() {
|
|
2450
|
-
return [s(this,
|
|
2454
|
+
return [s(this, A).clone(), s(this, k).clone()];
|
|
2451
2455
|
}
|
|
2452
2456
|
subtract(e) {
|
|
2453
2457
|
if (e instanceof xe)
|
|
2454
|
-
return s(this,
|
|
2458
|
+
return s(this, A).subtract(e.left), s(this, k).subtract(e.right), this;
|
|
2455
2459
|
if (typeof e == "string" && !xe.isEquationString(e))
|
|
2456
2460
|
return this.subtract(new xe(e));
|
|
2457
|
-
const t = new
|
|
2458
|
-
return s(this,
|
|
2461
|
+
const t = new q(e);
|
|
2462
|
+
return s(this, A).subtract(t), s(this, k).subtract(t), this;
|
|
2459
2463
|
}
|
|
2460
2464
|
static isEquationString(e) {
|
|
2461
2465
|
return e.includes("=") || e.includes("<") || e.includes(">") || e.includes("<=") || e.includes(">=");
|
|
@@ -2465,51 +2469,51 @@ const xe = class xe {
|
|
|
2465
2469
|
return t === !0 && n.sort((r, l) => r.value - l.value), n;
|
|
2466
2470
|
}
|
|
2467
2471
|
get display() {
|
|
2468
|
-
return `${s(this,
|
|
2472
|
+
return `${s(this, A).display}${this.signAsTex}${s(this, k).display}`;
|
|
2469
2473
|
}
|
|
2470
2474
|
// Getter and setter
|
|
2471
2475
|
get left() {
|
|
2472
|
-
return s(this,
|
|
2476
|
+
return s(this, A);
|
|
2473
2477
|
}
|
|
2474
2478
|
set left(e) {
|
|
2475
|
-
h(this,
|
|
2479
|
+
h(this, A, e);
|
|
2476
2480
|
}
|
|
2477
2481
|
get numberOfVars() {
|
|
2478
2482
|
return this.variables.length;
|
|
2479
2483
|
}
|
|
2480
2484
|
get right() {
|
|
2481
|
-
return s(this,
|
|
2485
|
+
return s(this, k);
|
|
2482
2486
|
}
|
|
2483
2487
|
set right(e) {
|
|
2484
|
-
h(this,
|
|
2488
|
+
h(this, k, e);
|
|
2485
2489
|
}
|
|
2486
2490
|
// ------------------------------------------
|
|
2487
2491
|
get sign() {
|
|
2488
2492
|
return s(this, se);
|
|
2489
2493
|
}
|
|
2490
2494
|
set sign(e) {
|
|
2491
|
-
h(this, se, s(this,
|
|
2495
|
+
h(this, se, s(this, et).call(this, e));
|
|
2492
2496
|
}
|
|
2493
2497
|
get signAsTex() {
|
|
2494
2498
|
return s(this, se) === ">=" ? "\\geq" : s(this, se) === "<=" ? "\\leq" : s(this, se);
|
|
2495
2499
|
}
|
|
2496
2500
|
get tex() {
|
|
2497
|
-
return `${s(this,
|
|
2501
|
+
return `${s(this, A).tex}${this.signAsTex}${s(this, k).tex}`;
|
|
2498
2502
|
}
|
|
2499
2503
|
get variables() {
|
|
2500
|
-
return [...new Set(s(this,
|
|
2504
|
+
return [...new Set(s(this, k).variables.concat(s(this, A).variables))];
|
|
2501
2505
|
}
|
|
2502
2506
|
};
|
|
2503
|
-
|
|
2507
|
+
A = new WeakMap(), k = new WeakMap(), se = new WeakMap(), Lt = new WeakMap(), et = new WeakMap(), Dt = new WeakMap();
|
|
2504
2508
|
let H = xe;
|
|
2505
|
-
var
|
|
2506
|
-
const
|
|
2509
|
+
var D, Ce, Vt, Zt;
|
|
2510
|
+
const We = class We {
|
|
2507
2511
|
constructor(...e) {
|
|
2508
|
-
p(this,
|
|
2512
|
+
p(this, D);
|
|
2509
2513
|
// Determine the letters in the linear system, usually ['x', 'y']
|
|
2510
2514
|
p(this, Ce);
|
|
2511
|
-
a(this, "parse", (...e) => (h(this,
|
|
2512
|
-
a(this, "clone", () => new
|
|
2515
|
+
a(this, "parse", (...e) => (h(this, D, e.map((t) => new H(t))), s(this, Vt).call(this), this));
|
|
2516
|
+
a(this, "clone", () => new We().parse(...s(this, D).map((e) => e.clone())));
|
|
2513
2517
|
a(this, "buildTex", (e, t) => {
|
|
2514
2518
|
let i, n, r = [];
|
|
2515
2519
|
const l = [];
|
|
@@ -2537,7 +2541,7 @@ const Xe = class Xe {
|
|
|
2537
2541
|
});
|
|
2538
2542
|
// ------------------------------------------
|
|
2539
2543
|
a(this, "reorder", () => {
|
|
2540
|
-
for (const e of s(this,
|
|
2544
|
+
for (const e of s(this, D))
|
|
2541
2545
|
e.reorder();
|
|
2542
2546
|
return this;
|
|
2543
2547
|
});
|
|
@@ -2558,10 +2562,10 @@ const Xe = class Xe {
|
|
|
2558
2562
|
}
|
|
2559
2563
|
return i.map((n) => n[n.length - 1]);
|
|
2560
2564
|
});
|
|
2561
|
-
p(this,
|
|
2562
|
-
p(this,
|
|
2565
|
+
p(this, Vt, () => (h(this, Ce, s(this, D).reduce((e, t) => [.../* @__PURE__ */ new Set([...e, ...t.variables])], [])), s(this, Ce).sort(), this));
|
|
2566
|
+
p(this, Zt, () => {
|
|
2563
2567
|
const e = [], t = [];
|
|
2564
|
-
for (const i of s(this,
|
|
2568
|
+
for (const i of s(this, D)) {
|
|
2565
2569
|
const n = [], r = i.clone().reorder();
|
|
2566
2570
|
for (const l of this.variables) {
|
|
2567
2571
|
const c = r.left.monomByLetter(l);
|
|
@@ -2571,47 +2575,47 @@ const Xe = class Xe {
|
|
|
2571
2575
|
}
|
|
2572
2576
|
return [e, t];
|
|
2573
2577
|
});
|
|
2574
|
-
return h(this,
|
|
2578
|
+
return h(this, D, []), h(this, Ce, []), e.length > 0 && this.parse(...e), this;
|
|
2575
2579
|
}
|
|
2576
2580
|
static fromMatrix(e, t = "xyz") {
|
|
2577
2581
|
const i = e[0].length;
|
|
2578
2582
|
if (e.some((r) => r.length !== i))
|
|
2579
2583
|
throw new Error("All rows must have the same number of columns");
|
|
2580
2584
|
const n = t.split("").splice(0, i - 1);
|
|
2581
|
-
return new
|
|
2585
|
+
return new We(
|
|
2582
2586
|
...e.map((r) => {
|
|
2583
|
-
const l = new
|
|
2587
|
+
const l = new q(n.join(""), ...r);
|
|
2584
2588
|
return new H(l, 0);
|
|
2585
2589
|
})
|
|
2586
2590
|
);
|
|
2587
2591
|
}
|
|
2588
2592
|
add(e, t) {
|
|
2589
|
-
if (e instanceof
|
|
2593
|
+
if (e instanceof We) {
|
|
2590
2594
|
const i = e.equations.length;
|
|
2591
|
-
if (i !== s(this,
|
|
2595
|
+
if (i !== s(this, D).length)
|
|
2592
2596
|
throw new Error("The number of equations must be the same");
|
|
2593
2597
|
for (let n = 0; n < i; n++)
|
|
2594
|
-
s(this,
|
|
2598
|
+
s(this, D)[n].add(e.equations[n]);
|
|
2595
2599
|
} else {
|
|
2596
|
-
if (t === void 0 || t < 0 || t >= s(this,
|
|
2600
|
+
if (t === void 0 || t < 0 || t >= s(this, D).length)
|
|
2597
2601
|
throw new Error("Index out of range");
|
|
2598
2602
|
const i = new H(e);
|
|
2599
|
-
s(this,
|
|
2603
|
+
s(this, D)[t].add(i);
|
|
2600
2604
|
}
|
|
2601
2605
|
return this;
|
|
2602
2606
|
}
|
|
2603
2607
|
degree(e) {
|
|
2604
|
-
return u.max(...s(this,
|
|
2608
|
+
return u.max(...s(this, D).map((t) => t.degree(e)));
|
|
2605
2609
|
}
|
|
2606
2610
|
get display() {
|
|
2607
2611
|
return this.tex + "as display";
|
|
2608
2612
|
}
|
|
2609
2613
|
// ------------------------------------------
|
|
2610
2614
|
get equations() {
|
|
2611
|
-
return s(this,
|
|
2615
|
+
return s(this, D);
|
|
2612
2616
|
}
|
|
2613
2617
|
set equations(e) {
|
|
2614
|
-
h(this,
|
|
2618
|
+
h(this, D, e);
|
|
2615
2619
|
}
|
|
2616
2620
|
evaluate(e, t) {
|
|
2617
2621
|
throw new Error("Method not implemented.");
|
|
@@ -2623,22 +2627,22 @@ const Xe = class Xe {
|
|
|
2623
2627
|
return this.equations.every((t, i) => t.isEqual(e.equations[i]));
|
|
2624
2628
|
}
|
|
2625
2629
|
get isSolvable() {
|
|
2626
|
-
return this.variables.length === s(this,
|
|
2630
|
+
return this.variables.length === s(this, D).length;
|
|
2627
2631
|
}
|
|
2628
2632
|
get matrix() {
|
|
2629
|
-
return s(this,
|
|
2633
|
+
return s(this, Zt).call(this);
|
|
2630
2634
|
}
|
|
2631
2635
|
multiply(e, t) {
|
|
2632
2636
|
if (Array.isArray(e)) {
|
|
2633
|
-
if (e.length !== s(this,
|
|
2637
|
+
if (e.length !== s(this, D).length)
|
|
2634
2638
|
throw new Error("The number of values must be the same as the number of equations");
|
|
2635
2639
|
for (let i = 0; i < e.length; i++)
|
|
2636
|
-
s(this,
|
|
2640
|
+
s(this, D)[i].multiply(e[i]);
|
|
2637
2641
|
return this;
|
|
2638
2642
|
}
|
|
2639
|
-
if (t === void 0 || t < 0 || t >= s(this,
|
|
2643
|
+
if (t === void 0 || t < 0 || t >= s(this, D).length)
|
|
2640
2644
|
throw new Error("Index out of range");
|
|
2641
|
-
return s(this,
|
|
2645
|
+
return s(this, D)[t].multiply(e), this;
|
|
2642
2646
|
}
|
|
2643
2647
|
reduce() {
|
|
2644
2648
|
throw new Error("Method not implemented.");
|
|
@@ -2647,17 +2651,17 @@ const Xe = class Xe {
|
|
|
2647
2651
|
return [];
|
|
2648
2652
|
}
|
|
2649
2653
|
subtract(e, t) {
|
|
2650
|
-
if (e instanceof
|
|
2654
|
+
if (e instanceof We) {
|
|
2651
2655
|
const i = e.equations.length;
|
|
2652
|
-
if (i !== s(this,
|
|
2656
|
+
if (i !== s(this, D).length)
|
|
2653
2657
|
throw new Error("The number of equations must be the same");
|
|
2654
2658
|
for (let n = 0; n < i; n++)
|
|
2655
|
-
s(this,
|
|
2659
|
+
s(this, D)[n].subtract(e.equations[n]);
|
|
2656
2660
|
} else {
|
|
2657
|
-
if (t === void 0 || t < 0 || t >= s(this,
|
|
2661
|
+
if (t === void 0 || t < 0 || t >= s(this, D).length)
|
|
2658
2662
|
throw new Error("Index out of range");
|
|
2659
2663
|
const i = new H(e);
|
|
2660
|
-
s(this,
|
|
2664
|
+
s(this, D)[t].subtract(i);
|
|
2661
2665
|
}
|
|
2662
2666
|
return this;
|
|
2663
2667
|
}
|
|
@@ -2673,14 +2677,14 @@ const Xe = class Xe {
|
|
|
2673
2677
|
t.sort(), h(this, Ce, t);
|
|
2674
2678
|
}
|
|
2675
2679
|
};
|
|
2676
|
-
|
|
2677
|
-
let
|
|
2678
|
-
function
|
|
2680
|
+
D = new WeakMap(), Ce = new WeakMap(), Vt = new WeakMap(), Zt = new WeakMap();
|
|
2681
|
+
let ni = We;
|
|
2682
|
+
function _i(o, e) {
|
|
2679
2683
|
return o.dimension === e.dimension && o.array.every(
|
|
2680
2684
|
(t, i) => e.array[i].isEqual(t)
|
|
2681
2685
|
);
|
|
2682
2686
|
}
|
|
2683
|
-
function
|
|
2687
|
+
function es(o, e) {
|
|
2684
2688
|
if (o.dimension !== e.dimension)
|
|
2685
2689
|
return !1;
|
|
2686
2690
|
const t = e.array[0].value / o.array[0].value;
|
|
@@ -2688,13 +2692,13 @@ function Ji(o, e) {
|
|
|
2688
2692
|
(i, n) => e.array[n].value === i.value * t
|
|
2689
2693
|
);
|
|
2690
2694
|
}
|
|
2691
|
-
function
|
|
2695
|
+
function ts(o, e) {
|
|
2692
2696
|
return o.dimension !== e.dimension ? new u().invalid() : o.array.reduce(
|
|
2693
2697
|
(t, i, n) => t.add(i.clone().multiply(e.array[n])),
|
|
2694
2698
|
new u(0)
|
|
2695
2699
|
);
|
|
2696
2700
|
}
|
|
2697
|
-
function
|
|
2701
|
+
function is(...o) {
|
|
2698
2702
|
return o.some((e) => e.dimension !== o[0].dimension) ? new u().invalid() : o[0].dimension === 2 && o.length !== 2 ? new u().invalid() : o[0].dimension === 3 && o.length !== 3 ? new u().invalid() : o[0].dimension === 2 ? o[0].array[0].clone().multiply(o[1].array[1]).subtract(o[0].array[1].clone().multiply(o[1].array[0])) : o[0].array[0].clone().multiply(
|
|
2699
2703
|
o[1].array[1].clone().multiply(o[2].array[2]).subtract(o[1].array[2].clone().multiply(o[2].array[1]))
|
|
2700
2704
|
).subtract(
|
|
@@ -2717,15 +2721,15 @@ const Be = class Be {
|
|
|
2717
2721
|
const e = this.norm;
|
|
2718
2722
|
return e === 0 ? this : this.divideByScalar(e);
|
|
2719
2723
|
});
|
|
2720
|
-
a(this, "dot", (e) =>
|
|
2724
|
+
a(this, "dot", (e) => ts(this, e));
|
|
2721
2725
|
a(this, "normal", () => {
|
|
2722
2726
|
if (this.dimension >= 3)
|
|
2723
2727
|
throw new Error("Normal vector can only be determined in 2D");
|
|
2724
2728
|
const e = this.x.clone().opposite(), t = this.y.clone();
|
|
2725
2729
|
return s(this, F)[0] = t, s(this, F)[1] = e, this;
|
|
2726
2730
|
});
|
|
2727
|
-
a(this, "isEqual", (e) =>
|
|
2728
|
-
a(this, "isColinearTo", (e) =>
|
|
2731
|
+
a(this, "isEqual", (e) => _i(this, e));
|
|
2732
|
+
a(this, "isColinearTo", (e) => es(this, e));
|
|
2729
2733
|
a(this, "isNormalTo", (e) => this.dot(e).isZero());
|
|
2730
2734
|
a(this, "multiplyByScalar", (e) => {
|
|
2731
2735
|
const t = new u(e);
|
|
@@ -2890,7 +2894,7 @@ const Be = class Be {
|
|
|
2890
2894
|
};
|
|
2891
2895
|
F = new WeakMap(), Le = new WeakMap();
|
|
2892
2896
|
let x = Be;
|
|
2893
|
-
function
|
|
2897
|
+
function Ai(o = 0.5) {
|
|
2894
2898
|
return Math.random() < o;
|
|
2895
2899
|
}
|
|
2896
2900
|
function fe(o, e, t) {
|
|
@@ -2908,19 +2912,19 @@ function fe(o, e, t) {
|
|
|
2908
2912
|
return i;
|
|
2909
2913
|
}
|
|
2910
2914
|
function Y(o, e) {
|
|
2911
|
-
return e === !1 ?
|
|
2915
|
+
return e === !1 ? Ai() ? fe(1, o) : -fe(1, o) : fe(-o, o);
|
|
2912
2916
|
}
|
|
2913
|
-
function
|
|
2917
|
+
function ss(o) {
|
|
2914
2918
|
let e = G.primes();
|
|
2915
|
-
return o !== void 0 && (e = e.filter((t) => t < o)),
|
|
2919
|
+
return o !== void 0 && (e = e.filter((t) => t < o)), fi(e);
|
|
2916
2920
|
}
|
|
2917
|
-
function
|
|
2918
|
-
return e === void 0 && (e = 1), o.length <= 0 ? Object.values(o) :
|
|
2921
|
+
function ns(o, e) {
|
|
2922
|
+
return e === void 0 && (e = 1), o.length <= 0 ? Object.values(o) : Oi(o).slice(0, e);
|
|
2919
2923
|
}
|
|
2920
|
-
function
|
|
2924
|
+
function fi(o) {
|
|
2921
2925
|
return o.length === 0 ? null : o[fe(0, o.length - 1)];
|
|
2922
2926
|
}
|
|
2923
|
-
function
|
|
2927
|
+
function Oi(o) {
|
|
2924
2928
|
const e = Object.values(o);
|
|
2925
2929
|
for (let t = e.length - 1; t > 0; t--) {
|
|
2926
2930
|
const i = Math.floor(Math.random() * (t + 1)), n = e[t];
|
|
@@ -2928,7 +2932,7 @@ function Ti(o) {
|
|
|
2928
2932
|
}
|
|
2929
2933
|
return e;
|
|
2930
2934
|
}
|
|
2931
|
-
class
|
|
2935
|
+
class B extends x {
|
|
2932
2936
|
constructor(...e) {
|
|
2933
2937
|
super(), e.length > 0 && this.parse(...e);
|
|
2934
2938
|
}
|
|
@@ -2950,11 +2954,11 @@ class V extends x {
|
|
|
2950
2954
|
return this;
|
|
2951
2955
|
}
|
|
2952
2956
|
clone() {
|
|
2953
|
-
const e = new
|
|
2957
|
+
const e = new B();
|
|
2954
2958
|
return e.array = this.copy(), e.asPoint = !0, e;
|
|
2955
2959
|
}
|
|
2956
2960
|
}
|
|
2957
|
-
var
|
|
2961
|
+
var qi = /* @__PURE__ */ ((o) => (o.None = "none", o.Parallel = "parallel", o.Perpendicular = "perpendicular", o.Tangent = "tangent", o))(qi || {}), $e, S, z, U, ne, Q, Ie, ve;
|
|
2958
2962
|
const Ve = class Ve {
|
|
2959
2963
|
/**
|
|
2960
2964
|
* Value can be a mix of:
|
|
@@ -2964,8 +2968,8 @@ const Ve = class Ve {
|
|
|
2964
2968
|
constructor(...e) {
|
|
2965
2969
|
p(this, $e);
|
|
2966
2970
|
// ax + by + c = 0
|
|
2967
|
-
p(this, B);
|
|
2968
2971
|
p(this, S);
|
|
2972
|
+
p(this, z);
|
|
2969
2973
|
p(this, U);
|
|
2970
2974
|
p(this, ne);
|
|
2971
2975
|
p(this, Q);
|
|
@@ -3051,7 +3055,7 @@ const Ve = class Ve {
|
|
|
3051
3055
|
e.left.monomByDegree(0).coefficient
|
|
3052
3056
|
);
|
|
3053
3057
|
});
|
|
3054
|
-
a(this, "fromCoefficient", (e, t, i) => (h(this,
|
|
3058
|
+
a(this, "fromCoefficient", (e, t, i) => (h(this, S, new u(e)), h(this, z, new u(t)), h(this, U, new u(i)), h(this, Q, new x(s(this, z).clone(), s(this, S).clone().opposite())), h(this, ne, new x(new u().zero(), s(this, U).clone())), h(this, Ie, s(this, Q).clone().normal()), this));
|
|
3055
3059
|
a(this, "fromPointAndDirection", (e, t) => (this.fromCoefficient(
|
|
3056
3060
|
t.y,
|
|
3057
3061
|
t.x.clone().opposite(),
|
|
@@ -3063,30 +3067,30 @@ const Ve = class Ve {
|
|
|
3063
3067
|
e.x.clone().multiply(t.x).add(e.y.clone().multiply(t.y)).opposite()
|
|
3064
3068
|
));
|
|
3065
3069
|
a(this, "fromPointAndLine", (e, t, i) => (i === void 0 && (i = "parallel"), i === "parallel" ? this.fromPointAndNormal(e, t.normal) : i === "perpendicular" ? this.fromPointAndNormal(e, t.director) : this));
|
|
3066
|
-
a(this, "clone", () => (h(this,
|
|
3070
|
+
a(this, "clone", () => (h(this, S, s(this, S).clone()), h(this, z, s(this, z).clone()), h(this, U, s(this, U).clone()), h(this, Q, s(this, Q).clone()), h(this, ne, s(this, ne).clone()), h(this, Ie, s(this, Ie).clone()), this));
|
|
3067
3071
|
// ------------------------------------------
|
|
3068
3072
|
// Mathematical operations
|
|
3069
3073
|
// ------------------------------------------
|
|
3070
|
-
a(this, "isOnLine", (e) => s(this,
|
|
3071
|
-
s(this,
|
|
3074
|
+
a(this, "isOnLine", (e) => s(this, S).clone().multiply(e.x).add(
|
|
3075
|
+
s(this, z).clone().multiply(e.y)
|
|
3072
3076
|
).add(s(this, U)).isZero());
|
|
3073
3077
|
a(this, "isParallelTo", (e) => this.slope.isEqual(e.slope) && this.height.isNotEqual(e.height));
|
|
3074
3078
|
a(this, "isSameAs", (e) => this.slope.isEqual(e.slope) && this.height.isEqual(e.height));
|
|
3075
3079
|
a(this, "isPerpendicularTo", (e) => this.d.isNormalTo(e.d));
|
|
3076
3080
|
a(this, "isVertical", () => this.slope.isInfinity());
|
|
3077
3081
|
a(this, "simplify", () => {
|
|
3078
|
-
const e = G.lcm(s(this,
|
|
3082
|
+
const e = G.lcm(s(this, S).denominator, s(this, z).denominator, s(this, U).denominator), t = G.gcd(s(this, S).numerator, s(this, z).numerator, s(this, U).numerator);
|
|
3079
3083
|
return this.fromCoefficient(
|
|
3080
|
-
s(this, B).clone().multiply(e).divide(t),
|
|
3081
3084
|
s(this, S).clone().multiply(e).divide(t),
|
|
3085
|
+
s(this, z).clone().multiply(e).divide(t),
|
|
3082
3086
|
s(this, U).clone().multiply(e).divide(t)
|
|
3083
3087
|
), this;
|
|
3084
3088
|
});
|
|
3085
3089
|
a(this, "simplifyDirection", () => (s(this, Q).simplify(), this));
|
|
3086
3090
|
a(this, "intersection", (e) => {
|
|
3087
|
-
const t = new
|
|
3091
|
+
const t = new B();
|
|
3088
3092
|
let i = !1, n = !1;
|
|
3089
|
-
return s(this,
|
|
3093
|
+
return s(this, z).isZero() || e.b.isZero(), this.isParallelTo(e) ? (t.x = new u().invalid(), t.y = new u().invalid(), i = !0) : this.isSameAs(e) ? (t.x = new u().invalid(), t.y = new u().invalid(), n = !0) : (t.x = s(this, z).clone().multiply(e.c).subtract(s(this, U).clone().multiply(e.b)).divide(s(this, S).clone().multiply(e.b).subtract(s(this, z).clone().multiply(e.a))), t.y = s(this, S).clone().multiply(e.c).subtract(s(this, U).clone().multiply(e.a)).divide(s(this, z).clone().multiply(e.a).subtract(s(this, S).clone().multiply(e.b)))), {
|
|
3090
3094
|
point: t,
|
|
3091
3095
|
hasIntersection: !(i || n),
|
|
3092
3096
|
isParallel: i,
|
|
@@ -3101,21 +3105,21 @@ const Ve = class Ve {
|
|
|
3101
3105
|
const t = this.getEquation().isolate("x"), i = new u(e);
|
|
3102
3106
|
return t instanceof H ? t.right.evaluate({ y: i }) : new u().invalid();
|
|
3103
3107
|
});
|
|
3104
|
-
return h(this,
|
|
3108
|
+
return h(this, S, new u().zero()), h(this, z, new u().zero()), h(this, U, new u().zero()), h(this, ne, new x()), h(this, Q, new x()), h(this, Ie, new x()), h(this, $e, !0), e.length > 0 && this.parse(...e), this;
|
|
3105
3109
|
}
|
|
3106
3110
|
get a() {
|
|
3107
|
-
return s(this,
|
|
3111
|
+
return s(this, S);
|
|
3108
3112
|
}
|
|
3109
3113
|
// ------------------------------------------
|
|
3110
3114
|
// Getter and setter
|
|
3111
3115
|
set a(e) {
|
|
3112
|
-
h(this,
|
|
3116
|
+
h(this, S, e);
|
|
3113
3117
|
}
|
|
3114
3118
|
get b() {
|
|
3115
|
-
return s(this,
|
|
3119
|
+
return s(this, z);
|
|
3116
3120
|
}
|
|
3117
3121
|
set b(e) {
|
|
3118
|
-
h(this,
|
|
3122
|
+
h(this, z, e);
|
|
3119
3123
|
}
|
|
3120
3124
|
get c() {
|
|
3121
3125
|
return s(this, U);
|
|
@@ -3140,7 +3144,7 @@ const Ve = class Ve {
|
|
|
3140
3144
|
}
|
|
3141
3145
|
// ------------------------------------------
|
|
3142
3146
|
getEquation() {
|
|
3143
|
-
const e = new H(new
|
|
3147
|
+
const e = new H(new q().parse("xy", s(this, S), s(this, z), s(this, U)), new q("0"));
|
|
3144
3148
|
return s(this, $e) ? e.simplify() : e;
|
|
3145
3149
|
}
|
|
3146
3150
|
// get system(): { x: Equation, y: Equation } {
|
|
@@ -3177,18 +3181,18 @@ const Ve = class Ve {
|
|
|
3177
3181
|
case "equation":
|
|
3178
3182
|
return this.getEquation().reorder().tex;
|
|
3179
3183
|
case "mxh":
|
|
3180
|
-
return this.slope.isInfinity() ? "x=" + this.OA.x.tex : "y=" + new
|
|
3184
|
+
return this.slope.isInfinity() ? "x=" + this.OA.x.tex : "y=" + new q().parse("x", this.slope, this.height).tex;
|
|
3181
3185
|
case "parametric":
|
|
3182
3186
|
case "system": {
|
|
3183
3187
|
const t = s(this, Q).clone();
|
|
3184
3188
|
return s(this, $e) && t.simplify(), e === "parametric" ? `${x.asTex("x", "y")} = ${x.asTex(s(this, ne).x.tex, s(this, ne).y.tex)} + k\\cdot ${x.asTex(t.x.tex, t.y.tex)}` : `\\left\\{\\begin{aligned}
|
|
3185
|
-
x &= ${new
|
|
3186
|
-
y &= ${new
|
|
3189
|
+
x &= ${new q(s(this, ne).x).add(new M(s(this, Q).x).multiply(new M("k"))).reorder("k", !0).tex}\\\\
|
|
3190
|
+
y &= ${new q(s(this, ne).y).add(new M(s(this, Q).y).multiply(new M("k"))).reorder("k", !0).tex}
|
|
3187
3191
|
\\end{aligned}\\right.`;
|
|
3188
3192
|
}
|
|
3189
3193
|
default: {
|
|
3190
3194
|
const t = this.getEquation();
|
|
3191
|
-
return s(this,
|
|
3195
|
+
return s(this, S).isNegative() && t.multiply(-1), t.tex;
|
|
3192
3196
|
}
|
|
3193
3197
|
}
|
|
3194
3198
|
}
|
|
@@ -3204,34 +3208,34 @@ const Ve = class Ve {
|
|
|
3204
3208
|
case "equation":
|
|
3205
3209
|
return this.getEquation().reorder().display;
|
|
3206
3210
|
case "mxh":
|
|
3207
|
-
return this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new
|
|
3211
|
+
return this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new q().parse("x", this.slope, this.height).display;
|
|
3208
3212
|
case "parametric": {
|
|
3209
3213
|
const t = s(this, Q).clone();
|
|
3210
3214
|
return s(this, $e) && t.simplify(), `((x,y))=((${s(this, ne).x.display},${s(this, ne).y.display}))+k((${t.x.display},${t.y.display}))`;
|
|
3211
3215
|
}
|
|
3212
3216
|
default: {
|
|
3213
3217
|
const t = this.getEquation();
|
|
3214
|
-
return s(this,
|
|
3218
|
+
return s(this, S).isNegative() && t.multiply(-1), t.display;
|
|
3215
3219
|
}
|
|
3216
3220
|
}
|
|
3217
3221
|
}
|
|
3218
3222
|
get normal() {
|
|
3219
|
-
return new x(s(this,
|
|
3223
|
+
return new x(s(this, S), s(this, z));
|
|
3220
3224
|
}
|
|
3221
3225
|
get director() {
|
|
3222
3226
|
return s(this, Q).clone();
|
|
3223
3227
|
}
|
|
3224
3228
|
get slope() {
|
|
3225
|
-
return s(this,
|
|
3229
|
+
return s(this, S).clone().opposite().divide(s(this, z));
|
|
3226
3230
|
}
|
|
3227
3231
|
get height() {
|
|
3228
|
-
return s(this, U).clone().opposite().divide(s(this,
|
|
3232
|
+
return s(this, U).clone().opposite().divide(s(this, z));
|
|
3229
3233
|
}
|
|
3230
3234
|
fromPoints(e, t) {
|
|
3231
3235
|
return this.fromPointAndDirection(e, new x(e, t));
|
|
3232
3236
|
}
|
|
3233
3237
|
distanceTo(e) {
|
|
3234
|
-
const t = e.x.clone().multiply(s(this,
|
|
3238
|
+
const t = e.x.clone().multiply(s(this, S)).add(e.y.clone().multiply(s(this, z))).add(s(this, U)).abs(), i = this.normal.normSquare;
|
|
3235
3239
|
if (i.isZero())
|
|
3236
3240
|
return {
|
|
3237
3241
|
value: NaN,
|
|
@@ -3261,19 +3265,19 @@ const Ve = class Ve {
|
|
|
3261
3265
|
canonicalAsFloatCoefficient(e) {
|
|
3262
3266
|
e === void 0 && (e = 2);
|
|
3263
3267
|
let t = "";
|
|
3264
|
-
return s(this,
|
|
3268
|
+
return s(this, S).isZero() || (s(this, S).isOne() ? t = "x" : s(this, S).clone().opposite().isOne() ? t = "-x" : t = s(this, S).value.toFixed(e) + "x"), s(this, z).isZero() || (s(this, z).isPositive() && (t += "+"), t += s(this, z).value.toFixed(e) + "y"), s(this, U).isZero() || (s(this, U).isPositive() && (t += "+"), t += s(this, U).value.toFixed(e)), t + "=0";
|
|
3265
3269
|
}
|
|
3266
3270
|
};
|
|
3267
|
-
$e = new WeakMap(),
|
|
3271
|
+
$e = new WeakMap(), S = new WeakMap(), z = new WeakMap(), U = new WeakMap(), ne = new WeakMap(), Q = new WeakMap(), Ie = new WeakMap(), ve = new WeakMap(), // A line is defined as the canonical form
|
|
3268
3272
|
a(Ve, "PERPENDICULAR", "perpendicular"), a(Ve, "PARALLEL", "parallel");
|
|
3269
|
-
let
|
|
3270
|
-
var re, j,
|
|
3271
|
-
const
|
|
3273
|
+
let R = Ve;
|
|
3274
|
+
var re, j, Ae, Ft, jt, Ut, oe, ki, xt, Mi, Ci, $i, ri;
|
|
3275
|
+
const Gt = class Gt {
|
|
3272
3276
|
constructor(...e) {
|
|
3273
3277
|
p(this, oe);
|
|
3274
3278
|
p(this, re);
|
|
3275
3279
|
p(this, j);
|
|
3276
|
-
p(this,
|
|
3280
|
+
p(this, Ae);
|
|
3277
3281
|
/**
|
|
3278
3282
|
* Get the relative position between circle and line. It corresponds to the number of intersection.
|
|
3279
3283
|
* @param {Line} L
|
|
@@ -3287,56 +3291,56 @@ const Ut = class Ut {
|
|
|
3287
3291
|
});
|
|
3288
3292
|
a(this, "lineIntersection", (e) => {
|
|
3289
3293
|
const t = [];
|
|
3290
|
-
if (s(this,
|
|
3294
|
+
if (s(this, Ae) === void 0)
|
|
3291
3295
|
return [];
|
|
3292
|
-
const i = s(this,
|
|
3296
|
+
const i = s(this, Ae).clone(), n = e.getEquation().clone().isolate("x"), r = e.getEquation().clone().isolate("y");
|
|
3293
3297
|
return n instanceof H && r instanceof H && (i.replaceBy("y", r.right).simplify(), i.solve()), t;
|
|
3294
3298
|
});
|
|
3295
|
-
a(this, "tangents", (e) => e instanceof u ? s(this,
|
|
3299
|
+
a(this, "tangents", (e) => e instanceof u ? s(this, Ut).call(this, e) : this.isPointOnCircle(e) ? s(this, Ft).call(this, e) : s(this, re) !== void 0 && s(this, re).distanceTo(e).value > this.radius.value ? s(this, jt).call(this, e) : (console.log("No tangents as the point is inside !"), []));
|
|
3296
3300
|
a(this, "isPointOnCircle", (e) => {
|
|
3297
3301
|
var t;
|
|
3298
|
-
return ((t = s(this,
|
|
3302
|
+
return ((t = s(this, Ae)) == null ? void 0 : t.test({ x: e.x, y: e.y })) ?? !1;
|
|
3299
3303
|
});
|
|
3300
3304
|
a(this, "getPointsOnCircle", (e) => {
|
|
3301
3305
|
const t = G.pythagoreanTripletsWithTarget(this.squareRadius.value, !0), i = [];
|
|
3302
3306
|
return t.forEach((n) => {
|
|
3303
3307
|
for (const r of [[1, 1], [-1, 1], [-1, -1], [1, -1]])
|
|
3304
3308
|
i.push(
|
|
3305
|
-
new
|
|
3309
|
+
new B(
|
|
3306
3310
|
this.center.x.clone().add(r[0] * n[0]),
|
|
3307
3311
|
this.center.y.clone().add(r[1] * n[1])
|
|
3308
3312
|
)
|
|
3309
3313
|
);
|
|
3310
3314
|
}), i;
|
|
3311
3315
|
});
|
|
3312
|
-
p(this,
|
|
3316
|
+
p(this, Ft, (e) => {
|
|
3313
3317
|
const t = new x(this.center, e);
|
|
3314
|
-
return [new
|
|
3318
|
+
return [new R(e, t, qi.Perpendicular)];
|
|
3315
3319
|
});
|
|
3316
|
-
p(this,
|
|
3317
|
-
const t = this.center.x.clone().subtract(e.x), i = this.center.y.clone().subtract(e.y), n = new
|
|
3320
|
+
p(this, jt, (e) => {
|
|
3321
|
+
const t = this.center.x.clone().subtract(e.x), i = this.center.y.clone().subtract(e.y), n = new q("x"), r = new q("x^2+1");
|
|
3318
3322
|
return n.multiply(t).subtract(i).pow(2), r.multiply(this.squareRadius), new H(n, r).solve().map((d) => {
|
|
3319
3323
|
let f;
|
|
3320
3324
|
const g = new H("y", "x");
|
|
3321
|
-
return d.exact instanceof u ? (f = e.x.clone().opposite().multiply(d.exact).add(e.y), g.right.multiply(d.exact).add(f)) : (f = e.x.clone().opposite().multiply(d.value).add(e.y), g.right.multiply(d.value).add(f)), new
|
|
3325
|
+
return d.exact instanceof u ? (f = e.x.clone().opposite().multiply(d.exact).add(e.y), g.right.multiply(d.exact).add(f)) : (f = e.x.clone().opposite().multiply(d.value).add(e.y), g.right.multiply(d.value).add(f)), new R(g);
|
|
3322
3326
|
});
|
|
3323
3327
|
});
|
|
3324
|
-
p(this,
|
|
3328
|
+
p(this, Ut, (e) => {
|
|
3325
3329
|
const t = e.numerator, i = -e.denominator, n = this.center.x.clone(), r = this.center.y.clone(), l = this.squareRadius.clone().multiply(e.numerator ** 2 + e.denominator ** 2), c = n.clone().multiply(t).opposite().subtract(r.clone().multiply(i)).add(l.clone().sqrt()), d = n.clone().multiply(t).opposite().subtract(r.clone().multiply(i)).subtract(l.clone().sqrt());
|
|
3326
|
-
return [new
|
|
3330
|
+
return [new R(t, i, c), new R(t, i, d)];
|
|
3327
3331
|
});
|
|
3328
3332
|
e.length > 0 && this.parse(...e);
|
|
3329
3333
|
}
|
|
3330
3334
|
get center() {
|
|
3331
|
-
return s(this, re) ?? new
|
|
3335
|
+
return s(this, re) ?? new B();
|
|
3332
3336
|
}
|
|
3333
3337
|
get squareRadius() {
|
|
3334
3338
|
return s(this, j) ?? new u(0);
|
|
3335
3339
|
}
|
|
3336
3340
|
get cartesian() {
|
|
3337
|
-
if (s(this,
|
|
3341
|
+
if (s(this, Ae) === void 0)
|
|
3338
3342
|
throw new Error("Cartesian equation not defined");
|
|
3339
|
-
return s(this,
|
|
3343
|
+
return s(this, Ae);
|
|
3340
3344
|
}
|
|
3341
3345
|
get radius() {
|
|
3342
3346
|
return s(this, j) === void 0 ? { tex: "", display: "", value: 0 } : s(this, j).isSquare() ? {
|
|
@@ -3361,17 +3365,17 @@ const Ut = class Ut {
|
|
|
3361
3365
|
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}`;
|
|
3362
3366
|
}
|
|
3363
3367
|
clone() {
|
|
3364
|
-
return new
|
|
3368
|
+
return new Gt(
|
|
3365
3369
|
this.center.clone(),
|
|
3366
3370
|
this.squareRadius.clone(),
|
|
3367
3371
|
!0
|
|
3368
3372
|
);
|
|
3369
3373
|
}
|
|
3370
3374
|
setRadius(e, t) {
|
|
3371
|
-
return t ? h(this, j, new u(e)) : h(this, j, new u(e).pow(2)),
|
|
3375
|
+
return t ? h(this, j, new u(e)) : h(this, j, new u(e).pow(2)), O(this, oe, xt).call(this), this;
|
|
3372
3376
|
}
|
|
3373
3377
|
parse(...e) {
|
|
3374
|
-
return
|
|
3378
|
+
return O(this, oe, ki).call(this), typeof e[0] == "string" ? O(this, oe, ri).call(this, new H(e[0])) : e[0] instanceof H ? O(this, oe, ri).call(this, e[0]) : e[0] instanceof Gt ? O(this, oe, Mi).call(this, e[0]) : e[0] instanceof B && e.length > 1 && (e[1] instanceof B ? e[2] instanceof B || O(this, oe, $i).call(this, e[0], e[1]) : (e[1] instanceof u || typeof e[1] == "number") && O(this, oe, Ci).call(this, e[0], e[1], typeof e[2] == "boolean" ? e[2] : !1)), O(this, oe, xt).call(this), this;
|
|
3375
3379
|
}
|
|
3376
3380
|
// private _parseThroughtThreePoints(A: Point, B: Point, C: Point): this {
|
|
3377
3381
|
// const T = new Triangle(A, B, C), mAB = T.remarquables.mediators.AB.clone(),
|
|
@@ -3380,37 +3384,45 @@ const Ut = class Ut {
|
|
|
3380
3384
|
// return this
|
|
3381
3385
|
// }
|
|
3382
3386
|
};
|
|
3383
|
-
re = new WeakMap(), j = new WeakMap(),
|
|
3384
|
-
return h(this, re, void 0), h(this, j, void 0), h(this,
|
|
3385
|
-
},
|
|
3386
|
-
h(this,
|
|
3387
|
-
new
|
|
3388
|
-
new
|
|
3387
|
+
re = new WeakMap(), j = new WeakMap(), Ae = new WeakMap(), Ft = new WeakMap(), jt = new WeakMap(), Ut = new WeakMap(), oe = new WeakSet(), ki = function() {
|
|
3388
|
+
return h(this, re, void 0), h(this, j, void 0), h(this, Ae, void 0), this;
|
|
3389
|
+
}, xt = function() {
|
|
3390
|
+
h(this, Ae, new H(
|
|
3391
|
+
new q(`(x-(${this.center.x.display}))^2+(y-(${this.center.y.display}))^2`),
|
|
3392
|
+
new q(this.squareRadius.display)
|
|
3389
3393
|
).moveLeft());
|
|
3390
|
-
},
|
|
3391
|
-
return h(this, re, e.center.clone()), h(this, j, e.squareRadius.clone()),
|
|
3392
|
-
},
|
|
3394
|
+
}, Mi = function(e) {
|
|
3395
|
+
return h(this, re, e.center.clone()), h(this, j, e.squareRadius.clone()), O(this, oe, xt).call(this), this;
|
|
3396
|
+
}, Ci = function(e, t, i) {
|
|
3393
3397
|
return h(this, re, e.clone()), i ? h(this, j, new u(t)) : h(this, j, new u(t).pow(2)), this;
|
|
3394
|
-
},
|
|
3398
|
+
}, $i = function(e, t) {
|
|
3395
3399
|
return h(this, re, e.clone()), h(this, j, new x(s(this, re), t).normSquare), this;
|
|
3396
|
-
},
|
|
3400
|
+
}, ri = function(e) {
|
|
3397
3401
|
if (e.moveLeft(), e.degree("x").value === 2 && e.degree("y").value === 2) {
|
|
3398
3402
|
const t = e.left.monomByDegree(2, "x"), i = e.left.monomByDegree(2, "y");
|
|
3399
3403
|
let n, r, l;
|
|
3400
|
-
t.coefficient.isEqual(i.coefficient) ? (e.divide(t.coefficient), n = e.left.monomByDegree(1, "x"), r = e.left.monomByDegree(1, "y"), l = e.left.monomByDegree(0), h(this, re, new
|
|
3404
|
+
t.coefficient.isEqual(i.coefficient) ? (e.divide(t.coefficient), n = e.left.monomByDegree(1, "x"), r = e.left.monomByDegree(1, "y"), l = e.left.monomByDegree(0), h(this, re, new B(n.coefficient.clone().divide(2).opposite(), r.coefficient.clone().divide(2).opposite())), h(this, j, l.coefficient.clone().opposite().add(s(this, re).x.clone().pow(2)).add(s(this, re).y.clone().pow(2)))) : (h(this, re, void 0), h(this, j, void 0));
|
|
3401
3405
|
}
|
|
3402
3406
|
return this;
|
|
3403
3407
|
};
|
|
3404
|
-
let
|
|
3405
|
-
var X, K, J,
|
|
3406
|
-
const
|
|
3408
|
+
let Nt = Gt;
|
|
3409
|
+
var X, K, J, tt, Oe, mt, Wt, gt, Pe, Ht, it;
|
|
3410
|
+
const Xt = class Xt {
|
|
3407
3411
|
constructor(...e) {
|
|
3408
|
-
p(this, X);
|
|
3409
|
-
p(this, K);
|
|
3410
|
-
p(this, J);
|
|
3411
|
-
p(this,
|
|
3412
|
-
|
|
3413
|
-
|
|
3412
|
+
p(this, X, new B());
|
|
3413
|
+
p(this, K, new B());
|
|
3414
|
+
p(this, J, new B());
|
|
3415
|
+
p(this, tt, {
|
|
3416
|
+
AB: new R(),
|
|
3417
|
+
AC: new R(),
|
|
3418
|
+
BC: new R()
|
|
3419
|
+
});
|
|
3420
|
+
p(this, Oe, {
|
|
3421
|
+
AB: new B(),
|
|
3422
|
+
AC: new B(),
|
|
3423
|
+
BC: new B()
|
|
3424
|
+
});
|
|
3425
|
+
p(this, mt, null);
|
|
3414
3426
|
// ------------------------------------------
|
|
3415
3427
|
// Creation / parsing functions
|
|
3416
3428
|
// ------------------------------------------
|
|
@@ -3434,11 +3446,11 @@ const Ht = class Ht {
|
|
|
3434
3446
|
} else if (e.length === 3) {
|
|
3435
3447
|
if (e.every((t) => typeof t == "string"))
|
|
3436
3448
|
return this.parse(
|
|
3437
|
-
...e.map((t) => new
|
|
3449
|
+
...e.map((t) => new R(t))
|
|
3438
3450
|
);
|
|
3439
|
-
if (e.every((t) => t instanceof
|
|
3451
|
+
if (e.every((t) => t instanceof R)) {
|
|
3440
3452
|
const t = e[0].clone(), i = e[1].clone(), n = e[2].clone();
|
|
3441
|
-
h(this,
|
|
3453
|
+
h(this, tt, { AB: t, BC: i, AC: n });
|
|
3442
3454
|
let r = t.intersection(i);
|
|
3443
3455
|
if (r.hasIntersection)
|
|
3444
3456
|
h(this, K, r.point.clone());
|
|
@@ -3452,19 +3464,19 @@ const Ht = class Ht {
|
|
|
3452
3464
|
h(this, X, r.point.clone());
|
|
3453
3465
|
else
|
|
3454
3466
|
throw new Error("Lines do not intersect !");
|
|
3455
|
-
} else e.every((t) => t instanceof
|
|
3456
|
-
AB: new
|
|
3457
|
-
BC: new
|
|
3458
|
-
AC: new
|
|
3467
|
+
} else e.every((t) => t instanceof B) && (h(this, X, e[0].clone()), h(this, K, e[1].clone()), h(this, J, e[2].clone()), h(this, tt, {
|
|
3468
|
+
AB: new R(s(this, X), s(this, K)),
|
|
3469
|
+
BC: new R(s(this, K), s(this, J)),
|
|
3470
|
+
AC: new R(s(this, X), s(this, J))
|
|
3459
3471
|
}));
|
|
3460
|
-
} else if (e.length === 1 && e[0] instanceof
|
|
3472
|
+
} else if (e.length === 1 && e[0] instanceof Xt)
|
|
3461
3473
|
return e[0].clone();
|
|
3462
|
-
return s(this,
|
|
3474
|
+
return s(this, Wt).call(this), this;
|
|
3463
3475
|
});
|
|
3464
3476
|
/**
|
|
3465
3477
|
* Clone the Triangle class
|
|
3466
3478
|
*/
|
|
3467
|
-
a(this, "clone", () => new
|
|
3479
|
+
a(this, "clone", () => new Xt(
|
|
3468
3480
|
s(this, X).clone(),
|
|
3469
3481
|
s(this, K).clone(),
|
|
3470
3482
|
s(this, J).clone()
|
|
@@ -3475,18 +3487,18 @@ const Ht = class Ht {
|
|
|
3475
3487
|
/**
|
|
3476
3488
|
* Generate the Line object for the three segments of the triangle
|
|
3477
3489
|
*/
|
|
3478
|
-
p(this,
|
|
3479
|
-
s(this, X).asPoint = !0, s(this, K).asPoint = !0, s(this, J).asPoint = !0, h(this,
|
|
3480
|
-
AB: new
|
|
3481
|
-
AC: new
|
|
3482
|
-
BC: new
|
|
3483
|
-
}), h(this,
|
|
3490
|
+
p(this, Wt, () => {
|
|
3491
|
+
s(this, X).asPoint = !0, s(this, K).asPoint = !0, s(this, J).asPoint = !0, h(this, Oe, {
|
|
3492
|
+
AB: new B().middleOf(s(this, X), s(this, K)),
|
|
3493
|
+
AC: new B().middleOf(s(this, X), s(this, J)),
|
|
3494
|
+
BC: new B().middleOf(s(this, K), s(this, J))
|
|
3495
|
+
}), h(this, mt, s(this, Ht).call(this));
|
|
3484
3496
|
});
|
|
3485
3497
|
/**
|
|
3486
3498
|
* Get the Vector2D class for the given name
|
|
3487
3499
|
* @param ptName
|
|
3488
3500
|
*/
|
|
3489
|
-
p(this,
|
|
3501
|
+
p(this, gt, (e) => {
|
|
3490
3502
|
switch (e.toUpperCase()) {
|
|
3491
3503
|
case "A":
|
|
3492
3504
|
return s(this, X);
|
|
@@ -3503,26 +3515,26 @@ const Ht = class Ht {
|
|
|
3503
3515
|
* @param ptName2
|
|
3504
3516
|
*/
|
|
3505
3517
|
p(this, Pe, (e, t) => new x(
|
|
3506
|
-
s(this,
|
|
3507
|
-
s(this,
|
|
3518
|
+
s(this, gt).call(this, e),
|
|
3519
|
+
s(this, gt).call(this, t)
|
|
3508
3520
|
));
|
|
3509
|
-
p(this,
|
|
3521
|
+
p(this, Ht, () => {
|
|
3510
3522
|
const e = {
|
|
3511
|
-
A: new
|
|
3512
|
-
B: new
|
|
3513
|
-
C: new
|
|
3523
|
+
A: new R().fromPoints(s(this, X), s(this, Oe).BC),
|
|
3524
|
+
B: new R().fromPoints(s(this, K), s(this, Oe).AC),
|
|
3525
|
+
C: new R().fromPoints(s(this, J), s(this, Oe).AB),
|
|
3514
3526
|
intersection: null
|
|
3515
3527
|
}, t = {
|
|
3516
|
-
AB: new
|
|
3517
|
-
AC: new
|
|
3518
|
-
BC: new
|
|
3528
|
+
AB: new R().fromPointAndNormal(s(this, Oe).AB, new x(s(this, X), s(this, K)).normal()),
|
|
3529
|
+
AC: new R().fromPointAndNormal(s(this, Oe).AC, new x(s(this, X), s(this, J)).normal()),
|
|
3530
|
+
BC: new R().fromPointAndNormal(s(this, Oe).BC, new x(s(this, K), s(this, J)).normal()),
|
|
3519
3531
|
intersection: null
|
|
3520
3532
|
}, i = {
|
|
3521
|
-
A: new
|
|
3522
|
-
B: new
|
|
3523
|
-
C: new
|
|
3533
|
+
A: new R().fromPointAndNormal(s(this, X), new x(s(this, K), s(this, J)).normal()),
|
|
3534
|
+
B: new R().fromPointAndNormal(s(this, K), new x(s(this, X), s(this, J)).normal()),
|
|
3535
|
+
C: new R().fromPointAndNormal(s(this, J), new x(s(this, X), s(this, K)).normal()),
|
|
3524
3536
|
intersection: null
|
|
3525
|
-
}, n = s(this,
|
|
3537
|
+
}, n = s(this, it).call(this, "A"), r = s(this, it).call(this, "B"), l = s(this, it).call(this, "C"), c = {
|
|
3526
3538
|
A: n.internal,
|
|
3527
3539
|
B: r.internal,
|
|
3528
3540
|
C: r.internal,
|
|
@@ -3541,12 +3553,12 @@ const Ht = class Ht {
|
|
|
3541
3553
|
};
|
|
3542
3554
|
return f.medians.intersection = f.medians.A.intersection(f.medians.B).point, f.mediators.intersection = f.mediators.AB.intersection(f.mediators.BC).point, f.heights.intersection = f.heights.A.intersection(f.heights.B).point, f.bisectors.intersection = f.bisectors.A.intersection(f.bisectors.B).point, f;
|
|
3543
3555
|
});
|
|
3544
|
-
p(this,
|
|
3556
|
+
p(this, it, (e) => {
|
|
3545
3557
|
const t = this.lines;
|
|
3546
3558
|
let i, n;
|
|
3547
3559
|
if (e === "A" ? (i = t.AB, n = t.AC) : e === "B" ? (i = t.AB, n = t.BC) : e === "C" && (i = t.BC, n = t.AC), i === void 0 || n === void 0)
|
|
3548
3560
|
throw new Error(`The point ${e} does not exist`);
|
|
3549
|
-
const r = i.n.simplify().norm, l = n.n.simplify().norm, c = i.getEquation().multiply(l), d = n.getEquation().multiply(r), f = new
|
|
3561
|
+
const r = i.n.simplify().norm, l = n.n.simplify().norm, c = i.getEquation().multiply(l), d = n.getEquation().multiply(r), f = new R(c.clone().subtract(d).simplify()), g = new R(d.clone().subtract(c).simplify());
|
|
3550
3562
|
return e === "A" ? f.hitSegment(this.B, this.C) ? { internal: f, external: g } : { internal: g, external: f } : e === "B" ? f.hitSegment(this.A, this.C) ? { internal: f, external: g } : { internal: g, external: f } : e === "C" ? f.hitSegment(this.B, this.A) ? { internal: f, external: g } : { internal: g, external: f } : { internal: f, external: g };
|
|
3551
3563
|
});
|
|
3552
3564
|
return e.length > 0 && this.parse(...e), this;
|
|
@@ -3591,21 +3603,21 @@ const Ht = class Ht {
|
|
|
3591
3603
|
return this.AB.normSquare.isEqual(this.BC.normSquare) || this.AB.normSquare.isEqual(this.AC.normSquare) || this.BC.normSquare.isEqual(this.AC.normSquare);
|
|
3592
3604
|
}
|
|
3593
3605
|
get lines() {
|
|
3594
|
-
return s(this,
|
|
3606
|
+
return s(this, tt);
|
|
3595
3607
|
}
|
|
3596
3608
|
get remarquables() {
|
|
3597
|
-
return s(this,
|
|
3609
|
+
return s(this, mt);
|
|
3598
3610
|
}
|
|
3599
3611
|
};
|
|
3600
|
-
X = new WeakMap(), K = new WeakMap(), J = new WeakMap(),
|
|
3601
|
-
let
|
|
3602
|
-
var
|
|
3612
|
+
X = new WeakMap(), K = new WeakMap(), J = new WeakMap(), tt = new WeakMap(), Oe = new WeakMap(), mt = new WeakMap(), Wt = new WeakMap(), gt = new WeakMap(), Pe = new WeakMap(), Ht = new WeakMap(), it = new WeakMap();
|
|
3613
|
+
let oi = Xt;
|
|
3614
|
+
var L, W;
|
|
3603
3615
|
const at = class at {
|
|
3604
3616
|
constructor(e, t) {
|
|
3605
3617
|
// ax + by + c = 0
|
|
3606
|
-
p(this,
|
|
3618
|
+
p(this, L, new B());
|
|
3607
3619
|
p(this, W, new x());
|
|
3608
|
-
a(this, "clone", () => (h(this, W, s(this, W).clone()), h(this,
|
|
3620
|
+
a(this, "clone", () => (h(this, W, s(this, W).clone()), h(this, L, s(this, L).clone()), this));
|
|
3609
3621
|
// ------------------------------------------
|
|
3610
3622
|
// Mathematical operations
|
|
3611
3623
|
// ------------------------------------------
|
|
@@ -3645,23 +3657,23 @@ const at = class at {
|
|
|
3645
3657
|
// return new Fraction().invalid()
|
|
3646
3658
|
// }
|
|
3647
3659
|
a(this, "randomPoint", (e = 5) => {
|
|
3648
|
-
const t = s(this,
|
|
3649
|
-
return new
|
|
3660
|
+
const t = s(this, L).clone(), i = new u(Y(e, !1));
|
|
3661
|
+
return new B(
|
|
3650
3662
|
t.x.clone().add(s(this, W).x.clone().multiply(i)),
|
|
3651
3663
|
t.y.clone().add(s(this, W).y.clone().multiply(i)),
|
|
3652
3664
|
t.z.clone().add(s(this, W).z.clone().multiply(i))
|
|
3653
3665
|
);
|
|
3654
3666
|
});
|
|
3655
|
-
return h(this,
|
|
3667
|
+
return h(this, L, e.clone()), h(this, W, t.asPoint ? new x(e, t) : t.clone()), this;
|
|
3656
3668
|
}
|
|
3657
3669
|
get OA() {
|
|
3658
|
-
return s(this,
|
|
3670
|
+
return s(this, L);
|
|
3659
3671
|
}
|
|
3660
3672
|
set OA(e) {
|
|
3661
|
-
h(this,
|
|
3673
|
+
h(this, L, e);
|
|
3662
3674
|
}
|
|
3663
3675
|
get point() {
|
|
3664
|
-
return s(this,
|
|
3676
|
+
return s(this, L).clone();
|
|
3665
3677
|
}
|
|
3666
3678
|
get d() {
|
|
3667
3679
|
return s(this, W);
|
|
@@ -3671,19 +3683,19 @@ const at = class at {
|
|
|
3671
3683
|
}
|
|
3672
3684
|
get tex() {
|
|
3673
3685
|
return {
|
|
3674
|
-
parametric: `${x.asTex("x", "y", "z")} = ${x.asTex(s(this,
|
|
3686
|
+
parametric: `${x.asTex("x", "y", "z")} = ${x.asTex(s(this, L).x.tex, s(this, L).y.tex, s(this, L).z.tex)} + k\\cdot ${x.asTex(s(this, W).x.tex, s(this, W).y.tex, s(this, W).z.tex)}`,
|
|
3675
3687
|
system: `\\left\\{\\begin{aligned}
|
|
3676
|
-
x &= ${new
|
|
3677
|
-
y &= ${new
|
|
3678
|
-
z &= ${new
|
|
3688
|
+
x &= ${new q(s(this, L).x).add(new M(s(this, W).x).multiply(new M("k"))).reorder("k", !0).tex}\\\\
|
|
3689
|
+
y &= ${new q(s(this, L).y).add(new M(s(this, W).y).multiply(new M("k"))).reorder("k", !0).tex}\\\\
|
|
3690
|
+
z &= ${new q(s(this, L).z).add(new M(s(this, W).z).multiply(new M("k"))).reorder("k", !0).tex}
|
|
3679
3691
|
\\end{aligned}\\right.`,
|
|
3680
|
-
cartesian: `\\frac{ ${new
|
|
3692
|
+
cartesian: `\\frac{ ${new q("x", 1, s(this, L).x.clone().opposite()).tex} }{ ${this.direction.x.tex} } = \\frac{ ${new q("y", 1, s(this, L).y.clone().opposite()).tex} }{ ${this.direction.y.tex} } = \\frac{ ${new q("z", 1, s(this, L).z.clone().opposite()).tex} }{ ${this.direction.z.tex} }`
|
|
3681
3693
|
};
|
|
3682
3694
|
}
|
|
3683
3695
|
get display() {
|
|
3684
|
-
const e = s(this,
|
|
3696
|
+
const e = s(this, L).x.display, t = s(this, L).y.display, i = s(this, L).z.display, n = this.direction.simplify(), r = n.x.display, l = n.y.display, c = n.z.display;
|
|
3685
3697
|
return {
|
|
3686
|
-
parametric: `${x.asDisplay("x", "y", "z")} = ${x.asDisplay(s(this,
|
|
3698
|
+
parametric: `${x.asDisplay("x", "y", "z")} = ${x.asDisplay(s(this, L).x.display, s(this, L).y.display, s(this, L).z.display)} + k\\cdot ${x.asDisplay(s(this, W).x.display, s(this, W).y.display, s(this, W).z.display)}`,
|
|
3687
3699
|
system: "",
|
|
3688
3700
|
cartesian: `(x-${e})/${r} = (y-${t})/${l} = (z-${i})/${c}`
|
|
3689
3701
|
};
|
|
@@ -3692,7 +3704,7 @@ const at = class at {
|
|
|
3692
3704
|
return s(this, W).clone();
|
|
3693
3705
|
}
|
|
3694
3706
|
distanceTo(e) {
|
|
3695
|
-
const t = new x(s(this,
|
|
3707
|
+
const t = new x(s(this, L), e), i = this.direction, n = this.direction.normSquare, r = t.cross(i).normSquare, l = r.clone().divide(n), c = l.clone().sqrt();
|
|
3696
3708
|
return console.log("CROSS", t.cross(i).display), {
|
|
3697
3709
|
value: Math.sqrt(l.value),
|
|
3698
3710
|
fraction: l.clone().sqrt(),
|
|
@@ -3706,14 +3718,14 @@ const at = class at {
|
|
|
3706
3718
|
return i.hasIntersection ? i.point.x.value >= Math.min(e.x.value, t.x.value) && i.point.x.value <= Math.max(e.x.value, t.x.value) && i.point.y.value >= Math.min(e.y.value, t.y.value) && i.point.y.value <= Math.max(e.y.value, t.y.value) && i.point.z.value >= Math.min(e.z.value, t.z.value) && i.point.z.value <= Math.max(e.z.value, t.z.value) : !1;
|
|
3707
3719
|
}
|
|
3708
3720
|
};
|
|
3709
|
-
|
|
3721
|
+
L = new WeakMap(), W = new WeakMap(), // A line is defined as the canonical form
|
|
3710
3722
|
a(at, "PERPENDICULAR", "perpendicular"), a(at, "PARALLEL", "parallel");
|
|
3711
|
-
let
|
|
3712
|
-
var qe,
|
|
3713
|
-
const
|
|
3723
|
+
let Tt = at;
|
|
3724
|
+
var qe, Ue;
|
|
3725
|
+
const pi = class pi {
|
|
3714
3726
|
constructor(e) {
|
|
3715
3727
|
p(this, qe, new x(0, 0, 1));
|
|
3716
|
-
p(this,
|
|
3728
|
+
p(this, Ue, new B(0, 0, 0));
|
|
3717
3729
|
return e && this.parse(e), this;
|
|
3718
3730
|
}
|
|
3719
3731
|
get normal() {
|
|
@@ -3723,10 +3735,10 @@ const fi = class fi {
|
|
|
3723
3735
|
h(this, qe, e), s(this, qe).asPoint = !1;
|
|
3724
3736
|
}
|
|
3725
3737
|
get point() {
|
|
3726
|
-
return s(this,
|
|
3738
|
+
return s(this, Ue);
|
|
3727
3739
|
}
|
|
3728
3740
|
set point(e) {
|
|
3729
|
-
h(this,
|
|
3741
|
+
h(this, Ue, e), s(this, Ue).asPoint = !0;
|
|
3730
3742
|
}
|
|
3731
3743
|
get a() {
|
|
3732
3744
|
return s(this, qe).x;
|
|
@@ -3738,12 +3750,12 @@ const fi = class fi {
|
|
|
3738
3750
|
return s(this, qe).z;
|
|
3739
3751
|
}
|
|
3740
3752
|
get d() {
|
|
3741
|
-
return s(this, qe).dot(s(this,
|
|
3753
|
+
return s(this, qe).dot(s(this, Ue)).opposite();
|
|
3742
3754
|
}
|
|
3743
3755
|
get tex() {
|
|
3744
3756
|
return new H(
|
|
3745
|
-
new
|
|
3746
|
-
new
|
|
3757
|
+
new q("xyz", this.a, this.b, this.c, this.d),
|
|
3758
|
+
new q(0)
|
|
3747
3759
|
).reduce().tex;
|
|
3748
3760
|
}
|
|
3749
3761
|
parse(e) {
|
|
@@ -3760,7 +3772,7 @@ const fi = class fi {
|
|
|
3760
3772
|
}
|
|
3761
3773
|
if (e.equation) {
|
|
3762
3774
|
const r = e.equation.moveLeft().reduce().left, l = r.monomByLetter("x").coefficient, c = r.monomByLetter("y").coefficient, d = r.monomByLetter("z").coefficient, f = r.monomByDegree(0).coefficient;
|
|
3763
|
-
this.normal = new x(l, c, d), l.isNotZero() ? this.point = new
|
|
3775
|
+
this.normal = new x(l, c, d), l.isNotZero() ? this.point = new B(f.clone().divide(l).opposite(), 0, 0) : c.isNotZero() ? this.point = new B(0, f.clone().divide(c).opposite(), 0) : this.point = new B(0, 0, f.clone().divide(d).opposite());
|
|
3764
3776
|
return;
|
|
3765
3777
|
}
|
|
3766
3778
|
if (((i = e.points) == null ? void 0 : i.length) === 3 && e.points.every((r) => r instanceof x)) {
|
|
@@ -3770,12 +3782,12 @@ const fi = class fi {
|
|
|
3770
3782
|
}
|
|
3771
3783
|
if (((n = e.coefficients) == null ? void 0 : n.length) === 4) {
|
|
3772
3784
|
const [r, l, c, d] = e.coefficients;
|
|
3773
|
-
this.normal = new x(r, l, c), this.point = new
|
|
3785
|
+
this.normal = new x(r, l, c), this.point = new B(0, 0, -d);
|
|
3774
3786
|
return;
|
|
3775
3787
|
}
|
|
3776
3788
|
}
|
|
3777
3789
|
angle(e, t, i) {
|
|
3778
|
-
if (e instanceof
|
|
3790
|
+
if (e instanceof pi)
|
|
3779
3791
|
return this.normal.angle(e.normal, t, i);
|
|
3780
3792
|
let n;
|
|
3781
3793
|
if (e instanceof x) {
|
|
@@ -3794,40 +3806,40 @@ const fi = class fi {
|
|
|
3794
3806
|
return t.clone().add(i.clone().multiplyByScalar(n));
|
|
3795
3807
|
}
|
|
3796
3808
|
intersectWithPlane(e) {
|
|
3797
|
-
throw this.normal.cross(e.normal), new
|
|
3809
|
+
throw this.normal.cross(e.normal), new B(0, 0, 0), new Error("Intersection with plane not yet implemented !");
|
|
3798
3810
|
}
|
|
3799
3811
|
isPointOnPlane(e) {
|
|
3800
3812
|
return this.normal.dot(e).add(this.d).isZero();
|
|
3801
3813
|
}
|
|
3802
3814
|
};
|
|
3803
|
-
qe = new WeakMap(),
|
|
3804
|
-
let
|
|
3805
|
-
var
|
|
3806
|
-
class
|
|
3815
|
+
qe = new WeakMap(), Ue = new WeakMap();
|
|
3816
|
+
let hi = pi;
|
|
3817
|
+
var ke;
|
|
3818
|
+
class rs {
|
|
3807
3819
|
constructor(...e) {
|
|
3808
|
-
p(this,
|
|
3809
|
-
return h(this,
|
|
3820
|
+
p(this, ke, []);
|
|
3821
|
+
return h(this, ke, e), this;
|
|
3810
3822
|
}
|
|
3811
3823
|
get values() {
|
|
3812
|
-
return s(this,
|
|
3824
|
+
return s(this, ke);
|
|
3813
3825
|
}
|
|
3814
3826
|
get array() {
|
|
3815
|
-
return s(this,
|
|
3827
|
+
return s(this, ke).map((e) => e.array);
|
|
3816
3828
|
}
|
|
3817
3829
|
get dimension() {
|
|
3818
|
-
return [s(this,
|
|
3830
|
+
return [s(this, ke).length, s(this, ke)[0].dimension];
|
|
3819
3831
|
}
|
|
3820
3832
|
isSquare() {
|
|
3821
|
-
return s(this,
|
|
3833
|
+
return s(this, ke).length === s(this, ke)[0].dimension;
|
|
3822
3834
|
}
|
|
3823
3835
|
determinant() {
|
|
3824
3836
|
if (!this.isSquare())
|
|
3825
3837
|
throw new Error("Matrix is not square");
|
|
3826
|
-
return
|
|
3838
|
+
return is(...this.values);
|
|
3827
3839
|
}
|
|
3828
3840
|
}
|
|
3829
|
-
|
|
3830
|
-
function
|
|
3841
|
+
ke = new WeakMap();
|
|
3842
|
+
function At(o) {
|
|
3831
3843
|
const e = Object.assign(
|
|
3832
3844
|
{
|
|
3833
3845
|
negative: !0,
|
|
@@ -3847,7 +3859,7 @@ function Tt(o) {
|
|
|
3847
3859
|
}
|
|
3848
3860
|
return e.reduced ? t.reduce() : t;
|
|
3849
3861
|
}
|
|
3850
|
-
function
|
|
3862
|
+
function Ii(o) {
|
|
3851
3863
|
const e = Object.assign(
|
|
3852
3864
|
{
|
|
3853
3865
|
letters: "x",
|
|
@@ -3856,8 +3868,8 @@ function Ci(o) {
|
|
|
3856
3868
|
zero: !1
|
|
3857
3869
|
},
|
|
3858
3870
|
o
|
|
3859
|
-
), t = new
|
|
3860
|
-
if (t.coefficient =
|
|
3871
|
+
), t = new M();
|
|
3872
|
+
if (t.coefficient = At({
|
|
3861
3873
|
zero: e.zero,
|
|
3862
3874
|
reduced: !0,
|
|
3863
3875
|
natural: !e.fraction
|
|
@@ -3865,14 +3877,14 @@ function Ci(o) {
|
|
|
3865
3877
|
for (const i of e.letters.split(""))
|
|
3866
3878
|
t.setLetter(i, 0);
|
|
3867
3879
|
for (let i = 0; i < e.degree; i++) {
|
|
3868
|
-
const n =
|
|
3880
|
+
const n = fi(e.letters.split(""));
|
|
3869
3881
|
t.setLetter(n, t.degree(n).clone().add(1));
|
|
3870
3882
|
}
|
|
3871
3883
|
} else
|
|
3872
3884
|
t.setLetter(e.letters, e.degree);
|
|
3873
3885
|
return t;
|
|
3874
3886
|
}
|
|
3875
|
-
const
|
|
3887
|
+
const os = {
|
|
3876
3888
|
letters: "x",
|
|
3877
3889
|
degree: 2,
|
|
3878
3890
|
fraction: !1,
|
|
@@ -3883,14 +3895,14 @@ const ns = {
|
|
|
3883
3895
|
numberOfMonoms: 0,
|
|
3884
3896
|
positive: !0
|
|
3885
3897
|
};
|
|
3886
|
-
function
|
|
3898
|
+
function Pi(o) {
|
|
3887
3899
|
const e = Object.assign(
|
|
3888
|
-
|
|
3900
|
+
os,
|
|
3889
3901
|
o
|
|
3890
|
-
), t = new
|
|
3902
|
+
), t = new q().empty();
|
|
3891
3903
|
let i;
|
|
3892
3904
|
for (let n = e.degree; n >= 0; n--)
|
|
3893
|
-
i =
|
|
3905
|
+
i = Ii({
|
|
3894
3906
|
letters: e.letters,
|
|
3895
3907
|
degree: n,
|
|
3896
3908
|
fraction: e.fraction,
|
|
@@ -3901,9 +3913,9 @@ function $i(o) {
|
|
|
3901
3913
|
const n = fe(1, t.length - 1);
|
|
3902
3914
|
t.monoms.splice(n, 1);
|
|
3903
3915
|
}
|
|
3904
|
-
return t;
|
|
3916
|
+
return t.reduce();
|
|
3905
3917
|
}
|
|
3906
|
-
function
|
|
3918
|
+
function hs(o) {
|
|
3907
3919
|
const e = Object.assign(
|
|
3908
3920
|
{
|
|
3909
3921
|
letters: "x",
|
|
@@ -3923,9 +3935,9 @@ function rs(o) {
|
|
|
3923
3935
|
}
|
|
3924
3936
|
},
|
|
3925
3937
|
o
|
|
3926
|
-
), t = new
|
|
3938
|
+
), t = new q().one();
|
|
3927
3939
|
for (let i = 0; i < e.degree; i++) {
|
|
3928
|
-
const n =
|
|
3940
|
+
const n = Pi({
|
|
3929
3941
|
degree: 1,
|
|
3930
3942
|
unit: e.unit,
|
|
3931
3943
|
fraction: e.fraction,
|
|
@@ -3936,7 +3948,7 @@ function rs(o) {
|
|
|
3936
3948
|
}
|
|
3937
3949
|
return new H(t, 0);
|
|
3938
3950
|
}
|
|
3939
|
-
function
|
|
3951
|
+
function ai(o) {
|
|
3940
3952
|
const e = Object.assign(
|
|
3941
3953
|
{
|
|
3942
3954
|
axis: !0,
|
|
@@ -3945,10 +3957,10 @@ function oi(o) {
|
|
|
3945
3957
|
quadrant: null
|
|
3946
3958
|
},
|
|
3947
3959
|
o
|
|
3948
|
-
), t = e.axis === "x", i = e.axis === "y", n = e.fraction ?
|
|
3949
|
-
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
|
|
3960
|
+
), t = e.axis === "x", i = e.axis === "y", n = e.fraction ? At({ max: e.max, zero: t }) : new u(Y(e.max, t)), r = e.fraction ? At({ max: e.max, zero: i }) : new u(Y(e.max, i));
|
|
3961
|
+
return Number(e.quadrant) === 1 && (n.abs(), r.abs()), Number(e.quadrant) === 2 && (n.isPositive() && n.opposite(), r.isNegative() && r.opposite()), Number(e.quadrant) === 3 && (n.isPositive() && n.opposite(), r.isPositive() && r.opposite()), Number(e.quadrant) === 4 && (n.isNegative() && n.opposite(), r.isPositive() && r.opposite()), new B(n, r);
|
|
3950
3962
|
}
|
|
3951
|
-
function
|
|
3963
|
+
function as(o) {
|
|
3952
3964
|
const e = Object.assign(
|
|
3953
3965
|
{
|
|
3954
3966
|
center: {
|
|
@@ -3958,11 +3970,11 @@ function os(o) {
|
|
|
3958
3970
|
pointsOnCircle: 8
|
|
3959
3971
|
},
|
|
3960
3972
|
o
|
|
3961
|
-
), t =
|
|
3973
|
+
), t = ai(e.center);
|
|
3962
3974
|
let i, n;
|
|
3963
|
-
return e.pointsOnCircle === 8 ? (i = fe(1, 3), n = i ** 2 + (i + 1) ** 2) : n = fe(1, 20), new
|
|
3975
|
+
return e.pointsOnCircle === 8 ? (i = fe(1, 3), n = i ** 2 + (i + 1) ** 2) : n = fe(1, 20), new Nt(t, n, !0);
|
|
3964
3976
|
}
|
|
3965
|
-
function
|
|
3977
|
+
function ls(o) {
|
|
3966
3978
|
const e = Object.assign(
|
|
3967
3979
|
{
|
|
3968
3980
|
A: {
|
|
@@ -3977,9 +3989,9 @@ function hs(o) {
|
|
|
3977
3989
|
);
|
|
3978
3990
|
for (; t.isNull; )
|
|
3979
3991
|
t.x = Y(10), t.y = Y(10);
|
|
3980
|
-
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
|
|
3992
|
+
return e.slope === 1 ? t.x.sign() !== t.y.sign() && t.y.opposite() : e.slope === -1 && t.x.sign() !== t.y.sign() && t.y.opposite(), new R(new x(e.A.x, e.A.y), t);
|
|
3981
3993
|
}
|
|
3982
|
-
function
|
|
3994
|
+
function cs(o) {
|
|
3983
3995
|
const e = Object.assign(
|
|
3984
3996
|
{
|
|
3985
3997
|
A: {
|
|
@@ -3994,48 +4006,48 @@ function as(o) {
|
|
|
3994
4006
|
}
|
|
3995
4007
|
},
|
|
3996
4008
|
o
|
|
3997
|
-
), t = new
|
|
3998
|
-
return new
|
|
4009
|
+
), t = new B(e.A.x, e.A.y, e.A.z), i = new x(e.direction.x, e.direction.y, e.direction.z);
|
|
4010
|
+
return new Tt(t, i);
|
|
3999
4011
|
}
|
|
4000
|
-
const
|
|
4001
|
-
equation: (o) =>
|
|
4002
|
-
polynom: (o) =>
|
|
4003
|
-
monom: (o) =>
|
|
4004
|
-
fraction: (o) =>
|
|
4012
|
+
const us = {
|
|
4013
|
+
equation: (o) => hs(o),
|
|
4014
|
+
polynom: (o) => Pi(o),
|
|
4015
|
+
monom: (o) => Ii(o),
|
|
4016
|
+
fraction: (o) => At(o),
|
|
4005
4017
|
number: (o, e, t) => fe(o, e, t),
|
|
4006
4018
|
numberSym: (o, e) => Y(o, e),
|
|
4007
|
-
prime: (o) =>
|
|
4008
|
-
bool: (o) =>
|
|
4009
|
-
array: (o, e) =>
|
|
4010
|
-
item: (o) =>
|
|
4011
|
-
shuffle: (o) =>
|
|
4012
|
-
line: (o) =>
|
|
4013
|
-
line3: (o) =>
|
|
4014
|
-
vector: (o) =>
|
|
4019
|
+
prime: (o) => ss(o),
|
|
4020
|
+
bool: (o) => Ai(o),
|
|
4021
|
+
array: (o, e) => ns(o, e),
|
|
4022
|
+
item: (o) => fi(o),
|
|
4023
|
+
shuffle: (o) => Oi(o),
|
|
4024
|
+
line: (o) => ls(o),
|
|
4025
|
+
line3: (o) => cs(o),
|
|
4026
|
+
vector: (o) => ai(o),
|
|
4015
4027
|
point: (o) => {
|
|
4016
|
-
const e =
|
|
4028
|
+
const e = ai(o);
|
|
4017
4029
|
return e.asPoint = !0, e;
|
|
4018
4030
|
},
|
|
4019
|
-
circle: (o) =>
|
|
4031
|
+
circle: (o) => as(o)
|
|
4020
4032
|
};
|
|
4021
|
-
var
|
|
4022
|
-
class
|
|
4033
|
+
var Me, yt, li;
|
|
4034
|
+
class fs {
|
|
4023
4035
|
/**
|
|
4024
4036
|
*
|
|
4025
4037
|
* @param {string} value (optional) Default polynom to parse on class creation
|
|
4026
4038
|
*/
|
|
4027
4039
|
constructor(e) {
|
|
4028
|
-
p(this,
|
|
4029
|
-
p(this,
|
|
4030
|
-
a(this, "parse", (e) => (h(this,
|
|
4031
|
-
return h(this,
|
|
4040
|
+
p(this, yt);
|
|
4041
|
+
p(this, Me);
|
|
4042
|
+
a(this, "parse", (e) => (h(this, Me, new Yt(Ze.SET).parse(e).rpn), this));
|
|
4043
|
+
return h(this, Me, []), e !== void 0 && this.parse(e), this;
|
|
4032
4044
|
}
|
|
4033
4045
|
evaluate(e) {
|
|
4034
4046
|
this.variables.forEach((i) => {
|
|
4035
4047
|
Object.hasOwn(e, i) || (e[i] = !1);
|
|
4036
4048
|
});
|
|
4037
4049
|
const t = [];
|
|
4038
|
-
for (const i of s(this,
|
|
4050
|
+
for (const i of s(this, Me))
|
|
4039
4051
|
if (console.log(i), i.tokenType === "variable")
|
|
4040
4052
|
t.push(e[i.token]);
|
|
4041
4053
|
else if (i.tokenType === "operation")
|
|
@@ -4064,11 +4076,11 @@ class cs {
|
|
|
4064
4076
|
return t.length === 1 && t[0];
|
|
4065
4077
|
}
|
|
4066
4078
|
get rpn() {
|
|
4067
|
-
return s(this,
|
|
4079
|
+
return s(this, Me);
|
|
4068
4080
|
}
|
|
4069
4081
|
get tex() {
|
|
4070
4082
|
const e = [];
|
|
4071
|
-
for (const t of s(this,
|
|
4083
|
+
for (const t of s(this, Me))
|
|
4072
4084
|
if (t.tokenType === "variable")
|
|
4073
4085
|
e.push(t);
|
|
4074
4086
|
else
|
|
@@ -4101,23 +4113,23 @@ class cs {
|
|
|
4101
4113
|
return e[0].token;
|
|
4102
4114
|
}
|
|
4103
4115
|
get variables() {
|
|
4104
|
-
return s(this,
|
|
4116
|
+
return s(this, Me).filter((e) => e.tokenType === "variable").map((e) => e.token);
|
|
4105
4117
|
}
|
|
4106
4118
|
vennAB() {
|
|
4107
|
-
return
|
|
4119
|
+
return O(this, yt, li).call(this, {
|
|
4108
4120
|
A: ["A", "AB"],
|
|
4109
4121
|
B: ["B", "AB"]
|
|
4110
4122
|
}, ["A", "B", "AB", "E"]);
|
|
4111
4123
|
}
|
|
4112
4124
|
vennABC() {
|
|
4113
|
-
return
|
|
4125
|
+
return O(this, yt, li).call(this, {
|
|
4114
4126
|
A: ["A", "AB", "AC", "ABC"],
|
|
4115
4127
|
B: ["B", "AB", "BC", "ABC"],
|
|
4116
4128
|
C: ["C", "AC", "BC", "ABC"]
|
|
4117
4129
|
}, ["A", "B", "C", "AB", "AC", "BC", "ABC", "E"]);
|
|
4118
4130
|
}
|
|
4119
4131
|
}
|
|
4120
|
-
|
|
4132
|
+
Me = new WeakMap(), yt = new WeakSet(), li = function(e, t) {
|
|
4121
4133
|
const i = [];
|
|
4122
4134
|
let n;
|
|
4123
4135
|
if (t === void 0) {
|
|
@@ -4129,7 +4141,7 @@ ke = new WeakMap(), gt = new WeakSet(), hi = function(e, t) {
|
|
|
4129
4141
|
]);
|
|
4130
4142
|
} else
|
|
4131
4143
|
n = new Set(t);
|
|
4132
|
-
for (const r of s(this,
|
|
4144
|
+
for (const r of s(this, Me))
|
|
4133
4145
|
if (r.tokenType === "variable")
|
|
4134
4146
|
e[r.token] === void 0 ? i.push(/* @__PURE__ */ new Set()) : i.push(new Set(e[r.token]));
|
|
4135
4147
|
else
|
|
@@ -4161,30 +4173,30 @@ ke = new WeakMap(), gt = new WeakSet(), hi = function(e, t) {
|
|
|
4161
4173
|
}
|
|
4162
4174
|
return [...i[0]].sort();
|
|
4163
4175
|
};
|
|
4164
|
-
const
|
|
4176
|
+
const ds = {
|
|
4165
4177
|
Vector: x,
|
|
4166
|
-
Point:
|
|
4167
|
-
Line:
|
|
4168
|
-
Triangle:
|
|
4169
|
-
Circle:
|
|
4170
|
-
Line3:
|
|
4171
|
-
Plane3:
|
|
4172
|
-
},
|
|
4178
|
+
Point: B,
|
|
4179
|
+
Line: R,
|
|
4180
|
+
Triangle: oi,
|
|
4181
|
+
Circle: Nt,
|
|
4182
|
+
Line3: Tt,
|
|
4183
|
+
Plane3: hi
|
|
4184
|
+
}, ms = {
|
|
4173
4185
|
Numeric: G,
|
|
4174
4186
|
Fraction: u,
|
|
4175
|
-
Root:
|
|
4176
|
-
Monom:
|
|
4177
|
-
Polynom:
|
|
4187
|
+
Root: wt,
|
|
4188
|
+
Monom: M,
|
|
4189
|
+
Polynom: q,
|
|
4178
4190
|
Equation: H,
|
|
4179
|
-
Matrix:
|
|
4180
|
-
LinearSystem:
|
|
4181
|
-
Factor:
|
|
4182
|
-
PolyFactor:
|
|
4183
|
-
LogicalSet:
|
|
4184
|
-
Random:
|
|
4185
|
-
Geometry:
|
|
4186
|
-
NumExp:
|
|
4191
|
+
Matrix: rs,
|
|
4192
|
+
LinearSystem: ni,
|
|
4193
|
+
Factor: ue,
|
|
4194
|
+
PolyFactor: ti,
|
|
4195
|
+
LogicalSet: fs,
|
|
4196
|
+
Random: us,
|
|
4197
|
+
Geometry: ds,
|
|
4198
|
+
NumExp: Ji
|
|
4187
4199
|
};
|
|
4188
4200
|
export {
|
|
4189
|
-
|
|
4201
|
+
ms as default
|
|
4190
4202
|
};
|