pimath 0.1.24 → 0.1.25
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/README.md +4 -7
- package/dist/algebra/factor.d.ts +4 -3
- package/dist/algebra/monom.d.ts +0 -1
- package/dist/algebra/polyFactor.d.ts +9 -3
- package/dist/algebra/polynom.d.ts +6 -4
- package/dist/geometry/triangle.d.ts +0 -1
- package/dist/pimath.interface.d.ts +2 -5
- package/dist/pimath.js +1066 -991
- package/dist/pimath.js.map +1 -1
- package/package.json +1 -1
package/dist/pimath.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var Li = Object.defineProperty;
|
|
2
|
+
var gi = (o) => {
|
|
3
3
|
throw TypeError(o);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var a = (o, e, t) =>
|
|
7
|
-
var s = (o, e, t) => (_t(o, e, "read from private field"), t ? t.call(o) : e.get(o)),
|
|
8
|
-
function
|
|
9
|
-
const e =
|
|
5
|
+
var Vi = (o, e, t) => e in o ? Li(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
6
|
+
var a = (o, e, t) => Vi(o, typeof e != "symbol" ? e + "" : e, t), _t = (o, e, t) => e.has(o) || gi("Cannot " + t);
|
|
7
|
+
var s = (o, e, t) => (_t(o, e, "read from private field"), t ? t.call(o) : e.get(o)), m = (o, e, t) => e.has(o) ? gi("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), h = (o, e, t, i) => (_t(o, e, "write to private field"), i ? i.call(o, t) : e.set(o, t), t), A = (o, e, t) => (_t(o, e, "access private method"), t);
|
|
8
|
+
function Di(o) {
|
|
9
|
+
const e = wi(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 = ui(...o);
|
|
17
17
|
return o.map((t) => t / e);
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function wi(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 vi(o) {
|
|
|
24
24
|
return n - r;
|
|
25
25
|
}), [...new Set(i)];
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function ui(...o) {
|
|
28
28
|
const e = function(n, r) {
|
|
29
29
|
return r === 0 ? n : e(r, n % r);
|
|
30
30
|
};
|
|
@@ -39,52 +39,52 @@ function fi(...o) {
|
|
|
39
39
|
;
|
|
40
40
|
return Math.abs(t);
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function Fi(...o) {
|
|
43
43
|
return o.reduce(function(e, t) {
|
|
44
|
-
return Math.abs(e * t /
|
|
44
|
+
return Math.abs(e * t / ui(e, t));
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function ji(o, e = 3) {
|
|
48
48
|
return +o.toFixed(e);
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function Ui(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 Wi(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 Gi(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 Hi(o, e = 2) {
|
|
67
67
|
return +`${Math.round(+`${o}e${e}`)}e-${e}`;
|
|
68
68
|
}
|
|
69
|
-
const
|
|
70
|
-
decompose:
|
|
71
|
-
dividers:
|
|
72
|
-
divideNumbersByGCD:
|
|
73
|
-
gcd:
|
|
74
|
-
lcm:
|
|
75
|
-
numberCorrection:
|
|
76
|
-
periodic:
|
|
77
|
-
primes:
|
|
78
|
-
pythagoreanTripletsWithTarget:
|
|
79
|
-
round:
|
|
69
|
+
const U = {
|
|
70
|
+
decompose: Di,
|
|
71
|
+
dividers: wi,
|
|
72
|
+
divideNumbersByGCD: Zi,
|
|
73
|
+
gcd: ui,
|
|
74
|
+
lcm: Fi,
|
|
75
|
+
numberCorrection: ji,
|
|
76
|
+
periodic: Ui,
|
|
77
|
+
primes: Wi,
|
|
78
|
+
pythagoreanTripletsWithTarget: Gi,
|
|
79
|
+
round: Hi
|
|
80
80
|
};
|
|
81
|
-
var
|
|
82
|
-
const
|
|
81
|
+
var ut, x, v, Re;
|
|
82
|
+
const P = class P {
|
|
83
83
|
constructor(e, t) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
m(this, ut, !1);
|
|
85
|
+
m(this, x, 1);
|
|
86
|
+
m(this, v, 1);
|
|
87
|
+
m(this, Re, "frac");
|
|
88
88
|
// ------------------------------------------
|
|
89
89
|
/**
|
|
90
90
|
* Parse the value to get the numerator and denominator
|
|
@@ -94,7 +94,7 @@ const $ = class $ {
|
|
|
94
94
|
a(this, "parse", (e, t) => {
|
|
95
95
|
let i;
|
|
96
96
|
if (e === "")
|
|
97
|
-
return h(this,
|
|
97
|
+
return h(this, v, 0), h(this, x, 1), this;
|
|
98
98
|
switch (typeof e) {
|
|
99
99
|
case "string":
|
|
100
100
|
if (i = e.split("/"), i.length > 2)
|
|
@@ -103,37 +103,36 @@ const $ = class $ {
|
|
|
103
103
|
throw new Error(`The given value is not a valid fraction (${e})`);
|
|
104
104
|
if (i.length === 1)
|
|
105
105
|
return this.parse(+i[0]);
|
|
106
|
-
i.length === 2 ? i[1] === "0" ? (h(this,
|
|
106
|
+
i.length === 2 ? i[1] === "0" ? (h(this, v, NaN), h(this, x, 1)) : (h(this, v, +i[0]), h(this, x, +i[1])) : (h(this, v, NaN), h(this, x, 1));
|
|
107
107
|
break;
|
|
108
108
|
case "number":
|
|
109
109
|
if (Number.isSafeInteger(e))
|
|
110
|
-
h(this,
|
|
110
|
+
h(this, v, +e), t === void 0 || !Number.isSafeInteger(t) ? h(this, x, 1) : h(this, x, +t);
|
|
111
111
|
else {
|
|
112
112
|
const [, n] = e.toString().split("."), r = n ? n.length : 0;
|
|
113
|
-
t === void 0 ? (h(this,
|
|
113
|
+
t === void 0 ? (h(this, v, e * Math.pow(10, r)), h(this, x, Math.pow(10, r))) : Number.isSafeInteger(t) && (h(this, v, e * Math.pow(10, r) - Math.floor(e * Math.pow(10, r - t))), this.denominator = Math.pow(10, r) - Math.pow(10, r - t)), this.reduce();
|
|
114
114
|
}
|
|
115
115
|
break;
|
|
116
116
|
case "object":
|
|
117
|
-
e instanceof
|
|
117
|
+
e instanceof P && (h(this, v, +e.numerator), h(this, x, +e.denominator));
|
|
118
118
|
break;
|
|
119
119
|
}
|
|
120
120
|
return this;
|
|
121
121
|
});
|
|
122
122
|
a(this, "clone", () => {
|
|
123
|
-
const e = new
|
|
124
|
-
return e.numerator = +s(this,
|
|
123
|
+
const e = new P();
|
|
124
|
+
return e.numerator = +s(this, v), e.denominator = +s(this, x), e;
|
|
125
125
|
});
|
|
126
|
-
a(this, "abs", () => (h(this,
|
|
126
|
+
a(this, "abs", () => (h(this, v, Math.abs(s(this, v))), h(this, x, Math.abs(s(this, x))), this));
|
|
127
127
|
a(this, "add", (e) => {
|
|
128
|
-
if (e instanceof
|
|
129
|
-
const t = s(this,
|
|
130
|
-
h(this,
|
|
128
|
+
if (e instanceof P) {
|
|
129
|
+
const t = s(this, v), i = s(this, x);
|
|
130
|
+
h(this, v, t * e.denominator + e.numerator * i), h(this, x, i * e.denominator);
|
|
131
131
|
} else
|
|
132
|
-
return this.add(new
|
|
132
|
+
return this.add(new P(e));
|
|
133
133
|
return this.reduce();
|
|
134
134
|
});
|
|
135
|
-
a(this, "amplify", (e) => (Number.isSafeInteger(e) && (h(this,
|
|
136
|
-
// TODO: The rest of the functions are not used or unnecessary ?
|
|
135
|
+
a(this, "amplify", (e) => (Number.isSafeInteger(e) && (h(this, v, s(this, v) * e), h(this, x, s(this, x) * e)), this));
|
|
137
136
|
/**
|
|
138
137
|
* Simple function to determine if it's a fraction
|
|
139
138
|
*/
|
|
@@ -147,7 +146,7 @@ const $ = class $ {
|
|
|
147
146
|
a(this, "compare", (e, t) => {
|
|
148
147
|
t === void 0 && (t = "=");
|
|
149
148
|
let i;
|
|
150
|
-
switch (e instanceof
|
|
149
|
+
switch (e instanceof P ? i = e.clone() : i = new P(e), t) {
|
|
151
150
|
case ">":
|
|
152
151
|
return this.value > i.value;
|
|
153
152
|
case ">=":
|
|
@@ -169,66 +168,66 @@ const $ = class $ {
|
|
|
169
168
|
}
|
|
170
169
|
});
|
|
171
170
|
a(this, "divide", (e) => {
|
|
172
|
-
const t = new
|
|
171
|
+
const t = new P(e);
|
|
173
172
|
if (t.numerator === 0)
|
|
174
|
-
return new
|
|
175
|
-
const i = +s(this,
|
|
176
|
-
return h(this,
|
|
173
|
+
return new P().infinite();
|
|
174
|
+
const i = +s(this, v), n = +s(this, x);
|
|
175
|
+
return h(this, v, i * t.denominator), h(this, x, n * t.numerator), this.reduce();
|
|
177
176
|
});
|
|
178
|
-
a(this, "infinite", () => (h(this,
|
|
179
|
-
a(this, "invalid", () => (h(this,
|
|
177
|
+
a(this, "infinite", () => (h(this, v, 1 / 0), h(this, x, 1), this));
|
|
178
|
+
a(this, "invalid", () => (h(this, v, NaN), h(this, x, 1), this));
|
|
180
179
|
a(this, "inverse", () => {
|
|
181
|
-
const e = +s(this,
|
|
182
|
-
return h(this,
|
|
180
|
+
const e = +s(this, v);
|
|
181
|
+
return h(this, v, +s(this, x)), h(this, x, e), this;
|
|
183
182
|
});
|
|
184
|
-
a(this, "isApproximative", () => s(this,
|
|
183
|
+
a(this, "isApproximative", () => s(this, ut) || s(this, v).toString().length >= 15 && s(this, x).toString().length >= 15);
|
|
185
184
|
a(this, "isEqual", (e) => this.compare(e, "="));
|
|
186
185
|
a(this, "isEven", () => this.isRelative() && this.value % 2 === 0);
|
|
187
186
|
a(this, "isExact", () => !this.isApproximative());
|
|
188
187
|
a(this, "isFinite", () => !this.isInfinity() && !this.isNaN());
|
|
189
188
|
a(this, "isGeq", (e) => this.compare(e, ">="));
|
|
190
189
|
a(this, "isGreater", (e) => this.compare(e, ">"));
|
|
191
|
-
a(this, "isInfinity", () => Math.abs(s(this,
|
|
192
|
-
a(this, "isInverted", (e) => this.isEqual(new
|
|
190
|
+
a(this, "isInfinity", () => Math.abs(s(this, v)) === 1 / 0);
|
|
191
|
+
a(this, "isInverted", (e) => this.isEqual(new P().one().divide(e.clone())));
|
|
193
192
|
a(this, "isLeq", (e) => this.compare(e, "<="));
|
|
194
193
|
/* Compare shortcuts */
|
|
195
194
|
a(this, "isLesser", (e) => this.compare(e, "<"));
|
|
196
|
-
a(this, "isNaN", () => isNaN(s(this,
|
|
195
|
+
a(this, "isNaN", () => isNaN(s(this, v)));
|
|
197
196
|
a(this, "isNatural", () => this.isRelative() && this.isPositive());
|
|
198
197
|
a(this, "isNegative", () => this.sign() === -1);
|
|
199
|
-
a(this, "isNegativeOne", () => s(this,
|
|
198
|
+
a(this, "isNegativeOne", () => s(this, v) === -1 && s(this, x) === 1);
|
|
200
199
|
a(this, "isNotEqual", (e) => this.compare(e, "<>"));
|
|
201
200
|
// ------------------------------------------
|
|
202
|
-
a(this, "isNotZero", () => s(this,
|
|
201
|
+
a(this, "isNotZero", () => s(this, v) !== 0);
|
|
203
202
|
a(this, "isOdd", () => this.isRelative() && this.value % 2 === 1);
|
|
204
|
-
a(this, "isOne", () => s(this,
|
|
203
|
+
a(this, "isOne", () => s(this, v) === 1 && s(this, x) === 1);
|
|
205
204
|
a(this, "isOpposite", (e) => this.isEqual(e.clone().opposite()));
|
|
206
205
|
a(this, "isPositive", () => this.sign() === 1);
|
|
207
206
|
a(this, "isRational", () => !this.isRelative());
|
|
208
|
-
a(this, "isReduced", () => Math.abs(
|
|
207
|
+
a(this, "isReduced", () => Math.abs(U.gcd(s(this, v), s(this, x))) === 1);
|
|
209
208
|
a(this, "isRelative", () => this.clone().reduce().denominator === 1);
|
|
210
|
-
a(this, "isSquare", () => Math.sqrt(s(this,
|
|
209
|
+
a(this, "isSquare", () => Math.sqrt(s(this, v)) % 1 === 0 && Math.sqrt(s(this, x)) % 1 === 0);
|
|
211
210
|
a(this, "isStrictlyNegative", () => this.value < 0);
|
|
212
211
|
a(this, "isStrictlyPositive", () => this.value > 0);
|
|
213
212
|
// Mathematical operations specific to fractions
|
|
214
|
-
a(this, "isZero", () => s(this,
|
|
213
|
+
a(this, "isZero", () => s(this, v) === 0);
|
|
215
214
|
a(this, "multiply", (e) => {
|
|
216
|
-
const t = new
|
|
217
|
-
return h(this,
|
|
215
|
+
const t = new P(e);
|
|
216
|
+
return h(this, v, s(this, v) * t.numerator), h(this, x, s(this, x) * t.denominator), this.reduce();
|
|
218
217
|
});
|
|
219
|
-
a(this, "one", () => (h(this,
|
|
220
|
-
a(this, "opposite", () => (h(this,
|
|
218
|
+
a(this, "one", () => (h(this, v, 1), h(this, x, 1), this));
|
|
219
|
+
a(this, "opposite", () => (h(this, v, -s(this, v)), this));
|
|
221
220
|
a(this, "pow", (e) => {
|
|
222
|
-
if (e instanceof
|
|
221
|
+
if (e instanceof P)
|
|
223
222
|
return this.pow(e.value);
|
|
224
223
|
this.reduce(), e < 0 && this.inverse();
|
|
225
|
-
const t = Math.floor(Math.pow(s(this,
|
|
226
|
-
return t ** Math.abs(e) === s(this,
|
|
224
|
+
const t = Math.floor(Math.pow(s(this, v), Math.abs(e))), i = Math.floor(Math.pow(s(this, x), Math.abs(e)));
|
|
225
|
+
return t ** Math.abs(e) === s(this, v) && i ** Math.abs(e) === s(this, x) ? (h(this, v, s(this, v) ** Math.abs(e)), h(this, x, s(this, x) ** Math.abs(e))) : (h(this, v, s(this, v) ** Math.abs(e)), h(this, x, s(this, x) ** Math.abs(e))), this;
|
|
227
226
|
});
|
|
228
227
|
// ------------------------------------------
|
|
229
228
|
a(this, "reduce", () => {
|
|
230
|
-
const e =
|
|
231
|
-
return h(this,
|
|
229
|
+
const e = U.gcd(s(this, v), s(this, x));
|
|
230
|
+
return h(this, v, s(this, v) / e), h(this, x, s(this, x) / e), s(this, x) < 0 && (h(this, x, -s(this, x)), h(this, v, -s(this, v))), this;
|
|
232
231
|
});
|
|
233
232
|
a(this, "root", (e) => {
|
|
234
233
|
if (e === 0)
|
|
@@ -239,111 +238,111 @@ const $ = class $ {
|
|
|
239
238
|
throw new Error("The root of a negative number must be odd.");
|
|
240
239
|
const t = this.sign();
|
|
241
240
|
this.abs(), this.reduce();
|
|
242
|
-
const i = Math.floor(Math.pow(s(this,
|
|
243
|
-
return h(this,
|
|
241
|
+
const i = Math.floor(Math.pow(s(this, v), Math.abs(1 / e))), n = Math.floor(Math.pow(s(this, x), Math.abs(1 / e)));
|
|
242
|
+
return h(this, v, Math.pow(s(this, v), Math.abs(1 / e))), h(this, x, Math.pow(s(this, x), Math.abs(1 / e))), (i !== s(this, v) || n !== s(this, x)) && (h(this, v, s(this, v) / s(this, x)), h(this, x, 1), h(this, ut, !0)), this.multiply(t), this;
|
|
244
243
|
});
|
|
245
244
|
// ------------------------------------------
|
|
246
245
|
// Getter and setter
|
|
247
|
-
a(this, "sign", () => s(this,
|
|
246
|
+
a(this, "sign", () => s(this, v) * s(this, x) >= 0 ? 1 : -1);
|
|
248
247
|
a(this, "sqrt", () => this.root(2));
|
|
249
|
-
a(this, "subtract", (e) => e instanceof
|
|
250
|
-
a(this, "zero", () => (h(this,
|
|
248
|
+
a(this, "subtract", (e) => e instanceof P ? this.add(e.clone().opposite()) : this.add(-e));
|
|
249
|
+
a(this, "zero", () => (h(this, v, 0), h(this, x, 1), this));
|
|
251
250
|
return e !== void 0 && this.parse(e, t), this;
|
|
252
251
|
}
|
|
253
252
|
get denominator() {
|
|
254
|
-
return s(this,
|
|
253
|
+
return s(this, x);
|
|
255
254
|
}
|
|
256
255
|
set denominator(e) {
|
|
257
|
-
h(this,
|
|
256
|
+
h(this, x, e);
|
|
258
257
|
}
|
|
259
258
|
get dfrac() {
|
|
260
|
-
return h(this,
|
|
259
|
+
return h(this, Re, "dfrac"), this;
|
|
261
260
|
}
|
|
262
261
|
get display() {
|
|
263
|
-
return this.isExact() ? s(this,
|
|
262
|
+
return this.isExact() ? s(this, x) === 1 ? `${s(this, v)}` : `${s(this, v)}/${s(this, x)}` : this.value.toFixed(3);
|
|
264
263
|
}
|
|
265
264
|
get frac() {
|
|
266
|
-
return h(this,
|
|
265
|
+
return h(this, Re, "frac"), this;
|
|
267
266
|
}
|
|
268
267
|
// ------------------------------------------
|
|
269
268
|
get numerator() {
|
|
270
|
-
return s(this,
|
|
269
|
+
return s(this, v);
|
|
271
270
|
}
|
|
272
271
|
set numerator(e) {
|
|
273
|
-
h(this,
|
|
272
|
+
h(this, v, e);
|
|
274
273
|
}
|
|
275
274
|
// Display getter
|
|
276
275
|
get tex() {
|
|
277
|
-
return this.isInfinity() ? `${this.sign() === 1 ? "+" : "-"}\\infty` : this.isExact() ? s(this,
|
|
276
|
+
return this.isInfinity() ? `${this.sign() === 1 ? "+" : "-"}\\infty` : this.isExact() ? s(this, x) === 1 ? `${s(this, v)}` : s(this, v) < 0 ? `-\\${s(this, Re)}{ ${-s(this, v)} }{ ${s(this, x)} }` : `\\${s(this, Re)}{ ${s(this, v)} }{ ${s(this, x)} }` : this.value.toFixed(3);
|
|
278
277
|
}
|
|
279
278
|
get texWithSign() {
|
|
280
279
|
return this.isPositive() ? `+${this.tex}` : this.tex;
|
|
281
280
|
}
|
|
282
281
|
get tfrac() {
|
|
283
|
-
return h(this,
|
|
282
|
+
return h(this, Re, "tfrac"), this;
|
|
284
283
|
}
|
|
285
284
|
get value() {
|
|
286
|
-
const e = s(this,
|
|
285
|
+
const e = s(this, v) / s(this, x);
|
|
287
286
|
return e === 0 ? 0 : e;
|
|
288
287
|
}
|
|
289
288
|
};
|
|
290
|
-
|
|
291
|
-
const t = new
|
|
289
|
+
ut = new WeakMap(), x = new WeakMap(), v = new WeakMap(), Re = new WeakMap(), a(P, "average", (...e) => {
|
|
290
|
+
const t = new P().zero();
|
|
292
291
|
for (const i of e)
|
|
293
292
|
t.add(i);
|
|
294
293
|
return t.divide(e.length), t;
|
|
295
|
-
}), a(
|
|
296
|
-
let t = new
|
|
294
|
+
}), a(P, "max", (...e) => {
|
|
295
|
+
let t = new P(e[0]);
|
|
297
296
|
for (const i of e) {
|
|
298
|
-
const n = new
|
|
297
|
+
const n = new P(i);
|
|
299
298
|
n.isGreater(t) && (t = n.clone());
|
|
300
299
|
}
|
|
301
300
|
return t;
|
|
302
|
-
}), a(
|
|
303
|
-
let t = new
|
|
301
|
+
}), a(P, "min", (...e) => {
|
|
302
|
+
let t = new P(e[0]);
|
|
304
303
|
for (const i of e) {
|
|
305
|
-
const n = new
|
|
304
|
+
const n = new P(i);
|
|
306
305
|
n.isLesser(t) && (t = n.clone());
|
|
307
306
|
}
|
|
308
307
|
return t;
|
|
309
|
-
}), a(
|
|
310
|
-
const n = e.map((r) => r instanceof
|
|
308
|
+
}), a(P, "sort", (e, t) => {
|
|
309
|
+
const n = e.map((r) => r instanceof P ? r : new P(r)).sort((r, l) => r.value - l.value);
|
|
311
310
|
return t && n.reverse(), n;
|
|
312
311
|
}), // ------------------------------------------
|
|
313
312
|
// Compare functions
|
|
314
|
-
a(
|
|
313
|
+
a(P, "unique", (e) => {
|
|
315
314
|
const t = {}, i = [];
|
|
316
315
|
return e.forEach((n) => {
|
|
317
|
-
n instanceof
|
|
316
|
+
n instanceof P || (n = new P(n)), t[n.clone().reduce().tex] || (i.push(n.clone()), t[n.tex] = !0);
|
|
318
317
|
}), i;
|
|
319
|
-
}), a(
|
|
320
|
-
const t = new
|
|
318
|
+
}), a(P, "xMultiply", (...e) => {
|
|
319
|
+
const t = new P();
|
|
321
320
|
for (const i of e) {
|
|
322
|
-
const n = new
|
|
321
|
+
const n = new P(i);
|
|
323
322
|
t.numerator = t.numerator * n.numerator, t.denominator = t.denominator * n.denominator;
|
|
324
323
|
}
|
|
325
324
|
return t;
|
|
326
325
|
});
|
|
327
|
-
let u =
|
|
328
|
-
var Z,
|
|
329
|
-
class
|
|
326
|
+
let u = P;
|
|
327
|
+
var Z, ie, ne, Ye;
|
|
328
|
+
class vt {
|
|
330
329
|
constructor(...e) {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
330
|
+
m(this, Z);
|
|
331
|
+
m(this, ie);
|
|
332
|
+
m(this, ne);
|
|
333
|
+
m(this, Ye);
|
|
335
334
|
// ------------------------------------------
|
|
336
335
|
// Creation / parsing functions
|
|
337
336
|
// ------------------------------------------
|
|
338
|
-
a(this, "parse", (e, t, i) => (h(this, ne, i ?? 1), h(this,
|
|
337
|
+
a(this, "parse", (e, t, i) => (h(this, ne, i ?? 1), h(this, ie, t ?? 2), h(this, Z, e), s(this, ie) % 2 === 0 && s(this, Z) < 0 && h(this, Ye, !1), this));
|
|
339
338
|
// ------------------------------------------
|
|
340
339
|
// Mathematical operations
|
|
341
340
|
// ------------------------------------------
|
|
342
341
|
a(this, "reduce", () => {
|
|
343
|
-
let e = Math.floor(Math.pow(s(this, Z), 1 / s(this,
|
|
342
|
+
let e = Math.floor(Math.pow(s(this, Z), 1 / s(this, ie)));
|
|
344
343
|
for (; e > 1; ) {
|
|
345
|
-
if (s(this, Z) % Math.pow(e, s(this,
|
|
346
|
-
h(this, ne, s(this, ne) * e), h(this, Z, s(this, Z) / Math.pow(e, s(this,
|
|
344
|
+
if (s(this, Z) % Math.pow(e, s(this, ie)) === 0) {
|
|
345
|
+
h(this, ne, s(this, ne) * e), h(this, Z, s(this, Z) / Math.pow(e, s(this, ie))), e = Math.floor(Math.pow(s(this, Z), 1 / s(this, ie)));
|
|
347
346
|
continue;
|
|
348
347
|
}
|
|
349
348
|
e--;
|
|
@@ -355,7 +354,7 @@ class bt {
|
|
|
355
354
|
// Help functions
|
|
356
355
|
// ------------------------------------------
|
|
357
356
|
a(this, "hasRadical", () => !(s(this, Z) === 1 || s(this, Z) === 0 || !s(this, Ye)));
|
|
358
|
-
h(this, Z, 1), h(this, ne, 1), h(this,
|
|
357
|
+
h(this, Z, 1), h(this, ne, 1), h(this, ie, 2), h(this, Ye, !0), e.length > 0 && this.parse(e[0], e[1], e[2]);
|
|
359
358
|
}
|
|
360
359
|
// ------------------------------------------
|
|
361
360
|
// Getter and setter
|
|
@@ -367,10 +366,10 @@ class bt {
|
|
|
367
366
|
h(this, Z, e);
|
|
368
367
|
}
|
|
369
368
|
get nth() {
|
|
370
|
-
return s(this,
|
|
369
|
+
return s(this, ie);
|
|
371
370
|
}
|
|
372
371
|
set nth(e) {
|
|
373
|
-
Number.isSafeInteger(e) && e >= 2 ? h(this,
|
|
372
|
+
Number.isSafeInteger(e) && e >= 2 ? h(this, ie, e) : (console.log("Error setting the nth root"), h(this, ie, 2));
|
|
374
373
|
}
|
|
375
374
|
get coefficient() {
|
|
376
375
|
return s(this, ne);
|
|
@@ -380,261 +379,302 @@ class bt {
|
|
|
380
379
|
}
|
|
381
380
|
get tex() {
|
|
382
381
|
let e;
|
|
383
|
-
return s(this, ne) === 1 ? e = "" : s(this, ne) === -1 ? e = "-" : e = s(this, ne).toString(), s(this, Z) === 1 ? `${s(this, ne)}` : s(this,
|
|
382
|
+
return s(this, ne) === 1 ? e = "" : s(this, ne) === -1 ? e = "-" : e = s(this, ne).toString(), s(this, Z) === 1 ? `${s(this, ne)}` : s(this, ie) === 2 ? `${e}\\sqrt{${s(this, Z)}}` : `${e}\\sqrt[${s(this, ie)}]{${s(this, Z)}}`;
|
|
384
383
|
}
|
|
385
384
|
get display() {
|
|
386
385
|
let e;
|
|
387
|
-
return s(this, ne) === 1 ? e = "" : s(this, ne) === -1 ? e = "-" : e = s(this, ne).toString(), s(this, Z) === 1 ? `${s(this, ne)}` : s(this,
|
|
386
|
+
return s(this, ne) === 1 ? e = "" : s(this, ne) === -1 ? e = "-" : e = s(this, ne).toString(), s(this, Z) === 1 ? `${s(this, ne)}` : s(this, ie) === 2 ? `${e}sqrt{${s(this, Z)}}` : `${e}root(${s(this, ie)}){${s(this, Z)}}`;
|
|
388
387
|
}
|
|
389
388
|
get value() {
|
|
390
|
-
return s(this, ne) * Math.pow(s(this, Z), 1 / s(this,
|
|
389
|
+
return s(this, ne) * Math.pow(s(this, Z), 1 / s(this, ie));
|
|
391
390
|
}
|
|
392
391
|
}
|
|
393
|
-
Z = new WeakMap(),
|
|
394
|
-
var
|
|
395
|
-
const
|
|
392
|
+
Z = new WeakMap(), ie = new WeakMap(), ne = new WeakMap(), Ye = new WeakMap();
|
|
393
|
+
var K, Fe, C, Ge, ge, vi, bi, xi, Ei, Ni, Ai, Ti;
|
|
394
|
+
const pi = class pi {
|
|
396
395
|
constructor(e, t, i = "x") {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
if (h(this,
|
|
396
|
+
m(this, C);
|
|
397
|
+
m(this, K);
|
|
398
|
+
m(this, Fe);
|
|
399
|
+
if (h(this, Fe, i), Object.hasOwn(e, "moveLeft")) {
|
|
401
400
|
const n = e;
|
|
402
|
-
h(this,
|
|
401
|
+
h(this, K, n.left.clone().subtract(n.right));
|
|
403
402
|
} else
|
|
404
|
-
h(this,
|
|
403
|
+
h(this, K, e.clone().subtract(t ?? 0));
|
|
405
404
|
}
|
|
406
405
|
solve() {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
if (e
|
|
413
|
-
return
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
throw new Error("The equation degree is too high.");
|
|
406
|
+
const e = s(this, K).degree().value;
|
|
407
|
+
if (e === 0)
|
|
408
|
+
return [];
|
|
409
|
+
if (e === 1)
|
|
410
|
+
return A(this, C, Ni).call(this);
|
|
411
|
+
if (e === 2)
|
|
412
|
+
return A(this, C, Ai).call(this);
|
|
413
|
+
const t = A(this, C, xi).call(this);
|
|
414
|
+
return t.length > 0 ? t : A(this, C, vi).call(this);
|
|
417
415
|
}
|
|
418
416
|
solveAsCardan() {
|
|
419
|
-
if (s(this,
|
|
417
|
+
if (s(this, K).degree().value !== 3)
|
|
420
418
|
throw new Error("The equation is not cubic.");
|
|
421
|
-
return A(this,
|
|
419
|
+
return A(this, C, Ei).call(this);
|
|
422
420
|
}
|
|
423
421
|
};
|
|
424
|
-
|
|
422
|
+
K = new WeakMap(), Fe = new WeakMap(), C = new WeakSet(), Ge = function(e, t) {
|
|
425
423
|
return {
|
|
426
|
-
variable: s(this,
|
|
424
|
+
variable: s(this, Fe),
|
|
427
425
|
exact: !1,
|
|
428
426
|
value: +e.toFixed(10),
|
|
429
427
|
tex: (t == null ? void 0 : t.tex) ?? "",
|
|
430
428
|
display: (t == null ? void 0 : t.display) ?? ""
|
|
431
429
|
};
|
|
432
|
-
},
|
|
430
|
+
}, ge = function(e) {
|
|
433
431
|
if (e instanceof u && e.isApproximative())
|
|
434
|
-
return A(this,
|
|
432
|
+
return A(this, C, Ge).call(this, e.value);
|
|
435
433
|
const t = new u(e);
|
|
436
434
|
return {
|
|
437
|
-
variable: s(this,
|
|
435
|
+
variable: s(this, Fe),
|
|
438
436
|
exact: t,
|
|
439
437
|
value: t.value,
|
|
440
438
|
tex: t.tex,
|
|
441
439
|
display: t.display
|
|
442
440
|
};
|
|
443
|
-
},
|
|
444
|
-
|
|
441
|
+
}, vi = function() {
|
|
442
|
+
const e = [];
|
|
443
|
+
s(this, K).degree().value;
|
|
444
|
+
const t = s(this, K).getCoefficients().map((p) => p.value), [i, ...n] = s(this, K).getCoefficients(), r = 1 + Math.max(...n.map((p) => p.value / i.value)), c = 2 * r / 100, f = [];
|
|
445
|
+
for (let p = -r; p <= r; p += c) {
|
|
446
|
+
const w = U.numberCorrection(p);
|
|
447
|
+
f.push(
|
|
448
|
+
{
|
|
449
|
+
x: w,
|
|
450
|
+
fx: s(this, K).evaluate(w, !0)
|
|
451
|
+
}
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
f.sort((p, w) => p.x - w.x);
|
|
455
|
+
const d = [];
|
|
456
|
+
return f.forEach((p, w) => {
|
|
457
|
+
w > 0 && (p.fx === 0 ? d.push([p.x, p.x]) : f[w - 1].fx * p.fx < 0 && d.push([
|
|
458
|
+
f[w - 1].x,
|
|
459
|
+
p.x
|
|
460
|
+
]));
|
|
461
|
+
}), d.forEach((p) => {
|
|
462
|
+
const [w, V] = p;
|
|
463
|
+
if (w === V)
|
|
464
|
+
e.push(A(this, C, ge).call(this, w));
|
|
465
|
+
else {
|
|
466
|
+
const ce = A(this, C, bi).call(this, t, w, V);
|
|
467
|
+
ce !== null && e.push(A(this, C, Ge).call(this, ce));
|
|
468
|
+
}
|
|
469
|
+
}), e;
|
|
470
|
+
}, bi = function(e, t, i, n = 1e-10) {
|
|
471
|
+
let r = s(this, K).evaluate(t, !0), l = s(this, K).evaluate(i, !0);
|
|
472
|
+
if (r * l > 0)
|
|
473
|
+
return console.log("Pas de racine dans l'intervalle donné"), null;
|
|
474
|
+
let c;
|
|
475
|
+
for (; (i - t) / 2 > n; ) {
|
|
476
|
+
c = (t + i) / 2;
|
|
477
|
+
const f = s(this, K).evaluate(c, !0);
|
|
478
|
+
if (f === 0)
|
|
479
|
+
return c;
|
|
480
|
+
r * f < 0 ? (i = c, l = f) : (t = c, r = f);
|
|
481
|
+
}
|
|
482
|
+
return (t + i) / 2;
|
|
483
|
+
}, xi = function() {
|
|
484
|
+
let e = s(this, K).clone(), t = [];
|
|
445
485
|
const i = e.lcmDenominator();
|
|
446
486
|
i !== 1 && e.multiply(i);
|
|
447
487
|
const n = e.monomByDegree().coefficient;
|
|
448
488
|
let r = e.monomByDegree(0).coefficient;
|
|
449
489
|
for (; r.isZero(); )
|
|
450
|
-
t.length === 0 && t.push(A(this,
|
|
451
|
-
const l =
|
|
452
|
-
for (const
|
|
453
|
-
for (const
|
|
454
|
-
const
|
|
455
|
-
e.evaluate(
|
|
490
|
+
t.length === 0 && t.push(A(this, C, ge).call(this, 0)), e = e.divide("x"), r = e.monomByDegree(0).coefficient;
|
|
491
|
+
const l = U.dividers(n.value), c = U.dividers(r.value);
|
|
492
|
+
for (const d of l)
|
|
493
|
+
for (const p of c) {
|
|
494
|
+
const w = new u(p, d);
|
|
495
|
+
e.evaluate(w).isZero() && !t.find((V) => V.value === w.value) && t.push(A(this, C, ge).call(this, w)), w.opposite(), e.evaluate(w).isZero() && !t.find((V) => V.value === w.value) && t.push(A(this, C, ge).call(this, w));
|
|
456
496
|
}
|
|
457
|
-
for (const
|
|
458
|
-
if (
|
|
497
|
+
for (const d of t) {
|
|
498
|
+
if (d.exact !== !1 && d.exact.isZero())
|
|
459
499
|
continue;
|
|
460
|
-
const
|
|
461
|
-
for (; e.isDividableBy(
|
|
462
|
-
e = e.divide(
|
|
500
|
+
const p = s(this, K).clone().parse("x", d.exact.denominator, -d.exact.numerator);
|
|
501
|
+
for (; e.isDividableBy(p); )
|
|
502
|
+
e = e.divide(p);
|
|
463
503
|
}
|
|
464
504
|
if (e.degree().isZero())
|
|
465
|
-
return t.sort((
|
|
505
|
+
return t.sort((d, p) => d.value - p.value);
|
|
466
506
|
if (e.degree().value > 3)
|
|
467
507
|
return [];
|
|
468
|
-
const
|
|
469
|
-
return t = t.concat(
|
|
470
|
-
},
|
|
471
|
-
const e = s(this,
|
|
472
|
-
if (
|
|
473
|
-
const
|
|
474
|
-
return [A(this,
|
|
475
|
-
}
|
|
476
|
-
if (
|
|
477
|
-
const
|
|
478
|
-
return
|
|
479
|
-
A(this,
|
|
480
|
-
A(this,
|
|
481
|
-
].sort((me,
|
|
482
|
-
}
|
|
483
|
-
if (
|
|
484
|
-
const
|
|
485
|
-
for (let
|
|
486
|
-
|
|
487
|
-
return
|
|
508
|
+
const f = new pi(e, e.clone().parse("0"), s(this, Fe));
|
|
509
|
+
return t = t.concat(f.solve()), t.sort((d, p) => d.value - p.value);
|
|
510
|
+
}, Ei = function() {
|
|
511
|
+
const e = s(this, K), 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), f = r.clone().divide(t), d = c.clone().subtract(l.clone().pow(2).divide(3)), p = f.clone().subtract(l.clone().multiply(c).divide(3)).add(l.clone().pow(3).multiply(2).divide(27)), w = p.clone().opposite(), V = d.clone().opposite().pow(3).divide(27), ce = w.clone().pow(2).subtract(V.clone().multiply(4)).opposite();
|
|
512
|
+
if (ce.isNegative()) {
|
|
513
|
+
const ue = p.clone().opposite().add(ce.clone().opposite().sqrt()).divide(2).root(3), fe = p.clone().opposite().subtract(ce.clone().opposite().sqrt()).divide(2).root(3), ye = ue.clone().add(fe).subtract(l.clone().divide(3));
|
|
514
|
+
return [A(this, C, ge).call(this, ye)];
|
|
515
|
+
}
|
|
516
|
+
if (ce.isZero()) {
|
|
517
|
+
const ue = p.clone().opposite().divide(2).root(3), fe = ue.clone().opposite().subtract(l.clone().divide(3)), ye = ue.clone().multiply(2).subtract(l.clone().divide(3));
|
|
518
|
+
return fe.isEqual(ye) ? [A(this, C, ge).call(this, fe)] : [
|
|
519
|
+
A(this, C, ge).call(this, ye),
|
|
520
|
+
A(this, C, ge).call(this, fe)
|
|
521
|
+
].sort((me, de) => me.value - de.value);
|
|
522
|
+
}
|
|
523
|
+
if (ce.isPositive()) {
|
|
524
|
+
const ue = [], fe = d.value, ye = p.value, me = l.value;
|
|
525
|
+
for (let de = 0; de < 3; de++)
|
|
526
|
+
ue.push(2 * Math.sqrt(-fe / 3) * Math.cos(Math.acos(3 * ye / (2 * fe) * Math.sqrt(-3 / fe)) / 3 + 2 * Math.PI * de / 3) - me / 3);
|
|
527
|
+
return ue.map((de) => A(this, C, Ge).call(this, de)).sort((de, rt) => de.value - rt.value);
|
|
488
528
|
}
|
|
489
529
|
return [];
|
|
490
|
-
},
|
|
491
|
-
const e = s(this,
|
|
530
|
+
}, Ni = function() {
|
|
531
|
+
const [e, t] = s(this, K).getCoefficients(), i = t.opposite().divide(e);
|
|
492
532
|
return [
|
|
493
|
-
A(this,
|
|
533
|
+
A(this, C, ge).call(this, i)
|
|
494
534
|
];
|
|
495
|
-
},
|
|
496
|
-
const e = s(this,
|
|
535
|
+
}, Ai = function() {
|
|
536
|
+
const e = s(this, K), [t, i, n] = e.getCoefficients(), r = i.clone().pow(2).subtract(t.clone().multiply(n).multiply(4));
|
|
497
537
|
if (r.isNegative())
|
|
498
538
|
return [];
|
|
499
539
|
if (r.isSquare()) {
|
|
500
|
-
const l = r.sqrt(), c = i.clone().opposite().add(l).divide(t.clone().multiply(2)),
|
|
501
|
-
return l.isZero() ? [A(this,
|
|
502
|
-
A(this,
|
|
503
|
-
A(this,
|
|
504
|
-
].sort((
|
|
505
|
-
}
|
|
506
|
-
return A(this,
|
|
507
|
-
},
|
|
508
|
-
const n =
|
|
509
|
-
function V(me,
|
|
510
|
-
return `\\frac{ ${
|
|
511
|
-
}
|
|
512
|
-
function
|
|
513
|
-
return `(${
|
|
514
|
-
}
|
|
515
|
-
const
|
|
540
|
+
const l = r.sqrt(), c = i.clone().opposite().add(l).divide(t.clone().multiply(2)), f = i.clone().opposite().subtract(l).divide(t.clone().multiply(2));
|
|
541
|
+
return l.isZero() ? [A(this, C, ge).call(this, c)] : [
|
|
542
|
+
A(this, C, ge).call(this, c),
|
|
543
|
+
A(this, C, ge).call(this, f)
|
|
544
|
+
].sort((d, p) => d.value - p.value);
|
|
545
|
+
}
|
|
546
|
+
return A(this, C, Ti).call(this, t, i, r);
|
|
547
|
+
}, Ti = function(e, t, i) {
|
|
548
|
+
const n = U.dividers(i.value).filter((me) => Math.sqrt(me) % 1 === 0).map((me) => Math.sqrt(me)).pop() ?? 1, r = U.gcd(2 * e.value, t.value, n) * (e.isNegative() ? -1 : 1), l = t.clone().divide(r).opposite(), c = e.clone().divide(r).multiply(2), f = i.clone().divide(n ** 2), d = Math.abs(n / r), p = n === 1 ? "-" : `-${d} `, w = n === 1 ? "+" : `+${d} `;
|
|
549
|
+
function V(me, de, rt, Jt) {
|
|
550
|
+
return `\\frac{ ${de} ${rt}\\sqrt{ ${Jt} } }{ ${me} }`;
|
|
551
|
+
}
|
|
552
|
+
function ce(me, de, rt, Jt) {
|
|
553
|
+
return `(${de}${rt}sqrt(${Jt}))/${me}`;
|
|
554
|
+
}
|
|
555
|
+
const ue = i.value ** 0.5, fe = (-t.value - ue) / (2 * e.value), ye = (-t.value + ue) / (2 * e.value);
|
|
516
556
|
return [
|
|
517
|
-
A(this,
|
|
518
|
-
tex: V(c.tex, l.tex,
|
|
519
|
-
display:
|
|
557
|
+
A(this, C, Ge).call(this, fe, {
|
|
558
|
+
tex: V(c.tex, l.tex, p.toString(), f.tex),
|
|
559
|
+
display: ce(c.display, l.display, p.toString(), f.display)
|
|
520
560
|
}),
|
|
521
|
-
A(this,
|
|
522
|
-
tex: V(c.tex, l.tex,
|
|
523
|
-
display:
|
|
561
|
+
A(this, C, Ge).call(this, ye, {
|
|
562
|
+
tex: V(c.tex, l.tex, w.toString(), f.tex),
|
|
563
|
+
display: ce(c.display, l.display, w.toString(), f.display)
|
|
524
564
|
})
|
|
525
|
-
].sort((me,
|
|
565
|
+
].sort((me, de) => me.value - de.value);
|
|
526
566
|
};
|
|
527
|
-
let
|
|
528
|
-
var
|
|
567
|
+
let At = pi;
|
|
568
|
+
var Xi = Object.defineProperty, Oi = (o) => {
|
|
529
569
|
throw TypeError(o);
|
|
530
|
-
},
|
|
531
|
-
const
|
|
570
|
+
}, Yi = (o, e, t) => e in o ? Xi(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, ei = (o, e, t) => Yi(o, typeof e != "symbol" ? e + "" : e, t), qi = (o, e, t) => e.has(o) || Oi("Cannot " + t), te = (o, e, t) => (qi(o, e, "read from private field"), t ? t.call(o) : e.get(o)), ot = (o, e, t) => e.has(o) ? Oi("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), Ee = (o, e, t, i) => (qi(o, e, "write to private field"), e.set(o, t), t);
|
|
571
|
+
const fi = {
|
|
532
572
|
pi: Math.PI,
|
|
533
573
|
e: Math.exp(1)
|
|
534
574
|
};
|
|
535
|
-
var
|
|
536
|
-
function
|
|
575
|
+
var g = /* @__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))(g || {}), Ze = /* @__PURE__ */ ((o) => (o.EXPRESSION = "expression", o.POLYNOM = "polynom", o.SET = "set", o.NUMERIC = "numeric", o))(Ze || {});
|
|
576
|
+
function Qi(o, e) {
|
|
537
577
|
if (o.length <= 1)
|
|
538
578
|
return o;
|
|
539
|
-
const t = Object.keys(e).filter((
|
|
540
|
-
t.sort((
|
|
541
|
-
const i = new RegExp(`^(${t.join("|")})\\(`), n = Object.keys(
|
|
542
|
-
n.sort((
|
|
579
|
+
const t = Object.keys(e).filter((w) => e[w].type === g.FUNCTION).map((w) => w);
|
|
580
|
+
t.sort((w, V) => V.length - w.length);
|
|
581
|
+
const i = new RegExp(`^(${t.join("|")})\\(`), n = Object.keys(fi);
|
|
582
|
+
n.sort((w, V) => V.length - w.length);
|
|
543
583
|
const r = new RegExp(`^(${n.join("|")})`), l = /^(\d+(\.\d+)?)/;
|
|
544
|
-
let c = "",
|
|
584
|
+
let c = "", f, d, p;
|
|
545
585
|
for (; o.length > 0; ) {
|
|
546
|
-
if (
|
|
547
|
-
const
|
|
548
|
-
|
|
586
|
+
if (f = d, p = void 0, t.length > 0 && i.exec(o)) {
|
|
587
|
+
const w = t.find((V) => o.startsWith(V));
|
|
588
|
+
w && (p = w + "(", o = o.slice(w.length + 1), d = g.FUNCTION);
|
|
549
589
|
} else if (n.length > 0 && r.exec(o)) {
|
|
550
|
-
const
|
|
551
|
-
|
|
590
|
+
const w = n.find((V) => o.startsWith(V));
|
|
591
|
+
w && (p = w, o = o.slice(w.length), d = g.CONSTANT);
|
|
552
592
|
} else if (l.exec(o)) {
|
|
553
|
-
const
|
|
554
|
-
|
|
593
|
+
const w = l.exec(o);
|
|
594
|
+
w && (p = w[0], o = o.slice(w[0].length), d = g.COEFFICIENT);
|
|
555
595
|
} else
|
|
556
|
-
switch (
|
|
596
|
+
switch (p = o[0], o = o.slice(1), p) {
|
|
557
597
|
case "(":
|
|
558
|
-
|
|
598
|
+
d = g.LEFT_PARENTHESIS;
|
|
559
599
|
break;
|
|
560
600
|
case ")":
|
|
561
|
-
|
|
601
|
+
d = g.RIGHT_PARENTHESIS;
|
|
562
602
|
break;
|
|
563
603
|
case ",":
|
|
564
|
-
|
|
604
|
+
d = g.FUNCTION_ARGUMENT;
|
|
565
605
|
break;
|
|
566
606
|
case "+":
|
|
567
607
|
case "-":
|
|
568
608
|
case "*":
|
|
569
609
|
case "/":
|
|
570
610
|
case "^":
|
|
571
|
-
|
|
611
|
+
d = g.OPERATION;
|
|
572
612
|
break;
|
|
573
613
|
default:
|
|
574
|
-
|
|
614
|
+
d = g.VARIABLE;
|
|
575
615
|
}
|
|
576
|
-
if (
|
|
616
|
+
if (p === void 0 || d === void 0)
|
|
577
617
|
throw new Error("The token is undefined");
|
|
578
|
-
c +=
|
|
618
|
+
c += Ki(f, d), c += p;
|
|
579
619
|
}
|
|
580
620
|
return c;
|
|
581
621
|
}
|
|
582
|
-
function
|
|
583
|
-
return o === void 0 || o ===
|
|
622
|
+
function Ki(o, e) {
|
|
623
|
+
return o === void 0 || o === g.OPERATION || e === g.OPERATION || o === g.LEFT_PARENTHESIS || o === g.FUNCTION || o === g.FUNCTION_ARGUMENT || e === g.RIGHT_PARENTHESIS || e === g.FUNCTION_ARGUMENT ? "" : "*";
|
|
584
624
|
}
|
|
585
|
-
const
|
|
586
|
-
"^": { precedence: 4, associative: "right", type:
|
|
587
|
-
"*": { precedence: 3, associative: "left", type:
|
|
588
|
-
"/": { precedence: 3, associative: "left", type:
|
|
589
|
-
"+": { precedence: 2, associative: "left", type:
|
|
590
|
-
"-": { precedence: 2, associative: "left", type:
|
|
591
|
-
}, Ki = {
|
|
592
|
-
"^": { precedence: 4, associative: "right", type: m.OPERATION },
|
|
593
|
-
"*": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
594
|
-
"/": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
595
|
-
"+": { precedence: 2, associative: "left", type: m.OPERATION },
|
|
596
|
-
"-": { precedence: 2, associative: "left", type: m.OPERATION },
|
|
597
|
-
"%": { precedence: 3, associative: "right", type: m.OPERATION },
|
|
598
|
-
sin: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
599
|
-
cos: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
600
|
-
tan: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
601
|
-
sqrt: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
602
|
-
nthrt: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
603
|
-
",": { precedence: 2, associative: "left", type: m.FUNCTION_ARGUMENT }
|
|
604
|
-
}, Ji = {
|
|
605
|
-
"^": { precedence: 4, associative: "right", type: m.OPERATION },
|
|
606
|
-
"*": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
607
|
-
"/": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
608
|
-
"+": { precedence: 2, associative: "left", type: m.OPERATION },
|
|
609
|
-
"-": { precedence: 2, associative: "left", type: m.OPERATION },
|
|
610
|
-
"%": { precedence: 3, associative: "right", type: m.OPERATION },
|
|
611
|
-
sin: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
612
|
-
cos: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
613
|
-
tan: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
614
|
-
sqrt: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
615
|
-
nthrt: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
616
|
-
ln: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
617
|
-
log: { precedence: 4, associative: "right", type: m.FUNCTION }
|
|
625
|
+
const Ji = {
|
|
626
|
+
"^": { precedence: 4, associative: "right", type: g.OPERATION },
|
|
627
|
+
"*": { precedence: 3, associative: "left", type: g.OPERATION },
|
|
628
|
+
"/": { precedence: 3, associative: "left", type: g.OPERATION },
|
|
629
|
+
"+": { precedence: 2, associative: "left", type: g.OPERATION },
|
|
630
|
+
"-": { precedence: 2, associative: "left", type: g.OPERATION }
|
|
618
631
|
}, _i = {
|
|
619
|
-
"
|
|
620
|
-
"
|
|
621
|
-
"
|
|
622
|
-
"
|
|
632
|
+
"^": { precedence: 4, associative: "right", type: g.OPERATION },
|
|
633
|
+
"*": { precedence: 3, associative: "left", type: g.OPERATION },
|
|
634
|
+
"/": { precedence: 3, associative: "left", type: g.OPERATION },
|
|
635
|
+
"+": { precedence: 2, associative: "left", type: g.OPERATION },
|
|
636
|
+
"-": { precedence: 2, associative: "left", type: g.OPERATION },
|
|
637
|
+
"%": { precedence: 3, associative: "right", type: g.OPERATION },
|
|
638
|
+
sin: { precedence: 4, associative: "right", type: g.FUNCTION },
|
|
639
|
+
cos: { precedence: 4, associative: "right", type: g.FUNCTION },
|
|
640
|
+
tan: { precedence: 4, associative: "right", type: g.FUNCTION },
|
|
641
|
+
sqrt: { precedence: 4, associative: "right", type: g.FUNCTION },
|
|
642
|
+
nthrt: { precedence: 4, associative: "right", type: g.FUNCTION },
|
|
643
|
+
",": { precedence: 2, associative: "left", type: g.FUNCTION_ARGUMENT }
|
|
644
|
+
}, es = {
|
|
645
|
+
"^": { precedence: 4, associative: "right", type: g.OPERATION },
|
|
646
|
+
"*": { precedence: 3, associative: "left", type: g.OPERATION },
|
|
647
|
+
"/": { precedence: 3, associative: "left", type: g.OPERATION },
|
|
648
|
+
"+": { precedence: 2, associative: "left", type: g.OPERATION },
|
|
649
|
+
"-": { precedence: 2, associative: "left", type: g.OPERATION },
|
|
650
|
+
"%": { precedence: 3, associative: "right", type: g.OPERATION },
|
|
651
|
+
sin: { precedence: 4, associative: "right", type: g.FUNCTION },
|
|
652
|
+
cos: { precedence: 4, associative: "right", type: g.FUNCTION },
|
|
653
|
+
tan: { precedence: 4, associative: "right", type: g.FUNCTION },
|
|
654
|
+
sqrt: { precedence: 4, associative: "right", type: g.FUNCTION },
|
|
655
|
+
nthrt: { precedence: 4, associative: "right", type: g.FUNCTION },
|
|
656
|
+
ln: { precedence: 4, associative: "right", type: g.FUNCTION },
|
|
657
|
+
log: { precedence: 4, associative: "right", type: g.FUNCTION }
|
|
658
|
+
}, ts = {
|
|
659
|
+
"&": { precedence: 3, associative: "left", type: g.OPERATION },
|
|
660
|
+
"|": { precedence: 3, associative: "left", type: g.OPERATION },
|
|
661
|
+
"!": { precedence: 4, associative: "right", type: g.OPERATION },
|
|
662
|
+
"-": { precedence: 2, associative: "left", type: g.OPERATION }
|
|
623
663
|
};
|
|
624
|
-
var He,
|
|
664
|
+
var He, at, se, bt, Ve;
|
|
625
665
|
class Kt {
|
|
626
666
|
constructor(e) {
|
|
627
|
-
ot(this, He), ot(this,
|
|
667
|
+
ot(this, He), ot(this, at, []), ot(this, se, {}), ot(this, bt, []), ot(this, Ve), Ee(this, He, typeof e > "u" ? Ze.POLYNOM : e), this.tokenConfigInitialization();
|
|
628
668
|
}
|
|
629
669
|
// Getter
|
|
630
670
|
get rpn() {
|
|
631
|
-
return
|
|
671
|
+
return te(this, at);
|
|
632
672
|
}
|
|
633
673
|
get rpnToken() {
|
|
634
|
-
return
|
|
674
|
+
return te(this, at).map((e) => e.token);
|
|
635
675
|
}
|
|
636
676
|
tokenConfigInitialization() {
|
|
637
|
-
return
|
|
677
|
+
return te(this, He) === Ze.SET ? (Ee(this, se, ts), Ee(this, Ve, !1)) : te(this, He) === Ze.NUMERIC ? (Ee(this, se, es), Ee(this, Ve, !0)) : te(this, He) === Ze.EXPRESSION ? (Ee(this, se, _i), Ee(this, Ve, !0)) : (Ee(this, se, Ji), Ee(this, Ve, !0)), Ee(this, bt, Object.keys(te(this, se)).sort((e, t) => t.length - e.length)), te(this, se);
|
|
638
678
|
}
|
|
639
679
|
/**
|
|
640
680
|
* Get the next token to analyse.
|
|
@@ -644,31 +684,31 @@ class Kt {
|
|
|
644
684
|
NextToken(e, t) {
|
|
645
685
|
let i, n;
|
|
646
686
|
if (i = "", n = void 0, e[t] === "(")
|
|
647
|
-
i = "(", n =
|
|
687
|
+
i = "(", n = g.LEFT_PARENTHESIS;
|
|
648
688
|
else if (e[t] === ")")
|
|
649
|
-
i = ")", n =
|
|
689
|
+
i = ")", n = g.RIGHT_PARENTHESIS;
|
|
650
690
|
else if (e[t] === ",")
|
|
651
|
-
i = ",", n =
|
|
691
|
+
i = ",", n = g.FUNCTION_ARGUMENT;
|
|
652
692
|
else {
|
|
653
|
-
for (const r of
|
|
693
|
+
for (const r of te(this, bt))
|
|
654
694
|
if (e.substring(t, t + r.length) === r) {
|
|
655
|
-
i += r, n =
|
|
695
|
+
i += r, n = te(this, se)[r].type;
|
|
656
696
|
break;
|
|
657
697
|
}
|
|
658
|
-
for (const r in
|
|
698
|
+
for (const r in fi)
|
|
659
699
|
if (e.substring(t, t + r.length) === r) {
|
|
660
|
-
i += r, n =
|
|
700
|
+
i += r, n = g.CONSTANT;
|
|
661
701
|
break;
|
|
662
702
|
}
|
|
663
703
|
if (i === "")
|
|
664
704
|
if (/[0-9.]/.exec(e[t])) {
|
|
665
705
|
const r = /^([0-9.]+)/.exec(e.substring(t));
|
|
666
|
-
i = r ? r[0] : "", n =
|
|
706
|
+
i = r ? r[0] : "", n = g.COEFFICIENT;
|
|
667
707
|
} else if (/[a-zA-Z]/.exec(e[t])) {
|
|
668
708
|
const r = /^([a-zA-Z])/.exec(e.substring(t));
|
|
669
|
-
i = r ? r[0] : "", n =
|
|
709
|
+
i = r ? r[0] : "", n = g.VARIABLE;
|
|
670
710
|
} else
|
|
671
|
-
console.log("Unidentified token", e[t], e, t), i = e[t], n =
|
|
711
|
+
console.log("Unidentified token", e[t], e, t), i = e[t], n = g.MONOM;
|
|
672
712
|
}
|
|
673
713
|
if (n === void 0)
|
|
674
714
|
throw new Error(`Token type is undefined for token ${i}`);
|
|
@@ -683,56 +723,56 @@ class Kt {
|
|
|
683
723
|
parse(e, t) {
|
|
684
724
|
const i = [], n = [];
|
|
685
725
|
let r = "", l = 0, c;
|
|
686
|
-
(t ??
|
|
687
|
-
const
|
|
688
|
-
let
|
|
726
|
+
(t ?? te(this, Ve)) && (e = Qi(e, te(this, se)));
|
|
727
|
+
const f = 50;
|
|
728
|
+
let d = 50, p;
|
|
689
729
|
for (; l < e.length; ) {
|
|
690
|
-
if (
|
|
730
|
+
if (d--, d === 0) {
|
|
691
731
|
console.log("SECURITY LEVEL 1 EXIT");
|
|
692
732
|
break;
|
|
693
733
|
}
|
|
694
734
|
switch ([r, l, c] = this.NextToken(e, l), c) {
|
|
695
|
-
case
|
|
696
|
-
case
|
|
697
|
-
case
|
|
698
|
-
case
|
|
735
|
+
case g.MONOM:
|
|
736
|
+
case g.COEFFICIENT:
|
|
737
|
+
case g.VARIABLE:
|
|
738
|
+
case g.CONSTANT:
|
|
699
739
|
i.push({
|
|
700
740
|
token: r,
|
|
701
741
|
tokenType: c
|
|
702
742
|
});
|
|
703
743
|
break;
|
|
704
|
-
case
|
|
744
|
+
case g.OPERATION:
|
|
705
745
|
if (n.length > 0) {
|
|
706
|
-
let
|
|
707
|
-
for (
|
|
708
|
-
(
|
|
709
|
-
|
|
710
|
-
if (
|
|
746
|
+
let w = n[n.length - 1];
|
|
747
|
+
for (p = +f; w.token in te(this, se) && //either o1 is left-associative and its precedence is less than or equal to that of o2,
|
|
748
|
+
(te(this, se)[r].associative === "left" && te(this, se)[r].precedence <= te(this, se)[w.token].precedence || //or o1 is right associative, and has precedence less than that of o2,
|
|
749
|
+
te(this, se)[r].associative === "right" && te(this, se)[r].precedence < te(this, se)[w.token].precedence); ) {
|
|
750
|
+
if (p--, p === 0) {
|
|
711
751
|
console.log("SECURITY LEVEL 2 OPERATION EXIT");
|
|
712
752
|
break;
|
|
713
753
|
}
|
|
714
|
-
if (i.push(n.pop() ?? { token: "", tokenType:
|
|
754
|
+
if (i.push(n.pop() ?? { token: "", tokenType: g.OPERATION }), n.length === 0)
|
|
715
755
|
break;
|
|
716
|
-
|
|
756
|
+
w = n[n.length - 1];
|
|
717
757
|
}
|
|
718
758
|
}
|
|
719
759
|
n.push({ token: r, tokenType: c });
|
|
720
760
|
break;
|
|
721
|
-
case
|
|
722
|
-
for (
|
|
723
|
-
if (
|
|
761
|
+
case g.FUNCTION_ARGUMENT:
|
|
762
|
+
for (p = +f; n[n.length - 1].token !== "(" && n.length > 0; ) {
|
|
763
|
+
if (p--, p === 0) {
|
|
724
764
|
console.log("SECURITY LEVEL 2 FUNCTION ARGUMENT EXIT");
|
|
725
765
|
break;
|
|
726
766
|
}
|
|
727
767
|
i.push(n.pop() ?? { token: r, tokenType: c });
|
|
728
768
|
}
|
|
729
769
|
break;
|
|
730
|
-
case
|
|
731
|
-
n.push({ token: r, tokenType: c }), e[l] === "-" && i.push({ token: "0", tokenType:
|
|
770
|
+
case g.LEFT_PARENTHESIS:
|
|
771
|
+
n.push({ token: r, tokenType: c }), e[l] === "-" && i.push({ token: "0", tokenType: g.COEFFICIENT });
|
|
732
772
|
break;
|
|
733
|
-
case
|
|
734
|
-
for (
|
|
735
|
-
if (
|
|
773
|
+
case g.RIGHT_PARENTHESIS:
|
|
774
|
+
for (p = +f; n[n.length - 1].token !== "(" && n.length > 1; ) {
|
|
775
|
+
if (p--, p === 0) {
|
|
736
776
|
console.log("SECURITY LEVEL 2 CLOSING PARENTHESIS EXIT");
|
|
737
777
|
break;
|
|
738
778
|
}
|
|
@@ -740,22 +780,22 @@ class Kt {
|
|
|
740
780
|
}
|
|
741
781
|
n.pop();
|
|
742
782
|
break;
|
|
743
|
-
case
|
|
783
|
+
case g.FUNCTION:
|
|
744
784
|
n.push({ token: r, tokenType: c });
|
|
745
785
|
break;
|
|
746
786
|
default:
|
|
747
787
|
throw new Error(`Token type ${r} is not handled`);
|
|
748
788
|
}
|
|
749
789
|
}
|
|
750
|
-
return
|
|
790
|
+
return Ee(this, at, i.concat(n.reverse())), this;
|
|
751
791
|
}
|
|
752
792
|
}
|
|
753
|
-
He = /* @__PURE__ */ new WeakMap(),
|
|
754
|
-
class
|
|
793
|
+
He = /* @__PURE__ */ new WeakMap(), at = /* @__PURE__ */ new WeakMap(), se = /* @__PURE__ */ new WeakMap(), bt = /* @__PURE__ */ new WeakMap(), Ve = /* @__PURE__ */ new WeakMap();
|
|
794
|
+
class is {
|
|
755
795
|
constructor(e, t) {
|
|
756
796
|
ei(this, "_rpn"), ei(this, "_expression"), ei(this, "_isValid"), this._expression = e;
|
|
757
797
|
try {
|
|
758
|
-
this._rpn = new Kt(
|
|
798
|
+
this._rpn = new Kt(Ze.NUMERIC).parse(e, t).rpn;
|
|
759
799
|
} catch {
|
|
760
800
|
throw this._rpn = null, this._isValid = !1, new Error(`There was a problem parsing: ${e}`);
|
|
761
801
|
}
|
|
@@ -784,7 +824,7 @@ class es {
|
|
|
784
824
|
return this._isValid = !1, 0;
|
|
785
825
|
this._isValid = !0;
|
|
786
826
|
for (const i of this._rpn)
|
|
787
|
-
if (i.tokenType ===
|
|
827
|
+
if (i.tokenType === g.COEFFICIENT)
|
|
788
828
|
if (!isNaN(+i.token))
|
|
789
829
|
t.push(+i.token);
|
|
790
830
|
else {
|
|
@@ -793,11 +833,11 @@ class es {
|
|
|
793
833
|
throw this._isValid = !1, new Error("This coefficient is not a fraction");
|
|
794
834
|
t.push(+n[0] / +n[1]);
|
|
795
835
|
}
|
|
796
|
-
else if (i.tokenType ===
|
|
836
|
+
else if (i.tokenType === g.VARIABLE && e !== void 0)
|
|
797
837
|
Object.hasOwn(e, i.token) && t.push(+e[i.token]);
|
|
798
|
-
else if (i.tokenType ===
|
|
799
|
-
t.push(
|
|
800
|
-
else if (i.tokenType ===
|
|
838
|
+
else if (i.tokenType === g.CONSTANT)
|
|
839
|
+
t.push(fi[i.token]);
|
|
840
|
+
else if (i.tokenType === g.OPERATION) {
|
|
801
841
|
if (i.token === "*") {
|
|
802
842
|
const n = t.pop(), r = t.pop();
|
|
803
843
|
if (r === void 0 || n === void 0)
|
|
@@ -824,7 +864,7 @@ class es {
|
|
|
824
864
|
throw this._isValid = !1, new Error(`The base value ${r ?? "a"} or exponent ${n ?? "b"} are not defined`);
|
|
825
865
|
t.push(Math.pow(r, n));
|
|
826
866
|
}
|
|
827
|
-
} else if (i.tokenType ===
|
|
867
|
+
} else if (i.tokenType === g.FUNCTION) {
|
|
828
868
|
const n = t.pop();
|
|
829
869
|
if (n === void 0)
|
|
830
870
|
throw this._isValid = !1, new Error(`The parameters for ${i.token} is not defined`);
|
|
@@ -851,20 +891,20 @@ class es {
|
|
|
851
891
|
return +e.toFixed(t);
|
|
852
892
|
}
|
|
853
893
|
}
|
|
854
|
-
var
|
|
894
|
+
var T, b, Qe, xt, ze, Mt, kt;
|
|
855
895
|
const I = class I {
|
|
856
896
|
constructor(e) {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
897
|
+
m(this, Qe);
|
|
898
|
+
m(this, T);
|
|
899
|
+
m(this, b);
|
|
860
900
|
/**
|
|
861
901
|
* Clone the current Monom.
|
|
862
902
|
*/
|
|
863
903
|
a(this, "clone", () => {
|
|
864
904
|
const e = new I();
|
|
865
|
-
e.coefficient = s(this,
|
|
866
|
-
for (const t in s(this,
|
|
867
|
-
e.setLetter(t, s(this,
|
|
905
|
+
e.coefficient = s(this, T).clone();
|
|
906
|
+
for (const t in s(this, b))
|
|
907
|
+
e.setLetter(t, s(this, b)[t].clone());
|
|
868
908
|
return e;
|
|
869
909
|
});
|
|
870
910
|
/**
|
|
@@ -874,24 +914,24 @@ const I = class I {
|
|
|
874
914
|
a(this, "add", (...e) => {
|
|
875
915
|
for (const t of e) {
|
|
876
916
|
const i = t instanceof I ? t : new I(t);
|
|
877
|
-
this.isSameAs(i) ? (this.isZero() && A(this, Qe,
|
|
917
|
+
this.isSameAs(i) ? (this.isZero() && A(this, Qe, xt).call(this, i), s(this, T).add(i.coefficient)) : console.log("Add monom: " + this.display + " is not similar with ", i.display);
|
|
878
918
|
}
|
|
879
919
|
return this;
|
|
880
920
|
});
|
|
881
|
-
a(this, "containsRationalPower", () => Object.values(s(this,
|
|
921
|
+
a(this, "containsRationalPower", () => Object.values(s(this, b)).some((e) => e.isRational()));
|
|
882
922
|
/**
|
|
883
923
|
* Get the degree of a monom. If no setLetter is given, the result will be the global degree.
|
|
884
924
|
* @param letter (string) Letter to get to degree (power)
|
|
885
925
|
*/
|
|
886
|
-
a(this, "degree", (e) => this.variables.length === 0 ? new u().zero() : e === void 0 ? Object.values(s(this,
|
|
926
|
+
a(this, "degree", (e) => this.variables.length === 0 ? new u().zero() : e === void 0 ? Object.values(s(this, b)).reduce((t, i) => t.clone().add(i)) : this.hasVariable(e) ? s(this, b)[e].clone() : new u().zero());
|
|
887
927
|
/**
|
|
888
928
|
* Derivative the monom
|
|
889
929
|
* @param letter
|
|
890
930
|
*/
|
|
891
931
|
a(this, "derivative", (e) => {
|
|
892
932
|
if (e === void 0 && (e = "x"), this.hasVariable(e)) {
|
|
893
|
-
const t = s(this,
|
|
894
|
-
return s(i,
|
|
933
|
+
const t = s(this, b)[e].clone(), i = this.clone();
|
|
934
|
+
return s(i, b)[e].subtract(1), s(i, T).multiply(new u(t.clone())), i;
|
|
895
935
|
} else
|
|
896
936
|
return new I().zero();
|
|
897
937
|
});
|
|
@@ -902,9 +942,9 @@ const I = class I {
|
|
|
902
942
|
a(this, "divide", (...e) => {
|
|
903
943
|
for (const t of e) {
|
|
904
944
|
const i = t instanceof I ? t : new I(t);
|
|
905
|
-
s(this,
|
|
945
|
+
s(this, T).divide(i.coefficient);
|
|
906
946
|
for (const n in i.literal)
|
|
907
|
-
s(this,
|
|
947
|
+
s(this, b)[n] = this.hasVariable(n) ? s(this, b)[n].subtract(i.literal[n]) : i.literal[n].clone().opposite(), s(this, b)[n].isZero() && this.removeVariable(n);
|
|
908
948
|
}
|
|
909
949
|
return this;
|
|
910
950
|
});
|
|
@@ -916,16 +956,16 @@ const I = class I {
|
|
|
916
956
|
a(this, "evaluate", (e, t) => {
|
|
917
957
|
if (t === !0) {
|
|
918
958
|
if (e instanceof u)
|
|
919
|
-
return s(this,
|
|
920
|
-
if (e instanceof
|
|
959
|
+
return s(this, ze).call(this, e.value);
|
|
960
|
+
if (e instanceof vt)
|
|
921
961
|
return new u().invalid();
|
|
922
962
|
if (typeof e == "number")
|
|
923
|
-
return s(this,
|
|
963
|
+
return s(this, ze).call(this, e);
|
|
924
964
|
if (typeof e == "object") {
|
|
925
965
|
const n = {};
|
|
926
966
|
for (const r in e)
|
|
927
967
|
n[r] = new u(e[r]).value;
|
|
928
|
-
return s(this,
|
|
968
|
+
return s(this, ze).call(this, n);
|
|
929
969
|
}
|
|
930
970
|
}
|
|
931
971
|
const i = this.coefficient.clone();
|
|
@@ -933,14 +973,14 @@ const I = class I {
|
|
|
933
973
|
const n = {};
|
|
934
974
|
return n[this.variables[0]] = new u(e), this.evaluate(n);
|
|
935
975
|
}
|
|
936
|
-
if (e instanceof
|
|
976
|
+
if (e instanceof vt)
|
|
937
977
|
return new u().invalid();
|
|
938
978
|
if (typeof e == "object") {
|
|
939
979
|
if (this.variables.length === 0)
|
|
940
980
|
return this.coefficient;
|
|
941
|
-
for (const n in s(this,
|
|
981
|
+
for (const n in s(this, b)) {
|
|
942
982
|
const r = new u(e[n]);
|
|
943
|
-
i.multiply(r.pow(s(this,
|
|
983
|
+
i.multiply(r.pow(s(this, b)[n]));
|
|
944
984
|
}
|
|
945
985
|
}
|
|
946
986
|
return i;
|
|
@@ -950,11 +990,11 @@ const I = class I {
|
|
|
950
990
|
* Determine if a monom contains a setLetter in it's literal part
|
|
951
991
|
* @param letter
|
|
952
992
|
*/
|
|
953
|
-
a(this, "hasVariable", (e) => Object.hasOwn(s(this,
|
|
993
|
+
a(this, "hasVariable", (e) => Object.hasOwn(s(this, b), e ?? "x"));
|
|
954
994
|
a(this, "inverse", () => {
|
|
955
|
-
s(this,
|
|
956
|
-
for (const e in s(this,
|
|
957
|
-
s(this,
|
|
995
|
+
s(this, T).opposite();
|
|
996
|
+
for (const e in s(this, b))
|
|
997
|
+
s(this, b)[e].opposite();
|
|
958
998
|
return this;
|
|
959
999
|
});
|
|
960
1000
|
a(this, "isDivisible", (e) => {
|
|
@@ -969,7 +1009,7 @@ const I = class I {
|
|
|
969
1009
|
* Determine if two monoms are equals
|
|
970
1010
|
* @param M
|
|
971
1011
|
*/
|
|
972
|
-
a(this, "isEqual", (e) => this.isSameAs(e) && s(this,
|
|
1012
|
+
a(this, "isEqual", (e) => this.isSameAs(e) && s(this, T).isEqual(e.coefficient));
|
|
973
1013
|
a(this, "isLiteralSquare", () => {
|
|
974
1014
|
for (const e in this.literal)
|
|
975
1015
|
if (this.literal[e].isRational() || this.literal[e].isEven())
|
|
@@ -979,7 +1019,7 @@ const I = class I {
|
|
|
979
1019
|
/**
|
|
980
1020
|
* Determine if the monom is one
|
|
981
1021
|
*/
|
|
982
|
-
a(this, "isOne", () => s(this,
|
|
1022
|
+
a(this, "isOne", () => s(this, T).value === 1 && this.variables.length === 0);
|
|
983
1023
|
/**
|
|
984
1024
|
* Determine if two monoms are similar
|
|
985
1025
|
* @param M
|
|
@@ -992,7 +1032,7 @@ const I = class I {
|
|
|
992
1032
|
return !1;
|
|
993
1033
|
if (!this.isZero() && !e.isZero()) {
|
|
994
1034
|
for (const r of n)
|
|
995
|
-
if (!this.hasVariable(r) || !e.hasVariable(r) || !s(this,
|
|
1035
|
+
if (!this.hasVariable(r) || !e.hasVariable(r) || !s(this, b)[r].isEqual(e.literal[r]))
|
|
996
1036
|
return !1;
|
|
997
1037
|
}
|
|
998
1038
|
return !0;
|
|
@@ -1001,7 +1041,7 @@ const I = class I {
|
|
|
1001
1041
|
/**
|
|
1002
1042
|
* Determine if the monom is null
|
|
1003
1043
|
*/
|
|
1004
|
-
a(this, "isZero", () => s(this,
|
|
1044
|
+
a(this, "isZero", () => s(this, T).value === 0);
|
|
1005
1045
|
/**
|
|
1006
1046
|
* Multiple multiple monoms to the current monom
|
|
1007
1047
|
* @param M (Monom[]) The monoms to multiply to.
|
|
@@ -1009,29 +1049,29 @@ const I = class I {
|
|
|
1009
1049
|
a(this, "multiply", (...e) => {
|
|
1010
1050
|
for (const t of e) {
|
|
1011
1051
|
const i = t instanceof I ? t : new I(t);
|
|
1012
|
-
s(this,
|
|
1052
|
+
s(this, T).multiply(i.coefficient);
|
|
1013
1053
|
for (const n in i.literal)
|
|
1014
|
-
this.hasVariable(n) ? s(this,
|
|
1054
|
+
this.hasVariable(n) ? s(this, b)[n].add(i.literal[n]) : s(this, b)[n] = i.literal[n].clone();
|
|
1015
1055
|
}
|
|
1016
1056
|
return this;
|
|
1017
1057
|
});
|
|
1018
1058
|
/**
|
|
1019
1059
|
* Create a one value monom
|
|
1020
1060
|
*/
|
|
1021
|
-
a(this, "one", () => (h(this,
|
|
1061
|
+
a(this, "one", () => (h(this, T, new u().one()), h(this, b, {}), this));
|
|
1022
1062
|
/**
|
|
1023
1063
|
* Get the opposite
|
|
1024
1064
|
* Returns a monom.
|
|
1025
1065
|
*/
|
|
1026
|
-
a(this, "opposite", () => (s(this,
|
|
1066
|
+
a(this, "opposite", () => (s(this, T).opposite(), this));
|
|
1027
1067
|
/**
|
|
1028
1068
|
* Get the pow of a monom.
|
|
1029
1069
|
* @param nb (number) : Mathematical pow
|
|
1030
1070
|
*/
|
|
1031
1071
|
a(this, "pow", (e) => {
|
|
1032
|
-
s(this,
|
|
1033
|
-
for (const t in s(this,
|
|
1034
|
-
s(this,
|
|
1072
|
+
s(this, T).pow(e);
|
|
1073
|
+
for (const t in s(this, b))
|
|
1074
|
+
s(this, b)[t].multiply(e);
|
|
1035
1075
|
return this;
|
|
1036
1076
|
});
|
|
1037
1077
|
a(this, "primitive", (e) => {
|
|
@@ -1042,8 +1082,8 @@ const I = class I {
|
|
|
1042
1082
|
});
|
|
1043
1083
|
a(this, "reduce", () => {
|
|
1044
1084
|
this.coefficient.reduce();
|
|
1045
|
-
for (const e in s(this,
|
|
1046
|
-
s(this,
|
|
1085
|
+
for (const e in s(this, b))
|
|
1086
|
+
s(this, b)[e].isZero() && this.removeVariable(e);
|
|
1047
1087
|
return this;
|
|
1048
1088
|
});
|
|
1049
1089
|
/**
|
|
@@ -1057,15 +1097,15 @@ const I = class I {
|
|
|
1057
1097
|
* @param letter (string) Letter to change
|
|
1058
1098
|
* @param pow (number) Power of the setLetter (must be positive integer.
|
|
1059
1099
|
*/
|
|
1060
|
-
a(this, "setLetter", (e, t) => t instanceof u ? (this.hasVariable(e) && t.isZero() && this.removeVariable(e), s(this,
|
|
1100
|
+
a(this, "setLetter", (e, t) => t instanceof u ? (this.hasVariable(e) && t.isZero() && this.removeVariable(e), s(this, b)[e] = t.clone(), this) : this.setLetter(e, new u(t)));
|
|
1061
1101
|
/**
|
|
1062
1102
|
* Return the square root of a monom
|
|
1063
1103
|
*/
|
|
1064
1104
|
a(this, "sqrt", () => {
|
|
1065
1105
|
if (this.isSquare()) {
|
|
1066
|
-
s(this,
|
|
1067
|
-
for (const e in s(this,
|
|
1068
|
-
s(this,
|
|
1106
|
+
s(this, T).sqrt();
|
|
1107
|
+
for (const e in s(this, b))
|
|
1108
|
+
s(this, b)[e].clone().divide(2);
|
|
1069
1109
|
}
|
|
1070
1110
|
return this;
|
|
1071
1111
|
});
|
|
@@ -1076,57 +1116,57 @@ const I = class I {
|
|
|
1076
1116
|
a(this, "subtract", (...e) => {
|
|
1077
1117
|
for (const t of e) {
|
|
1078
1118
|
const i = t instanceof I ? t : new I(t);
|
|
1079
|
-
this.isSameAs(i) ? (this.isZero() && A(this, Qe,
|
|
1119
|
+
this.isSameAs(i) ? (this.isZero() && A(this, Qe, xt).call(this, i), s(this, T).add(i.clone().coefficient.opposite())) : console.log("Subtract: Is not similar: ", i.display);
|
|
1080
1120
|
}
|
|
1081
1121
|
return this;
|
|
1082
1122
|
});
|
|
1083
1123
|
/**
|
|
1084
1124
|
* Create a zero value monom
|
|
1085
1125
|
*/
|
|
1086
|
-
a(this, "zero", () => (h(this,
|
|
1087
|
-
|
|
1126
|
+
a(this, "zero", () => (h(this, T, new u().zero()), h(this, b, {}), this));
|
|
1127
|
+
m(this, ze, (e) => {
|
|
1088
1128
|
let t = this.coefficient.value;
|
|
1089
1129
|
if (typeof e == "number") {
|
|
1090
1130
|
const i = {}, n = this.variables[0];
|
|
1091
|
-
return i[n] = e, s(this,
|
|
1131
|
+
return i[n] = e, s(this, ze).call(this, i);
|
|
1092
1132
|
}
|
|
1093
1133
|
if (e instanceof u) {
|
|
1094
1134
|
const i = {};
|
|
1095
|
-
return i[this.variables[0]] = new u(e).value, s(this,
|
|
1135
|
+
return i[this.variables[0]] = new u(e).value, s(this, ze).call(this, i);
|
|
1096
1136
|
}
|
|
1097
|
-
if (e instanceof
|
|
1137
|
+
if (e instanceof vt)
|
|
1098
1138
|
return NaN;
|
|
1099
1139
|
if (typeof e == "object") {
|
|
1100
1140
|
if (this.variables.length === 0)
|
|
1101
1141
|
return this.coefficient.value;
|
|
1102
|
-
for (const i in s(this,
|
|
1142
|
+
for (const i in s(this, b)) {
|
|
1103
1143
|
const n = e[i];
|
|
1104
|
-
n instanceof u ? t *= n.value ** s(this,
|
|
1144
|
+
n instanceof u ? t *= n.value ** s(this, b)[i].value : t *= n ** s(this, b)[i].value;
|
|
1105
1145
|
}
|
|
1106
1146
|
}
|
|
1107
1147
|
return t;
|
|
1108
1148
|
});
|
|
1109
|
-
|
|
1149
|
+
m(this, Mt, (e) => {
|
|
1110
1150
|
const i = new Kt().parse(e).rpn, n = [];
|
|
1111
1151
|
if (i.length === 0)
|
|
1112
1152
|
return this.zero(), this;
|
|
1113
1153
|
if (i.length === 1) {
|
|
1114
1154
|
const r = i[0];
|
|
1115
|
-
return this.one(), r.tokenType ===
|
|
1155
|
+
return this.one(), r.tokenType === g.COEFFICIENT ? this.coefficient = new u(r.token) : r.tokenType === g.VARIABLE && this.setLetter(r.token, 1), this;
|
|
1116
1156
|
} else
|
|
1117
1157
|
for (const r of i)
|
|
1118
1158
|
s(this, kt).call(this, n, r);
|
|
1119
1159
|
return this.one(), this.multiply(n[0]), this;
|
|
1120
1160
|
});
|
|
1121
|
-
|
|
1122
|
-
var
|
|
1161
|
+
m(this, kt, (e, t) => {
|
|
1162
|
+
var f;
|
|
1123
1163
|
let i, n, r, l, c;
|
|
1124
|
-
if (t.tokenType ===
|
|
1164
|
+
if (t.tokenType === g.COEFFICIENT)
|
|
1125
1165
|
e.push(new I(new u(t.token)));
|
|
1126
|
-
else if (t.tokenType ===
|
|
1127
|
-
const
|
|
1128
|
-
|
|
1129
|
-
} else if (t.tokenType ===
|
|
1166
|
+
else if (t.tokenType === g.VARIABLE) {
|
|
1167
|
+
const d = new I().one();
|
|
1168
|
+
d.setLetter(t.token, 1), e.push(d.clone());
|
|
1169
|
+
} else if (t.tokenType === g.OPERATION)
|
|
1130
1170
|
switch (t.token) {
|
|
1131
1171
|
case "-":
|
|
1132
1172
|
n = e.pop() ?? new I().zero(), i = e.pop() ?? new I().zero(), e.push(i.subtract(n));
|
|
@@ -1138,12 +1178,12 @@ const I = class I {
|
|
|
1138
1178
|
n = e.pop() ?? new I().one(), i = e.pop() ?? new I().one(), e.push(i.divide(n));
|
|
1139
1179
|
break;
|
|
1140
1180
|
case "^": {
|
|
1141
|
-
c = ((
|
|
1181
|
+
c = ((f = e.pop()) == null ? void 0 : f.coefficient) ?? new u().one(), r = e.pop() ?? new I().one(), l = r.variables[0], l && r.setLetter(l, c), e.push(r);
|
|
1142
1182
|
break;
|
|
1143
1183
|
}
|
|
1144
1184
|
}
|
|
1145
1185
|
});
|
|
1146
|
-
return h(this,
|
|
1186
|
+
return h(this, T, new u().zero()), h(this, b, {}), e !== void 0 && this.parse(e), this;
|
|
1147
1187
|
}
|
|
1148
1188
|
// -----------------------------------------
|
|
1149
1189
|
/**
|
|
@@ -1151,21 +1191,21 @@ const I = class I {
|
|
|
1151
1191
|
* @param inputStr
|
|
1152
1192
|
*/
|
|
1153
1193
|
parse(e) {
|
|
1154
|
-
return h(this,
|
|
1194
|
+
return h(this, T, new u()), h(this, b, {}), typeof e == "string" ? s(this, Mt).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()), A(this, Qe, xt).call(this, e)), this;
|
|
1155
1195
|
}
|
|
1156
1196
|
/**
|
|
1157
1197
|
* Get the coefficient \\(k\\) of the Monom \\(k\\cdot x^{n}\\)
|
|
1158
1198
|
* @returns {Fraction}
|
|
1159
1199
|
*/
|
|
1160
1200
|
get coefficient() {
|
|
1161
|
-
return s(this,
|
|
1201
|
+
return s(this, T);
|
|
1162
1202
|
}
|
|
1163
1203
|
/**
|
|
1164
1204
|
* Set the coefficient \\(k\\) value of the monom
|
|
1165
1205
|
* @param {Fraction | number | string} F
|
|
1166
1206
|
*/
|
|
1167
1207
|
set coefficient(e) {
|
|
1168
|
-
h(this,
|
|
1208
|
+
h(this, T, new u(e));
|
|
1169
1209
|
}
|
|
1170
1210
|
// Display getter
|
|
1171
1211
|
/**
|
|
@@ -1173,10 +1213,10 @@ const I = class I {
|
|
|
1173
1213
|
*/
|
|
1174
1214
|
get display() {
|
|
1175
1215
|
let e = "";
|
|
1176
|
-
const t = Object.keys(s(this,
|
|
1216
|
+
const t = Object.keys(s(this, b)).sort();
|
|
1177
1217
|
for (const i of t)
|
|
1178
|
-
s(this,
|
|
1179
|
-
return e === "" ? s(this,
|
|
1218
|
+
s(this, b)[i].isNotZero() && (e += i, s(this, b)[i].isNotEqual(1) && (e += `^(${s(this, b)[i].display})`));
|
|
1219
|
+
return e === "" ? s(this, T).value != 0 ? s(this, T).display : "" : s(this, T).value === 1 ? e : s(this, T).value === -1 ? `-${e}` : s(this, T).value === 0 ? "0" : `${s(this, T).display}${e}`;
|
|
1180
1220
|
}
|
|
1181
1221
|
get dividers() {
|
|
1182
1222
|
if (!this.coefficient.isRelative())
|
|
@@ -1185,7 +1225,7 @@ const I = class I {
|
|
|
1185
1225
|
return [this.clone()];
|
|
1186
1226
|
if (this.coefficient.numerator > 1e6)
|
|
1187
1227
|
return [this.clone()];
|
|
1188
|
-
const e =
|
|
1228
|
+
const e = U.dividers(Math.abs(this.coefficient.numerator));
|
|
1189
1229
|
let t = [];
|
|
1190
1230
|
for (const n in this.literal)
|
|
1191
1231
|
t = this._getLiteralDividers(t, n);
|
|
@@ -1217,28 +1257,27 @@ const I = class I {
|
|
|
1217
1257
|
* @returns {literalType}
|
|
1218
1258
|
*/
|
|
1219
1259
|
get literal() {
|
|
1220
|
-
return s(this,
|
|
1260
|
+
return s(this, b);
|
|
1221
1261
|
}
|
|
1222
1262
|
/**
|
|
1223
1263
|
* Set the literal part of the monom. Must be a dictionary {x: Fraction, y: Fraction, ...}
|
|
1224
1264
|
* @param {literalType<Fraction>} L
|
|
1225
1265
|
*/
|
|
1226
1266
|
set literal(e) {
|
|
1227
|
-
h(this,
|
|
1267
|
+
h(this, b, e);
|
|
1228
1268
|
}
|
|
1229
1269
|
/**
|
|
1230
1270
|
* Get the literal square roots of the Monom.
|
|
1231
|
-
* TODO: remove this getter ? Is it used and is it correct ?
|
|
1232
1271
|
* @returns {literalType<Fraction>}
|
|
1233
1272
|
*/
|
|
1234
1273
|
get literalSqrt() {
|
|
1235
1274
|
if (this.isLiteralSquare()) {
|
|
1236
1275
|
const e = {};
|
|
1237
|
-
for (const t in s(this,
|
|
1238
|
-
e[t] = s(this,
|
|
1276
|
+
for (const t in s(this, b))
|
|
1277
|
+
e[t] = s(this, b)[t].clone().sqrt();
|
|
1239
1278
|
return e;
|
|
1240
1279
|
} else
|
|
1241
|
-
return s(this,
|
|
1280
|
+
return s(this, b);
|
|
1242
1281
|
}
|
|
1243
1282
|
/**
|
|
1244
1283
|
* Set the literal part of the monom from a string
|
|
@@ -1246,29 +1285,29 @@ const I = class I {
|
|
|
1246
1285
|
*/
|
|
1247
1286
|
set literalStr(e) {
|
|
1248
1287
|
for (const t of [...e.matchAll(/([a-z])\^([+-]?[0-9]+)/g)])
|
|
1249
|
-
t[1] in s(this,
|
|
1288
|
+
t[1] in s(this, b) || (s(this, b)[t[1]] = new u().zero()), s(this, b)[t[1]].add(+t[2]);
|
|
1250
1289
|
for (const t of [...e.matchAll(/([a-z](?!\^))/g)])
|
|
1251
|
-
t[1] in s(this,
|
|
1290
|
+
t[1] in s(this, b) || (s(this, b)[t[1]] = new u().zero()), s(this, b)[t[1]].add(1);
|
|
1252
1291
|
}
|
|
1253
1292
|
get plotFunction() {
|
|
1254
1293
|
let e = "";
|
|
1255
|
-
const t = Object.keys(s(this,
|
|
1294
|
+
const t = Object.keys(s(this, b)).sort();
|
|
1256
1295
|
for (const i of t)
|
|
1257
|
-
s(this,
|
|
1258
|
-
return e === "" ? s(this,
|
|
1296
|
+
s(this, b)[i].isNotZero() && (e += (e === "" ? "" : "*") + i, s(this, b)[i].isNotEqual(1) && (e += `^(${s(this, b)[i].display})`));
|
|
1297
|
+
return e === "" ? s(this, T).value != 0 ? s(this, T).display : "" : s(this, T).value === 1 ? e : s(this, T).value === -1 ? `-${e}` : s(this, T).value === 0 ? "0" : `${s(this, T).display}*${e}`;
|
|
1259
1298
|
}
|
|
1260
1299
|
removeVariable(e) {
|
|
1261
|
-
delete s(this,
|
|
1300
|
+
delete s(this, b)[e];
|
|
1262
1301
|
}
|
|
1263
1302
|
/**
|
|
1264
1303
|
* Get the tex output of the monom
|
|
1265
1304
|
*/
|
|
1266
1305
|
get tex() {
|
|
1267
1306
|
let e = "";
|
|
1268
|
-
const t = Object.keys(s(this,
|
|
1307
|
+
const t = Object.keys(s(this, b)).sort();
|
|
1269
1308
|
for (const i of t)
|
|
1270
|
-
s(this,
|
|
1271
|
-
return e === "" ? s(this,
|
|
1309
|
+
s(this, b)[i].isNotZero() && (e += i, s(this, b)[i].isNotEqual(1) && (e += `^{ ${s(this, b)[i].tfrac.tex} }`));
|
|
1310
|
+
return e === "" ? s(this, T).value != 0 ? s(this, T).frac.tex : "0" : s(this, T).value === 1 ? e : s(this, T).value === -1 ? `-${e}` : s(this, T).value === 0 ? "0" : `${s(this, T).frac.tex}${e}`;
|
|
1272
1311
|
}
|
|
1273
1312
|
// Getter helpers.
|
|
1274
1313
|
/**
|
|
@@ -1298,14 +1337,14 @@ const I = class I {
|
|
|
1298
1337
|
return i;
|
|
1299
1338
|
}
|
|
1300
1339
|
};
|
|
1301
|
-
|
|
1340
|
+
T = new WeakMap(), b = new WeakMap(), Qe = new WeakSet(), xt = function(e) {
|
|
1302
1341
|
for (const t in e.literal)
|
|
1303
|
-
s(this,
|
|
1304
|
-
},
|
|
1342
|
+
s(this, b)[t] = e.literal[t].clone();
|
|
1343
|
+
}, ze = new WeakMap(), Mt = new WeakMap(), kt = new WeakMap(), a(I, "gcd", (...e) => {
|
|
1305
1344
|
for (const r of e)
|
|
1306
1345
|
if (r.containsRationalPower())
|
|
1307
1346
|
return new I().zero();
|
|
1308
|
-
const t = new I(), i =
|
|
1347
|
+
const t = new I(), i = U.gcd(...e.map((r) => r.coefficient.numerator)), n = U.lcm(...e.map((r) => r.coefficient.denominator));
|
|
1309
1348
|
t.coefficient = new u(i, n).reduce();
|
|
1310
1349
|
for (const r of e) {
|
|
1311
1350
|
for (const l in t.literal)
|
|
@@ -1325,35 +1364,35 @@ a(I, "xMultiply", (...e) => {
|
|
|
1325
1364
|
return t;
|
|
1326
1365
|
});
|
|
1327
1366
|
let k = I;
|
|
1328
|
-
function
|
|
1367
|
+
function yi(o, e = !0) {
|
|
1329
1368
|
return e ? `\\left( ${o} \\right)` : `(${o})`;
|
|
1330
1369
|
}
|
|
1331
|
-
function
|
|
1332
|
-
return o.map((r, l) =>
|
|
1370
|
+
function Et(o, e, t, i, n) {
|
|
1371
|
+
return o.map((r, l) => r === e ? t : r);
|
|
1333
1372
|
}
|
|
1334
|
-
var
|
|
1335
|
-
const
|
|
1373
|
+
var je, y, Ke, ft, Je, dt, Ct, $t, Pt, _e, It, pt, Bt, St, Rt, zt, Mi, Lt, Vt;
|
|
1374
|
+
const $ = class $ {
|
|
1336
1375
|
constructor(e, ...t) {
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1376
|
+
m(this, zt);
|
|
1377
|
+
m(this, je);
|
|
1378
|
+
m(this, y);
|
|
1379
|
+
m(this, Ke);
|
|
1380
|
+
m(this, ft, !1);
|
|
1342
1381
|
/**
|
|
1343
1382
|
* Parse a string to a polynom.
|
|
1344
1383
|
* @param inputStr
|
|
1345
1384
|
* @param values
|
|
1346
1385
|
*/
|
|
1347
1386
|
a(this, "parse", (e, ...t) => {
|
|
1348
|
-
if (h(this, y, []), h(this,
|
|
1349
|
-
return A(this, zt,
|
|
1387
|
+
if (h(this, y, []), h(this, je, []), typeof e == "string")
|
|
1388
|
+
return A(this, zt, Mi).call(this, e, ...t);
|
|
1350
1389
|
if ((typeof e == "number" || e instanceof u || e instanceof k) && t.length === 0)
|
|
1351
1390
|
s(this, y).push(new k(e));
|
|
1352
1391
|
else if (e instanceof k && t.length > 0)
|
|
1353
1392
|
s(this, y).push(new k(e)), t.forEach((i) => {
|
|
1354
1393
|
s(this, y).push(new k(i));
|
|
1355
1394
|
});
|
|
1356
|
-
else if (e instanceof
|
|
1395
|
+
else if (e instanceof $)
|
|
1357
1396
|
for (const i of e.monoms)
|
|
1358
1397
|
s(this, y).push(i.clone());
|
|
1359
1398
|
return this;
|
|
@@ -1362,14 +1401,14 @@ const C = class C {
|
|
|
1362
1401
|
* Clone the polynom
|
|
1363
1402
|
*/
|
|
1364
1403
|
a(this, "clone", () => {
|
|
1365
|
-
const e = new
|
|
1404
|
+
const e = new $(), t = [];
|
|
1366
1405
|
for (const i of s(this, y))
|
|
1367
1406
|
t.push(i.clone());
|
|
1368
1407
|
return e.monoms = t, e;
|
|
1369
1408
|
});
|
|
1370
1409
|
a(this, "add", (...e) => {
|
|
1371
1410
|
for (const t of e)
|
|
1372
|
-
t instanceof
|
|
1411
|
+
t instanceof $ ? h(this, y, s(this, y).concat(t.monoms)) : t instanceof k ? s(this, y).push(t.clone()) : typeof t == "number" && Number.isSafeInteger(t) ? s(this, y).push(new k(t.toString())) : s(this, y).push(new k(t));
|
|
1373
1412
|
return this.reduce();
|
|
1374
1413
|
});
|
|
1375
1414
|
a(this, "commonMonom", () => {
|
|
@@ -1390,28 +1429,28 @@ const C = class C {
|
|
|
1390
1429
|
return t;
|
|
1391
1430
|
});
|
|
1392
1431
|
a(this, "derivative", (e) => {
|
|
1393
|
-
const t = new
|
|
1432
|
+
const t = new $();
|
|
1394
1433
|
for (const i of s(this, y))
|
|
1395
1434
|
t.add(i.derivative(e));
|
|
1396
|
-
return t;
|
|
1435
|
+
return t.reduce();
|
|
1397
1436
|
});
|
|
1398
1437
|
a(this, "divide", (e) => {
|
|
1399
1438
|
if (e instanceof u)
|
|
1400
|
-
return s(this,
|
|
1439
|
+
return s(this, dt).call(this, e);
|
|
1401
1440
|
if (typeof e == "number" && Number.isSafeInteger(e))
|
|
1402
1441
|
return s(this, Ct).call(this, e);
|
|
1403
1442
|
if (e instanceof k)
|
|
1404
|
-
return this.divide(new
|
|
1405
|
-
if (e instanceof
|
|
1443
|
+
return this.divide(new $(e));
|
|
1444
|
+
if (e instanceof $) {
|
|
1406
1445
|
if (e.monoms.length === 1 && e.variables.length === 0)
|
|
1407
|
-
return s(this,
|
|
1446
|
+
return s(this, dt).call(this, e.monoms[0].coefficient);
|
|
1408
1447
|
{
|
|
1409
1448
|
const { quotient: t, reminder: i } = this.euclidean(e);
|
|
1410
1449
|
if (i.isZero())
|
|
1411
1450
|
return h(this, y, t.monoms), this;
|
|
1412
1451
|
}
|
|
1413
1452
|
} else if (typeof e == "string")
|
|
1414
|
-
return this.divide(new
|
|
1453
|
+
return this.divide(new $(e));
|
|
1415
1454
|
throw new Error(`Cannot divide by ${e}`);
|
|
1416
1455
|
});
|
|
1417
1456
|
a(this, "empty", () => (h(this, y, []), this));
|
|
@@ -1421,15 +1460,15 @@ const C = class C {
|
|
|
1421
1460
|
* returns {quotient: Polynom, reminder: Polynom}
|
|
1422
1461
|
*/
|
|
1423
1462
|
a(this, "euclidean", (e) => {
|
|
1424
|
-
const t = e.variables[0], i = new
|
|
1463
|
+
const t = e.variables[0], i = new $().zero(), n = this.clone().reorder(t);
|
|
1425
1464
|
if (e.variables.length === 0)
|
|
1426
1465
|
return {
|
|
1427
1466
|
quotient: this.clone().divide(e).reduce(),
|
|
1428
|
-
reminder: new
|
|
1467
|
+
reminder: new $().zero()
|
|
1429
1468
|
};
|
|
1430
1469
|
const r = e.monomByDegree(void 0, t), l = e.degree(t);
|
|
1431
|
-
let c,
|
|
1432
|
-
for (; n.degree(t).isGeq(l) &&
|
|
1470
|
+
let c, f = this.degree(t).value * 2;
|
|
1471
|
+
for (; n.degree(t).isGeq(l) && f > 0 && (f--, c = n.monomByDegree(void 0, t).clone().divide(r), !(!c.isZero() && (i.add(c), n.subtract(e.clone().multiply(c)).reduce(), c.degree(t).isZero()))); )
|
|
1433
1472
|
;
|
|
1434
1473
|
return i.reduce(), n.reduce(), { quotient: i, reminder: n };
|
|
1435
1474
|
});
|
|
@@ -1450,7 +1489,7 @@ const C = class C {
|
|
|
1450
1489
|
let t = [], i = this.clone().reorder();
|
|
1451
1490
|
const n = i.commonMonom();
|
|
1452
1491
|
if (i.monomByDegree().coefficient.isStrictlyNegative() && n.coefficient.isStrictlyPositive() && !n.isOne() && n.opposite(), !n.isOne()) {
|
|
1453
|
-
const c = new
|
|
1492
|
+
const c = new $(n);
|
|
1454
1493
|
t = [c.clone()], i = i.euclidean(c).quotient;
|
|
1455
1494
|
}
|
|
1456
1495
|
let r = i.degree().clone().multiply(2).value, l = 1;
|
|
@@ -1462,24 +1501,24 @@ const C = class C {
|
|
|
1462
1501
|
t.push(i.clone()), i.one();
|
|
1463
1502
|
break;
|
|
1464
1503
|
} else {
|
|
1465
|
-
let c = s(this,
|
|
1504
|
+
let c = s(this, It).call(this, i, l, e ?? "x");
|
|
1466
1505
|
for (l = i.degree(e).value; c.length > 0; ) {
|
|
1467
|
-
const
|
|
1468
|
-
if (!i.isDividableBy(
|
|
1506
|
+
const f = c[0];
|
|
1507
|
+
if (!i.isDividableBy(f))
|
|
1469
1508
|
c.shift();
|
|
1470
1509
|
else {
|
|
1471
|
-
const
|
|
1472
|
-
t.push(
|
|
1473
|
-
const
|
|
1474
|
-
return V.isDivisible(
|
|
1510
|
+
const d = i.euclidean(f);
|
|
1511
|
+
t.push(f), i = d.quotient.clone(), c = c.filter((p) => {
|
|
1512
|
+
const w = i.monoms[0], V = i.monoms[i.monoms.length - 1], ce = p.monoms[0], ue = p.monoms[p.monoms.length - 1];
|
|
1513
|
+
return V.isDivisible(ue) ? w.isDivisible(ce) : !1;
|
|
1475
1514
|
});
|
|
1476
1515
|
}
|
|
1477
1516
|
}
|
|
1478
1517
|
}
|
|
1479
|
-
return i.isOne() || t.push(i.clone()), h(this,
|
|
1518
|
+
return i.isOne() || t.push(i.clone()), h(this, je, t), s(this, je);
|
|
1480
1519
|
});
|
|
1481
|
-
a(this, "gcdDenominator", () =>
|
|
1482
|
-
a(this, "gcdNumerator", () =>
|
|
1520
|
+
a(this, "gcdDenominator", () => U.gcd(...this.getDenominators()));
|
|
1521
|
+
a(this, "gcdNumerator", () => U.gcd(...this.getNumerators()));
|
|
1483
1522
|
// Next functions are used for for commonMonom, which is used in the factorize method.
|
|
1484
1523
|
a(this, "getDenominators", () => {
|
|
1485
1524
|
const e = [];
|
|
@@ -1493,7 +1532,7 @@ const C = class C {
|
|
|
1493
1532
|
e.push(t.coefficient.numerator);
|
|
1494
1533
|
return e;
|
|
1495
1534
|
});
|
|
1496
|
-
a(this, "getZeroes", () => this.degree().isZero() ? [] : (this.roots = new
|
|
1535
|
+
a(this, "getZeroes", () => this.degree().isZero() ? [] : (this.roots = new At(this.clone()).solve(), this.roots));
|
|
1497
1536
|
a(this, "integrate", (e, t, i = "x") => {
|
|
1498
1537
|
const n = this.primitive(i), r = {}, l = {};
|
|
1499
1538
|
return r[i] = new u(e), l[i] = new u(t), n.evaluate(l).subtract(n.evaluate(r));
|
|
@@ -1504,7 +1543,7 @@ const C = class C {
|
|
|
1504
1543
|
if (i.includes("(") || i.includes(")"))
|
|
1505
1544
|
return !1;
|
|
1506
1545
|
try {
|
|
1507
|
-
t = new
|
|
1546
|
+
t = new $(e);
|
|
1508
1547
|
} catch {
|
|
1509
1548
|
return !1;
|
|
1510
1549
|
}
|
|
@@ -1524,7 +1563,7 @@ const C = class C {
|
|
|
1524
1563
|
a(this, "isReduced", (e) => {
|
|
1525
1564
|
if (!this.isDeveloped(e))
|
|
1526
1565
|
return !1;
|
|
1527
|
-
const t = new
|
|
1566
|
+
const t = new $(e);
|
|
1528
1567
|
if (t.monoms.length > this.monoms.length)
|
|
1529
1568
|
return !1;
|
|
1530
1569
|
for (const i of t.monoms)
|
|
@@ -1533,8 +1572,8 @@ const C = class C {
|
|
|
1533
1572
|
return !1;
|
|
1534
1573
|
});
|
|
1535
1574
|
a(this, "isSameAs", (e) => s(this, Je).call(this, e, "same"));
|
|
1536
|
-
a(this, "lcmDenominator", () =>
|
|
1537
|
-
a(this, "lcmNumerator", () =>
|
|
1575
|
+
a(this, "lcmDenominator", () => U.lcm(...this.getDenominators()));
|
|
1576
|
+
a(this, "lcmNumerator", () => U.lcm(...this.getNumerators()));
|
|
1538
1577
|
a(this, "letters", () => {
|
|
1539
1578
|
let e = /* @__PURE__ */ new Set();
|
|
1540
1579
|
for (const t of s(this, y))
|
|
@@ -1574,7 +1613,7 @@ const C = class C {
|
|
|
1574
1613
|
r.degree(t).isEqual(e) && i.push(r.clone());
|
|
1575
1614
|
return i;
|
|
1576
1615
|
});
|
|
1577
|
-
a(this, "multiply", (e) => e instanceof
|
|
1616
|
+
a(this, "multiply", (e) => e instanceof $ ? s(this, Rt).call(this, e) : e instanceof u ? s(this, pt).call(this, e) : e instanceof k ? s(this, St).call(this, e) : Number.isSafeInteger(e) && typeof e == "number" ? s(this, Bt).call(this, e) : this);
|
|
1578
1617
|
a(this, "one", () => (h(this, y, []), s(this, y).push(new k().one()), this));
|
|
1579
1618
|
// ------------------------------------------
|
|
1580
1619
|
a(this, "opposite", () => (h(this, y, s(this, y).map((e) => e.opposite())), this));
|
|
@@ -1584,14 +1623,14 @@ const C = class C {
|
|
|
1584
1623
|
if (e < 0)
|
|
1585
1624
|
return this.zero();
|
|
1586
1625
|
if (e === 0)
|
|
1587
|
-
return new
|
|
1626
|
+
return new $();
|
|
1588
1627
|
const t = this.clone();
|
|
1589
1628
|
for (let i = 1; i < e; i++)
|
|
1590
1629
|
this.multiply(t);
|
|
1591
1630
|
return this.reduce();
|
|
1592
1631
|
});
|
|
1593
1632
|
a(this, "primitive", (e) => {
|
|
1594
|
-
const t = new
|
|
1633
|
+
const t = new $();
|
|
1595
1634
|
for (const i of s(this, y))
|
|
1596
1635
|
t.add(i.primitive(e));
|
|
1597
1636
|
return t;
|
|
@@ -1606,8 +1645,9 @@ const C = class C {
|
|
|
1606
1645
|
h(this, y, s(this, y).filter((t) => !t.coefficient.isZero()));
|
|
1607
1646
|
for (const t of s(this, y))
|
|
1608
1647
|
t.coefficient.reduce();
|
|
1609
|
-
return this.length === 0 ? new
|
|
1648
|
+
return this.length === 0 ? new $().zero() : this.reorder();
|
|
1610
1649
|
});
|
|
1650
|
+
// ------------------------------------------
|
|
1611
1651
|
a(this, "reorder", (e = "x", t) => {
|
|
1612
1652
|
t === void 0 && (t = !1);
|
|
1613
1653
|
const i = this.variables.filter((n) => n !== e);
|
|
@@ -1616,15 +1656,14 @@ const C = class C {
|
|
|
1616
1656
|
if (l !== c)
|
|
1617
1657
|
return t ? l - c : c - l;
|
|
1618
1658
|
if (i.length > 0)
|
|
1619
|
-
for (const
|
|
1620
|
-
const
|
|
1621
|
-
if (
|
|
1622
|
-
return t ?
|
|
1659
|
+
for (const f of i) {
|
|
1660
|
+
const d = n.degree(f).value, p = r.degree(f).value;
|
|
1661
|
+
if (d !== p)
|
|
1662
|
+
return t ? d - p : p - d;
|
|
1623
1663
|
}
|
|
1624
1664
|
return 0;
|
|
1625
1665
|
}), this;
|
|
1626
1666
|
});
|
|
1627
|
-
// ------------------------------------------
|
|
1628
1667
|
/**
|
|
1629
1668
|
* Replace a variable (letter) by a polynom.
|
|
1630
1669
|
* @param letter
|
|
@@ -1632,14 +1671,14 @@ const C = class C {
|
|
|
1632
1671
|
*/
|
|
1633
1672
|
a(this, "replaceBy", (e, t) => {
|
|
1634
1673
|
let i;
|
|
1635
|
-
const n = new
|
|
1674
|
+
const n = new $().zero();
|
|
1636
1675
|
for (const r of this.monoms)
|
|
1637
1676
|
!r.hasVariable(e) || r.literal[e].isZero() ? n.add(r.clone()) : (i = r.literal[e].clone(), r.removeVariable(e), n.add(t.clone().pow(Math.abs(i.numerator)).multiply(r)));
|
|
1638
1677
|
return h(this, y, n.reduce().monoms), this;
|
|
1639
1678
|
});
|
|
1640
1679
|
a(this, "subtract", (...e) => {
|
|
1641
1680
|
for (const t of e)
|
|
1642
|
-
t instanceof
|
|
1681
|
+
t instanceof $ ? this.add(t.clone().opposite()) : t instanceof k ? s(this, y).push(t.clone().opposite()) : s(this, y).push(new k(t).opposite());
|
|
1643
1682
|
return this.reduce();
|
|
1644
1683
|
});
|
|
1645
1684
|
/**
|
|
@@ -1647,7 +1686,7 @@ const C = class C {
|
|
|
1647
1686
|
* @returns {this}
|
|
1648
1687
|
*/
|
|
1649
1688
|
a(this, "zero", () => (h(this, y, []), s(this, y).push(new k().zero()), this));
|
|
1650
|
-
|
|
1689
|
+
m(this, Je, (e, t) => {
|
|
1651
1690
|
t === void 0 && (t = "=");
|
|
1652
1691
|
const i = this.clone().reduce().reorder(), n = e.clone().reduce().reorder();
|
|
1653
1692
|
switch (t) {
|
|
@@ -1659,47 +1698,47 @@ const C = class C {
|
|
|
1659
1698
|
return !1;
|
|
1660
1699
|
}
|
|
1661
1700
|
});
|
|
1662
|
-
|
|
1701
|
+
m(this, dt, (e) => {
|
|
1663
1702
|
for (const t of s(this, y))
|
|
1664
1703
|
t.coefficient.divide(e);
|
|
1665
1704
|
return this;
|
|
1666
1705
|
});
|
|
1667
|
-
|
|
1706
|
+
m(this, Ct, (e) => {
|
|
1668
1707
|
const t = new u(e);
|
|
1669
1708
|
for (const i of s(this, y))
|
|
1670
1709
|
i.coefficient.divide(t);
|
|
1671
1710
|
return this;
|
|
1672
1711
|
});
|
|
1673
|
-
|
|
1712
|
+
m(this, $t, (e) => {
|
|
1674
1713
|
let t = 0;
|
|
1675
1714
|
return s(this, y).forEach((i) => {
|
|
1676
1715
|
t += i.evaluate(e, !0);
|
|
1677
1716
|
}), t;
|
|
1678
1717
|
});
|
|
1679
|
-
|
|
1680
|
-
var
|
|
1681
|
-
let t, i, n, r, l, c,
|
|
1718
|
+
m(this, Pt, (e) => {
|
|
1719
|
+
var w;
|
|
1720
|
+
let t, i, n, r, l, c, f, d, p;
|
|
1682
1721
|
if (this.numberOfVars === 1)
|
|
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() ? (
|
|
1684
|
-
new
|
|
1685
|
-
new
|
|
1722
|
+
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() ? (f = r.clone().opposite().divide(n.clone().multiply(2)), t = new $(e).subtract(f.display).multiply(f.denominator), i = new $(e).subtract(f.display).multiply(f.denominator), p = n.divide(f.denominator).divide(f.denominator), p.isOne() ? [t, i] : [new $(p.display), t, i]) : c.isPositive() && c.isSquare() ? (f = r.clone().opposite().add(c.clone().sqrt()).divide(n.clone().multiply(2)), d = r.clone().opposite().subtract(c.clone().sqrt()).divide(n.clone().multiply(2)), p = n.divide(f.denominator).divide(d.denominator), p.isOne() ? [
|
|
1723
|
+
new $(e).subtract(f.display).multiply(f.denominator),
|
|
1724
|
+
new $(e).subtract(d.display).multiply(d.denominator)
|
|
1686
1725
|
] : [
|
|
1687
|
-
new
|
|
1688
|
-
new
|
|
1689
|
-
new
|
|
1726
|
+
new $(p.display),
|
|
1727
|
+
new $(e).subtract(f.display).multiply(f.denominator),
|
|
1728
|
+
new $(e).subtract(d.display).multiply(d.denominator)
|
|
1690
1729
|
]) : [this.clone()];
|
|
1691
1730
|
if (n = this.monomByDegree(2, e), r = this.monomByDegree(1, e), l = this.monomByDegree(0, e), n.isLiteralSquare() && l.isLiteralSquare() && r.clone().pow(2).isSameAs(n.clone().multiply(l))) {
|
|
1692
|
-
const V = new
|
|
1693
|
-
let
|
|
1694
|
-
if (
|
|
1695
|
-
for (const
|
|
1696
|
-
|
|
1697
|
-
return
|
|
1731
|
+
const V = new $("x", n.coefficient, r.coefficient, l.coefficient), ce = s(w = V, Pt).call(w, "x"), ue = [];
|
|
1732
|
+
let fe;
|
|
1733
|
+
if (ce.length >= 2) {
|
|
1734
|
+
for (const ye of ce)
|
|
1735
|
+
ye.degree().isZero() ? ue.push(ye.clone()) : (fe = ye.clone(), fe.monoms[0].literal = n.literalSqrt, fe.monoms[1].literal = l.literalSqrt, ue.push(fe.clone()));
|
|
1736
|
+
return ue;
|
|
1698
1737
|
}
|
|
1699
1738
|
}
|
|
1700
1739
|
return [this.clone()];
|
|
1701
1740
|
});
|
|
1702
|
-
|
|
1741
|
+
m(this, _e, (e, t, i, n) => {
|
|
1703
1742
|
let r = "";
|
|
1704
1743
|
for (const l of s(this, y)) {
|
|
1705
1744
|
if (l.coefficient.value === 0)
|
|
@@ -1709,26 +1748,26 @@ const C = class C {
|
|
|
1709
1748
|
}
|
|
1710
1749
|
return i === !0 && this.length > 1 && (e === "tex" ? r = `\\left( ${r} \\right)` : r = `(${r})`), r === "" && (r = "0"), r;
|
|
1711
1750
|
});
|
|
1712
|
-
|
|
1751
|
+
m(this, It, (e, t, i) => {
|
|
1713
1752
|
const n = e.monoms[0].dividers, r = e.monoms[e.monoms.length - 1].dividers, l = [];
|
|
1714
1753
|
return n.forEach((c) => {
|
|
1715
|
-
c.degree(i).isLeq(t) && r.forEach((
|
|
1716
|
-
c.degree(i).isNotEqual(
|
|
1754
|
+
c.degree(i).isLeq(t) && r.forEach((f) => {
|
|
1755
|
+
c.degree(i).isNotEqual(f.degree(i)) && (l.push(new $(c, f)), l.push(new $(c, f.clone().opposite())));
|
|
1717
1756
|
});
|
|
1718
1757
|
}), l;
|
|
1719
1758
|
});
|
|
1720
|
-
|
|
1759
|
+
m(this, pt, (e) => {
|
|
1721
1760
|
for (const t of s(this, y))
|
|
1722
1761
|
t.coefficient.multiply(e);
|
|
1723
1762
|
return this.reduce();
|
|
1724
1763
|
});
|
|
1725
|
-
|
|
1726
|
-
|
|
1764
|
+
m(this, Bt, (e) => s(this, pt).call(this, new u(e)));
|
|
1765
|
+
m(this, St, (e) => {
|
|
1727
1766
|
for (const t of s(this, y))
|
|
1728
1767
|
t.multiply(e);
|
|
1729
1768
|
return this.reduce();
|
|
1730
1769
|
});
|
|
1731
|
-
|
|
1770
|
+
m(this, Rt, (e) => {
|
|
1732
1771
|
const t = [];
|
|
1733
1772
|
for (const i of s(this, y))
|
|
1734
1773
|
for (const n of e.monoms)
|
|
@@ -1739,26 +1778,26 @@ const C = class C {
|
|
|
1739
1778
|
* Main parse using a shutting yard class
|
|
1740
1779
|
* @param inputStr
|
|
1741
1780
|
*/
|
|
1742
|
-
|
|
1781
|
+
m(this, Lt, (e) => {
|
|
1743
1782
|
const i = new Kt().parse(e).rpn;
|
|
1744
1783
|
this.zero();
|
|
1745
1784
|
const n = [];
|
|
1746
1785
|
for (const r of i)
|
|
1747
|
-
s(this,
|
|
1786
|
+
s(this, Vt).call(this, n, r);
|
|
1748
1787
|
return n.length === 1 && this.add(n[0]), this.reorder();
|
|
1749
1788
|
});
|
|
1750
|
-
|
|
1789
|
+
m(this, Vt, (e, t) => {
|
|
1751
1790
|
switch (t.tokenType) {
|
|
1752
|
-
case
|
|
1753
|
-
e.push(new
|
|
1791
|
+
case g.COEFFICIENT:
|
|
1792
|
+
e.push(new $(t.token));
|
|
1754
1793
|
break;
|
|
1755
|
-
case
|
|
1756
|
-
e.push(new
|
|
1794
|
+
case g.VARIABLE:
|
|
1795
|
+
e.push(new $().add(new k(t.token)));
|
|
1757
1796
|
break;
|
|
1758
|
-
case
|
|
1797
|
+
case g.CONSTANT:
|
|
1759
1798
|
console.log("Actually, not supported - will be added later !");
|
|
1760
1799
|
break;
|
|
1761
|
-
case
|
|
1800
|
+
case g.OPERATION:
|
|
1762
1801
|
if (e.length >= 2) {
|
|
1763
1802
|
const i = e.pop(), n = e.pop();
|
|
1764
1803
|
if (n === void 0 || i === void 0)
|
|
@@ -1789,19 +1828,37 @@ const C = class C {
|
|
|
1789
1828
|
} else
|
|
1790
1829
|
throw new Error("Error parsing the polynom");
|
|
1791
1830
|
break;
|
|
1792
|
-
case
|
|
1831
|
+
case g.MONOM:
|
|
1793
1832
|
console.error("The monom token should not appear here");
|
|
1794
1833
|
break;
|
|
1795
|
-
case
|
|
1834
|
+
case g.FUNCTION:
|
|
1796
1835
|
console.error("The function token should not appear here - might be introduced later.");
|
|
1797
1836
|
break;
|
|
1798
1837
|
}
|
|
1799
1838
|
});
|
|
1800
|
-
return h(this, y, []), h(this,
|
|
1839
|
+
return h(this, y, []), h(this, je, []), h(this, Ke, []), e !== void 0 && this.parse(e, ...t), this;
|
|
1840
|
+
}
|
|
1841
|
+
get tex() {
|
|
1842
|
+
return s(this, _e).call(this, "tex");
|
|
1801
1843
|
}
|
|
1802
1844
|
get display() {
|
|
1803
1845
|
return s(this, _e).call(this);
|
|
1804
1846
|
}
|
|
1847
|
+
fromCoefficients(...e) {
|
|
1848
|
+
h(this, y, []);
|
|
1849
|
+
const t = "x";
|
|
1850
|
+
return e.reverse().forEach((i, n) => {
|
|
1851
|
+
const r = new k();
|
|
1852
|
+
r.coefficient = new u(i), r.setLetter(t, n), s(this, y).push(r);
|
|
1853
|
+
}), this;
|
|
1854
|
+
}
|
|
1855
|
+
getCoefficients() {
|
|
1856
|
+
const e = this.clone().reorder(), t = this.degree().value + 1, i = new Array(t).fill(new u(0));
|
|
1857
|
+
return e.monoms.forEach((n) => {
|
|
1858
|
+
const r = t - n.degree().value - 1;
|
|
1859
|
+
i[r] = n.coefficient.clone();
|
|
1860
|
+
}), i;
|
|
1861
|
+
}
|
|
1805
1862
|
hasVariable(e) {
|
|
1806
1863
|
return this.variables.includes(e);
|
|
1807
1864
|
}
|
|
@@ -1836,43 +1893,32 @@ const C = class C {
|
|
|
1836
1893
|
throw new Error("Cannot take the root from a polynom");
|
|
1837
1894
|
}
|
|
1838
1895
|
get roots() {
|
|
1839
|
-
return s(this,
|
|
1896
|
+
return s(this, ft) ? s(this, Ke) : this.getZeroes();
|
|
1840
1897
|
}
|
|
1841
1898
|
set roots(e) {
|
|
1842
|
-
h(this,
|
|
1899
|
+
h(this, ft, !0), h(this, Ke, e);
|
|
1843
1900
|
}
|
|
1844
1901
|
sqrt() {
|
|
1845
1902
|
throw new Error("Cannot take the square root from a polynom");
|
|
1846
1903
|
}
|
|
1847
|
-
tableOfSigns(
|
|
1848
|
-
const
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
"",
|
|
1864
|
-
this.evaluate(d.value - 1, !0) < 0 ? "-" : "+",
|
|
1865
|
-
0,
|
|
1866
|
-
l
|
|
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 x = f === i.length - 1 ? d.value + 1 : (d.value + i[f + 1].value) / 2;
|
|
1869
|
-
c = this.evaluate(x, !0) < 0 ? "-" : "+", n[r] = "z", n = Re(n, "", c, r, l), r = +l, l = n.length;
|
|
1904
|
+
tableOfSigns() {
|
|
1905
|
+
const e = this.roots;
|
|
1906
|
+
let t = new Array(2 * e.length + 1).fill("").map((i, n) => n % 2 === 0 ? "" : "z");
|
|
1907
|
+
if (t.length === 1) {
|
|
1908
|
+
const [i] = this.getCoefficients().map((n) => n.value);
|
|
1909
|
+
t = Et(t, "", i > 0 ? "+" : "-");
|
|
1910
|
+
} else if (this.degree().isOne()) {
|
|
1911
|
+
const [i] = this.getCoefficients().map((n) => n.value);
|
|
1912
|
+
t[0] = i > 0 ? "-" : "+", t[1] = "z", t[2] = i > 0 ? "+" : "-";
|
|
1913
|
+
} else
|
|
1914
|
+
[
|
|
1915
|
+
e[0].value - 1,
|
|
1916
|
+
...e.map((n, r) => r === e.length - 1 ? e[r].value + 1 : (e[r].value + e[r + 1].value) / 2)
|
|
1917
|
+
].forEach((n, r) => {
|
|
1918
|
+
const l = this.evaluate({ x: n }, !0);
|
|
1919
|
+
t[r * 2] = l > 0 ? "+" : "-";
|
|
1870
1920
|
});
|
|
1871
|
-
}
|
|
1872
|
-
return { roots: t, signs: n };
|
|
1873
|
-
}
|
|
1874
|
-
get tex() {
|
|
1875
|
-
return s(this, _e).call(this, "tex");
|
|
1921
|
+
return { roots: e, signs: t };
|
|
1876
1922
|
}
|
|
1877
1923
|
get variables() {
|
|
1878
1924
|
let e = [];
|
|
@@ -1884,7 +1930,7 @@ const C = class C {
|
|
|
1884
1930
|
return this.getZeroes();
|
|
1885
1931
|
}
|
|
1886
1932
|
};
|
|
1887
|
-
|
|
1933
|
+
je = new WeakMap(), y = new WeakMap(), Ke = new WeakMap(), ft = new WeakMap(), Je = new WeakMap(), dt = new WeakMap(), Ct = new WeakMap(), $t = new WeakMap(), Pt = new WeakMap(), _e = new WeakMap(), It = new WeakMap(), pt = new WeakMap(), Bt = new WeakMap(), St = new WeakMap(), Rt = new WeakMap(), zt = new WeakSet(), Mi = function(e, ...t) {
|
|
1888
1934
|
if (t.length === 0) {
|
|
1889
1935
|
if (e = "" + e, e !== "" && !isNaN(Number(e))) {
|
|
1890
1936
|
this.empty();
|
|
@@ -1897,6 +1943,8 @@ Ue = new WeakMap(), y = new WeakMap(), Ke = new WeakMap(), dt = new WeakMap(), J
|
|
|
1897
1943
|
const i = t.map((n) => new u(n));
|
|
1898
1944
|
if (e.length > 1) {
|
|
1899
1945
|
const n = e.split("");
|
|
1946
|
+
if (n.length < t.length - 2)
|
|
1947
|
+
throw new Error("Too many factors for too few variables !");
|
|
1900
1948
|
let r = 0;
|
|
1901
1949
|
for (const l of i) {
|
|
1902
1950
|
const c = new k();
|
|
@@ -1912,27 +1960,27 @@ Ue = new WeakMap(), y = new WeakMap(), Ke = new WeakMap(), dt = new WeakMap(), J
|
|
|
1912
1960
|
return this;
|
|
1913
1961
|
} else
|
|
1914
1962
|
return this.zero();
|
|
1915
|
-
}, Lt = new WeakMap(),
|
|
1916
|
-
let
|
|
1917
|
-
var q, M, re,
|
|
1918
|
-
const
|
|
1963
|
+
}, Lt = new WeakMap(), Vt = new WeakMap();
|
|
1964
|
+
let O = $;
|
|
1965
|
+
var q, M, re, Dt, et, Zt;
|
|
1966
|
+
const Ne = class Ne {
|
|
1919
1967
|
constructor(e, t, i) {
|
|
1920
1968
|
// Left part of the equation
|
|
1921
|
-
|
|
1969
|
+
m(this, q);
|
|
1922
1970
|
// Right part of the equation
|
|
1923
|
-
|
|
1971
|
+
m(this, M);
|
|
1924
1972
|
// Signe of the equation
|
|
1925
|
-
|
|
1973
|
+
m(this, re);
|
|
1926
1974
|
// ------------------------------------------
|
|
1927
1975
|
a(this, "parse", (e) => {
|
|
1928
|
-
const t = s(this,
|
|
1976
|
+
const t = s(this, Dt).call(this, e);
|
|
1929
1977
|
if (t === !1)
|
|
1930
1978
|
throw new Error("The equation is not valid (no sign found)");
|
|
1931
1979
|
const i = e.split(t);
|
|
1932
|
-
return this.create(new
|
|
1980
|
+
return this.create(new O(i[0]), new O(i[1]), s(this, et).call(this, t));
|
|
1933
1981
|
});
|
|
1934
1982
|
a(this, "create", (e, t, i) => (h(this, q, e), h(this, M, t), h(this, re, s(this, et).call(this, i ?? "=")), this));
|
|
1935
|
-
a(this, "clone", () => new
|
|
1983
|
+
a(this, "clone", () => new Ne(s(this, q).clone(), s(this, M).clone(), s(this, re)));
|
|
1936
1984
|
/**
|
|
1937
1985
|
* Get the degree of the equation
|
|
1938
1986
|
* @param letter
|
|
@@ -2019,11 +2067,11 @@ const Ee = class Ee {
|
|
|
2019
2067
|
/**
|
|
2020
2068
|
* Multiply by the lcm denominator and divide by the gcm numerators.
|
|
2021
2069
|
*/
|
|
2022
|
-
a(this, "simplify", () => (this.multiply(
|
|
2070
|
+
a(this, "simplify", () => (this.multiply(U.lcm(...s(this, q).getDenominators(), ...s(this, M).getDenominators())), this.divide(U.gcd(...s(this, q).getNumerators(), ...s(this, M).getNumerators())), this));
|
|
2023
2071
|
// -----------------------------------------------
|
|
2024
|
-
a(this, "solve", () => new
|
|
2072
|
+
a(this, "solve", () => new At(this.clone()).solve());
|
|
2025
2073
|
a(this, "test", (e) => this.left.evaluate(e).isEqual(this.right.evaluate(e)));
|
|
2026
|
-
|
|
2074
|
+
m(this, Dt, (e) => {
|
|
2027
2075
|
if (e.includes("geq"))
|
|
2028
2076
|
return e.includes("\\geq") ? "\\geq" : "geq";
|
|
2029
2077
|
if (e.includes("leq"))
|
|
@@ -2046,13 +2094,13 @@ const Ee = class Ee {
|
|
|
2046
2094
|
});
|
|
2047
2095
|
// -----------------------------------------------
|
|
2048
2096
|
// Equations solving algorithms
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
if (h(this, q, new
|
|
2052
|
-
if (e instanceof
|
|
2097
|
+
m(this, et, (e) => e === void 0 ? "=" : e.includes("geq") || e.includes(">=") || e.includes("=>") ? ">=" : e.includes(">") ? ">" : e.includes("leq") || e.includes("<=") || e.includes("=<") ? "<=" : e.includes("<") ? "<" : "=");
|
|
2098
|
+
m(this, Zt, () => s(this, re) === "=" ? this : s(this, re).includes("<") ? (s(this, re).replace("<", ">"), this) : s(this, re).includes(">") ? (s(this, re).replace(">", "<"), this) : this);
|
|
2099
|
+
if (h(this, q, new O().zero()), h(this, M, new O().zero()), h(this, re, "="), e !== void 0 && t === void 0) {
|
|
2100
|
+
if (e instanceof Ne)
|
|
2053
2101
|
return e.clone();
|
|
2054
2102
|
typeof e == "string" && this.parse(e);
|
|
2055
|
-
} else e !== void 0 && t !== void 0 && (this.left = new
|
|
2103
|
+
} else e !== void 0 && t !== void 0 && (this.left = new O(e), this.right = new O(t));
|
|
2056
2104
|
return i !== void 0 && (this.sign = i), this;
|
|
2057
2105
|
}
|
|
2058
2106
|
/**
|
|
@@ -2064,11 +2112,11 @@ const Ee = class Ee {
|
|
|
2064
2112
|
* @param value | Polynom | Monom | Fraction | string | monom
|
|
2065
2113
|
*/
|
|
2066
2114
|
add(e) {
|
|
2067
|
-
if (e instanceof
|
|
2115
|
+
if (e instanceof Ne)
|
|
2068
2116
|
return s(this, q).add(e.left), s(this, M).add(e.right), this;
|
|
2069
|
-
if (typeof e == "string" && !
|
|
2070
|
-
return this.add(new
|
|
2071
|
-
const t = new
|
|
2117
|
+
if (typeof e == "string" && !Ne.isEquationString(e))
|
|
2118
|
+
return this.add(new Ne(e));
|
|
2119
|
+
const t = new O(e);
|
|
2072
2120
|
return s(this, q).add(t), s(this, M).add(t), this;
|
|
2073
2121
|
}
|
|
2074
2122
|
/**
|
|
@@ -2082,7 +2130,7 @@ const Ee = class Ee {
|
|
|
2082
2130
|
return t ? i === n : i.isEqual(n);
|
|
2083
2131
|
}
|
|
2084
2132
|
isEqual(e) {
|
|
2085
|
-
const t = new
|
|
2133
|
+
const t = new Ne(e);
|
|
2086
2134
|
return t.left.isEqual(s(this, q)) && t.right.isEqual(s(this, M));
|
|
2087
2135
|
}
|
|
2088
2136
|
pow(e) {
|
|
@@ -2095,11 +2143,11 @@ const Ee = class Ee {
|
|
|
2095
2143
|
return [s(this, q).clone(), s(this, M).clone()];
|
|
2096
2144
|
}
|
|
2097
2145
|
subtract(e) {
|
|
2098
|
-
if (e instanceof
|
|
2146
|
+
if (e instanceof Ne)
|
|
2099
2147
|
return s(this, q).subtract(e.left), s(this, M).subtract(e.right), this;
|
|
2100
|
-
if (typeof e == "string" && !
|
|
2101
|
-
return this.subtract(new
|
|
2102
|
-
const t = new
|
|
2148
|
+
if (typeof e == "string" && !Ne.isEquationString(e))
|
|
2149
|
+
return this.subtract(new Ne(e));
|
|
2150
|
+
const t = new O(e);
|
|
2103
2151
|
return s(this, q).subtract(t), s(this, M).subtract(t), this;
|
|
2104
2152
|
}
|
|
2105
2153
|
static isEquationString(e) {
|
|
@@ -2145,23 +2193,16 @@ const Ee = class Ee {
|
|
|
2145
2193
|
return [...new Set(s(this, M).variables.concat(s(this, q).variables))];
|
|
2146
2194
|
}
|
|
2147
2195
|
};
|
|
2148
|
-
q = new WeakMap(), M = new WeakMap(), re = new WeakMap(),
|
|
2149
|
-
let
|
|
2150
|
-
var
|
|
2196
|
+
q = new WeakMap(), M = new WeakMap(), re = new WeakMap(), Dt = new WeakMap(), et = new WeakMap(), Zt = new WeakMap();
|
|
2197
|
+
let H = Ne;
|
|
2198
|
+
var Te, Ae, be, tt;
|
|
2151
2199
|
const ve = class ve {
|
|
2152
2200
|
constructor(e, t) {
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
h(this, Oe, e.polynom.clone()), h(this, Te, e.power.clone());
|
|
2159
|
-
else if (typeof e == "string" && t === void 0) {
|
|
2160
|
-
const [i, n = "1"] = e.split("^");
|
|
2161
|
-
h(this, Oe, new T(i)), h(this, Te, new u(n.replace("(", "").replace(")", "")));
|
|
2162
|
-
} else
|
|
2163
|
-
h(this, Oe, new T(e)), h(this, Te, new u(t ?? 1));
|
|
2164
|
-
return h(this, Ne, 1), this;
|
|
2201
|
+
m(this, Te);
|
|
2202
|
+
m(this, Ae);
|
|
2203
|
+
m(this, be);
|
|
2204
|
+
m(this, tt, !1);
|
|
2205
|
+
return e instanceof ve ? (h(this, Ae, e.polynom.clone()), h(this, be, e.power.clone()), t !== void 0 && s(this, be).multiply(new u(t))) : e !== void 0 ? (h(this, Ae, new O(e)), h(this, be, new u(t ?? 1))) : (h(this, Ae, new O()), h(this, be, new u(1))), h(this, Te, 1), this;
|
|
2165
2206
|
}
|
|
2166
2207
|
parse() {
|
|
2167
2208
|
throw new Error("Method not implemented.");
|
|
@@ -2169,15 +2210,18 @@ const ve = class ve {
|
|
|
2169
2210
|
clone() {
|
|
2170
2211
|
return new ve(this);
|
|
2171
2212
|
}
|
|
2213
|
+
fromPolynom(e) {
|
|
2214
|
+
return h(this, Ae, new O(e)), h(this, be, new u(1)), this;
|
|
2215
|
+
}
|
|
2172
2216
|
get tex() {
|
|
2173
2217
|
const e = this.power.numerator, t = this.power.denominator;
|
|
2174
2218
|
let i, n;
|
|
2175
|
-
return s(this,
|
|
2219
|
+
return s(this, Te) === 0 && t > 1 ? (i = `\\sqrt${t === 2 ? "" : `[ ${t} ]`}{ ${this.polynom.tex} }`, n = e === 1 ? "" : `^{ ${e} }`) : (i = s(this, tt) && this.power.isOne() ? this.polynom.tex : yi(this.polynom.tex), n = t === 1 && e === 1 ? "" : `^{ ${this.power.tex} }`), i = `${i}${n}`, s(this, Te) === 0 && e < 0 && (i = `\\frac{ 1 }{ ${i} }`), i;
|
|
2176
2220
|
}
|
|
2177
2221
|
get display() {
|
|
2178
2222
|
const e = this.power.numerator, t = this.power.denominator;
|
|
2179
2223
|
let i, n;
|
|
2180
|
-
return s(this,
|
|
2224
|
+
return s(this, Te) === 0 && t > 1 ? (i = `${t === 2 ? "sqrt" : `root(${t})`}(${this.polynom.display})`, n = e === 1 ? "" : `^(${e})`) : (i = s(this, tt) && this.power.isOne() ? this.polynom.display : yi(this.polynom.display, !1), n = t === 1 && e === 1 ? "" : `^(${this.power.display})`), i = `${i}${n}`, s(this, Te) === 0 && e < 0 && (i = `1/(${i})`), i;
|
|
2181
2225
|
}
|
|
2182
2226
|
add() {
|
|
2183
2227
|
throw new Error("Adding two factors is not possible");
|
|
@@ -2189,7 +2233,7 @@ const ve = class ve {
|
|
|
2189
2233
|
return this.polynom.degree(e).multiply(this.power);
|
|
2190
2234
|
}
|
|
2191
2235
|
derivative() {
|
|
2192
|
-
return this.power.isZero() ? [new ve("0"
|
|
2236
|
+
return this.power.isZero() ? [new ve("0")] : this.power.isOne() ? [new ve(this.polynom.clone().derivative())] : [
|
|
2193
2237
|
new ve(this.power.clone()),
|
|
2194
2238
|
new ve(this.polynom.clone().derivative()),
|
|
2195
2239
|
new ve(this.polynom.clone(), this.power.clone().subtract(1))
|
|
@@ -2203,7 +2247,7 @@ const ve = class ve {
|
|
|
2203
2247
|
divide(e) {
|
|
2204
2248
|
if (e instanceof ve && this.isSameAs(e))
|
|
2205
2249
|
return this.power.subtract(e.power), this;
|
|
2206
|
-
const t = new
|
|
2250
|
+
const t = new O(e);
|
|
2207
2251
|
if (this.isSameAs(t))
|
|
2208
2252
|
return this.power.subtract(1), this;
|
|
2209
2253
|
throw new Error("The two factors must be the same");
|
|
@@ -2225,7 +2269,7 @@ const ve = class ve {
|
|
|
2225
2269
|
}
|
|
2226
2270
|
isSameAs(e) {
|
|
2227
2271
|
let t;
|
|
2228
|
-
return e instanceof ve ? t = e.polynom : e instanceof
|
|
2272
|
+
return e instanceof ve ? t = e.polynom : e instanceof O ? t = e : t = new O(e), this.polynom.isEqual(t);
|
|
2229
2273
|
}
|
|
2230
2274
|
isZero() {
|
|
2231
2275
|
return this.polynom.isZero();
|
|
@@ -2233,31 +2277,31 @@ const ve = class ve {
|
|
|
2233
2277
|
multiply(e) {
|
|
2234
2278
|
if (e instanceof ve && this.isSameAs(e))
|
|
2235
2279
|
return this.power.add(e.power), this;
|
|
2236
|
-
const t = new
|
|
2280
|
+
const t = new O(e);
|
|
2237
2281
|
if (this.isSameAs(t))
|
|
2238
2282
|
return this.power.add(1), this;
|
|
2239
2283
|
throw new Error("The two factors must be the same");
|
|
2240
2284
|
}
|
|
2241
2285
|
one() {
|
|
2242
|
-
return s(this,
|
|
2286
|
+
return s(this, Ae).one(), s(this, be).one(), this;
|
|
2243
2287
|
}
|
|
2244
2288
|
opposite() {
|
|
2245
2289
|
throw new Error("Method not implemented.");
|
|
2246
2290
|
}
|
|
2247
2291
|
get polynom() {
|
|
2248
|
-
return s(this,
|
|
2292
|
+
return s(this, Ae);
|
|
2249
2293
|
}
|
|
2250
2294
|
set polynom(e) {
|
|
2251
|
-
h(this,
|
|
2295
|
+
h(this, Ae, e);
|
|
2252
2296
|
}
|
|
2253
2297
|
pow(e) {
|
|
2254
2298
|
return this.power.multiply(e), this;
|
|
2255
2299
|
}
|
|
2256
2300
|
get power() {
|
|
2257
|
-
return s(this,
|
|
2301
|
+
return s(this, be);
|
|
2258
2302
|
}
|
|
2259
2303
|
set power(e) {
|
|
2260
|
-
h(this,
|
|
2304
|
+
h(this, be, new u(e));
|
|
2261
2305
|
}
|
|
2262
2306
|
primitive() {
|
|
2263
2307
|
throw new Error("Method not implemented.");
|
|
@@ -2274,48 +2318,48 @@ const ve = class ve {
|
|
|
2274
2318
|
subtract() {
|
|
2275
2319
|
throw new Error("Subtracting two factors is not possible");
|
|
2276
2320
|
}
|
|
2277
|
-
tableOfSigns(
|
|
2278
|
-
const
|
|
2279
|
-
return
|
|
2321
|
+
tableOfSigns() {
|
|
2322
|
+
const e = this.power.clone().reduce(), t = this.polynom.tableOfSigns();
|
|
2323
|
+
return e.isStrictlyNegative() && (t.signs = Et(t.signs, "z", "d")), e.denominator % 2 === 0 ? t.signs = Et(t.signs, "-", "h") : e.numerator % 2 === 0 && (t.signs = Et(t.signs, "-", "+")), { roots: t.roots, signs: t.signs };
|
|
2280
2324
|
}
|
|
2281
2325
|
get variables() {
|
|
2282
2326
|
return this.polynom.variables;
|
|
2283
2327
|
}
|
|
2284
2328
|
get withPower() {
|
|
2285
|
-
return h(this,
|
|
2329
|
+
return h(this, Te, 1), this;
|
|
2286
2330
|
}
|
|
2287
2331
|
get withRoot() {
|
|
2288
|
-
return h(this,
|
|
2332
|
+
return h(this, Te, 0), this;
|
|
2289
2333
|
}
|
|
2290
2334
|
zero() {
|
|
2291
|
-
return s(this,
|
|
2335
|
+
return s(this, Ae).zero(), s(this, be).one(), this;
|
|
2292
2336
|
}
|
|
2293
2337
|
};
|
|
2294
|
-
|
|
2295
|
-
let
|
|
2296
|
-
var
|
|
2338
|
+
Te = new WeakMap(), Ae = new WeakMap(), be = new WeakMap(), tt = new WeakMap();
|
|
2339
|
+
let ae = ve;
|
|
2340
|
+
var lt = /* @__PURE__ */ ((o) => (o[o.ROOT = 0] = "ROOT", o[o.POWER = 1] = "POWER", o))(lt || {}), D, $e, Ft, jt;
|
|
2297
2341
|
const Xe = class Xe {
|
|
2298
2342
|
constructor(...e) {
|
|
2299
|
-
|
|
2343
|
+
m(this, D);
|
|
2300
2344
|
// Determine the letters in the linear system, usually ['x', 'y']
|
|
2301
|
-
|
|
2302
|
-
a(this, "parse", (...e) => (h(this, D, e.map((t) => new
|
|
2345
|
+
m(this, $e);
|
|
2346
|
+
a(this, "parse", (...e) => (h(this, D, e.map((t) => new H(t))), s(this, Ft).call(this), this));
|
|
2303
2347
|
a(this, "clone", () => new Xe().parse(...s(this, D).map((e) => e.clone())));
|
|
2304
2348
|
a(this, "buildTex", (e, t) => {
|
|
2305
2349
|
let i, n, r = [];
|
|
2306
2350
|
const l = [];
|
|
2307
|
-
for (const
|
|
2308
|
-
r = r.concat(
|
|
2351
|
+
for (const f of e)
|
|
2352
|
+
r = r.concat(f.letters());
|
|
2309
2353
|
r = [...new Set(r)], r.sort();
|
|
2310
|
-
for (let
|
|
2311
|
-
const
|
|
2354
|
+
for (let f = 0; f < e.length; f++) {
|
|
2355
|
+
const d = e[f];
|
|
2312
2356
|
i = [];
|
|
2313
|
-
for (const
|
|
2314
|
-
n =
|
|
2315
|
-
if (i.push("="), i.push(
|
|
2357
|
+
for (const p of r)
|
|
2358
|
+
n = d.left.monomByLetter(p), i.length === 0 ? i.push(n.isZero() ? "" : n.tex) : i.push(n.isZero() ? "" : (n.coefficient.sign() === 1 ? "+" : "") + n.tex);
|
|
2359
|
+
if (i.push("="), i.push(d.right.tex), (t == null ? void 0 : t[f]) !== void 0) {
|
|
2316
2360
|
i[i.length - 1] = i[i.length - 1] + " \\phantom{\\quad}";
|
|
2317
|
-
for (const
|
|
2318
|
-
i.push(`\\ \\cdot\\ ${
|
|
2361
|
+
for (const p of t[f])
|
|
2362
|
+
i.push(`\\ \\cdot\\ ${p.startsWith("-") ? "\\left(" + p + "\\right)" : p}`);
|
|
2319
2363
|
}
|
|
2320
2364
|
l.push(i.join("&"));
|
|
2321
2365
|
}
|
|
@@ -2341,16 +2385,16 @@ const Xe = class Xe {
|
|
|
2341
2385
|
if (l === n)
|
|
2342
2386
|
continue;
|
|
2343
2387
|
const c = i[l][n].clone().opposite();
|
|
2344
|
-
for (let
|
|
2345
|
-
i[l][
|
|
2346
|
-
if (i[l].slice(0, i[l].length - 1).every((
|
|
2388
|
+
for (let f = 0; f < i[l].length; f++)
|
|
2389
|
+
i[l][f].add(i[n][f].clone().multiply(c));
|
|
2390
|
+
if (i[l].slice(0, i[l].length - 1).every((f) => f.isZero()))
|
|
2347
2391
|
return i[l][i[l].length - 1].isZero() ? [new u().infinite()] : [];
|
|
2348
2392
|
}
|
|
2349
2393
|
}
|
|
2350
2394
|
return i.map((n) => n[n.length - 1]);
|
|
2351
2395
|
});
|
|
2352
|
-
|
|
2353
|
-
|
|
2396
|
+
m(this, Ft, () => (h(this, $e, s(this, D).reduce((e, t) => [.../* @__PURE__ */ new Set([...e, ...t.variables])], [])), s(this, $e).sort(), this));
|
|
2397
|
+
m(this, jt, () => {
|
|
2354
2398
|
const e = [], t = [];
|
|
2355
2399
|
for (const i of s(this, D)) {
|
|
2356
2400
|
const n = [], r = i.clone().reorder();
|
|
@@ -2371,8 +2415,8 @@ const Xe = class Xe {
|
|
|
2371
2415
|
const n = t.split("").splice(0, i - 1);
|
|
2372
2416
|
return new Xe(
|
|
2373
2417
|
...e.map((r) => {
|
|
2374
|
-
const l = new
|
|
2375
|
-
return new
|
|
2418
|
+
const l = new O(n.join(""), ...r);
|
|
2419
|
+
return new H(l, 0);
|
|
2376
2420
|
})
|
|
2377
2421
|
);
|
|
2378
2422
|
}
|
|
@@ -2386,7 +2430,7 @@ const Xe = class Xe {
|
|
|
2386
2430
|
} else {
|
|
2387
2431
|
if (t === void 0 || t < 0 || t >= s(this, D).length)
|
|
2388
2432
|
throw new Error("Index out of range");
|
|
2389
|
-
const i = new
|
|
2433
|
+
const i = new H(e);
|
|
2390
2434
|
s(this, D)[t].add(i);
|
|
2391
2435
|
}
|
|
2392
2436
|
return this;
|
|
@@ -2447,7 +2491,7 @@ const Xe = class Xe {
|
|
|
2447
2491
|
} else {
|
|
2448
2492
|
if (t === void 0 || t < 0 || t >= s(this, D).length)
|
|
2449
2493
|
throw new Error("Index out of range");
|
|
2450
|
-
const i = new
|
|
2494
|
+
const i = new H(e);
|
|
2451
2495
|
s(this, D)[t].subtract(i);
|
|
2452
2496
|
}
|
|
2453
2497
|
return this;
|
|
@@ -2465,25 +2509,25 @@ const Xe = class Xe {
|
|
|
2465
2509
|
}
|
|
2466
2510
|
};
|
|
2467
2511
|
D = new WeakMap(), $e = new WeakMap(), Ft = new WeakMap(), jt = new WeakMap();
|
|
2468
|
-
let
|
|
2469
|
-
var
|
|
2470
|
-
class
|
|
2512
|
+
let ti = Xe;
|
|
2513
|
+
var Oe, mt, ii;
|
|
2514
|
+
class ss {
|
|
2471
2515
|
/**
|
|
2472
2516
|
*
|
|
2473
2517
|
* @param {string} value (optional) Default polynom to parse on class creation
|
|
2474
2518
|
*/
|
|
2475
2519
|
constructor(e) {
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
a(this, "parse", (e) => (h(this,
|
|
2479
|
-
return h(this,
|
|
2520
|
+
m(this, mt);
|
|
2521
|
+
m(this, Oe);
|
|
2522
|
+
a(this, "parse", (e) => (h(this, Oe, new Kt(Ze.SET).parse(e).rpn), this));
|
|
2523
|
+
return h(this, Oe, []), e !== void 0 && this.parse(e), this;
|
|
2480
2524
|
}
|
|
2481
2525
|
evaluate(e) {
|
|
2482
2526
|
this.variables.forEach((i) => {
|
|
2483
2527
|
Object.hasOwn(e, i) || (e[i] = !1);
|
|
2484
2528
|
});
|
|
2485
2529
|
const t = [];
|
|
2486
|
-
for (const i of s(this,
|
|
2530
|
+
for (const i of s(this, Oe))
|
|
2487
2531
|
if (console.log(i), i.tokenType === "variable")
|
|
2488
2532
|
t.push(e[i.token]);
|
|
2489
2533
|
else if (i.tokenType === "operation")
|
|
@@ -2512,11 +2556,11 @@ class ts {
|
|
|
2512
2556
|
return t.length === 1 && t[0];
|
|
2513
2557
|
}
|
|
2514
2558
|
get rpn() {
|
|
2515
|
-
return s(this,
|
|
2559
|
+
return s(this, Oe);
|
|
2516
2560
|
}
|
|
2517
2561
|
get tex() {
|
|
2518
2562
|
const e = [];
|
|
2519
|
-
for (const t of s(this,
|
|
2563
|
+
for (const t of s(this, Oe))
|
|
2520
2564
|
if (t.tokenType === "variable")
|
|
2521
2565
|
e.push(t);
|
|
2522
2566
|
else
|
|
@@ -2549,23 +2593,23 @@ class ts {
|
|
|
2549
2593
|
return e[0].token;
|
|
2550
2594
|
}
|
|
2551
2595
|
get variables() {
|
|
2552
|
-
return s(this,
|
|
2596
|
+
return s(this, Oe).filter((e) => e.tokenType === "variable").map((e) => e.token);
|
|
2553
2597
|
}
|
|
2554
2598
|
vennAB() {
|
|
2555
|
-
return A(this,
|
|
2599
|
+
return A(this, mt, ii).call(this, {
|
|
2556
2600
|
A: ["A", "AB"],
|
|
2557
2601
|
B: ["B", "AB"]
|
|
2558
2602
|
}, ["A", "B", "AB", "E"]);
|
|
2559
2603
|
}
|
|
2560
2604
|
vennABC() {
|
|
2561
|
-
return A(this,
|
|
2605
|
+
return A(this, mt, ii).call(this, {
|
|
2562
2606
|
A: ["A", "AB", "AC", "ABC"],
|
|
2563
2607
|
B: ["B", "AB", "BC", "ABC"],
|
|
2564
2608
|
C: ["C", "AC", "BC", "ABC"]
|
|
2565
2609
|
}, ["A", "B", "C", "AB", "AC", "BC", "ABC", "E"]);
|
|
2566
2610
|
}
|
|
2567
2611
|
}
|
|
2568
|
-
|
|
2612
|
+
Oe = new WeakMap(), mt = new WeakSet(), ii = function(e, t) {
|
|
2569
2613
|
const i = [];
|
|
2570
2614
|
let n;
|
|
2571
2615
|
if (t === void 0) {
|
|
@@ -2577,7 +2621,7 @@ Ae = new WeakMap(), gt = new WeakSet(), si = function(e, t) {
|
|
|
2577
2621
|
]);
|
|
2578
2622
|
} else
|
|
2579
2623
|
n = new Set(t);
|
|
2580
|
-
for (const r of s(this,
|
|
2624
|
+
for (const r of s(this, Oe))
|
|
2581
2625
|
if (r.tokenType === "variable")
|
|
2582
2626
|
e[r.token] === void 0 ? i.push(/* @__PURE__ */ new Set()) : i.push(new Set(e[r.token]));
|
|
2583
2627
|
else
|
|
@@ -2585,7 +2629,7 @@ Ae = new WeakMap(), gt = new WeakSet(), si = function(e, t) {
|
|
|
2585
2629
|
case "&":
|
|
2586
2630
|
if (i.length >= 2) {
|
|
2587
2631
|
const l = i.pop(), c = i.pop();
|
|
2588
|
-
c && l && i.push(new Set([...c].filter((
|
|
2632
|
+
c && l && i.push(new Set([...c].filter((f) => l.has(f))));
|
|
2589
2633
|
}
|
|
2590
2634
|
break;
|
|
2591
2635
|
case "|":
|
|
@@ -2597,7 +2641,7 @@ Ae = new WeakMap(), gt = new WeakSet(), si = function(e, t) {
|
|
|
2597
2641
|
case "-":
|
|
2598
2642
|
if (i.length >= 2) {
|
|
2599
2643
|
const l = i.pop(), c = i.pop();
|
|
2600
|
-
c && l && i.push(new Set([...c].filter((
|
|
2644
|
+
c && l && i.push(new Set([...c].filter((f) => !l.has(f))));
|
|
2601
2645
|
}
|
|
2602
2646
|
break;
|
|
2603
2647
|
case "!":
|
|
@@ -2609,112 +2653,113 @@ Ae = new WeakMap(), gt = new WeakSet(), si = function(e, t) {
|
|
|
2609
2653
|
}
|
|
2610
2654
|
return [...i[0]].sort();
|
|
2611
2655
|
};
|
|
2612
|
-
var it, N,
|
|
2613
|
-
const
|
|
2656
|
+
var it, N, We, ni, ki, gt, ri;
|
|
2657
|
+
const X = class X {
|
|
2614
2658
|
constructor(...e) {
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2659
|
+
m(this, gt);
|
|
2660
|
+
m(this, it, lt.POWER);
|
|
2661
|
+
m(this, N, []);
|
|
2618
2662
|
return this.parse(...e), this;
|
|
2619
2663
|
}
|
|
2620
2664
|
parse(...e) {
|
|
2621
|
-
return e.length === 0 ? this : (
|
|
2622
|
-
|
|
2623
|
-
const i = t.split(")(").join(")*(").split("*");
|
|
2624
|
-
s(this, N).push(...i.map((n) => new ie(n)));
|
|
2625
|
-
} else t instanceof G ? s(this, N).push(...t.factors.map((i) => i.clone())) : s(this, N).push(new ie(t));
|
|
2665
|
+
return h(this, N, []), e.length === 0 ? this : (e.forEach((t) => {
|
|
2666
|
+
t instanceof X ? s(this, N).push(...t.factors.map((i) => i.clone())) : s(this, N).push(new ae(t));
|
|
2626
2667
|
}), this);
|
|
2627
2668
|
}
|
|
2628
2669
|
clone() {
|
|
2629
|
-
return new
|
|
2670
|
+
return new X(...s(this, N).map((e) => e.clone()));
|
|
2630
2671
|
}
|
|
2631
2672
|
get tex() {
|
|
2632
|
-
const { num: e, den: t } = A(this,
|
|
2673
|
+
const { num: e, den: t } = A(this, gt, ri).call(this);
|
|
2633
2674
|
if (t.length === 0)
|
|
2634
2675
|
return e.length === 1 ? e[0].asSingle.tex : e.map((r) => r.tex).join("");
|
|
2635
2676
|
const i = e.length === 1 ? e[0].asSingle.tex : e.map((r) => r.tex).join(""), n = t.length === 1 ? t[0].asSingle.tex : t.map((r) => r.tex).join("");
|
|
2636
2677
|
return `\\frac{ ${i} }{ ${n} }`;
|
|
2637
2678
|
}
|
|
2638
2679
|
get display() {
|
|
2639
|
-
const { num: e, den: t } = A(this,
|
|
2680
|
+
const { num: e, den: t } = A(this, gt, ri).call(this);
|
|
2640
2681
|
if (t.length === 0)
|
|
2641
|
-
return e.length === 1 ? e[0].asSingle.display : e.map(
|
|
2682
|
+
return e.length === 1 ? e[0].asSingle.display : e.map(
|
|
2683
|
+
(r, l) => l === 0 && r.polynom.monoms.length === 1 ? r.asSingle.display : r.display
|
|
2684
|
+
).join("");
|
|
2642
2685
|
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("");
|
|
2643
2686
|
return `(${i})/(${n})`;
|
|
2644
2687
|
}
|
|
2645
2688
|
static gcd(...e) {
|
|
2646
2689
|
var i;
|
|
2647
2690
|
if (e.length === 0)
|
|
2648
|
-
return new
|
|
2691
|
+
return new X().one();
|
|
2649
2692
|
if (e.length === 1)
|
|
2650
2693
|
return e[0];
|
|
2651
2694
|
if (e.length === 2)
|
|
2652
|
-
return A(i =
|
|
2695
|
+
return A(i = X, We, ni).call(i, e[0], e[1]);
|
|
2653
2696
|
let t = e[0];
|
|
2654
2697
|
return e.shift(), e.forEach((n) => {
|
|
2655
2698
|
var r;
|
|
2656
|
-
return t = A(r =
|
|
2699
|
+
return t = A(r = X, We, ni).call(r, t, n);
|
|
2657
2700
|
}), t;
|
|
2658
2701
|
}
|
|
2659
2702
|
static lcm(...e) {
|
|
2660
2703
|
if (e.length === 0)
|
|
2661
|
-
return new
|
|
2704
|
+
return new X().one();
|
|
2662
2705
|
if (e.length === 1)
|
|
2663
2706
|
return e[0];
|
|
2664
2707
|
let t = e[0];
|
|
2665
2708
|
return e.shift(), e.forEach((i) => {
|
|
2666
2709
|
var n;
|
|
2667
|
-
return t = A(n =
|
|
2710
|
+
return t = A(n = X, We, ki).call(n, t, i);
|
|
2668
2711
|
}), t;
|
|
2669
2712
|
}
|
|
2670
2713
|
add(...e) {
|
|
2671
2714
|
const t = [this.numerator, ...e.map((c) => c.numerator)], i = [this.denominator, ...e.map((c) => c.denominator)];
|
|
2672
2715
|
let n;
|
|
2673
2716
|
if (i.some((c) => c.factors.length > 0)) {
|
|
2674
|
-
const c =
|
|
2675
|
-
t.forEach((
|
|
2676
|
-
|
|
2717
|
+
const c = X.lcm(...i);
|
|
2718
|
+
t.forEach((f, d) => {
|
|
2719
|
+
f.multiply(c.clone().divide(i[d]));
|
|
2677
2720
|
}), n = c;
|
|
2678
2721
|
}
|
|
2679
|
-
const r =
|
|
2722
|
+
const r = X.gcd(...t), l = new O(0).add(
|
|
2680
2723
|
...t.map((c) => c.divide(r).reduce().develop().factors[0].polynom)
|
|
2681
|
-
);
|
|
2724
|
+
).reduce();
|
|
2682
2725
|
return h(this, N, [
|
|
2683
2726
|
...r.factors,
|
|
2684
|
-
new
|
|
2727
|
+
new ae(l)
|
|
2685
2728
|
]), n && this.divide(n), h(this, N, s(this, N).filter((c) => !c.power.isZero())), this;
|
|
2686
2729
|
}
|
|
2687
2730
|
get asPower() {
|
|
2688
|
-
return h(this, it,
|
|
2731
|
+
return h(this, it, lt.POWER), this;
|
|
2689
2732
|
}
|
|
2690
2733
|
get asRoot() {
|
|
2691
|
-
return h(this, it,
|
|
2734
|
+
return h(this, it, lt.ROOT), this;
|
|
2692
2735
|
}
|
|
2693
2736
|
degree(e) {
|
|
2694
2737
|
return s(this, N).reduce((t, i) => t.add(i.degree(e)), new u("0"));
|
|
2695
2738
|
}
|
|
2696
2739
|
get denominator() {
|
|
2697
|
-
return new
|
|
2740
|
+
return new X(
|
|
2698
2741
|
...s(this, N).filter((e) => e.power.isNegative()).map((e) => e.clone().inverse())
|
|
2699
2742
|
);
|
|
2700
2743
|
}
|
|
2701
2744
|
derivative() {
|
|
2702
2745
|
const e = [], t = s(this, N).length;
|
|
2703
2746
|
for (let n = 0; n < t; n++) {
|
|
2704
|
-
const r = s(this, N).slice(), l = r.splice(n, 1)[0];
|
|
2705
|
-
e.push(
|
|
2747
|
+
const r = s(this, N).slice(), l = r.splice(n, 1)[0].derivative();
|
|
2748
|
+
e.push(
|
|
2749
|
+
new X(...r, ...l)
|
|
2750
|
+
);
|
|
2706
2751
|
}
|
|
2707
2752
|
e.forEach((n) => n.reduce());
|
|
2708
2753
|
const i = e.shift();
|
|
2709
2754
|
return i !== void 0 && h(this, N, i.factors), this.add(...e);
|
|
2710
2755
|
}
|
|
2711
2756
|
develop() {
|
|
2712
|
-
const e = new
|
|
2757
|
+
const e = new O("1"), t = new O("1");
|
|
2713
2758
|
return this.numerator.factors.forEach((i) => {
|
|
2714
2759
|
e.multiply(i.develop());
|
|
2715
2760
|
}), this.denominator.factors.forEach((i) => {
|
|
2716
2761
|
t.multiply(i.develop());
|
|
2717
|
-
}), new
|
|
2762
|
+
}), new X().fromPolynom(e, t);
|
|
2718
2763
|
}
|
|
2719
2764
|
divide(e) {
|
|
2720
2765
|
return h(this, N, s(this, N).concat(e.clone().factors.map((t) => t.inverse()))), this;
|
|
@@ -2727,12 +2772,12 @@ const G = class G {
|
|
|
2727
2772
|
s(this, N).forEach((l) => {
|
|
2728
2773
|
const c = l.polynom.factorize(e);
|
|
2729
2774
|
if (c.length > 1) {
|
|
2730
|
-
const
|
|
2731
|
-
t.push(...c.map((
|
|
2775
|
+
const f = l.power.clone();
|
|
2776
|
+
t.push(...c.map((d) => new ae(d, f)));
|
|
2732
2777
|
} else
|
|
2733
2778
|
t.push(l.clone());
|
|
2734
2779
|
});
|
|
2735
|
-
const i = new
|
|
2780
|
+
const i = new X(...t), n = i.numerator.reduce(), r = i.denominator.reduce();
|
|
2736
2781
|
return n.divide(r);
|
|
2737
2782
|
}
|
|
2738
2783
|
get factors() {
|
|
@@ -2742,13 +2787,13 @@ const G = class G {
|
|
|
2742
2787
|
h(this, N, e);
|
|
2743
2788
|
}
|
|
2744
2789
|
fromPolynom(e, t) {
|
|
2745
|
-
if (h(this, N, [new
|
|
2746
|
-
const i = new
|
|
2790
|
+
if (h(this, N, [new ae(new O(e))]), t) {
|
|
2791
|
+
const i = new O(t);
|
|
2747
2792
|
if (i.isOne())
|
|
2748
2793
|
return this;
|
|
2749
2794
|
if (i.isZero())
|
|
2750
2795
|
throw new Error("Cannot divide by zero");
|
|
2751
|
-
s(this, N).push(new
|
|
2796
|
+
s(this, N).push(new ae(i, -1));
|
|
2752
2797
|
}
|
|
2753
2798
|
return this;
|
|
2754
2799
|
}
|
|
@@ -2767,7 +2812,7 @@ const G = class G {
|
|
|
2767
2812
|
return h(this, N, s(this, N).map((e) => e.inverse())), this;
|
|
2768
2813
|
}
|
|
2769
2814
|
isEqual(e) {
|
|
2770
|
-
const t =
|
|
2815
|
+
const t = X.gcd(this, e), i = this.clone().divide(t).reduce(), n = e.clone().divide(t).reduce();
|
|
2771
2816
|
return i.isOne() && n.isOne();
|
|
2772
2817
|
}
|
|
2773
2818
|
isOne() {
|
|
@@ -2782,14 +2827,14 @@ const G = class G {
|
|
|
2782
2827
|
}), this;
|
|
2783
2828
|
}
|
|
2784
2829
|
get numerator() {
|
|
2785
|
-
return new
|
|
2830
|
+
return new X(...s(this, N).filter((e) => e.power.isPositive()));
|
|
2786
2831
|
}
|
|
2787
2832
|
one() {
|
|
2788
|
-
return h(this, N, [new
|
|
2833
|
+
return h(this, N, [new ae("1", "1")]), this;
|
|
2789
2834
|
}
|
|
2790
2835
|
opposite() {
|
|
2791
2836
|
const e = s(this, N).findIndex((t) => t.display === "(-1)");
|
|
2792
|
-
return e >= 0 ? s(this, N).splice(e, 1) : s(this, N).push(new
|
|
2837
|
+
return e >= 0 ? s(this, N).splice(e, 1) : s(this, N).push(new ae("-1", "1")), this;
|
|
2793
2838
|
}
|
|
2794
2839
|
pow(e) {
|
|
2795
2840
|
return h(this, N, s(this, N).map((t) => t.pow(e))), this;
|
|
@@ -2801,14 +2846,29 @@ const G = class G {
|
|
|
2801
2846
|
const e = ht(this);
|
|
2802
2847
|
return h(this, N, Object.values(e).map((t) => {
|
|
2803
2848
|
const i = t[0].polynom, n = t.reduce((r, l) => r.add(l.power), new u("0"));
|
|
2804
|
-
return new
|
|
2849
|
+
return new ae(i, n.reduce());
|
|
2805
2850
|
}).filter((t) => !t.power.isZero())), this;
|
|
2806
2851
|
}
|
|
2807
2852
|
root(e) {
|
|
2808
2853
|
return h(this, N, s(this, N).map((t) => t.root(e))), this;
|
|
2809
2854
|
}
|
|
2810
|
-
|
|
2811
|
-
|
|
2855
|
+
/**
|
|
2856
|
+
* Reoarder the factors using :
|
|
2857
|
+
* 1. number of monoms
|
|
2858
|
+
* 2. degree of polynom
|
|
2859
|
+
* 3. power of polyfactor
|
|
2860
|
+
*/
|
|
2861
|
+
sort(e) {
|
|
2862
|
+
return s(this, N).sort((t, i) => {
|
|
2863
|
+
const n = t.power.value, r = i.power.value;
|
|
2864
|
+
if (n * r < 0)
|
|
2865
|
+
return -n;
|
|
2866
|
+
const l = t.polynom.monoms.length, c = i.polynom.monoms.length;
|
|
2867
|
+
if (l !== c)
|
|
2868
|
+
return l - c;
|
|
2869
|
+
const f = t.polynom.degree(e).value, d = i.polynom.degree(e).value;
|
|
2870
|
+
return f !== d ? f - d : n !== r ? n - r : t.degree().isLeq(i.degree()) ? -1 : 1;
|
|
2871
|
+
}), this;
|
|
2812
2872
|
}
|
|
2813
2873
|
sqrt() {
|
|
2814
2874
|
return h(this, N, s(this, N).map((e) => e.sqrt())), this;
|
|
@@ -2817,48 +2877,60 @@ const G = class G {
|
|
|
2817
2877
|
return this.add(...e.map((t) => t.opposite()));
|
|
2818
2878
|
}
|
|
2819
2879
|
tableOfSigns() {
|
|
2820
|
-
const e = this.getZeroes(), t = this.factors.map((
|
|
2821
|
-
return
|
|
2822
|
-
|
|
2880
|
+
const e = this.getZeroes(), t = e.map((r) => r.value), i = this.factors.map((r) => ({ factor: new ae(r), ...r.tableOfSigns() }));
|
|
2881
|
+
return i.forEach((r) => {
|
|
2882
|
+
const l = new Array(2 * e.length + 1).fill("");
|
|
2883
|
+
let c = r.signs.shift(), f = r.roots.shift();
|
|
2884
|
+
const d = l.map((p, w) => {
|
|
2885
|
+
if (w % 2 === 0)
|
|
2886
|
+
return c;
|
|
2887
|
+
if (f === void 0 || f.value !== t[(w - 1) / 2])
|
|
2888
|
+
return "t";
|
|
2889
|
+
const V = r.signs.shift();
|
|
2890
|
+
return c = r.signs.shift(), f = r.roots.shift(), V;
|
|
2891
|
+
});
|
|
2892
|
+
r.roots = e, r.signs = d;
|
|
2893
|
+
}), { signs: i.map((r) => r.signs).reduce((r, l) => r.length === 0 ? l : (l.forEach((c, f) => {
|
|
2894
|
+
switch (c) {
|
|
2823
2895
|
case "d":
|
|
2824
|
-
|
|
2896
|
+
r[f] = "d";
|
|
2825
2897
|
break;
|
|
2826
2898
|
case "z":
|
|
2827
|
-
|
|
2899
|
+
r[f] = r[f] === "d" ? "d" : "z";
|
|
2828
2900
|
break;
|
|
2829
2901
|
case "h":
|
|
2830
|
-
|
|
2902
|
+
r[f] = "h";
|
|
2831
2903
|
break;
|
|
2832
2904
|
case "-":
|
|
2833
|
-
|
|
2905
|
+
r[f] = r[f] === "h" ? "h" : r[f] === "-" ? "+" : "-";
|
|
2834
2906
|
break;
|
|
2835
2907
|
}
|
|
2836
|
-
}),
|
|
2908
|
+
}), r), []), roots: e, factors: i };
|
|
2837
2909
|
}
|
|
2838
2910
|
get variables() {
|
|
2839
2911
|
return s(this, N).reduce((e, t) => e.concat(t.variables), []);
|
|
2840
2912
|
}
|
|
2841
2913
|
zero() {
|
|
2842
|
-
return h(this, N, [new
|
|
2914
|
+
return h(this, N, [new ae("0", "1")]), this;
|
|
2843
2915
|
}
|
|
2844
2916
|
};
|
|
2845
|
-
it = new WeakMap(), N = new WeakMap(),
|
|
2917
|
+
it = new WeakMap(), N = new WeakMap(), We = new WeakSet(), ni = function(e, t) {
|
|
2846
2918
|
const i = ht(e), n = ht(t), l = Object.keys(i).filter((c) => Object.hasOwn(n, c)).map((c) => {
|
|
2847
|
-
const
|
|
2848
|
-
return new
|
|
2919
|
+
const f = i[c].reduce((p, w) => p.add(w.power), new u("0")), d = n[c].reduce((p, w) => p.add(w.power), new u("0"));
|
|
2920
|
+
return new ae(c, u.min(f, d));
|
|
2849
2921
|
});
|
|
2850
|
-
return new
|
|
2851
|
-
},
|
|
2922
|
+
return new X(...l);
|
|
2923
|
+
}, ki = function(e, t) {
|
|
2852
2924
|
const i = ht(e), n = ht(t), l = [.../* @__PURE__ */ new Set([...Object.keys(i), ...Object.keys(n)])].map((c) => {
|
|
2853
|
-
const
|
|
2854
|
-
return new
|
|
2925
|
+
const f = Object.hasOwn(i, c) ? i[c].reduce((p, w) => p.add(w.power), new u("0")) : new u(0), d = Object.hasOwn(n, c) ? n[c].reduce((p, w) => p.add(w.power), new u("0")) : new u(0);
|
|
2926
|
+
return new ae(c, u.max(f, d));
|
|
2855
2927
|
});
|
|
2856
|
-
return new
|
|
2857
|
-
},
|
|
2928
|
+
return new X(...l);
|
|
2929
|
+
}, gt = new WeakSet(), ri = function() {
|
|
2858
2930
|
let e, t = [];
|
|
2859
|
-
return s(this, it) ===
|
|
2860
|
-
},
|
|
2861
|
-
let
|
|
2931
|
+
return s(this, it) === lt.ROOT ? (e = this.numerator.factors, t = this.denominator.factors) : e = s(this, N), e.length === 0 && (e = [new ae("1")]), { num: e, den: t };
|
|
2932
|
+
}, m(X, We);
|
|
2933
|
+
let si = X;
|
|
2862
2934
|
function ht(o) {
|
|
2863
2935
|
const e = new u().one(), t = o.factors.reduce((i, n) => {
|
|
2864
2936
|
if (n.polynom.degree().isZero())
|
|
@@ -2866,14 +2938,14 @@ function ht(o) {
|
|
|
2866
2938
|
const r = n.polynom.display;
|
|
2867
2939
|
return Object.hasOwn(i, r) ? i[r].push(n) : i[r] = [n], i;
|
|
2868
2940
|
}, {});
|
|
2869
|
-
return e.isOne() || (t[e.display] = [new
|
|
2941
|
+
return e.isOne() || (t[e.display] = [new ae(e.display, 1)]), t;
|
|
2870
2942
|
}
|
|
2871
|
-
function
|
|
2943
|
+
function ns(o, e) {
|
|
2872
2944
|
return o.dimension === e.dimension && o.array.every(
|
|
2873
2945
|
(t, i) => e.array[i].isEqual(t)
|
|
2874
2946
|
);
|
|
2875
2947
|
}
|
|
2876
|
-
function
|
|
2948
|
+
function rs(o, e) {
|
|
2877
2949
|
if (o.dimension !== e.dimension)
|
|
2878
2950
|
return !1;
|
|
2879
2951
|
const t = e.array[0].value / o.array[0].value;
|
|
@@ -2881,14 +2953,18 @@ function ss(o, e) {
|
|
|
2881
2953
|
(i, n) => e.array[n].value === i.value * t
|
|
2882
2954
|
);
|
|
2883
2955
|
}
|
|
2884
|
-
function
|
|
2956
|
+
function os(o, e) {
|
|
2885
2957
|
return o.dimension !== e.dimension ? new u().invalid() : o.array.reduce(
|
|
2886
2958
|
(t, i, n) => t.add(i.clone().multiply(e.array[n])),
|
|
2887
2959
|
new u(0)
|
|
2888
2960
|
);
|
|
2889
2961
|
}
|
|
2890
|
-
function
|
|
2891
|
-
|
|
2962
|
+
function hs(...o) {
|
|
2963
|
+
if (o.some((e) => e.dimension !== o[0].dimension))
|
|
2964
|
+
throw new Error("All vectors must have the same dimension");
|
|
2965
|
+
if (o[0].dimension !== o.length)
|
|
2966
|
+
throw new Error(`The determinant of dimension ${o[0].dimension} must have the same number of vectors (${o.length} given)`);
|
|
2967
|
+
return 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(
|
|
2892
2968
|
o[1].array[1].clone().multiply(o[2].array[2]).subtract(o[1].array[2].clone().multiply(o[2].array[1]))
|
|
2893
2969
|
).subtract(
|
|
2894
2970
|
o[0].array[1].clone().multiply(
|
|
@@ -2896,11 +2972,11 @@ function rs(...o) {
|
|
|
2896
2972
|
)
|
|
2897
2973
|
).add(o[0].array[2].clone().multiply(o[1].array[0].clone().multiply(o[2].array[1]).subtract(o[1].array[1].clone().multiply(o[2].array[0]))));
|
|
2898
2974
|
}
|
|
2899
|
-
var F,
|
|
2975
|
+
var F, Le;
|
|
2900
2976
|
const Se = class Se {
|
|
2901
2977
|
constructor(...e) {
|
|
2902
|
-
|
|
2903
|
-
|
|
2978
|
+
m(this, F, []);
|
|
2979
|
+
m(this, Le, !1);
|
|
2904
2980
|
a(this, "zero", () => (s(this, F).forEach((e) => e.zero()), this));
|
|
2905
2981
|
a(this, "one", () => (this.zero(), this.x.one(), this));
|
|
2906
2982
|
a(this, "opposite", () => (s(this, F).forEach((e) => e.opposite()), this));
|
|
@@ -2910,15 +2986,15 @@ const Se = class Se {
|
|
|
2910
2986
|
const e = this.norm;
|
|
2911
2987
|
return e === 0 ? this : this.divideByScalar(e);
|
|
2912
2988
|
});
|
|
2913
|
-
a(this, "dot", (e) =>
|
|
2989
|
+
a(this, "dot", (e) => os(this, e));
|
|
2914
2990
|
a(this, "normal", () => {
|
|
2915
2991
|
if (this.dimension >= 3)
|
|
2916
2992
|
throw new Error("Normal vector can only be determined in 2D");
|
|
2917
2993
|
const e = this.x.clone().opposite(), t = this.y.clone();
|
|
2918
2994
|
return s(this, F)[0] = t, s(this, F)[1] = e, this;
|
|
2919
2995
|
});
|
|
2920
|
-
a(this, "isEqual", (e) =>
|
|
2921
|
-
a(this, "isColinearTo", (e) =>
|
|
2996
|
+
a(this, "isEqual", (e) => ns(this, e));
|
|
2997
|
+
a(this, "isColinearTo", (e) => rs(this, e));
|
|
2922
2998
|
a(this, "isNormalTo", (e) => this.dot(e).isZero());
|
|
2923
2999
|
a(this, "multiplyByScalar", (e) => {
|
|
2924
3000
|
const t = new u(e);
|
|
@@ -2926,9 +3002,9 @@ const Se = class Se {
|
|
|
2926
3002
|
});
|
|
2927
3003
|
a(this, "divideByScalar", (e) => this.multiplyByScalar(new u(e).inverse()));
|
|
2928
3004
|
a(this, "simplify", () => this.multiplyByScalar(
|
|
2929
|
-
|
|
3005
|
+
U.lcm(...this.array.map((e) => e.denominator))
|
|
2930
3006
|
).divideByScalar(
|
|
2931
|
-
|
|
3007
|
+
U.gcd(...this.array.map((e) => e.numerator))
|
|
2932
3008
|
).multiplyByScalar(
|
|
2933
3009
|
this.x.isNegative() ? -1 : 1
|
|
2934
3010
|
));
|
|
@@ -2975,10 +3051,10 @@ const Se = class Se {
|
|
|
2975
3051
|
s(this, F)[2] = new u(e);
|
|
2976
3052
|
}
|
|
2977
3053
|
get asPoint() {
|
|
2978
|
-
return s(this,
|
|
3054
|
+
return s(this, Le);
|
|
2979
3055
|
}
|
|
2980
3056
|
set asPoint(e) {
|
|
2981
|
-
h(this,
|
|
3057
|
+
h(this, Le, e);
|
|
2982
3058
|
}
|
|
2983
3059
|
get normSquare() {
|
|
2984
3060
|
return this.array.reduce((e, t) => e.add(t.clone().pow(2)), new u(0));
|
|
@@ -2987,10 +3063,10 @@ const Se = class Se {
|
|
|
2987
3063
|
return Math.sqrt(this.normSquare.value);
|
|
2988
3064
|
}
|
|
2989
3065
|
get tex() {
|
|
2990
|
-
return s(this,
|
|
3066
|
+
return s(this, Le) ? `\\left(${this.array.map((e) => e.tex).join(";")}\\right)` : `\\begin{pmatrix} ${this.array.map((e) => e.tex).join(" \\\\ ")} \\end{pmatrix}`;
|
|
2991
3067
|
}
|
|
2992
3068
|
get display() {
|
|
2993
|
-
return s(this,
|
|
3069
|
+
return s(this, Le) ? `(${this.array.map((e) => e.display).join(";")})` : `((${this.array.map((e) => e.display).join(",")}))`;
|
|
2994
3070
|
}
|
|
2995
3071
|
setDimension(e = 2) {
|
|
2996
3072
|
if (e < 2)
|
|
@@ -3018,7 +3094,7 @@ const Se = class Se {
|
|
|
3018
3094
|
return `((${e.join(",")}))`;
|
|
3019
3095
|
}
|
|
3020
3096
|
defineAsPoint(e) {
|
|
3021
|
-
return h(this,
|
|
3097
|
+
return h(this, Le, e !== !1), this;
|
|
3022
3098
|
}
|
|
3023
3099
|
parse(...e) {
|
|
3024
3100
|
if (e.length === 0)
|
|
@@ -3081,40 +3157,40 @@ const Se = class Se {
|
|
|
3081
3157
|
};
|
|
3082
3158
|
}
|
|
3083
3159
|
};
|
|
3084
|
-
F = new WeakMap(),
|
|
3160
|
+
F = new WeakMap(), Le = new WeakMap();
|
|
3085
3161
|
let E = Se;
|
|
3086
|
-
var we = /* @__PURE__ */ ((o) => (o.None = "none", o.Parallel = "parallel", o.Perpendicular = "perpendicular", o.Tangent = "tangent", o))(we || {}),
|
|
3087
|
-
function
|
|
3162
|
+
var we = /* @__PURE__ */ ((o) => (o.None = "none", o.Parallel = "parallel", o.Perpendicular = "perpendicular", o.Tangent = "tangent", o))(we || {}), oi = /* @__PURE__ */ ((o) => (o.None = "none", o.Parallel = "parallel", o.Perpendicular = "perpendicular", o.Tangent = "tangent", o))(oi || {});
|
|
3163
|
+
function Ci(o = 0.5) {
|
|
3088
3164
|
return Math.random() < o;
|
|
3089
3165
|
}
|
|
3090
|
-
function
|
|
3166
|
+
function pe(o, e, t) {
|
|
3091
3167
|
if (e === void 0)
|
|
3092
|
-
return o >= 0 ?
|
|
3168
|
+
return o >= 0 ? pe(0, o) : pe(o, 0);
|
|
3093
3169
|
if (o === e)
|
|
3094
3170
|
return o;
|
|
3095
3171
|
if (t === void 0)
|
|
3096
3172
|
return Math.floor(Math.random() * (e - o + 1) + o);
|
|
3097
3173
|
if (Math.abs(e - o) <= t.length)
|
|
3098
3174
|
throw new Error("The number of excluded values is too high.");
|
|
3099
|
-
let i =
|
|
3175
|
+
let i = pe(o, e);
|
|
3100
3176
|
for (; t.includes(i); )
|
|
3101
|
-
i =
|
|
3177
|
+
i = pe(o, e);
|
|
3102
3178
|
return i;
|
|
3103
3179
|
}
|
|
3104
3180
|
function Q(o, e) {
|
|
3105
|
-
return e === !1 ?
|
|
3181
|
+
return e === !1 ? Ci() ? pe(1, o) : -pe(1, o) : pe(-o, o);
|
|
3106
3182
|
}
|
|
3107
|
-
function
|
|
3108
|
-
let e =
|
|
3109
|
-
return o !== void 0 && (e = e.filter((t) => t < o)),
|
|
3183
|
+
function as(o) {
|
|
3184
|
+
let e = U.primes();
|
|
3185
|
+
return o !== void 0 && (e = e.filter((t) => t < o)), di(e);
|
|
3110
3186
|
}
|
|
3111
|
-
function
|
|
3112
|
-
return e === void 0 && (e = 1), o.length <= 0 ? Object.values(o) :
|
|
3187
|
+
function ls(o, e) {
|
|
3188
|
+
return e === void 0 && (e = 1), o.length <= 0 ? Object.values(o) : $i(o).slice(0, e);
|
|
3113
3189
|
}
|
|
3114
|
-
function
|
|
3115
|
-
return o.length === 0 ? null : o[
|
|
3190
|
+
function di(o) {
|
|
3191
|
+
return o.length === 0 ? null : o[pe(0, o.length - 1)];
|
|
3116
3192
|
}
|
|
3117
|
-
function
|
|
3193
|
+
function $i(o) {
|
|
3118
3194
|
const e = Object.values(o);
|
|
3119
3195
|
for (let t = e.length - 1; t > 0; t--) {
|
|
3120
3196
|
const i = Math.floor(Math.random() * (t + 1)), n = e[t];
|
|
@@ -3148,25 +3224,25 @@ class B extends E {
|
|
|
3148
3224
|
return e.array = this.copy(), e.asPoint = !0, e;
|
|
3149
3225
|
}
|
|
3150
3226
|
}
|
|
3151
|
-
var
|
|
3152
|
-
const
|
|
3227
|
+
var Pe, S, z, W, oe, J, Ie, xe;
|
|
3228
|
+
const De = class De {
|
|
3153
3229
|
/**
|
|
3154
3230
|
* Value can be a mix of:
|
|
3155
3231
|
*
|
|
3156
3232
|
* @param values
|
|
3157
3233
|
*/
|
|
3158
3234
|
constructor(...e) {
|
|
3159
|
-
|
|
3235
|
+
m(this, Pe);
|
|
3160
3236
|
// ax + by + c = 0
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3237
|
+
m(this, S);
|
|
3238
|
+
m(this, z);
|
|
3239
|
+
m(this, W);
|
|
3240
|
+
m(this, oe);
|
|
3241
|
+
m(this, J);
|
|
3242
|
+
m(this, Ie);
|
|
3243
|
+
m(this, xe, "canonical");
|
|
3168
3244
|
a(this, "randomPoint", (e) => {
|
|
3169
|
-
const t = s(this,
|
|
3245
|
+
const t = s(this, J).clone().multiplyByScalar(Q(e === void 0 || e <= 1 ? 3 : e, !1)).add(s(this, oe));
|
|
3170
3246
|
return t.asPoint = !0, t;
|
|
3171
3247
|
});
|
|
3172
3248
|
a(this, "randomNearPoint", (e) => {
|
|
@@ -3188,13 +3264,13 @@ const Ze = class Ze {
|
|
|
3188
3264
|
if (e.length === 0)
|
|
3189
3265
|
return this;
|
|
3190
3266
|
if (e.length === 1) {
|
|
3191
|
-
if (e[0] instanceof
|
|
3267
|
+
if (e[0] instanceof De)
|
|
3192
3268
|
return this.fromCoefficient(e[0].a, e[0].b, e[0].c);
|
|
3193
|
-
if (e[0] instanceof
|
|
3269
|
+
if (e[0] instanceof H)
|
|
3194
3270
|
return this.fromEquation(e[0]);
|
|
3195
3271
|
if (typeof e[0] == "string")
|
|
3196
3272
|
try {
|
|
3197
|
-
const t = new
|
|
3273
|
+
const t = new H(e[0]);
|
|
3198
3274
|
return this.parse(t);
|
|
3199
3275
|
} catch {
|
|
3200
3276
|
return this;
|
|
@@ -3214,7 +3290,7 @@ const Ze = class Ze {
|
|
|
3214
3290
|
if (e[2] === we.Parallel)
|
|
3215
3291
|
return this.fromPointAndDirection(e[0], e[1]);
|
|
3216
3292
|
}
|
|
3217
|
-
return e[0] instanceof E && e[1] instanceof
|
|
3293
|
+
return e[0] instanceof E && e[1] instanceof De ? e[2] === we.Parallel || e[2] === null ? this.fromPointAndLine(e[0], e[1], we.Parallel) : this.fromPointAndLine(e[0], e[1], we.Perpendicular) : this.fromCoefficient(
|
|
3218
3294
|
e[0],
|
|
3219
3295
|
e[1],
|
|
3220
3296
|
e[2]
|
|
@@ -3235,42 +3311,42 @@ const Ze = class Ze {
|
|
|
3235
3311
|
e.left.monomByDegree(0).coefficient
|
|
3236
3312
|
);
|
|
3237
3313
|
});
|
|
3238
|
-
a(this, "fromCoefficient", (e, t, i) => (h(this, S, new u(e)), h(this, z, new u(t)), h(this,
|
|
3314
|
+
a(this, "fromCoefficient", (e, t, i) => (h(this, S, new u(e)), h(this, z, new u(t)), h(this, W, new u(i)), h(this, J, new E(s(this, z).clone(), s(this, S).clone().opposite())), h(this, oe, new E(new u().zero(), s(this, W).clone())), h(this, Ie, s(this, J).clone().normal()), this));
|
|
3239
3315
|
a(this, "fromPointAndDirection", (e, t) => (this.fromCoefficient(
|
|
3240
3316
|
t.y,
|
|
3241
3317
|
t.x.clone().opposite(),
|
|
3242
3318
|
e.x.clone().multiply(t.y).subtract(e.y.clone().multiply(t.x)).opposite()
|
|
3243
|
-
), h(this, oe, e.clone()), h(this,
|
|
3319
|
+
), h(this, oe, e.clone()), h(this, J, t.clone()), h(this, Ie, s(this, J).clone().normal()), this));
|
|
3244
3320
|
a(this, "fromPointAndNormal", (e, t) => this.fromCoefficient(
|
|
3245
3321
|
t.x,
|
|
3246
3322
|
t.y,
|
|
3247
3323
|
e.x.clone().multiply(t.x).add(e.y.clone().multiply(t.y)).opposite()
|
|
3248
3324
|
));
|
|
3249
3325
|
a(this, "fromPointAndLine", (e, t, i) => (i === void 0 && (i = we.Parallel), i === we.Parallel ? this.fromPointAndNormal(e, t.normal) : i === we.Perpendicular ? this.fromPointAndNormal(e, t.director) : this));
|
|
3250
|
-
a(this, "clone", () => (h(this, S, s(this, S).clone()), h(this, z, s(this, z).clone()), h(this,
|
|
3326
|
+
a(this, "clone", () => (h(this, S, s(this, S).clone()), h(this, z, s(this, z).clone()), h(this, W, s(this, W).clone()), h(this, J, s(this, J).clone()), h(this, oe, s(this, oe).clone()), h(this, Ie, s(this, Ie).clone()), this));
|
|
3251
3327
|
// ------------------------------------------
|
|
3252
3328
|
// Mathematical operations
|
|
3253
3329
|
// ------------------------------------------
|
|
3254
3330
|
a(this, "isOnLine", (e) => s(this, S).clone().multiply(e.x).add(
|
|
3255
3331
|
s(this, z).clone().multiply(e.y)
|
|
3256
|
-
).add(s(this,
|
|
3332
|
+
).add(s(this, W)).isZero());
|
|
3257
3333
|
a(this, "isParallelTo", (e) => this.slope.isEqual(e.slope) && this.height.isNotEqual(e.height));
|
|
3258
3334
|
a(this, "isSameAs", (e) => this.slope.isEqual(e.slope) && this.height.isEqual(e.height));
|
|
3259
3335
|
a(this, "isPerpendicularTo", (e) => this.d.isNormalTo(e.d));
|
|
3260
3336
|
a(this, "isVertical", () => this.slope.isInfinity());
|
|
3261
3337
|
a(this, "simplify", () => {
|
|
3262
|
-
const e =
|
|
3338
|
+
const e = U.lcm(s(this, S).denominator, s(this, z).denominator, s(this, W).denominator), t = U.gcd(s(this, S).numerator, s(this, z).numerator, s(this, W).numerator);
|
|
3263
3339
|
return this.fromCoefficient(
|
|
3264
3340
|
s(this, S).clone().multiply(e).divide(t),
|
|
3265
3341
|
s(this, z).clone().multiply(e).divide(t),
|
|
3266
|
-
s(this,
|
|
3342
|
+
s(this, W).clone().multiply(e).divide(t)
|
|
3267
3343
|
), this;
|
|
3268
3344
|
});
|
|
3269
|
-
a(this, "simplifyDirection", () => (s(this,
|
|
3345
|
+
a(this, "simplifyDirection", () => (s(this, J).simplify(), this));
|
|
3270
3346
|
a(this, "intersection", (e) => {
|
|
3271
3347
|
const t = new B();
|
|
3272
3348
|
let i = !1, n = !1;
|
|
3273
|
-
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,
|
|
3349
|
+
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, W).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, W).clone().multiply(e.a)).divide(s(this, z).clone().multiply(e.a).subtract(s(this, S).clone().multiply(e.b)))), {
|
|
3274
3350
|
point: t,
|
|
3275
3351
|
hasIntersection: !(i || n),
|
|
3276
3352
|
isParallel: i,
|
|
@@ -3279,13 +3355,13 @@ const Ze = class Ze {
|
|
|
3279
3355
|
});
|
|
3280
3356
|
a(this, "getValueAtX", (e) => {
|
|
3281
3357
|
const t = this.getEquation().isolate("y"), i = new u(e);
|
|
3282
|
-
return t instanceof
|
|
3358
|
+
return t instanceof H ? t.right.evaluate({ x: i }) : new u().invalid();
|
|
3283
3359
|
});
|
|
3284
3360
|
a(this, "getValueAtY", (e) => {
|
|
3285
3361
|
const t = this.getEquation().isolate("x"), i = new u(e);
|
|
3286
|
-
return t instanceof
|
|
3362
|
+
return t instanceof H ? t.right.evaluate({ y: i }) : new u().invalid();
|
|
3287
3363
|
});
|
|
3288
|
-
return h(this, S, new u().zero()), h(this, z, new u().zero()), h(this,
|
|
3364
|
+
return h(this, S, new u().zero()), h(this, z, new u().zero()), h(this, W, new u().zero()), h(this, oe, new E()), h(this, J, new E()), h(this, Ie, new E()), h(this, Pe, !0), e.length > 0 && this.parse(...e), this;
|
|
3289
3365
|
}
|
|
3290
3366
|
get a() {
|
|
3291
3367
|
return s(this, S);
|
|
@@ -3302,10 +3378,10 @@ const Ze = class Ze {
|
|
|
3302
3378
|
h(this, z, e);
|
|
3303
3379
|
}
|
|
3304
3380
|
get c() {
|
|
3305
|
-
return s(this,
|
|
3381
|
+
return s(this, W);
|
|
3306
3382
|
}
|
|
3307
3383
|
set c(e) {
|
|
3308
|
-
h(this,
|
|
3384
|
+
h(this, W, e);
|
|
3309
3385
|
}
|
|
3310
3386
|
get OA() {
|
|
3311
3387
|
return s(this, oe);
|
|
@@ -3314,18 +3390,18 @@ const Ze = class Ze {
|
|
|
3314
3390
|
h(this, oe, e);
|
|
3315
3391
|
}
|
|
3316
3392
|
get d() {
|
|
3317
|
-
return s(this,
|
|
3393
|
+
return s(this, J);
|
|
3318
3394
|
}
|
|
3319
3395
|
set d(e) {
|
|
3320
|
-
h(this,
|
|
3396
|
+
h(this, J, e);
|
|
3321
3397
|
}
|
|
3322
3398
|
get n() {
|
|
3323
|
-
return s(this,
|
|
3399
|
+
return s(this, Ie);
|
|
3324
3400
|
}
|
|
3325
3401
|
// ------------------------------------------
|
|
3326
3402
|
getEquation() {
|
|
3327
|
-
const e = new
|
|
3328
|
-
return s(this,
|
|
3403
|
+
const e = new H(new O().parse("xy", s(this, S), s(this, z), s(this, W)), new O("0"));
|
|
3404
|
+
return s(this, Pe) ? e.simplify() : e;
|
|
3329
3405
|
}
|
|
3330
3406
|
// get system(): { x: Equation, y: Equation } {
|
|
3331
3407
|
// const e1 = new Equation(
|
|
@@ -3341,33 +3417,33 @@ const Ze = class Ze {
|
|
|
3341
3417
|
// return { x: e1, y: e2 }
|
|
3342
3418
|
// }
|
|
3343
3419
|
get canonical() {
|
|
3344
|
-
return h(this,
|
|
3420
|
+
return h(this, xe, "canonical"), this;
|
|
3345
3421
|
}
|
|
3346
3422
|
get equation() {
|
|
3347
|
-
return h(this,
|
|
3423
|
+
return h(this, xe, "equation"), this;
|
|
3348
3424
|
}
|
|
3349
3425
|
get mxh() {
|
|
3350
|
-
return h(this,
|
|
3426
|
+
return h(this, xe, "mxh"), this;
|
|
3351
3427
|
}
|
|
3352
3428
|
get parametric() {
|
|
3353
|
-
return h(this,
|
|
3429
|
+
return h(this, xe, "parametric"), this;
|
|
3354
3430
|
}
|
|
3355
3431
|
get system() {
|
|
3356
|
-
return h(this,
|
|
3432
|
+
return h(this, xe, "system"), this;
|
|
3357
3433
|
}
|
|
3358
3434
|
get tex() {
|
|
3359
|
-
const e = s(this,
|
|
3360
|
-
switch (h(this,
|
|
3435
|
+
const e = s(this, xe);
|
|
3436
|
+
switch (h(this, xe, "canonical"), e) {
|
|
3361
3437
|
case "equation":
|
|
3362
3438
|
return this.getEquation().reorder().tex;
|
|
3363
3439
|
case "mxh":
|
|
3364
|
-
return this.slope.isInfinity() ? "x=" + this.OA.x.tex : "y=" + new
|
|
3440
|
+
return this.slope.isInfinity() ? "x=" + this.OA.x.tex : "y=" + new O().parse("x", this.slope, this.height).tex;
|
|
3365
3441
|
case "parametric":
|
|
3366
3442
|
case "system": {
|
|
3367
|
-
const t = s(this,
|
|
3368
|
-
return s(this,
|
|
3369
|
-
x &= ${new
|
|
3370
|
-
y &= ${new
|
|
3443
|
+
const t = s(this, J).clone();
|
|
3444
|
+
return s(this, Pe) && t.simplify(), e === "parametric" ? `${E.asTex("x", "y")} = ${E.asTex(s(this, oe).x.tex, s(this, oe).y.tex)} + k\\cdot ${E.asTex(t.x.tex, t.y.tex)}` : `\\left\\{\\begin{aligned}
|
|
3445
|
+
x &= ${new O(s(this, oe).x).add(new k(s(this, J).x).multiply(new k("k"))).reorder("k", !0).tex}\\\\
|
|
3446
|
+
y &= ${new O(s(this, oe).y).add(new k(s(this, J).y).multiply(new k("k"))).reorder("k", !0).tex}
|
|
3371
3447
|
\\end{aligned}\\right.`;
|
|
3372
3448
|
}
|
|
3373
3449
|
default: {
|
|
@@ -3377,21 +3453,21 @@ const Ze = class Ze {
|
|
|
3377
3453
|
}
|
|
3378
3454
|
}
|
|
3379
3455
|
get reduceBeforeDisplay() {
|
|
3380
|
-
return s(this,
|
|
3456
|
+
return s(this, Pe);
|
|
3381
3457
|
}
|
|
3382
3458
|
set reduceBeforeDisplay(e) {
|
|
3383
|
-
h(this,
|
|
3459
|
+
h(this, Pe, e);
|
|
3384
3460
|
}
|
|
3385
3461
|
get display() {
|
|
3386
|
-
const e = s(this,
|
|
3387
|
-
switch (h(this,
|
|
3462
|
+
const e = s(this, xe);
|
|
3463
|
+
switch (h(this, xe, "canonical"), e) {
|
|
3388
3464
|
case "equation":
|
|
3389
3465
|
return this.getEquation().reorder().display;
|
|
3390
3466
|
case "mxh":
|
|
3391
|
-
return this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new
|
|
3467
|
+
return this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new O().parse("x", this.slope, this.height).display;
|
|
3392
3468
|
case "parametric": {
|
|
3393
|
-
const t = s(this,
|
|
3394
|
-
return s(this,
|
|
3469
|
+
const t = s(this, J).clone();
|
|
3470
|
+
return s(this, Pe) && t.simplify(), `((x,y))=((${s(this, oe).x.display},${s(this, oe).y.display}))+k((${t.x.display},${t.y.display}))`;
|
|
3395
3471
|
}
|
|
3396
3472
|
default: {
|
|
3397
3473
|
const t = this.getEquation();
|
|
@@ -3403,19 +3479,19 @@ const Ze = class Ze {
|
|
|
3403
3479
|
return new E(s(this, S), s(this, z));
|
|
3404
3480
|
}
|
|
3405
3481
|
get director() {
|
|
3406
|
-
return s(this,
|
|
3482
|
+
return s(this, J).clone();
|
|
3407
3483
|
}
|
|
3408
3484
|
get slope() {
|
|
3409
3485
|
return s(this, S).clone().opposite().divide(s(this, z));
|
|
3410
3486
|
}
|
|
3411
3487
|
get height() {
|
|
3412
|
-
return s(this,
|
|
3488
|
+
return s(this, W).clone().opposite().divide(s(this, z));
|
|
3413
3489
|
}
|
|
3414
3490
|
fromPoints(e, t) {
|
|
3415
3491
|
return this.fromPointAndDirection(e, new E(e, t));
|
|
3416
3492
|
}
|
|
3417
3493
|
distanceTo(e) {
|
|
3418
|
-
const t = e.x.clone().multiply(s(this, S)).add(e.y.clone().multiply(s(this, z))).add(s(this,
|
|
3494
|
+
const t = e.x.clone().multiply(s(this, S)).add(e.y.clone().multiply(s(this, z))).add(s(this, W)).abs(), i = this.normal.normSquare;
|
|
3419
3495
|
if (i.isZero())
|
|
3420
3496
|
return {
|
|
3421
3497
|
value: NaN,
|
|
@@ -3435,7 +3511,7 @@ const Ze = class Ze {
|
|
|
3435
3511
|
}
|
|
3436
3512
|
hitSegment(e, t) {
|
|
3437
3513
|
const i = this.intersection(
|
|
3438
|
-
new
|
|
3514
|
+
new De().fromPoints(e, t)
|
|
3439
3515
|
);
|
|
3440
3516
|
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) : !1;
|
|
3441
3517
|
}
|
|
@@ -3445,19 +3521,19 @@ const Ze = class Ze {
|
|
|
3445
3521
|
canonicalAsFloatCoefficient(e) {
|
|
3446
3522
|
e === void 0 && (e = 2);
|
|
3447
3523
|
let t = "";
|
|
3448
|
-
return s(this, S).isZero() || (s(this, S).isOne() ? t = "x" : s(this, S).clone().opposite().isOne() ? t = "-x" : t = s(this, S).value.toFixed(e) + "x"), s(this, z).isZero() || (s(this, z).isPositive() && (t += "+"), t += s(this, z).value.toFixed(e) + "y"), s(this,
|
|
3524
|
+
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, W).isZero() || (s(this, W).isPositive() && (t += "+"), t += s(this, W).value.toFixed(e)), t + "=0";
|
|
3449
3525
|
}
|
|
3450
3526
|
};
|
|
3451
|
-
|
|
3452
|
-
a(
|
|
3453
|
-
let R =
|
|
3454
|
-
var he, j, qe, Ut, Wt, Gt,
|
|
3527
|
+
Pe = new WeakMap(), S = new WeakMap(), z = new WeakMap(), W = new WeakMap(), oe = new WeakMap(), J = new WeakMap(), Ie = new WeakMap(), xe = new WeakMap(), // A line is defined as the canonical form
|
|
3528
|
+
a(De, "PERPENDICULAR", we.Perpendicular), a(De, "PARALLEL", we.Parallel);
|
|
3529
|
+
let R = De;
|
|
3530
|
+
var he, j, qe, Ut, Wt, Gt, le, Pi, Nt, Ii, Bi, Si, hi;
|
|
3455
3531
|
const Ht = class Ht {
|
|
3456
3532
|
constructor(...e) {
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3533
|
+
m(this, le);
|
|
3534
|
+
m(this, he);
|
|
3535
|
+
m(this, j);
|
|
3536
|
+
m(this, qe);
|
|
3461
3537
|
/**
|
|
3462
3538
|
* Get the relative position between circle and line. It corresponds to the number of intersection.
|
|
3463
3539
|
* @param {Line} L
|
|
@@ -3474,7 +3550,7 @@ const Ht = class Ht {
|
|
|
3474
3550
|
if (s(this, qe) === void 0)
|
|
3475
3551
|
return [];
|
|
3476
3552
|
const i = s(this, qe).clone(), n = e.getEquation().clone().isolate("x"), r = e.getEquation().clone().isolate("y");
|
|
3477
|
-
return n instanceof
|
|
3553
|
+
return n instanceof H && r instanceof H && (i.replaceBy("y", r.right).simplify(), i.solve()), t;
|
|
3478
3554
|
});
|
|
3479
3555
|
a(this, "tangents", (e) => e instanceof u ? s(this, Gt).call(this, e) : this.isPointOnCircle(e) ? s(this, Ut).call(this, e) : s(this, he) !== void 0 && s(this, he).distanceTo(e).value > this.radius.value ? s(this, Wt).call(this, e) : (console.log("No tangents as the point is inside !"), []));
|
|
3480
3556
|
a(this, "isPointOnCircle", (e) => {
|
|
@@ -3482,7 +3558,7 @@ const Ht = class Ht {
|
|
|
3482
3558
|
return ((t = s(this, qe)) == null ? void 0 : t.test({ x: e.x, y: e.y })) ?? !1;
|
|
3483
3559
|
});
|
|
3484
3560
|
a(this, "getPointsOnCircle", (e) => {
|
|
3485
|
-
const t =
|
|
3561
|
+
const t = U.pythagoreanTripletsWithTarget(this.squareRadius.value, !0), i = [];
|
|
3486
3562
|
return t.forEach((n) => {
|
|
3487
3563
|
for (const r of [[1, 1], [-1, 1], [-1, -1], [1, -1]])
|
|
3488
3564
|
i.push(
|
|
@@ -3493,21 +3569,21 @@ const Ht = class Ht {
|
|
|
3493
3569
|
);
|
|
3494
3570
|
}), i;
|
|
3495
3571
|
});
|
|
3496
|
-
|
|
3572
|
+
m(this, Ut, (e) => {
|
|
3497
3573
|
const t = new E(this.center, e);
|
|
3498
3574
|
return [new R(e, t, we.Perpendicular)];
|
|
3499
3575
|
});
|
|
3500
|
-
|
|
3501
|
-
const t = this.center.x.clone().subtract(e.x), i = this.center.y.clone().subtract(e.y), n = new
|
|
3502
|
-
return n.multiply(t).subtract(i).pow(2), r.multiply(this.squareRadius), new
|
|
3503
|
-
let
|
|
3504
|
-
const
|
|
3505
|
-
return
|
|
3576
|
+
m(this, Wt, (e) => {
|
|
3577
|
+
const t = this.center.x.clone().subtract(e.x), i = this.center.y.clone().subtract(e.y), n = new O("x"), r = new O("x^2+1");
|
|
3578
|
+
return n.multiply(t).subtract(i).pow(2), r.multiply(this.squareRadius), new H(n, r).solve().map((f) => {
|
|
3579
|
+
let d;
|
|
3580
|
+
const p = new H("y", "x");
|
|
3581
|
+
return f.exact instanceof u ? (d = e.x.clone().opposite().multiply(f.exact).add(e.y), p.right.multiply(f.exact).add(d)) : (d = e.x.clone().opposite().multiply(f.value).add(e.y), p.right.multiply(f.value).add(d)), new R(p);
|
|
3506
3582
|
});
|
|
3507
3583
|
});
|
|
3508
|
-
|
|
3509
|
-
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()),
|
|
3510
|
-
return [new R(t, i, c), new R(t, i,
|
|
3584
|
+
m(this, Gt, (e) => {
|
|
3585
|
+
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()), f = n.clone().multiply(t).opposite().subtract(r.clone().multiply(i)).subtract(l.clone().sqrt());
|
|
3586
|
+
return [new R(t, i, c), new R(t, i, f)];
|
|
3511
3587
|
});
|
|
3512
3588
|
e.length > 0 && this.parse(...e);
|
|
3513
3589
|
}
|
|
@@ -3552,10 +3628,10 @@ const Ht = class Ht {
|
|
|
3552
3628
|
);
|
|
3553
3629
|
}
|
|
3554
3630
|
setRadius(e, t) {
|
|
3555
|
-
return t ? h(this, j, new u(e)) : h(this, j, new u(e).pow(2)), A(this,
|
|
3631
|
+
return t ? h(this, j, new u(e)) : h(this, j, new u(e).pow(2)), A(this, le, Nt).call(this), this;
|
|
3556
3632
|
}
|
|
3557
3633
|
parse(...e) {
|
|
3558
|
-
return A(this,
|
|
3634
|
+
return A(this, le, Pi).call(this), typeof e[0] == "string" ? A(this, le, hi).call(this, new H(e[0])) : e[0] instanceof H ? A(this, le, hi).call(this, e[0]) : e[0] instanceof Ht ? A(this, le, Ii).call(this, e[0]) : e[0] instanceof B && e.length > 1 && (e[1] instanceof B ? e[2] instanceof B || A(this, le, Si).call(this, e[0], e[1]) : (e[1] instanceof u || typeof e[1] == "number") && A(this, le, Bi).call(this, e[0], e[1], typeof e[2] == "boolean" ? e[2] : !1)), A(this, le, Nt).call(this), this;
|
|
3559
3635
|
}
|
|
3560
3636
|
// private _parseThroughtThreePoints(A: Point, B: Point, C: Point): this {
|
|
3561
3637
|
// const T = new Triangle(A, B, C), mAB = T.remarquables.mediators.AB.clone(),
|
|
@@ -3564,20 +3640,20 @@ const Ht = class Ht {
|
|
|
3564
3640
|
// return this
|
|
3565
3641
|
// }
|
|
3566
3642
|
};
|
|
3567
|
-
he = new WeakMap(), j = new WeakMap(), qe = new WeakMap(), Ut = new WeakMap(), Wt = new WeakMap(), Gt = new WeakMap(),
|
|
3643
|
+
he = new WeakMap(), j = new WeakMap(), qe = new WeakMap(), Ut = new WeakMap(), Wt = new WeakMap(), Gt = new WeakMap(), le = new WeakSet(), Pi = function() {
|
|
3568
3644
|
return h(this, he, void 0), h(this, j, void 0), h(this, qe, void 0), this;
|
|
3569
3645
|
}, Nt = function() {
|
|
3570
|
-
h(this, qe, new
|
|
3571
|
-
new
|
|
3572
|
-
new
|
|
3646
|
+
h(this, qe, new H(
|
|
3647
|
+
new O(`(x-(${this.center.x.display}))^2+(y-(${this.center.y.display}))^2`),
|
|
3648
|
+
new O(this.squareRadius.display)
|
|
3573
3649
|
).moveLeft());
|
|
3574
|
-
},
|
|
3575
|
-
return h(this, he, e.center.clone()), h(this, j, e.squareRadius.clone()), A(this,
|
|
3576
|
-
},
|
|
3650
|
+
}, Ii = function(e) {
|
|
3651
|
+
return h(this, he, e.center.clone()), h(this, j, e.squareRadius.clone()), A(this, le, Nt).call(this), this;
|
|
3652
|
+
}, Bi = function(e, t, i) {
|
|
3577
3653
|
return h(this, he, e.clone()), i ? h(this, j, new u(t)) : h(this, j, new u(t).pow(2)), this;
|
|
3578
|
-
},
|
|
3654
|
+
}, Si = function(e, t) {
|
|
3579
3655
|
return h(this, he, e.clone()), h(this, j, new E(s(this, he), t).normSquare), this;
|
|
3580
|
-
},
|
|
3656
|
+
}, hi = function(e) {
|
|
3581
3657
|
if (e.moveLeft(), e.degree("x").value === 2 && e.degree("y").value === 2) {
|
|
3582
3658
|
const t = e.left.monomByDegree(2, "x"), i = e.left.monomByDegree(2, "y");
|
|
3583
3659
|
let n, r, l;
|
|
@@ -3586,13 +3662,13 @@ he = new WeakMap(), j = new WeakMap(), qe = new WeakMap(), Ut = new WeakMap(), W
|
|
|
3586
3662
|
return this;
|
|
3587
3663
|
};
|
|
3588
3664
|
let Tt = Ht;
|
|
3589
|
-
var L,
|
|
3590
|
-
const
|
|
3665
|
+
var L, G;
|
|
3666
|
+
const ct = class ct {
|
|
3591
3667
|
constructor(e, t) {
|
|
3592
3668
|
// ax + by + c = 0
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
a(this, "clone", () => (h(this,
|
|
3669
|
+
m(this, L, new B());
|
|
3670
|
+
m(this, G, new E());
|
|
3671
|
+
a(this, "clone", () => (h(this, G, s(this, G).clone()), h(this, L, s(this, L).clone()), this));
|
|
3596
3672
|
// ------------------------------------------
|
|
3597
3673
|
// Mathematical operations
|
|
3598
3674
|
// ------------------------------------------
|
|
@@ -3634,12 +3710,12 @@ const ut = class ut {
|
|
|
3634
3710
|
a(this, "randomPoint", (e = 5) => {
|
|
3635
3711
|
const t = s(this, L).clone(), i = new u(Q(e, !1));
|
|
3636
3712
|
return new B(
|
|
3637
|
-
t.x.clone().add(s(this,
|
|
3638
|
-
t.y.clone().add(s(this,
|
|
3639
|
-
t.z.clone().add(s(this,
|
|
3713
|
+
t.x.clone().add(s(this, G).x.clone().multiply(i)),
|
|
3714
|
+
t.y.clone().add(s(this, G).y.clone().multiply(i)),
|
|
3715
|
+
t.z.clone().add(s(this, G).z.clone().multiply(i))
|
|
3640
3716
|
);
|
|
3641
3717
|
});
|
|
3642
|
-
return h(this, L, e.clone()), h(this,
|
|
3718
|
+
return h(this, L, e.clone()), h(this, G, t.asPoint ? new E(e, t) : t.clone()), this;
|
|
3643
3719
|
}
|
|
3644
3720
|
get OA() {
|
|
3645
3721
|
return s(this, L);
|
|
@@ -3651,32 +3727,32 @@ const ut = class ut {
|
|
|
3651
3727
|
return s(this, L).clone();
|
|
3652
3728
|
}
|
|
3653
3729
|
get d() {
|
|
3654
|
-
return s(this,
|
|
3730
|
+
return s(this, G);
|
|
3655
3731
|
}
|
|
3656
3732
|
set d(e) {
|
|
3657
|
-
h(this,
|
|
3733
|
+
h(this, G, e);
|
|
3658
3734
|
}
|
|
3659
3735
|
get tex() {
|
|
3660
3736
|
return {
|
|
3661
|
-
parametric: `${E.asTex("x", "y", "z")} = ${E.asTex(s(this, L).x.tex, s(this, L).y.tex, s(this, L).z.tex)} + k\\cdot ${E.asTex(s(this,
|
|
3737
|
+
parametric: `${E.asTex("x", "y", "z")} = ${E.asTex(s(this, L).x.tex, s(this, L).y.tex, s(this, L).z.tex)} + k\\cdot ${E.asTex(s(this, G).x.tex, s(this, G).y.tex, s(this, G).z.tex)}`,
|
|
3662
3738
|
system: `\\left\\{\\begin{aligned}
|
|
3663
|
-
x &= ${new
|
|
3664
|
-
y &= ${new
|
|
3665
|
-
z &= ${new
|
|
3739
|
+
x &= ${new O(s(this, L).x).add(new k(s(this, G).x).multiply(new k("k"))).reorder("k", !0).tex}\\\\
|
|
3740
|
+
y &= ${new O(s(this, L).y).add(new k(s(this, G).y).multiply(new k("k"))).reorder("k", !0).tex}\\\\
|
|
3741
|
+
z &= ${new O(s(this, L).z).add(new k(s(this, G).z).multiply(new k("k"))).reorder("k", !0).tex}
|
|
3666
3742
|
\\end{aligned}\\right.`,
|
|
3667
|
-
cartesian: `\\frac{ ${new
|
|
3743
|
+
cartesian: `\\frac{ ${new O("x", 1, s(this, L).x.clone().opposite()).tex} }{ ${this.direction.x.tex} } = \\frac{ ${new O("y", 1, s(this, L).y.clone().opposite()).tex} }{ ${this.direction.y.tex} } = \\frac{ ${new O("z", 1, s(this, L).z.clone().opposite()).tex} }{ ${this.direction.z.tex} }`
|
|
3668
3744
|
};
|
|
3669
3745
|
}
|
|
3670
3746
|
get display() {
|
|
3671
3747
|
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;
|
|
3672
3748
|
return {
|
|
3673
|
-
parametric: `${E.asDisplay("x", "y", "z")} = ${E.asDisplay(s(this, L).x.display, s(this, L).y.display, s(this, L).z.display)} + k\\cdot ${E.asDisplay(s(this,
|
|
3749
|
+
parametric: `${E.asDisplay("x", "y", "z")} = ${E.asDisplay(s(this, L).x.display, s(this, L).y.display, s(this, L).z.display)} + k\\cdot ${E.asDisplay(s(this, G).x.display, s(this, G).y.display, s(this, G).z.display)}`,
|
|
3674
3750
|
system: "",
|
|
3675
3751
|
cartesian: `(x-${e})/${r} = (y-${t})/${l} = (z-${i})/${c}`
|
|
3676
3752
|
};
|
|
3677
3753
|
}
|
|
3678
3754
|
get direction() {
|
|
3679
|
-
return s(this,
|
|
3755
|
+
return s(this, G).clone();
|
|
3680
3756
|
}
|
|
3681
3757
|
distanceTo(e) {
|
|
3682
3758
|
const t = new E(s(this, L), e), i = this.direction, n = this.direction.normSquare, r = t.cross(i).normSquare, l = r.clone().divide(n), c = l.clone().sqrt();
|
|
@@ -3688,18 +3764,18 @@ const ut = class ut {
|
|
|
3688
3764
|
}
|
|
3689
3765
|
hitSegment(e, t) {
|
|
3690
3766
|
const i = this.intersection(
|
|
3691
|
-
new
|
|
3767
|
+
new ct(e, t)
|
|
3692
3768
|
);
|
|
3693
3769
|
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;
|
|
3694
3770
|
}
|
|
3695
3771
|
};
|
|
3696
|
-
L = new WeakMap(),
|
|
3697
|
-
a(
|
|
3698
|
-
let
|
|
3772
|
+
L = new WeakMap(), G = new WeakMap(), // A line is defined as the canonical form
|
|
3773
|
+
a(ct, "PERPENDICULAR", oi.Perpendicular), a(ct, "PARALLEL", oi.Parallel);
|
|
3774
|
+
let Ot = ct;
|
|
3699
3775
|
var Me;
|
|
3700
|
-
class
|
|
3776
|
+
class cs {
|
|
3701
3777
|
constructor(...e) {
|
|
3702
|
-
|
|
3778
|
+
m(this, Me, []);
|
|
3703
3779
|
return h(this, Me, e), this;
|
|
3704
3780
|
}
|
|
3705
3781
|
get values() {
|
|
@@ -3717,15 +3793,15 @@ class as {
|
|
|
3717
3793
|
determinant() {
|
|
3718
3794
|
if (!this.isSquare())
|
|
3719
3795
|
throw new Error("Matrix is not square");
|
|
3720
|
-
return
|
|
3796
|
+
return hs(...this.values);
|
|
3721
3797
|
}
|
|
3722
3798
|
}
|
|
3723
3799
|
Me = new WeakMap();
|
|
3724
|
-
var ke,
|
|
3725
|
-
const
|
|
3800
|
+
var ke, Ue;
|
|
3801
|
+
const mi = class mi {
|
|
3726
3802
|
constructor(e) {
|
|
3727
|
-
|
|
3728
|
-
|
|
3803
|
+
m(this, ke, new E(0, 0, 1));
|
|
3804
|
+
m(this, Ue, new B(0, 0, 0));
|
|
3729
3805
|
return e && this.parse(e), this;
|
|
3730
3806
|
}
|
|
3731
3807
|
get normal() {
|
|
@@ -3735,10 +3811,10 @@ const gi = class gi {
|
|
|
3735
3811
|
h(this, ke, e), s(this, ke).asPoint = !1;
|
|
3736
3812
|
}
|
|
3737
3813
|
get point() {
|
|
3738
|
-
return s(this,
|
|
3814
|
+
return s(this, Ue);
|
|
3739
3815
|
}
|
|
3740
3816
|
set point(e) {
|
|
3741
|
-
h(this,
|
|
3817
|
+
h(this, Ue, e), s(this, Ue).asPoint = !0;
|
|
3742
3818
|
}
|
|
3743
3819
|
get a() {
|
|
3744
3820
|
return s(this, ke).x;
|
|
@@ -3750,12 +3826,12 @@ const gi = class gi {
|
|
|
3750
3826
|
return s(this, ke).z;
|
|
3751
3827
|
}
|
|
3752
3828
|
get d() {
|
|
3753
|
-
return s(this, ke).dot(s(this,
|
|
3829
|
+
return s(this, ke).dot(s(this, Ue)).opposite();
|
|
3754
3830
|
}
|
|
3755
3831
|
get tex() {
|
|
3756
|
-
return new
|
|
3757
|
-
new
|
|
3758
|
-
new
|
|
3832
|
+
return new H(
|
|
3833
|
+
new O("xyz", this.a, this.b, this.c, this.d),
|
|
3834
|
+
new O(0)
|
|
3759
3835
|
).reduce().tex;
|
|
3760
3836
|
}
|
|
3761
3837
|
parse(e) {
|
|
@@ -3771,23 +3847,23 @@ const gi = class gi {
|
|
|
3771
3847
|
return;
|
|
3772
3848
|
}
|
|
3773
3849
|
if (e.equation) {
|
|
3774
|
-
const r = e.equation.moveLeft().reduce().left, l = r.monomByLetter("x").coefficient, c = r.monomByLetter("y").coefficient,
|
|
3775
|
-
this.normal = new E(l, c,
|
|
3850
|
+
const r = e.equation.moveLeft().reduce().left, l = r.monomByLetter("x").coefficient, c = r.monomByLetter("y").coefficient, f = r.monomByLetter("z").coefficient, d = r.monomByDegree(0).coefficient;
|
|
3851
|
+
this.normal = new E(l, c, f), l.isNotZero() ? this.point = new B(d.clone().divide(l).opposite(), 0, 0) : c.isNotZero() ? this.point = new B(0, d.clone().divide(c).opposite(), 0) : this.point = new B(0, 0, d.clone().divide(f).opposite());
|
|
3776
3852
|
return;
|
|
3777
3853
|
}
|
|
3778
3854
|
if (((i = e.points) == null ? void 0 : i.length) === 3 && e.points.every((r) => r instanceof E)) {
|
|
3779
|
-
const r = e.points[0], l = e.points[1], c = e.points[2],
|
|
3780
|
-
this.normal =
|
|
3855
|
+
const r = e.points[0], l = e.points[1], c = e.points[2], f = new E(r, l), d = new E(r, c);
|
|
3856
|
+
this.normal = f.cross(d), this.point = r;
|
|
3781
3857
|
return;
|
|
3782
3858
|
}
|
|
3783
3859
|
if (((n = e.coefficients) == null ? void 0 : n.length) === 4) {
|
|
3784
|
-
const [r, l, c,
|
|
3785
|
-
this.normal = new E(r, l, c), this.point = new B(0, 0, -
|
|
3860
|
+
const [r, l, c, f] = e.coefficients;
|
|
3861
|
+
this.normal = new E(r, l, c), this.point = new B(0, 0, -f);
|
|
3786
3862
|
return;
|
|
3787
3863
|
}
|
|
3788
3864
|
}
|
|
3789
3865
|
angle(e, t, i) {
|
|
3790
|
-
if (e instanceof
|
|
3866
|
+
if (e instanceof mi)
|
|
3791
3867
|
return this.normal.angle(e.normal, t, i);
|
|
3792
3868
|
let n;
|
|
3793
3869
|
if (e instanceof E) {
|
|
@@ -3812,25 +3888,25 @@ const gi = class gi {
|
|
|
3812
3888
|
return this.normal.dot(e).add(this.d).isZero();
|
|
3813
3889
|
}
|
|
3814
3890
|
};
|
|
3815
|
-
ke = new WeakMap(),
|
|
3816
|
-
let
|
|
3817
|
-
var Y,
|
|
3891
|
+
ke = new WeakMap(), Ue = new WeakMap();
|
|
3892
|
+
let ai = mi;
|
|
3893
|
+
var Y, _, ee, st, Ce, yt, Xt, wt, Be, Yt, nt;
|
|
3818
3894
|
const Qt = class Qt {
|
|
3819
3895
|
constructor(...e) {
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3896
|
+
m(this, Y, new B());
|
|
3897
|
+
m(this, _, new B());
|
|
3898
|
+
m(this, ee, new B());
|
|
3899
|
+
m(this, st, {
|
|
3824
3900
|
AB: new R(),
|
|
3825
3901
|
AC: new R(),
|
|
3826
3902
|
BC: new R()
|
|
3827
3903
|
});
|
|
3828
|
-
|
|
3904
|
+
m(this, Ce, {
|
|
3829
3905
|
AB: new B(),
|
|
3830
3906
|
AC: new B(),
|
|
3831
3907
|
BC: new B()
|
|
3832
3908
|
});
|
|
3833
|
-
|
|
3909
|
+
m(this, yt, null);
|
|
3834
3910
|
// ------------------------------------------
|
|
3835
3911
|
// Creation / parsing functions
|
|
3836
3912
|
// ------------------------------------------
|
|
@@ -3838,7 +3914,6 @@ const Qt = class Qt {
|
|
|
3838
3914
|
* Parse values to a triangle. Supported formats:
|
|
3839
3915
|
* Vector2D, Vector2D, Vector2D
|
|
3840
3916
|
* x1, y1, x2, y2, x3, y3
|
|
3841
|
-
* TODO: Something else ?
|
|
3842
3917
|
* @param values
|
|
3843
3918
|
*/
|
|
3844
3919
|
a(this, "parse", (...e) => {
|
|
@@ -3861,21 +3936,21 @@ const Qt = class Qt {
|
|
|
3861
3936
|
h(this, st, { AB: t, BC: i, AC: n });
|
|
3862
3937
|
let r = t.intersection(i);
|
|
3863
3938
|
if (r.hasIntersection)
|
|
3864
|
-
h(this,
|
|
3939
|
+
h(this, _, r.point.clone());
|
|
3865
3940
|
else
|
|
3866
3941
|
throw new Error("Lines do not intersect !");
|
|
3867
3942
|
if (r = i.intersection(n), r.hasIntersection)
|
|
3868
|
-
h(this,
|
|
3943
|
+
h(this, ee, r.point.clone());
|
|
3869
3944
|
else
|
|
3870
3945
|
throw new Error("Lines do not intersect !");
|
|
3871
3946
|
if (r = n.intersection(t), r.hasIntersection)
|
|
3872
3947
|
h(this, Y, r.point.clone());
|
|
3873
3948
|
else
|
|
3874
3949
|
throw new Error("Lines do not intersect !");
|
|
3875
|
-
} else e.every((t) => t instanceof B) && (h(this, Y, e[0].clone()), h(this,
|
|
3876
|
-
AB: new R(s(this, Y), s(this,
|
|
3877
|
-
BC: new R(s(this,
|
|
3878
|
-
AC: new R(s(this, Y), s(this,
|
|
3950
|
+
} else e.every((t) => t instanceof B) && (h(this, Y, e[0].clone()), h(this, _, e[1].clone()), h(this, ee, e[2].clone()), h(this, st, {
|
|
3951
|
+
AB: new R(s(this, Y), s(this, _)),
|
|
3952
|
+
BC: new R(s(this, _), s(this, ee)),
|
|
3953
|
+
AC: new R(s(this, Y), s(this, ee))
|
|
3879
3954
|
}));
|
|
3880
3955
|
} else if (e.length === 1 && e[0] instanceof Qt)
|
|
3881
3956
|
return e[0].clone();
|
|
@@ -3886,8 +3961,8 @@ const Qt = class Qt {
|
|
|
3886
3961
|
*/
|
|
3887
3962
|
a(this, "clone", () => new Qt(
|
|
3888
3963
|
s(this, Y).clone(),
|
|
3889
|
-
s(this,
|
|
3890
|
-
s(this,
|
|
3964
|
+
s(this, _).clone(),
|
|
3965
|
+
s(this, ee).clone()
|
|
3891
3966
|
));
|
|
3892
3967
|
// ------------------------------------------
|
|
3893
3968
|
// Triangle operations and properties
|
|
@@ -3895,25 +3970,25 @@ const Qt = class Qt {
|
|
|
3895
3970
|
/**
|
|
3896
3971
|
* Generate the Line object for the three segments of the triangle
|
|
3897
3972
|
*/
|
|
3898
|
-
|
|
3899
|
-
s(this, Y).asPoint = !0, s(this,
|
|
3900
|
-
AB: new B().middleOf(s(this, Y), s(this,
|
|
3901
|
-
AC: new B().middleOf(s(this, Y), s(this,
|
|
3902
|
-
BC: new B().middleOf(s(this,
|
|
3903
|
-
}), h(this,
|
|
3973
|
+
m(this, Xt, () => {
|
|
3974
|
+
s(this, Y).asPoint = !0, s(this, _).asPoint = !0, s(this, ee).asPoint = !0, h(this, Ce, {
|
|
3975
|
+
AB: new B().middleOf(s(this, Y), s(this, _)),
|
|
3976
|
+
AC: new B().middleOf(s(this, Y), s(this, ee)),
|
|
3977
|
+
BC: new B().middleOf(s(this, _), s(this, ee))
|
|
3978
|
+
}), h(this, yt, s(this, Yt).call(this));
|
|
3904
3979
|
});
|
|
3905
3980
|
/**
|
|
3906
3981
|
* Get the Vector2D class for the given name
|
|
3907
3982
|
* @param ptName
|
|
3908
3983
|
*/
|
|
3909
|
-
|
|
3984
|
+
m(this, wt, (e) => {
|
|
3910
3985
|
switch (e.toUpperCase()) {
|
|
3911
3986
|
case "A":
|
|
3912
3987
|
return s(this, Y);
|
|
3913
3988
|
case "B":
|
|
3914
|
-
return s(this, J);
|
|
3915
|
-
case "C":
|
|
3916
3989
|
return s(this, _);
|
|
3990
|
+
case "C":
|
|
3991
|
+
return s(this, ee);
|
|
3917
3992
|
}
|
|
3918
3993
|
return s(this, Y);
|
|
3919
3994
|
});
|
|
@@ -3922,52 +3997,52 @@ const Qt = class Qt {
|
|
|
3922
3997
|
* @param ptName1
|
|
3923
3998
|
* @param ptName2
|
|
3924
3999
|
*/
|
|
3925
|
-
|
|
3926
|
-
s(this,
|
|
3927
|
-
s(this,
|
|
4000
|
+
m(this, Be, (e, t) => new E(
|
|
4001
|
+
s(this, wt).call(this, e),
|
|
4002
|
+
s(this, wt).call(this, t)
|
|
3928
4003
|
));
|
|
3929
|
-
|
|
4004
|
+
m(this, Yt, () => {
|
|
3930
4005
|
const e = {
|
|
3931
4006
|
A: new R().fromPoints(s(this, Y), s(this, Ce).BC),
|
|
3932
|
-
B: new R().fromPoints(s(this,
|
|
3933
|
-
C: new R().fromPoints(s(this,
|
|
4007
|
+
B: new R().fromPoints(s(this, _), s(this, Ce).AC),
|
|
4008
|
+
C: new R().fromPoints(s(this, ee), s(this, Ce).AB),
|
|
3934
4009
|
intersection: null
|
|
3935
4010
|
}, t = {
|
|
3936
|
-
AB: new R().fromPointAndNormal(s(this, Ce).AB, new E(s(this, Y), s(this,
|
|
3937
|
-
AC: new R().fromPointAndNormal(s(this, Ce).AC, new E(s(this, Y), s(this,
|
|
3938
|
-
BC: new R().fromPointAndNormal(s(this, Ce).BC, new E(s(this,
|
|
4011
|
+
AB: new R().fromPointAndNormal(s(this, Ce).AB, new E(s(this, Y), s(this, _)).normal()),
|
|
4012
|
+
AC: new R().fromPointAndNormal(s(this, Ce).AC, new E(s(this, Y), s(this, ee)).normal()),
|
|
4013
|
+
BC: new R().fromPointAndNormal(s(this, Ce).BC, new E(s(this, _), s(this, ee)).normal()),
|
|
3939
4014
|
intersection: null
|
|
3940
4015
|
}, i = {
|
|
3941
|
-
A: new R().fromPointAndNormal(s(this, Y), new E(s(this,
|
|
3942
|
-
B: new R().fromPointAndNormal(s(this,
|
|
3943
|
-
C: new R().fromPointAndNormal(s(this,
|
|
4016
|
+
A: new R().fromPointAndNormal(s(this, Y), new E(s(this, _), s(this, ee)).normal()),
|
|
4017
|
+
B: new R().fromPointAndNormal(s(this, _), new E(s(this, Y), s(this, ee)).normal()),
|
|
4018
|
+
C: new R().fromPointAndNormal(s(this, ee), new E(s(this, Y), s(this, _)).normal()),
|
|
3944
4019
|
intersection: null
|
|
3945
4020
|
}, n = s(this, nt).call(this, "A"), r = s(this, nt).call(this, "B"), l = s(this, nt).call(this, "C"), c = {
|
|
3946
4021
|
A: n.internal,
|
|
3947
4022
|
B: r.internal,
|
|
3948
4023
|
C: r.internal,
|
|
3949
4024
|
intersection: null
|
|
3950
|
-
},
|
|
4025
|
+
}, f = {
|
|
3951
4026
|
A: n.external,
|
|
3952
4027
|
B: r.external,
|
|
3953
4028
|
C: l.external,
|
|
3954
4029
|
intersection: null
|
|
3955
|
-
},
|
|
4030
|
+
}, d = {
|
|
3956
4031
|
medians: e,
|
|
3957
4032
|
mediators: t,
|
|
3958
4033
|
heights: i,
|
|
3959
4034
|
bisectors: c,
|
|
3960
|
-
externalBisectors:
|
|
4035
|
+
externalBisectors: f
|
|
3961
4036
|
};
|
|
3962
|
-
return
|
|
4037
|
+
return d.medians.intersection = d.medians.A.intersection(d.medians.B).point, d.mediators.intersection = d.mediators.AB.intersection(d.mediators.BC).point, d.heights.intersection = d.heights.A.intersection(d.heights.B).point, d.bisectors.intersection = d.bisectors.A.intersection(d.bisectors.B).point, d;
|
|
3963
4038
|
});
|
|
3964
|
-
|
|
4039
|
+
m(this, nt, (e) => {
|
|
3965
4040
|
const t = this.lines;
|
|
3966
4041
|
let i, n;
|
|
3967
4042
|
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)
|
|
3968
4043
|
throw new Error(`The point ${e} does not exist`);
|
|
3969
|
-
const r = i.n.simplify().norm, l = n.n.simplify().norm, c = i.getEquation().multiply(l),
|
|
3970
|
-
return e === "A" ?
|
|
4044
|
+
const r = i.n.simplify().norm, l = n.n.simplify().norm, c = i.getEquation().multiply(l), f = n.getEquation().multiply(r), d = new R(c.clone().subtract(f).simplify()), p = new R(f.clone().subtract(c).simplify());
|
|
4045
|
+
return e === "A" ? d.hitSegment(this.B, this.C) ? { internal: d, external: p } : { internal: p, external: d } : e === "B" ? d.hitSegment(this.A, this.C) ? { internal: d, external: p } : { internal: p, external: d } : e === "C" ? d.hitSegment(this.B, this.A) ? { internal: d, external: p } : { internal: p, external: d } : { internal: d, external: p };
|
|
3971
4046
|
});
|
|
3972
4047
|
return e.length > 0 && this.parse(...e), this;
|
|
3973
4048
|
}
|
|
@@ -3978,10 +4053,10 @@ const Qt = class Qt {
|
|
|
3978
4053
|
return s(this, Y);
|
|
3979
4054
|
}
|
|
3980
4055
|
get B() {
|
|
3981
|
-
return s(this,
|
|
4056
|
+
return s(this, _);
|
|
3982
4057
|
}
|
|
3983
4058
|
get C() {
|
|
3984
|
-
return s(this,
|
|
4059
|
+
return s(this, ee);
|
|
3985
4060
|
}
|
|
3986
4061
|
get AB() {
|
|
3987
4062
|
return s(this, Be).call(this, "A", "B");
|
|
@@ -4014,11 +4089,11 @@ const Qt = class Qt {
|
|
|
4014
4089
|
return s(this, st);
|
|
4015
4090
|
}
|
|
4016
4091
|
get remarquables() {
|
|
4017
|
-
return s(this,
|
|
4092
|
+
return s(this, yt);
|
|
4018
4093
|
}
|
|
4019
4094
|
};
|
|
4020
|
-
Y = new WeakMap(),
|
|
4021
|
-
let
|
|
4095
|
+
Y = new WeakMap(), _ = new WeakMap(), ee = new WeakMap(), st = new WeakMap(), Ce = new WeakMap(), yt = new WeakMap(), Xt = new WeakMap(), wt = new WeakMap(), Be = new WeakMap(), Yt = new WeakMap(), nt = new WeakMap();
|
|
4096
|
+
let li = Qt;
|
|
4022
4097
|
function qt(o) {
|
|
4023
4098
|
const e = Object.assign(
|
|
4024
4099
|
{
|
|
@@ -4030,16 +4105,16 @@ function qt(o) {
|
|
|
4030
4105
|
},
|
|
4031
4106
|
o
|
|
4032
4107
|
), t = new u();
|
|
4033
|
-
if (e.negative ? t.numerator = Q(e.max, e.zero) : t.numerator =
|
|
4108
|
+
if (e.negative ? t.numerator = Q(e.max, e.zero) : t.numerator = pe(e.zero ? 0 : 1, e.max), e.natural)
|
|
4034
4109
|
t.denominator = 1;
|
|
4035
4110
|
else {
|
|
4036
4111
|
let i = 0;
|
|
4037
4112
|
for (; t.isRelative() && i < 10; )
|
|
4038
|
-
t.denominator =
|
|
4113
|
+
t.denominator = pe(1, e.max), i++;
|
|
4039
4114
|
}
|
|
4040
4115
|
return e.reduced ? t.reduce() : t;
|
|
4041
4116
|
}
|
|
4042
|
-
function
|
|
4117
|
+
function Ri(o) {
|
|
4043
4118
|
const e = Object.assign(
|
|
4044
4119
|
{
|
|
4045
4120
|
letters: "x",
|
|
@@ -4057,14 +4132,14 @@ function Bi(o) {
|
|
|
4057
4132
|
for (const i of e.letters.split(""))
|
|
4058
4133
|
t.setLetter(i, 0);
|
|
4059
4134
|
for (let i = 0; i < e.degree; i++) {
|
|
4060
|
-
const n =
|
|
4135
|
+
const n = di(e.letters.split(""));
|
|
4061
4136
|
t.setLetter(n, t.degree(n).clone().add(1));
|
|
4062
4137
|
}
|
|
4063
4138
|
} else
|
|
4064
4139
|
t.setLetter(e.letters, e.degree);
|
|
4065
4140
|
return t;
|
|
4066
4141
|
}
|
|
4067
|
-
const
|
|
4142
|
+
const us = {
|
|
4068
4143
|
letters: "x",
|
|
4069
4144
|
degree: 2,
|
|
4070
4145
|
fraction: !1,
|
|
@@ -4075,14 +4150,14 @@ const ls = {
|
|
|
4075
4150
|
numberOfMonoms: 0,
|
|
4076
4151
|
positive: !0
|
|
4077
4152
|
};
|
|
4078
|
-
function
|
|
4153
|
+
function zi(o) {
|
|
4079
4154
|
const e = Object.assign(
|
|
4080
|
-
|
|
4155
|
+
us,
|
|
4081
4156
|
o
|
|
4082
|
-
), t = new
|
|
4157
|
+
), t = new O().empty();
|
|
4083
4158
|
let i;
|
|
4084
4159
|
for (let n = e.degree; n >= 0; n--)
|
|
4085
|
-
i =
|
|
4160
|
+
i = Ri({
|
|
4086
4161
|
letters: e.letters,
|
|
4087
4162
|
degree: n,
|
|
4088
4163
|
fraction: e.fraction,
|
|
@@ -4090,12 +4165,12 @@ function Si(o) {
|
|
|
4090
4165
|
}), e.unit && e.degree === n && i.coefficient.one(), t.add(i);
|
|
4091
4166
|
if (e.positive && t.monomByDegree().coefficient.isNegative() && t.monomByDegree().coefficient.opposite(), e.numberOfMonoms && e.numberOfMonoms > 0 && e.numberOfMonoms < t.length)
|
|
4092
4167
|
for (; t.length > e.numberOfMonoms; ) {
|
|
4093
|
-
const n =
|
|
4168
|
+
const n = pe(1, t.length - 1);
|
|
4094
4169
|
t.monoms.splice(n, 1);
|
|
4095
4170
|
}
|
|
4096
4171
|
return t.reduce();
|
|
4097
4172
|
}
|
|
4098
|
-
function
|
|
4173
|
+
function fs(o) {
|
|
4099
4174
|
const e = Object.assign(
|
|
4100
4175
|
{
|
|
4101
4176
|
letters: "x",
|
|
@@ -4115,9 +4190,9 @@ function cs(o) {
|
|
|
4115
4190
|
}
|
|
4116
4191
|
},
|
|
4117
4192
|
o
|
|
4118
|
-
), t = new
|
|
4193
|
+
), t = new O().one();
|
|
4119
4194
|
for (let i = 0; i < e.degree; i++) {
|
|
4120
|
-
const n =
|
|
4195
|
+
const n = zi({
|
|
4121
4196
|
degree: 1,
|
|
4122
4197
|
unit: e.unit,
|
|
4123
4198
|
fraction: e.fraction,
|
|
@@ -4126,9 +4201,9 @@ function cs(o) {
|
|
|
4126
4201
|
});
|
|
4127
4202
|
t.multiply(n);
|
|
4128
4203
|
}
|
|
4129
|
-
return new
|
|
4204
|
+
return new H(t, 0);
|
|
4130
4205
|
}
|
|
4131
|
-
function
|
|
4206
|
+
function ci(o) {
|
|
4132
4207
|
const e = Object.assign(
|
|
4133
4208
|
{
|
|
4134
4209
|
axis: !0,
|
|
@@ -4140,7 +4215,7 @@ function ui(o) {
|
|
|
4140
4215
|
), t = e.axis === "x", i = e.axis === "y", n = e.fraction ? qt({ max: e.max, zero: t }) : new u(Q(e.max, t)), r = e.fraction ? qt({ max: e.max, zero: i }) : new u(Q(e.max, i));
|
|
4141
4216
|
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);
|
|
4142
4217
|
}
|
|
4143
|
-
function
|
|
4218
|
+
function ds(o) {
|
|
4144
4219
|
const e = Object.assign(
|
|
4145
4220
|
{
|
|
4146
4221
|
center: {
|
|
@@ -4150,11 +4225,11 @@ function us(o) {
|
|
|
4150
4225
|
pointsOnCircle: 8
|
|
4151
4226
|
},
|
|
4152
4227
|
o
|
|
4153
|
-
), t =
|
|
4228
|
+
), t = ci(e.center);
|
|
4154
4229
|
let i, n;
|
|
4155
|
-
return e.pointsOnCircle === 8 ? (i =
|
|
4230
|
+
return e.pointsOnCircle === 8 ? (i = pe(1, 3), n = i ** 2 + (i + 1) ** 2) : n = pe(1, 20), new Tt(t, n, !0);
|
|
4156
4231
|
}
|
|
4157
|
-
function
|
|
4232
|
+
function ps(o) {
|
|
4158
4233
|
const e = Object.assign(
|
|
4159
4234
|
{
|
|
4160
4235
|
A: {
|
|
@@ -4171,7 +4246,7 @@ function fs(o) {
|
|
|
4171
4246
|
t.x = Q(10), t.y = Q(10);
|
|
4172
4247
|
return e.slope === 1 ? t.x.sign() !== t.y.sign() && t.y.opposite() : e.slope === -1 && t.x.sign() !== t.y.sign() && t.y.opposite(), new R(new E(e.A.x, e.A.y), t);
|
|
4173
4248
|
}
|
|
4174
|
-
function
|
|
4249
|
+
function ms(o) {
|
|
4175
4250
|
const e = Object.assign(
|
|
4176
4251
|
{
|
|
4177
4252
|
A: {
|
|
@@ -4187,79 +4262,79 @@ function ds(o) {
|
|
|
4187
4262
|
},
|
|
4188
4263
|
o
|
|
4189
4264
|
), t = new B(e.A.x, e.A.y, e.A.z), i = new E(e.direction.x, e.direction.y, e.direction.z);
|
|
4190
|
-
return new
|
|
4265
|
+
return new Ot(t, i);
|
|
4191
4266
|
}
|
|
4192
|
-
const
|
|
4193
|
-
equation: (o) =>
|
|
4194
|
-
polynom: (o) =>
|
|
4195
|
-
monom: (o) =>
|
|
4267
|
+
const gs = {
|
|
4268
|
+
equation: (o) => fs(o),
|
|
4269
|
+
polynom: (o) => zi(o),
|
|
4270
|
+
monom: (o) => Ri(o),
|
|
4196
4271
|
fraction: (o) => qt(o),
|
|
4197
|
-
number: (o, e, t) =>
|
|
4272
|
+
number: (o, e, t) => pe(o, e, t),
|
|
4198
4273
|
numberSym: (o, e) => Q(o, e),
|
|
4199
|
-
prime: (o) =>
|
|
4200
|
-
bool: (o) =>
|
|
4201
|
-
array: (o, e) =>
|
|
4202
|
-
item: (o) =>
|
|
4203
|
-
shuffle: (o) =>
|
|
4204
|
-
line: (o) =>
|
|
4205
|
-
line3: (o) =>
|
|
4206
|
-
vector: (o) =>
|
|
4274
|
+
prime: (o) => as(o),
|
|
4275
|
+
bool: (o) => Ci(o),
|
|
4276
|
+
array: (o, e) => ls(o, e),
|
|
4277
|
+
item: (o) => di(o),
|
|
4278
|
+
shuffle: (o) => $i(o),
|
|
4279
|
+
line: (o) => ps(o),
|
|
4280
|
+
line3: (o) => ms(o),
|
|
4281
|
+
vector: (o) => ci(o),
|
|
4207
4282
|
point: (o) => {
|
|
4208
|
-
const e =
|
|
4283
|
+
const e = ci(o);
|
|
4209
4284
|
return e.asPoint = !0, e;
|
|
4210
4285
|
},
|
|
4211
|
-
circle: (o) =>
|
|
4212
|
-
},
|
|
4213
|
-
Numeric:
|
|
4286
|
+
circle: (o) => ds(o)
|
|
4287
|
+
}, ws = {
|
|
4288
|
+
Numeric: U,
|
|
4214
4289
|
Fraction: u,
|
|
4215
|
-
Root:
|
|
4290
|
+
Root: vt,
|
|
4216
4291
|
Monom: k,
|
|
4217
|
-
Polynom:
|
|
4218
|
-
Equation:
|
|
4219
|
-
Matrix:
|
|
4220
|
-
LinearSystem:
|
|
4221
|
-
Factor:
|
|
4222
|
-
PolyFactor:
|
|
4223
|
-
LogicalSet:
|
|
4224
|
-
Random:
|
|
4292
|
+
Polynom: O,
|
|
4293
|
+
Equation: H,
|
|
4294
|
+
Matrix: cs,
|
|
4295
|
+
LinearSystem: ti,
|
|
4296
|
+
Factor: ae,
|
|
4297
|
+
PolyFactor: si,
|
|
4298
|
+
LogicalSet: ss,
|
|
4299
|
+
Random: gs,
|
|
4225
4300
|
Geometry: {
|
|
4226
4301
|
Vector: E,
|
|
4227
4302
|
Point: B,
|
|
4228
4303
|
Line: R,
|
|
4229
|
-
Triangle:
|
|
4304
|
+
Triangle: li,
|
|
4230
4305
|
Circle: Tt,
|
|
4231
|
-
Line3:
|
|
4232
|
-
Plane3:
|
|
4306
|
+
Line3: Ot,
|
|
4307
|
+
Plane3: ai
|
|
4233
4308
|
},
|
|
4234
|
-
NumExp:
|
|
4309
|
+
NumExp: is
|
|
4235
4310
|
};
|
|
4236
4311
|
export {
|
|
4237
4312
|
Tt as Circle,
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4313
|
+
H as Equation,
|
|
4314
|
+
At as EquationSolver,
|
|
4315
|
+
lt as FACTOR_DISPLAY,
|
|
4316
|
+
ae as Factor,
|
|
4242
4317
|
u as Fraction,
|
|
4243
4318
|
R as Line,
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4319
|
+
Ot as Line3,
|
|
4320
|
+
ti as LinearSystem,
|
|
4321
|
+
ss as LogicalSet,
|
|
4322
|
+
cs as Matrix,
|
|
4248
4323
|
k as Monom,
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4324
|
+
vt as NthRoot,
|
|
4325
|
+
is as NumExp,
|
|
4326
|
+
U as Numeric,
|
|
4327
|
+
ai as Plane3,
|
|
4253
4328
|
B as Point,
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4329
|
+
si as PolyFactor,
|
|
4330
|
+
O as Polynom,
|
|
4331
|
+
gs as Random,
|
|
4332
|
+
li as Triangle,
|
|
4258
4333
|
E as Vector,
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4334
|
+
rs as areVectorsColinears,
|
|
4335
|
+
ns as areVectorsEquals,
|
|
4336
|
+
ws as default,
|
|
4337
|
+
hs as determinant,
|
|
4338
|
+
os as dotProduct
|
|
4264
4339
|
};
|
|
4265
4340
|
//# sourceMappingURL=pimath.js.map
|