pimath 0.1.28 → 0.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/algebra/linearSystem.d.ts +1 -1
- package/dist/geometry/index.d.ts +1 -0
- package/dist/geometry/plane3.d.ts +1 -0
- package/dist/geometry/sphere3.d.ts +34 -0
- package/dist/index.d.ts +2 -1
- package/dist/pimath.js +1157 -1044
- package/dist/pimath.js.map +1 -1
- package/dist/randomization/algebra/rndPolynom.d.ts +1 -1
- package/package.json +1 -1
package/dist/pimath.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var Xi = Object.defineProperty;
|
|
2
|
+
var Ni = (o) => {
|
|
3
3
|
throw TypeError(o);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var a = (o, e, t) =>
|
|
7
|
-
var s = (o, e, t) => (
|
|
8
|
-
function
|
|
9
|
-
const e =
|
|
5
|
+
var Yi = (o, e, t) => e in o ? Xi(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
6
|
+
var a = (o, e, t) => Yi(o, typeof e != "symbol" ? e + "" : e, t), ri = (o, e, t) => e.has(o) || Ni("Cannot " + t);
|
|
7
|
+
var s = (o, e, t) => (ri(o, e, "read from private field"), t ? t.call(o) : e.get(o)), m = (o, e, t) => e.has(o) ? Ni("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), h = (o, e, t, i) => (ri(o, e, "write to private field"), i ? i.call(o, t) : e.set(o, t), t), A = (o, e, t) => (ri(o, e, "access private method"), t);
|
|
8
|
+
function Qi(o) {
|
|
9
|
+
const e = Ai(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 Hi(...o) {
|
|
16
|
+
const e = wi(...o);
|
|
17
17
|
return o.map((t) => t / e);
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function Ai(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 wi(o) {
|
|
|
24
24
|
return n - r;
|
|
25
25
|
}), [...new Set(i)];
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function wi(...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 ui(...o) {
|
|
|
39
39
|
;
|
|
40
40
|
return Math.abs(t);
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function Ki(...o) {
|
|
43
43
|
return o.reduce(function(e, t) {
|
|
44
|
-
return Math.abs(e * t /
|
|
44
|
+
return Math.abs(e * t / wi(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 _i(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 es(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 ts(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 is(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 G = {
|
|
70
|
+
decompose: Qi,
|
|
71
|
+
dividers: Ai,
|
|
72
|
+
divideNumbersByGCD: Hi,
|
|
73
|
+
gcd: wi,
|
|
74
|
+
lcm: Ki,
|
|
75
|
+
numberCorrection: Ji,
|
|
76
|
+
periodic: _i,
|
|
77
|
+
primes: es,
|
|
78
|
+
pythagoreanTripletsWithTarget: ts,
|
|
79
|
+
round: is
|
|
80
80
|
};
|
|
81
|
-
var
|
|
82
|
-
const
|
|
81
|
+
var mt, x, v, Le;
|
|
82
|
+
const B = class B {
|
|
83
83
|
constructor(e, t) {
|
|
84
|
-
m(this,
|
|
84
|
+
m(this, mt, !1);
|
|
85
85
|
m(this, x, 1);
|
|
86
86
|
m(this, v, 1);
|
|
87
|
-
m(this,
|
|
87
|
+
m(this, Le, "frac");
|
|
88
88
|
// ------------------------------------------
|
|
89
89
|
/**
|
|
90
90
|
* Parse the value to get the numerator and denominator
|
|
@@ -114,22 +114,22 @@ const $ = class $ {
|
|
|
114
114
|
}
|
|
115
115
|
break;
|
|
116
116
|
case "object":
|
|
117
|
-
e instanceof
|
|
117
|
+
e instanceof B && (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
|
|
123
|
+
const e = new B();
|
|
124
124
|
return e.numerator = +s(this, v), e.denominator = +s(this, x), e;
|
|
125
125
|
});
|
|
126
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
|
|
128
|
+
if (e instanceof B) {
|
|
129
129
|
const t = s(this, v), i = s(this, x);
|
|
130
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 B(e));
|
|
133
133
|
return this.reduce();
|
|
134
134
|
});
|
|
135
135
|
a(this, "amplify", (e) => (Number.isSafeInteger(e) && (h(this, v, s(this, v) * e), h(this, x, s(this, x) * e)), this));
|
|
@@ -146,7 +146,7 @@ const $ = class $ {
|
|
|
146
146
|
a(this, "compare", (e, t) => {
|
|
147
147
|
t === void 0 && (t = "=");
|
|
148
148
|
let i;
|
|
149
|
-
switch (e instanceof
|
|
149
|
+
switch (e instanceof B ? i = e.clone() : i = new B(e), t) {
|
|
150
150
|
case ">":
|
|
151
151
|
return this.value > i.value;
|
|
152
152
|
case ">=":
|
|
@@ -168,9 +168,9 @@ const $ = class $ {
|
|
|
168
168
|
}
|
|
169
169
|
});
|
|
170
170
|
a(this, "divide", (e) => {
|
|
171
|
-
const t = new
|
|
171
|
+
const t = new B(e);
|
|
172
172
|
if (t.numerator === 0)
|
|
173
|
-
return new
|
|
173
|
+
return new B().infinite();
|
|
174
174
|
const i = +s(this, v), n = +s(this, x);
|
|
175
175
|
return h(this, v, i * t.denominator), h(this, x, n * t.numerator), this.reduce();
|
|
176
176
|
});
|
|
@@ -180,7 +180,7 @@ const $ = class $ {
|
|
|
180
180
|
const e = +s(this, v);
|
|
181
181
|
return h(this, v, +s(this, x)), h(this, x, e), this;
|
|
182
182
|
});
|
|
183
|
-
a(this, "isApproximative", () => s(this,
|
|
183
|
+
a(this, "isApproximative", () => s(this, mt) || s(this, v).toString().length >= 15 && s(this, x).toString().length >= 15);
|
|
184
184
|
a(this, "isEqual", (e) => this.compare(e, "="));
|
|
185
185
|
a(this, "isEven", () => this.isRelative() && this.value % 2 === 0);
|
|
186
186
|
a(this, "isExact", () => !this.isApproximative());
|
|
@@ -188,7 +188,7 @@ const $ = class $ {
|
|
|
188
188
|
a(this, "isGeq", (e) => this.compare(e, ">="));
|
|
189
189
|
a(this, "isGreater", (e) => this.compare(e, ">"));
|
|
190
190
|
a(this, "isInfinity", () => Math.abs(s(this, v)) === 1 / 0);
|
|
191
|
-
a(this, "isInverted", (e) => this.isEqual(new
|
|
191
|
+
a(this, "isInverted", (e) => this.isEqual(new B().one().divide(e.clone())));
|
|
192
192
|
a(this, "isLeq", (e) => this.compare(e, "<="));
|
|
193
193
|
/* Compare shortcuts */
|
|
194
194
|
a(this, "isLesser", (e) => this.compare(e, "<"));
|
|
@@ -204,7 +204,7 @@ const $ = class $ {
|
|
|
204
204
|
a(this, "isOpposite", (e) => this.isEqual(e.clone().opposite()));
|
|
205
205
|
a(this, "isPositive", () => this.sign() === 1);
|
|
206
206
|
a(this, "isRational", () => !this.isRelative());
|
|
207
|
-
a(this, "isReduced", () => Math.abs(
|
|
207
|
+
a(this, "isReduced", () => Math.abs(G.gcd(s(this, v), s(this, x))) === 1);
|
|
208
208
|
a(this, "isRelative", () => this.clone().reduce().denominator === 1);
|
|
209
209
|
a(this, "isSquare", () => Math.sqrt(s(this, v)) % 1 === 0 && Math.sqrt(s(this, x)) % 1 === 0);
|
|
210
210
|
a(this, "isStrictlyNegative", () => this.value < 0);
|
|
@@ -212,13 +212,13 @@ const $ = class $ {
|
|
|
212
212
|
// Mathematical operations specific to fractions
|
|
213
213
|
a(this, "isZero", () => s(this, v) === 0);
|
|
214
214
|
a(this, "multiply", (e) => {
|
|
215
|
-
const t = new
|
|
215
|
+
const t = new B(e);
|
|
216
216
|
return h(this, v, s(this, v) * t.numerator), h(this, x, s(this, x) * t.denominator), this.reduce();
|
|
217
217
|
});
|
|
218
218
|
a(this, "one", () => (h(this, v, 1), h(this, x, 1), this));
|
|
219
219
|
a(this, "opposite", () => (h(this, v, -s(this, v)), this));
|
|
220
220
|
a(this, "pow", (e) => {
|
|
221
|
-
if (e instanceof
|
|
221
|
+
if (e instanceof B)
|
|
222
222
|
return this.pow(e.value);
|
|
223
223
|
this.reduce(), e < 0 && this.inverse();
|
|
224
224
|
const t = Math.floor(Math.pow(s(this, v), Math.abs(e))), i = Math.floor(Math.pow(s(this, x), Math.abs(e)));
|
|
@@ -226,7 +226,7 @@ const $ = class $ {
|
|
|
226
226
|
});
|
|
227
227
|
// ------------------------------------------
|
|
228
228
|
a(this, "reduce", () => {
|
|
229
|
-
const e =
|
|
229
|
+
const e = G.gcd(s(this, v), s(this, x));
|
|
230
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;
|
|
231
231
|
});
|
|
232
232
|
a(this, "root", (e) => {
|
|
@@ -239,13 +239,13 @@ const $ = class $ {
|
|
|
239
239
|
const t = this.sign();
|
|
240
240
|
this.abs(), this.reduce();
|
|
241
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,
|
|
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, mt, !0)), this.multiply(t), this;
|
|
243
243
|
});
|
|
244
244
|
// ------------------------------------------
|
|
245
245
|
// Getter and setter
|
|
246
246
|
a(this, "sign", () => s(this, v) * s(this, x) >= 0 ? 1 : -1);
|
|
247
247
|
a(this, "sqrt", () => this.root(2));
|
|
248
|
-
a(this, "subtract", (e) => e instanceof
|
|
248
|
+
a(this, "subtract", (e) => e instanceof B ? this.add(e.clone().opposite()) : this.add(-e));
|
|
249
249
|
a(this, "zero", () => (h(this, v, 0), h(this, x, 1), this));
|
|
250
250
|
return e !== void 0 && this.parse(e, t), this;
|
|
251
251
|
}
|
|
@@ -256,13 +256,13 @@ const $ = class $ {
|
|
|
256
256
|
h(this, x, e);
|
|
257
257
|
}
|
|
258
258
|
get dfrac() {
|
|
259
|
-
return h(this,
|
|
259
|
+
return h(this, Le, "dfrac"), this;
|
|
260
260
|
}
|
|
261
261
|
get display() {
|
|
262
262
|
return this.isExact() ? s(this, x) === 1 ? `${s(this, v)}` : `${s(this, v)}/${s(this, x)}` : this.value.toFixed(3);
|
|
263
263
|
}
|
|
264
264
|
get frac() {
|
|
265
|
-
return h(this,
|
|
265
|
+
return h(this, Le, "frac"), this;
|
|
266
266
|
}
|
|
267
267
|
// ------------------------------------------
|
|
268
268
|
get numerator() {
|
|
@@ -273,97 +273,97 @@ const $ = class $ {
|
|
|
273
273
|
}
|
|
274
274
|
// Display getter
|
|
275
275
|
get tex() {
|
|
276
|
-
return this.isInfinity() ? `${this.sign() === 1 ? "+" : "-"}\\infty` : this.isExact() ? s(this, x) === 1 ? `${s(this, v)}` : s(this, v) < 0 ? `-\\${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, Le)}{ ${-s(this, v)} }{ ${s(this, x)} }` : `\\${s(this, Le)}{ ${s(this, v)} }{ ${s(this, x)} }` : this.value.toFixed(3);
|
|
277
277
|
}
|
|
278
278
|
get texWithSign() {
|
|
279
279
|
return this.isPositive() ? `+${this.tex}` : this.tex;
|
|
280
280
|
}
|
|
281
281
|
get tfrac() {
|
|
282
|
-
return h(this,
|
|
282
|
+
return h(this, Le, "tfrac"), this;
|
|
283
283
|
}
|
|
284
284
|
get value() {
|
|
285
285
|
const e = s(this, v) / s(this, x);
|
|
286
286
|
return e === 0 ? 0 : e;
|
|
287
287
|
}
|
|
288
288
|
};
|
|
289
|
-
|
|
290
|
-
const t = new
|
|
289
|
+
mt = new WeakMap(), x = new WeakMap(), v = new WeakMap(), Le = new WeakMap(), a(B, "average", (...e) => {
|
|
290
|
+
const t = new B().zero();
|
|
291
291
|
for (const i of e)
|
|
292
292
|
t.add(i);
|
|
293
293
|
return t.divide(e.length), t;
|
|
294
|
-
}), a(
|
|
295
|
-
let t = new
|
|
294
|
+
}), a(B, "max", (...e) => {
|
|
295
|
+
let t = new B(e[0]);
|
|
296
296
|
for (const i of e) {
|
|
297
|
-
const n = new
|
|
297
|
+
const n = new B(i);
|
|
298
298
|
n.isGreater(t) && (t = n.clone());
|
|
299
299
|
}
|
|
300
300
|
return t;
|
|
301
|
-
}), a(
|
|
302
|
-
let t = new
|
|
301
|
+
}), a(B, "min", (...e) => {
|
|
302
|
+
let t = new B(e[0]);
|
|
303
303
|
for (const i of e) {
|
|
304
|
-
const n = new
|
|
304
|
+
const n = new B(i);
|
|
305
305
|
n.isLesser(t) && (t = n.clone());
|
|
306
306
|
}
|
|
307
307
|
return t;
|
|
308
|
-
}), a(
|
|
309
|
-
const n = e.map((r) => r instanceof
|
|
308
|
+
}), a(B, "sort", (e, t) => {
|
|
309
|
+
const n = e.map((r) => r instanceof B ? r : new B(r)).sort((r, l) => r.value - l.value);
|
|
310
310
|
return t && n.reverse(), n;
|
|
311
311
|
}), // ------------------------------------------
|
|
312
312
|
// Compare functions
|
|
313
|
-
a(
|
|
313
|
+
a(B, "unique", (e) => {
|
|
314
314
|
const t = {}, i = [];
|
|
315
315
|
return e.forEach((n) => {
|
|
316
|
-
n instanceof
|
|
316
|
+
n instanceof B || (n = new B(n)), t[n.clone().reduce().tex] || (i.push(n.clone()), t[n.tex] = !0);
|
|
317
317
|
}), i;
|
|
318
|
-
}), a(
|
|
319
|
-
const t = new
|
|
318
|
+
}), a(B, "xMultiply", (...e) => {
|
|
319
|
+
const t = new B();
|
|
320
320
|
for (const i of e) {
|
|
321
|
-
const n = new
|
|
321
|
+
const n = new B(i);
|
|
322
322
|
t.numerator = t.numerator * n.numerator, t.denominator = t.denominator * n.denominator;
|
|
323
323
|
}
|
|
324
324
|
return t;
|
|
325
325
|
});
|
|
326
|
-
let
|
|
327
|
-
var
|
|
328
|
-
class
|
|
326
|
+
let u = B;
|
|
327
|
+
var F, ie, re, Je;
|
|
328
|
+
class At {
|
|
329
329
|
constructor(...e) {
|
|
330
|
-
m(this,
|
|
330
|
+
m(this, F);
|
|
331
331
|
m(this, ie);
|
|
332
332
|
m(this, re);
|
|
333
|
-
m(this,
|
|
333
|
+
m(this, Je);
|
|
334
334
|
// ------------------------------------------
|
|
335
335
|
// Creation / parsing functions
|
|
336
336
|
// ------------------------------------------
|
|
337
|
-
a(this, "parse", (e, t, i) => (h(this, re, i ?? 1), h(this, ie, t ?? 2), h(this,
|
|
337
|
+
a(this, "parse", (e, t, i) => (h(this, re, i ?? 1), h(this, ie, t ?? 2), h(this, F, e), s(this, ie) % 2 === 0 && s(this, F) < 0 && h(this, Je, !1), this));
|
|
338
338
|
// ------------------------------------------
|
|
339
339
|
// Mathematical operations
|
|
340
340
|
// ------------------------------------------
|
|
341
341
|
a(this, "reduce", () => {
|
|
342
|
-
let e = Math.floor(Math.pow(s(this,
|
|
342
|
+
let e = Math.floor(Math.pow(s(this, F), 1 / s(this, ie)));
|
|
343
343
|
for (; e > 1; ) {
|
|
344
|
-
if (s(this,
|
|
345
|
-
h(this, re, s(this, re) * e), h(this,
|
|
344
|
+
if (s(this, F) % Math.pow(e, s(this, ie)) === 0) {
|
|
345
|
+
h(this, re, s(this, re) * e), h(this, F, s(this, F) / Math.pow(e, s(this, ie))), e = Math.floor(Math.pow(s(this, F), 1 / s(this, ie)));
|
|
346
346
|
continue;
|
|
347
347
|
}
|
|
348
348
|
e--;
|
|
349
349
|
}
|
|
350
350
|
return this;
|
|
351
351
|
});
|
|
352
|
-
a(this, "multiply", (e) => (h(this,
|
|
352
|
+
a(this, "multiply", (e) => (h(this, F, s(this, F) * e.radical), this.reduce()));
|
|
353
353
|
// ------------------------------------------
|
|
354
354
|
// Help functions
|
|
355
355
|
// ------------------------------------------
|
|
356
|
-
a(this, "hasRadical", () => !(s(this,
|
|
357
|
-
h(this,
|
|
356
|
+
a(this, "hasRadical", () => !(s(this, F) === 1 || s(this, F) === 0 || !s(this, Je)));
|
|
357
|
+
h(this, F, 1), h(this, re, 1), h(this, ie, 2), h(this, Je, !0), e.length > 0 && this.parse(e[0], e[1], e[2]);
|
|
358
358
|
}
|
|
359
359
|
// ------------------------------------------
|
|
360
360
|
// Getter and setter
|
|
361
361
|
// ------------------------------------------
|
|
362
362
|
get radical() {
|
|
363
|
-
return s(this,
|
|
363
|
+
return s(this, F);
|
|
364
364
|
}
|
|
365
365
|
set radical(e) {
|
|
366
|
-
h(this,
|
|
366
|
+
h(this, F, e);
|
|
367
367
|
}
|
|
368
368
|
get nth() {
|
|
369
369
|
return s(this, ie);
|
|
@@ -379,24 +379,24 @@ class vt {
|
|
|
379
379
|
}
|
|
380
380
|
get tex() {
|
|
381
381
|
let e;
|
|
382
|
-
return s(this, re) === 1 ? e = "" : s(this, re) === -1 ? e = "-" : e = s(this, re).toString(), s(this,
|
|
382
|
+
return s(this, re) === 1 ? e = "" : s(this, re) === -1 ? e = "-" : e = s(this, re).toString(), s(this, F) === 1 ? `${s(this, re)}` : s(this, ie) === 2 ? `${e}\\sqrt{${s(this, F)}}` : `${e}\\sqrt[${s(this, ie)}]{${s(this, F)}}`;
|
|
383
383
|
}
|
|
384
384
|
get display() {
|
|
385
385
|
let e;
|
|
386
|
-
return s(this, re) === 1 ? e = "" : s(this, re) === -1 ? e = "-" : e = s(this, re).toString(), s(this,
|
|
386
|
+
return s(this, re) === 1 ? e = "" : s(this, re) === -1 ? e = "-" : e = s(this, re).toString(), s(this, F) === 1 ? `${s(this, re)}` : s(this, ie) === 2 ? `${e}sqrt{${s(this, F)}}` : `${e}root(${s(this, ie)}){${s(this, F)}}`;
|
|
387
387
|
}
|
|
388
388
|
get value() {
|
|
389
|
-
return s(this, re) * Math.pow(s(this,
|
|
389
|
+
return s(this, re) * Math.pow(s(this, F), 1 / s(this, ie));
|
|
390
390
|
}
|
|
391
391
|
}
|
|
392
|
-
|
|
393
|
-
var K,
|
|
394
|
-
const
|
|
392
|
+
F = new WeakMap(), ie = new WeakMap(), re = new WeakMap(), Je = new WeakMap();
|
|
393
|
+
var K, Ge, M, Qe, ye, Ti, Oi, Ci, ki, Mi, $i, Bi;
|
|
394
|
+
const xi = class xi {
|
|
395
395
|
constructor(e, t, i = "x") {
|
|
396
|
-
m(this,
|
|
396
|
+
m(this, M);
|
|
397
397
|
m(this, K);
|
|
398
|
-
m(this,
|
|
399
|
-
if (h(this,
|
|
398
|
+
m(this, Ge);
|
|
399
|
+
if (h(this, Ge, i), Object.hasOwn(e, "moveLeft")) {
|
|
400
400
|
const n = e;
|
|
401
401
|
h(this, K, n.left.clone().subtract(n.right));
|
|
402
402
|
} else
|
|
@@ -407,92 +407,92 @@ const pi = class pi {
|
|
|
407
407
|
if (e === 0)
|
|
408
408
|
return [];
|
|
409
409
|
if (e === 1)
|
|
410
|
-
return A(this,
|
|
410
|
+
return A(this, M, Mi).call(this);
|
|
411
411
|
if (e === 2)
|
|
412
|
-
return A(this,
|
|
413
|
-
const t = A(this,
|
|
414
|
-
return t.length > 0 ? t : A(this,
|
|
412
|
+
return A(this, M, $i).call(this);
|
|
413
|
+
const t = A(this, M, Ci).call(this);
|
|
414
|
+
return t.length > 0 ? t : A(this, M, Ti).call(this);
|
|
415
415
|
}
|
|
416
416
|
solveAsCardan() {
|
|
417
417
|
if (s(this, K).degree().value !== 3)
|
|
418
418
|
throw new Error("The equation is not cubic.");
|
|
419
|
-
return A(this,
|
|
419
|
+
return A(this, M, ki).call(this);
|
|
420
420
|
}
|
|
421
421
|
};
|
|
422
|
-
K = new WeakMap(),
|
|
422
|
+
K = new WeakMap(), Ge = new WeakMap(), M = new WeakSet(), Qe = function(e, t) {
|
|
423
423
|
return {
|
|
424
|
-
variable: s(this,
|
|
424
|
+
variable: s(this, Ge),
|
|
425
425
|
exact: !1,
|
|
426
426
|
value: +e.toFixed(10),
|
|
427
427
|
tex: (t == null ? void 0 : t.tex) ?? "",
|
|
428
428
|
display: (t == null ? void 0 : t.display) ?? ""
|
|
429
429
|
};
|
|
430
|
-
},
|
|
431
|
-
if (e instanceof
|
|
432
|
-
return A(this,
|
|
433
|
-
const t = new
|
|
430
|
+
}, ye = function(e) {
|
|
431
|
+
if (e instanceof u && e.isApproximative())
|
|
432
|
+
return A(this, M, Qe).call(this, e.value);
|
|
433
|
+
const t = new u(e);
|
|
434
434
|
return {
|
|
435
|
-
variable: s(this,
|
|
435
|
+
variable: s(this, Ge),
|
|
436
436
|
exact: t,
|
|
437
437
|
value: t.value,
|
|
438
438
|
tex: t.tex,
|
|
439
439
|
display: t.display
|
|
440
440
|
};
|
|
441
|
-
},
|
|
441
|
+
}, Ti = function() {
|
|
442
442
|
const e = [];
|
|
443
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,
|
|
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
445
|
for (let p = -r; p <= r; p += c) {
|
|
446
|
-
const w =
|
|
447
|
-
|
|
446
|
+
const w = G.numberCorrection(p);
|
|
447
|
+
f.push(
|
|
448
448
|
{
|
|
449
449
|
x: w,
|
|
450
450
|
fx: s(this, K).evaluate(w, !0)
|
|
451
451
|
}
|
|
452
452
|
);
|
|
453
453
|
}
|
|
454
|
-
|
|
454
|
+
f.sort((p, w) => p.x - w.x);
|
|
455
455
|
const d = [];
|
|
456
|
-
return
|
|
457
|
-
w > 0 && (p.fx === 0 ? d.push([p.x, p.x]) :
|
|
458
|
-
|
|
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
459
|
p.x
|
|
460
460
|
]));
|
|
461
461
|
}), d.forEach((p) => {
|
|
462
|
-
const [w,
|
|
463
|
-
if (w ===
|
|
464
|
-
e.push(A(this,
|
|
462
|
+
const [w, L] = p;
|
|
463
|
+
if (w === L)
|
|
464
|
+
e.push(A(this, M, ye).call(this, w));
|
|
465
465
|
else {
|
|
466
|
-
const ce = A(this,
|
|
467
|
-
ce !== null && e.push(A(this,
|
|
466
|
+
const ce = A(this, M, Oi).call(this, t, w, L);
|
|
467
|
+
ce !== null && e.push(A(this, M, Qe).call(this, ce));
|
|
468
468
|
}
|
|
469
469
|
}), e;
|
|
470
|
-
},
|
|
470
|
+
}, Oi = function(e, t, i, n = 1e-10) {
|
|
471
471
|
let r = s(this, K).evaluate(t, !0), l = s(this, K).evaluate(i, !0);
|
|
472
472
|
if (r * l > 0)
|
|
473
473
|
return console.log("Pas de racine dans l'intervalle donné"), null;
|
|
474
474
|
let c;
|
|
475
475
|
for (; (i - t) / 2 > n; ) {
|
|
476
476
|
c = (t + i) / 2;
|
|
477
|
-
const
|
|
478
|
-
if (
|
|
477
|
+
const f = s(this, K).evaluate(c, !0);
|
|
478
|
+
if (f === 0)
|
|
479
479
|
return c;
|
|
480
|
-
r *
|
|
480
|
+
r * f < 0 ? (i = c, l = f) : (t = c, r = f);
|
|
481
481
|
}
|
|
482
482
|
return (t + i) / 2;
|
|
483
|
-
},
|
|
483
|
+
}, Ci = function() {
|
|
484
484
|
let e = s(this, K).clone(), t = [];
|
|
485
485
|
const i = e.lcmDenominator();
|
|
486
486
|
i !== 1 && e.multiply(i);
|
|
487
487
|
const n = e.monomByDegree().coefficient;
|
|
488
488
|
let r = e.monomByDegree(0).coefficient;
|
|
489
489
|
for (; r.isZero(); )
|
|
490
|
-
t.length === 0 && t.push(A(this,
|
|
491
|
-
const l =
|
|
490
|
+
t.length === 0 && t.push(A(this, M, ye).call(this, 0)), e = e.divide("x"), r = e.monomByDegree(0).coefficient;
|
|
491
|
+
const l = G.dividers(n.value), c = G.dividers(r.value);
|
|
492
492
|
for (const d of l)
|
|
493
493
|
for (const p of c) {
|
|
494
|
-
const w = new
|
|
495
|
-
e.evaluate(w).isZero() && !t.find((
|
|
494
|
+
const w = new u(p, d);
|
|
495
|
+
e.evaluate(w).isZero() && !t.find((L) => L.value === w.value) && t.push(A(this, M, ye).call(this, w)), w.opposite(), e.evaluate(w).isZero() && !t.find((L) => L.value === w.value) && t.push(A(this, M, ye).call(this, w));
|
|
496
496
|
}
|
|
497
497
|
for (const d of t) {
|
|
498
498
|
if (d.exact !== !1 && d.exact.isZero())
|
|
@@ -505,89 +505,89 @@ K = new WeakMap(), Fe = new WeakMap(), C = new WeakSet(), Ge = function(e, t) {
|
|
|
505
505
|
return t.sort((d, p) => d.value - p.value);
|
|
506
506
|
if (e.degree().value > 3)
|
|
507
507
|
return [];
|
|
508
|
-
const
|
|
509
|
-
return t = t.concat(
|
|
510
|
-
},
|
|
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),
|
|
508
|
+
const f = new xi(e, e.clone().parse("0"), s(this, Ge));
|
|
509
|
+
return t = t.concat(f.solve()), t.sort((d, p) => d.value - p.value);
|
|
510
|
+
}, ki = 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(), L = d.clone().opposite().pow(3).divide(27), ce = w.clone().pow(2).subtract(L.clone().multiply(4)).opposite();
|
|
512
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),
|
|
514
|
-
return [A(this,
|
|
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), we = ue.clone().add(fe).subtract(l.clone().divide(3));
|
|
514
|
+
return [A(this, M, ye).call(this, we)];
|
|
515
515
|
}
|
|
516
516
|
if (ce.isZero()) {
|
|
517
|
-
const ue = p.clone().opposite().divide(2).root(3), fe = ue.clone().opposite().subtract(l.clone().divide(3)),
|
|
518
|
-
return fe.isEqual(
|
|
519
|
-
A(this,
|
|
520
|
-
A(this,
|
|
521
|
-
].sort((
|
|
517
|
+
const ue = p.clone().opposite().divide(2).root(3), fe = ue.clone().opposite().subtract(l.clone().divide(3)), we = ue.clone().multiply(2).subtract(l.clone().divide(3));
|
|
518
|
+
return fe.isEqual(we) ? [A(this, M, ye).call(this, fe)] : [
|
|
519
|
+
A(this, M, ye).call(this, we),
|
|
520
|
+
A(this, M, ye).call(this, fe)
|
|
521
|
+
].sort((ge, pe) => ge.value - pe.value);
|
|
522
522
|
}
|
|
523
523
|
if (ce.isPositive()) {
|
|
524
|
-
const ue = [], fe = d.value,
|
|
525
|
-
for (let
|
|
526
|
-
ue.push(2 * Math.sqrt(-fe / 3) * Math.cos(Math.acos(3 *
|
|
527
|
-
return ue.map((
|
|
524
|
+
const ue = [], fe = d.value, we = p.value, ge = l.value;
|
|
525
|
+
for (let pe = 0; pe < 3; pe++)
|
|
526
|
+
ue.push(2 * Math.sqrt(-fe / 3) * Math.cos(Math.acos(3 * we / (2 * fe) * Math.sqrt(-3 / fe)) / 3 + 2 * Math.PI * pe / 3) - ge / 3);
|
|
527
|
+
return ue.map((pe) => A(this, M, Qe).call(this, pe)).sort((pe, lt) => pe.value - lt.value);
|
|
528
528
|
}
|
|
529
529
|
return [];
|
|
530
|
-
},
|
|
530
|
+
}, Mi = function() {
|
|
531
531
|
const [e, t] = s(this, K).getCoefficients(), i = t.opposite().divide(e);
|
|
532
532
|
return [
|
|
533
|
-
A(this,
|
|
533
|
+
A(this, M, ye).call(this, i)
|
|
534
534
|
];
|
|
535
|
-
},
|
|
535
|
+
}, $i = function() {
|
|
536
536
|
const e = s(this, K), [t, i, n] = e.getCoefficients(), r = i.clone().pow(2).subtract(t.clone().multiply(n).multiply(4));
|
|
537
537
|
if (r.isNegative())
|
|
538
538
|
return [];
|
|
539
539
|
if (r.isSquare()) {
|
|
540
|
-
const l = r.sqrt(), c = i.clone().opposite().add(l).divide(t.clone().multiply(2)),
|
|
541
|
-
return l.isZero() ? [A(this,
|
|
542
|
-
A(this,
|
|
543
|
-
A(this,
|
|
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, M, ye).call(this, c)] : [
|
|
542
|
+
A(this, M, ye).call(this, c),
|
|
543
|
+
A(this, M, ye).call(this, f)
|
|
544
544
|
].sort((d, p) => d.value - p.value);
|
|
545
545
|
}
|
|
546
|
-
return A(this,
|
|
547
|
-
},
|
|
548
|
-
const n =
|
|
549
|
-
function
|
|
550
|
-
return `\\frac{ ${
|
|
546
|
+
return A(this, M, Bi).call(this, t, i, r);
|
|
547
|
+
}, Bi = function(e, t, i) {
|
|
548
|
+
const n = G.dividers(i.value).filter((ge) => Math.sqrt(ge) % 1 === 0).map((ge) => Math.sqrt(ge)).pop() ?? 1, r = G.gcd(2 * e.value, t.value, n) * (e.isNegative() ? -1 : 1), l = t.clone().divide(r).opposite(), c = e.clone().divide(r).multiply(2), f = i.clone().divide(n ** 2), d = Math.abs(n / r), p = n === 1 ? "-" : `-${d} `, w = n === 1 ? "+" : `+${d} `;
|
|
549
|
+
function L(ge, pe, lt, ni) {
|
|
550
|
+
return `\\frac{ ${pe} ${lt}\\sqrt{ ${ni} } }{ ${ge} }`;
|
|
551
551
|
}
|
|
552
|
-
function ce(
|
|
553
|
-
return `(${
|
|
552
|
+
function ce(ge, pe, lt, ni) {
|
|
553
|
+
return `(${pe}${lt}sqrt(${ni}))/${ge}`;
|
|
554
554
|
}
|
|
555
|
-
const ue = i.value ** 0.5, fe = (-t.value - ue) / (2 * e.value),
|
|
555
|
+
const ue = i.value ** 0.5, fe = (-t.value - ue) / (2 * e.value), we = (-t.value + ue) / (2 * e.value);
|
|
556
556
|
return [
|
|
557
|
-
A(this,
|
|
558
|
-
tex:
|
|
559
|
-
display: ce(c.display, l.display, p.toString(),
|
|
557
|
+
A(this, M, Qe).call(this, fe, {
|
|
558
|
+
tex: L(c.tex, l.tex, p.toString(), f.tex),
|
|
559
|
+
display: ce(c.display, l.display, p.toString(), f.display)
|
|
560
560
|
}),
|
|
561
|
-
A(this,
|
|
562
|
-
tex:
|
|
563
|
-
display: ce(c.display, l.display, w.toString(),
|
|
561
|
+
A(this, M, Qe).call(this, we, {
|
|
562
|
+
tex: L(c.tex, l.tex, w.toString(), f.tex),
|
|
563
|
+
display: ce(c.display, l.display, w.toString(), f.display)
|
|
564
564
|
})
|
|
565
|
-
].sort((
|
|
565
|
+
].sort((ge, pe) => ge.value - pe.value);
|
|
566
566
|
};
|
|
567
|
-
let
|
|
568
|
-
var
|
|
567
|
+
let Mt = xi;
|
|
568
|
+
var ss = Object.defineProperty, Pi = (o) => {
|
|
569
569
|
throw TypeError(o);
|
|
570
|
-
},
|
|
571
|
-
const
|
|
570
|
+
}, ns = (o, e, t) => e in o ? ss(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, oi = (o, e, t) => ns(o, typeof e != "symbol" ? e + "" : e, t), Si = (o, e, t) => e.has(o) || Pi("Cannot " + t), te = (o, e, t) => (Si(o, e, "read from private field"), t ? t.call(o) : e.get(o)), ct = (o, e, t) => e.has(o) ? Pi("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), Ne = (o, e, t, i) => (Si(o, e, "write to private field"), e.set(o, t), t);
|
|
571
|
+
const vi = {
|
|
572
572
|
pi: Math.PI,
|
|
573
573
|
e: Math.exp(1)
|
|
574
574
|
};
|
|
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 || {}),
|
|
576
|
-
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 || {}), Ue = /* @__PURE__ */ ((o) => (o.EXPRESSION = "expression", o.POLYNOM = "polynom", o.SET = "set", o.NUMERIC = "numeric", o))(Ue || {});
|
|
576
|
+
function rs(o, e) {
|
|
577
577
|
if (o.length <= 1)
|
|
578
578
|
return o;
|
|
579
579
|
const t = Object.keys(e).filter((w) => e[w].type === g.FUNCTION).map((w) => w);
|
|
580
|
-
t.sort((w,
|
|
581
|
-
const i = new RegExp(`^(${t.join("|")})\\(`), n = Object.keys(
|
|
582
|
-
n.sort((w,
|
|
580
|
+
t.sort((w, L) => L.length - w.length);
|
|
581
|
+
const i = new RegExp(`^(${t.join("|")})\\(`), n = Object.keys(vi);
|
|
582
|
+
n.sort((w, L) => L.length - w.length);
|
|
583
583
|
const r = new RegExp(`^(${n.join("|")})`), l = /^(\d+(\.\d+)?)/;
|
|
584
|
-
let c = "",
|
|
584
|
+
let c = "", f, d, p;
|
|
585
585
|
for (; o.length > 0; ) {
|
|
586
|
-
if (
|
|
587
|
-
const w = t.find((
|
|
586
|
+
if (f = d, p = void 0, t.length > 0 && i.exec(o)) {
|
|
587
|
+
const w = t.find((L) => o.startsWith(L));
|
|
588
588
|
w && (p = w + "(", o = o.slice(w.length + 1), d = g.FUNCTION);
|
|
589
589
|
} else if (n.length > 0 && r.exec(o)) {
|
|
590
|
-
const w = n.find((
|
|
590
|
+
const w = n.find((L) => o.startsWith(L));
|
|
591
591
|
w && (p = w, o = o.slice(w.length), d = g.CONSTANT);
|
|
592
592
|
} else if (l.exec(o)) {
|
|
593
593
|
const w = l.exec(o);
|
|
@@ -615,20 +615,20 @@ function Qi(o, e) {
|
|
|
615
615
|
}
|
|
616
616
|
if (p === void 0 || d === void 0)
|
|
617
617
|
throw new Error("The token is undefined");
|
|
618
|
-
c +=
|
|
618
|
+
c += os(f, d), c += p;
|
|
619
619
|
}
|
|
620
620
|
return c;
|
|
621
621
|
}
|
|
622
|
-
function
|
|
622
|
+
function os(o, e) {
|
|
623
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 ? "" : "*";
|
|
624
624
|
}
|
|
625
|
-
const
|
|
625
|
+
const hs = {
|
|
626
626
|
"^": { precedence: 4, associative: "right", type: g.OPERATION },
|
|
627
627
|
"*": { precedence: 3, associative: "left", type: g.OPERATION },
|
|
628
628
|
"/": { precedence: 3, associative: "left", type: g.OPERATION },
|
|
629
629
|
"+": { precedence: 2, associative: "left", type: g.OPERATION },
|
|
630
630
|
"-": { precedence: 2, associative: "left", type: g.OPERATION }
|
|
631
|
-
},
|
|
631
|
+
}, as = {
|
|
632
632
|
"^": { precedence: 4, associative: "right", type: g.OPERATION },
|
|
633
633
|
"*": { precedence: 3, associative: "left", type: g.OPERATION },
|
|
634
634
|
"/": { precedence: 3, associative: "left", type: g.OPERATION },
|
|
@@ -641,7 +641,7 @@ const Ji = {
|
|
|
641
641
|
sqrt: { precedence: 4, associative: "right", type: g.FUNCTION },
|
|
642
642
|
nthrt: { precedence: 4, associative: "right", type: g.FUNCTION },
|
|
643
643
|
",": { precedence: 2, associative: "left", type: g.FUNCTION_ARGUMENT }
|
|
644
|
-
},
|
|
644
|
+
}, ls = {
|
|
645
645
|
"^": { precedence: 4, associative: "right", type: g.OPERATION },
|
|
646
646
|
"*": { precedence: 3, associative: "left", type: g.OPERATION },
|
|
647
647
|
"/": { precedence: 3, associative: "left", type: g.OPERATION },
|
|
@@ -655,26 +655,26 @@ const Ji = {
|
|
|
655
655
|
nthrt: { precedence: 4, associative: "right", type: g.FUNCTION },
|
|
656
656
|
ln: { precedence: 4, associative: "right", type: g.FUNCTION },
|
|
657
657
|
log: { precedence: 4, associative: "right", type: g.FUNCTION }
|
|
658
|
-
},
|
|
658
|
+
}, cs = {
|
|
659
659
|
"&": { precedence: 3, associative: "left", type: g.OPERATION },
|
|
660
660
|
"|": { precedence: 3, associative: "left", type: g.OPERATION },
|
|
661
661
|
"!": { precedence: 4, associative: "right", type: g.OPERATION },
|
|
662
662
|
"-": { precedence: 2, associative: "left", type: g.OPERATION }
|
|
663
663
|
};
|
|
664
|
-
var He,
|
|
665
|
-
class
|
|
664
|
+
var He, ft, ne, Tt, Fe;
|
|
665
|
+
class si {
|
|
666
666
|
constructor(e) {
|
|
667
|
-
|
|
667
|
+
ct(this, He), ct(this, ft, []), ct(this, ne, {}), ct(this, Tt, []), ct(this, Fe), Ne(this, He, typeof e > "u" ? Ue.POLYNOM : e), this.tokenConfigInitialization();
|
|
668
668
|
}
|
|
669
669
|
// Getter
|
|
670
670
|
get rpn() {
|
|
671
|
-
return te(this,
|
|
671
|
+
return te(this, ft);
|
|
672
672
|
}
|
|
673
673
|
get rpnToken() {
|
|
674
|
-
return te(this,
|
|
674
|
+
return te(this, ft).map((e) => e.token);
|
|
675
675
|
}
|
|
676
676
|
tokenConfigInitialization() {
|
|
677
|
-
return te(this, He) ===
|
|
677
|
+
return te(this, He) === Ue.SET ? (Ne(this, ne, cs), Ne(this, Fe, !1)) : te(this, He) === Ue.NUMERIC ? (Ne(this, ne, ls), Ne(this, Fe, !0)) : te(this, He) === Ue.EXPRESSION ? (Ne(this, ne, as), Ne(this, Fe, !0)) : (Ne(this, ne, hs), Ne(this, Fe, !0)), Ne(this, Tt, Object.keys(te(this, ne)).sort((e, t) => t.length - e.length)), te(this, ne);
|
|
678
678
|
}
|
|
679
679
|
/**
|
|
680
680
|
* Get the next token to analyse.
|
|
@@ -690,12 +690,12 @@ class Kt {
|
|
|
690
690
|
else if (e[t] === ",")
|
|
691
691
|
i = ",", n = g.FUNCTION_ARGUMENT;
|
|
692
692
|
else {
|
|
693
|
-
for (const r of te(this,
|
|
693
|
+
for (const r of te(this, Tt))
|
|
694
694
|
if (e.substring(t, t + r.length) === r) {
|
|
695
695
|
i += r, n = te(this, ne)[r].type;
|
|
696
696
|
break;
|
|
697
697
|
}
|
|
698
|
-
for (const r in
|
|
698
|
+
for (const r in vi)
|
|
699
699
|
if (e.substring(t, t + r.length) === r) {
|
|
700
700
|
i += r, n = g.CONSTANT;
|
|
701
701
|
break;
|
|
@@ -723,8 +723,8 @@ class Kt {
|
|
|
723
723
|
parse(e, t) {
|
|
724
724
|
const i = [], n = [];
|
|
725
725
|
let r = "", l = 0, c;
|
|
726
|
-
(t ?? te(this,
|
|
727
|
-
const
|
|
726
|
+
(t ?? te(this, Fe)) && (e = rs(e, te(this, ne)));
|
|
727
|
+
const f = 50;
|
|
728
728
|
let d = 50, p;
|
|
729
729
|
for (; l < e.length; ) {
|
|
730
730
|
if (d--, d === 0) {
|
|
@@ -744,7 +744,7 @@ class Kt {
|
|
|
744
744
|
case g.OPERATION:
|
|
745
745
|
if (n.length > 0) {
|
|
746
746
|
let w = n[n.length - 1];
|
|
747
|
-
for (p = +
|
|
747
|
+
for (p = +f; w.token in te(this, ne) && //either o1 is left-associative and its precedence is less than or equal to that of o2,
|
|
748
748
|
(te(this, ne)[r].associative === "left" && te(this, ne)[r].precedence <= te(this, ne)[w.token].precedence || //or o1 is right associative, and has precedence less than that of o2,
|
|
749
749
|
te(this, ne)[r].associative === "right" && te(this, ne)[r].precedence < te(this, ne)[w.token].precedence); ) {
|
|
750
750
|
if (p--, p === 0) {
|
|
@@ -759,7 +759,7 @@ class Kt {
|
|
|
759
759
|
n.push({ token: r, tokenType: c });
|
|
760
760
|
break;
|
|
761
761
|
case g.FUNCTION_ARGUMENT:
|
|
762
|
-
for (p = +
|
|
762
|
+
for (p = +f; n[n.length - 1].token !== "(" && n.length > 0; ) {
|
|
763
763
|
if (p--, p === 0) {
|
|
764
764
|
console.log("SECURITY LEVEL 2 FUNCTION ARGUMENT EXIT");
|
|
765
765
|
break;
|
|
@@ -771,7 +771,7 @@ class Kt {
|
|
|
771
771
|
n.push({ token: r, tokenType: c }), e[l] === "-" && i.push({ token: "0", tokenType: g.COEFFICIENT });
|
|
772
772
|
break;
|
|
773
773
|
case g.RIGHT_PARENTHESIS:
|
|
774
|
-
for (p = +
|
|
774
|
+
for (p = +f; n[n.length - 1].token !== "(" && n.length > 1; ) {
|
|
775
775
|
if (p--, p === 0) {
|
|
776
776
|
console.log("SECURITY LEVEL 2 CLOSING PARENTHESIS EXIT");
|
|
777
777
|
break;
|
|
@@ -787,15 +787,15 @@ class Kt {
|
|
|
787
787
|
throw new Error(`Token type ${r} is not handled`);
|
|
788
788
|
}
|
|
789
789
|
}
|
|
790
|
-
return
|
|
790
|
+
return Ne(this, ft, i.concat(n.reverse())), this;
|
|
791
791
|
}
|
|
792
792
|
}
|
|
793
|
-
He = /* @__PURE__ */ new WeakMap(),
|
|
794
|
-
class
|
|
793
|
+
He = /* @__PURE__ */ new WeakMap(), ft = /* @__PURE__ */ new WeakMap(), ne = /* @__PURE__ */ new WeakMap(), Tt = /* @__PURE__ */ new WeakMap(), Fe = /* @__PURE__ */ new WeakMap();
|
|
794
|
+
class us {
|
|
795
795
|
constructor(e, t) {
|
|
796
|
-
|
|
796
|
+
oi(this, "_rpn"), oi(this, "_expression"), oi(this, "_isValid"), this._expression = e;
|
|
797
797
|
try {
|
|
798
|
-
this._rpn = new
|
|
798
|
+
this._rpn = new si(Ue.NUMERIC).parse(e, t).rpn;
|
|
799
799
|
} catch {
|
|
800
800
|
throw this._rpn = null, this._isValid = !1, new Error(`There was a problem parsing: ${e}`);
|
|
801
801
|
}
|
|
@@ -836,7 +836,7 @@ class is {
|
|
|
836
836
|
else if (i.tokenType === g.VARIABLE && e !== void 0)
|
|
837
837
|
Object.hasOwn(e, i.token) && t.push(+e[i.token]);
|
|
838
838
|
else if (i.tokenType === g.CONSTANT)
|
|
839
|
-
t.push(
|
|
839
|
+
t.push(vi[i.token]);
|
|
840
840
|
else if (i.tokenType === g.OPERATION) {
|
|
841
841
|
if (i.token === "*") {
|
|
842
842
|
const n = t.pop(), r = t.pop();
|
|
@@ -891,17 +891,17 @@ class is {
|
|
|
891
891
|
return +e.toFixed(t);
|
|
892
892
|
}
|
|
893
893
|
}
|
|
894
|
-
var T, b,
|
|
895
|
-
const
|
|
894
|
+
var T, b, _e, Ot, Ze, St, It;
|
|
895
|
+
const P = class P {
|
|
896
896
|
constructor(e) {
|
|
897
|
-
m(this,
|
|
897
|
+
m(this, _e);
|
|
898
898
|
m(this, T);
|
|
899
899
|
m(this, b);
|
|
900
900
|
/**
|
|
901
901
|
* Clone the current Monom.
|
|
902
902
|
*/
|
|
903
903
|
a(this, "clone", () => {
|
|
904
|
-
const e = new
|
|
904
|
+
const e = new P();
|
|
905
905
|
e.coefficient = s(this, T).clone();
|
|
906
906
|
for (const t in s(this, b))
|
|
907
907
|
e.setLetter(t, s(this, b)[t].clone());
|
|
@@ -913,8 +913,8 @@ const I = class I {
|
|
|
913
913
|
*/
|
|
914
914
|
a(this, "add", (...e) => {
|
|
915
915
|
for (const t of e) {
|
|
916
|
-
const i = t instanceof
|
|
917
|
-
this.isSameAs(i) ? (this.isZero() && A(this,
|
|
916
|
+
const i = t instanceof P ? t : new P(t);
|
|
917
|
+
this.isSameAs(i) ? (this.isZero() && A(this, _e, Ot).call(this, i), s(this, T).add(i.coefficient)) : console.log("Add monom: " + this.display + " is not similar with ", i.display);
|
|
918
918
|
}
|
|
919
919
|
return this;
|
|
920
920
|
});
|
|
@@ -923,7 +923,7 @@ const I = class I {
|
|
|
923
923
|
* Get the degree of a monom. If no setLetter is given, the result will be the global degree.
|
|
924
924
|
* @param letter (string) Letter to get to degree (power)
|
|
925
925
|
*/
|
|
926
|
-
a(this, "degree", (e) => this.variables.length === 0 ? new
|
|
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());
|
|
927
927
|
/**
|
|
928
928
|
* Derivative the monom
|
|
929
929
|
* @param letter
|
|
@@ -931,9 +931,9 @@ const I = class I {
|
|
|
931
931
|
a(this, "derivative", (e) => {
|
|
932
932
|
if (e === void 0 && (e = "x"), this.hasVariable(e)) {
|
|
933
933
|
const t = s(this, b)[e].clone(), i = this.clone();
|
|
934
|
-
return s(i, b)[e].subtract(1), s(i, T).multiply(new
|
|
934
|
+
return s(i, b)[e].subtract(1), s(i, T).multiply(new u(t.clone())), i;
|
|
935
935
|
} else
|
|
936
|
-
return new
|
|
936
|
+
return new P().zero();
|
|
937
937
|
});
|
|
938
938
|
/**
|
|
939
939
|
* Divide the current monoms by multiple monoms
|
|
@@ -941,7 +941,7 @@ const I = class I {
|
|
|
941
941
|
*/
|
|
942
942
|
a(this, "divide", (...e) => {
|
|
943
943
|
for (const t of e) {
|
|
944
|
-
const i = t instanceof
|
|
944
|
+
const i = t instanceof P ? t : new P(t);
|
|
945
945
|
s(this, T).divide(i.coefficient);
|
|
946
946
|
for (const n in i.literal)
|
|
947
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);
|
|
@@ -955,31 +955,31 @@ const I = class I {
|
|
|
955
955
|
*/
|
|
956
956
|
a(this, "evaluate", (e, t) => {
|
|
957
957
|
if (t === !0) {
|
|
958
|
-
if (e instanceof
|
|
959
|
-
return s(this,
|
|
960
|
-
if (e instanceof
|
|
961
|
-
return new
|
|
958
|
+
if (e instanceof u)
|
|
959
|
+
return s(this, Ze).call(this, e.value);
|
|
960
|
+
if (e instanceof At)
|
|
961
|
+
return new u().invalid();
|
|
962
962
|
if (typeof e == "number")
|
|
963
|
-
return s(this,
|
|
963
|
+
return s(this, Ze).call(this, e);
|
|
964
964
|
if (typeof e == "object") {
|
|
965
965
|
const n = {};
|
|
966
966
|
for (const r in e)
|
|
967
|
-
n[r] = new
|
|
968
|
-
return s(this,
|
|
967
|
+
n[r] = new u(e[r]).value;
|
|
968
|
+
return s(this, Ze).call(this, n);
|
|
969
969
|
}
|
|
970
970
|
}
|
|
971
971
|
const i = this.coefficient.clone();
|
|
972
|
-
if (typeof e == "number" || e instanceof
|
|
972
|
+
if (typeof e == "number" || e instanceof u) {
|
|
973
973
|
const n = {};
|
|
974
|
-
return n[this.variables[0]] = new
|
|
974
|
+
return n[this.variables[0]] = new u(e), this.evaluate(n);
|
|
975
975
|
}
|
|
976
|
-
if (e instanceof
|
|
977
|
-
return new
|
|
976
|
+
if (e instanceof At)
|
|
977
|
+
return new u().invalid();
|
|
978
978
|
if (typeof e == "object") {
|
|
979
979
|
if (this.variables.length === 0)
|
|
980
980
|
return this.coefficient;
|
|
981
981
|
for (const n in s(this, b)) {
|
|
982
|
-
const r = new
|
|
982
|
+
const r = new u(e[n]);
|
|
983
983
|
i.multiply(r.pow(s(this, b)[n]));
|
|
984
984
|
}
|
|
985
985
|
}
|
|
@@ -1048,7 +1048,7 @@ const I = class I {
|
|
|
1048
1048
|
*/
|
|
1049
1049
|
a(this, "multiply", (...e) => {
|
|
1050
1050
|
for (const t of e) {
|
|
1051
|
-
const i = t instanceof
|
|
1051
|
+
const i = t instanceof P ? t : new P(t);
|
|
1052
1052
|
s(this, T).multiply(i.coefficient);
|
|
1053
1053
|
for (const n in i.literal)
|
|
1054
1054
|
this.hasVariable(n) ? s(this, b)[n].add(i.literal[n]) : s(this, b)[n] = i.literal[n].clone();
|
|
@@ -1058,7 +1058,7 @@ const I = class I {
|
|
|
1058
1058
|
/**
|
|
1059
1059
|
* Create a one value monom
|
|
1060
1060
|
*/
|
|
1061
|
-
a(this, "one", () => (h(this, T, new
|
|
1061
|
+
a(this, "one", () => (h(this, T, new u().one()), h(this, b, {}), this));
|
|
1062
1062
|
/**
|
|
1063
1063
|
* Get the opposite
|
|
1064
1064
|
* Returns a monom.
|
|
@@ -1078,7 +1078,7 @@ const I = class I {
|
|
|
1078
1078
|
e === void 0 && (e = "x");
|
|
1079
1079
|
const t = this.clone();
|
|
1080
1080
|
let i;
|
|
1081
|
-
return t.hasVariable(e) ? (i = t.degree(e).clone().add(1), t.coefficient = t.coefficient.clone().divide(i), t.setLetter(e, i)) : (t.coefficient.isZero() && (t.coefficient = new
|
|
1081
|
+
return t.hasVariable(e) ? (i = t.degree(e).clone().add(1), t.coefficient = t.coefficient.clone().divide(i), t.setLetter(e, i)) : (t.coefficient.isZero() && (t.coefficient = new u().one()), t.setLetter(e, 1)), t;
|
|
1082
1082
|
});
|
|
1083
1083
|
a(this, "reduce", () => {
|
|
1084
1084
|
this.coefficient.reduce();
|
|
@@ -1097,7 +1097,7 @@ const I = class I {
|
|
|
1097
1097
|
* @param letter (string) Letter to change
|
|
1098
1098
|
* @param pow (number) Power of the setLetter (must be positive integer.
|
|
1099
1099
|
*/
|
|
1100
|
-
a(this, "setLetter", (e, t) => t instanceof
|
|
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)));
|
|
1101
1101
|
/**
|
|
1102
1102
|
* Return the square root of a monom
|
|
1103
1103
|
*/
|
|
@@ -1115,75 +1115,75 @@ const I = class I {
|
|
|
1115
1115
|
*/
|
|
1116
1116
|
a(this, "subtract", (...e) => {
|
|
1117
1117
|
for (const t of e) {
|
|
1118
|
-
const i = t instanceof
|
|
1119
|
-
this.isSameAs(i) ? (this.isZero() && A(this,
|
|
1118
|
+
const i = t instanceof P ? t : new P(t);
|
|
1119
|
+
this.isSameAs(i) ? (this.isZero() && A(this, _e, Ot).call(this, i), s(this, T).add(i.clone().coefficient.opposite())) : console.log("Subtract: Is not similar: ", i.display);
|
|
1120
1120
|
}
|
|
1121
1121
|
return this;
|
|
1122
1122
|
});
|
|
1123
1123
|
/**
|
|
1124
1124
|
* Create a zero value monom
|
|
1125
1125
|
*/
|
|
1126
|
-
a(this, "zero", () => (h(this, T, new
|
|
1127
|
-
m(this,
|
|
1126
|
+
a(this, "zero", () => (h(this, T, new u().zero()), h(this, b, {}), this));
|
|
1127
|
+
m(this, Ze, (e) => {
|
|
1128
1128
|
let t = this.coefficient.value;
|
|
1129
1129
|
if (typeof e == "number") {
|
|
1130
1130
|
const i = {}, n = this.variables[0];
|
|
1131
|
-
return i[n] = e, s(this,
|
|
1131
|
+
return i[n] = e, s(this, Ze).call(this, i);
|
|
1132
1132
|
}
|
|
1133
|
-
if (e instanceof
|
|
1133
|
+
if (e instanceof u) {
|
|
1134
1134
|
const i = {};
|
|
1135
|
-
return i[this.variables[0]] = new
|
|
1135
|
+
return i[this.variables[0]] = new u(e).value, s(this, Ze).call(this, i);
|
|
1136
1136
|
}
|
|
1137
|
-
if (e instanceof
|
|
1137
|
+
if (e instanceof At)
|
|
1138
1138
|
return NaN;
|
|
1139
1139
|
if (typeof e == "object") {
|
|
1140
1140
|
if (this.variables.length === 0)
|
|
1141
1141
|
return this.coefficient.value;
|
|
1142
1142
|
for (const i in s(this, b)) {
|
|
1143
1143
|
const n = e[i];
|
|
1144
|
-
n instanceof
|
|
1144
|
+
n instanceof u ? t *= n.value ** s(this, b)[i].value : t *= n ** s(this, b)[i].value;
|
|
1145
1145
|
}
|
|
1146
1146
|
}
|
|
1147
1147
|
return t;
|
|
1148
1148
|
});
|
|
1149
|
-
m(this,
|
|
1150
|
-
const i = new
|
|
1149
|
+
m(this, St, (e) => {
|
|
1150
|
+
const i = new si().parse(e).rpn, n = [];
|
|
1151
1151
|
if (i.length === 0)
|
|
1152
1152
|
return this.zero(), this;
|
|
1153
1153
|
if (i.length === 1) {
|
|
1154
1154
|
const r = i[0];
|
|
1155
|
-
return this.one(), r.tokenType === g.COEFFICIENT ? this.coefficient = new
|
|
1155
|
+
return this.one(), r.tokenType === g.COEFFICIENT ? this.coefficient = new u(r.token) : r.tokenType === g.VARIABLE && this.setLetter(r.token, 1), this;
|
|
1156
1156
|
} else
|
|
1157
1157
|
for (const r of i)
|
|
1158
|
-
s(this,
|
|
1158
|
+
s(this, It).call(this, n, r);
|
|
1159
1159
|
return this.one(), this.multiply(n[0]), this;
|
|
1160
1160
|
});
|
|
1161
|
-
m(this,
|
|
1162
|
-
var
|
|
1161
|
+
m(this, It, (e, t) => {
|
|
1162
|
+
var f;
|
|
1163
1163
|
let i, n, r, l, c;
|
|
1164
1164
|
if (t.tokenType === g.COEFFICIENT)
|
|
1165
|
-
e.push(new
|
|
1165
|
+
e.push(new P(new u(t.token)));
|
|
1166
1166
|
else if (t.tokenType === g.VARIABLE) {
|
|
1167
|
-
const d = new
|
|
1167
|
+
const d = new P().one();
|
|
1168
1168
|
d.setLetter(t.token, 1), e.push(d.clone());
|
|
1169
1169
|
} else if (t.tokenType === g.OPERATION)
|
|
1170
1170
|
switch (t.token) {
|
|
1171
1171
|
case "-":
|
|
1172
|
-
n = e.pop() ?? new
|
|
1172
|
+
n = e.pop() ?? new P().zero(), i = e.pop() ?? new P().zero(), e.push(i.subtract(n));
|
|
1173
1173
|
break;
|
|
1174
1174
|
case "*":
|
|
1175
|
-
n = e.pop() ?? new
|
|
1175
|
+
n = e.pop() ?? new P().one(), i = e.pop() ?? new P().one(), e.push(i.multiply(n));
|
|
1176
1176
|
break;
|
|
1177
1177
|
case "/":
|
|
1178
|
-
n = e.pop() ?? new
|
|
1178
|
+
n = e.pop() ?? new P().one(), i = e.pop() ?? new P().one(), e.push(i.divide(n));
|
|
1179
1179
|
break;
|
|
1180
1180
|
case "^": {
|
|
1181
|
-
c = ((
|
|
1181
|
+
c = ((f = e.pop()) == null ? void 0 : f.coefficient) ?? new u().one(), r = e.pop() ?? new P().one(), l = r.variables[0], l && r.setLetter(l, c), e.push(r);
|
|
1182
1182
|
break;
|
|
1183
1183
|
}
|
|
1184
1184
|
}
|
|
1185
1185
|
});
|
|
1186
|
-
return h(this, T, new
|
|
1186
|
+
return h(this, T, new u().zero()), h(this, b, {}), e !== void 0 && this.parse(e), this;
|
|
1187
1187
|
}
|
|
1188
1188
|
// -----------------------------------------
|
|
1189
1189
|
/**
|
|
@@ -1191,7 +1191,7 @@ const I = class I {
|
|
|
1191
1191
|
* @param inputStr
|
|
1192
1192
|
*/
|
|
1193
1193
|
parse(e) {
|
|
1194
|
-
return h(this, T, new
|
|
1194
|
+
return h(this, T, new u()), h(this, b, {}), typeof e == "string" ? s(this, St).call(this, e) : typeof e == "number" ? h(this, T, new u(e)) : e instanceof u ? h(this, T, e.clone()) : e instanceof P && (h(this, T, s(e, T).clone()), A(this, _e, Ot).call(this, e)), this;
|
|
1195
1195
|
}
|
|
1196
1196
|
/**
|
|
1197
1197
|
* Get the coefficient \\(k\\) of the Monom \\(k\\cdot x^{n}\\)
|
|
@@ -1205,7 +1205,7 @@ const I = class I {
|
|
|
1205
1205
|
* @param {Fraction | number | string} F
|
|
1206
1206
|
*/
|
|
1207
1207
|
set coefficient(e) {
|
|
1208
|
-
h(this, T, new
|
|
1208
|
+
h(this, T, new u(e));
|
|
1209
1209
|
}
|
|
1210
1210
|
// Display getter
|
|
1211
1211
|
/**
|
|
@@ -1225,7 +1225,7 @@ const I = class I {
|
|
|
1225
1225
|
return [this.clone()];
|
|
1226
1226
|
if (this.coefficient.numerator > 1e6)
|
|
1227
1227
|
return [this.clone()];
|
|
1228
|
-
const e =
|
|
1228
|
+
const e = G.dividers(Math.abs(this.coefficient.numerator));
|
|
1229
1229
|
let t = [];
|
|
1230
1230
|
for (const n in this.literal)
|
|
1231
1231
|
t = this._getLiteralDividers(t, n);
|
|
@@ -1233,20 +1233,20 @@ const I = class I {
|
|
|
1233
1233
|
if (t.length > 0 && e.length > 0)
|
|
1234
1234
|
for (const n of e)
|
|
1235
1235
|
for (const r of t) {
|
|
1236
|
-
const l = new
|
|
1237
|
-
l.coefficient = new
|
|
1236
|
+
const l = new P();
|
|
1237
|
+
l.coefficient = new u(n), l.literal = r, i.push(l);
|
|
1238
1238
|
}
|
|
1239
1239
|
else if (e.length === 0)
|
|
1240
1240
|
for (const n of t) {
|
|
1241
|
-
const r = new
|
|
1242
|
-
r.coefficient = new
|
|
1241
|
+
const r = new P();
|
|
1242
|
+
r.coefficient = new u().one(), r.literal = n, i.push(r);
|
|
1243
1243
|
}
|
|
1244
1244
|
else
|
|
1245
1245
|
for (const n of e) {
|
|
1246
|
-
const r = new
|
|
1247
|
-
r.coefficient = new
|
|
1246
|
+
const r = new P();
|
|
1247
|
+
r.coefficient = new u(n), i.push(r);
|
|
1248
1248
|
}
|
|
1249
|
-
return i.length === 0 ? [new
|
|
1249
|
+
return i.length === 0 ? [new P().one()] : i;
|
|
1250
1250
|
}
|
|
1251
1251
|
integrate(e, t, i) {
|
|
1252
1252
|
const n = this.primitive(i);
|
|
@@ -1285,9 +1285,9 @@ const I = class I {
|
|
|
1285
1285
|
*/
|
|
1286
1286
|
set literalStr(e) {
|
|
1287
1287
|
for (const t of [...e.matchAll(/([a-z])\^([+-]?[0-9]+)/g)])
|
|
1288
|
-
t[1] in s(this, b) || (s(this, b)[t[1]] = new
|
|
1288
|
+
t[1] in s(this, b) || (s(this, b)[t[1]] = new u().zero()), s(this, b)[t[1]].add(+t[2]);
|
|
1289
1289
|
for (const t of [...e.matchAll(/([a-z](?!\^))/g)])
|
|
1290
|
-
t[1] in s(this, b) || (s(this, b)[t[1]] = new
|
|
1290
|
+
t[1] in s(this, b) || (s(this, b)[t[1]] = new u().zero()), s(this, b)[t[1]].add(1);
|
|
1291
1291
|
}
|
|
1292
1292
|
get plotFunction() {
|
|
1293
1293
|
let e = "";
|
|
@@ -1326,73 +1326,73 @@ const I = class I {
|
|
|
1326
1326
|
for (let n = 0; n <= this.literal[t].value; n++)
|
|
1327
1327
|
if (e.length === 0) {
|
|
1328
1328
|
const r = {};
|
|
1329
|
-
r[t] = new
|
|
1329
|
+
r[t] = new u(n), i.push(r);
|
|
1330
1330
|
} else
|
|
1331
1331
|
for (const r of e) {
|
|
1332
1332
|
const l = {};
|
|
1333
1333
|
for (const c in r)
|
|
1334
1334
|
l[c] = r[c];
|
|
1335
|
-
l[t] = new
|
|
1335
|
+
l[t] = new u(n), i.push(l);
|
|
1336
1336
|
}
|
|
1337
1337
|
return i;
|
|
1338
1338
|
}
|
|
1339
1339
|
};
|
|
1340
|
-
T = new WeakMap(), b = new WeakMap(),
|
|
1340
|
+
T = new WeakMap(), b = new WeakMap(), _e = new WeakSet(), Ot = function(e) {
|
|
1341
1341
|
for (const t in e.literal)
|
|
1342
1342
|
s(this, b)[t] = e.literal[t].clone();
|
|
1343
|
-
},
|
|
1343
|
+
}, Ze = new WeakMap(), St = new WeakMap(), It = new WeakMap(), a(P, "gcd", (...e) => {
|
|
1344
1344
|
for (const r of e)
|
|
1345
1345
|
if (r.containsRationalPower())
|
|
1346
|
-
return new
|
|
1347
|
-
const t = new
|
|
1348
|
-
t.coefficient = new
|
|
1346
|
+
return new P().zero();
|
|
1347
|
+
const t = new P(), i = G.gcd(...e.map((r) => r.coefficient.numerator)), n = G.lcm(...e.map((r) => r.coefficient.denominator));
|
|
1348
|
+
t.coefficient = new u(i, n).reduce();
|
|
1349
1349
|
for (const r of e) {
|
|
1350
1350
|
for (const l in t.literal)
|
|
1351
1351
|
l in r.literal || t.literal[l].zero();
|
|
1352
1352
|
for (const l in r.literal)
|
|
1353
|
-
!t.hasVariable(l) && r.literal[l].isStrictlyPositive() ? t.literal[l] = r.literal[l].clone() : t.literal[l] = new
|
|
1353
|
+
!t.hasVariable(l) && r.literal[l].isStrictlyPositive() ? t.literal[l] = r.literal[l].clone() : t.literal[l] = new u(Math.min(r.literal[l].value, t.literal[l].value));
|
|
1354
1354
|
}
|
|
1355
1355
|
return t;
|
|
1356
1356
|
}), /**
|
|
1357
1357
|
* Multiply two monoms and return a NEW monom.
|
|
1358
1358
|
* @param monoms
|
|
1359
1359
|
*/
|
|
1360
|
-
a(
|
|
1361
|
-
const t = new
|
|
1360
|
+
a(P, "xMultiply", (...e) => {
|
|
1361
|
+
const t = new P().one();
|
|
1362
1362
|
for (const i of e)
|
|
1363
1363
|
t.multiply(i);
|
|
1364
1364
|
return t;
|
|
1365
1365
|
});
|
|
1366
|
-
let
|
|
1367
|
-
function
|
|
1366
|
+
let k = P;
|
|
1367
|
+
function qi(o, e = !0) {
|
|
1368
1368
|
return e ? `\\left( ${o} \\right)` : `(${o})`;
|
|
1369
1369
|
}
|
|
1370
|
-
function
|
|
1370
|
+
function Ct(o, e, t, i, n) {
|
|
1371
1371
|
return o.map((r, l) => r === e ? t : r);
|
|
1372
1372
|
}
|
|
1373
|
-
var
|
|
1374
|
-
const
|
|
1373
|
+
var We, y, et, gt, tt, yt, zt, Rt, Dt, it, Lt, wt, Zt, Vt, Ft, jt, Ii, Ut, Gt;
|
|
1374
|
+
const $ = class $ {
|
|
1375
1375
|
constructor(e, ...t) {
|
|
1376
|
-
m(this,
|
|
1377
|
-
m(this,
|
|
1376
|
+
m(this, jt);
|
|
1377
|
+
m(this, We);
|
|
1378
1378
|
m(this, y);
|
|
1379
|
-
m(this,
|
|
1380
|
-
m(this,
|
|
1379
|
+
m(this, et);
|
|
1380
|
+
m(this, gt, !1);
|
|
1381
1381
|
/**
|
|
1382
1382
|
* Parse a string to a polynom.
|
|
1383
1383
|
* @param inputStr
|
|
1384
1384
|
* @param values
|
|
1385
1385
|
*/
|
|
1386
1386
|
a(this, "parse", (e, ...t) => {
|
|
1387
|
-
if (h(this, y, []), h(this,
|
|
1388
|
-
return A(this,
|
|
1389
|
-
if ((typeof e == "number" || e instanceof
|
|
1390
|
-
s(this, y).push(new
|
|
1391
|
-
else if (e instanceof
|
|
1392
|
-
s(this, y).push(new
|
|
1393
|
-
s(this, y).push(new
|
|
1387
|
+
if (h(this, y, []), h(this, We, []), typeof e == "string")
|
|
1388
|
+
return A(this, jt, Ii).call(this, e, ...t);
|
|
1389
|
+
if ((typeof e == "number" || e instanceof u || e instanceof k) && t.length === 0)
|
|
1390
|
+
s(this, y).push(new k(e));
|
|
1391
|
+
else if (e instanceof k && t.length > 0)
|
|
1392
|
+
s(this, y).push(new k(e)), t.forEach((i) => {
|
|
1393
|
+
s(this, y).push(new k(i));
|
|
1394
1394
|
});
|
|
1395
|
-
else if (e instanceof
|
|
1395
|
+
else if (e instanceof $)
|
|
1396
1396
|
for (const i of e.monoms)
|
|
1397
1397
|
s(this, y).push(i.clone());
|
|
1398
1398
|
return this;
|
|
@@ -1401,56 +1401,56 @@ const P = class P {
|
|
|
1401
1401
|
* Clone the polynom
|
|
1402
1402
|
*/
|
|
1403
1403
|
a(this, "clone", () => {
|
|
1404
|
-
const e = new
|
|
1404
|
+
const e = new $(), t = [];
|
|
1405
1405
|
for (const i of s(this, y))
|
|
1406
1406
|
t.push(i.clone());
|
|
1407
1407
|
return e.monoms = t, e;
|
|
1408
1408
|
});
|
|
1409
1409
|
a(this, "add", (...e) => {
|
|
1410
1410
|
for (const t of e)
|
|
1411
|
-
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));
|
|
1412
1412
|
return this.reduce();
|
|
1413
1413
|
});
|
|
1414
1414
|
a(this, "commonMonom", () => {
|
|
1415
|
-
const e = new
|
|
1416
|
-
e.coefficient = new
|
|
1415
|
+
const e = new k().one(), t = this.gcdNumerator(), i = this.gcdDenominator(), n = this.degree();
|
|
1416
|
+
e.coefficient = new u(t, i);
|
|
1417
1417
|
for (const r of this.variables) {
|
|
1418
1418
|
e.setLetter(r, n);
|
|
1419
1419
|
for (const l of s(this, y))
|
|
1420
|
-
if (e.setLetter(r,
|
|
1420
|
+
if (e.setLetter(r, u.min(l.degree(r), e.degree(r))), e.degree(r).isZero())
|
|
1421
1421
|
break;
|
|
1422
1422
|
}
|
|
1423
1423
|
return e;
|
|
1424
1424
|
});
|
|
1425
1425
|
a(this, "degree", (e) => {
|
|
1426
|
-
let t = new
|
|
1426
|
+
let t = new u().zero();
|
|
1427
1427
|
for (const i of s(this, y))
|
|
1428
|
-
t =
|
|
1428
|
+
t = u.max(i.degree(e).value, t);
|
|
1429
1429
|
return t;
|
|
1430
1430
|
});
|
|
1431
1431
|
a(this, "derivative", (e) => {
|
|
1432
|
-
const t = new
|
|
1432
|
+
const t = new $();
|
|
1433
1433
|
for (const i of s(this, y))
|
|
1434
1434
|
t.add(i.derivative(e));
|
|
1435
1435
|
return t.reduce();
|
|
1436
1436
|
});
|
|
1437
1437
|
a(this, "divide", (e) => {
|
|
1438
|
-
if (e instanceof
|
|
1439
|
-
return s(this,
|
|
1438
|
+
if (e instanceof u)
|
|
1439
|
+
return s(this, yt).call(this, e);
|
|
1440
1440
|
if (typeof e == "number" && Number.isSafeInteger(e))
|
|
1441
|
-
return s(this,
|
|
1442
|
-
if (e instanceof
|
|
1443
|
-
return this.divide(new
|
|
1444
|
-
if (e instanceof
|
|
1441
|
+
return s(this, zt).call(this, e);
|
|
1442
|
+
if (e instanceof k)
|
|
1443
|
+
return this.divide(new $(e));
|
|
1444
|
+
if (e instanceof $) {
|
|
1445
1445
|
if (e.monoms.length === 1 && e.variables.length === 0)
|
|
1446
|
-
return s(this,
|
|
1446
|
+
return s(this, yt).call(this, e.monoms[0].coefficient);
|
|
1447
1447
|
{
|
|
1448
1448
|
const { quotient: t, reminder: i } = this.euclidean(e);
|
|
1449
1449
|
if (i.isZero())
|
|
1450
1450
|
return h(this, y, t.monoms), this;
|
|
1451
1451
|
}
|
|
1452
1452
|
} else if (typeof e == "string")
|
|
1453
|
-
return this.divide(new
|
|
1453
|
+
return this.divide(new $(e));
|
|
1454
1454
|
throw new Error(`Cannot divide by ${e}`);
|
|
1455
1455
|
});
|
|
1456
1456
|
a(this, "empty", () => (h(this, y, []), this));
|
|
@@ -1460,22 +1460,22 @@ const P = class P {
|
|
|
1460
1460
|
* returns {quotient: Polynom, reminder: Polynom}
|
|
1461
1461
|
*/
|
|
1462
1462
|
a(this, "euclidean", (e) => {
|
|
1463
|
-
const t = e.variables[0], i = new
|
|
1463
|
+
const t = e.variables[0], i = new $().zero(), n = this.clone().reorder(t);
|
|
1464
1464
|
if (e.variables.length === 0)
|
|
1465
1465
|
return {
|
|
1466
1466
|
quotient: this.clone().divide(e).reduce(),
|
|
1467
|
-
reminder: new
|
|
1467
|
+
reminder: new $().zero()
|
|
1468
1468
|
};
|
|
1469
1469
|
const r = e.monomByDegree(void 0, t), l = e.degree(t);
|
|
1470
|
-
let c,
|
|
1471
|
-
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()))); )
|
|
1472
1472
|
;
|
|
1473
1473
|
return i.reduce(), n.reduce(), { quotient: i, reminder: n };
|
|
1474
1474
|
});
|
|
1475
1475
|
a(this, "evaluate", (e, t) => {
|
|
1476
1476
|
if (t)
|
|
1477
|
-
return s(this,
|
|
1478
|
-
const i = new
|
|
1477
|
+
return s(this, Rt).call(this, e);
|
|
1478
|
+
const i = new u().zero();
|
|
1479
1479
|
return s(this, y).forEach((n) => {
|
|
1480
1480
|
i.add(n.evaluate(e, t));
|
|
1481
1481
|
}), i;
|
|
@@ -1489,7 +1489,7 @@ const P = class P {
|
|
|
1489
1489
|
let t = [], i = this.clone().reorder();
|
|
1490
1490
|
const n = i.commonMonom();
|
|
1491
1491
|
if (i.monomByDegree().coefficient.isStrictlyNegative() && n.coefficient.isStrictlyPositive() && !n.isOne() && n.opposite(), !n.isOne()) {
|
|
1492
|
-
const c = new
|
|
1492
|
+
const c = new $(n);
|
|
1493
1493
|
t = [c.clone()], i = i.euclidean(c).quotient;
|
|
1494
1494
|
}
|
|
1495
1495
|
let r = i.degree().clone().multiply(2).value, l = 1;
|
|
@@ -1501,24 +1501,24 @@ const P = class P {
|
|
|
1501
1501
|
t.push(i.clone()), i.one();
|
|
1502
1502
|
break;
|
|
1503
1503
|
} else {
|
|
1504
|
-
let c = s(this,
|
|
1504
|
+
let c = s(this, Lt).call(this, i, l, e ?? "x");
|
|
1505
1505
|
for (l = i.degree(e).value; c.length > 0; ) {
|
|
1506
|
-
const
|
|
1507
|
-
if (!i.isDividableBy(
|
|
1506
|
+
const f = c[0];
|
|
1507
|
+
if (!i.isDividableBy(f))
|
|
1508
1508
|
c.shift();
|
|
1509
1509
|
else {
|
|
1510
|
-
const d = i.euclidean(
|
|
1511
|
-
t.push(
|
|
1512
|
-
const w = i.monoms[0],
|
|
1513
|
-
return
|
|
1510
|
+
const d = i.euclidean(f);
|
|
1511
|
+
t.push(f), i = d.quotient.clone(), c = c.filter((p) => {
|
|
1512
|
+
const w = i.monoms[0], L = i.monoms[i.monoms.length - 1], ce = p.monoms[0], ue = p.monoms[p.monoms.length - 1];
|
|
1513
|
+
return L.isDivisible(ue) ? w.isDivisible(ce) : !1;
|
|
1514
1514
|
});
|
|
1515
1515
|
}
|
|
1516
1516
|
}
|
|
1517
1517
|
}
|
|
1518
|
-
return i.isOne() || t.push(i.clone()), h(this,
|
|
1518
|
+
return i.isOne() || t.push(i.clone()), h(this, We, t), s(this, We);
|
|
1519
1519
|
});
|
|
1520
|
-
a(this, "gcdDenominator", () =>
|
|
1521
|
-
a(this, "gcdNumerator", () =>
|
|
1520
|
+
a(this, "gcdDenominator", () => G.gcd(...this.getDenominators()));
|
|
1521
|
+
a(this, "gcdNumerator", () => G.gcd(...this.getNumerators()));
|
|
1522
1522
|
// Next functions are used for for commonMonom, which is used in the factorize method.
|
|
1523
1523
|
a(this, "getDenominators", () => {
|
|
1524
1524
|
const e = [];
|
|
@@ -1532,10 +1532,10 @@ const P = class P {
|
|
|
1532
1532
|
e.push(t.coefficient.numerator);
|
|
1533
1533
|
return e;
|
|
1534
1534
|
});
|
|
1535
|
-
a(this, "getZeroes", () => this.degree().isZero() ? [] : (this.roots = new
|
|
1535
|
+
a(this, "getZeroes", () => this.degree().isZero() ? [] : (this.roots = new Mt(this.clone()).solve(), this.roots));
|
|
1536
1536
|
a(this, "integrate", (e, t, i = "x") => {
|
|
1537
1537
|
const n = this.primitive(i), r = {}, l = {};
|
|
1538
|
-
return r[i] = new
|
|
1538
|
+
return r[i] = new u(e), l[i] = new u(t), n.evaluate(l).subtract(n.evaluate(r));
|
|
1539
1539
|
});
|
|
1540
1540
|
a(this, "isDeveloped", (e) => {
|
|
1541
1541
|
let t;
|
|
@@ -1543,7 +1543,7 @@ const P = class P {
|
|
|
1543
1543
|
if (i.includes("(") || i.includes(")"))
|
|
1544
1544
|
return !1;
|
|
1545
1545
|
try {
|
|
1546
|
-
t = new
|
|
1546
|
+
t = new $(e);
|
|
1547
1547
|
} catch {
|
|
1548
1548
|
return !1;
|
|
1549
1549
|
}
|
|
@@ -1552,18 +1552,18 @@ const P = class P {
|
|
|
1552
1552
|
a(this, "isDividableBy", (e) => {
|
|
1553
1553
|
if (e.degree().isOne()) {
|
|
1554
1554
|
const t = e.getZeroes()[0];
|
|
1555
|
-
return t.exact instanceof
|
|
1555
|
+
return t.exact instanceof u ? this.evaluate(t.exact).isZero() : !1;
|
|
1556
1556
|
} else {
|
|
1557
1557
|
const { reminder: t } = this.euclidean(e);
|
|
1558
1558
|
return t.isZero();
|
|
1559
1559
|
}
|
|
1560
1560
|
});
|
|
1561
|
-
a(this, "isEqual", (e) => s(this,
|
|
1562
|
-
a(this, "isOppositeAt", (e) => s(this,
|
|
1561
|
+
a(this, "isEqual", (e) => s(this, tt).call(this, e, "="));
|
|
1562
|
+
a(this, "isOppositeAt", (e) => s(this, tt).call(this, e.clone().opposite(), "="));
|
|
1563
1563
|
a(this, "isReduced", (e) => {
|
|
1564
1564
|
if (!this.isDeveloped(e))
|
|
1565
1565
|
return !1;
|
|
1566
|
-
const t = new
|
|
1566
|
+
const t = new $(e);
|
|
1567
1567
|
if (t.monoms.length > this.monoms.length)
|
|
1568
1568
|
return !1;
|
|
1569
1569
|
for (const i of t.monoms)
|
|
@@ -1571,9 +1571,9 @@ const P = class P {
|
|
|
1571
1571
|
return !1;
|
|
1572
1572
|
return !1;
|
|
1573
1573
|
});
|
|
1574
|
-
a(this, "isSameAs", (e) => s(this,
|
|
1575
|
-
a(this, "lcmDenominator", () =>
|
|
1576
|
-
a(this, "lcmNumerator", () =>
|
|
1574
|
+
a(this, "isSameAs", (e) => s(this, tt).call(this, e, "same"));
|
|
1575
|
+
a(this, "lcmDenominator", () => G.lcm(...this.getDenominators()));
|
|
1576
|
+
a(this, "lcmNumerator", () => G.lcm(...this.getNumerators()));
|
|
1577
1577
|
a(this, "letters", () => {
|
|
1578
1578
|
let e = /* @__PURE__ */ new Set();
|
|
1579
1579
|
for (const t of s(this, y))
|
|
@@ -1582,11 +1582,11 @@ const P = class P {
|
|
|
1582
1582
|
});
|
|
1583
1583
|
a(this, "limitToInfinity", (e) => {
|
|
1584
1584
|
const t = this.monomByDegree(void 0, e), i = t.coefficient.sign(), n = t.degree(e);
|
|
1585
|
-
return n.isStrictlyPositive() ? i === 1 ? new
|
|
1585
|
+
return n.isStrictlyPositive() ? i === 1 ? new u().infinite() : new u().infinite().opposite() : n.isZero() ? t.coefficient : new u().zero();
|
|
1586
1586
|
});
|
|
1587
1587
|
a(this, "limitToNegativeInfinity", (e) => {
|
|
1588
1588
|
const t = this.monomByDegree(void 0, e), i = t.coefficient.sign(), n = t.degree(e);
|
|
1589
|
-
return n.isStrictlyPositive() ? i === -1 ? new
|
|
1589
|
+
return n.isStrictlyPositive() ? i === -1 ? new u().infinite() : new u().infinite().opposite() : n.isZero() ? t.coefficient : new u().zero();
|
|
1590
1590
|
});
|
|
1591
1591
|
a(this, "monomByDegree", (e, t) => {
|
|
1592
1592
|
if (e === void 0)
|
|
@@ -1595,7 +1595,7 @@ const P = class P {
|
|
|
1595
1595
|
for (const n of s(i, y))
|
|
1596
1596
|
if (n.degree(t).isEqual(e))
|
|
1597
1597
|
return n.clone();
|
|
1598
|
-
return new
|
|
1598
|
+
return new k().zero();
|
|
1599
1599
|
});
|
|
1600
1600
|
// Used in LinearSystem.tex
|
|
1601
1601
|
a(this, "monomByLetter", (e) => {
|
|
@@ -1603,7 +1603,7 @@ const P = class P {
|
|
|
1603
1603
|
for (const i of s(t, y))
|
|
1604
1604
|
if (i.hasVariable(e))
|
|
1605
1605
|
return i.clone();
|
|
1606
|
-
return new
|
|
1606
|
+
return new k().zero();
|
|
1607
1607
|
});
|
|
1608
1608
|
a(this, "monomsByDegree", (e, t) => {
|
|
1609
1609
|
if (e === void 0)
|
|
@@ -1613,8 +1613,8 @@ const P = class P {
|
|
|
1613
1613
|
r.degree(t).isEqual(e) && i.push(r.clone());
|
|
1614
1614
|
return i;
|
|
1615
1615
|
});
|
|
1616
|
-
a(this, "multiply", (e) => e instanceof
|
|
1617
|
-
a(this, "one", () => (h(this, y, []), s(this, y).push(new
|
|
1616
|
+
a(this, "multiply", (e) => e instanceof $ ? s(this, Ft).call(this, e) : e instanceof u ? s(this, wt).call(this, e) : e instanceof k ? s(this, Vt).call(this, e) : Number.isSafeInteger(e) && typeof e == "number" ? s(this, Zt).call(this, e) : this);
|
|
1617
|
+
a(this, "one", () => (h(this, y, []), s(this, y).push(new k().one()), this));
|
|
1618
1618
|
// ------------------------------------------
|
|
1619
1619
|
a(this, "opposite", () => (h(this, y, s(this, y).map((e) => e.opposite())), this));
|
|
1620
1620
|
a(this, "pow", (e) => {
|
|
@@ -1623,14 +1623,14 @@ const P = class P {
|
|
|
1623
1623
|
if (e < 0)
|
|
1624
1624
|
return this.zero();
|
|
1625
1625
|
if (e === 0)
|
|
1626
|
-
return new
|
|
1626
|
+
return new $();
|
|
1627
1627
|
const t = this.clone();
|
|
1628
1628
|
for (let i = 1; i < e; i++)
|
|
1629
1629
|
this.multiply(t);
|
|
1630
1630
|
return this.reduce();
|
|
1631
1631
|
});
|
|
1632
1632
|
a(this, "primitive", (e) => {
|
|
1633
|
-
const t = new
|
|
1633
|
+
const t = new $();
|
|
1634
1634
|
for (const i of s(this, y))
|
|
1635
1635
|
t.add(i.primitive(e));
|
|
1636
1636
|
return t;
|
|
@@ -1639,13 +1639,13 @@ const P = class P {
|
|
|
1639
1639
|
let e = 0;
|
|
1640
1640
|
for (; e < s(this, y).length; ) {
|
|
1641
1641
|
for (let t = e + 1; t < s(this, y).length; t++)
|
|
1642
|
-
s(this, y)[e].isSameAs(s(this, y)[t]) && (s(this, y)[e].add(s(this, y)[t]), s(this, y).splice(t, 1), s(this, y)[e].isZero() && (s(this, y)[e] = new
|
|
1642
|
+
s(this, y)[e].isSameAs(s(this, y)[t]) && (s(this, y)[e].add(s(this, y)[t]), s(this, y).splice(t, 1), s(this, y)[e].isZero() && (s(this, y)[e] = new k().zero()), t--);
|
|
1643
1643
|
e++;
|
|
1644
1644
|
}
|
|
1645
1645
|
h(this, y, s(this, y).filter((t) => !t.coefficient.isZero()));
|
|
1646
1646
|
for (const t of s(this, y))
|
|
1647
1647
|
t.coefficient.reduce();
|
|
1648
|
-
return this.length === 0 ? new
|
|
1648
|
+
return this.length === 0 ? new $().zero() : this.reorder();
|
|
1649
1649
|
});
|
|
1650
1650
|
// ------------------------------------------
|
|
1651
1651
|
a(this, "reorder", (e = "x", t) => {
|
|
@@ -1656,8 +1656,8 @@ const P = class P {
|
|
|
1656
1656
|
if (l !== c)
|
|
1657
1657
|
return t ? l - c : c - l;
|
|
1658
1658
|
if (i.length > 0)
|
|
1659
|
-
for (const
|
|
1660
|
-
const d = n.degree(
|
|
1659
|
+
for (const f of i) {
|
|
1660
|
+
const d = n.degree(f).value, p = r.degree(f).value;
|
|
1661
1661
|
if (d !== p)
|
|
1662
1662
|
return t ? d - p : p - d;
|
|
1663
1663
|
}
|
|
@@ -1671,22 +1671,22 @@ const P = class P {
|
|
|
1671
1671
|
*/
|
|
1672
1672
|
a(this, "replaceBy", (e, t) => {
|
|
1673
1673
|
let i;
|
|
1674
|
-
const n = new
|
|
1674
|
+
const n = new $().zero();
|
|
1675
1675
|
for (const r of this.monoms)
|
|
1676
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)));
|
|
1677
1677
|
return h(this, y, n.reduce().monoms), this;
|
|
1678
1678
|
});
|
|
1679
1679
|
a(this, "subtract", (...e) => {
|
|
1680
1680
|
for (const t of e)
|
|
1681
|
-
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());
|
|
1682
1682
|
return this.reduce();
|
|
1683
1683
|
});
|
|
1684
1684
|
/**
|
|
1685
1685
|
* Set the polynom to zero.
|
|
1686
1686
|
* @returns {this}
|
|
1687
1687
|
*/
|
|
1688
|
-
a(this, "zero", () => (h(this, y, []), s(this, y).push(new
|
|
1689
|
-
m(this,
|
|
1688
|
+
a(this, "zero", () => (h(this, y, []), s(this, y).push(new k().zero()), this));
|
|
1689
|
+
m(this, tt, (e, t) => {
|
|
1690
1690
|
t === void 0 && (t = "=");
|
|
1691
1691
|
const i = this.clone().reduce().reorder(), n = e.clone().reduce().reorder();
|
|
1692
1692
|
switch (t) {
|
|
@@ -1698,47 +1698,47 @@ const P = class P {
|
|
|
1698
1698
|
return !1;
|
|
1699
1699
|
}
|
|
1700
1700
|
});
|
|
1701
|
-
m(this,
|
|
1701
|
+
m(this, yt, (e) => {
|
|
1702
1702
|
for (const t of s(this, y))
|
|
1703
1703
|
t.coefficient.divide(e);
|
|
1704
1704
|
return this;
|
|
1705
1705
|
});
|
|
1706
|
-
m(this,
|
|
1707
|
-
const t = new
|
|
1706
|
+
m(this, zt, (e) => {
|
|
1707
|
+
const t = new u(e);
|
|
1708
1708
|
for (const i of s(this, y))
|
|
1709
1709
|
i.coefficient.divide(t);
|
|
1710
1710
|
return this;
|
|
1711
1711
|
});
|
|
1712
|
-
m(this,
|
|
1712
|
+
m(this, Rt, (e) => {
|
|
1713
1713
|
let t = 0;
|
|
1714
1714
|
return s(this, y).forEach((i) => {
|
|
1715
1715
|
t += i.evaluate(e, !0);
|
|
1716
1716
|
}), t;
|
|
1717
1717
|
});
|
|
1718
|
-
m(this,
|
|
1718
|
+
m(this, Dt, (e) => {
|
|
1719
1719
|
var w;
|
|
1720
|
-
let t, i, n, r, l, c,
|
|
1720
|
+
let t, i, n, r, l, c, f, d, p;
|
|
1721
1721
|
if (this.numberOfVars === 1)
|
|
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() ? (
|
|
1723
|
-
new
|
|
1724
|
-
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)
|
|
1725
1725
|
] : [
|
|
1726
|
-
new
|
|
1727
|
-
new
|
|
1728
|
-
new
|
|
1726
|
+
new $(p.display),
|
|
1727
|
+
new $(e).subtract(f.display).multiply(f.denominator),
|
|
1728
|
+
new $(e).subtract(d.display).multiply(d.denominator)
|
|
1729
1729
|
]) : [this.clone()];
|
|
1730
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))) {
|
|
1731
|
-
const
|
|
1731
|
+
const L = new $("x", n.coefficient, r.coefficient, l.coefficient), ce = s(w = L, Dt).call(w, "x"), ue = [];
|
|
1732
1732
|
let fe;
|
|
1733
1733
|
if (ce.length >= 2) {
|
|
1734
|
-
for (const
|
|
1735
|
-
|
|
1734
|
+
for (const we of ce)
|
|
1735
|
+
we.degree().isZero() ? ue.push(we.clone()) : (fe = we.clone(), fe.monoms[0].literal = n.literalSqrt, fe.monoms[1].literal = l.literalSqrt, ue.push(fe.clone()));
|
|
1736
1736
|
return ue;
|
|
1737
1737
|
}
|
|
1738
1738
|
}
|
|
1739
1739
|
return [this.clone()];
|
|
1740
1740
|
});
|
|
1741
|
-
m(this,
|
|
1741
|
+
m(this, it, (e, t, i, n) => {
|
|
1742
1742
|
let r = "";
|
|
1743
1743
|
for (const l of s(this, y)) {
|
|
1744
1744
|
if (l.coefficient.value === 0)
|
|
@@ -1748,51 +1748,51 @@ const P = class P {
|
|
|
1748
1748
|
}
|
|
1749
1749
|
return i === !0 && this.length > 1 && (e === "tex" ? r = `\\left( ${r} \\right)` : r = `(${r})`), r === "" && (r = "0"), r;
|
|
1750
1750
|
});
|
|
1751
|
-
m(this,
|
|
1751
|
+
m(this, Lt, (e, t, i) => {
|
|
1752
1752
|
const n = e.monoms[0].dividers, r = e.monoms[e.monoms.length - 1].dividers, l = [];
|
|
1753
1753
|
return n.forEach((c) => {
|
|
1754
|
-
c.degree(i).isLeq(t) && r.forEach((
|
|
1755
|
-
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())));
|
|
1756
1756
|
});
|
|
1757
1757
|
}), l;
|
|
1758
1758
|
});
|
|
1759
|
-
m(this,
|
|
1759
|
+
m(this, wt, (e) => {
|
|
1760
1760
|
for (const t of s(this, y))
|
|
1761
1761
|
t.coefficient.multiply(e);
|
|
1762
1762
|
return this.reduce();
|
|
1763
1763
|
});
|
|
1764
|
-
m(this,
|
|
1765
|
-
m(this,
|
|
1764
|
+
m(this, Zt, (e) => s(this, wt).call(this, new u(e)));
|
|
1765
|
+
m(this, Vt, (e) => {
|
|
1766
1766
|
for (const t of s(this, y))
|
|
1767
1767
|
t.multiply(e);
|
|
1768
1768
|
return this.reduce();
|
|
1769
1769
|
});
|
|
1770
|
-
m(this,
|
|
1770
|
+
m(this, Ft, (e) => {
|
|
1771
1771
|
const t = [];
|
|
1772
1772
|
for (const i of s(this, y))
|
|
1773
1773
|
for (const n of e.monoms)
|
|
1774
|
-
t.push(
|
|
1774
|
+
t.push(k.xMultiply(i, n));
|
|
1775
1775
|
return h(this, y, t), this.reduce();
|
|
1776
1776
|
});
|
|
1777
1777
|
/**
|
|
1778
1778
|
* Main parse using a shutting yard class
|
|
1779
1779
|
* @param inputStr
|
|
1780
1780
|
*/
|
|
1781
|
-
m(this,
|
|
1782
|
-
const i = new
|
|
1781
|
+
m(this, Ut, (e) => {
|
|
1782
|
+
const i = new si().parse(e).rpn;
|
|
1783
1783
|
this.zero();
|
|
1784
1784
|
const n = [];
|
|
1785
1785
|
for (const r of i)
|
|
1786
|
-
s(this,
|
|
1786
|
+
s(this, Gt).call(this, n, r);
|
|
1787
1787
|
return n.length === 1 && this.add(n[0]), this.reorder();
|
|
1788
1788
|
});
|
|
1789
|
-
m(this,
|
|
1789
|
+
m(this, Gt, (e, t) => {
|
|
1790
1790
|
switch (t.tokenType) {
|
|
1791
1791
|
case g.COEFFICIENT:
|
|
1792
|
-
e.push(new
|
|
1792
|
+
e.push(new $(t.token));
|
|
1793
1793
|
break;
|
|
1794
1794
|
case g.VARIABLE:
|
|
1795
|
-
e.push(new
|
|
1795
|
+
e.push(new $().add(new k(t.token)));
|
|
1796
1796
|
break;
|
|
1797
1797
|
case g.CONSTANT:
|
|
1798
1798
|
console.log("Actually, not supported - will be added later !");
|
|
@@ -1836,24 +1836,24 @@ const P = class P {
|
|
|
1836
1836
|
break;
|
|
1837
1837
|
}
|
|
1838
1838
|
});
|
|
1839
|
-
return h(this, y, []), h(this,
|
|
1839
|
+
return h(this, y, []), h(this, We, []), h(this, et, []), e !== void 0 && this.parse(e, ...t), this;
|
|
1840
1840
|
}
|
|
1841
1841
|
get tex() {
|
|
1842
|
-
return s(this,
|
|
1842
|
+
return s(this, it).call(this, "tex");
|
|
1843
1843
|
}
|
|
1844
1844
|
get display() {
|
|
1845
|
-
return s(this,
|
|
1845
|
+
return s(this, it).call(this);
|
|
1846
1846
|
}
|
|
1847
1847
|
fromCoefficients(...e) {
|
|
1848
1848
|
h(this, y, []);
|
|
1849
1849
|
const t = "x";
|
|
1850
1850
|
return e.reverse().forEach((i, n) => {
|
|
1851
|
-
const r = new
|
|
1852
|
-
r.coefficient = new
|
|
1851
|
+
const r = new k();
|
|
1852
|
+
r.coefficient = new u(i), r.setLetter(t, n), s(this, y).push(r);
|
|
1853
1853
|
}), this;
|
|
1854
1854
|
}
|
|
1855
1855
|
getCoefficients() {
|
|
1856
|
-
const e = this.clone().reorder(), t = this.degree().value + 1, i = new Array(t).fill(new
|
|
1856
|
+
const e = this.clone().reorder(), t = this.degree().value + 1, i = new Array(t).fill(new u(0));
|
|
1857
1857
|
return e.monoms.forEach((n) => {
|
|
1858
1858
|
const r = t - n.degree().value - 1;
|
|
1859
1859
|
i[r] = n.coefficient.clone();
|
|
@@ -1887,16 +1887,16 @@ const P = class P {
|
|
|
1887
1887
|
return this.variables.length;
|
|
1888
1888
|
}
|
|
1889
1889
|
get plotFunction() {
|
|
1890
|
-
return s(this,
|
|
1890
|
+
return s(this, it).call(this, "tex", !1, !1, !0);
|
|
1891
1891
|
}
|
|
1892
1892
|
root() {
|
|
1893
1893
|
throw new Error("Cannot take the root from a polynom");
|
|
1894
1894
|
}
|
|
1895
1895
|
get roots() {
|
|
1896
|
-
return s(this,
|
|
1896
|
+
return s(this, gt) ? s(this, et) : this.getZeroes();
|
|
1897
1897
|
}
|
|
1898
1898
|
set roots(e) {
|
|
1899
|
-
h(this,
|
|
1899
|
+
h(this, gt, !0), h(this, et, e);
|
|
1900
1900
|
}
|
|
1901
1901
|
sqrt() {
|
|
1902
1902
|
throw new Error("Cannot take the square root from a polynom");
|
|
@@ -1906,7 +1906,7 @@ const P = class P {
|
|
|
1906
1906
|
let t = new Array(2 * e.length + 1).fill("").map((i, n) => n % 2 === 0 ? "" : "z");
|
|
1907
1907
|
if (t.length === 1) {
|
|
1908
1908
|
const [i] = this.getCoefficients().map((n) => n.value);
|
|
1909
|
-
t =
|
|
1909
|
+
t = Ct(t, "", i > 0 ? "+" : "-");
|
|
1910
1910
|
} else if (this.degree().isOne()) {
|
|
1911
1911
|
const [i] = this.getCoefficients().map((n) => n.value);
|
|
1912
1912
|
t[0] = i > 0 ? "-" : "+", t[1] = "z", t[2] = i > 0 ? "+" : "-";
|
|
@@ -1930,62 +1930,62 @@ const P = class P {
|
|
|
1930
1930
|
return this.getZeroes();
|
|
1931
1931
|
}
|
|
1932
1932
|
};
|
|
1933
|
-
|
|
1933
|
+
We = new WeakMap(), y = new WeakMap(), et = new WeakMap(), gt = new WeakMap(), tt = new WeakMap(), yt = new WeakMap(), zt = new WeakMap(), Rt = new WeakMap(), Dt = new WeakMap(), it = new WeakMap(), Lt = new WeakMap(), wt = new WeakMap(), Zt = new WeakMap(), Vt = new WeakMap(), Ft = new WeakMap(), jt = new WeakSet(), Ii = function(e, ...t) {
|
|
1934
1934
|
if (t.length === 0) {
|
|
1935
1935
|
if (e = "" + e, e !== "" && !isNaN(Number(e))) {
|
|
1936
1936
|
this.empty();
|
|
1937
|
-
const i = new
|
|
1937
|
+
const i = new k(e);
|
|
1938
1938
|
return this.add(i), this;
|
|
1939
1939
|
}
|
|
1940
|
-
return s(this,
|
|
1940
|
+
return s(this, Ut).call(this, e);
|
|
1941
1941
|
} else if (/^[a-z]+/.test(e)) {
|
|
1942
1942
|
this.empty();
|
|
1943
|
-
const i = t.map((n) => new
|
|
1943
|
+
const i = t.map((n) => new u(n));
|
|
1944
1944
|
if (e.length > 1) {
|
|
1945
1945
|
const n = e.split("");
|
|
1946
1946
|
if (n.length < t.length - 2)
|
|
1947
1947
|
throw new Error("Too many factors for too few variables !");
|
|
1948
1948
|
let r = 0;
|
|
1949
1949
|
for (const l of i) {
|
|
1950
|
-
const c = new
|
|
1950
|
+
const c = new k();
|
|
1951
1951
|
c.coefficient = l.clone(), c.literalStr = n[r] || "", this.add(c), r++;
|
|
1952
1952
|
}
|
|
1953
1953
|
} else {
|
|
1954
1954
|
let n = i.length - 1;
|
|
1955
1955
|
for (const r of i) {
|
|
1956
|
-
const l = new
|
|
1956
|
+
const l = new k();
|
|
1957
1957
|
l.coefficient = r.clone(), l.literalStr = `${e}^${n}`, this.add(l), n--;
|
|
1958
1958
|
}
|
|
1959
1959
|
}
|
|
1960
1960
|
return this;
|
|
1961
1961
|
} else
|
|
1962
1962
|
return this.zero();
|
|
1963
|
-
},
|
|
1964
|
-
let
|
|
1965
|
-
var
|
|
1966
|
-
const
|
|
1963
|
+
}, Ut = new WeakMap(), Gt = new WeakMap();
|
|
1964
|
+
let N = $;
|
|
1965
|
+
var O, C, oe, Wt, st, Xt;
|
|
1966
|
+
const qe = class qe {
|
|
1967
1967
|
constructor(e, t, i) {
|
|
1968
1968
|
// Left part of the equation
|
|
1969
|
-
m(this,
|
|
1969
|
+
m(this, O);
|
|
1970
1970
|
// Right part of the equation
|
|
1971
|
-
m(this,
|
|
1971
|
+
m(this, C);
|
|
1972
1972
|
// Signe of the equation
|
|
1973
1973
|
m(this, oe);
|
|
1974
1974
|
// ------------------------------------------
|
|
1975
1975
|
a(this, "parse", (e) => {
|
|
1976
|
-
const t = s(this,
|
|
1976
|
+
const t = s(this, Wt).call(this, e);
|
|
1977
1977
|
if (t === !1)
|
|
1978
1978
|
throw new Error("The equation is not valid (no sign found)");
|
|
1979
1979
|
const i = e.split(t);
|
|
1980
|
-
return this.create(new
|
|
1980
|
+
return this.create(new N(i[0]), new N(i[1]), s(this, st).call(this, t));
|
|
1981
1981
|
});
|
|
1982
|
-
a(this, "create", (e, t, i) => (h(this,
|
|
1983
|
-
a(this, "clone", () => new
|
|
1982
|
+
a(this, "create", (e, t, i) => (h(this, O, e), h(this, C, t), h(this, oe, s(this, st).call(this, i ?? "=")), this));
|
|
1983
|
+
a(this, "clone", () => new qe(s(this, O).clone(), s(this, C).clone(), s(this, oe)));
|
|
1984
1984
|
/**
|
|
1985
1985
|
* Get the degree of the equation
|
|
1986
1986
|
* @param letter
|
|
1987
1987
|
*/
|
|
1988
|
-
a(this, "degree", (e) =>
|
|
1988
|
+
a(this, "degree", (e) => u.max(s(this, O).degree(e), s(this, C).degree(e)));
|
|
1989
1989
|
/**
|
|
1990
1990
|
* divide an equation by a given value (transformed as a fraction)
|
|
1991
1991
|
*
|
|
@@ -2001,7 +2001,7 @@ const Ne = class Ne {
|
|
|
2001
2001
|
* @returns {Equation}
|
|
2002
2002
|
*/
|
|
2003
2003
|
a(this, "divide", (e) => {
|
|
2004
|
-
const t = new
|
|
2004
|
+
const t = new u(e);
|
|
2005
2005
|
return t.isZero() ? this : this.multiply(t.inverse());
|
|
2006
2006
|
});
|
|
2007
2007
|
/**
|
|
@@ -2016,7 +2016,7 @@ const Ne = class Ne {
|
|
|
2016
2016
|
/**
|
|
2017
2017
|
* Determine if the equation contains more than one letter/variable.
|
|
2018
2018
|
*/
|
|
2019
|
-
a(this, "isMultiVariable", () => s(this,
|
|
2019
|
+
a(this, "isMultiVariable", () => s(this, O).isMultiVariable || s(this, C).isMultiVariable);
|
|
2020
2020
|
// -----------------------------------------------
|
|
2021
2021
|
// Equations helpers
|
|
2022
2022
|
a(this, "isEqualTo", (e) => {
|
|
@@ -2031,47 +2031,47 @@ const Ne = class Ne {
|
|
|
2031
2031
|
if (!this.degree(e).isOne() || this.isMultiVariable())
|
|
2032
2032
|
return !1;
|
|
2033
2033
|
let t;
|
|
2034
|
-
s(this,
|
|
2035
|
-
const i = [...s(this,
|
|
2034
|
+
s(this, O).subtract(s(this, C)), s(this, C).zero();
|
|
2035
|
+
const i = [...s(this, O).monoms];
|
|
2036
2036
|
for (const r of i)
|
|
2037
|
-
r.hasVariable(e) || (t = r.clone(), s(this,
|
|
2038
|
-
if (s(this,
|
|
2037
|
+
r.hasVariable(e) || (t = r.clone(), s(this, O).subtract(t), s(this, C).subtract(t));
|
|
2038
|
+
if (s(this, O).length !== 1)
|
|
2039
2039
|
return !1;
|
|
2040
|
-
const n = s(this,
|
|
2041
|
-
return s(this,
|
|
2040
|
+
const n = s(this, O).monoms[0].coefficient.clone();
|
|
2041
|
+
return s(this, O).divide(n), s(this, C).divide(n), this;
|
|
2042
2042
|
});
|
|
2043
2043
|
// -----------------------------------------------
|
|
2044
2044
|
// Equations operations
|
|
2045
2045
|
// -----------------------------------------------
|
|
2046
|
-
a(this, "letters", () => [.../* @__PURE__ */ new Set([...s(this,
|
|
2046
|
+
a(this, "letters", () => [.../* @__PURE__ */ new Set([...s(this, O).letters(), ...s(this, C).letters()])]);
|
|
2047
2047
|
// -----------------------------------------------
|
|
2048
2048
|
/**
|
|
2049
2049
|
* Reorder will move all monoms containing a letter on the left, all the other on the right.
|
|
2050
2050
|
*/
|
|
2051
|
-
a(this, "moveLeft", () => (s(this,
|
|
2051
|
+
a(this, "moveLeft", () => (s(this, O).subtract(s(this, C)), s(this, C).zero(), this));
|
|
2052
2052
|
/**
|
|
2053
2053
|
* Multiple an equation by a fraction value.
|
|
2054
2054
|
* @param value
|
|
2055
2055
|
*/
|
|
2056
2056
|
a(this, "multiply", (e) => {
|
|
2057
|
-
const t = new
|
|
2058
|
-
return s(this,
|
|
2057
|
+
const t = new u(e);
|
|
2058
|
+
return s(this, O).multiply(t), s(this, C).multiply(t), s(this, oe) !== "=" && t.sign() === -1 && s(this, Xt).call(this), this;
|
|
2059
2059
|
});
|
|
2060
|
-
a(this, "opposite", () => (h(this,
|
|
2061
|
-
a(this, "reorder", (e) => (s(this,
|
|
2060
|
+
a(this, "opposite", () => (h(this, O, s(this, O).opposite()), h(this, C, s(this, C).opposite()), this));
|
|
2061
|
+
a(this, "reorder", (e) => (s(this, O).subtract(s(this, C)), s(this, C).zero(), s(this, O).reorder(), e ? this : (s(this, O).monoms.filter((t) => t.degree().isZero()).forEach((t) => {
|
|
2062
2062
|
const i = t.clone();
|
|
2063
|
-
s(this,
|
|
2064
|
-
}), s(this,
|
|
2063
|
+
s(this, O).subtract(i), s(this, C).subtract(i);
|
|
2064
|
+
}), s(this, O).reorder(), s(this, C).reorder(), this)));
|
|
2065
2065
|
// ------------------------------------------
|
|
2066
|
-
a(this, "replaceBy", (e, t) => (s(this,
|
|
2066
|
+
a(this, "replaceBy", (e, t) => (s(this, O).replaceBy(e, t), s(this, C).replaceBy(e, t), this));
|
|
2067
2067
|
/**
|
|
2068
2068
|
* Multiply by the lcm denominator and divide by the gcm numerators.
|
|
2069
2069
|
*/
|
|
2070
|
-
a(this, "simplify", () => (this.multiply(
|
|
2070
|
+
a(this, "simplify", () => (this.multiply(G.lcm(...s(this, O).getDenominators(), ...s(this, C).getDenominators())), this.divide(G.gcd(...s(this, O).getNumerators(), ...s(this, C).getNumerators())), this));
|
|
2071
2071
|
// -----------------------------------------------
|
|
2072
|
-
a(this, "solve", () => new
|
|
2072
|
+
a(this, "solve", () => new Mt(this.clone()).solve());
|
|
2073
2073
|
a(this, "test", (e) => this.left.evaluate(e).isEqual(this.right.evaluate(e)));
|
|
2074
|
-
m(this,
|
|
2074
|
+
m(this, Wt, (e) => {
|
|
2075
2075
|
if (e.includes("geq"))
|
|
2076
2076
|
return e.includes("\\geq") ? "\\geq" : "geq";
|
|
2077
2077
|
if (e.includes("leq"))
|
|
@@ -2094,13 +2094,13 @@ const Ne = class Ne {
|
|
|
2094
2094
|
});
|
|
2095
2095
|
// -----------------------------------------------
|
|
2096
2096
|
// Equations solving algorithms
|
|
2097
|
-
m(this,
|
|
2098
|
-
m(this,
|
|
2099
|
-
if (h(this,
|
|
2100
|
-
if (e instanceof
|
|
2097
|
+
m(this, st, (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, Xt, () => s(this, oe) === "=" ? this : s(this, oe).includes("<") ? (s(this, oe).replace("<", ">"), this) : s(this, oe).includes(">") ? (s(this, oe).replace(">", "<"), this) : this);
|
|
2099
|
+
if (h(this, O, new N().zero()), h(this, C, new N().zero()), h(this, oe, "="), e !== void 0 && t === void 0) {
|
|
2100
|
+
if (e instanceof qe)
|
|
2101
2101
|
return e.clone();
|
|
2102
2102
|
typeof e == "string" && this.parse(e);
|
|
2103
|
-
} else e !== void 0 && t !== void 0 && (this.left = new
|
|
2103
|
+
} else e !== void 0 && t !== void 0 && (this.left = new N(e), this.right = new N(t));
|
|
2104
2104
|
return i !== void 0 && (this.sign = i), this;
|
|
2105
2105
|
}
|
|
2106
2106
|
/**
|
|
@@ -2112,12 +2112,12 @@ const Ne = class Ne {
|
|
|
2112
2112
|
* @param value | Polynom | Monom | Fraction | string | monom
|
|
2113
2113
|
*/
|
|
2114
2114
|
add(e) {
|
|
2115
|
-
if (e instanceof
|
|
2116
|
-
return s(this,
|
|
2117
|
-
if (typeof e == "string" && !
|
|
2118
|
-
return this.add(new
|
|
2119
|
-
const t = new
|
|
2120
|
-
return s(this,
|
|
2115
|
+
if (e instanceof qe)
|
|
2116
|
+
return s(this, O).add(e.left), s(this, C).add(e.right), this;
|
|
2117
|
+
if (typeof e == "string" && !qe.isEquationString(e))
|
|
2118
|
+
return this.add(new qe(e));
|
|
2119
|
+
const t = new N(e);
|
|
2120
|
+
return s(this, O).add(t), s(this, C).add(t), this;
|
|
2121
2121
|
}
|
|
2122
2122
|
/**
|
|
2123
2123
|
* Create an Equation using two polynoms.
|
|
@@ -2126,29 +2126,29 @@ const Ne = class Ne {
|
|
|
2126
2126
|
* @param asNumeric
|
|
2127
2127
|
*/
|
|
2128
2128
|
evaluate(e, t) {
|
|
2129
|
-
const i = s(this,
|
|
2129
|
+
const i = s(this, O).evaluate(e, t), n = s(this, C).evaluate(e, t);
|
|
2130
2130
|
return t ? i === n : i.isEqual(n);
|
|
2131
2131
|
}
|
|
2132
2132
|
isEqual(e) {
|
|
2133
|
-
const t = new
|
|
2134
|
-
return t.left.isEqual(s(this,
|
|
2133
|
+
const t = new qe(e);
|
|
2134
|
+
return t.left.isEqual(s(this, O)) && t.right.isEqual(s(this, C));
|
|
2135
2135
|
}
|
|
2136
2136
|
pow(e) {
|
|
2137
|
-
return s(this,
|
|
2137
|
+
return s(this, O).pow(e), s(this, C).pow(e), this;
|
|
2138
2138
|
}
|
|
2139
2139
|
reduce() {
|
|
2140
|
-
return this.moveLeft(), s(this,
|
|
2140
|
+
return this.moveLeft(), s(this, O).reduce(), this.simplify(), s(this, O).monoms[0].coefficient.isNegative() && this.multiply(-1), this;
|
|
2141
2141
|
}
|
|
2142
2142
|
split() {
|
|
2143
|
-
return [s(this,
|
|
2143
|
+
return [s(this, O).clone(), s(this, C).clone()];
|
|
2144
2144
|
}
|
|
2145
2145
|
subtract(e) {
|
|
2146
|
-
if (e instanceof
|
|
2147
|
-
return s(this,
|
|
2148
|
-
if (typeof e == "string" && !
|
|
2149
|
-
return this.subtract(new
|
|
2150
|
-
const t = new
|
|
2151
|
-
return s(this,
|
|
2146
|
+
if (e instanceof qe)
|
|
2147
|
+
return s(this, O).subtract(e.left), s(this, C).subtract(e.right), this;
|
|
2148
|
+
if (typeof e == "string" && !qe.isEquationString(e))
|
|
2149
|
+
return this.subtract(new qe(e));
|
|
2150
|
+
const t = new N(e);
|
|
2151
|
+
return s(this, O).subtract(t), s(this, C).subtract(t), this;
|
|
2152
2152
|
}
|
|
2153
2153
|
static isEquationString(e) {
|
|
2154
2154
|
return e.includes("=") || e.includes("<") || e.includes(">") || e.includes("<=") || e.includes(">=");
|
|
@@ -2158,85 +2158,85 @@ const Ne = class Ne {
|
|
|
2158
2158
|
return t === !0 && n.sort((r, l) => r.value - l.value), n;
|
|
2159
2159
|
}
|
|
2160
2160
|
get display() {
|
|
2161
|
-
return `${s(this,
|
|
2161
|
+
return `${s(this, O).display}${this.signAsTex}${s(this, C).display}`;
|
|
2162
2162
|
}
|
|
2163
2163
|
// Getter and setter
|
|
2164
2164
|
get left() {
|
|
2165
|
-
return s(this,
|
|
2165
|
+
return s(this, O);
|
|
2166
2166
|
}
|
|
2167
2167
|
set left(e) {
|
|
2168
|
-
h(this,
|
|
2168
|
+
h(this, O, e);
|
|
2169
2169
|
}
|
|
2170
2170
|
get numberOfVars() {
|
|
2171
2171
|
return this.variables.length;
|
|
2172
2172
|
}
|
|
2173
2173
|
get right() {
|
|
2174
|
-
return s(this,
|
|
2174
|
+
return s(this, C);
|
|
2175
2175
|
}
|
|
2176
2176
|
set right(e) {
|
|
2177
|
-
h(this,
|
|
2177
|
+
h(this, C, e);
|
|
2178
2178
|
}
|
|
2179
2179
|
// ------------------------------------------
|
|
2180
2180
|
get sign() {
|
|
2181
2181
|
return s(this, oe);
|
|
2182
2182
|
}
|
|
2183
2183
|
set sign(e) {
|
|
2184
|
-
h(this, oe, s(this,
|
|
2184
|
+
h(this, oe, s(this, st).call(this, e));
|
|
2185
2185
|
}
|
|
2186
2186
|
get signAsTex() {
|
|
2187
2187
|
return s(this, oe) === ">=" ? "\\geq" : s(this, oe) === "<=" ? "\\leq" : s(this, oe);
|
|
2188
2188
|
}
|
|
2189
2189
|
get tex() {
|
|
2190
|
-
return `${s(this,
|
|
2190
|
+
return `${s(this, O).tex}${this.signAsTex}${s(this, C).tex}`;
|
|
2191
2191
|
}
|
|
2192
2192
|
get variables() {
|
|
2193
|
-
return [...new Set(s(this,
|
|
2193
|
+
return [...new Set(s(this, C).variables.concat(s(this, O).variables))];
|
|
2194
2194
|
}
|
|
2195
2195
|
};
|
|
2196
|
-
|
|
2197
|
-
let
|
|
2198
|
-
var
|
|
2199
|
-
const
|
|
2196
|
+
O = new WeakMap(), C = new WeakMap(), oe = new WeakMap(), Wt = new WeakMap(), st = new WeakMap(), Xt = new WeakMap();
|
|
2197
|
+
let V = qe;
|
|
2198
|
+
var Ce, Ae, xe, nt;
|
|
2199
|
+
const be = class be {
|
|
2200
2200
|
constructor(e, t) {
|
|
2201
|
-
m(this,
|
|
2201
|
+
m(this, Ce);
|
|
2202
2202
|
m(this, Ae);
|
|
2203
|
-
m(this,
|
|
2204
|
-
m(this,
|
|
2205
|
-
return e instanceof
|
|
2203
|
+
m(this, xe);
|
|
2204
|
+
m(this, nt, !1);
|
|
2205
|
+
return e instanceof be ? (h(this, Ae, e.polynom.clone()), h(this, xe, e.power.clone()), t !== void 0 && s(this, xe).multiply(new u(t))) : e !== void 0 ? (h(this, Ae, new N(e)), h(this, xe, new u(t ?? 1))) : (h(this, Ae, new N()), h(this, xe, new u(1))), h(this, Ce, 1), this;
|
|
2206
2206
|
}
|
|
2207
2207
|
parse() {
|
|
2208
2208
|
throw new Error("Method not implemented.");
|
|
2209
2209
|
}
|
|
2210
2210
|
clone() {
|
|
2211
|
-
return new
|
|
2211
|
+
return new be(this);
|
|
2212
2212
|
}
|
|
2213
2213
|
fromPolynom(e) {
|
|
2214
|
-
return h(this, Ae, new
|
|
2214
|
+
return h(this, Ae, new N(e)), h(this, xe, new u(1)), this;
|
|
2215
2215
|
}
|
|
2216
2216
|
get tex() {
|
|
2217
2217
|
const e = this.power.numerator, t = this.power.denominator;
|
|
2218
2218
|
let i, n;
|
|
2219
|
-
return s(this,
|
|
2219
|
+
return s(this, Ce) === 0 && t > 1 ? (i = `\\sqrt${t === 2 ? "" : `[ ${t} ]`}{ ${this.polynom.tex} }`, n = e === 1 ? "" : `^{ ${e} }`) : (i = s(this, nt) && this.power.isOne() ? this.polynom.tex : qi(this.polynom.tex), n = t === 1 && e === 1 ? "" : `^{ ${this.power.tex} }`), i = `${i}${n}`, s(this, Ce) === 0 && e < 0 && (i = `\\frac{ 1 }{ ${i} }`), i;
|
|
2220
2220
|
}
|
|
2221
2221
|
get display() {
|
|
2222
2222
|
const e = this.power.numerator, t = this.power.denominator;
|
|
2223
2223
|
let i, n;
|
|
2224
|
-
return s(this,
|
|
2224
|
+
return s(this, Ce) === 0 && t > 1 ? (i = `${t === 2 ? "sqrt" : `root(${t})`}(${this.polynom.display})`, n = e === 1 ? "" : `^(${e})`) : (i = s(this, nt) && this.power.isOne() ? this.polynom.display : qi(this.polynom.display, !1), n = t === 1 && e === 1 ? "" : `^(${this.power.display})`), i = `${i}${n}`, s(this, Ce) === 0 && e < 0 && (i = `1/(${i})`), i;
|
|
2225
2225
|
}
|
|
2226
2226
|
add() {
|
|
2227
2227
|
throw new Error("Adding two factors is not possible");
|
|
2228
2228
|
}
|
|
2229
2229
|
get asSingle() {
|
|
2230
|
-
return h(this,
|
|
2230
|
+
return h(this, nt, !0), this;
|
|
2231
2231
|
}
|
|
2232
2232
|
degree(e) {
|
|
2233
2233
|
return this.polynom.degree(e).multiply(this.power);
|
|
2234
2234
|
}
|
|
2235
2235
|
derivative() {
|
|
2236
|
-
return this.power.isZero() ? [new
|
|
2237
|
-
new
|
|
2238
|
-
new
|
|
2239
|
-
new
|
|
2236
|
+
return this.power.isZero() ? [new be("0")] : this.power.isOne() ? [new be(this.polynom.clone().derivative())] : [
|
|
2237
|
+
new be(this.power.clone()),
|
|
2238
|
+
new be(this.polynom.clone().derivative()),
|
|
2239
|
+
new be(this.polynom.clone(), this.power.clone().subtract(1))
|
|
2240
2240
|
];
|
|
2241
2241
|
}
|
|
2242
2242
|
develop() {
|
|
@@ -2245,9 +2245,9 @@ const ve = class ve {
|
|
|
2245
2245
|
throw new Error("The power must be a natural number");
|
|
2246
2246
|
}
|
|
2247
2247
|
divide(e) {
|
|
2248
|
-
if (e instanceof
|
|
2248
|
+
if (e instanceof be && this.isSameAs(e))
|
|
2249
2249
|
return this.power.subtract(e.power), this;
|
|
2250
|
-
const t = new
|
|
2250
|
+
const t = new N(e);
|
|
2251
2251
|
if (this.isSameAs(t))
|
|
2252
2252
|
return this.power.subtract(1), this;
|
|
2253
2253
|
throw new Error("The two factors must be the same");
|
|
@@ -2269,21 +2269,21 @@ const ve = class ve {
|
|
|
2269
2269
|
}
|
|
2270
2270
|
isSameAs(e) {
|
|
2271
2271
|
let t;
|
|
2272
|
-
return e instanceof
|
|
2272
|
+
return e instanceof be ? t = e.polynom : e instanceof N ? t = e : t = new N(e), this.polynom.isEqual(t);
|
|
2273
2273
|
}
|
|
2274
2274
|
isZero() {
|
|
2275
2275
|
return this.polynom.isZero();
|
|
2276
2276
|
}
|
|
2277
2277
|
multiply(e) {
|
|
2278
|
-
if (e instanceof
|
|
2278
|
+
if (e instanceof be && this.isSameAs(e))
|
|
2279
2279
|
return this.power.add(e.power), this;
|
|
2280
|
-
const t = new
|
|
2280
|
+
const t = new N(e);
|
|
2281
2281
|
if (this.isSameAs(t))
|
|
2282
2282
|
return this.power.add(1), this;
|
|
2283
2283
|
throw new Error("The two factors must be the same");
|
|
2284
2284
|
}
|
|
2285
2285
|
one() {
|
|
2286
|
-
return s(this, Ae).one(), s(this,
|
|
2286
|
+
return s(this, Ae).one(), s(this, xe).one(), this;
|
|
2287
2287
|
}
|
|
2288
2288
|
opposite() {
|
|
2289
2289
|
throw new Error("Method not implemented.");
|
|
@@ -2298,10 +2298,10 @@ const ve = class ve {
|
|
|
2298
2298
|
return this.power.multiply(e), this;
|
|
2299
2299
|
}
|
|
2300
2300
|
get power() {
|
|
2301
|
-
return s(this,
|
|
2301
|
+
return s(this, xe);
|
|
2302
2302
|
}
|
|
2303
2303
|
set power(e) {
|
|
2304
|
-
h(this,
|
|
2304
|
+
h(this, xe, new u(e));
|
|
2305
2305
|
}
|
|
2306
2306
|
primitive() {
|
|
2307
2307
|
throw new Error("Method not implemented.");
|
|
@@ -2320,45 +2320,45 @@ const ve = class ve {
|
|
|
2320
2320
|
}
|
|
2321
2321
|
tableOfSigns() {
|
|
2322
2322
|
const e = this.power.clone().reduce(), t = this.polynom.tableOfSigns();
|
|
2323
|
-
return e.isStrictlyNegative() && (t.signs =
|
|
2323
|
+
return e.isStrictlyNegative() && (t.signs = Ct(t.signs, "z", "d")), e.denominator % 2 === 0 ? t.signs = Ct(t.signs, "-", "h") : e.numerator % 2 === 0 && (t.signs = Ct(t.signs, "-", "+")), { roots: t.roots, signs: t.signs };
|
|
2324
2324
|
}
|
|
2325
2325
|
get variables() {
|
|
2326
2326
|
return this.polynom.variables;
|
|
2327
2327
|
}
|
|
2328
2328
|
get withPower() {
|
|
2329
|
-
return h(this,
|
|
2329
|
+
return h(this, Ce, 1), this;
|
|
2330
2330
|
}
|
|
2331
2331
|
get withRoot() {
|
|
2332
|
-
return h(this,
|
|
2332
|
+
return h(this, Ce, 0), this;
|
|
2333
2333
|
}
|
|
2334
2334
|
zero() {
|
|
2335
|
-
return s(this, Ae).zero(), s(this,
|
|
2335
|
+
return s(this, Ae).zero(), s(this, xe).one(), this;
|
|
2336
2336
|
}
|
|
2337
2337
|
};
|
|
2338
|
-
|
|
2339
|
-
let se =
|
|
2340
|
-
var
|
|
2341
|
-
const
|
|
2338
|
+
Ce = new WeakMap(), Ae = new WeakMap(), xe = new WeakMap(), nt = new WeakMap();
|
|
2339
|
+
let se = be;
|
|
2340
|
+
var dt = /* @__PURE__ */ ((o) => (o[o.ROOT = 0] = "ROOT", o[o.POWER = 1] = "POWER", o))(dt || {}), Z, Se, Yt, Qt;
|
|
2341
|
+
const Ke = class Ke {
|
|
2342
2342
|
constructor(...e) {
|
|
2343
|
-
m(this,
|
|
2343
|
+
m(this, Z);
|
|
2344
2344
|
// Determine the letters in the linear system, usually ['x', 'y']
|
|
2345
|
-
m(this,
|
|
2346
|
-
a(this, "parse", (...e) => (h(this,
|
|
2347
|
-
a(this, "clone", () => new
|
|
2345
|
+
m(this, Se);
|
|
2346
|
+
a(this, "parse", (...e) => (h(this, Z, e.map((t) => new V(t))), s(this, Yt).call(this), this));
|
|
2347
|
+
a(this, "clone", () => new Ke().parse(...s(this, Z).map((e) => e.clone())));
|
|
2348
2348
|
a(this, "buildTex", (e, t) => {
|
|
2349
2349
|
let i, n, r = [];
|
|
2350
2350
|
const l = [];
|
|
2351
|
-
for (const
|
|
2352
|
-
r = r.concat(
|
|
2351
|
+
for (const f of e)
|
|
2352
|
+
r = r.concat(f.letters());
|
|
2353
2353
|
r = [...new Set(r)], r.sort();
|
|
2354
|
-
for (let
|
|
2355
|
-
const d = e[
|
|
2354
|
+
for (let f = 0; f < e.length; f++) {
|
|
2355
|
+
const d = e[f];
|
|
2356
2356
|
i = [];
|
|
2357
2357
|
for (const p of r)
|
|
2358
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[
|
|
2359
|
+
if (i.push("="), i.push(d.right.tex), (t == null ? void 0 : t[f]) !== void 0) {
|
|
2360
2360
|
i[i.length - 1] = i[i.length - 1] + " \\phantom{\\quad}";
|
|
2361
|
-
for (const p of t[
|
|
2361
|
+
for (const p of t[f])
|
|
2362
2362
|
i.push(`\\ \\cdot\\ ${p.startsWith("-") ? "\\left(" + p + "\\right)" : p}`);
|
|
2363
2363
|
}
|
|
2364
2364
|
l.push(i.join("&"));
|
|
@@ -2367,12 +2367,12 @@ const Xe = class Xe {
|
|
|
2367
2367
|
return t !== void 0 && t.length > 0 && (c = t[0].length), `\\left\\{\\begin{array}{${"r".repeat(r.length)}cl ${"|l".repeat(c)}}${l.join("\\\\ ")}\\end{array}\\right.`;
|
|
2368
2368
|
});
|
|
2369
2369
|
a(this, "mergeEquations", (e, t, i, n) => {
|
|
2370
|
-
const r = e.clone().multiply(new
|
|
2370
|
+
const r = e.clone().multiply(new u(i)), l = t.clone().multiply(new u(n));
|
|
2371
2371
|
return r.left.add(l.left), r.right.add(l.right), r;
|
|
2372
2372
|
});
|
|
2373
2373
|
// ------------------------------------------
|
|
2374
2374
|
a(this, "reorder", () => {
|
|
2375
|
-
for (const e of s(this,
|
|
2375
|
+
for (const e of s(this, Z))
|
|
2376
2376
|
e.reorder();
|
|
2377
2377
|
return this;
|
|
2378
2378
|
});
|
|
@@ -2381,9 +2381,9 @@ const Xe = class Xe {
|
|
|
2381
2381
|
for (let n = 0; n < e.length; n++) {
|
|
2382
2382
|
let r = i[n][n].clone();
|
|
2383
2383
|
if (r.isZero()) {
|
|
2384
|
-
const l = i.find((c,
|
|
2384
|
+
const l = i.find((c, f) => f > n && !c[n].isZero());
|
|
2385
2385
|
if (l)
|
|
2386
|
-
i[n].forEach((c,
|
|
2386
|
+
i[n].forEach((c, f) => c.add(l[f])), r = i[n][n].clone();
|
|
2387
2387
|
else
|
|
2388
2388
|
throw new Error("Unsolvable...");
|
|
2389
2389
|
}
|
|
@@ -2392,18 +2392,18 @@ const Xe = class Xe {
|
|
|
2392
2392
|
if (l === n)
|
|
2393
2393
|
continue;
|
|
2394
2394
|
const c = i[l][n].clone().opposite();
|
|
2395
|
-
for (let
|
|
2396
|
-
i[l][
|
|
2397
|
-
if (i[l].slice(0, i[l].length - 1).every((
|
|
2398
|
-
return i[l][i[l].length - 1].isZero() ? [new
|
|
2395
|
+
for (let f = 0; f < i[l].length; f++)
|
|
2396
|
+
i[l][f].add(i[n][f].clone().multiply(c));
|
|
2397
|
+
if (i[l].slice(0, i[l].length - 1).every((f) => f.isZero()))
|
|
2398
|
+
return i[l][i[l].length - 1].isZero() ? [new u().infinite()] : [];
|
|
2399
2399
|
}
|
|
2400
2400
|
}
|
|
2401
2401
|
return i.map((n) => n[n.length - 1]);
|
|
2402
2402
|
});
|
|
2403
|
-
m(this,
|
|
2404
|
-
m(this,
|
|
2403
|
+
m(this, Yt, () => (h(this, Se, s(this, Z).reduce((e, t) => [.../* @__PURE__ */ new Set([...e, ...t.variables])], [])), s(this, Se).sort(), this));
|
|
2404
|
+
m(this, Qt, () => {
|
|
2405
2405
|
const e = [], t = [];
|
|
2406
|
-
for (const i of s(this,
|
|
2406
|
+
for (const i of s(this, Z)) {
|
|
2407
2407
|
const n = [], r = i.clone().reorder();
|
|
2408
2408
|
for (const l of this.variables) {
|
|
2409
2409
|
const c = r.left.monomByLetter(l);
|
|
@@ -2413,74 +2413,74 @@ const Xe = class Xe {
|
|
|
2413
2413
|
}
|
|
2414
2414
|
return [e, t];
|
|
2415
2415
|
});
|
|
2416
|
-
return h(this,
|
|
2416
|
+
return h(this, Z, []), h(this, Se, []), e.length > 0 && this.parse(...e), this;
|
|
2417
2417
|
}
|
|
2418
2418
|
static fromMatrix(e, t = "xyz") {
|
|
2419
2419
|
const i = e[0].length;
|
|
2420
2420
|
if (e.some((r) => r.length !== i))
|
|
2421
2421
|
throw new Error("All rows must have the same number of columns");
|
|
2422
2422
|
const n = t.split("").splice(0, i - 1);
|
|
2423
|
-
return new
|
|
2423
|
+
return new Ke(
|
|
2424
2424
|
...e.map((r) => {
|
|
2425
|
-
const l = new
|
|
2426
|
-
return new
|
|
2425
|
+
const l = new N(n.join(""), ...r);
|
|
2426
|
+
return new V(l, 0);
|
|
2427
2427
|
})
|
|
2428
2428
|
);
|
|
2429
2429
|
}
|
|
2430
2430
|
add(e, t) {
|
|
2431
|
-
if (e instanceof
|
|
2431
|
+
if (e instanceof Ke) {
|
|
2432
2432
|
const i = e.equations.length;
|
|
2433
|
-
if (i !== s(this,
|
|
2433
|
+
if (i !== s(this, Z).length)
|
|
2434
2434
|
throw new Error("The number of equations must be the same");
|
|
2435
2435
|
for (let n = 0; n < i; n++)
|
|
2436
|
-
s(this,
|
|
2436
|
+
s(this, Z)[n].add(e.equations[n]);
|
|
2437
2437
|
} else {
|
|
2438
|
-
if (t === void 0 || t < 0 || t >= s(this,
|
|
2438
|
+
if (t === void 0 || t < 0 || t >= s(this, Z).length)
|
|
2439
2439
|
throw new Error("Index out of range");
|
|
2440
|
-
const i = new
|
|
2441
|
-
s(this,
|
|
2440
|
+
const i = new V(e);
|
|
2441
|
+
s(this, Z)[t].add(i);
|
|
2442
2442
|
}
|
|
2443
2443
|
return this;
|
|
2444
2444
|
}
|
|
2445
2445
|
degree(e) {
|
|
2446
|
-
return
|
|
2446
|
+
return u.max(...s(this, Z).map((t) => t.degree(e)));
|
|
2447
2447
|
}
|
|
2448
2448
|
get display() {
|
|
2449
2449
|
return this.tex + "as display";
|
|
2450
2450
|
}
|
|
2451
2451
|
// ------------------------------------------
|
|
2452
2452
|
get equations() {
|
|
2453
|
-
return s(this,
|
|
2453
|
+
return s(this, Z);
|
|
2454
2454
|
}
|
|
2455
2455
|
set equations(e) {
|
|
2456
|
-
h(this,
|
|
2456
|
+
h(this, Z, e);
|
|
2457
2457
|
}
|
|
2458
2458
|
evaluate(e, t) {
|
|
2459
2459
|
throw new Error("Method not implemented.");
|
|
2460
2460
|
}
|
|
2461
2461
|
hasVariable(e) {
|
|
2462
|
-
return s(this,
|
|
2462
|
+
return s(this, Se).includes(e);
|
|
2463
2463
|
}
|
|
2464
2464
|
isEqual(e) {
|
|
2465
2465
|
return this.equations.every((t, i) => t.isEqual(e.equations[i]));
|
|
2466
2466
|
}
|
|
2467
2467
|
get isSolvable() {
|
|
2468
|
-
return this.variables.length === s(this,
|
|
2468
|
+
return this.variables.length === s(this, Z).length;
|
|
2469
2469
|
}
|
|
2470
2470
|
get matrix() {
|
|
2471
|
-
return s(this,
|
|
2471
|
+
return s(this, Qt).call(this);
|
|
2472
2472
|
}
|
|
2473
2473
|
multiply(e, t) {
|
|
2474
2474
|
if (Array.isArray(e)) {
|
|
2475
|
-
if (e.length !== s(this,
|
|
2475
|
+
if (e.length !== s(this, Z).length)
|
|
2476
2476
|
throw new Error("The number of values must be the same as the number of equations");
|
|
2477
2477
|
for (let i = 0; i < e.length; i++)
|
|
2478
|
-
s(this,
|
|
2478
|
+
s(this, Z)[i].multiply(e[i]);
|
|
2479
2479
|
return this;
|
|
2480
2480
|
}
|
|
2481
|
-
if (t === void 0 || t < 0 || t >= s(this,
|
|
2481
|
+
if (t === void 0 || t < 0 || t >= s(this, Z).length)
|
|
2482
2482
|
throw new Error("Index out of range");
|
|
2483
|
-
return s(this,
|
|
2483
|
+
return s(this, Z)[t].multiply(e), this;
|
|
2484
2484
|
}
|
|
2485
2485
|
reduce() {
|
|
2486
2486
|
throw new Error("Method not implemented.");
|
|
@@ -2489,17 +2489,17 @@ const Xe = class Xe {
|
|
|
2489
2489
|
return [];
|
|
2490
2490
|
}
|
|
2491
2491
|
subtract(e, t) {
|
|
2492
|
-
if (e instanceof
|
|
2492
|
+
if (e instanceof Ke) {
|
|
2493
2493
|
const i = e.equations.length;
|
|
2494
|
-
if (i !== s(this,
|
|
2494
|
+
if (i !== s(this, Z).length)
|
|
2495
2495
|
throw new Error("The number of equations must be the same");
|
|
2496
2496
|
for (let n = 0; n < i; n++)
|
|
2497
|
-
s(this,
|
|
2497
|
+
s(this, Z)[n].subtract(e.equations[n]);
|
|
2498
2498
|
} else {
|
|
2499
|
-
if (t === void 0 || t < 0 || t >= s(this,
|
|
2499
|
+
if (t === void 0 || t < 0 || t >= s(this, Z).length)
|
|
2500
2500
|
throw new Error("Index out of range");
|
|
2501
|
-
const i = new
|
|
2502
|
-
s(this,
|
|
2501
|
+
const i = new V(e);
|
|
2502
|
+
s(this, Z)[t].subtract(i);
|
|
2503
2503
|
}
|
|
2504
2504
|
return this;
|
|
2505
2505
|
}
|
|
@@ -2508,33 +2508,33 @@ const Xe = class Xe {
|
|
|
2508
2508
|
return this.buildTex(e.equations);
|
|
2509
2509
|
}
|
|
2510
2510
|
get variables() {
|
|
2511
|
-
return s(this,
|
|
2511
|
+
return s(this, Se);
|
|
2512
2512
|
}
|
|
2513
2513
|
set variables(e) {
|
|
2514
2514
|
const t = typeof e == "string" ? e.split("") : [...e];
|
|
2515
|
-
t.sort(), h(this,
|
|
2515
|
+
t.sort(), h(this, Se, t);
|
|
2516
2516
|
}
|
|
2517
2517
|
};
|
|
2518
|
-
|
|
2519
|
-
let
|
|
2520
|
-
var
|
|
2521
|
-
class
|
|
2518
|
+
Z = new WeakMap(), Se = new WeakMap(), Yt = new WeakMap(), Qt = new WeakMap();
|
|
2519
|
+
let hi = Ke;
|
|
2520
|
+
var ke, vt, ai;
|
|
2521
|
+
class fs {
|
|
2522
2522
|
/**
|
|
2523
2523
|
*
|
|
2524
2524
|
* @param {string} value (optional) Default polynom to parse on class creation
|
|
2525
2525
|
*/
|
|
2526
2526
|
constructor(e) {
|
|
2527
|
-
m(this,
|
|
2528
|
-
m(this,
|
|
2529
|
-
a(this, "parse", (e) => (h(this,
|
|
2530
|
-
return h(this,
|
|
2527
|
+
m(this, vt);
|
|
2528
|
+
m(this, ke);
|
|
2529
|
+
a(this, "parse", (e) => (h(this, ke, new si(Ue.SET).parse(e).rpn), this));
|
|
2530
|
+
return h(this, ke, []), e !== void 0 && this.parse(e), this;
|
|
2531
2531
|
}
|
|
2532
2532
|
evaluate(e) {
|
|
2533
2533
|
this.variables.forEach((i) => {
|
|
2534
2534
|
Object.hasOwn(e, i) || (e[i] = !1);
|
|
2535
2535
|
});
|
|
2536
2536
|
const t = [];
|
|
2537
|
-
for (const i of s(this,
|
|
2537
|
+
for (const i of s(this, ke))
|
|
2538
2538
|
if (console.log(i), i.tokenType === "variable")
|
|
2539
2539
|
t.push(e[i.token]);
|
|
2540
2540
|
else if (i.tokenType === "operation")
|
|
@@ -2563,11 +2563,11 @@ class ss {
|
|
|
2563
2563
|
return t.length === 1 && t[0];
|
|
2564
2564
|
}
|
|
2565
2565
|
get rpn() {
|
|
2566
|
-
return s(this,
|
|
2566
|
+
return s(this, ke);
|
|
2567
2567
|
}
|
|
2568
2568
|
get tex() {
|
|
2569
2569
|
const e = [];
|
|
2570
|
-
for (const t of s(this,
|
|
2570
|
+
for (const t of s(this, ke))
|
|
2571
2571
|
if (t.tokenType === "variable")
|
|
2572
2572
|
e.push(t);
|
|
2573
2573
|
else
|
|
@@ -2600,23 +2600,23 @@ class ss {
|
|
|
2600
2600
|
return e[0].token;
|
|
2601
2601
|
}
|
|
2602
2602
|
get variables() {
|
|
2603
|
-
return s(this,
|
|
2603
|
+
return s(this, ke).filter((e) => e.tokenType === "variable").map((e) => e.token);
|
|
2604
2604
|
}
|
|
2605
2605
|
vennAB() {
|
|
2606
|
-
return A(this,
|
|
2606
|
+
return A(this, vt, ai).call(this, {
|
|
2607
2607
|
A: ["A", "AB"],
|
|
2608
2608
|
B: ["B", "AB"]
|
|
2609
2609
|
}, ["A", "B", "AB", "E"]);
|
|
2610
2610
|
}
|
|
2611
2611
|
vennABC() {
|
|
2612
|
-
return A(this,
|
|
2612
|
+
return A(this, vt, ai).call(this, {
|
|
2613
2613
|
A: ["A", "AB", "AC", "ABC"],
|
|
2614
2614
|
B: ["B", "AB", "BC", "ABC"],
|
|
2615
2615
|
C: ["C", "AC", "BC", "ABC"]
|
|
2616
2616
|
}, ["A", "B", "C", "AB", "AC", "BC", "ABC", "E"]);
|
|
2617
2617
|
}
|
|
2618
2618
|
}
|
|
2619
|
-
|
|
2619
|
+
ke = new WeakMap(), vt = new WeakSet(), ai = function(e, t) {
|
|
2620
2620
|
const i = [];
|
|
2621
2621
|
let n;
|
|
2622
2622
|
if (t === void 0) {
|
|
@@ -2628,7 +2628,7 @@ Oe = new WeakMap(), mt = new WeakSet(), ii = function(e, t) {
|
|
|
2628
2628
|
]);
|
|
2629
2629
|
} else
|
|
2630
2630
|
n = new Set(t);
|
|
2631
|
-
for (const r of s(this,
|
|
2631
|
+
for (const r of s(this, ke))
|
|
2632
2632
|
if (r.tokenType === "variable")
|
|
2633
2633
|
e[r.token] === void 0 ? i.push(/* @__PURE__ */ new Set()) : i.push(new Set(e[r.token]));
|
|
2634
2634
|
else
|
|
@@ -2636,7 +2636,7 @@ Oe = new WeakMap(), mt = new WeakSet(), ii = function(e, t) {
|
|
|
2636
2636
|
case "&":
|
|
2637
2637
|
if (i.length >= 2) {
|
|
2638
2638
|
const l = i.pop(), c = i.pop();
|
|
2639
|
-
c && l && i.push(new Set([...c].filter((
|
|
2639
|
+
c && l && i.push(new Set([...c].filter((f) => l.has(f))));
|
|
2640
2640
|
}
|
|
2641
2641
|
break;
|
|
2642
2642
|
case "|":
|
|
@@ -2648,7 +2648,7 @@ Oe = new WeakMap(), mt = new WeakSet(), ii = function(e, t) {
|
|
|
2648
2648
|
case "-":
|
|
2649
2649
|
if (i.length >= 2) {
|
|
2650
2650
|
const l = i.pop(), c = i.pop();
|
|
2651
|
-
c && l && i.push(new Set([...c].filter((
|
|
2651
|
+
c && l && i.push(new Set([...c].filter((f) => !l.has(f))));
|
|
2652
2652
|
}
|
|
2653
2653
|
break;
|
|
2654
2654
|
case "!":
|
|
@@ -2660,31 +2660,31 @@ Oe = new WeakMap(), mt = new WeakSet(), ii = function(e, t) {
|
|
|
2660
2660
|
}
|
|
2661
2661
|
return [...i[0]].sort();
|
|
2662
2662
|
};
|
|
2663
|
-
var
|
|
2664
|
-
const
|
|
2663
|
+
var rt, q, Ye, ci, zi, bt, ui;
|
|
2664
|
+
const Y = class Y {
|
|
2665
2665
|
constructor(...e) {
|
|
2666
|
-
m(this,
|
|
2667
|
-
m(this,
|
|
2668
|
-
m(this,
|
|
2666
|
+
m(this, bt);
|
|
2667
|
+
m(this, rt, dt.POWER);
|
|
2668
|
+
m(this, q, []);
|
|
2669
2669
|
return this.parse(...e), this;
|
|
2670
2670
|
}
|
|
2671
2671
|
parse(...e) {
|
|
2672
|
-
return h(this,
|
|
2673
|
-
t instanceof
|
|
2672
|
+
return h(this, q, []), e.length === 0 ? this : (e.forEach((t) => {
|
|
2673
|
+
t instanceof Y ? s(this, q).push(...t.factors.map((i) => i.clone())) : s(this, q).push(new se(t));
|
|
2674
2674
|
}), this);
|
|
2675
2675
|
}
|
|
2676
2676
|
clone() {
|
|
2677
|
-
return new
|
|
2677
|
+
return new Y(...s(this, q).map((e) => e.clone()));
|
|
2678
2678
|
}
|
|
2679
2679
|
get tex() {
|
|
2680
|
-
const { num: e, den: t } = A(this,
|
|
2680
|
+
const { num: e, den: t } = A(this, bt, ui).call(this);
|
|
2681
2681
|
if (t.length === 0)
|
|
2682
2682
|
return e.length === 1 ? e[0].asSingle.tex : e.map((r) => r.tex).join("");
|
|
2683
2683
|
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("");
|
|
2684
2684
|
return `\\frac{ ${i} }{ ${n} }`;
|
|
2685
2685
|
}
|
|
2686
2686
|
get display() {
|
|
2687
|
-
const { num: e, den: t } = A(this,
|
|
2687
|
+
const { num: e, den: t } = A(this, bt, ui).call(this);
|
|
2688
2688
|
if (t.length === 0)
|
|
2689
2689
|
return e.length === 1 ? e[0].asSingle.display : e.map(
|
|
2690
2690
|
(r, l) => l === 0 && r.polynom.monoms.length === 1 ? r.asSingle.display : r.display
|
|
@@ -2695,117 +2695,117 @@ const X = class X {
|
|
|
2695
2695
|
static gcd(...e) {
|
|
2696
2696
|
var i;
|
|
2697
2697
|
if (e.length === 0)
|
|
2698
|
-
return new
|
|
2698
|
+
return new Y().one();
|
|
2699
2699
|
if (e.length === 1)
|
|
2700
2700
|
return e[0];
|
|
2701
2701
|
if (e.length === 2)
|
|
2702
|
-
return A(i =
|
|
2702
|
+
return A(i = Y, Ye, ci).call(i, e[0], e[1]);
|
|
2703
2703
|
let t = e[0];
|
|
2704
2704
|
return e.shift(), e.forEach((n) => {
|
|
2705
2705
|
var r;
|
|
2706
|
-
return t = A(r =
|
|
2706
|
+
return t = A(r = Y, Ye, ci).call(r, t, n);
|
|
2707
2707
|
}), t;
|
|
2708
2708
|
}
|
|
2709
2709
|
static lcm(...e) {
|
|
2710
2710
|
if (e.length === 0)
|
|
2711
|
-
return new
|
|
2711
|
+
return new Y().one();
|
|
2712
2712
|
if (e.length === 1)
|
|
2713
2713
|
return e[0];
|
|
2714
2714
|
let t = e[0];
|
|
2715
2715
|
return e.shift(), e.forEach((i) => {
|
|
2716
2716
|
var n;
|
|
2717
|
-
return t = A(n =
|
|
2717
|
+
return t = A(n = Y, Ye, zi).call(n, t, i);
|
|
2718
2718
|
}), t;
|
|
2719
2719
|
}
|
|
2720
2720
|
add(...e) {
|
|
2721
2721
|
const t = [this.numerator, ...e.map((c) => c.numerator)], i = [this.denominator, ...e.map((c) => c.denominator)];
|
|
2722
2722
|
let n;
|
|
2723
2723
|
if (i.some((c) => c.factors.length > 0)) {
|
|
2724
|
-
const c =
|
|
2725
|
-
t.forEach((
|
|
2726
|
-
|
|
2724
|
+
const c = Y.lcm(...i);
|
|
2725
|
+
t.forEach((f, d) => {
|
|
2726
|
+
f.multiply(c.clone().divide(i[d]));
|
|
2727
2727
|
}), n = c;
|
|
2728
2728
|
}
|
|
2729
|
-
const r =
|
|
2729
|
+
const r = Y.gcd(...t), l = new N(0).add(
|
|
2730
2730
|
...t.map((c) => c.divide(r).reduce().develop().factors[0].polynom)
|
|
2731
2731
|
).reduce();
|
|
2732
|
-
return h(this,
|
|
2732
|
+
return h(this, q, [
|
|
2733
2733
|
...r.factors,
|
|
2734
2734
|
new se(l)
|
|
2735
|
-
]), n && this.divide(n), h(this,
|
|
2735
|
+
]), n && this.divide(n), h(this, q, s(this, q).filter((c) => !c.power.isZero())), this;
|
|
2736
2736
|
}
|
|
2737
2737
|
get asPower() {
|
|
2738
|
-
return h(this,
|
|
2738
|
+
return h(this, rt, dt.POWER), this;
|
|
2739
2739
|
}
|
|
2740
2740
|
get asRoot() {
|
|
2741
|
-
return h(this,
|
|
2741
|
+
return h(this, rt, dt.ROOT), this;
|
|
2742
2742
|
}
|
|
2743
2743
|
degree(e) {
|
|
2744
|
-
return s(this,
|
|
2744
|
+
return s(this, q).reduce((t, i) => t.add(i.degree(e)), new u("0"));
|
|
2745
2745
|
}
|
|
2746
2746
|
get denominator() {
|
|
2747
|
-
return new
|
|
2748
|
-
...s(this,
|
|
2747
|
+
return new Y(
|
|
2748
|
+
...s(this, q).filter((e) => e.power.isNegative()).map((e) => e.clone().inverse())
|
|
2749
2749
|
);
|
|
2750
2750
|
}
|
|
2751
2751
|
derivative() {
|
|
2752
|
-
const e = [], t = s(this,
|
|
2752
|
+
const e = [], t = s(this, q).length;
|
|
2753
2753
|
for (let n = 0; n < t; n++) {
|
|
2754
|
-
const r = s(this,
|
|
2754
|
+
const r = s(this, q).slice(), l = r.splice(n, 1)[0].derivative();
|
|
2755
2755
|
e.push(
|
|
2756
|
-
new
|
|
2756
|
+
new Y(...r, ...l)
|
|
2757
2757
|
);
|
|
2758
2758
|
}
|
|
2759
2759
|
e.forEach((n) => n.reduce());
|
|
2760
2760
|
const i = e.shift();
|
|
2761
|
-
return i !== void 0 && h(this,
|
|
2761
|
+
return i !== void 0 && h(this, q, i.factors), this.add(...e);
|
|
2762
2762
|
}
|
|
2763
2763
|
develop() {
|
|
2764
|
-
const e = new
|
|
2764
|
+
const e = new N("1"), t = new N("1");
|
|
2765
2765
|
return this.numerator.factors.forEach((i) => {
|
|
2766
2766
|
e.multiply(i.develop());
|
|
2767
2767
|
}), this.denominator.factors.forEach((i) => {
|
|
2768
2768
|
t.multiply(i.develop());
|
|
2769
|
-
}), new
|
|
2769
|
+
}), new Y().fromPolynom(e, t);
|
|
2770
2770
|
}
|
|
2771
2771
|
divide(e) {
|
|
2772
|
-
return h(this,
|
|
2772
|
+
return h(this, q, s(this, q).concat(e.clone().factors.map((t) => t.inverse()))), this;
|
|
2773
2773
|
}
|
|
2774
2774
|
evaluate(e, t) {
|
|
2775
|
-
return t ? s(this,
|
|
2775
|
+
return t ? s(this, q).reduce((i, n) => i * n.evaluate(e, t), 1) : s(this, q).reduce((i, n) => i.multiply(n.evaluate(e)), new u("1"));
|
|
2776
2776
|
}
|
|
2777
2777
|
factorize(e) {
|
|
2778
2778
|
const t = [];
|
|
2779
|
-
s(this,
|
|
2779
|
+
s(this, q).forEach((l) => {
|
|
2780
2780
|
const c = l.polynom.factorize(e);
|
|
2781
2781
|
if (c.length > 1) {
|
|
2782
|
-
const
|
|
2783
|
-
t.push(...c.map((d) => new se(d,
|
|
2782
|
+
const f = l.power.clone();
|
|
2783
|
+
t.push(...c.map((d) => new se(d, f)));
|
|
2784
2784
|
} else
|
|
2785
2785
|
t.push(l.clone());
|
|
2786
2786
|
});
|
|
2787
|
-
const i = new
|
|
2787
|
+
const i = new Y(...t), n = i.numerator.reduce(), r = i.denominator.reduce();
|
|
2788
2788
|
return n.divide(r);
|
|
2789
2789
|
}
|
|
2790
2790
|
get factors() {
|
|
2791
|
-
return s(this,
|
|
2791
|
+
return s(this, q);
|
|
2792
2792
|
}
|
|
2793
2793
|
set factors(e) {
|
|
2794
|
-
h(this,
|
|
2794
|
+
h(this, q, e);
|
|
2795
2795
|
}
|
|
2796
2796
|
fromPolynom(e, t) {
|
|
2797
|
-
if (h(this,
|
|
2798
|
-
const i = new
|
|
2797
|
+
if (h(this, q, [new se(new N(e))]), t) {
|
|
2798
|
+
const i = new N(t);
|
|
2799
2799
|
if (i.isOne())
|
|
2800
2800
|
return this;
|
|
2801
2801
|
if (i.isZero())
|
|
2802
2802
|
throw new Error("Cannot divide by zero");
|
|
2803
|
-
s(this,
|
|
2803
|
+
s(this, q).push(new se(i, -1));
|
|
2804
2804
|
}
|
|
2805
2805
|
return this;
|
|
2806
2806
|
}
|
|
2807
2807
|
getZeroes() {
|
|
2808
|
-
const e = [].concat(...s(this,
|
|
2808
|
+
const e = [].concat(...s(this, q).map((t) => t.polynom.getZeroes()));
|
|
2809
2809
|
return e.sort((t, i) => t.value - i.value), e.filter(
|
|
2810
2810
|
(t, i, n) => i === n.findIndex(
|
|
2811
2811
|
(r) => r.value === t.value
|
|
@@ -2813,51 +2813,51 @@ const X = class X {
|
|
|
2813
2813
|
);
|
|
2814
2814
|
}
|
|
2815
2815
|
hasVariable(e) {
|
|
2816
|
-
return s(this,
|
|
2816
|
+
return s(this, q).some((t) => t.hasVariable(e));
|
|
2817
2817
|
}
|
|
2818
2818
|
inverse() {
|
|
2819
|
-
return h(this,
|
|
2819
|
+
return h(this, q, s(this, q).map((e) => e.inverse())), this;
|
|
2820
2820
|
}
|
|
2821
2821
|
isEqual(e) {
|
|
2822
|
-
const t =
|
|
2822
|
+
const t = Y.gcd(this, e), i = this.clone().divide(t).reduce(), n = e.clone().divide(t).reduce();
|
|
2823
2823
|
return i.isOne() && n.isOne();
|
|
2824
2824
|
}
|
|
2825
2825
|
isOne() {
|
|
2826
|
-
return s(this,
|
|
2826
|
+
return s(this, q).every((e) => e.isOne());
|
|
2827
2827
|
}
|
|
2828
2828
|
isZero() {
|
|
2829
|
-
return s(this,
|
|
2829
|
+
return s(this, q).every((e) => e.isZero());
|
|
2830
2830
|
}
|
|
2831
2831
|
multiply(...e) {
|
|
2832
2832
|
return e.forEach((t) => {
|
|
2833
|
-
h(this,
|
|
2833
|
+
h(this, q, s(this, q).concat(t.clone().factors));
|
|
2834
2834
|
}), this;
|
|
2835
2835
|
}
|
|
2836
2836
|
get numerator() {
|
|
2837
|
-
return new
|
|
2837
|
+
return new Y(...s(this, q).filter((e) => e.power.isPositive()));
|
|
2838
2838
|
}
|
|
2839
2839
|
one() {
|
|
2840
|
-
return h(this,
|
|
2840
|
+
return h(this, q, [new se("1", "1")]), this;
|
|
2841
2841
|
}
|
|
2842
2842
|
opposite() {
|
|
2843
|
-
const e = s(this,
|
|
2844
|
-
return e >= 0 ? s(this,
|
|
2843
|
+
const e = s(this, q).findIndex((t) => t.display === "(-1)");
|
|
2844
|
+
return e >= 0 ? s(this, q).splice(e, 1) : s(this, q).push(new se("-1", "1")), this;
|
|
2845
2845
|
}
|
|
2846
2846
|
pow(e) {
|
|
2847
|
-
return h(this,
|
|
2847
|
+
return h(this, q, s(this, q).map((t) => t.pow(e))), this;
|
|
2848
2848
|
}
|
|
2849
2849
|
primitive() {
|
|
2850
2850
|
throw new Error("Method not implemented.");
|
|
2851
2851
|
}
|
|
2852
2852
|
reduce() {
|
|
2853
|
-
const e =
|
|
2854
|
-
return h(this,
|
|
2855
|
-
const i = t[0].polynom, n = t.reduce((r, l) => r.add(l.power), new
|
|
2853
|
+
const e = ut(this);
|
|
2854
|
+
return h(this, q, Object.values(e).map((t) => {
|
|
2855
|
+
const i = t[0].polynom, n = t.reduce((r, l) => r.add(l.power), new u("0"));
|
|
2856
2856
|
return new se(i, n.reduce());
|
|
2857
2857
|
}).filter((t) => !t.power.isZero())), this;
|
|
2858
2858
|
}
|
|
2859
2859
|
root(e) {
|
|
2860
|
-
return h(this,
|
|
2860
|
+
return h(this, q, s(this, q).map((t) => t.root(e))), this;
|
|
2861
2861
|
}
|
|
2862
2862
|
/**
|
|
2863
2863
|
* Reoarder the factors using :
|
|
@@ -2866,19 +2866,19 @@ const X = class X {
|
|
|
2866
2866
|
* 3. power of polyfactor
|
|
2867
2867
|
*/
|
|
2868
2868
|
sort(e) {
|
|
2869
|
-
return s(this,
|
|
2869
|
+
return s(this, q).sort((t, i) => {
|
|
2870
2870
|
const n = t.power.value, r = i.power.value;
|
|
2871
2871
|
if (n * r < 0)
|
|
2872
2872
|
return -n;
|
|
2873
2873
|
const l = t.polynom.monoms.length, c = i.polynom.monoms.length;
|
|
2874
2874
|
if (l !== c)
|
|
2875
2875
|
return l - c;
|
|
2876
|
-
const
|
|
2877
|
-
return
|
|
2876
|
+
const f = t.polynom.degree(e).value, d = i.polynom.degree(e).value;
|
|
2877
|
+
return f !== d ? f - d : n !== r ? n - r : t.degree().isLeq(i.degree()) ? -1 : 1;
|
|
2878
2878
|
}), this;
|
|
2879
2879
|
}
|
|
2880
2880
|
sqrt() {
|
|
2881
|
-
return h(this,
|
|
2881
|
+
return h(this, q, s(this, q).map((e) => e.sqrt())), this;
|
|
2882
2882
|
}
|
|
2883
2883
|
subtract(...e) {
|
|
2884
2884
|
return this.add(...e.map((t) => t.opposite()));
|
|
@@ -2887,72 +2887,72 @@ const X = class X {
|
|
|
2887
2887
|
const e = this.getZeroes(), t = e.map((r) => r.value), i = this.factors.map((r) => ({ factor: new se(r), ...r.tableOfSigns() }));
|
|
2888
2888
|
return i.forEach((r) => {
|
|
2889
2889
|
const l = new Array(2 * e.length + 1).fill("");
|
|
2890
|
-
let c = r.signs.shift(),
|
|
2890
|
+
let c = r.signs.shift(), f = r.roots.shift();
|
|
2891
2891
|
const d = l.map((p, w) => {
|
|
2892
2892
|
if (w % 2 === 0)
|
|
2893
2893
|
return c;
|
|
2894
|
-
if (
|
|
2894
|
+
if (f === void 0 || f.value !== t[(w - 1) / 2])
|
|
2895
2895
|
return "t";
|
|
2896
|
-
const
|
|
2897
|
-
return c = r.signs.shift(),
|
|
2896
|
+
const L = r.signs.shift();
|
|
2897
|
+
return c = r.signs.shift(), f = r.roots.shift(), L;
|
|
2898
2898
|
});
|
|
2899
2899
|
r.roots = e, r.signs = d;
|
|
2900
|
-
}), { signs: i.map((r) => r.signs).reduce((r, l) => r.length === 0 ? l : (l.forEach((c,
|
|
2900
|
+
}), { signs: i.map((r) => r.signs).reduce((r, l) => r.length === 0 ? l : (l.forEach((c, f) => {
|
|
2901
2901
|
switch (c) {
|
|
2902
2902
|
case "d":
|
|
2903
|
-
r[
|
|
2903
|
+
r[f] = "d";
|
|
2904
2904
|
break;
|
|
2905
2905
|
case "z":
|
|
2906
|
-
r[
|
|
2906
|
+
r[f] = r[f] === "d" ? "d" : "z";
|
|
2907
2907
|
break;
|
|
2908
2908
|
case "h":
|
|
2909
|
-
r[
|
|
2909
|
+
r[f] = "h";
|
|
2910
2910
|
break;
|
|
2911
2911
|
case "-":
|
|
2912
|
-
r[
|
|
2912
|
+
r[f] = r[f] === "h" ? "h" : r[f] === "-" ? "+" : "-";
|
|
2913
2913
|
break;
|
|
2914
2914
|
}
|
|
2915
2915
|
}), r), []), roots: e, factors: i };
|
|
2916
2916
|
}
|
|
2917
2917
|
get variables() {
|
|
2918
|
-
return s(this,
|
|
2918
|
+
return s(this, q).reduce((e, t) => e.concat(t.variables), []);
|
|
2919
2919
|
}
|
|
2920
2920
|
zero() {
|
|
2921
|
-
return h(this,
|
|
2921
|
+
return h(this, q, [new se("0", "1")]), this;
|
|
2922
2922
|
}
|
|
2923
2923
|
};
|
|
2924
|
-
|
|
2925
|
-
const i =
|
|
2926
|
-
const
|
|
2927
|
-
return new se(c,
|
|
2924
|
+
rt = new WeakMap(), q = new WeakMap(), Ye = new WeakSet(), ci = function(e, t) {
|
|
2925
|
+
const i = ut(e), n = ut(t), l = Object.keys(i).filter((c) => Object.hasOwn(n, c)).map((c) => {
|
|
2926
|
+
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"));
|
|
2927
|
+
return new se(c, u.min(f, d));
|
|
2928
2928
|
});
|
|
2929
|
-
return new
|
|
2930
|
-
},
|
|
2931
|
-
const i =
|
|
2932
|
-
const
|
|
2933
|
-
return new se(c,
|
|
2929
|
+
return new Y(...l);
|
|
2930
|
+
}, zi = function(e, t) {
|
|
2931
|
+
const i = ut(e), n = ut(t), l = [.../* @__PURE__ */ new Set([...Object.keys(i), ...Object.keys(n)])].map((c) => {
|
|
2932
|
+
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);
|
|
2933
|
+
return new se(c, u.max(f, d));
|
|
2934
2934
|
});
|
|
2935
|
-
return new
|
|
2936
|
-
},
|
|
2935
|
+
return new Y(...l);
|
|
2936
|
+
}, bt = new WeakSet(), ui = function() {
|
|
2937
2937
|
let e, t = [];
|
|
2938
|
-
return s(this,
|
|
2939
|
-
}, m(
|
|
2940
|
-
let
|
|
2941
|
-
function
|
|
2942
|
-
const e = new
|
|
2938
|
+
return s(this, rt) === dt.ROOT ? (e = this.numerator.factors, t = this.denominator.factors) : e = s(this, q), e.length === 0 && (e = [new se("1")]), { num: e, den: t };
|
|
2939
|
+
}, m(Y, Ye);
|
|
2940
|
+
let li = Y;
|
|
2941
|
+
function ut(o) {
|
|
2942
|
+
const e = new u().one(), t = new u().one(), i = o.factors.reduce((l, c) => {
|
|
2943
2943
|
if (c.polynom.degree().isZero())
|
|
2944
2944
|
return c.power.isPositive() ? e.multiply(c.polynom.monoms[0].coefficient) : t.multiply(c.polynom.monoms[0].coefficient), l;
|
|
2945
|
-
const
|
|
2946
|
-
return Object.hasOwn(l,
|
|
2945
|
+
const f = c.polynom.display;
|
|
2946
|
+
return Object.hasOwn(l, f) ? l[f].push(c) : l[f] = [c], l;
|
|
2947
2947
|
}, {}), { numerator: n, denominator: r } = e.divide(t).reduce();
|
|
2948
2948
|
return n !== 1 && (i[n.toString()] = [new se(n, 1)]), r !== 1 && (i[r.toString()] = [new se(r, -1)]), i;
|
|
2949
2949
|
}
|
|
2950
|
-
function
|
|
2950
|
+
function ds(o, e) {
|
|
2951
2951
|
return o.dimension === e.dimension && o.array.every(
|
|
2952
2952
|
(t, i) => e.array[i].isEqual(t)
|
|
2953
2953
|
);
|
|
2954
2954
|
}
|
|
2955
|
-
function
|
|
2955
|
+
function ps(o, e) {
|
|
2956
2956
|
if (o.dimension !== e.dimension)
|
|
2957
2957
|
return !1;
|
|
2958
2958
|
const t = e.array[0].value / o.array[0].value;
|
|
@@ -2960,13 +2960,13 @@ function rs(o, e) {
|
|
|
2960
2960
|
(i, n) => e.array[n].value === i.value * t
|
|
2961
2961
|
);
|
|
2962
2962
|
}
|
|
2963
|
-
function
|
|
2964
|
-
return o.dimension !== e.dimension ? new
|
|
2963
|
+
function ms(o, e) {
|
|
2964
|
+
return o.dimension !== e.dimension ? new u().invalid() : o.array.reduce(
|
|
2965
2965
|
(t, i, n) => t.add(i.clone().multiply(e.array[n])),
|
|
2966
|
-
new
|
|
2966
|
+
new u(0)
|
|
2967
2967
|
);
|
|
2968
2968
|
}
|
|
2969
|
-
function
|
|
2969
|
+
function gs(...o) {
|
|
2970
2970
|
if (o.some((e) => e.dimension !== o[0].dimension))
|
|
2971
2971
|
throw new Error("All vectors must have the same dimension");
|
|
2972
2972
|
if (o[0].dimension !== o.length)
|
|
@@ -2979,39 +2979,39 @@ function hs(...o) {
|
|
|
2979
2979
|
)
|
|
2980
2980
|
).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]))));
|
|
2981
2981
|
}
|
|
2982
|
-
var
|
|
2983
|
-
const
|
|
2982
|
+
var j, Ve;
|
|
2983
|
+
const De = class De {
|
|
2984
2984
|
constructor(...e) {
|
|
2985
|
-
m(this,
|
|
2986
|
-
m(this,
|
|
2987
|
-
a(this, "zero", () => (s(this,
|
|
2985
|
+
m(this, j, []);
|
|
2986
|
+
m(this, Ve, !1);
|
|
2987
|
+
a(this, "zero", () => (s(this, j).forEach((e) => e.zero()), this));
|
|
2988
2988
|
a(this, "one", () => (this.zero(), this.x.one(), this));
|
|
2989
|
-
a(this, "opposite", () => (s(this,
|
|
2990
|
-
a(this, "add", (e) => (s(this,
|
|
2989
|
+
a(this, "opposite", () => (s(this, j).forEach((e) => e.opposite()), this));
|
|
2990
|
+
a(this, "add", (e) => (s(this, j).forEach((t, i) => t.add(e.array[i])), this));
|
|
2991
2991
|
a(this, "subtract", (e) => this.add(e.clone().opposite()));
|
|
2992
2992
|
a(this, "unit", () => {
|
|
2993
2993
|
const e = this.norm;
|
|
2994
2994
|
return e === 0 ? this : this.divideByScalar(e);
|
|
2995
2995
|
});
|
|
2996
|
-
a(this, "dot", (e) =>
|
|
2996
|
+
a(this, "dot", (e) => ms(this, e));
|
|
2997
2997
|
a(this, "normal", () => {
|
|
2998
2998
|
if (this.dimension >= 3)
|
|
2999
2999
|
throw new Error("Normal vector can only be determined in 2D");
|
|
3000
3000
|
const e = this.x.clone().opposite(), t = this.y.clone();
|
|
3001
|
-
return s(this,
|
|
3001
|
+
return s(this, j)[0] = t, s(this, j)[1] = e, this;
|
|
3002
3002
|
});
|
|
3003
|
-
a(this, "isEqual", (e) =>
|
|
3004
|
-
a(this, "isColinearTo", (e) =>
|
|
3003
|
+
a(this, "isEqual", (e) => ds(this, e));
|
|
3004
|
+
a(this, "isColinearTo", (e) => ps(this, e));
|
|
3005
3005
|
a(this, "isNormalTo", (e) => this.dot(e).isZero());
|
|
3006
3006
|
a(this, "multiplyByScalar", (e) => {
|
|
3007
|
-
const t = new
|
|
3007
|
+
const t = new u(e);
|
|
3008
3008
|
return this.array.forEach((i) => i.multiply(t)), this;
|
|
3009
3009
|
});
|
|
3010
|
-
a(this, "divideByScalar", (e) => this.multiplyByScalar(new
|
|
3010
|
+
a(this, "divideByScalar", (e) => this.multiplyByScalar(new u(e).inverse()));
|
|
3011
3011
|
a(this, "simplify", () => this.multiplyByScalar(
|
|
3012
|
-
|
|
3012
|
+
G.lcm(...this.array.map((e) => e.denominator))
|
|
3013
3013
|
).divideByScalar(
|
|
3014
|
-
|
|
3014
|
+
G.gcd(...this.array.map((e) => e.numerator))
|
|
3015
3015
|
).multiplyByScalar(
|
|
3016
3016
|
this.x.isNegative() ? -1 : 1
|
|
3017
3017
|
));
|
|
@@ -3022,7 +3022,7 @@ const Be = class Be {
|
|
|
3022
3022
|
a(this, "fromString", (e) => {
|
|
3023
3023
|
e.startsWith("(") && (e = e.substring(1)), e.endsWith(")") && (e = e.substring(0, e.length - 1));
|
|
3024
3024
|
const t = e.split(/[,;\s]/g).filter((i) => i.trim() !== "");
|
|
3025
|
-
return t.length < 2 ? this : (h(this,
|
|
3025
|
+
return t.length < 2 ? this : (h(this, j, t.map((i) => new u(i))), this);
|
|
3026
3026
|
});
|
|
3027
3027
|
e.length > 0 && this.parse(...e);
|
|
3028
3028
|
}
|
|
@@ -3030,59 +3030,59 @@ const Be = class Be {
|
|
|
3030
3030
|
// Getter and setter
|
|
3031
3031
|
// ------------------------------------------
|
|
3032
3032
|
get array() {
|
|
3033
|
-
return s(this,
|
|
3033
|
+
return s(this, j);
|
|
3034
3034
|
}
|
|
3035
3035
|
set array(e) {
|
|
3036
|
-
h(this,
|
|
3036
|
+
h(this, j, e);
|
|
3037
3037
|
}
|
|
3038
3038
|
get x() {
|
|
3039
|
-
return s(this,
|
|
3039
|
+
return s(this, j)[0];
|
|
3040
3040
|
}
|
|
3041
3041
|
set x(e) {
|
|
3042
|
-
s(this,
|
|
3042
|
+
s(this, j)[0] = new u(e);
|
|
3043
3043
|
}
|
|
3044
3044
|
get y() {
|
|
3045
|
-
return s(this,
|
|
3045
|
+
return s(this, j)[1];
|
|
3046
3046
|
}
|
|
3047
3047
|
set y(e) {
|
|
3048
|
-
s(this,
|
|
3048
|
+
s(this, j)[1] = new u(e);
|
|
3049
3049
|
}
|
|
3050
3050
|
get z() {
|
|
3051
3051
|
if (this.dimension < 3)
|
|
3052
3052
|
throw new Error("Vector is not 3D");
|
|
3053
|
-
return s(this,
|
|
3053
|
+
return s(this, j)[2];
|
|
3054
3054
|
}
|
|
3055
3055
|
set z(e) {
|
|
3056
3056
|
if (this.dimension < 3)
|
|
3057
3057
|
throw new Error("Vector is not 3D");
|
|
3058
|
-
s(this,
|
|
3058
|
+
s(this, j)[2] = new u(e);
|
|
3059
3059
|
}
|
|
3060
3060
|
get asPoint() {
|
|
3061
|
-
return s(this,
|
|
3061
|
+
return s(this, Ve);
|
|
3062
3062
|
}
|
|
3063
3063
|
set asPoint(e) {
|
|
3064
|
-
h(this,
|
|
3064
|
+
h(this, Ve, e);
|
|
3065
3065
|
}
|
|
3066
3066
|
get normSquare() {
|
|
3067
|
-
return this.array.reduce((e, t) => e.add(t.clone().pow(2)), new
|
|
3067
|
+
return this.array.reduce((e, t) => e.add(t.clone().pow(2)), new u(0));
|
|
3068
3068
|
}
|
|
3069
3069
|
get norm() {
|
|
3070
3070
|
return Math.sqrt(this.normSquare.value);
|
|
3071
3071
|
}
|
|
3072
3072
|
get tex() {
|
|
3073
|
-
return s(this,
|
|
3073
|
+
return s(this, Ve) ? `\\left(${this.array.map((e) => e.tex).join(";")}\\right)` : `\\begin{pmatrix} ${this.array.map((e) => e.tex).join(" \\\\ ")} \\end{pmatrix}`;
|
|
3074
3074
|
}
|
|
3075
3075
|
get display() {
|
|
3076
|
-
return s(this,
|
|
3076
|
+
return s(this, Ve) ? `(${this.array.map((e) => e.display).join(";")})` : `((${this.array.map((e) => e.display).join(",")}))`;
|
|
3077
3077
|
}
|
|
3078
3078
|
setDimension(e = 2) {
|
|
3079
3079
|
if (e < 2)
|
|
3080
3080
|
throw new Error("Dimension must be at least 2");
|
|
3081
3081
|
if (e < this.dimension)
|
|
3082
|
-
h(this,
|
|
3082
|
+
h(this, j, s(this, j).slice(0, e));
|
|
3083
3083
|
else if (e > this.dimension)
|
|
3084
3084
|
for (let t = this.dimension; t < e; t++)
|
|
3085
|
-
s(this,
|
|
3085
|
+
s(this, j).push(new u(0));
|
|
3086
3086
|
return this;
|
|
3087
3087
|
}
|
|
3088
3088
|
get dimension() {
|
|
@@ -3101,13 +3101,13 @@ const Be = class Be {
|
|
|
3101
3101
|
return `((${e.join(",")}))`;
|
|
3102
3102
|
}
|
|
3103
3103
|
defineAsPoint(e) {
|
|
3104
|
-
return h(this,
|
|
3104
|
+
return h(this, Ve, e !== !1), this;
|
|
3105
3105
|
}
|
|
3106
3106
|
parse(...e) {
|
|
3107
3107
|
if (e.length === 0)
|
|
3108
3108
|
throw new Error("Invalid value");
|
|
3109
3109
|
if (e.length === 1) {
|
|
3110
|
-
if (e[0] instanceof
|
|
3110
|
+
if (e[0] instanceof De)
|
|
3111
3111
|
return e[0].clone();
|
|
3112
3112
|
if (typeof e[0] == "string")
|
|
3113
3113
|
return this.fromString(e[0]);
|
|
@@ -3115,20 +3115,20 @@ const Be = class Be {
|
|
|
3115
3115
|
}
|
|
3116
3116
|
if (e.length === 2) {
|
|
3117
3117
|
const [t, i] = e;
|
|
3118
|
-
if (t instanceof
|
|
3118
|
+
if (t instanceof De && i instanceof De) {
|
|
3119
3119
|
if (t.dimension !== i.dimension)
|
|
3120
3120
|
throw new Error("Vectors must have the same dimension");
|
|
3121
|
-
return h(this,
|
|
3121
|
+
return h(this, j, i.array.map((n, r) => n.clone().subtract(t.array[r]))), this;
|
|
3122
3122
|
}
|
|
3123
3123
|
}
|
|
3124
|
-
return h(this,
|
|
3124
|
+
return h(this, j, e.map((t) => new u(t))), this;
|
|
3125
3125
|
}
|
|
3126
3126
|
clone() {
|
|
3127
|
-
const e = new
|
|
3127
|
+
const e = new De();
|
|
3128
3128
|
return e.array = this.copy(), e.asPoint = this.asPoint, e;
|
|
3129
3129
|
}
|
|
3130
3130
|
copy() {
|
|
3131
|
-
return s(this,
|
|
3131
|
+
return s(this, j).map((e) => e.clone());
|
|
3132
3132
|
}
|
|
3133
3133
|
middleOf(e, t) {
|
|
3134
3134
|
if (e.dimension !== t.dimension)
|
|
@@ -3143,7 +3143,7 @@ const Be = class Be {
|
|
|
3143
3143
|
cross(e) {
|
|
3144
3144
|
if (this.dimension !== 3 || e.dimension !== 3)
|
|
3145
3145
|
throw new Error("Cross product can only be determined in 3D");
|
|
3146
|
-
return new
|
|
3146
|
+
return new De(
|
|
3147
3147
|
this.y.clone().multiply(e.z).subtract(this.z.clone().multiply(e.y)),
|
|
3148
3148
|
this.z.clone().multiply(e.x).subtract(this.x.clone().multiply(e.z)),
|
|
3149
3149
|
this.x.clone().multiply(e.y).subtract(this.y.clone().multiply(e.x))
|
|
@@ -3156,7 +3156,7 @@ const Be = class Be {
|
|
|
3156
3156
|
return this.array.every((e, t) => t === 0 ? e.isOne() : e.isZero());
|
|
3157
3157
|
}
|
|
3158
3158
|
distanceTo(e) {
|
|
3159
|
-
const t = new
|
|
3159
|
+
const t = new De(this, e);
|
|
3160
3160
|
return {
|
|
3161
3161
|
value: t.norm,
|
|
3162
3162
|
fraction: t.normSquare,
|
|
@@ -3164,40 +3164,40 @@ const Be = class Be {
|
|
|
3164
3164
|
};
|
|
3165
3165
|
}
|
|
3166
3166
|
};
|
|
3167
|
-
|
|
3168
|
-
let E =
|
|
3169
|
-
var
|
|
3170
|
-
function
|
|
3167
|
+
j = new WeakMap(), Ve = new WeakMap();
|
|
3168
|
+
let E = De;
|
|
3169
|
+
var ve = /* @__PURE__ */ ((o) => (o.None = "none", o.Parallel = "parallel", o.Perpendicular = "perpendicular", o.Tangent = "tangent", o))(ve || {}), fi = /* @__PURE__ */ ((o) => (o.None = "none", o.Parallel = "parallel", o.Perpendicular = "perpendicular", o.Tangent = "tangent", o))(fi || {});
|
|
3170
|
+
function Ri(o = 0.5) {
|
|
3171
3171
|
return Math.random() < o;
|
|
3172
3172
|
}
|
|
3173
|
-
function
|
|
3173
|
+
function me(o, e, t) {
|
|
3174
3174
|
if (e === void 0)
|
|
3175
|
-
return o >= 0 ?
|
|
3175
|
+
return o >= 0 ? me(0, o) : me(o, 0);
|
|
3176
3176
|
if (o === e)
|
|
3177
3177
|
return o;
|
|
3178
3178
|
if (t === void 0)
|
|
3179
3179
|
return Math.floor(Math.random() * (e - o + 1) + o);
|
|
3180
3180
|
if (Math.abs(e - o) <= t.length)
|
|
3181
3181
|
throw new Error("The number of excluded values is too high.");
|
|
3182
|
-
let i =
|
|
3182
|
+
let i = me(o, e);
|
|
3183
3183
|
for (; t.includes(i); )
|
|
3184
|
-
i =
|
|
3184
|
+
i = me(o, e);
|
|
3185
3185
|
return i;
|
|
3186
3186
|
}
|
|
3187
|
-
function
|
|
3188
|
-
return e === !1 ?
|
|
3187
|
+
function H(o, e) {
|
|
3188
|
+
return e === !1 ? Ri() ? me(1, o) : -me(1, o) : me(-o, o);
|
|
3189
3189
|
}
|
|
3190
|
-
function
|
|
3191
|
-
let e =
|
|
3192
|
-
return o !== void 0 && (e = e.filter((t) => t < o)),
|
|
3190
|
+
function ys(o) {
|
|
3191
|
+
let e = G.primes();
|
|
3192
|
+
return o !== void 0 && (e = e.filter((t) => t < o)), bi(e);
|
|
3193
3193
|
}
|
|
3194
|
-
function
|
|
3195
|
-
return e === void 0 && (e = 1), o.length <= 0 ? Object.values(o) :
|
|
3194
|
+
function ws(o, e) {
|
|
3195
|
+
return e === void 0 && (e = 1), o.length <= 0 ? Object.values(o) : Di(o).slice(0, e);
|
|
3196
3196
|
}
|
|
3197
|
-
function
|
|
3198
|
-
return o.length === 0 ? null : o[
|
|
3197
|
+
function bi(o) {
|
|
3198
|
+
return o.length === 0 ? null : o[me(0, o.length - 1)];
|
|
3199
3199
|
}
|
|
3200
|
-
function
|
|
3200
|
+
function Di(o) {
|
|
3201
3201
|
const e = Object.values(o);
|
|
3202
3202
|
for (let t = e.length - 1; t > 0; t--) {
|
|
3203
3203
|
const i = Math.floor(Math.random() * (t + 1)), n = e[t];
|
|
@@ -3219,7 +3219,7 @@ class S extends E {
|
|
|
3219
3219
|
if (e.length > 1) {
|
|
3220
3220
|
if (e.some((i) => i instanceof E))
|
|
3221
3221
|
throw new Error("Creating a point with multiple argument requires an input fraction");
|
|
3222
|
-
const t = e.map((i) => new
|
|
3222
|
+
const t = e.map((i) => new u(i));
|
|
3223
3223
|
if (t.some((i) => i.isNaN()))
|
|
3224
3224
|
throw new Error("The value is not a valid point sting (a,b): " + e.join(","));
|
|
3225
3225
|
this.array = t;
|
|
@@ -3231,32 +3231,32 @@ class S extends E {
|
|
|
3231
3231
|
return e.array = this.copy(), e.asPoint = !0, e;
|
|
3232
3232
|
}
|
|
3233
3233
|
}
|
|
3234
|
-
var
|
|
3235
|
-
const
|
|
3234
|
+
var Ie, I, R, W, he, J, ze, Ee;
|
|
3235
|
+
const je = class je {
|
|
3236
3236
|
/**
|
|
3237
3237
|
* Value can be a mix of:
|
|
3238
3238
|
*
|
|
3239
3239
|
* @param values
|
|
3240
3240
|
*/
|
|
3241
3241
|
constructor(...e) {
|
|
3242
|
-
m(this,
|
|
3242
|
+
m(this, Ie);
|
|
3243
3243
|
// ax + by + c = 0
|
|
3244
|
-
m(this,
|
|
3245
|
-
m(this,
|
|
3244
|
+
m(this, I);
|
|
3245
|
+
m(this, R);
|
|
3246
3246
|
m(this, W);
|
|
3247
3247
|
m(this, he);
|
|
3248
3248
|
m(this, J);
|
|
3249
|
-
m(this,
|
|
3250
|
-
m(this,
|
|
3249
|
+
m(this, ze);
|
|
3250
|
+
m(this, Ee, "canonical");
|
|
3251
3251
|
a(this, "randomPoint", (e) => {
|
|
3252
|
-
const t = s(this, J).clone().multiplyByScalar(
|
|
3252
|
+
const t = s(this, J).clone().multiplyByScalar(H(e === void 0 || e <= 1 ? 3 : e, !1)).add(s(this, he));
|
|
3253
3253
|
return t.asPoint = !0, t;
|
|
3254
3254
|
});
|
|
3255
3255
|
a(this, "randomNearPoint", (e) => {
|
|
3256
3256
|
const t = this.randomPoint(e);
|
|
3257
3257
|
let i = 10;
|
|
3258
3258
|
for (; this.isOnLine(t) && i > 0; )
|
|
3259
|
-
t.x.add(
|
|
3259
|
+
t.x.add(H(1, !1)), t.y.add(H(1, !1)), i--;
|
|
3260
3260
|
return t;
|
|
3261
3261
|
});
|
|
3262
3262
|
// ------------------------------------------
|
|
@@ -3271,13 +3271,13 @@ const De = class De {
|
|
|
3271
3271
|
if (e.length === 0)
|
|
3272
3272
|
return this;
|
|
3273
3273
|
if (e.length === 1) {
|
|
3274
|
-
if (e[0] instanceof
|
|
3274
|
+
if (e[0] instanceof je)
|
|
3275
3275
|
return this.fromCoefficient(e[0].a, e[0].b, e[0].c);
|
|
3276
|
-
if (e[0] instanceof
|
|
3276
|
+
if (e[0] instanceof V)
|
|
3277
3277
|
return this.fromEquation(e[0]);
|
|
3278
3278
|
if (typeof e[0] == "string")
|
|
3279
3279
|
try {
|
|
3280
|
-
const t = new
|
|
3280
|
+
const t = new V(e[0]);
|
|
3281
3281
|
return this.parse(t);
|
|
3282
3282
|
} catch {
|
|
3283
3283
|
return this;
|
|
@@ -3292,12 +3292,12 @@ const De = class De {
|
|
|
3292
3292
|
}
|
|
3293
3293
|
if (e.length === 3) {
|
|
3294
3294
|
if (e[0] instanceof E && e[1] instanceof E) {
|
|
3295
|
-
if (e[2] ===
|
|
3295
|
+
if (e[2] === ve.Perpendicular)
|
|
3296
3296
|
return this.fromPointAndNormal(e[0], e[1]);
|
|
3297
|
-
if (e[2] ===
|
|
3297
|
+
if (e[2] === ve.Parallel)
|
|
3298
3298
|
return this.fromPointAndDirection(e[0], e[1]);
|
|
3299
3299
|
}
|
|
3300
|
-
return e[0] instanceof E && e[1] instanceof
|
|
3300
|
+
return e[0] instanceof E && e[1] instanceof je ? e[2] === ve.Parallel || e[2] === null ? this.fromPointAndLine(e[0], e[1], ve.Parallel) : this.fromPointAndLine(e[0], e[1], ve.Perpendicular) : this.fromCoefficient(
|
|
3301
3301
|
e[0],
|
|
3302
3302
|
e[1],
|
|
3303
3303
|
e[2]
|
|
@@ -3318,34 +3318,34 @@ const De = class De {
|
|
|
3318
3318
|
e.left.monomByDegree(0).coefficient
|
|
3319
3319
|
);
|
|
3320
3320
|
});
|
|
3321
|
-
a(this, "fromCoefficient", (e, t, i) => (h(this,
|
|
3321
|
+
a(this, "fromCoefficient", (e, t, i) => (h(this, I, new u(e)), h(this, R, new u(t)), h(this, W, new u(i)), h(this, J, new E(s(this, R).clone(), s(this, I).clone().opposite())), h(this, he, new E(new u().zero(), s(this, W).clone())), h(this, ze, s(this, J).clone().normal()), this));
|
|
3322
3322
|
a(this, "fromPointAndDirection", (e, t) => (this.fromCoefficient(
|
|
3323
3323
|
t.y,
|
|
3324
3324
|
t.x.clone().opposite(),
|
|
3325
3325
|
e.x.clone().multiply(t.y).subtract(e.y.clone().multiply(t.x)).opposite()
|
|
3326
|
-
), h(this, he, e.clone()), h(this, J, t.clone()), h(this,
|
|
3326
|
+
), h(this, he, e.clone()), h(this, J, t.clone()), h(this, ze, s(this, J).clone().normal()), this));
|
|
3327
3327
|
a(this, "fromPointAndNormal", (e, t) => this.fromCoefficient(
|
|
3328
3328
|
t.x,
|
|
3329
3329
|
t.y,
|
|
3330
3330
|
e.x.clone().multiply(t.x).add(e.y.clone().multiply(t.y)).opposite()
|
|
3331
3331
|
));
|
|
3332
|
-
a(this, "fromPointAndLine", (e, t, i) => (i === void 0 && (i =
|
|
3333
|
-
a(this, "clone", () => (h(this,
|
|
3332
|
+
a(this, "fromPointAndLine", (e, t, i) => (i === void 0 && (i = ve.Parallel), i === ve.Parallel ? this.fromPointAndNormal(e, t.normal) : i === ve.Perpendicular ? this.fromPointAndNormal(e, t.director) : this));
|
|
3333
|
+
a(this, "clone", () => (h(this, I, s(this, I).clone()), h(this, R, s(this, R).clone()), h(this, W, s(this, W).clone()), h(this, J, s(this, J).clone()), h(this, he, s(this, he).clone()), h(this, ze, s(this, ze).clone()), this));
|
|
3334
3334
|
// ------------------------------------------
|
|
3335
3335
|
// Mathematical operations
|
|
3336
3336
|
// ------------------------------------------
|
|
3337
|
-
a(this, "isOnLine", (e) => s(this,
|
|
3338
|
-
s(this,
|
|
3337
|
+
a(this, "isOnLine", (e) => s(this, I).clone().multiply(e.x).add(
|
|
3338
|
+
s(this, R).clone().multiply(e.y)
|
|
3339
3339
|
).add(s(this, W)).isZero());
|
|
3340
3340
|
a(this, "isParallelTo", (e) => this.slope.isEqual(e.slope) && this.height.isNotEqual(e.height));
|
|
3341
3341
|
a(this, "isSameAs", (e) => this.slope.isEqual(e.slope) && this.height.isEqual(e.height));
|
|
3342
3342
|
a(this, "isPerpendicularTo", (e) => this.d.isNormalTo(e.d));
|
|
3343
3343
|
a(this, "isVertical", () => this.slope.isInfinity());
|
|
3344
3344
|
a(this, "simplify", () => {
|
|
3345
|
-
const e =
|
|
3345
|
+
const e = G.lcm(s(this, I).denominator, s(this, R).denominator, s(this, W).denominator), t = G.gcd(s(this, I).numerator, s(this, R).numerator, s(this, W).numerator);
|
|
3346
3346
|
return this.fromCoefficient(
|
|
3347
|
-
s(this,
|
|
3348
|
-
s(this,
|
|
3347
|
+
s(this, I).clone().multiply(e).divide(t),
|
|
3348
|
+
s(this, R).clone().multiply(e).divide(t),
|
|
3349
3349
|
s(this, W).clone().multiply(e).divide(t)
|
|
3350
3350
|
), this;
|
|
3351
3351
|
});
|
|
@@ -3353,7 +3353,7 @@ const De = class De {
|
|
|
3353
3353
|
a(this, "intersection", (e) => {
|
|
3354
3354
|
const t = new S();
|
|
3355
3355
|
let i = !1, n = !1;
|
|
3356
|
-
return s(this,
|
|
3356
|
+
return s(this, R).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, R).clone().multiply(e.c).subtract(s(this, W).clone().multiply(e.b)).divide(s(this, I).clone().multiply(e.b).subtract(s(this, R).clone().multiply(e.a))), t.y = s(this, I).clone().multiply(e.c).subtract(s(this, W).clone().multiply(e.a)).divide(s(this, R).clone().multiply(e.a).subtract(s(this, I).clone().multiply(e.b)))), {
|
|
3357
3357
|
point: t,
|
|
3358
3358
|
hasIntersection: !(i || n),
|
|
3359
3359
|
isParallel: i,
|
|
@@ -3361,28 +3361,28 @@ const De = class De {
|
|
|
3361
3361
|
};
|
|
3362
3362
|
});
|
|
3363
3363
|
a(this, "getValueAtX", (e) => {
|
|
3364
|
-
const t = this.getEquation().isolate("y"), i = new
|
|
3365
|
-
return t instanceof
|
|
3364
|
+
const t = this.getEquation().isolate("y"), i = new u(e);
|
|
3365
|
+
return t instanceof V ? t.right.evaluate({ x: i }) : new u().invalid();
|
|
3366
3366
|
});
|
|
3367
3367
|
a(this, "getValueAtY", (e) => {
|
|
3368
|
-
const t = this.getEquation().isolate("x"), i = new
|
|
3369
|
-
return t instanceof
|
|
3368
|
+
const t = this.getEquation().isolate("x"), i = new u(e);
|
|
3369
|
+
return t instanceof V ? t.right.evaluate({ y: i }) : new u().invalid();
|
|
3370
3370
|
});
|
|
3371
|
-
return h(this,
|
|
3371
|
+
return h(this, I, new u().zero()), h(this, R, new u().zero()), h(this, W, new u().zero()), h(this, he, new E()), h(this, J, new E()), h(this, ze, new E()), h(this, Ie, !0), e.length > 0 && this.parse(...e), this;
|
|
3372
3372
|
}
|
|
3373
3373
|
get a() {
|
|
3374
|
-
return s(this,
|
|
3374
|
+
return s(this, I);
|
|
3375
3375
|
}
|
|
3376
3376
|
// ------------------------------------------
|
|
3377
3377
|
// Getter and setter
|
|
3378
3378
|
set a(e) {
|
|
3379
|
-
h(this,
|
|
3379
|
+
h(this, I, e);
|
|
3380
3380
|
}
|
|
3381
3381
|
get b() {
|
|
3382
|
-
return s(this,
|
|
3382
|
+
return s(this, R);
|
|
3383
3383
|
}
|
|
3384
3384
|
set b(e) {
|
|
3385
|
-
h(this,
|
|
3385
|
+
h(this, R, e);
|
|
3386
3386
|
}
|
|
3387
3387
|
get c() {
|
|
3388
3388
|
return s(this, W);
|
|
@@ -3403,12 +3403,12 @@ const De = class De {
|
|
|
3403
3403
|
h(this, J, e);
|
|
3404
3404
|
}
|
|
3405
3405
|
get n() {
|
|
3406
|
-
return s(this,
|
|
3406
|
+
return s(this, ze);
|
|
3407
3407
|
}
|
|
3408
3408
|
// ------------------------------------------
|
|
3409
3409
|
getEquation() {
|
|
3410
|
-
const e = new
|
|
3411
|
-
return s(this,
|
|
3410
|
+
const e = new V(new N().parse("xy", s(this, I), s(this, R), s(this, W)), new N("0"));
|
|
3411
|
+
return s(this, Ie) ? e.simplify() : e;
|
|
3412
3412
|
}
|
|
3413
3413
|
// get system(): { x: Equation, y: Equation } {
|
|
3414
3414
|
// const e1 = new Equation(
|
|
@@ -3424,86 +3424,86 @@ const De = class De {
|
|
|
3424
3424
|
// return { x: e1, y: e2 }
|
|
3425
3425
|
// }
|
|
3426
3426
|
get canonical() {
|
|
3427
|
-
return h(this,
|
|
3427
|
+
return h(this, Ee, "canonical"), this;
|
|
3428
3428
|
}
|
|
3429
3429
|
get equation() {
|
|
3430
|
-
return h(this,
|
|
3430
|
+
return h(this, Ee, "equation"), this;
|
|
3431
3431
|
}
|
|
3432
3432
|
get mxh() {
|
|
3433
|
-
return h(this,
|
|
3433
|
+
return h(this, Ee, "mxh"), this;
|
|
3434
3434
|
}
|
|
3435
3435
|
get parametric() {
|
|
3436
|
-
return h(this,
|
|
3436
|
+
return h(this, Ee, "parametric"), this;
|
|
3437
3437
|
}
|
|
3438
3438
|
get system() {
|
|
3439
|
-
return h(this,
|
|
3439
|
+
return h(this, Ee, "system"), this;
|
|
3440
3440
|
}
|
|
3441
3441
|
get tex() {
|
|
3442
|
-
const e = s(this,
|
|
3443
|
-
switch (h(this,
|
|
3442
|
+
const e = s(this, Ee);
|
|
3443
|
+
switch (h(this, Ee, "canonical"), e) {
|
|
3444
3444
|
case "equation":
|
|
3445
3445
|
return this.getEquation().reorder().tex;
|
|
3446
3446
|
case "mxh":
|
|
3447
|
-
return this.slope.isInfinity() ? "x=" + this.OA.x.tex : "y=" + new
|
|
3447
|
+
return this.slope.isInfinity() ? "x=" + this.OA.x.tex : "y=" + new N().parse("x", this.slope, this.height).tex;
|
|
3448
3448
|
case "parametric":
|
|
3449
3449
|
case "system": {
|
|
3450
3450
|
const t = s(this, J).clone();
|
|
3451
|
-
return s(this,
|
|
3452
|
-
x &= ${new
|
|
3453
|
-
y &= ${new
|
|
3451
|
+
return s(this, Ie) && t.simplify(), e === "parametric" ? `${E.asTex("x", "y")} = ${E.asTex(s(this, he).x.tex, s(this, he).y.tex)} + k\\cdot ${E.asTex(t.x.tex, t.y.tex)}` : `\\left\\{\\begin{aligned}
|
|
3452
|
+
x &= ${new N(s(this, he).x).add(new k(s(this, J).x).multiply(new k("k"))).reorder("k", !0).tex}\\\\
|
|
3453
|
+
y &= ${new N(s(this, he).y).add(new k(s(this, J).y).multiply(new k("k"))).reorder("k", !0).tex}
|
|
3454
3454
|
\\end{aligned}\\right.`;
|
|
3455
3455
|
}
|
|
3456
3456
|
default: {
|
|
3457
3457
|
const t = this.getEquation();
|
|
3458
|
-
return s(this,
|
|
3458
|
+
return s(this, I).isNegative() && t.multiply(-1), t.tex;
|
|
3459
3459
|
}
|
|
3460
3460
|
}
|
|
3461
3461
|
}
|
|
3462
3462
|
get reduceBeforeDisplay() {
|
|
3463
|
-
return s(this,
|
|
3463
|
+
return s(this, Ie);
|
|
3464
3464
|
}
|
|
3465
3465
|
set reduceBeforeDisplay(e) {
|
|
3466
|
-
h(this,
|
|
3466
|
+
h(this, Ie, e);
|
|
3467
3467
|
}
|
|
3468
3468
|
get display() {
|
|
3469
|
-
const e = s(this,
|
|
3470
|
-
switch (h(this,
|
|
3469
|
+
const e = s(this, Ee);
|
|
3470
|
+
switch (h(this, Ee, "canonical"), e) {
|
|
3471
3471
|
case "equation":
|
|
3472
3472
|
return this.getEquation().reorder().display;
|
|
3473
3473
|
case "mxh":
|
|
3474
|
-
return this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new
|
|
3474
|
+
return this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new N().parse("x", this.slope, this.height).display;
|
|
3475
3475
|
case "parametric": {
|
|
3476
3476
|
const t = s(this, J).clone();
|
|
3477
|
-
return s(this,
|
|
3477
|
+
return s(this, Ie) && t.simplify(), `((x,y))=((${s(this, he).x.display},${s(this, he).y.display}))+k((${t.x.display},${t.y.display}))`;
|
|
3478
3478
|
}
|
|
3479
3479
|
default: {
|
|
3480
3480
|
const t = this.getEquation();
|
|
3481
|
-
return s(this,
|
|
3481
|
+
return s(this, I).isNegative() && t.multiply(-1), t.display;
|
|
3482
3482
|
}
|
|
3483
3483
|
}
|
|
3484
3484
|
}
|
|
3485
3485
|
get normal() {
|
|
3486
|
-
return new E(s(this,
|
|
3486
|
+
return new E(s(this, I), s(this, R));
|
|
3487
3487
|
}
|
|
3488
3488
|
get director() {
|
|
3489
3489
|
return s(this, J).clone();
|
|
3490
3490
|
}
|
|
3491
3491
|
get slope() {
|
|
3492
|
-
return s(this,
|
|
3492
|
+
return s(this, I).clone().opposite().divide(s(this, R));
|
|
3493
3493
|
}
|
|
3494
3494
|
get height() {
|
|
3495
|
-
return s(this, W).clone().opposite().divide(s(this,
|
|
3495
|
+
return s(this, W).clone().opposite().divide(s(this, R));
|
|
3496
3496
|
}
|
|
3497
3497
|
fromPoints(e, t) {
|
|
3498
3498
|
return this.fromPointAndDirection(e, new E(e, t));
|
|
3499
3499
|
}
|
|
3500
3500
|
distanceTo(e) {
|
|
3501
|
-
const t = e.x.clone().multiply(s(this,
|
|
3501
|
+
const t = e.x.clone().multiply(s(this, I)).add(e.y.clone().multiply(s(this, R))).add(s(this, W)).abs(), i = this.normal.normSquare;
|
|
3502
3502
|
if (i.isZero())
|
|
3503
3503
|
return {
|
|
3504
3504
|
value: NaN,
|
|
3505
3505
|
tex: "Not a line",
|
|
3506
|
-
fraction: new
|
|
3506
|
+
fraction: new u().infinite()
|
|
3507
3507
|
};
|
|
3508
3508
|
const n = t.value / Math.sqrt(i.value), r = t.clone().divide(i.clone().sqrt());
|
|
3509
3509
|
return i.isSquare() ? {
|
|
@@ -3518,7 +3518,7 @@ const De = class De {
|
|
|
3518
3518
|
}
|
|
3519
3519
|
hitSegment(e, t) {
|
|
3520
3520
|
const i = this.intersection(
|
|
3521
|
-
new
|
|
3521
|
+
new je().fromPoints(e, t)
|
|
3522
3522
|
);
|
|
3523
3523
|
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;
|
|
3524
3524
|
}
|
|
@@ -3528,44 +3528,44 @@ const De = class De {
|
|
|
3528
3528
|
canonicalAsFloatCoefficient(e) {
|
|
3529
3529
|
e === void 0 && (e = 2);
|
|
3530
3530
|
let t = "";
|
|
3531
|
-
return s(this,
|
|
3531
|
+
return s(this, I).isZero() || (s(this, I).isOne() ? t = "x" : s(this, I).clone().opposite().isOne() ? t = "-x" : t = s(this, I).value.toFixed(e) + "x"), s(this, R).isZero() || (s(this, R).isPositive() && (t += "+"), t += s(this, R).value.toFixed(e) + "y"), s(this, W).isZero() || (s(this, W).isPositive() && (t += "+"), t += s(this, W).value.toFixed(e)), t + "=0";
|
|
3532
3532
|
}
|
|
3533
3533
|
};
|
|
3534
|
-
|
|
3535
|
-
a(
|
|
3536
|
-
let
|
|
3537
|
-
var ae,
|
|
3538
|
-
const
|
|
3534
|
+
Ie = new WeakMap(), I = new WeakMap(), R = new WeakMap(), W = new WeakMap(), he = new WeakMap(), J = new WeakMap(), ze = new WeakMap(), Ee = new WeakMap(), // A line is defined as the canonical form
|
|
3535
|
+
a(je, "PERPENDICULAR", ve.Perpendicular), a(je, "PARALLEL", ve.Parallel);
|
|
3536
|
+
let z = je;
|
|
3537
|
+
var ae, U, Me, Ht, Kt, Jt, le, Li, kt, Zi, Vi, Fi, di;
|
|
3538
|
+
const _t = class _t {
|
|
3539
3539
|
constructor(...e) {
|
|
3540
3540
|
m(this, le);
|
|
3541
3541
|
m(this, ae);
|
|
3542
|
-
m(this,
|
|
3543
|
-
m(this,
|
|
3542
|
+
m(this, U);
|
|
3543
|
+
m(this, Me);
|
|
3544
3544
|
/**
|
|
3545
3545
|
* Get the relative position between circle and line. It corresponds to the number of intersection.
|
|
3546
3546
|
* @param {Line} L
|
|
3547
3547
|
* @returns {number}
|
|
3548
3548
|
*/
|
|
3549
3549
|
a(this, "relativePosition", (e) => {
|
|
3550
|
-
if (s(this, ae) === void 0 || s(this,
|
|
3550
|
+
if (s(this, ae) === void 0 || s(this, U) === void 0)
|
|
3551
3551
|
throw new Error("Circle not defined");
|
|
3552
|
-
const t = e.distanceTo(s(this, ae)), i = Math.sqrt(s(this,
|
|
3552
|
+
const t = e.distanceTo(s(this, ae)), i = Math.sqrt(s(this, U).value);
|
|
3553
3553
|
return t.value - i > 1e-10 ? 0 : Math.abs(t.value - i) < 1e-10 ? 1 : 2;
|
|
3554
3554
|
});
|
|
3555
3555
|
a(this, "lineIntersection", (e) => {
|
|
3556
3556
|
const t = [];
|
|
3557
|
-
if (s(this,
|
|
3557
|
+
if (s(this, Me) === void 0)
|
|
3558
3558
|
return [];
|
|
3559
|
-
const i = s(this,
|
|
3560
|
-
return n instanceof
|
|
3559
|
+
const i = s(this, Me).clone(), n = e.getEquation().clone().isolate("x"), r = e.getEquation().clone().isolate("y");
|
|
3560
|
+
return n instanceof V && r instanceof V && (i.replaceBy("y", r.right).simplify(), i.solve()), t;
|
|
3561
3561
|
});
|
|
3562
|
-
a(this, "tangents", (e) => e instanceof
|
|
3562
|
+
a(this, "tangents", (e) => e instanceof u ? s(this, Jt).call(this, e) : this.isPointOnCircle(e) ? s(this, Ht).call(this, e) : s(this, ae) !== void 0 && s(this, ae).distanceTo(e).value > this.radius.value ? s(this, Kt).call(this, e) : (console.log("No tangents as the point is inside !"), []));
|
|
3563
3563
|
a(this, "isPointOnCircle", (e) => {
|
|
3564
3564
|
var t;
|
|
3565
|
-
return ((t = s(this,
|
|
3565
|
+
return ((t = s(this, Me)) == null ? void 0 : t.test({ x: e.x, y: e.y })) ?? !1;
|
|
3566
3566
|
});
|
|
3567
3567
|
a(this, "getPointsOnCircle", (e) => {
|
|
3568
|
-
const t =
|
|
3568
|
+
const t = G.pythagoreanTripletsWithTarget(this.squareRadius.value, !0), i = [];
|
|
3569
3569
|
return t.forEach((n) => {
|
|
3570
3570
|
for (const r of [[1, 1], [-1, 1], [-1, -1], [1, -1]])
|
|
3571
3571
|
i.push(
|
|
@@ -3576,21 +3576,21 @@ const Ht = class Ht {
|
|
|
3576
3576
|
);
|
|
3577
3577
|
}), i;
|
|
3578
3578
|
});
|
|
3579
|
-
m(this,
|
|
3579
|
+
m(this, Ht, (e) => {
|
|
3580
3580
|
const t = new E(this.center, e);
|
|
3581
|
-
return [new
|
|
3581
|
+
return [new z(e, t, ve.Perpendicular)];
|
|
3582
3582
|
});
|
|
3583
|
-
m(this,
|
|
3584
|
-
const t = this.center.x.clone().subtract(e.x), i = this.center.y.clone().subtract(e.y), n = new
|
|
3585
|
-
return n.multiply(t).subtract(i).pow(2), r.multiply(this.squareRadius), new
|
|
3583
|
+
m(this, Kt, (e) => {
|
|
3584
|
+
const t = this.center.x.clone().subtract(e.x), i = this.center.y.clone().subtract(e.y), n = new N("x"), r = new N("x^2+1");
|
|
3585
|
+
return n.multiply(t).subtract(i).pow(2), r.multiply(this.squareRadius), new V(n, r).solve().map((f) => {
|
|
3586
3586
|
let d;
|
|
3587
|
-
const p = new
|
|
3588
|
-
return
|
|
3587
|
+
const p = new V("y", "x");
|
|
3588
|
+
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 z(p);
|
|
3589
3589
|
});
|
|
3590
3590
|
});
|
|
3591
|
-
m(this,
|
|
3592
|
-
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()),
|
|
3593
|
-
return [new
|
|
3591
|
+
m(this, Jt, (e) => {
|
|
3592
|
+
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());
|
|
3593
|
+
return [new z(t, i, c), new z(t, i, f)];
|
|
3594
3594
|
});
|
|
3595
3595
|
e.length > 0 && this.parse(...e);
|
|
3596
3596
|
}
|
|
@@ -3598,22 +3598,22 @@ const Ht = class Ht {
|
|
|
3598
3598
|
return s(this, ae) ?? new S();
|
|
3599
3599
|
}
|
|
3600
3600
|
get squareRadius() {
|
|
3601
|
-
return s(this,
|
|
3601
|
+
return s(this, U) ?? new u(0);
|
|
3602
3602
|
}
|
|
3603
3603
|
get cartesian() {
|
|
3604
|
-
if (s(this,
|
|
3604
|
+
if (s(this, Me) === void 0)
|
|
3605
3605
|
throw new Error("Cartesian equation not defined");
|
|
3606
|
-
return s(this,
|
|
3606
|
+
return s(this, Me);
|
|
3607
3607
|
}
|
|
3608
3608
|
get radius() {
|
|
3609
|
-
return s(this,
|
|
3610
|
-
tex: s(this,
|
|
3611
|
-
display: s(this,
|
|
3612
|
-
value: s(this,
|
|
3609
|
+
return s(this, U) === void 0 ? { tex: "", display: "", value: 0 } : s(this, U).isSquare() ? {
|
|
3610
|
+
tex: s(this, U).clone().sqrt().tex,
|
|
3611
|
+
display: s(this, U).clone().sqrt().display,
|
|
3612
|
+
value: s(this, U).clone().sqrt().value
|
|
3613
3613
|
} : {
|
|
3614
|
-
tex: `\\sqrt{${s(this,
|
|
3615
|
-
display: `sqrt(${s(this,
|
|
3616
|
-
value: s(this,
|
|
3614
|
+
tex: `\\sqrt{${s(this, U).tex}}`,
|
|
3615
|
+
display: `sqrt(${s(this, U).display})`,
|
|
3616
|
+
value: s(this, U).clone().sqrt().value
|
|
3617
3617
|
};
|
|
3618
3618
|
}
|
|
3619
3619
|
get tex() {
|
|
@@ -3628,17 +3628,17 @@ const Ht = class Ht {
|
|
|
3628
3628
|
return this.center.x.isZero() ? e = "x^2" : e = `(x${this.center.x.isNegative() ? "+" : "-"}${this.center.x.clone().abs().tex})^2`, this.center.y.isZero() ? t = "y^2" : t = `(y${this.center.y.isNegative() ? "+" : "-"}${this.center.y.clone().abs().tex})^2`, `${e}+${t}=${this.squareRadius.display}`;
|
|
3629
3629
|
}
|
|
3630
3630
|
clone() {
|
|
3631
|
-
return new
|
|
3631
|
+
return new _t(
|
|
3632
3632
|
this.center.clone(),
|
|
3633
3633
|
this.squareRadius.clone(),
|
|
3634
3634
|
!0
|
|
3635
3635
|
);
|
|
3636
3636
|
}
|
|
3637
3637
|
setRadius(e, t) {
|
|
3638
|
-
return t ? h(this,
|
|
3638
|
+
return t ? h(this, U, new u(e)) : h(this, U, new u(e).pow(2)), A(this, le, kt).call(this), this;
|
|
3639
3639
|
}
|
|
3640
3640
|
parse(...e) {
|
|
3641
|
-
return A(this, le,
|
|
3641
|
+
return A(this, le, Li).call(this), typeof e[0] == "string" ? A(this, le, di).call(this, new V(e[0])) : e[0] instanceof V ? A(this, le, di).call(this, e[0]) : e[0] instanceof _t ? A(this, le, Zi).call(this, e[0]) : e[0] instanceof S && e.length > 1 && (e[1] instanceof S ? e[2] instanceof S || A(this, le, Fi).call(this, e[0], e[1]) : (e[1] instanceof u || typeof e[1] == "number") && A(this, le, Vi).call(this, e[0], e[1], typeof e[2] == "boolean" ? e[2] : !1)), A(this, le, kt).call(this), this;
|
|
3642
3642
|
}
|
|
3643
3643
|
// private _parseThroughtThreePoints(A: Point, B: Point, C: Point): this {
|
|
3644
3644
|
// const T = new Triangle(A, B, C), mAB = T.remarquables.mediators.AB.clone(),
|
|
@@ -3647,35 +3647,35 @@ const Ht = class Ht {
|
|
|
3647
3647
|
// return this
|
|
3648
3648
|
// }
|
|
3649
3649
|
};
|
|
3650
|
-
ae = new WeakMap(),
|
|
3651
|
-
return h(this, ae, void 0), h(this,
|
|
3652
|
-
},
|
|
3653
|
-
h(this,
|
|
3654
|
-
new
|
|
3655
|
-
new
|
|
3650
|
+
ae = new WeakMap(), U = new WeakMap(), Me = new WeakMap(), Ht = new WeakMap(), Kt = new WeakMap(), Jt = new WeakMap(), le = new WeakSet(), Li = function() {
|
|
3651
|
+
return h(this, ae, void 0), h(this, U, void 0), h(this, Me, void 0), this;
|
|
3652
|
+
}, kt = function() {
|
|
3653
|
+
h(this, Me, new V(
|
|
3654
|
+
new N(`(x-(${this.center.x.display}))^2+(y-(${this.center.y.display}))^2`),
|
|
3655
|
+
new N(this.squareRadius.display)
|
|
3656
3656
|
).moveLeft());
|
|
3657
|
-
},
|
|
3658
|
-
return h(this, ae, e.center.clone()), h(this,
|
|
3659
|
-
},
|
|
3660
|
-
return h(this, ae, e.clone()), i ? h(this,
|
|
3661
|
-
},
|
|
3662
|
-
return h(this, ae, e.clone()), h(this,
|
|
3663
|
-
},
|
|
3657
|
+
}, Zi = function(e) {
|
|
3658
|
+
return h(this, ae, e.center.clone()), h(this, U, e.squareRadius.clone()), A(this, le, kt).call(this), this;
|
|
3659
|
+
}, Vi = function(e, t, i) {
|
|
3660
|
+
return h(this, ae, e.clone()), i ? h(this, U, new u(t)) : h(this, U, new u(t).pow(2)), this;
|
|
3661
|
+
}, Fi = function(e, t) {
|
|
3662
|
+
return h(this, ae, e.clone()), h(this, U, new E(s(this, ae), t).normSquare), this;
|
|
3663
|
+
}, di = function(e) {
|
|
3664
3664
|
if (e.moveLeft(), e.degree("x").value === 2 && e.degree("y").value === 2) {
|
|
3665
3665
|
const t = e.left.monomByDegree(2, "x"), i = e.left.monomByDegree(2, "y");
|
|
3666
3666
|
let n, r, l;
|
|
3667
|
-
t.coefficient.isEqual(i.coefficient) ? (e.divide(t.coefficient), n = e.left.monomByDegree(1, "x"), r = e.left.monomByDegree(1, "y"), l = e.left.monomByDegree(0), h(this, ae, new S(n.coefficient.clone().divide(2).opposite(), r.coefficient.clone().divide(2).opposite())), h(this,
|
|
3667
|
+
t.coefficient.isEqual(i.coefficient) ? (e.divide(t.coefficient), n = e.left.monomByDegree(1, "x"), r = e.left.monomByDegree(1, "y"), l = e.left.monomByDegree(0), h(this, ae, new S(n.coefficient.clone().divide(2).opposite(), r.coefficient.clone().divide(2).opposite())), h(this, U, l.coefficient.clone().opposite().add(s(this, ae).x.clone().pow(2)).add(s(this, ae).y.clone().pow(2)))) : (h(this, ae, void 0), h(this, U, void 0));
|
|
3668
3668
|
}
|
|
3669
3669
|
return this;
|
|
3670
3670
|
};
|
|
3671
|
-
let
|
|
3672
|
-
var
|
|
3673
|
-
const
|
|
3671
|
+
let $t = _t;
|
|
3672
|
+
var D, X;
|
|
3673
|
+
const pt = class pt {
|
|
3674
3674
|
constructor(e, t) {
|
|
3675
3675
|
// ax + by + c = 0
|
|
3676
|
-
m(this,
|
|
3677
|
-
m(this,
|
|
3678
|
-
a(this, "clone", () => (h(this,
|
|
3676
|
+
m(this, D, new S());
|
|
3677
|
+
m(this, X, new E());
|
|
3678
|
+
a(this, "clone", () => (h(this, X, s(this, X).clone()), h(this, D, s(this, D).clone()), this));
|
|
3679
3679
|
// ------------------------------------------
|
|
3680
3680
|
// Mathematical operations
|
|
3681
3681
|
// ------------------------------------------
|
|
@@ -3715,54 +3715,54 @@ const ct = class ct {
|
|
|
3715
3715
|
// return new Fraction().invalid()
|
|
3716
3716
|
// }
|
|
3717
3717
|
a(this, "randomPoint", (e = 5) => {
|
|
3718
|
-
const t = s(this,
|
|
3718
|
+
const t = s(this, D).clone(), i = new u(H(e, !1));
|
|
3719
3719
|
return new S(
|
|
3720
|
-
t.x.clone().add(s(this,
|
|
3721
|
-
t.y.clone().add(s(this,
|
|
3722
|
-
t.z.clone().add(s(this,
|
|
3720
|
+
t.x.clone().add(s(this, X).x.clone().multiply(i)),
|
|
3721
|
+
t.y.clone().add(s(this, X).y.clone().multiply(i)),
|
|
3722
|
+
t.z.clone().add(s(this, X).z.clone().multiply(i))
|
|
3723
3723
|
);
|
|
3724
3724
|
});
|
|
3725
|
-
return h(this,
|
|
3725
|
+
return h(this, D, e.clone()), h(this, X, t.asPoint ? new E(e, t) : t.clone()), this;
|
|
3726
3726
|
}
|
|
3727
3727
|
get OA() {
|
|
3728
|
-
return s(this,
|
|
3728
|
+
return s(this, D);
|
|
3729
3729
|
}
|
|
3730
3730
|
set OA(e) {
|
|
3731
|
-
h(this,
|
|
3731
|
+
h(this, D, e);
|
|
3732
3732
|
}
|
|
3733
3733
|
get point() {
|
|
3734
|
-
return s(this,
|
|
3734
|
+
return s(this, D).clone();
|
|
3735
3735
|
}
|
|
3736
3736
|
get d() {
|
|
3737
|
-
return s(this,
|
|
3737
|
+
return s(this, X);
|
|
3738
3738
|
}
|
|
3739
3739
|
set d(e) {
|
|
3740
|
-
h(this,
|
|
3740
|
+
h(this, X, e);
|
|
3741
3741
|
}
|
|
3742
3742
|
get tex() {
|
|
3743
3743
|
return {
|
|
3744
|
-
parametric: `${E.asTex("x", "y", "z")} = ${E.asTex(s(this,
|
|
3744
|
+
parametric: `${E.asTex("x", "y", "z")} = ${E.asTex(s(this, D).x.tex, s(this, D).y.tex, s(this, D).z.tex)} + k\\cdot ${E.asTex(s(this, X).x.tex, s(this, X).y.tex, s(this, X).z.tex)}`,
|
|
3745
3745
|
system: `\\left\\{\\begin{aligned}
|
|
3746
|
-
x &= ${new
|
|
3747
|
-
y &= ${new
|
|
3748
|
-
z &= ${new
|
|
3746
|
+
x &= ${new N(s(this, D).x).add(new k(s(this, X).x).multiply(new k("k"))).reorder("k", !0).tex}\\\\
|
|
3747
|
+
y &= ${new N(s(this, D).y).add(new k(s(this, X).y).multiply(new k("k"))).reorder("k", !0).tex}\\\\
|
|
3748
|
+
z &= ${new N(s(this, D).z).add(new k(s(this, X).z).multiply(new k("k"))).reorder("k", !0).tex}
|
|
3749
3749
|
\\end{aligned}\\right.`,
|
|
3750
|
-
cartesian: `\\frac{ ${new
|
|
3750
|
+
cartesian: `\\frac{ ${new N("x", 1, s(this, D).x.clone().opposite()).tex} }{ ${this.direction.x.tex} } = \\frac{ ${new N("y", 1, s(this, D).y.clone().opposite()).tex} }{ ${this.direction.y.tex} } = \\frac{ ${new N("z", 1, s(this, D).z.clone().opposite()).tex} }{ ${this.direction.z.tex} }`
|
|
3751
3751
|
};
|
|
3752
3752
|
}
|
|
3753
3753
|
get display() {
|
|
3754
|
-
const e = s(this,
|
|
3754
|
+
const e = s(this, D).x.display, t = s(this, D).y.display, i = s(this, D).z.display, n = this.direction.simplify(), r = n.x.display, l = n.y.display, c = n.z.display;
|
|
3755
3755
|
return {
|
|
3756
|
-
parametric: `${E.asDisplay("x", "y", "z")} = ${E.asDisplay(s(this,
|
|
3756
|
+
parametric: `${E.asDisplay("x", "y", "z")} = ${E.asDisplay(s(this, D).x.display, s(this, D).y.display, s(this, D).z.display)} + k\\cdot ${E.asDisplay(s(this, X).x.display, s(this, X).y.display, s(this, X).z.display)}`,
|
|
3757
3757
|
system: "",
|
|
3758
3758
|
cartesian: `(x-${e})/${r} = (y-${t})/${l} = (z-${i})/${c}`
|
|
3759
3759
|
};
|
|
3760
3760
|
}
|
|
3761
3761
|
get direction() {
|
|
3762
|
-
return s(this,
|
|
3762
|
+
return s(this, X).clone();
|
|
3763
3763
|
}
|
|
3764
3764
|
distanceTo(e) {
|
|
3765
|
-
const t = new E(s(this,
|
|
3765
|
+
const t = new E(s(this, D), e), i = this.direction, n = this.direction.normSquare, r = t.cross(i).normSquare, l = r.clone().divide(n), c = l.clone().sqrt();
|
|
3766
3766
|
return console.log("CROSS", t.cross(i).display), {
|
|
3767
3767
|
value: Math.sqrt(l.value),
|
|
3768
3768
|
fraction: l.clone().sqrt(),
|
|
@@ -3771,76 +3771,82 @@ const ct = class ct {
|
|
|
3771
3771
|
}
|
|
3772
3772
|
hitSegment(e, t) {
|
|
3773
3773
|
const i = this.intersection(
|
|
3774
|
-
new
|
|
3774
|
+
new pt(e, t)
|
|
3775
3775
|
);
|
|
3776
3776
|
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;
|
|
3777
3777
|
}
|
|
3778
3778
|
};
|
|
3779
|
-
|
|
3780
|
-
a(
|
|
3781
|
-
let
|
|
3782
|
-
var
|
|
3783
|
-
class
|
|
3779
|
+
D = new WeakMap(), X = new WeakMap(), // A line is defined as the canonical form
|
|
3780
|
+
a(pt, "PERPENDICULAR", fi.Perpendicular), a(pt, "PARALLEL", fi.Parallel);
|
|
3781
|
+
let Bt = pt;
|
|
3782
|
+
var $e;
|
|
3783
|
+
class vs {
|
|
3784
3784
|
constructor(...e) {
|
|
3785
|
-
m(this,
|
|
3786
|
-
return h(this,
|
|
3785
|
+
m(this, $e, []);
|
|
3786
|
+
return h(this, $e, e), this;
|
|
3787
3787
|
}
|
|
3788
3788
|
get values() {
|
|
3789
|
-
return s(this,
|
|
3789
|
+
return s(this, $e);
|
|
3790
3790
|
}
|
|
3791
3791
|
get array() {
|
|
3792
|
-
return s(this,
|
|
3792
|
+
return s(this, $e).map((e) => e.array);
|
|
3793
3793
|
}
|
|
3794
3794
|
get dimension() {
|
|
3795
|
-
return [s(this,
|
|
3795
|
+
return [s(this, $e).length, s(this, $e)[0].dimension];
|
|
3796
3796
|
}
|
|
3797
3797
|
isSquare() {
|
|
3798
|
-
return s(this,
|
|
3798
|
+
return s(this, $e).length === s(this, $e)[0].dimension;
|
|
3799
3799
|
}
|
|
3800
3800
|
determinant() {
|
|
3801
3801
|
if (!this.isSquare())
|
|
3802
3802
|
throw new Error("Matrix is not square");
|
|
3803
|
-
return
|
|
3803
|
+
return gs(...this.values);
|
|
3804
3804
|
}
|
|
3805
3805
|
}
|
|
3806
|
-
|
|
3807
|
-
var
|
|
3808
|
-
const
|
|
3806
|
+
$e = new WeakMap();
|
|
3807
|
+
var Be, Xe;
|
|
3808
|
+
const Ei = class Ei {
|
|
3809
3809
|
constructor(e) {
|
|
3810
|
-
m(this,
|
|
3811
|
-
m(this,
|
|
3810
|
+
m(this, Be, new E(0, 0, 1));
|
|
3811
|
+
m(this, Xe, new S(0, 0, 0));
|
|
3812
3812
|
return e && this.parse(e), this;
|
|
3813
3813
|
}
|
|
3814
3814
|
get normal() {
|
|
3815
|
-
return s(this,
|
|
3815
|
+
return s(this, Be);
|
|
3816
3816
|
}
|
|
3817
3817
|
set normal(e) {
|
|
3818
|
-
h(this,
|
|
3818
|
+
h(this, Be, e), s(this, Be).asPoint = !1;
|
|
3819
3819
|
}
|
|
3820
3820
|
get point() {
|
|
3821
|
-
return s(this,
|
|
3821
|
+
return s(this, Xe);
|
|
3822
3822
|
}
|
|
3823
3823
|
set point(e) {
|
|
3824
|
-
h(this,
|
|
3824
|
+
h(this, Xe, e), s(this, Xe).asPoint = !0;
|
|
3825
3825
|
}
|
|
3826
3826
|
get a() {
|
|
3827
|
-
return s(this,
|
|
3827
|
+
return s(this, Be).x;
|
|
3828
3828
|
}
|
|
3829
3829
|
get b() {
|
|
3830
|
-
return s(this,
|
|
3830
|
+
return s(this, Be).y;
|
|
3831
3831
|
}
|
|
3832
3832
|
get c() {
|
|
3833
|
-
return s(this,
|
|
3833
|
+
return s(this, Be).z;
|
|
3834
3834
|
}
|
|
3835
3835
|
get d() {
|
|
3836
|
-
return s(this,
|
|
3836
|
+
return s(this, Be).dot(s(this, Xe)).opposite();
|
|
3837
3837
|
}
|
|
3838
3838
|
get tex() {
|
|
3839
|
-
return new
|
|
3840
|
-
new
|
|
3841
|
-
new
|
|
3839
|
+
return new V(
|
|
3840
|
+
new N("xyz", this.a, this.b, this.c, this.d),
|
|
3841
|
+
new N(0)
|
|
3842
3842
|
).reduce().tex;
|
|
3843
3843
|
}
|
|
3844
|
+
get display() {
|
|
3845
|
+
return new V(
|
|
3846
|
+
new N("xyz", this.a, this.b, this.c, this.d),
|
|
3847
|
+
new N(0)
|
|
3848
|
+
).reduce().display;
|
|
3849
|
+
}
|
|
3844
3850
|
parse(e) {
|
|
3845
3851
|
var t, i, n;
|
|
3846
3852
|
if (e.point && e.normal) {
|
|
@@ -3854,23 +3860,23 @@ const mi = class mi {
|
|
|
3854
3860
|
return;
|
|
3855
3861
|
}
|
|
3856
3862
|
if (e.equation) {
|
|
3857
|
-
const r = e.equation.moveLeft().reduce().left, l = r.monomByLetter("x").coefficient, c = r.monomByLetter("y").coefficient,
|
|
3858
|
-
this.normal = new E(l, c,
|
|
3863
|
+
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;
|
|
3864
|
+
this.normal = new E(l, c, f), l.isNotZero() ? this.point = new S(d.clone().divide(l).opposite(), 0, 0) : c.isNotZero() ? this.point = new S(0, d.clone().divide(c).opposite(), 0) : this.point = new S(0, 0, d.clone().divide(f).opposite());
|
|
3859
3865
|
return;
|
|
3860
3866
|
}
|
|
3861
3867
|
if (((i = e.points) == null ? void 0 : i.length) === 3 && e.points.every((r) => r instanceof E)) {
|
|
3862
|
-
const r = e.points[0], l = e.points[1], c = e.points[2],
|
|
3863
|
-
this.normal =
|
|
3868
|
+
const r = e.points[0], l = e.points[1], c = e.points[2], f = new E(r, l), d = new E(r, c);
|
|
3869
|
+
this.normal = f.cross(d), this.point = r;
|
|
3864
3870
|
return;
|
|
3865
3871
|
}
|
|
3866
3872
|
if (((n = e.coefficients) == null ? void 0 : n.length) === 4) {
|
|
3867
|
-
const [r, l, c,
|
|
3868
|
-
this.normal = new E(r, l, c), this.point = new S(0, 0, -
|
|
3873
|
+
const [r, l, c, f] = e.coefficients;
|
|
3874
|
+
this.normal = new E(r, l, c), this.point = new S(0, 0, -f);
|
|
3869
3875
|
return;
|
|
3870
3876
|
}
|
|
3871
3877
|
}
|
|
3872
3878
|
angle(e, t, i) {
|
|
3873
|
-
if (e instanceof
|
|
3879
|
+
if (e instanceof Ei)
|
|
3874
3880
|
return this.normal.angle(e.normal, t, i);
|
|
3875
3881
|
let n;
|
|
3876
3882
|
if (e instanceof E) {
|
|
@@ -3895,25 +3901,25 @@ const mi = class mi {
|
|
|
3895
3901
|
return this.normal.dot(e).add(this.d).isZero();
|
|
3896
3902
|
}
|
|
3897
3903
|
};
|
|
3898
|
-
|
|
3899
|
-
let
|
|
3900
|
-
var
|
|
3901
|
-
const
|
|
3904
|
+
Be = new WeakMap(), Xe = new WeakMap();
|
|
3905
|
+
let pi = Ei;
|
|
3906
|
+
var Q, _, ee, ot, Pe, xt, ei, Et, Re, ti, ht;
|
|
3907
|
+
const ii = class ii {
|
|
3902
3908
|
constructor(...e) {
|
|
3903
|
-
m(this,
|
|
3909
|
+
m(this, Q, new S());
|
|
3904
3910
|
m(this, _, new S());
|
|
3905
3911
|
m(this, ee, new S());
|
|
3906
|
-
m(this,
|
|
3907
|
-
AB: new
|
|
3908
|
-
AC: new
|
|
3909
|
-
BC: new
|
|
3912
|
+
m(this, ot, {
|
|
3913
|
+
AB: new z(),
|
|
3914
|
+
AC: new z(),
|
|
3915
|
+
BC: new z()
|
|
3910
3916
|
});
|
|
3911
|
-
m(this,
|
|
3917
|
+
m(this, Pe, {
|
|
3912
3918
|
AB: new S(),
|
|
3913
3919
|
AC: new S(),
|
|
3914
3920
|
BC: new S()
|
|
3915
3921
|
});
|
|
3916
|
-
m(this,
|
|
3922
|
+
m(this, xt, null);
|
|
3917
3923
|
// ------------------------------------------
|
|
3918
3924
|
// Creation / parsing functions
|
|
3919
3925
|
// ------------------------------------------
|
|
@@ -3925,7 +3931,7 @@ const Qt = class Qt {
|
|
|
3925
3931
|
*/
|
|
3926
3932
|
a(this, "parse", (...e) => {
|
|
3927
3933
|
if (e.length === 6) {
|
|
3928
|
-
const t = e.map((i) => new
|
|
3934
|
+
const t = e.map((i) => new u(i));
|
|
3929
3935
|
if (t.some((i) => i.isNaN()))
|
|
3930
3936
|
throw new Error("One of the values is not a valid number");
|
|
3931
3937
|
return this.parse(
|
|
@@ -3936,11 +3942,11 @@ const Qt = class Qt {
|
|
|
3936
3942
|
} else if (e.length === 3) {
|
|
3937
3943
|
if (e.every((t) => typeof t == "string"))
|
|
3938
3944
|
return this.parse(
|
|
3939
|
-
...e.map((t) => new
|
|
3945
|
+
...e.map((t) => new z(t))
|
|
3940
3946
|
);
|
|
3941
|
-
if (e.every((t) => t instanceof
|
|
3947
|
+
if (e.every((t) => t instanceof z)) {
|
|
3942
3948
|
const t = e[0].clone(), i = e[1].clone(), n = e[2].clone();
|
|
3943
|
-
h(this,
|
|
3949
|
+
h(this, ot, { AB: t, BC: i, AC: n });
|
|
3944
3950
|
let r = t.intersection(i);
|
|
3945
3951
|
if (r.hasIntersection)
|
|
3946
3952
|
h(this, _, r.point.clone());
|
|
@@ -3951,23 +3957,23 @@ const Qt = class Qt {
|
|
|
3951
3957
|
else
|
|
3952
3958
|
throw new Error("Lines do not intersect !");
|
|
3953
3959
|
if (r = n.intersection(t), r.hasIntersection)
|
|
3954
|
-
h(this,
|
|
3960
|
+
h(this, Q, r.point.clone());
|
|
3955
3961
|
else
|
|
3956
3962
|
throw new Error("Lines do not intersect !");
|
|
3957
|
-
} else e.every((t) => t instanceof S) && (h(this,
|
|
3958
|
-
AB: new
|
|
3959
|
-
BC: new
|
|
3960
|
-
AC: new
|
|
3963
|
+
} else e.every((t) => t instanceof S) && (h(this, Q, e[0].clone()), h(this, _, e[1].clone()), h(this, ee, e[2].clone()), h(this, ot, {
|
|
3964
|
+
AB: new z(s(this, Q), s(this, _)),
|
|
3965
|
+
BC: new z(s(this, _), s(this, ee)),
|
|
3966
|
+
AC: new z(s(this, Q), s(this, ee))
|
|
3961
3967
|
}));
|
|
3962
|
-
} else if (e.length === 1 && e[0] instanceof
|
|
3968
|
+
} else if (e.length === 1 && e[0] instanceof ii)
|
|
3963
3969
|
return e[0].clone();
|
|
3964
|
-
return s(this,
|
|
3970
|
+
return s(this, ei).call(this), this;
|
|
3965
3971
|
});
|
|
3966
3972
|
/**
|
|
3967
3973
|
* Clone the Triangle class
|
|
3968
3974
|
*/
|
|
3969
|
-
a(this, "clone", () => new
|
|
3970
|
-
s(this,
|
|
3975
|
+
a(this, "clone", () => new ii(
|
|
3976
|
+
s(this, Q).clone(),
|
|
3971
3977
|
s(this, _).clone(),
|
|
3972
3978
|
s(this, ee).clone()
|
|
3973
3979
|
));
|
|
@@ -3977,59 +3983,59 @@ const Qt = class Qt {
|
|
|
3977
3983
|
/**
|
|
3978
3984
|
* Generate the Line object for the three segments of the triangle
|
|
3979
3985
|
*/
|
|
3980
|
-
m(this,
|
|
3981
|
-
s(this,
|
|
3982
|
-
AB: new S().middleOf(s(this,
|
|
3983
|
-
AC: new S().middleOf(s(this,
|
|
3986
|
+
m(this, ei, () => {
|
|
3987
|
+
s(this, Q).asPoint = !0, s(this, _).asPoint = !0, s(this, ee).asPoint = !0, h(this, Pe, {
|
|
3988
|
+
AB: new S().middleOf(s(this, Q), s(this, _)),
|
|
3989
|
+
AC: new S().middleOf(s(this, Q), s(this, ee)),
|
|
3984
3990
|
BC: new S().middleOf(s(this, _), s(this, ee))
|
|
3985
|
-
}), h(this,
|
|
3991
|
+
}), h(this, xt, s(this, ti).call(this));
|
|
3986
3992
|
});
|
|
3987
3993
|
/**
|
|
3988
3994
|
* Get the Vector2D class for the given name
|
|
3989
3995
|
* @param ptName
|
|
3990
3996
|
*/
|
|
3991
|
-
m(this,
|
|
3997
|
+
m(this, Et, (e) => {
|
|
3992
3998
|
switch (e.toUpperCase()) {
|
|
3993
3999
|
case "A":
|
|
3994
|
-
return s(this,
|
|
4000
|
+
return s(this, Q);
|
|
3995
4001
|
case "B":
|
|
3996
4002
|
return s(this, _);
|
|
3997
4003
|
case "C":
|
|
3998
4004
|
return s(this, ee);
|
|
3999
4005
|
}
|
|
4000
|
-
return s(this,
|
|
4006
|
+
return s(this, Q);
|
|
4001
4007
|
});
|
|
4002
4008
|
/**
|
|
4003
4009
|
* Get the vector for the segment given by name.
|
|
4004
4010
|
* @param ptName1
|
|
4005
4011
|
* @param ptName2
|
|
4006
4012
|
*/
|
|
4007
|
-
m(this,
|
|
4008
|
-
s(this,
|
|
4009
|
-
s(this,
|
|
4013
|
+
m(this, Re, (e, t) => new E(
|
|
4014
|
+
s(this, Et).call(this, e),
|
|
4015
|
+
s(this, Et).call(this, t)
|
|
4010
4016
|
));
|
|
4011
|
-
m(this,
|
|
4017
|
+
m(this, ti, () => {
|
|
4012
4018
|
const e = {
|
|
4013
|
-
A: new
|
|
4014
|
-
B: new
|
|
4015
|
-
C: new
|
|
4019
|
+
A: new z().fromPoints(s(this, Q), s(this, Pe).BC),
|
|
4020
|
+
B: new z().fromPoints(s(this, _), s(this, Pe).AC),
|
|
4021
|
+
C: new z().fromPoints(s(this, ee), s(this, Pe).AB),
|
|
4016
4022
|
intersection: null
|
|
4017
4023
|
}, t = {
|
|
4018
|
-
AB: new
|
|
4019
|
-
AC: new
|
|
4020
|
-
BC: new
|
|
4024
|
+
AB: new z().fromPointAndNormal(s(this, Pe).AB, new E(s(this, Q), s(this, _)).normal()),
|
|
4025
|
+
AC: new z().fromPointAndNormal(s(this, Pe).AC, new E(s(this, Q), s(this, ee)).normal()),
|
|
4026
|
+
BC: new z().fromPointAndNormal(s(this, Pe).BC, new E(s(this, _), s(this, ee)).normal()),
|
|
4021
4027
|
intersection: null
|
|
4022
4028
|
}, i = {
|
|
4023
|
-
A: new
|
|
4024
|
-
B: new
|
|
4025
|
-
C: new
|
|
4029
|
+
A: new z().fromPointAndNormal(s(this, Q), new E(s(this, _), s(this, ee)).normal()),
|
|
4030
|
+
B: new z().fromPointAndNormal(s(this, _), new E(s(this, Q), s(this, ee)).normal()),
|
|
4031
|
+
C: new z().fromPointAndNormal(s(this, ee), new E(s(this, Q), s(this, _)).normal()),
|
|
4026
4032
|
intersection: null
|
|
4027
|
-
}, n = s(this,
|
|
4033
|
+
}, n = s(this, ht).call(this, "A"), r = s(this, ht).call(this, "B"), l = s(this, ht).call(this, "C"), c = {
|
|
4028
4034
|
A: n.internal,
|
|
4029
4035
|
B: r.internal,
|
|
4030
4036
|
C: r.internal,
|
|
4031
4037
|
intersection: null
|
|
4032
|
-
},
|
|
4038
|
+
}, f = {
|
|
4033
4039
|
A: n.external,
|
|
4034
4040
|
B: r.external,
|
|
4035
4041
|
C: l.external,
|
|
@@ -4039,16 +4045,16 @@ const Qt = class Qt {
|
|
|
4039
4045
|
mediators: t,
|
|
4040
4046
|
heights: i,
|
|
4041
4047
|
bisectors: c,
|
|
4042
|
-
externalBisectors:
|
|
4048
|
+
externalBisectors: f
|
|
4043
4049
|
};
|
|
4044
4050
|
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;
|
|
4045
4051
|
});
|
|
4046
|
-
m(this,
|
|
4052
|
+
m(this, ht, (e) => {
|
|
4047
4053
|
const t = this.lines;
|
|
4048
4054
|
let i, n;
|
|
4049
4055
|
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)
|
|
4050
4056
|
throw new Error(`The point ${e} does not exist`);
|
|
4051
|
-
const r = i.n.simplify().norm, l = n.n.simplify().norm, c = i.getEquation().multiply(l),
|
|
4057
|
+
const r = i.n.simplify().norm, l = n.n.simplify().norm, c = i.getEquation().multiply(l), f = n.getEquation().multiply(r), d = new z(c.clone().subtract(f).simplify()), p = new z(f.clone().subtract(c).simplify());
|
|
4052
4058
|
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 };
|
|
4053
4059
|
});
|
|
4054
4060
|
return e.length > 0 && this.parse(...e), this;
|
|
@@ -4057,7 +4063,7 @@ const Qt = class Qt {
|
|
|
4057
4063
|
// Getter and setters
|
|
4058
4064
|
// ------------------------------------------
|
|
4059
4065
|
get A() {
|
|
4060
|
-
return s(this,
|
|
4066
|
+
return s(this, Q);
|
|
4061
4067
|
}
|
|
4062
4068
|
get B() {
|
|
4063
4069
|
return s(this, _);
|
|
@@ -4066,22 +4072,22 @@ const Qt = class Qt {
|
|
|
4066
4072
|
return s(this, ee);
|
|
4067
4073
|
}
|
|
4068
4074
|
get AB() {
|
|
4069
|
-
return s(this,
|
|
4075
|
+
return s(this, Re).call(this, "A", "B");
|
|
4070
4076
|
}
|
|
4071
4077
|
get BA() {
|
|
4072
|
-
return s(this,
|
|
4078
|
+
return s(this, Re).call(this, "B", "A");
|
|
4073
4079
|
}
|
|
4074
4080
|
get BC() {
|
|
4075
|
-
return s(this,
|
|
4081
|
+
return s(this, Re).call(this, "B", "C");
|
|
4076
4082
|
}
|
|
4077
4083
|
get CB() {
|
|
4078
|
-
return s(this,
|
|
4084
|
+
return s(this, Re).call(this, "C", "B");
|
|
4079
4085
|
}
|
|
4080
4086
|
get AC() {
|
|
4081
|
-
return s(this,
|
|
4087
|
+
return s(this, Re).call(this, "A", "C");
|
|
4082
4088
|
}
|
|
4083
4089
|
get CA() {
|
|
4084
|
-
return s(this,
|
|
4090
|
+
return s(this, Re).call(this, "C", "A");
|
|
4085
4091
|
}
|
|
4086
4092
|
get isRectangle() {
|
|
4087
4093
|
return !!(this.AB.isNormalTo(this.BC) || this.AB.isNormalTo(this.AC) || this.BC.isNormalTo(this.AC));
|
|
@@ -4093,15 +4099,119 @@ const Qt = class Qt {
|
|
|
4093
4099
|
return this.AB.normSquare.isEqual(this.BC.normSquare) || this.AB.normSquare.isEqual(this.AC.normSquare) || this.BC.normSquare.isEqual(this.AC.normSquare);
|
|
4094
4100
|
}
|
|
4095
4101
|
get lines() {
|
|
4096
|
-
return s(this,
|
|
4102
|
+
return s(this, ot);
|
|
4097
4103
|
}
|
|
4098
4104
|
get remarquables() {
|
|
4099
|
-
return s(this,
|
|
4105
|
+
return s(this, xt);
|
|
4100
4106
|
}
|
|
4101
4107
|
};
|
|
4102
|
-
|
|
4103
|
-
let
|
|
4104
|
-
|
|
4108
|
+
Q = new WeakMap(), _ = new WeakMap(), ee = new WeakMap(), ot = new WeakMap(), Pe = new WeakMap(), xt = new WeakMap(), ei = new WeakMap(), Et = new WeakMap(), Re = new WeakMap(), ti = new WeakMap(), ht = new WeakMap();
|
|
4109
|
+
let mi = ii;
|
|
4110
|
+
var ji = /* @__PURE__ */ ((o) => (o[o.INTERIOR = 0] = "INTERIOR", o[o.EXTERIOR = 1] = "EXTERIOR", o[o.SECANT = 2] = "SECANT", o[o.TANGENT_INSIDE = 3] = "TANGENT_INSIDE", o[o.TANGENT_OUTSIDE = 4] = "TANGENT_OUTSIDE", o[o.SUPERPOSED = 5] = "SUPERPOSED", o[o.CONCENTRIC = 6] = "CONCENTRIC", o))(ji || {}), Te, de, Oe, at, Nt, qt, gi;
|
|
4111
|
+
class Ui {
|
|
4112
|
+
constructor(e, t) {
|
|
4113
|
+
m(this, qt);
|
|
4114
|
+
m(this, Te);
|
|
4115
|
+
m(this, de);
|
|
4116
|
+
m(this, Oe);
|
|
4117
|
+
m(this, at, 1);
|
|
4118
|
+
m(this, Nt, (e) => {
|
|
4119
|
+
if (s(this, Oe) === void 0)
|
|
4120
|
+
throw new Error("Sphere3 is undefined");
|
|
4121
|
+
if (s(this, at) === 0)
|
|
4122
|
+
return e ? s(this, Oe).tex : s(this, Oe).display;
|
|
4123
|
+
const t = [];
|
|
4124
|
+
return ["x", "y", "z"].forEach((n) => {
|
|
4125
|
+
if (this.center[n].isZero())
|
|
4126
|
+
t.push(`${n}^2`);
|
|
4127
|
+
else {
|
|
4128
|
+
const r = new N(n).subtract(this.center[n]);
|
|
4129
|
+
t.push(
|
|
4130
|
+
e ? `\\(${r.tex}\\)^2` : `(${r.display})^2`
|
|
4131
|
+
);
|
|
4132
|
+
}
|
|
4133
|
+
}), t.join("+") + "=" + (e ? this.squareRadius.tex : this.squareRadius.display);
|
|
4134
|
+
});
|
|
4135
|
+
a(this, "relativePosition", (e) => {
|
|
4136
|
+
const t = this.center.distanceTo(e.center).value, i = this.radius.value, n = e.radius.value;
|
|
4137
|
+
return t > i + n ? 1 : t === i + n ? 4 : t === Math.abs(i - n) ? 3 : t < Math.abs(i - n) ? 0 : t === 0 ? i === n ? 5 : 6 : 2;
|
|
4138
|
+
});
|
|
4139
|
+
a(this, "isPointOnSphere", (e) => {
|
|
4140
|
+
var t;
|
|
4141
|
+
return ((t = s(this, Oe)) == null ? void 0 : t.test({
|
|
4142
|
+
x: e.x,
|
|
4143
|
+
y: e.y,
|
|
4144
|
+
z: e.z
|
|
4145
|
+
})) ?? !1;
|
|
4146
|
+
});
|
|
4147
|
+
return e && t && (h(this, Te, e), h(this, de, new u(t).clone().pow(2)), A(this, qt, gi).call(this)), this;
|
|
4148
|
+
}
|
|
4149
|
+
fromEquation(e) {
|
|
4150
|
+
const t = new V(e).moveLeft().reduce(), i = ["x", "y", "z"];
|
|
4151
|
+
if (i.some((r) => t.degree(r).value !== 2))
|
|
4152
|
+
return this.makeUndefined();
|
|
4153
|
+
const n = t.left.monomByDegree(2, "x").coefficient;
|
|
4154
|
+
return i.some((r) => t.left.monomByDegree(2, r).coefficient.isNotEqual(n)) ? this.makeUndefined() : (h(this, Te, new S(
|
|
4155
|
+
t.left.monomByDegree(1, "x").coefficient.clone().opposite().divide(2),
|
|
4156
|
+
t.left.monomByDegree(1, "y").coefficient.clone().opposite().divide(2),
|
|
4157
|
+
t.left.monomByDegree(1, "z").coefficient.clone().opposite().divide(2)
|
|
4158
|
+
)), h(this, de, t.left.monomByDegree(0).coefficient.clone().opposite().add(s(this, Te).x.clone().pow(2)).add(s(this, Te).y.clone().pow(2)).add(s(this, Te).z.clone().pow(2))), A(this, qt, gi).call(this), this);
|
|
4159
|
+
}
|
|
4160
|
+
get center() {
|
|
4161
|
+
if (s(this, Te) === void 0)
|
|
4162
|
+
throw new Error("Sphere3 is undefined");
|
|
4163
|
+
return s(this, Te);
|
|
4164
|
+
}
|
|
4165
|
+
get squareRadius() {
|
|
4166
|
+
if (s(this, de) === void 0)
|
|
4167
|
+
throw new Error("Sphere3 is undefined");
|
|
4168
|
+
return s(this, de);
|
|
4169
|
+
}
|
|
4170
|
+
get radius() {
|
|
4171
|
+
if (s(this, de) === void 0)
|
|
4172
|
+
throw new Error("Sphere3 is undefined");
|
|
4173
|
+
return s(this, de).isSquare() ? {
|
|
4174
|
+
tex: s(this, de).clone().sqrt().tex,
|
|
4175
|
+
display: s(this, de).clone().sqrt().display,
|
|
4176
|
+
value: s(this, de).clone().sqrt().value
|
|
4177
|
+
} : {
|
|
4178
|
+
tex: `\\sqrt{${s(this, de).tex}}`,
|
|
4179
|
+
display: `sqrt(${s(this, de).display})`,
|
|
4180
|
+
value: s(this, de).clone().sqrt().value
|
|
4181
|
+
};
|
|
4182
|
+
}
|
|
4183
|
+
get equation() {
|
|
4184
|
+
if (s(this, Oe) === void 0)
|
|
4185
|
+
throw new Error("Sphere3 is undefined");
|
|
4186
|
+
return s(this, Oe);
|
|
4187
|
+
}
|
|
4188
|
+
makeUndefined() {
|
|
4189
|
+
return h(this, Te, void 0), h(this, de, void 0), h(this, Oe, void 0), this;
|
|
4190
|
+
}
|
|
4191
|
+
get centerRadius() {
|
|
4192
|
+
return h(this, at, 1), this;
|
|
4193
|
+
}
|
|
4194
|
+
get developped() {
|
|
4195
|
+
return h(this, at, 0), this;
|
|
4196
|
+
}
|
|
4197
|
+
get tex() {
|
|
4198
|
+
return s(this, Nt).call(this, !0);
|
|
4199
|
+
}
|
|
4200
|
+
get display() {
|
|
4201
|
+
return s(this, Nt).call(this, !1);
|
|
4202
|
+
}
|
|
4203
|
+
}
|
|
4204
|
+
Te = new WeakMap(), de = new WeakMap(), Oe = new WeakMap(), at = new WeakMap(), Nt = new WeakMap(), qt = new WeakSet(), gi = function() {
|
|
4205
|
+
h(this, Oe, new V(
|
|
4206
|
+
new N("x").subtract(this.center.x).pow(2).add(
|
|
4207
|
+
new N("y").subtract(this.center.y).pow(2)
|
|
4208
|
+
).add(
|
|
4209
|
+
new N("z").subtract(this.center.z).pow(2)
|
|
4210
|
+
),
|
|
4211
|
+
new N(this.squareRadius)
|
|
4212
|
+
).reduce());
|
|
4213
|
+
}, a(Ui, "RELATIVE_POSITION", ji);
|
|
4214
|
+
function Pt(o) {
|
|
4105
4215
|
const e = Object.assign(
|
|
4106
4216
|
{
|
|
4107
4217
|
negative: !0,
|
|
@@ -4111,17 +4221,17 @@ function qt(o) {
|
|
|
4111
4221
|
natural: !1
|
|
4112
4222
|
},
|
|
4113
4223
|
o
|
|
4114
|
-
), t = new
|
|
4115
|
-
if (e.negative ? t.numerator =
|
|
4224
|
+
), t = new u();
|
|
4225
|
+
if (e.negative ? t.numerator = H(e.max, e.zero) : t.numerator = me(e.zero ? 0 : 1, e.max), e.natural)
|
|
4116
4226
|
t.denominator = 1;
|
|
4117
4227
|
else {
|
|
4118
4228
|
let i = 0;
|
|
4119
4229
|
for (; t.isRelative() && i < 10; )
|
|
4120
|
-
t.denominator =
|
|
4230
|
+
t.denominator = me(1, e.max), i++;
|
|
4121
4231
|
}
|
|
4122
4232
|
return e.reduced ? t.reduce() : t;
|
|
4123
4233
|
}
|
|
4124
|
-
function
|
|
4234
|
+
function Gi(o) {
|
|
4125
4235
|
const e = Object.assign(
|
|
4126
4236
|
{
|
|
4127
4237
|
letters: "x",
|
|
@@ -4130,8 +4240,8 @@ function Ri(o) {
|
|
|
4130
4240
|
zero: !1
|
|
4131
4241
|
},
|
|
4132
4242
|
o
|
|
4133
|
-
), t = new
|
|
4134
|
-
if (t.coefficient =
|
|
4243
|
+
), t = new k();
|
|
4244
|
+
if (t.coefficient = Pt({
|
|
4135
4245
|
zero: e.zero,
|
|
4136
4246
|
reduced: !0,
|
|
4137
4247
|
natural: !e.fraction
|
|
@@ -4139,14 +4249,14 @@ function Ri(o) {
|
|
|
4139
4249
|
for (const i of e.letters.split(""))
|
|
4140
4250
|
t.setLetter(i, 0);
|
|
4141
4251
|
for (let i = 0; i < e.degree; i++) {
|
|
4142
|
-
const n =
|
|
4252
|
+
const n = bi(e.letters.split(""));
|
|
4143
4253
|
t.setLetter(n, t.degree(n).clone().add(1));
|
|
4144
4254
|
}
|
|
4145
4255
|
} else
|
|
4146
4256
|
t.setLetter(e.letters, e.degree);
|
|
4147
4257
|
return t;
|
|
4148
4258
|
}
|
|
4149
|
-
const
|
|
4259
|
+
const bs = {
|
|
4150
4260
|
letters: "x",
|
|
4151
4261
|
degree: 2,
|
|
4152
4262
|
fraction: !1,
|
|
@@ -4157,14 +4267,14 @@ const us = {
|
|
|
4157
4267
|
numberOfMonoms: 0,
|
|
4158
4268
|
positive: !0
|
|
4159
4269
|
};
|
|
4160
|
-
function
|
|
4270
|
+
function Wi(o) {
|
|
4161
4271
|
const e = Object.assign(
|
|
4162
|
-
|
|
4272
|
+
bs,
|
|
4163
4273
|
o
|
|
4164
|
-
), t = new
|
|
4274
|
+
), t = new N().empty();
|
|
4165
4275
|
let i;
|
|
4166
4276
|
for (let n = e.degree; n >= 0; n--)
|
|
4167
|
-
i =
|
|
4277
|
+
i = Gi({
|
|
4168
4278
|
letters: e.letters,
|
|
4169
4279
|
degree: n,
|
|
4170
4280
|
fraction: e.fraction,
|
|
@@ -4172,12 +4282,12 @@ function zi(o) {
|
|
|
4172
4282
|
}), e.unit && e.degree === n && i.coefficient.one(), t.add(i);
|
|
4173
4283
|
if (e.positive && t.monomByDegree().coefficient.isNegative() && t.monomByDegree().coefficient.opposite(), e.numberOfMonoms && e.numberOfMonoms > 0 && e.numberOfMonoms < t.length)
|
|
4174
4284
|
for (; t.length > e.numberOfMonoms; ) {
|
|
4175
|
-
const n =
|
|
4285
|
+
const n = me(1, t.length - 1);
|
|
4176
4286
|
t.monoms.splice(n, 1);
|
|
4177
4287
|
}
|
|
4178
4288
|
return t.reduce();
|
|
4179
4289
|
}
|
|
4180
|
-
function
|
|
4290
|
+
function xs(o) {
|
|
4181
4291
|
const e = Object.assign(
|
|
4182
4292
|
{
|
|
4183
4293
|
letters: "x",
|
|
@@ -4197,9 +4307,9 @@ function fs(o) {
|
|
|
4197
4307
|
}
|
|
4198
4308
|
},
|
|
4199
4309
|
o
|
|
4200
|
-
), t = new
|
|
4310
|
+
), t = new N().one();
|
|
4201
4311
|
for (let i = 0; i < e.degree; i++) {
|
|
4202
|
-
const n =
|
|
4312
|
+
const n = Wi({
|
|
4203
4313
|
degree: 1,
|
|
4204
4314
|
unit: e.unit,
|
|
4205
4315
|
fraction: e.fraction,
|
|
@@ -4208,9 +4318,9 @@ function fs(o) {
|
|
|
4208
4318
|
});
|
|
4209
4319
|
t.multiply(n);
|
|
4210
4320
|
}
|
|
4211
|
-
return new
|
|
4321
|
+
return new V(t, 0);
|
|
4212
4322
|
}
|
|
4213
|
-
function
|
|
4323
|
+
function yi(o) {
|
|
4214
4324
|
const e = Object.assign(
|
|
4215
4325
|
{
|
|
4216
4326
|
axis: !0,
|
|
@@ -4219,10 +4329,10 @@ function ci(o) {
|
|
|
4219
4329
|
quadrant: null
|
|
4220
4330
|
},
|
|
4221
4331
|
o
|
|
4222
|
-
), t = e.axis === "x", i = e.axis === "y", n = e.fraction ?
|
|
4332
|
+
), t = e.axis === "x", i = e.axis === "y", n = e.fraction ? Pt({ max: e.max, zero: t }) : new u(H(e.max, t)), r = e.fraction ? Pt({ max: e.max, zero: i }) : new u(H(e.max, i));
|
|
4223
4333
|
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 S(n, r);
|
|
4224
4334
|
}
|
|
4225
|
-
function
|
|
4335
|
+
function Es(o) {
|
|
4226
4336
|
const e = Object.assign(
|
|
4227
4337
|
{
|
|
4228
4338
|
center: {
|
|
@@ -4232,116 +4342,119 @@ function ds(o) {
|
|
|
4232
4342
|
pointsOnCircle: 8
|
|
4233
4343
|
},
|
|
4234
4344
|
o
|
|
4235
|
-
), t =
|
|
4345
|
+
), t = yi(e.center);
|
|
4236
4346
|
let i, n;
|
|
4237
|
-
return e.pointsOnCircle === 8 ? (i =
|
|
4347
|
+
return e.pointsOnCircle === 8 ? (i = me(1, 3), n = i ** 2 + (i + 1) ** 2) : n = me(1, 20), new $t(t, n, !0);
|
|
4238
4348
|
}
|
|
4239
|
-
function
|
|
4349
|
+
function Ns(o) {
|
|
4240
4350
|
const e = Object.assign(
|
|
4241
4351
|
{
|
|
4242
4352
|
A: {
|
|
4243
|
-
x:
|
|
4244
|
-
y:
|
|
4353
|
+
x: H(10),
|
|
4354
|
+
y: H(10)
|
|
4245
4355
|
}
|
|
4246
4356
|
},
|
|
4247
4357
|
o
|
|
4248
4358
|
), t = new E(
|
|
4249
|
-
|
|
4250
|
-
|
|
4359
|
+
H(10),
|
|
4360
|
+
H(10)
|
|
4251
4361
|
);
|
|
4252
4362
|
for (; t.isNull; )
|
|
4253
|
-
t.x =
|
|
4254
|
-
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
|
|
4363
|
+
t.x = H(10), t.y = H(10);
|
|
4364
|
+
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 z().fromPointAndDirection(new E(e.A.x, e.A.y), t);
|
|
4255
4365
|
}
|
|
4256
|
-
function
|
|
4366
|
+
function qs(o) {
|
|
4257
4367
|
const e = Object.assign(
|
|
4258
4368
|
{
|
|
4259
4369
|
A: {
|
|
4260
|
-
x:
|
|
4261
|
-
y:
|
|
4262
|
-
z:
|
|
4370
|
+
x: H(10),
|
|
4371
|
+
y: H(10),
|
|
4372
|
+
z: H(10)
|
|
4263
4373
|
},
|
|
4264
4374
|
direction: {
|
|
4265
|
-
x:
|
|
4266
|
-
y:
|
|
4267
|
-
z:
|
|
4375
|
+
x: H(10),
|
|
4376
|
+
y: H(10),
|
|
4377
|
+
z: H(10)
|
|
4268
4378
|
}
|
|
4269
4379
|
},
|
|
4270
4380
|
o
|
|
4271
4381
|
), t = new S(e.A.x, e.A.y, e.A.z), i = new E(e.direction.x, e.direction.y, e.direction.z);
|
|
4272
|
-
return new
|
|
4382
|
+
return new Bt(t, i);
|
|
4273
4383
|
}
|
|
4274
|
-
const
|
|
4275
|
-
equation: (o) =>
|
|
4276
|
-
polynom: (o) =>
|
|
4277
|
-
monom: (o) =>
|
|
4278
|
-
fraction: (o) =>
|
|
4279
|
-
number: (o, e, t) =>
|
|
4280
|
-
numberSym: (o, e) =>
|
|
4281
|
-
prime: (o) =>
|
|
4282
|
-
bool: (o) =>
|
|
4283
|
-
array: (o, e) =>
|
|
4284
|
-
item: (o) =>
|
|
4285
|
-
shuffle: (o) =>
|
|
4286
|
-
line: (o) =>
|
|
4287
|
-
line3: (o) =>
|
|
4288
|
-
vector: (o) =>
|
|
4384
|
+
const As = {
|
|
4385
|
+
equation: (o) => xs(o),
|
|
4386
|
+
polynom: (o) => Wi(o),
|
|
4387
|
+
monom: (o) => Gi(o),
|
|
4388
|
+
fraction: (o) => Pt(o),
|
|
4389
|
+
number: (o, e, t) => me(o, e, t),
|
|
4390
|
+
numberSym: (o, e) => H(o, e),
|
|
4391
|
+
prime: (o) => ys(o),
|
|
4392
|
+
bool: (o) => Ri(o),
|
|
4393
|
+
array: (o, e) => ws(o, e),
|
|
4394
|
+
item: (o) => bi(o),
|
|
4395
|
+
shuffle: (o) => Di(o),
|
|
4396
|
+
line: (o) => Ns(o),
|
|
4397
|
+
line3: (o) => qs(o),
|
|
4398
|
+
vector: (o) => yi(o),
|
|
4289
4399
|
point: (o) => {
|
|
4290
|
-
const e =
|
|
4400
|
+
const e = yi(o);
|
|
4291
4401
|
return e.asPoint = !0, e;
|
|
4292
4402
|
},
|
|
4293
|
-
circle: (o) =>
|
|
4294
|
-
},
|
|
4295
|
-
Numeric:
|
|
4296
|
-
Fraction:
|
|
4297
|
-
Root:
|
|
4298
|
-
Monom:
|
|
4299
|
-
Polynom:
|
|
4300
|
-
Equation:
|
|
4301
|
-
Matrix:
|
|
4302
|
-
LinearSystem:
|
|
4403
|
+
circle: (o) => Es(o)
|
|
4404
|
+
}, Os = {
|
|
4405
|
+
Numeric: G,
|
|
4406
|
+
Fraction: u,
|
|
4407
|
+
Root: At,
|
|
4408
|
+
Monom: k,
|
|
4409
|
+
Polynom: N,
|
|
4410
|
+
Equation: V,
|
|
4411
|
+
Matrix: vs,
|
|
4412
|
+
LinearSystem: hi,
|
|
4303
4413
|
Factor: se,
|
|
4304
|
-
PolyFactor:
|
|
4305
|
-
LogicalSet:
|
|
4306
|
-
Random:
|
|
4414
|
+
PolyFactor: li,
|
|
4415
|
+
LogicalSet: fs,
|
|
4416
|
+
Random: As,
|
|
4307
4417
|
Geometry: {
|
|
4308
4418
|
Vector: E,
|
|
4309
4419
|
Point: S,
|
|
4310
|
-
Line:
|
|
4311
|
-
Triangle:
|
|
4312
|
-
Circle:
|
|
4313
|
-
Line3:
|
|
4314
|
-
Plane3:
|
|
4420
|
+
Line: z,
|
|
4421
|
+
Triangle: mi,
|
|
4422
|
+
Circle: $t,
|
|
4423
|
+
Line3: Bt,
|
|
4424
|
+
Plane3: pi,
|
|
4425
|
+
Sphere3: Ui
|
|
4315
4426
|
},
|
|
4316
|
-
NumExp:
|
|
4427
|
+
NumExp: us
|
|
4317
4428
|
};
|
|
4318
4429
|
export {
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4430
|
+
$t as Circle,
|
|
4431
|
+
V as Equation,
|
|
4432
|
+
Mt as EquationSolver,
|
|
4433
|
+
dt as FACTOR_DISPLAY,
|
|
4323
4434
|
se as Factor,
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4435
|
+
u as Fraction,
|
|
4436
|
+
z as Line,
|
|
4437
|
+
Bt as Line3,
|
|
4438
|
+
hi as LinearSystem,
|
|
4439
|
+
fs as LogicalSet,
|
|
4440
|
+
vs as Matrix,
|
|
4441
|
+
k as Monom,
|
|
4442
|
+
At as NthRoot,
|
|
4443
|
+
us as NumExp,
|
|
4444
|
+
G as Numeric,
|
|
4445
|
+
pi as Plane3,
|
|
4335
4446
|
S as Point,
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4447
|
+
li as PolyFactor,
|
|
4448
|
+
N as Polynom,
|
|
4449
|
+
As as Random,
|
|
4450
|
+
ji as SPHERE3_RELATIVE_POSITION,
|
|
4451
|
+
Ui as Sphere3,
|
|
4452
|
+
mi as Triangle,
|
|
4340
4453
|
E as Vector,
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4454
|
+
ps as areVectorsColinears,
|
|
4455
|
+
ds as areVectorsEquals,
|
|
4456
|
+
Os as default,
|
|
4457
|
+
gs as determinant,
|
|
4458
|
+
ms as dotProduct
|
|
4346
4459
|
};
|
|
4347
4460
|
//# sourceMappingURL=pimath.js.map
|