pimath 0.0.130 → 0.0.132

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/pimath.js CHANGED
@@ -1,84 +1,6 @@
1
1
  var te = Object.defineProperty;
2
2
  var ie = (c, e, t) => e in c ? te(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t;
3
3
  var r = (c, e, t) => (ie(c, typeof e != "symbol" ? e + "" : e, t), t);
4
- class x {
5
- static round(e, t = 2) {
6
- return +(Math.round(+(e + "e" + t)) + "e-" + t);
7
- }
8
- /**
9
- * Get the list of the nth first prime numbers.
10
- * @param nb : number of primes to choose from
11
- */
12
- static primes(e) {
13
- let t = [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];
14
- return e === void 0 ? t : t.slice(0, Math.min(t.length, e));
15
- }
16
- /**
17
- * Get the list of all dividers of a number.
18
- * @param value
19
- */
20
- static dividers(e) {
21
- let t;
22
- const i = Math.sqrt(Math.abs(e));
23
- t = [];
24
- for (let s = 1; s <= i; s++)
25
- e % s === 0 && (t.push(s), t.push(e / s));
26
- return t.sort(function(s, n) {
27
- return s - n;
28
- }), [...new Set(t)];
29
- }
30
- /**
31
- * Great Common Divisor
32
- * @param values : number values
33
- */
34
- static gcd(...e) {
35
- let t = function(n, o) {
36
- return o === 0 ? n : t(o, n % o);
37
- }, i = 1, s = 2;
38
- if (e.length === 0)
39
- return 1;
40
- if (e.length === 1)
41
- return e[0] === 0 ? 1 : e[0];
42
- if (i = t(e[0], e[1]), i === 1)
43
- return 1;
44
- for (s = 2; s < e.length && (i = t(i, e[s]), i !== 1); s++)
45
- ;
46
- return Math.abs(i);
47
- }
48
- static divideNumbersByGCD(...e) {
49
- let t = x.gcd(...e);
50
- return e.map((i) => i / t);
51
- }
52
- /**
53
- * Least Common Multiple
54
- * @param values: list of numbers
55
- */
56
- static lcm(...e) {
57
- return e.reduce(function(t, i) {
58
- return Math.abs(t * i / x.gcd(t, i));
59
- });
60
- }
61
- static pythagoricianTripletsWithTarget(e, t) {
62
- const i = [], s = t === !0 ? +e : e ** 2;
63
- for (let n = 0; n <= e; n++)
64
- for (let o = 0; o <= e; o++)
65
- n ** 2 + o ** 2 === s && i.push([n, o, e]);
66
- return i;
67
- }
68
- static numberCorrection(e, t = 1, i = 10, s = 8) {
69
- return +e.toFixed(s);
70
- }
71
- static periodic(e) {
72
- if (Number.isSafeInteger(e) || e.toString().split(".")[0].length < 10)
73
- return 0;
74
- }
75
- static decompose(e) {
76
- let t = x.dividers(e), i = [], s, n;
77
- for (; t.length > 0; )
78
- s = t.shift(), n = t.length > 0 ? t.pop() : +s, i.push([s, n]);
79
- return i;
80
- }
81
- }
82
4
  const X = {
83
5
  pi: Math.PI,
84
6
  e: Math.exp(1)
@@ -527,6 +449,84 @@ class P {
527
449
  return this._rpn = i.concat(s.reverse()), this;
528
450
  }
529
451
  }
452
+ class x {
453
+ static round(e, t = 2) {
454
+ return +(Math.round(+(e + "e" + t)) + "e-" + t);
455
+ }
456
+ /**
457
+ * Get the list of the nth first prime numbers.
458
+ * @param nb : number of primes to choose from
459
+ */
460
+ static primes(e) {
461
+ let t = [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];
462
+ return e === void 0 ? t : t.slice(0, Math.min(t.length, e));
463
+ }
464
+ /**
465
+ * Get the list of all dividers of a number.
466
+ * @param value
467
+ */
468
+ static dividers(e) {
469
+ let t;
470
+ const i = Math.sqrt(Math.abs(e));
471
+ t = [];
472
+ for (let s = 1; s <= i; s++)
473
+ e % s === 0 && (t.push(s), t.push(e / s));
474
+ return t.sort(function(s, n) {
475
+ return s - n;
476
+ }), [...new Set(t)];
477
+ }
478
+ /**
479
+ * Great Common Divisor
480
+ * @param values : number values
481
+ */
482
+ static gcd(...e) {
483
+ let t = function(n, o) {
484
+ return o === 0 ? n : t(o, n % o);
485
+ }, i = 1, s = 2;
486
+ if (e.length === 0)
487
+ return 1;
488
+ if (e.length === 1)
489
+ return e[0] === 0 ? 1 : e[0];
490
+ if (i = t(e[0], e[1]), i === 1)
491
+ return 1;
492
+ for (s = 2; s < e.length && (i = t(i, e[s]), i !== 1); s++)
493
+ ;
494
+ return Math.abs(i);
495
+ }
496
+ static divideNumbersByGCD(...e) {
497
+ let t = x.gcd(...e);
498
+ return e.map((i) => i / t);
499
+ }
500
+ /**
501
+ * Least Common Multiple
502
+ * @param values: list of numbers
503
+ */
504
+ static lcm(...e) {
505
+ return e.reduce(function(t, i) {
506
+ return Math.abs(t * i / x.gcd(t, i));
507
+ });
508
+ }
509
+ static pythagoricianTripletsWithTarget(e, t) {
510
+ const i = [], s = t === !0 ? +e : e ** 2;
511
+ for (let n = 0; n <= e; n++)
512
+ for (let o = 0; o <= e; o++)
513
+ n ** 2 + o ** 2 === s && i.push([n, o, e]);
514
+ return i;
515
+ }
516
+ static numberCorrection(e, t = 1, i = 10, s = 8) {
517
+ return +e.toFixed(s);
518
+ }
519
+ static periodic(e) {
520
+ if (Number.isSafeInteger(e) || e.toString().split(".")[0].length < 10)
521
+ return 0;
522
+ }
523
+ static decompose(e) {
524
+ let t = x.dividers(e), i = [], s, n;
525
+ for (; t.length > 0; )
526
+ s = t.shift(), n = t.length > 0 ? t.pop() : +s, i.push([s, n]);
527
+ return i;
528
+ }
529
+ }
530
530
  const b = class b {
531
531
  constructor(e, t) {
532
532
  r(this, "_denominator");
@@ -870,14 +870,68 @@ class K {
870
870
  e.push(this._numberCorrection(t));
871
871
  }
872
872
  }
873
- class D {
874
- constructor() {
875
- r(this, "_config");
876
- r(this, "_defaultConfig");
877
- r(this, "mergeConfig", (e, t) => e !== void 0 ? { ...t, ...e } : t);
878
- r(this, "generate", () => {
873
+ class Q {
874
+ constructor(...e) {
875
+ r(this, "_radical");
876
+ r(this, "_nth");
877
+ r(this, "_coefficient");
878
+ r(this, "_isValid");
879
+ // ------------------------------------------
880
+ // Creation / parsing functions
881
+ // ------------------------------------------
882
+ r(this, "parse", (e, t, i) => (this._coefficient = i === void 0 ? 1 : i, this._nth = t === void 0 ? 2 : t, this._radical = e === void 0 ? 1 : e, this._nth % 2 === 0 && this._radical < 0 && (this._isValid = !1), this));
883
+ // ------------------------------------------
884
+ // Mathematical operations
885
+ // ------------------------------------------
886
+ r(this, "reduce", () => {
887
+ let e = Math.floor(Math.pow(this._radical, 1 / this._nth));
888
+ for (; e > 1; ) {
889
+ if (this._radical % Math.pow(e, this._nth) === 0) {
890
+ this._coefficient *= e, this._radical = this._radical / Math.pow(e, this._nth), e = Math.floor(Math.pow(this._radical, 1 / this._nth));
891
+ continue;
892
+ }
893
+ e--;
894
+ }
895
+ return this;
879
896
  });
880
- r(this, "config", (e) => (this._config = this.mergeConfig(e, this._defaultConfig), this));
897
+ r(this, "multiply", (e) => (this._radical *= e.radical, this.reduce()));
898
+ // ------------------------------------------
899
+ // Help functions
900
+ // ------------------------------------------
901
+ r(this, "hasRadical", () => !(this._radical === 1 || this._radical === 0 || this._isValid === !1));
902
+ this._radical = 1, this._coefficient = 1, this._nth = 2, this._isValid = !0, e !== void 0 && this.parse(e[0], e[1], e[2]);
903
+ }
904
+ // ------------------------------------------
905
+ // Getter and setter
906
+ // ------------------------------------------
907
+ get radical() {
908
+ return this._radical;
909
+ }
910
+ set radical(e) {
911
+ this._radical = e;
912
+ }
913
+ get nth() {
914
+ return this._nth;
915
+ }
916
+ set nth(e) {
917
+ Number.isSafeInteger(e) && e >= 2 ? this._nth = e : (console.log("Error setting the nth root"), this._nth = 2);
918
+ }
919
+ get coefficient() {
920
+ return this._coefficient;
921
+ }
922
+ set coefficient(e) {
923
+ this._coefficient = e;
924
+ }
925
+ get tex() {
926
+ let e;
927
+ return this._coefficient === 1 ? e = "" : this._coefficient === -1 ? e = "-" : e = this._coefficient.toString(), this._radical === 1 ? `${this._coefficient}` : this._nth === 2 ? `${e}\\sqrt{${this._radical}}` : `${e}\\sqrt[${this._nth}]{${this._radical}}`;
928
+ }
929
+ get display() {
930
+ let e;
931
+ return this._coefficient === 1 ? e = "" : this._coefficient === -1 ? e = "-" : e = this._coefficient.toString(), this._radical === 1 ? `${this._coefficient}` : this._nth === 2 ? `${e}sqrt{${this._radical}}` : `${e}root(${this._nth}){${this._radical}}`;
932
+ }
933
+ get value() {
934
+ return this._coefficient * Math.pow(this._radical, 1 / this._nth);
881
935
  }
882
936
  }
883
937
  const $ = class $ {
@@ -1390,98 +1444,6 @@ r($, "xmultiply", (...e) => {
1390
1444
  return t;
1391
1445
  });
1392
1446
  let g = $;
1393
- class Q extends D {
1394
- constructor(t) {
1395
- super();
1396
- r(this, "generate", () => {
1397
- let t = new g();
1398
- if (typeof this._config.fraction == "boolean" ? t.coefficient = w.fraction({
1399
- zero: this._config.zero,
1400
- reduced: !0,
1401
- natural: !this._config.fraction
1402
- }) : t.coefficient = w.fraction(this._config.fraction), this._config.letters.length > 1) {
1403
- for (let i of this._config.letters.split(""))
1404
- t.setLetter(i, 0);
1405
- for (let i = 0; i < this._config.degree; i++) {
1406
- const s = w.item(this._config.letters.split(""));
1407
- t.setLetter(s, t.degree(s).clone().add(1));
1408
- }
1409
- } else
1410
- t.setLetter(this._config.letters, this._config.degree);
1411
- return t;
1412
- });
1413
- this._defaultConfig = {
1414
- letters: "x",
1415
- degree: 2,
1416
- fraction: !0,
1417
- zero: !1
1418
- }, this._config = this.mergeConfig(t, this._defaultConfig);
1419
- }
1420
- }
1421
- class J {
1422
- constructor(...e) {
1423
- r(this, "_radical");
1424
- r(this, "_nth");
1425
- r(this, "_coefficient");
1426
- r(this, "_isValid");
1427
- // ------------------------------------------
1428
- // Creation / parsing functions
1429
- // ------------------------------------------
1430
- r(this, "parse", (e, t, i) => (this._coefficient = i === void 0 ? 1 : i, this._nth = t === void 0 ? 2 : t, this._radical = e === void 0 ? 1 : e, this._nth % 2 === 0 && this._radical < 0 && (this._isValid = !1), this));
1431
- // ------------------------------------------
1432
- // Mathematical operations
1433
- // ------------------------------------------
1434
- r(this, "reduce", () => {
1435
- let e = Math.floor(Math.pow(this._radical, 1 / this._nth));
1436
- for (; e > 1; ) {
1437
- if (this._radical % Math.pow(e, this._nth) === 0) {
1438
- this._coefficient *= e, this._radical = this._radical / Math.pow(e, this._nth), e = Math.floor(Math.pow(this._radical, 1 / this._nth));
1439
- continue;
1440
- }
1441
- e--;
1442
- }
1443
- return this;
1444
- });
1445
- r(this, "multiply", (e) => (this._radical *= e.radical, this.reduce()));
1446
- // ------------------------------------------
1447
- // Help functions
1448
- // ------------------------------------------
1449
- r(this, "hasRadical", () => !(this._radical === 1 || this._radical === 0 || this._isValid === !1));
1450
- this._radical = 1, this._coefficient = 1, this._nth = 2, this._isValid = !0, e !== void 0 && this.parse(e[0], e[1], e[2]);
1451
- }
1452
- // ------------------------------------------
1453
- // Getter and setter
1454
- // ------------------------------------------
1455
- get radical() {
1456
- return this._radical;
1457
- }
1458
- set radical(e) {
1459
- this._radical = e;
1460
- }
1461
- get nth() {
1462
- return this._nth;
1463
- }
1464
- set nth(e) {
1465
- Number.isSafeInteger(e) && e >= 2 ? this._nth = e : (console.log("Error setting the nth root"), this._nth = 2);
1466
- }
1467
- get coefficient() {
1468
- return this._coefficient;
1469
- }
1470
- set coefficient(e) {
1471
- this._coefficient = e;
1472
- }
1473
- get tex() {
1474
- let e;
1475
- return this._coefficient === 1 ? e = "" : this._coefficient === -1 ? e = "-" : e = this._coefficient.toString(), this._radical === 1 ? `${this._coefficient}` : this._nth === 2 ? `${e}\\sqrt{${this._radical}}` : `${e}\\sqrt[${this._nth}]{${this._radical}}`;
1476
- }
1477
- get display() {
1478
- let e;
1479
- return this._coefficient === 1 ? e = "" : this._coefficient === -1 ? e = "-" : e = this._coefficient.toString(), this._radical === 1 ? `${this._coefficient}` : this._nth === 2 ? `${e}sqrt{${this._radical}}` : `${e}root(${this._nth}){${this._radical}}`;
1480
- }
1481
- get value() {
1482
- return this._coefficient * Math.pow(this._radical, 1 / this._nth);
1483
- }
1484
- }
1485
1447
  var F = /* @__PURE__ */ ((c) => (c.real = "\\mathbb{R}", c.varnothing = "\\varnothing", c))(F || {});
1486
1448
  class k {
1487
1449
  /**
@@ -1669,7 +1631,7 @@ class k {
1669
1631
  exact: !1
1670
1632
  }
1671
1633
  ];
1672
- } else if (o = new J(n).reduce(), o.hasRadical()) {
1634
+ } else if (o = new Q(n).reduce(), o.hasRadical()) {
1673
1635
  let v = x.gcd(f, 2 * a, o.coefficient), B = a / v, S = f / v;
1674
1636
  o.coefficient = o.coefficient / v, a < 0 && (B = -B, S = -S);
1675
1637
  let I = "", Z = "";
@@ -2550,1724 +2512,1762 @@ class u {
2550
2512
  return this.zero();
2551
2513
  }
2552
2514
  }
2553
- class se extends D {
2554
- constructor(t) {
2555
- super();
2556
- r(this, "generate", () => {
2557
- if (this._config.factorable && this._config.degree > 1)
2558
- return this.factorable();
2559
- let t = new u().empty(), i;
2560
- for (let s = this._config.degree; s >= 0; s--)
2561
- i = new Q({
2562
- letters: this._config.letters,
2563
- degree: s,
2564
- fraction: this._config.fraction,
2565
- zero: s === this._config.degree ? !1 : this._config.allowNullMonom
2566
- }).generate(), this._config.unit && this._config.degree === s && i.coefficient.one(), t.add(i);
2567
- if (this._config.positive && t.monomByDegree().coefficient.isNegative() && t.monomByDegree().coefficient.opposed(), this._config.numberOfMonoms > 0 && this._config.numberOfMonoms < t.length) {
2568
- let s = t.monomByDegree().clone();
2569
- t.monoms = w.array(t.monoms.slice(1), this._config.numberOfMonoms - 1), t.add(s).reorder().reduce();
2515
+ class Y {
2516
+ constructor(...e) {
2517
+ // Stores the original equations
2518
+ r(this, "_equations");
2519
+ // Determine the letters in the linear system, usually ['x', 'y']
2520
+ r(this, "_letters");
2521
+ // Resolution steps contains each steps
2522
+ // letter : target letter
2523
+ // steps: {system: current LinearSystem, operations: [*3,/5] or [[*3,*2], [,*5], [*2,]]}
2524
+ r(this, "_resolutionSteps");
2525
+ // Get the solution of the equation
2526
+ r(this, "_solutions");
2527
+ r(this, "buildTex", (e, t) => {
2528
+ let i, s = [], n, o = [];
2529
+ for (let a of e)
2530
+ o = o.concat(a.letters());
2531
+ o = [...new Set(o)], o.sort();
2532
+ for (let a = 0; a < e.length; a++) {
2533
+ let f = e[a];
2534
+ i = [];
2535
+ for (let m of o)
2536
+ n = f.left.monomByLetter(m), i.length === 0 ? i.push(n.isZero() ? "" : n.tex) : i.push(n.isZero() ? "" : (n.coefficient.sign() === 1 ? "+" : "") + n.tex);
2537
+ if (i.push("="), i.push(f.right.tex), t !== void 0 && t[a] !== void 0) {
2538
+ i[i.length - 1] = i[i.length - 1] + " \\phantom{\\quad}";
2539
+ for (let m of t[a])
2540
+ i.push(`\\ \\cdot\\ ${m.startsWith("-") ? "\\left(" + m + "\\right)" : m}`);
2541
+ }
2542
+ s.push(i.join("&"));
2570
2543
  }
2571
- return t;
2544
+ let l = 0;
2545
+ return t !== void 0 && t.length > 0 && (l = t[0].length), `\\left\\{\\begin{array}{${"r".repeat(o.length)}cl ${"|l".repeat(l)}}${s.join("\\\\ ")}\\end{array}\\right.`;
2572
2546
  });
2573
- r(this, "factorable", () => {
2574
- let t = new u().one(), i = { ...this._config };
2575
- i.degree = 1, i.factorable = !1;
2576
- for (let s = 0; s < this._config.degree; s++)
2577
- t.multiply(w.polynom(i));
2578
- return t;
2547
+ r(this, "stepTex", (e) => {
2548
+ const t = this._resolutionSteps[e];
2549
+ if (t === void 0)
2550
+ return "";
2551
+ let i = [];
2552
+ for (let s = 0; s < t.length; s++)
2553
+ i.push(this.buildTex(t[s].equations, t[s].operations));
2554
+ return `\\begin{aligned}&${i.join("\\\\&")}\\end{aligned}`;
2579
2555
  });
2580
- this._defaultConfig = {
2581
- letters: "x",
2582
- degree: 2,
2583
- fraction: !1,
2584
- zero: !1,
2585
- unit: !1,
2586
- factorable: !1,
2587
- allowNullMonom: !0,
2588
- numberOfMonoms: 0,
2589
- positive: !0
2590
- }, this._config = this.mergeConfig(t, this._defaultConfig);
2556
+ // ------------------------------------------
2557
+ // Creation / parsing functions
2558
+ // ------------------------------------------
2559
+ r(this, "parse", (...e) => (this._equations = e.map((t) => new k(t)), this._findLetters(), this));
2560
+ r(this, "clone", () => new Y().parse(...this._equations.map((e) => e.clone())));
2561
+ // ------------------------------------------
2562
+ r(this, "reorder", () => {
2563
+ for (let e of this._equations)
2564
+ e.reorder();
2565
+ return this;
2566
+ });
2567
+ // -----------------------------------------------
2568
+ // Equations solving algorithms
2569
+ r(this, "solve", (e) => {
2570
+ this._solutions = {}, this._resolutionSteps = {}, this.reorder(), e === void 0 && (e = !1);
2571
+ for (let t of this.variables)
2572
+ this._solutions[t] = this._solveOneLetter(t, e);
2573
+ return this;
2574
+ });
2575
+ r(this, "mergeEquations", (e, t, i, s) => {
2576
+ let n = e.clone().multiply(new h(i)), o = t.clone().multiply(new h(s));
2577
+ return n.left.add(o.left), n.right.add(o.right), n;
2578
+ });
2579
+ r(this, "_findLetters", () => {
2580
+ let e = /* @__PURE__ */ new Set();
2581
+ for (let t of this._equations)
2582
+ e = /* @__PURE__ */ new Set([...e, ...t.variables]);
2583
+ return this._letters = [...e], this._letters.sort(), this;
2584
+ });
2585
+ return this._equations = [], this._letters = "xyz".split(""), e !== void 0 && e.length > 0 && this.parse(...e), this;
2591
2586
  }
2592
- }
2593
- class T {
2594
- /**
2595
- * Random boolean with a percent ratio
2596
- * @param percent
2597
- */
2598
- static randomBool(e = 0.5) {
2599
- return Math.random() < e;
2587
+ // ------------------------------------------
2588
+ // Getter and setter
2589
+ // ------------------------------------------
2590
+ get equations() {
2591
+ return this._equations;
2600
2592
  }
2601
- /**
2602
- * Random integer between two values.
2603
- * @param a (number) : From this value to the second value. If the second is ommited, this value is the max value.
2604
- * @param b (number) : To this value. If this is ommited.
2605
- */
2606
- static randomInt(e, t, i) {
2607
- if (t === void 0)
2608
- return e >= 0 ? this.randomInt(0, e) : this.randomInt(e, 0);
2609
- if (e === t)
2610
- return e;
2611
- if (i === void 0)
2612
- return Math.floor(Math.random() * (t - e + 1) + e);
2613
- if (Math.abs(t - e) <= i.length)
2614
- throw new Error("The number of excluded values is too high.");
2615
- let s = this.randomInt(e, t);
2616
- for (; i.includes(s); )
2617
- s = this.randomInt(e, t);
2618
- return s;
2593
+ set equations(e) {
2594
+ this._equations = e;
2619
2595
  }
2620
- /**
2621
- * Random integer between -max and max value.
2622
- * @param max (number) : determine the limits.
2623
- * @param zero (bool) : determine if zero is allowed or not.
2624
- */
2625
- static randomIntSym(e, t) {
2626
- return t === !1 ? this.randomBool() ? this.randomInt(1, e) : -this.randomInt(1, e) : this.randomInt(-e, e);
2596
+ get letters() {
2597
+ return this._letters.join("");
2627
2598
  }
2628
- static randomPrime(e) {
2629
- let t = x.primes();
2630
- return e !== void 0 && (t = t.filter((i) => i < e)), this.randomItem(t);
2599
+ set letters(e) {
2600
+ this._letters = e.split("");
2631
2601
  }
2632
- static randomArray(e, t) {
2633
- return t === void 0 && (t = 1), e.length <= 0 ? Object.values(e) : T.shuffleArray(e).slice(0, t);
2602
+ get isSolvable() {
2603
+ return this.variables.length === this._equations.length;
2634
2604
  }
2635
- static randomItem(e) {
2636
- return e.length === 0 ? "" : e[this.randomInt(0, e.length - 1)];
2605
+ get variables() {
2606
+ return this._letters;
2637
2607
  }
2638
- static shuffleArray(e) {
2639
- let t = Object.values(e);
2640
- for (let i = t.length - 1; i > 0; i--) {
2641
- const s = Math.floor(Math.random() * (i + 1)), n = t[i];
2642
- t[i] = t[s], t[s] = n;
2643
- }
2644
- return t;
2608
+ get tex() {
2609
+ let e = this.clone().reorder();
2610
+ return e.variables, this.buildTex(e.equations);
2645
2611
  }
2646
- }
2647
- class re extends D {
2648
- constructor(t) {
2649
- super();
2650
- r(this, "generate", () => {
2651
- let t = new h();
2652
- if (this._config.negative ? t.numerator = w.numberSym(this._config.max, this._config.zero) : t.numerator = w.number(this._config.zero ? 0 : 1, this._config.max), this._config.natural)
2653
- t.denominator = 1;
2654
- else {
2655
- let i = 0;
2656
- for (; t.isRelative() && i < 10; )
2657
- t.denominator = w.number(1, this._config.max), i++;
2658
- }
2659
- return this._config.reduced ? t.reduce() : t;
2660
- });
2661
- this._defaultConfig = {
2662
- negative: !0,
2663
- max: 10,
2664
- reduced: !0,
2665
- zero: !0,
2666
- natural: !1
2667
- }, this._config = this.mergeConfig(t, this._defaultConfig);
2612
+ get solution() {
2613
+ let e = [];
2614
+ this._solutions === void 0 && this.solve();
2615
+ for (let t in this._solutions) {
2616
+ if (this._solutions[t].display === "RR")
2617
+ return `\\left\\{ \\left(${this._letters.join(";")}\\right) \\big\\vert ${this.equations[0].tex} \\right\\}`;
2618
+ if (this._solutions[t].display === "O/")
2619
+ return "\\varnothing";
2620
+ e.push(this._solutions[t].tex);
2621
+ }
2622
+ return `\\left(${e.join(";")}\\right)`;
2668
2623
  }
2669
- }
2670
- class ne {
2671
- constructor() {
2672
- r(this, "x");
2673
- r(this, "y");
2624
+ get solutionAsDisplay() {
2625
+ let e = [];
2626
+ this._solutions === void 0 && this.solve();
2627
+ for (let t in this._solutions) {
2628
+ if (this._solutions[t].display === "RR")
2629
+ return `{(${this._letters.join(";")}) | ${this.equations[0].display} }`;
2630
+ if (this._solutions[t].display === "O/")
2631
+ return "O/";
2632
+ e.push(this._solutions[t].display);
2633
+ }
2634
+ return `(${e.join(";")})`;
2674
2635
  }
2675
- }
2676
- const V = class V {
2677
- constructor(...e) {
2678
- r(this, "_x");
2679
- // 1st component
2680
- r(this, "_y");
2681
- // 2nd component
2682
- r(this, "_exist");
2683
- // ------------------------------------------
2684
- r(this, "parse", (...e) => {
2685
- if (this.zero(), e.length === 0)
2686
- return this;
2687
- if (e.length === 1) {
2688
- if (e[0] instanceof V)
2689
- return this._x = e[0].x.clone(), this._y = e[0].y.clone(), this;
2690
- if (typeof e[0] == "string") {
2691
- let t = e[0].split(",");
2692
- if (t.length === 2)
2693
- return this._x = new h(t[0]).reduce(), this._y = new h(t[1]).reduce(), this;
2636
+ get resolutionSteps() {
2637
+ return this._resolutionSteps;
2638
+ }
2639
+ _linearReduction(e, t, i) {
2640
+ let s = e.left.monomByDegree(1, i).coefficient.clone(), n = t.left.monomByDegree(1, i).coefficient.clone().opposed();
2641
+ const o = x.gcd(s.numerator, n.numerator), l = x.gcd(s.denominator, n.denominator);
2642
+ return s.divide(o).multiply(l), n.divide(o).multiply(l), (n.isNegativeOne() || s.isNegativeOne()) && (s.opposed(), n.opposed()), {
2643
+ merged: this.mergeEquations(e, t, n, s),
2644
+ factors: [n, s]
2645
+ };
2646
+ }
2647
+ /**
2648
+ * Linear reduction of the equations to have only one letter
2649
+ * @param letter letter to isolate
2650
+ * @private
2651
+ */
2652
+ _solveOneLetter(e, t) {
2653
+ let i = this.clone().equations, s = [], n;
2654
+ this._resolutionSteps[e] = [];
2655
+ for (let a of this.variables)
2656
+ if (s = [], a !== e) {
2657
+ t && (this._resolutionSteps[e].push({
2658
+ equations: i.map((f) => f.clone()),
2659
+ operations: [...new Array(i.length)].map((f) => [...new Array(i.length - 1)].map((m) => ""))
2660
+ }), n = this._resolutionSteps[e].length - 1);
2661
+ for (let f = 0; f < i.length - 1; f++) {
2662
+ const m = this._linearReduction(i[f], i[f + 1], a);
2663
+ s.push(m.merged), t && (this._resolutionSteps[e][n].operations[f][f] = m.factors[0].tex, this._resolutionSteps[e][n].operations[f + 1][f] = m.factors[1].tex);
2694
2664
  }
2695
- return e[0] instanceof ne ? (this._x = new h(e[0].x).reduce(), this._y = new h(e[0].y).reduce(), this) : this.zero();
2665
+ i = [...s];
2696
2666
  }
2697
- return e.length === 2 ? (this._x = new h(e[0]).reduce(), this._y = new h(e[1]).reduce(), this) : this;
2667
+ let o = i[0];
2668
+ o.solve();
2669
+ const l = o.solutions[0];
2670
+ if (t) {
2671
+ this._resolutionSteps[e].push({
2672
+ equations: [i[0]],
2673
+ operations: [[i[0].left.monoms[0].coefficient.tex]]
2674
+ });
2675
+ let a;
2676
+ l.exact instanceof h || typeof l.exact == "string" ? a = new u(l.exact) : a = new u(l.value), this._resolutionSteps[e].push({
2677
+ equations: [new k(new u(e), a)],
2678
+ operations: []
2679
+ });
2680
+ }
2681
+ return o.solutions[0];
2682
+ }
2683
+ }
2684
+ var L = /* @__PURE__ */ ((c) => (c.ZERO = "z", c.DEFENCE = "d", c.NOTHING = "t", c))(L || {}), M = /* @__PURE__ */ ((c) => (c.VERTICAL = "av", c.HORIZONTAL = "ah", c.SLOPE = "ao", c.HOLE = "hole", c))(M || {}), E = /* @__PURE__ */ ((c) => (c.LT = "LT", c.RT = "RT", c.LB = "LB", c.RB = "RB", c))(E || {}), H = /* @__PURE__ */ ((c) => (c.MIN = "min", c.MAX = "max", c.FLAT = "flat", c.NOTHING = "", c))(H || {}), W = /* @__PURE__ */ ((c) => (c.SIGNS = "signs", c.GROWS = "grows", c.VARIATIONS = "variatins", c))(W || {});
2685
+ class se {
2686
+ constructor(e, t) {
2687
+ r(this, "fx");
2688
+ r(this, "_asymptotes");
2689
+ r(this, "_derivative");
2690
+ r(this, "_signs");
2691
+ r(this, "_variations");
2692
+ r(this, "_zeroes");
2693
+ r(this, "_config");
2694
+ r(this, "_name");
2695
+ r(this, "makeStudy", () => {
2696
+ this._zeroes = this.makeZeroes(), this._config.signs && (this._signs = this.makeSigns()), this._config.asymptotes && (this._asymptotes = this.makeAsymptotes()), this._config.derivative && (this._derivative = this.makeDerivative()), this._config.variations && (this._variations = this.makeVariation()), this._config.signs && (this._signs.tex = this.texSigns), this._config.derivative && (this._derivative.tex = this.texGrows), this._config.variations && (this._variations.tex = this.texVariations);
2698
2697
  });
2699
- r(this, "clone", () => (this._x = this._x.clone(), this._y = this._y.clone(), this));
2700
- r(this, "zero", () => (this._x = new h(null), this._y = new h(null), this));
2701
- r(this, "origin", () => (this.zero(), this));
2702
- // ------------------------------------------
2703
- // Display functions
2704
- r(this, "middleOf", (e, t) => (this._x = e.x.clone().add(t.x).divide(2), this._y = e.y.clone().add(t.y).divide(2), this));
2705
- // ------------------------------------------
2706
- // Mathematical operations
2707
- // ------------------------------------------
2708
- // ------------------------------------------
2709
- // Vector functions
2710
- // ------------------------------------------
2711
- // ------------------------------------------
2712
- // Static functions
2713
- r(this, "translate", (e) => (this._x = this._x.add(e.x), this._y = this._y.add(e.y), this));
2714
- // ------------------------------------------
2715
- r(this, "texValues", (e) => {
2716
- let t = [];
2717
- return t.push(this._x.value.toFixed(e === void 0 ? 2 : e)), t.push(this._y.value.toFixed(e === void 0 ? 2 : e)), `\\left(${t.join(";")}\\right)`;
2698
+ r(this, "indexOfZero", (e, t) => {
2699
+ for (let i = 0; i < e.length; i++)
2700
+ if (e[i].tex === t.tex)
2701
+ return i;
2702
+ return -1;
2718
2703
  });
2719
- r(this, "distanceTo", (e) => {
2720
- let t = 0, i = new h(), s = "";
2721
- if (e instanceof A)
2722
- return e.distanceTo(this);
2723
- if (e instanceof V) {
2724
- let n = new N(this, e);
2725
- t = n.norm, i = n.normSquare.sqrt(), s = n.normSquare.isSquare() ? i.tex : `\\sqrt{\\frac{ ${n.normSquare.numerator} }{ ${n.normSquare.denominator} }}`;
2704
+ r(this, "makeOneLineForSigns", (e, t, i) => {
2705
+ let s = [], n = e.getZeroes().map((o) => o.tex);
2706
+ s.push(""), e.degree().isZero() ? s.push(e.monoms[0].coefficient.sign() === 1 ? "+" : "-") : s.push(e.evaluate(t[0].value - 1).sign() === 1 ? "+" : "-");
2707
+ for (let o = 0; o < t.length; o++)
2708
+ s.push(
2709
+ n.includes(t[o].tex) ? i : "t"
2710
+ /* NOTHING */
2711
+ ), o < t.length - 1 ? s.push(e.evaluate((t[o].value + t[o + 1].value) / 2).sign() === 1 ? "+" : "-") : o === t.length - 1 && s.push(e.evaluate(t[o].value + 1).sign() === 1 ? "+" : "-");
2712
+ return s.push(""), s;
2713
+ });
2714
+ r(this, "makeSignsResult", (e) => {
2715
+ let t = e[0].map((i, s) => s === 0 || s === e[0].length - 1 ? "" : s % 2 === 0 ? "t" : "+");
2716
+ for (let i of e)
2717
+ for (let s = 0; s < i.length; s++)
2718
+ if (s % 2 === 0) {
2719
+ if (t[s] === "d")
2720
+ continue;
2721
+ i[s] !== "t" && (t[s] = i[s]);
2722
+ } else
2723
+ i[s] === "-" && (t[s] = t[s] === "+" ? "-" : "+");
2724
+ return t;
2725
+ });
2726
+ r(this, "makeGrowsResult", (e) => {
2727
+ let t = Object.values(e.signs), i = t[t.length - 1], s = [], n = {}, o = e.zeroes;
2728
+ for (let l = 0; l < o.length; l++) {
2729
+ let a = 2 * l + 2;
2730
+ if (i[a] === "z") {
2731
+ let f, m, d = o[l].exact, p, _, q, v = new K(this.fx.plotFunction);
2732
+ if (d instanceof h) {
2733
+ let B = d, S = this.fx.evaluate(B);
2734
+ f = d.value, m = S.value, p = d.tex, _ = S.tex;
2735
+ } else
2736
+ f = o[l].value, m = v.evaluate({ x: f }), p = f.toFixed(2), _ = m.toFixed(2);
2737
+ i[a - 1] === i[a + 1] ? q = "flat" : i[a - 1] === "+" ? q = "max" : q = "min", n[o[l].tex] = {
2738
+ type: q,
2739
+ tex: { x: p, y: _ },
2740
+ value: { x: f, y: m }
2741
+ };
2742
+ }
2726
2743
  }
2727
- return { value: t, fraction: i, tex: s };
2744
+ s.push(i[1] === "+" ? "-/" : "+/");
2745
+ for (let l = 1; l < i.length - 1; l++)
2746
+ if (i[l] === "z") {
2747
+ let a = n[o[(l - 2) / 2].tex];
2748
+ s.push(`${i[l - 1]}/\\(${a.type}(${a.tex.x};${a.tex.y})\\)`);
2749
+ } else
2750
+ i[l] === "d" && s.push(`${i[l - 1]}D${i[l + 1] === "+" ? "-" : "+"}/`);
2751
+ return s.push(`${i[i.length - 2]}/`), { growsLine: s, extremes: n };
2728
2752
  });
2729
- r(this, "isInListOfPoints", (e) => e.map((i) => i.key).includes(this.key));
2730
- r(this, "isEqual", (e) => this.x.isEqual(e.x) && this.y.isEqual(e.y));
2731
- return this._x = new h().zero(), this._y = new h().zero(), e !== void 0 && this.parse(...e), this;
2753
+ r(this, "makeVariationsResult", (e) => ({ varsLine: [], extremes: {} }));
2754
+ r(this, "drawCode", () => {
2755
+ let e = `f(x)=${this.fx.plotFunction}`, t = 1;
2756
+ this.asymptotes.forEach((i) => {
2757
+ i.type === "av" ? (e += `
2758
+ av_${t}=line x=${i.zero.value}->red,dash`, t++) : i.type === "ah" ? e += `
2759
+ ah=line y=${i.fx.monoms[0].coefficient.value}->orange,dash` : i.type === "ao" && (e += `
2760
+ ao=line y=${i.fx.plotFunction}->red,dash`), t++;
2761
+ });
2762
+ for (let i in this.derivative.extremes) {
2763
+ let s = this.derivative.extremes[i];
2764
+ e += `
2765
+ M_${t}(${s.value.x},${s.value.y})*`, t++;
2766
+ }
2767
+ return this.zeroes.forEach((i) => {
2768
+ i.type === "z" && (e += `
2769
+ Z_${t}(${i.value},0)*`, t++);
2770
+ }), e;
2771
+ });
2772
+ r(this, "_makeTexFromTableOfSigns", (e) => {
2773
+ let t = e.factors.map((l) => `\\(${l.tex}\\)/1`), i = `\\(${this._config.name}(${this._config.variable})\\)/1.2`, s = e.zeroes;
2774
+ e.type === "grows" ? i = `\\(${this._config.name}'(${this._config.variable})\\)/1.2,\\(f(x${this._config.variable})\\)/2` : e.type === "variatins" && (i = `\\(${this._config.name}''(${this._config.variable})\\)/1.2,\\(f(${this._config.variable})\\)/2`);
2775
+ let n = `\\begin{tikzpicture}
2776
+ \\tkzTabInit[lgt=3,espcl=2,deltacl=0]{/1.2,${t.join(",")},/.1,${i} }{{\\scriptsize \\hspace{1cm} \\(-\\infty\\)},\\(${s.map((l) => l.tex).join("\\),\\(")}\\),{\\scriptsize \\hspace{-1cm} \\(+\\infty\\)}}`, o;
2777
+ for (o = 0; o < e.factors.length; o++)
2778
+ n += `
2779
+ \\tkzTabLine{${e.signs[o].join(",")}}`;
2780
+ return n += `
2781
+ \\tkzTabLine{${e.signs[o].join(",")}}`, e.type === "grows" ? n += `
2782
+ \\tkzTabVar{${e.signs[o + 1].join(",")}}` : e.type === "variatins" && (n += `
2783
+ \\tkzTabVar{${e.signs[o + 1].join(",")}}`), n += `
2784
+ \\end{tikzpicture}`, n;
2785
+ });
2786
+ if (this.fx = e, this._config = {
2787
+ name: "f",
2788
+ variable: "x",
2789
+ domain: !0,
2790
+ asymptotes: !0,
2791
+ signs: !0,
2792
+ derivative: !0,
2793
+ variations: !0
2794
+ }, t)
2795
+ if (typeof t == "string") {
2796
+ const i = t.split(",");
2797
+ this._config = {};
2798
+ let s = i.filter((n) => n.includes("(") && n.includes(")"));
2799
+ s.length === 1 && (this._config.name = s[0].split("(")[0], this._config.variable = s[0].split("(")[1].split(")")[0]), this._config.domain = i.includes("d"), this._config.asymptotes = i.includes("a"), this._config.signs = i.includes("signs"), this._config.derivative = i.includes("dx"), this._config.variations = i.includes("ddx");
2800
+ } else
2801
+ this._config = t;
2802
+ return this.makeStudy(), this;
2732
2803
  }
2733
- // ------------------------------------------
2734
- // Getter and setter
2735
- // ------------------------------------------
2736
- get x() {
2737
- return this._x;
2804
+ get name() {
2805
+ return this._config.name;
2738
2806
  }
2739
- set x(e) {
2740
- this._x = e;
2807
+ set name(e) {
2808
+ this._config.name = e;
2741
2809
  }
2742
- get y() {
2743
- return this._y;
2810
+ get config() {
2811
+ return this._config;
2744
2812
  }
2745
- set y(e) {
2746
- this._y = e;
2813
+ set config(e) {
2814
+ this._config = e;
2747
2815
  }
2748
- get tex() {
2749
- let e = [];
2750
- return e.push(this._x.tex), e.push(this._y.tex), `\\left(${e.join(";")}\\right)`;
2816
+ get zeroes() {
2817
+ return this._zeroes;
2751
2818
  }
2752
- get display() {
2753
- let e = [];
2754
- return e.push(this._x.tex), e.push(this._y.tex), `(${e.join(";")})`;
2819
+ get domain() {
2820
+ return this.fx.domain();
2755
2821
  }
2756
- get asVector() {
2757
- return new N(this.x, this.y);
2822
+ get signs() {
2823
+ return this._signs;
2758
2824
  }
2759
- // ------------------------------------------
2760
- // Creation / parsing functions
2761
- get key() {
2762
- return `${this.x.display};${this.y.display}`;
2825
+ get asymptotes() {
2826
+ return this._asymptotes;
2763
2827
  }
2764
- };
2765
- // ------------------------------------------
2766
- r(V, "pmatrix", (e, t, i) => i === void 0 ? `\\begin{pmatrix} ${e.tex ? e.tex : e} \\\\ ${t.tex ? t.tex : t} \\end{pmatrix}` : `\\begin{pmatrix} ${e.tex ? e.tex : e} \\\\ ${t.tex ? t.tex : t} \\\\ ${i.tex ? i.tex : i} \\end{pmatrix}`);
2767
- let y = V;
2768
- const O = class O {
2769
- // 2nd component
2770
- constructor(...e) {
2771
- r(this, "_x");
2772
- // 1st component
2773
- r(this, "_y");
2774
- r(this, "parse", (...e) => {
2775
- if (this.zero(), e.length === 0)
2776
- return this;
2777
- if (e.length === 1)
2778
- return e[0] instanceof O ? e[0].clone() : this._parseString(e[0]);
2779
- if (e.length >= 2) {
2780
- if (e[0] instanceof y && e[1] instanceof y)
2781
- return this._x = e[1].x.clone().subtract(e[0].x), this._y = e[1].y.clone().subtract(e[0].y), this;
2782
- (e[0] instanceof h || !isNaN(e[0])) && (this._x = new h(e[0])), (e[1] instanceof h || !isNaN(e[1])) && (this._y = new h(e[1])), typeof e[0] == "object" && !isNaN(e[0].x) && !isNaN(e[0].x) && typeof e[1] == "object" && !isNaN(e[1].x) && !isNaN(e[1].x) && (this._x = new h(+e[1].x - e[0].x), this._y = new h(+e[1].y - e[0].y));
2783
- }
2784
- return this;
2785
- });
2786
- r(this, "clone", () => {
2787
- let e = new O();
2788
- return this._x !== null && (e.x = this._x.clone()), this._y !== null && (e.y = this._y.clone()), e;
2789
- });
2790
- r(this, "reset", () => (this._x = null, this._y = null, this));
2791
- // ------------------------------------------
2792
- // Mathematical operations
2793
- r(this, "zero", () => (this.reset(), this._x = new h(null), this._y = new h(null), this));
2794
- r(this, "one", () => (this._x = new h(), this._y = new h(), this));
2795
- // ------------------------------------------
2796
- r(this, "opposed", () => (this._x.opposed(), this._y.opposed(), this));
2797
- r(this, "add", (e) => (this._x.add(e.x), this._y.add(e.y), this));
2798
- r(this, "subtract", (e) => this.add(e.clone().opposed()));
2799
- r(this, "scalarProductWithVector", (e) => O.scalarProduct(this, e));
2800
- r(this, "determinantWithVector", (e) => O.determinant(this, e));
2801
- r(this, "normal", () => {
2802
- let e = this.x.clone().opposed(), t = this.y.clone();
2803
- return this._x = t, this._y = e, this;
2804
- });
2805
- r(this, "isColinearTo", (e) => this.determinantWithVector(e).isZero());
2806
- r(this, "isNormalTo", (e) => this.scalarProductWithVector(e).isZero());
2807
- r(this, "multiplyByScalar", (e) => {
2808
- let t = new h(e);
2809
- return this._x.multiply(t), this._y.multiply(t), this;
2810
- });
2811
- r(this, "divideByScalar", (e) => this.multiplyByScalar(new h(e).invert()));
2812
- r(this, "simplify", () => this.multiplyByScalar(x.lcm(this._x.denominator, this._y.denominator)).divideByScalar(x.gcd(this._x.numerator, this._y.numerator)));
2813
- // ------------------------------------------
2814
- // Vector functions
2815
- // ------------------------------------------
2816
- r(this, "simplifyDirection", () => {
2817
- let e = x.lcm(this.x.denominator, this.y.denominator), t = x.gcd(this.x.numerator, this.y.numerator);
2818
- return this.x.multiply(e).divide(t), this.y.multiply(e).divide(t), this;
2819
- });
2820
- r(this, "angleWith", (e, t, i) => {
2821
- let s = this.scalarProductWithVector(e).value, n = i ? 1 : 180 / Math.PI;
2822
- return t && (s = Math.abs(s)), n * Math.acos(s / (this.norm * e.norm));
2823
- });
2824
- r(this, "_parseString", (e) => {
2825
- let t = e.split(/[,;\s]/g);
2826
- return this.x = new h(t[0] || null), this.y = new h(t[1] || null), this;
2827
- });
2828
- this._x = new h().zero(), this._y = new h().zero(), e !== void 0 && this.parse(...e);
2828
+ get derivative() {
2829
+ return this._derivative;
2829
2830
  }
2830
- // ------------------------------------------
2831
- // Getter and setter
2832
- // ------------------------------------------
2833
- get x() {
2834
- return this._x;
2831
+ get texSigns() {
2832
+ return this._makeTexFromTableOfSigns(this._signs);
2835
2833
  }
2836
- set x(e) {
2837
- this._x = new h(e);
2834
+ get texGrows() {
2835
+ return this._makeTexFromTableOfSigns(this._derivative);
2838
2836
  }
2839
- get y() {
2840
- return this._y;
2837
+ get texVariations() {
2838
+ return this._makeTexFromTableOfSigns(this._variations);
2841
2839
  }
2842
- set y(e) {
2843
- this._y = new h(e);
2840
+ makeZeroes() {
2841
+ return [];
2844
2842
  }
2845
- get normSquare() {
2846
- return this._x.clone().pow(2).add(this._y.clone().pow(2));
2843
+ makeSigns() {
2844
+ return {
2845
+ type: "signs",
2846
+ fx: null,
2847
+ factors: [],
2848
+ zeroes: [],
2849
+ signs: [],
2850
+ extremes: {},
2851
+ tex: ""
2852
+ };
2847
2853
  }
2848
- get norm() {
2849
- return Math.sqrt(this.normSquare.value);
2854
+ makeAsymptotes() {
2855
+ return [];
2850
2856
  }
2851
- get tex() {
2852
- return `\\begin{pmatrix}${this._x.tex} \\\\ ${this._y.tex} \\end{pmatrix}`;
2857
+ makeDerivative() {
2858
+ return {
2859
+ type: "grows",
2860
+ fx: null,
2861
+ factors: [],
2862
+ zeroes: [],
2863
+ signs: [],
2864
+ extremes: {},
2865
+ tex: ""
2866
+ };
2853
2867
  }
2854
- get asPoint() {
2855
- return new y(this.x, this.y);
2868
+ makeVariation() {
2869
+ return {
2870
+ type: "variatins",
2871
+ fx: null,
2872
+ factors: [],
2873
+ zeroes: [],
2874
+ signs: [],
2875
+ extremes: {},
2876
+ tex: ""
2877
+ };
2856
2878
  }
2857
- // ------------------------------------------
2858
- // Creation / parsing functions
2859
- // ------------------------------------------
2860
- get isNull() {
2861
- return this.x.isZero() && this.y.isZero();
2879
+ }
2880
+ class re extends se {
2881
+ constructor(e, t) {
2882
+ return super(e, t), this;
2862
2883
  }
2863
- };
2864
- r(O, "scalarProduct", (e, t) => e.x.clone().multiply(t.x).add(e.y.clone().multiply(t.y))), r(O, "determinant", (e, t) => e.x.clone().multiply(t.y).subtract(e.y.clone().multiply(t.x)));
2865
- let N = O;
2866
- var ee = /* @__PURE__ */ ((c) => (c[c.None = 0] = "None", c.Parallel = "parallel", c.Perpendicular = "perpendicular", c.Tangent = "tangent", c))(ee || {});
2867
- const z = class z {
2868
- /**
2869
- * Value can be a mix of:
2870
- *
2871
- * @param values
2872
- */
2873
- constructor(...e) {
2874
- r(this, "_referencePropriety");
2875
- r(this, "_referenceLine");
2876
- r(this, "_reduceBeforeDisplay");
2877
- // ax + by + c = 0
2878
- r(this, "_a");
2879
- r(this, "_b");
2880
- r(this, "_c");
2881
- r(this, "_OA");
2882
- r(this, "_d");
2883
- r(this, "_n");
2884
- r(this, "_exists");
2885
- r(this, "randomPoint", (e) => this._d.clone().multiplyByScalar(w.numberSym(e === void 0 || e <= 1 ? 3 : e, !1)).add(this._OA.asVector).asPoint);
2886
- r(this, "randomNearPoint", (e) => {
2887
- let t = this.randomPoint(e), i = 10;
2888
- for (; this.isOnLine(t) && i > 0; )
2889
- t.x.add(w.numberSym(1, !1)), t.y.add(w.numberSym(1, !1)), i--;
2890
- return t;
2891
- });
2892
- // ------------------------------------------
2893
- // Creation / parsing functions
2894
- // ------------------------------------------
2895
- /**
2896
- * Parse data to a line
2897
- * @param {any} values
2898
- * @returns {Line}
2899
- */
2900
- r(this, "parse", (...e) => {
2901
- if (this._exists = !1, e.length === 0)
2902
- return this;
2903
- if (e.length === 1) {
2904
- if (e[0] instanceof z)
2905
- return e[0].clone();
2906
- if (e[0] instanceof k)
2907
- return this.parseEquation(e[0]);
2908
- if (typeof e[0] == "string")
2909
- try {
2910
- let t = new k(e[0]);
2911
- return this.parse(t);
2912
- } catch {
2913
- return this;
2914
- }
2915
- }
2916
- if (e.length === 2) {
2917
- if (e[0] instanceof y && e[1] instanceof N)
2918
- return this.parseByPointAndVector(e[0], e[1]);
2919
- if (e[0] instanceof y && e[1] instanceof y)
2920
- return this.parseByPointAndVector(e[0], new N(e[0], e[1]));
2921
- if (e[0] instanceof N && e[1] instanceof y)
2922
- return this.parseByPointAndNormal(e[1], e[0]);
2923
- }
2924
- if (e.length === 3) {
2925
- if ((e[0] instanceof h || typeof e[0] == "number") && (e[1] instanceof h || typeof e[1] == "number") && (e[2] instanceof h || typeof e[2] == "number"))
2926
- return this.parseByCoefficient(e[0], e[1], e[2]);
2927
- if (e[0] instanceof y && e[1] instanceof N) {
2928
- if (e[2] === "perpendicular")
2929
- return this.parseByPointAndNormal(e[0], e[1]);
2930
- if (e[2] === "parallel")
2931
- return this.parseByPointAndVector(e[0], e[1]);
2932
- } else if (e[0] instanceof y && e[1] instanceof z)
2933
- return e[2] === "parallel" || e[2] === null ? this.parseByPointAndLine(
2934
- e[0],
2935
- e[1],
2936
- "parallel"
2937
- /* Parallel */
2938
- ) : this.parseByPointAndLine(
2939
- e[0],
2940
- e[1],
2941
- "perpendicular"
2942
- /* Perpendicular */
2943
- );
2944
- }
2945
- return console.log("Someting wrong happend while creating the line"), this;
2884
+ makeZeroes() {
2885
+ return this._getZeroes(this.fx);
2886
+ }
2887
+ makeSigns() {
2888
+ return this._getSigns(this.fx, this.zeroes);
2889
+ }
2890
+ makeAsymptotes() {
2891
+ const e = this.fx.clone().reduce();
2892
+ let t = [];
2893
+ this.zeroes.filter((n) => n.type === L.DEFENCE).forEach((n) => {
2894
+ let o = M.VERTICAL, l = `x=${n.tex}`, a = `x=${n.display}`;
2895
+ n.exact instanceof h ? e.denominator.evaluate(n.exact).isNotZero() && (o = M.HOLE, l = `(${n.tex};${e.evaluate(n.exact).tex})`, a = `(${n.display};${e.evaluate(n.exact).display})`) : e.denominator.evaluate(n.value).isNotZero() && (o = M.HOLE, l = `(${n.tex};${e.evaluate(n.value).tex})`, a = `(${n.display};${e.evaluate(n.value).display})`);
2896
+ const f = 1e-6;
2897
+ let m = this.fx.evaluateAsNumeric(n.value - f), d = this.fx.evaluateAsNumeric(n.value + f), p = [], _ = "";
2898
+ d < -1e4 ? (p.push(E.RB), _ += "m") : d > 1e4 && (p.push(E.RT), _ += "p"), m < -1e4 ? (p.push(E.LB), _ += "m") : m > 1e4 && (p.push(E.LT), _ += "p"), _ === "pp" ? _ = "+" : _ === "mm" ? _ = "-" : _ = `\\${_}`, t.push({
2899
+ fx: null,
2900
+ type: o,
2901
+ tex: l,
2902
+ display: a,
2903
+ zero: n,
2904
+ limits: `\\lim_{x\\to${n.tex} }\\ f(x) = ${_}\\infty`,
2905
+ deltaX: null,
2906
+ tableOfSign: null,
2907
+ position: p
2908
+ });
2946
2909
  });
2947
- r(this, "parseEquation", (e) => {
2948
- e.reorder(!0);
2949
- let t = new Set(e.letters());
2950
- if (!(t.has("x") || t.has("y")))
2951
- return this;
2952
- for (let i of ["x", "y"])
2953
- t.has(i) && t.delete(i);
2954
- return t.size > 0 ? this : this.parseByCoefficient(e.left.monomByLetter("x").coefficient, e.left.monomByLetter("y").coefficient, e.left.monomByDegree(0).coefficient);
2955
- });
2956
- r(this, "parseByCoefficient", (e, t, i) => (this._a = new h(e), this._b = new h(t), this._c = new h(i), this._d = new N(this._b.clone(), this._a.clone().opposed()), this._OA = new y(new h().zero(), this._c.clone()), this._n = this._d.clone().normal(), this._exists = !0, this));
2957
- r(this, "parseByPointAndVector", (e, t) => (this.parseByCoefficient(
2958
- t.y,
2959
- t.x.clone().opposed(),
2960
- e.x.clone().multiply(t.y).subtract(e.y.clone().multiply(t.x)).opposed()
2961
- ), this._OA = e.clone(), this._d = t.clone(), this._n = this._d.clone().normal(), this._exists = !0, this));
2962
- r(this, "parseByPointAndNormal", (e, t) => this.parseByCoefficient(
2963
- t.x,
2964
- t.y,
2965
- e.x.clone().multiply(t.x).add(e.y.clone().multiply(t.y)).opposed()
2910
+ let i = this.fx.numerator.degree(), s = this.fx.denominator.degree();
2911
+ if (i.isEqual(s)) {
2912
+ let n = this.fx.numerator.monomByDegree().coefficient.clone().divide(this.fx.denominator.monomByDegree().coefficient), o = n.tex, { reminder: l } = e.euclidian(), a = new R(l, e.denominator);
2913
+ t.push({
2914
+ fx: new u(n),
2915
+ type: M.HORIZONTAL,
2916
+ tex: `y=${o}`,
2917
+ display: `y=${n.display}`,
2918
+ zero: null,
2919
+ limits: `\\lim_{x\\to\\infty}\\ f(x) = ${o}`,
2920
+ deltaX: a,
2921
+ tableOfSign: this._getSigns(a),
2922
+ position: this._getHorizontalAsymptoteRelativePositon(a)
2923
+ });
2924
+ } else if (s.greater(i))
2925
+ t.push({
2926
+ fx: new u("0"),
2927
+ type: M.HORIZONTAL,
2928
+ tex: "y=0",
2929
+ display: "y=0",
2930
+ zero: null,
2931
+ limits: "\\lim_{x\\to\\infty}\\ f(x) = 0",
2932
+ deltaX: null,
2933
+ tableOfSign: null,
2934
+ position: this._getHorizontalAsymptoteRelativePositon(this.fx)
2935
+ });
2936
+ else if (i.value - 1 === s.value) {
2937
+ let { quotient: n, reminder: o } = e.euclidian(), l = new R(o, e.denominator);
2938
+ t.push({
2939
+ fx: n.clone(),
2940
+ type: M.SLOPE,
2941
+ tex: `y=${n.tex}`,
2942
+ display: `y=${n.display}`,
2943
+ zero: null,
2944
+ limits: "",
2945
+ deltaX: new R(o, e.denominator),
2946
+ tableOfSign: this._getSigns(l),
2947
+ position: this._getHorizontalAsymptoteRelativePositon(l)
2948
+ });
2949
+ }
2950
+ return t;
2951
+ }
2952
+ _getHorizontalAsymptoteRelativePositon(e, t = 1e6) {
2953
+ let i = [], s = e.evaluateAsNumeric(-t), n = e.evaluateAsNumeric(t);
2954
+ return s >= 0 ? i.push(E.LT) : i.push(E.LB), n >= 0 ? i.push(E.RT) : i.push(E.RB), i;
2955
+ }
2956
+ makeDerivative() {
2957
+ let e = this.fx.clone().derivative(), t = this._getSigns(e, this._getZeroes(e), W.GROWS), i = this.makeGrowsResult(t);
2958
+ return t.signs.push(i.growsLine), t.extremes = i.extremes, t;
2959
+ }
2960
+ makeVariation() {
2961
+ let e = this.derivative.fx.clone().derivative(), t = this._getSigns(e, this._getZeroes(e), W.VARIATIONS), i = this.makeVariationsResult(t);
2962
+ return t.signs.push(i.varsLine), t.extremes = i.extremes, t;
2963
+ }
2964
+ _getZeroes(e) {
2965
+ let t = [];
2966
+ return e.numerator.getZeroes().filter((i) => !isNaN(i.value)).forEach((i) => {
2967
+ t.push({
2968
+ tex: i.tex,
2969
+ display: i.display,
2970
+ value: i.value,
2971
+ exact: i.exact,
2972
+ extrema: H.NOTHING,
2973
+ type: L.ZERO
2974
+ });
2975
+ }), e.denominator.getZeroes().filter((i) => !isNaN(i.value)).forEach((i) => {
2976
+ let s = this.indexOfZero(t, i);
2977
+ s !== -1 ? t[s].type = L.DEFENCE : t.push({
2978
+ tex: i.tex,
2979
+ display: i.display,
2980
+ value: i.value,
2981
+ exact: i.exact,
2982
+ extrema: H.NOTHING,
2983
+ type: L.DEFENCE
2984
+ });
2985
+ }), t.sort((i, s) => i.value - s.value), t;
2986
+ }
2987
+ _getSigns(e, t, i) {
2988
+ let s = [], n = [];
2989
+ return t === void 0 && (t = this._getZeroes(e)), e.numerator.factors.forEach((o) => {
2990
+ s.push(this.makeOneLineForSigns(o, t, L.ZERO)), n.push(o.clone());
2991
+ }), e.denominator.factors.forEach((o) => {
2992
+ s.push(this.makeOneLineForSigns(o, t, L.DEFENCE)), n.push(o.clone());
2993
+ }), s.push(this.makeSignsResult(s)), {
2994
+ type: i,
2995
+ fx: e,
2996
+ factors: n,
2997
+ zeroes: t,
2998
+ signs: s,
2999
+ extremes: {},
3000
+ tex: ""
3001
+ };
3002
+ }
3003
+ }
3004
+ class R {
3005
+ /**
3006
+ *
3007
+ * @param numerator
3008
+ * @param denominator
3009
+ */
3010
+ constructor(e, t) {
3011
+ r(this, "_denominator");
3012
+ r(this, "_numerator");
3013
+ r(this, "_rawString");
3014
+ r(this, "clone", () => new R(
3015
+ this._numerator.clone(),
3016
+ this._denominator.clone()
2966
3017
  ));
2967
- r(this, "parseByPointAndLine", (e, t, i) => (i === void 0 && (i = "parallel"), i === "parallel" ? this.parseByPointAndNormal(e, t.normal) : i === "perpendicular" ? this.parseByPointAndNormal(e, t.director) : (this._exists = !1, this)));
2968
- r(this, "clone", () => (this._a = this._a.clone(), this._b = this._b.clone(), this._c = this._c.clone(), this._d = this._d.clone(), this._OA = this._OA.clone(), this._n = this._n.clone(), this._exists = this.exists, this));
2969
- // ------------------------------------------
2970
- // Mathematical operations
2971
- // ------------------------------------------
2972
- r(this, "isOnLine", (e) => this._a.clone().multiply(e.x).add(
2973
- this._b.clone().multiply(e.y)
2974
- ).add(this._c).isZero());
2975
- r(this, "isParallelTo", (e) => this.slope.isEqual(e.slope) && this.height.isNotEqual(e.height));
2976
- r(this, "isSameAs", (e) => this.slope.isEqual(e.slope) && this.height.isEqual(e.height));
2977
- r(this, "isPerpendicularTo", (e) => this.d.isNormalTo(e.d));
2978
- r(this, "isVertical", () => this.slope.isInfinity());
2979
- r(this, "simplify", () => {
2980
- let e = x.lcm(this._a.denominator, this._b.denominator, this._c.denominator), t = x.gcd(this._a.numerator, this._b.numerator, this._c.numerator);
2981
- return this.parseByCoefficient(
2982
- this._a.clone().multiply(e).divide(t),
2983
- this._b.clone().multiply(e).divide(t),
2984
- this._c.clone().multiply(e).divide(t)
2985
- ), this;
3018
+ r(this, "domain", () => {
3019
+ let e = this._denominator.getZeroes();
3020
+ return e.length === 0 || e[0].tex === F.real ? F.varnothing : e[0].tex === F.varnothing ? F.real : "\\mathbb{R}\\setminus\\left\\{" + e.map((t) => t.tex).join(";") + "\\right\\}";
2986
3021
  });
2987
- r(this, "simplifyDirection", () => (this._d.simplifyDirection(), this));
2988
- r(this, "intersection", (e) => {
2989
- let t = new y(), i = !1, s = !1;
2990
- return this._b.isZero() || e.b.isZero(), this.isParallelTo(e) ? (t.x = null, t.y = null, i = !0) : this.isSameAs(e) ? (t.x = null, t.y = null, s = !0) : (t.x = this._b.clone().multiply(e.c).subtract(this._c.clone().multiply(e.b)).divide(this._a.clone().multiply(e.b).subtract(this._b.clone().multiply(e.a))), t.y = this._a.clone().multiply(e.c).subtract(this._c.clone().multiply(e.a)).divide(this._b.clone().multiply(e.a).subtract(this._a.clone().multiply(e.b)))), {
2991
- point: t,
2992
- hasIntersection: !(i || s),
2993
- isParallel: i,
2994
- isSame: s
2995
- };
3022
+ r(this, "amplify", (e) => (this._numerator.multiply(e), this._denominator.multiply(e), this));
3023
+ r(this, "derivative", (e) => {
3024
+ let t = this._numerator.clone(), i = this._denominator.clone(), s = t.clone().derivative(e), n = i.clone().derivative(e);
3025
+ return this._numerator = s.clone().multiply(i).subtract(t.clone().multiply(n)), this._denominator = i.clone().pow(2), this;
2996
3026
  });
2997
- r(this, "getValueAtX", (e) => {
2998
- const t = this.equation.clone().isolate("y"), i = new h(e);
2999
- if (t instanceof k)
3000
- return t.right.evaluate({ x: i });
3027
+ r(this, "factorize", (e) => (this._numerator.factorize(e), this._denominator.factorize(e), this));
3028
+ r(this, "simplify", (e) => {
3029
+ let t = this._numerator.euclidian(e);
3030
+ if (!t.reminder.isZero())
3031
+ return this;
3032
+ let i = this._denominator.euclidian(e);
3033
+ return i.reminder.isZero() ? (this._numerator = t.quotient, this._denominator = i.quotient, this) : this;
3001
3034
  });
3002
- r(this, "getValueAtY", (e) => {
3003
- const t = this.equation.clone().isolate("x"), i = new h(e);
3004
- if (t instanceof k)
3005
- return t.right.evaluate({ y: i });
3035
+ r(this, "reduce", () => {
3036
+ this._numerator.factorize();
3037
+ for (let e of this._numerator.factors)
3038
+ e.degree().isZero() ? this._denominator.commonMonom().coefficient.clone().divide(e.monomByDegree().coefficient).isNatural() && this.simplify(e) : this.simplify(e);
3039
+ return this;
3006
3040
  });
3007
- return this._exists = !1, this._reduceBeforeDisplay = !0, e.length > 0 && this.parse(...e), this;
3008
- }
3009
- get a() {
3010
- return this._a;
3041
+ r(this, "opposed", () => (this._numerator.opposed(), this));
3042
+ r(this, "add", (e) => {
3043
+ let t = this._denominator.clone();
3044
+ return this.amplify(e._denominator), this._numerator.add(e._numerator.clone().multiply(t)), this;
3045
+ });
3046
+ r(this, "subtract", (e) => this.add(e.clone().opposed()));
3047
+ r(this, "euclidian", () => this._numerator.euclidian(this._denominator));
3048
+ // TODO : where and how is used limits ?
3049
+ r(this, "limits", (e, t, i) => {
3050
+ if (e === 1 / 0 || e === -1 / 0) {
3051
+ let { quotient: s, reminder: n } = this._numerator.clone().euclidian(this._denominator);
3052
+ return s.degree(i).isStrictlyPositive() ? e === 1 / 0 ? s.limitToInfinity(i) : s.limitToNegativeInfinity(i) : s.monomByDegree(void 0, i).coefficient;
3053
+ } else {
3054
+ let s = {}, n = {}, o, l, a = this.clone().reduce();
3055
+ return s[i === void 0 ? "x" : i] = new h(e), t !== "above" && t !== "below" ? (o = a._numerator.evaluate(s).divide(a._denominator.evaluate(s)), o.isInfinity() ? o.abs() : o) : (t === "above" ? n[i === void 0 ? "x" : i] = new h(e).add(1e-6) : t === "below" && (n[i === void 0 ? "x" : i] = new h(e).subtract(1e-6)), o = a._numerator.evaluate(s).divide(a._denominator.evaluate(s)), l = a._numerator.evaluate(n).divide(a._denominator.evaluate(n)).sign(), o.isInfinity() ? l === 1 ? o.abs() : o.abs().opposed() : o);
3056
+ }
3057
+ });
3058
+ r(this, "evaluate", (e) => {
3059
+ new h().zero();
3060
+ let t = this._numerator.evaluate(e), i = this._denominator.evaluate(e);
3061
+ return t.divide(i);
3062
+ });
3063
+ r(this, "evaluateAsNumeric", (e) => this._numerator.evaluateAsNumeric(e) / this._denominator.evaluateAsNumeric(e));
3064
+ r(this, "study", (e) => new re(this, e));
3065
+ e instanceof u ? this._numerator = e.clone() : typeof e == "string" ? this._numerator = new u(e) : this._numerator = new u(), t instanceof u ? this._denominator = t.clone() : typeof t == "string" ? this._denominator = new u(t) : this._denominator = new u();
3011
3066
  }
3012
- // ------------------------------------------
3013
- // Getter and setter
3014
- set a(e) {
3015
- this._a = e;
3067
+ get numerator() {
3068
+ return this._numerator;
3016
3069
  }
3017
- get b() {
3018
- return this._b;
3070
+ get denominator() {
3071
+ return this._denominator;
3019
3072
  }
3020
- set b(e) {
3021
- this._b = e;
3073
+ get tex() {
3074
+ return `\\frac{ ${this._numerator.tex} }{ ${this._denominator.tex} }`;
3022
3075
  }
3023
- get c() {
3024
- return this._c;
3076
+ get display() {
3077
+ return `(${this._numerator.display})/(${this._denominator.display})`;
3025
3078
  }
3026
- set c(e) {
3027
- this._c = e;
3079
+ get texFactors() {
3080
+ return `\\frac{ ${this._numerator.texFactors} }{ ${this._denominator.texFactors} }`;
3028
3081
  }
3029
- get OA() {
3030
- return this._OA;
3082
+ get displayFactors() {
3083
+ return `(${this._numerator.displayFactors})/(${this._denominator.displayFactors})`;
3031
3084
  }
3032
- set OA(e) {
3033
- this._OA = e;
3085
+ get plotFunction() {
3086
+ return `(${this._numerator.plotFunction})/(${this._denominator.plotFunction})`;
3034
3087
  }
3035
- get d() {
3036
- return this._d;
3088
+ }
3089
+ class ne {
3090
+ /**
3091
+ *
3092
+ * @param {string} value (optional) Default polynom to parse on class creation
3093
+ */
3094
+ constructor(e) {
3095
+ r(this, "_rawString");
3096
+ r(this, "_rpn");
3097
+ r(this, "parse", (e) => (this._rpn = new P(U.SET).parse(e).rpn, this));
3098
+ return this._rawString = e, this.parse(e), this;
3037
3099
  }
3038
- set d(e) {
3039
- this._d = e;
3100
+ get isLogicalset() {
3101
+ return !0;
3040
3102
  }
3041
- get n() {
3042
- return this._n;
3043
- }
3044
- get exists() {
3045
- return this._exists;
3046
- }
3047
- // ------------------------------------------
3048
- get equation() {
3049
- let e = new k(new u().parse("xy", this._a, this._b, this._c), new u("0"));
3050
- return this._reduceBeforeDisplay ? e.simplify() : e;
3051
- }
3052
- get system() {
3053
- let e = new k(
3054
- new u("x"),
3055
- new u(this._OA.x).add(new g("k").multiplyByNumber(this._d.x))
3056
- ), t = new k(
3057
- new u("y"),
3058
- new u(this._OA.y).add(new g("k").multiplyByNumber(this._d.y))
3059
- );
3060
- return { x: e, y: t };
3103
+ get rpn() {
3104
+ return this._rpn;
3061
3105
  }
3062
3106
  get tex() {
3063
- let e = this.equation.clone().reorder(!0);
3064
- this._a.isNegative() && e.multiply(-1);
3065
- let t = this._d.clone();
3066
- return this._reduceBeforeDisplay && t.simplifyDirection(), {
3067
- canonical: e.tex,
3068
- equation: e.clone().reorder().tex,
3069
- mxh: this.slope.isInfinity() ? "x=" + this.OA.x.tex : "y=" + new u().parse("x", this.slope, this.height).tex,
3070
- parametric: `${y.pmatrix("x", "y")} = ${y.pmatrix(this._OA.x, this._OA.y)} + k\\cdot ${y.pmatrix(t.x, t.y)}`,
3071
- system: `\\left\\{\\begin{aligned}
3072
- x &= ${new u(this._OA.x).add(new g(this._d.x).multiply(new g("k"))).reorder("k", !0).tex}\\\\
3073
- y &= ${new u(this._OA.y).add(new g(this._d.y).multiply(new g("k"))).reorder("k", !0).tex}
3074
- \\end{aligned}\\right.`
3075
- };
3076
- }
3077
- get reduceBeforeDisplay() {
3078
- return this._reduceBeforeDisplay;
3079
- }
3080
- set reduceBeforeDisplay(e) {
3081
- this._reduceBeforeDisplay = e;
3082
- }
3083
- get display() {
3084
- let e = this.equation;
3085
- return this._a.isNegative() && e.multiply(-1), {
3086
- canonical: e.display,
3087
- mxh: this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new u().parse("x", this.slope, this.height).display,
3088
- parametric: ""
3089
- };
3090
- }
3091
- get normal() {
3092
- return new N(this._a, this._b);
3093
- }
3094
- get director() {
3095
- return this._d.clone();
3096
- }
3097
- get slope() {
3098
- return this._a.clone().opposed().divide(this._b);
3107
+ let e = [];
3108
+ for (let t of this._rpn)
3109
+ if (t.tokenType === "variable")
3110
+ e.push(t);
3111
+ else
3112
+ switch (t.token) {
3113
+ case "&":
3114
+ if (e.length >= 2) {
3115
+ let i = e.pop(), s = e.pop();
3116
+ s.tokenType === "mix" && (s.token = `( ${s.token} )`), i.tokenType === "mix" && (i.token = `( ${i.token} )`), e.push({ token: `${s.token} \\cap ${i.token}`, tokenType: "mix" });
3117
+ }
3118
+ break;
3119
+ case "|":
3120
+ if (e.length >= 2) {
3121
+ let i = e.pop(), s = e.pop();
3122
+ s.tokenType === "mix" && (s.token = `( ${s.token} )`), i.tokenType === "mix" && (i.token = `( ${i.token} )`), e.push({ token: `${s.token} \\cup ${i.token}`, tokenType: "mix" });
3123
+ }
3124
+ break;
3125
+ case "-":
3126
+ if (e.length >= 2) {
3127
+ let i = e.pop(), s = e.pop();
3128
+ s.tokenType === "mix" && (s.token = `( ${s.token} )`), i.tokenType === "mix" && (i.token = `( ${i.token} )`), e.push({ token: `${s.token} \\setminus ${i.token}`, tokenType: "mix" });
3129
+ }
3130
+ break;
3131
+ case "!":
3132
+ if (e.length >= 1) {
3133
+ let i = e.pop();
3134
+ e.push({ token: `\\overline{ ${i.token} }`, tokenType: "variable" });
3135
+ }
3136
+ break;
3137
+ }
3138
+ return e[0].token;
3099
3139
  }
3100
- get height() {
3101
- return this._c.clone().opposed().divide(this._b);
3140
+ evaluate(e, t) {
3141
+ let i = [], s;
3142
+ if (t === void 0) {
3143
+ s = /* @__PURE__ */ new Set();
3144
+ for (let n in e)
3145
+ s = /* @__PURE__ */ new Set([...s, ...e[n]]);
3146
+ } else
3147
+ s = new Set(t);
3148
+ for (let n of this._rpn)
3149
+ if (n.tokenType === "variable")
3150
+ e[n.token] === void 0 ? i.push(/* @__PURE__ */ new Set()) : i.push(new Set(e[n.token]));
3151
+ else
3152
+ switch (n.token) {
3153
+ case "&":
3154
+ if (i.length >= 2) {
3155
+ let o = i.pop(), l = i.pop();
3156
+ i.push(new Set([...l].filter((a) => o.has(a))));
3157
+ }
3158
+ break;
3159
+ case "|":
3160
+ if (i.length >= 2) {
3161
+ let o = i.pop(), l = i.pop();
3162
+ i.push(/* @__PURE__ */ new Set([...l, ...o]));
3163
+ }
3164
+ break;
3165
+ case "-":
3166
+ if (i.length >= 2) {
3167
+ let o = i.pop(), l = i.pop();
3168
+ i.push(new Set([...l].filter((a) => !o.has(a))));
3169
+ }
3170
+ break;
3171
+ case "!":
3172
+ if (i.length >= 1) {
3173
+ let o = i.pop();
3174
+ i.push(new Set([...s].filter((l) => !o.has(l))));
3175
+ }
3176
+ break;
3177
+ }
3178
+ return [...i[0]].sort();
3102
3179
  }
3103
- distanceTo(e) {
3104
- let t = e.x.clone().multiply(this._a).add(e.y.clone().multiply(this._b)).add(this._c).abs(), i = this.normal.normSquare;
3105
- if (i.isZero())
3106
- return {
3107
- value: NaN,
3108
- tex: "Not a line",
3109
- fraction: new h().infinite()
3110
- };
3111
- let s = t.value / Math.sqrt(i.value), n = t.clone().divide(i.clone().sqrt());
3112
- return i.isSquare() ? {
3113
- value: s,
3114
- tex: n.tex,
3115
- fraction: n
3116
- } : {
3117
- value: s,
3118
- tex: `\\frac{${t.tex}}{\\sqrt{${i.tex}}}`,
3119
- fraction: n
3120
- };
3180
+ vennAB() {
3181
+ return this.evaluate(
3182
+ {
3183
+ A: ["A", "AB"],
3184
+ B: ["B", "AB"]
3185
+ },
3186
+ ["A", "B", "AB", "E"]
3187
+ );
3121
3188
  }
3122
- hitSegment(e, t) {
3123
- let i = this.intersection(
3124
- new z(e, t)
3189
+ vennABC() {
3190
+ return this.evaluate(
3191
+ {
3192
+ A: ["A", "AB", "AC", "ABC"],
3193
+ B: ["B", "AB", "BC", "ABC"],
3194
+ C: ["C", "AC", "BC", "ABC"]
3195
+ },
3196
+ ["A", "B", "C", "AB", "AC", "BC", "E"]
3125
3197
  );
3126
- 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;
3127
3198
  }
3128
- // ------------------------------------------
3129
- // Special functions
3130
- // ------------------------------------------
3131
- canonicalAsFloatCoefficient(e) {
3132
- e === void 0 && (e = 2), this._a.value, this._b.value, this._c.value;
3133
- let t = "";
3134
- return this._a.isZero() || (this._a.isOne() ? t = "x" : this._a.clone().opposed().isOne() ? t = "-x" : t = this._a.value.toFixed(e) + "x"), this._b.isZero() || (this._b.isPositive() && (t += "+"), t += this._b.value.toFixed(e) + "y"), this._c.isZero() || (this._c.isPositive() && (t += "+"), t += this._c.value.toFixed(e)), t + "=0";
3199
+ }
3200
+ class D {
3201
+ constructor() {
3202
+ r(this, "_config");
3203
+ r(this, "_defaultConfig");
3204
+ r(this, "mergeConfig", (e, t) => e !== void 0 ? { ...t, ...e } : t);
3205
+ r(this, "generate", () => {
3206
+ });
3207
+ r(this, "config", (e) => (this._config = this.mergeConfig(e, this._defaultConfig), this));
3135
3208
  }
3136
- };
3137
- // A line is defined as the canonical form
3138
- r(z, "PERPENDICULAR", "perpendicular"), r(z, "PARALLEL", "parallel");
3139
- let A = z;
3140
- class oe extends D {
3209
+ }
3210
+ class J extends D {
3141
3211
  constructor(t) {
3142
3212
  super();
3143
3213
  r(this, "generate", () => {
3144
- const t = new N(
3145
- w.numberSym(10),
3146
- w.numberSym(10)
3147
- );
3148
- for (; t.isNull; )
3149
- t.x = w.numberSym(10), t.y = w.numberSym(10);
3150
- return this._config.slope === 1 ? t.x.sign() !== t.y.sign() && t.y.opposed() : this._config.slope === -1 && t.x.sign() !== t.y.sign() && t.y.opposed(), new A(new y(this._config.A.x, this._config.A.y), t);
3214
+ let t = new g();
3215
+ if (typeof this._config.fraction == "boolean" ? t.coefficient = w.fraction({
3216
+ zero: this._config.zero,
3217
+ reduced: !0,
3218
+ natural: !this._config.fraction
3219
+ }) : t.coefficient = w.fraction(this._config.fraction), this._config.letters.length > 1) {
3220
+ for (let i of this._config.letters.split(""))
3221
+ t.setLetter(i, 0);
3222
+ for (let i = 0; i < this._config.degree; i++) {
3223
+ const s = w.item(this._config.letters.split(""));
3224
+ t.setLetter(s, t.degree(s).clone().add(1));
3225
+ }
3226
+ } else
3227
+ t.setLetter(this._config.letters, this._config.degree);
3228
+ return t;
3151
3229
  });
3152
3230
  this._defaultConfig = {
3153
- A: {
3154
- x: w.numberSym(10),
3155
- y: w.numberSym(10)
3156
- }
3231
+ letters: "x",
3232
+ degree: 2,
3233
+ fraction: !0,
3234
+ zero: !1
3157
3235
  }, this._config = this.mergeConfig(t, this._defaultConfig);
3158
3236
  }
3159
3237
  }
3160
- class le extends D {
3238
+ class oe extends D {
3161
3239
  constructor(t) {
3162
3240
  super();
3163
3241
  r(this, "generate", () => {
3164
- let t, i, s = this._config.axis === !0 || this._config.axis === "x", n = this._config.axis === !0 || this._config.axis === "y";
3165
- return t = this._config.fraction ? w.fraction({ max: this._config.max, zero: s }) : new h(w.numberSym(this._config.max, s)), i = this._config.fraction ? w.fraction({ max: this._config.max, zero: n }) : new h(w.numberSym(this._config.max, n)), +this._config.quadrant == 1 && (t.abs(), i.abs()), +this._config.quadrant == 2 && (t.isPositive() && t.opposed(), i.isNegative() && i.opposed()), +this._config.quadrant == 3 && (t.isPositive() && t.opposed(), i.isPositive() && i.opposed()), +this._config.quadrant == 4 && (t.isNegative() && t.opposed(), i.isPositive() && i.opposed()), new y(t, i);
3242
+ if (this._config.factorable && this._config.degree > 1)
3243
+ return this.factorable();
3244
+ let t = new u().empty(), i;
3245
+ for (let s = this._config.degree; s >= 0; s--)
3246
+ i = new J({
3247
+ letters: this._config.letters,
3248
+ degree: s,
3249
+ fraction: this._config.fraction,
3250
+ zero: s === this._config.degree ? !1 : this._config.allowNullMonom
3251
+ }).generate(), this._config.unit && this._config.degree === s && i.coefficient.one(), t.add(i);
3252
+ if (this._config.positive && t.monomByDegree().coefficient.isNegative() && t.monomByDegree().coefficient.opposed(), this._config.numberOfMonoms > 0 && this._config.numberOfMonoms < t.length) {
3253
+ let s = t.monomByDegree().clone();
3254
+ t.monoms = w.array(t.monoms.slice(1), this._config.numberOfMonoms - 1), t.add(s).reorder().reduce();
3255
+ }
3256
+ return t;
3257
+ });
3258
+ r(this, "factorable", () => {
3259
+ let t = new u().one(), i = { ...this._config };
3260
+ i.degree = 1, i.factorable = !1;
3261
+ for (let s = 0; s < this._config.degree; s++)
3262
+ t.multiply(w.polynom(i));
3263
+ return t;
3166
3264
  });
3167
3265
  this._defaultConfig = {
3168
- axis: !0,
3266
+ letters: "x",
3267
+ degree: 2,
3169
3268
  fraction: !1,
3170
- max: 10
3269
+ zero: !1,
3270
+ unit: !1,
3271
+ factorable: !1,
3272
+ allowNullMonom: !0,
3273
+ numberOfMonoms: 0,
3274
+ positive: !0
3171
3275
  }, this._config = this.mergeConfig(t, this._defaultConfig);
3172
3276
  }
3173
3277
  }
3174
- class j {
3175
- constructor(...e) {
3176
- r(this, "_A");
3177
- r(this, "_B");
3178
- r(this, "_C");
3179
- r(this, "_lines");
3180
- r(this, "_middles");
3181
- r(this, "_remarquables");
3182
- // ------------------------------------------
3183
- // Creation / parsing functions
3278
+ class T {
3279
+ /**
3280
+ * Random boolean with a percent ratio
3281
+ * @param percent
3282
+ */
3283
+ static randomBool(e = 0.5) {
3284
+ return Math.random() < e;
3285
+ }
3286
+ /**
3287
+ * Random integer between two values.
3288
+ * @param a (number) : From this value to the second value. If the second is ommited, this value is the max value.
3289
+ * @param b (number) : To this value. If this is ommited.
3290
+ */
3291
+ static randomInt(e, t, i) {
3292
+ if (t === void 0)
3293
+ return e >= 0 ? this.randomInt(0, e) : this.randomInt(e, 0);
3294
+ if (e === t)
3295
+ return e;
3296
+ if (i === void 0)
3297
+ return Math.floor(Math.random() * (t - e + 1) + e);
3298
+ if (Math.abs(t - e) <= i.length)
3299
+ throw new Error("The number of excluded values is too high.");
3300
+ let s = this.randomInt(e, t);
3301
+ for (; i.includes(s); )
3302
+ s = this.randomInt(e, t);
3303
+ return s;
3304
+ }
3305
+ /**
3306
+ * Random integer between -max and max value.
3307
+ * @param max (number) : determine the limits.
3308
+ * @param zero (bool) : determine if zero is allowed or not.
3309
+ */
3310
+ static randomIntSym(e, t) {
3311
+ return t === !1 ? this.randomBool() ? this.randomInt(1, e) : -this.randomInt(1, e) : this.randomInt(-e, e);
3312
+ }
3313
+ static randomPrime(e) {
3314
+ let t = x.primes();
3315
+ return e !== void 0 && (t = t.filter((i) => i < e)), this.randomItem(t);
3316
+ }
3317
+ static randomArray(e, t) {
3318
+ return t === void 0 && (t = 1), e.length <= 0 ? Object.values(e) : T.shuffleArray(e).slice(0, t);
3319
+ }
3320
+ static randomItem(e) {
3321
+ return e.length === 0 ? "" : e[this.randomInt(0, e.length - 1)];
3322
+ }
3323
+ static shuffleArray(e) {
3324
+ let t = Object.values(e);
3325
+ for (let i = t.length - 1; i > 0; i--) {
3326
+ const s = Math.floor(Math.random() * (i + 1)), n = t[i];
3327
+ t[i] = t[s], t[s] = n;
3328
+ }
3329
+ return t;
3330
+ }
3331
+ }
3332
+ class le extends D {
3333
+ constructor(t) {
3334
+ super();
3335
+ r(this, "generate", () => {
3336
+ let t = new h();
3337
+ if (this._config.negative ? t.numerator = w.numberSym(this._config.max, this._config.zero) : t.numerator = w.number(this._config.zero ? 0 : 1, this._config.max), this._config.natural)
3338
+ t.denominator = 1;
3339
+ else {
3340
+ let i = 0;
3341
+ for (; t.isRelative() && i < 10; )
3342
+ t.denominator = w.number(1, this._config.max), i++;
3343
+ }
3344
+ return this._config.reduced ? t.reduce() : t;
3345
+ });
3346
+ this._defaultConfig = {
3347
+ negative: !0,
3348
+ max: 10,
3349
+ reduced: !0,
3350
+ zero: !0,
3351
+ natural: !1
3352
+ }, this._config = this.mergeConfig(t, this._defaultConfig);
3353
+ }
3354
+ }
3355
+ class ae {
3356
+ constructor() {
3357
+ r(this, "x");
3358
+ r(this, "y");
3359
+ }
3360
+ }
3361
+ const V = class V {
3362
+ constructor(...e) {
3363
+ r(this, "_x");
3364
+ // 1st component
3365
+ r(this, "_y");
3366
+ // 2nd component
3367
+ r(this, "_exist");
3184
3368
  // ------------------------------------------
3185
- /**
3186
- * Parse values to a triangle. Supported formats:
3187
- * Point, Point, Point
3188
- * x1, y1, x2, y2, x3, y3
3189
- * TODO: Something else ?
3190
- * @param values
3191
- */
3192
3369
  r(this, "parse", (...e) => {
3193
- if (e.length === 6) {
3194
- let t = e.map((i) => new h(i));
3195
- return this.parse(
3196
- new y(t[0], t[1]),
3197
- new y(t[2], t[3]),
3198
- new y(t[4], t[5])
3199
- );
3200
- } else if (e.length === 3) {
3201
- if (e.filter((t) => typeof t == "string").length === 3)
3202
- return this.parse(...e.map((t) => new A(t)));
3203
- if (e.filter((t) => t instanceof A).length === 3) {
3204
- this._lines = {
3205
- AB: e[0],
3206
- BC: e[1],
3207
- AC: e[2]
3208
- };
3209
- let t = e[0].intersection(e[1]);
3210
- if (t.hasIntersection)
3211
- this._B = t.point.clone();
3212
- else
3213
- return this;
3214
- if (t = e[1].intersection(e[2]), t.hasIntersection)
3215
- this._C = t.point.clone();
3216
- else
3217
- return this;
3218
- if (t = e[2].intersection(e[0]), t.hasIntersection)
3219
- this._A = t.point.clone();
3220
- else
3221
- return this;
3222
- } else {
3223
- if (e.filter((t) => t instanceof y).length < 3)
3224
- return this.parse(
3225
- new y(e[0]),
3226
- new y(e[1]),
3227
- new y(e[2])
3228
- );
3229
- this._A = e[0].clone(), this._B = e[1].clone(), this._C = e[2].clone(), this._lines = {
3230
- AB: new A(this._A, this._B),
3231
- BC: new A(this._B, this._C),
3232
- AC: new A(this._A, this._C)
3233
- };
3370
+ if (this.zero(), e.length === 0)
3371
+ return this;
3372
+ if (e.length === 1) {
3373
+ if (e[0] instanceof V)
3374
+ return this._x = e[0].x.clone(), this._y = e[0].y.clone(), this;
3375
+ if (typeof e[0] == "string") {
3376
+ let t = e[0].split(",");
3377
+ if (t.length === 2)
3378
+ return this._x = new h(t[0]).reduce(), this._y = new h(t[1]).reduce(), this;
3234
3379
  }
3235
- } else if (e.length === 1 && e[0] instanceof j)
3236
- return e[0].clone();
3237
- return this._updateTriangle(), this;
3380
+ return e[0] instanceof ae ? (this._x = new h(e[0].x).reduce(), this._y = new h(e[0].y).reduce(), this) : this.zero();
3381
+ }
3382
+ return e.length === 2 ? (this._x = new h(e[0]).reduce(), this._y = new h(e[1]).reduce(), this) : this;
3238
3383
  });
3239
- /**
3240
- * Clone the Triangle class
3241
- */
3242
- r(this, "clone", () => (this._A = this._A.clone(), this._B = this._B.clone(), this._C = this._C.clone(), this._lines = {
3243
- AB: this._lines.AB.clone(),
3244
- BC: this._lines.BC.clone(),
3245
- AC: this._lines.AC.clone()
3246
- }, this._updateTriangle(), this));
3384
+ r(this, "clone", () => (this._x = this._x.clone(), this._y = this._y.clone(), this));
3385
+ r(this, "zero", () => (this._x = new h(null), this._y = new h(null), this));
3386
+ r(this, "origin", () => (this.zero(), this));
3247
3387
  // ------------------------------------------
3248
- // Triangle operations and properties
3388
+ // Display functions
3389
+ r(this, "middleOf", (e, t) => (this._x = e.x.clone().add(t.x).divide(2), this._y = e.y.clone().add(t.y).divide(2), this));
3249
3390
  // ------------------------------------------
3250
- /**
3251
- * Generate the Line object for the three segments of the triangle
3252
- */
3253
- r(this, "_updateTriangle", () => {
3254
- this._middles = {
3255
- AB: new y().middleOf(this._A, this._B),
3256
- AC: new y().middleOf(this._A, this._C),
3257
- BC: new y().middleOf(this._B, this._C)
3258
- }, this._remarquables = this._calculateRemarquableLines();
3391
+ // Mathematical operations
3392
+ // ------------------------------------------
3393
+ // ------------------------------------------
3394
+ // Vector functions
3395
+ // ------------------------------------------
3396
+ // ------------------------------------------
3397
+ // Static functions
3398
+ r(this, "translate", (e) => (this._x = this._x.add(e.x), this._y = this._y.add(e.y), this));
3399
+ // ------------------------------------------
3400
+ r(this, "texValues", (e) => {
3401
+ let t = [];
3402
+ return t.push(this._x.value.toFixed(e === void 0 ? 2 : e)), t.push(this._y.value.toFixed(e === void 0 ? 2 : e)), `\\left(${t.join(";")}\\right)`;
3259
3403
  });
3260
- /**
3261
- * Get the Point class for the given name
3262
- * @param ptName
3263
- */
3264
- r(this, "getPointByName", (e) => {
3265
- switch (e.toUpperCase()) {
3266
- case "A":
3267
- return this._A;
3268
- case "B":
3269
- return this._B;
3270
- case "C":
3271
- return this._C;
3404
+ r(this, "distanceTo", (e) => {
3405
+ let t = 0, i = new h(), s = "";
3406
+ if (e instanceof A)
3407
+ return e.distanceTo(this);
3408
+ if (e instanceof V) {
3409
+ let n = new N(this, e);
3410
+ t = n.norm, i = n.normSquare.sqrt(), s = n.normSquare.isSquare() ? i.tex : `\\sqrt{\\frac{ ${n.normSquare.numerator} }{ ${n.normSquare.denominator} }}`;
3272
3411
  }
3273
- return this._A;
3274
- });
3275
- /**
3276
- * Get the vector for the segment given by name.
3277
- * @param ptName1
3278
- * @param ptName2
3279
- */
3280
- r(this, "getSegment", (e, t) => new N(
3281
- this.getPointByName(e),
3282
- this.getPointByName(t)
3283
- ));
3284
- r(this, "_calculateRemarquableLines", () => {
3285
- const e = this._calculateBisectors("A"), t = this._calculateBisectors("B"), i = this._calculateBisectors("C");
3286
- let s = {
3287
- medians: {
3288
- A: new A(this._A, this._middles.BC),
3289
- B: new A(this._B, this._middles.AC),
3290
- C: new A(this._C, this._middles.AB),
3291
- intersection: null
3292
- },
3293
- mediators: {
3294
- AB: new A(this._middles.AB, new N(this._A, this._B).normal()),
3295
- AC: new A(this._middles.AC, new N(this._A, this._C).normal()),
3296
- BC: new A(this._middles.BC, new N(this._B, this._C).normal()),
3297
- intersection: null
3298
- },
3299
- heights: {
3300
- A: new A(this._A, new N(this._B, this._C).normal()),
3301
- B: new A(this._B, new N(this._A, this._C).normal()),
3302
- C: new A(this._C, new N(this._A, this._B).normal()),
3303
- intersection: null
3304
- },
3305
- bisectors: {
3306
- A: e.internal,
3307
- B: t.internal,
3308
- C: t.internal,
3309
- intersection: null
3310
- },
3311
- externalBisectors: {
3312
- A: e.external,
3313
- B: t.external,
3314
- C: i.external,
3315
- intersection: null
3316
- }
3317
- };
3318
- return s.medians.intersection = s.medians.A.intersection(s.medians.B).point, s.mediators.intersection = s.mediators.AB.intersection(s.mediators.BC).point, s.heights.intersection = s.heights.A.intersection(s.heights.B).point, s.bisectors.intersection = s.bisectors.A.intersection(s.bisectors.B).point, s;
3319
- });
3320
- r(this, "_calculateBisectors", (e) => {
3321
- let t = this.lines, i, s;
3322
- e === "A" ? (i = t.AB, s = t.AC) : e === "B" ? (i = t.AB, s = t.BC) : e === "C" && (i = t.BC, s = t.AC);
3323
- let n = new A(new k(i.equation.left.clone().multiply(s.n.simplify().norm), s.equation.left.clone().multiply(i.n.simplify().norm)).reorder(!0).simplify()), o = new A(new k(i.equation.left.clone().multiply(s.n.simplify().norm), s.equation.left.clone().multiply(i.n.simplify().norm).opposed()).reorder(!0).simplify());
3324
- return e === "A" ? n.hitSegment(this.B, this.C) ? { internal: n, external: o } : { internal: o, external: n } : e === "B" ? n.hitSegment(this.A, this.C) ? { internal: n, external: o } : { internal: o, external: n } : e === "C" ? n.hitSegment(this.B, this.A) ? { internal: n, external: o } : { internal: o, external: n } : { internal: n, external: o };
3325
- });
3326
- return e.length > 0 && this.parse(...e), this;
3327
- }
3328
- // ------------------------------------------
3329
- // Getter and setters
3330
- // ------------------------------------------
3331
- get A() {
3332
- return this._A;
3333
- }
3334
- get B() {
3335
- return this._B;
3336
- }
3337
- get C() {
3338
- return this._C;
3339
- }
3340
- get AB() {
3341
- return this.getSegment("A", "B");
3342
- }
3343
- get BA() {
3344
- return this.getSegment("B", "A");
3345
- }
3346
- get BC() {
3347
- return this.getSegment("B", "C");
3412
+ return { value: t, fraction: i, tex: s };
3413
+ });
3414
+ r(this, "isInListOfPoints", (e) => e.map((i) => i.key).includes(this.key));
3415
+ r(this, "isEqual", (e) => this.x.isEqual(e.x) && this.y.isEqual(e.y));
3416
+ return this._x = new h().zero(), this._y = new h().zero(), e !== void 0 && this.parse(...e), this;
3348
3417
  }
3349
- get CB() {
3350
- return this.getSegment("C", "B");
3418
+ // ------------------------------------------
3419
+ // Getter and setter
3420
+ // ------------------------------------------
3421
+ get x() {
3422
+ return this._x;
3351
3423
  }
3352
- get AC() {
3353
- return this.getSegment("A", "C");
3424
+ set x(e) {
3425
+ this._x = e;
3354
3426
  }
3355
- get CA() {
3356
- return this.getSegment("C", "A");
3427
+ get y() {
3428
+ return this._y;
3357
3429
  }
3358
- get isRectangle() {
3359
- return !!(this.AB.isNormalTo(this.BC) || this.AB.isNormalTo(this.AC) || this.BC.isNormalTo(this.AC));
3430
+ set y(e) {
3431
+ this._y = e;
3360
3432
  }
3361
- get isEquilateral() {
3362
- return this.AB.normSquare.isEqual(this.BC.normSquare) && this.AB.normSquare.isEqual(this.AC.normSquare);
3433
+ get tex() {
3434
+ let e = [];
3435
+ return e.push(this._x.tex), e.push(this._y.tex), `\\left(${e.join(";")}\\right)`;
3363
3436
  }
3364
- get isIsocele() {
3365
- return this.AB.normSquare.isEqual(this.BC.normSquare) || this.AB.normSquare.isEqual(this.AC.normSquare) || this.BC.normSquare.isEqual(this.AC.normSquare);
3437
+ get display() {
3438
+ let e = [];
3439
+ return e.push(this._x.tex), e.push(this._y.tex), `(${e.join(";")})`;
3366
3440
  }
3367
- get lines() {
3368
- return this._lines;
3441
+ get asVector() {
3442
+ return new N(this.x, this.y);
3369
3443
  }
3370
- get remarquables() {
3371
- return this._remarquables;
3444
+ // ------------------------------------------
3445
+ // Creation / parsing functions
3446
+ get key() {
3447
+ return `${this.x.display};${this.y.display}`;
3372
3448
  }
3373
- }
3374
- class G {
3449
+ };
3450
+ // ------------------------------------------
3451
+ r(V, "pmatrix", (e, t, i) => i === void 0 ? `\\begin{pmatrix} ${e.tex ? e.tex : e} \\\\ ${t.tex ? t.tex : t} \\end{pmatrix}` : `\\begin{pmatrix} ${e.tex ? e.tex : e} \\\\ ${t.tex ? t.tex : t} \\\\ ${i.tex ? i.tex : i} \\end{pmatrix}`);
3452
+ let y = V;
3453
+ const O = class O {
3454
+ // 2nd component
3375
3455
  constructor(...e) {
3376
- r(this, "_center");
3377
- r(this, "_squareRadius");
3378
- r(this, "_cartesian");
3379
- r(this, "_exists");
3380
- /**
3381
- * Get the relative position between circle and line. It corresponds to the number of intersection.
3382
- * @param {Line} L
3383
- * @returns {number}
3384
- */
3385
- r(this, "relativePosition", (e) => {
3386
- let t = e.distanceTo(this.center), i = Math.sqrt(this._squareRadius.value);
3387
- return t.value - i > 1e-10 ? 0 : Math.abs(t.value - i) < 1e-10 ? 1 : 2;
3388
- });
3389
- r(this, "lineIntersection", (e) => {
3390
- let t = [], i;
3391
- if (this._cartesian === null)
3392
- return [];
3393
- const s = this._cartesian.clone(), n = e.equation.clone().isolate("x"), o = e.equation.clone().isolate("y");
3394
- if (n instanceof k && o instanceof k) {
3395
- s.replaceBy("y", o.right).simplify(), s.solve();
3396
- for (let l of s.solutions)
3397
- l.exact === !1 && isNaN(l.value) || (i = new h(l.exact === !1 ? l.value : l.exact), t.push(new y(i.clone(), o.right.evaluate(i))));
3456
+ r(this, "_x");
3457
+ // 1st component
3458
+ r(this, "_y");
3459
+ r(this, "parse", (...e) => {
3460
+ if (this.zero(), e.length === 0)
3461
+ return this;
3462
+ if (e.length === 1)
3463
+ return e[0] instanceof O ? e[0].clone() : this._parseString(e[0]);
3464
+ if (e.length >= 2) {
3465
+ if (e[0] instanceof y && e[1] instanceof y)
3466
+ return this._x = e[1].x.clone().subtract(e[0].x), this._y = e[1].y.clone().subtract(e[0].y), this;
3467
+ (e[0] instanceof h || !isNaN(e[0])) && (this._x = new h(e[0])), (e[1] instanceof h || !isNaN(e[1])) && (this._y = new h(e[1])), typeof e[0] == "object" && !isNaN(e[0].x) && !isNaN(e[0].x) && typeof e[1] == "object" && !isNaN(e[1].x) && !isNaN(e[1].x) && (this._x = new h(+e[1].x - e[0].x), this._y = new h(+e[1].y - e[0].y));
3398
3468
  }
3399
- return t;
3469
+ return this;
3400
3470
  });
3401
- r(this, "tangents", (e) => e instanceof h ? this._tangentsWithSlope(e) : this.isPointOnCircle(e) ? this._tangentsThroughOnePointOnTheCircle(e) : this.center.distanceTo(e).value > this.radius.value ? this._tangentsThroughOnePointOutsideTheCircle(e) : (console.log("No tangents as the point is inside !"), []));
3402
- r(this, "isPointOnCircle", (e) => this._cartesian.test({ x: e.x, y: e.y }));
3403
- r(this, "getPointsOnCircle", (e) => {
3404
- let t = x.pythagoricianTripletsWithTarget(this._squareRadius.value, !0), i = [], s;
3405
- return t.forEach((n) => {
3406
- for (let o of [[1, 1], [-1, 1], [-1, -1], [1, -1]])
3407
- s = new y(
3408
- this.center.x.clone().add(o[0] * n[0]),
3409
- this.center.y.clone().add(o[1] * n[1])
3410
- ), s.isInListOfPoints(i) || i.push(s);
3411
- }), i;
3471
+ r(this, "clone", () => {
3472
+ let e = new O();
3473
+ return this._x !== null && (e.x = this._x.clone()), this._y !== null && (e.y = this._y.clone()), e;
3412
3474
  });
3413
- r(this, "_tangentsThroughOnePointOnTheCircle", (e) => {
3414
- let t = new N(this._center, e);
3415
- return [new A(e, t, ee.Perpendicular)];
3475
+ r(this, "reset", () => (this._x = null, this._y = null, this));
3476
+ // ------------------------------------------
3477
+ // Mathematical operations
3478
+ r(this, "zero", () => (this.reset(), this._x = new h(null), this._y = new h(null), this));
3479
+ r(this, "one", () => (this._x = new h(), this._y = new h(), this));
3480
+ // ------------------------------------------
3481
+ r(this, "opposed", () => (this._x.opposed(), this._y.opposed(), this));
3482
+ r(this, "add", (e) => (this._x.add(e.x), this._y.add(e.y), this));
3483
+ r(this, "subtract", (e) => this.add(e.clone().opposed()));
3484
+ r(this, "scalarProductWithVector", (e) => O.scalarProduct(this, e));
3485
+ r(this, "determinantWithVector", (e) => O.determinant(this, e));
3486
+ r(this, "normal", () => {
3487
+ let e = this.x.clone().opposed(), t = this.y.clone();
3488
+ return this._x = t, this._y = e, this;
3416
3489
  });
3417
- r(this, "_tangentsThroughOnePointOutsideTheCircle", (e) => {
3418
- let t = this.center.x.clone().subtract(e.x), i = this.center.y.clone().subtract(e.y), s = new u("x"), n = new u("x^2+1");
3419
- s.multiply(t).subtract(i).pow(2), n.multiply(this.squareRadius);
3420
- let o = new k(s, n);
3421
- return o.moveLeft().simplify().solve(), o.solutions.map((l) => {
3422
- let a, f = new k("y", "x");
3423
- return l.exact instanceof h ? (a = e.x.clone().opposed().multiply(l.exact).add(e.y), f.right.multiply(l.exact).add(a)) : (a = e.x.clone().opposed().multiply(l.value).add(e.y), f.right.multiply(l.value).add(a)), new A(f);
3424
- });
3490
+ r(this, "isColinearTo", (e) => this.determinantWithVector(e).isZero());
3491
+ r(this, "isNormalTo", (e) => this.scalarProductWithVector(e).isZero());
3492
+ r(this, "multiplyByScalar", (e) => {
3493
+ let t = new h(e);
3494
+ return this._x.multiply(t), this._y.multiply(t), this;
3425
3495
  });
3426
- r(this, "_tangentsWithSlope", (e) => {
3427
- const t = e.numerator, i = -e.denominator, s = this._center.x.clone(), n = this._center.y.clone();
3428
- this._squareRadius;
3429
- let o = this._squareRadius.clone().multiply(e.numerator ** 2 + e.denominator ** 2), l = s.clone().multiply(t).opposed().subtract(n.clone().multiply(i)).add(o.clone().sqrt()), a = s.clone().multiply(t).opposed().subtract(n.clone().multiply(i)).subtract(o.clone().sqrt());
3430
- return [new A(t, i, l), new A(t, i, a)];
3496
+ r(this, "divideByScalar", (e) => this.multiplyByScalar(new h(e).invert()));
3497
+ r(this, "simplify", () => this.multiplyByScalar(x.lcm(this._x.denominator, this._y.denominator)).divideByScalar(x.gcd(this._x.numerator, this._y.numerator)));
3498
+ // ------------------------------------------
3499
+ // Vector functions
3500
+ // ------------------------------------------
3501
+ r(this, "simplifyDirection", () => {
3502
+ let e = x.lcm(this.x.denominator, this.y.denominator), t = x.gcd(this.x.numerator, this.y.numerator);
3503
+ return this.x.multiply(e).divide(t), this.y.multiply(e).divide(t), this;
3431
3504
  });
3432
- this._exists = !1, e !== void 0 && this.parse(...e);
3433
- }
3434
- get center() {
3435
- return this._center;
3436
- }
3437
- get squareRadius() {
3438
- return this._squareRadius;
3439
- }
3440
- get cartesian() {
3441
- return this._cartesian;
3442
- }
3443
- get exists() {
3444
- return this._exists;
3445
- }
3446
- get radius() {
3447
- return this._squareRadius.isSquare() ? {
3448
- tex: this._squareRadius.clone().sqrt().tex,
3449
- display: this._squareRadius.clone().sqrt().display,
3450
- value: this._squareRadius.clone().sqrt().value
3451
- } : {
3452
- tex: `\\sqrt{${this._squareRadius.tex}}`,
3453
- display: `sqrt(${this._squareRadius.display})`,
3454
- value: this._squareRadius.clone().sqrt().value
3455
- };
3456
- }
3457
- get tex() {
3458
- if (this._exists) {
3459
- let e, t;
3460
- return this._center.x.isZero() ? e = "x^2" : e = `\\left(x${this._center.x.isNegative() ? "+" : "-"}${this._center.x.clone().abs().tex}\\right)^2`, this._center.y.isZero() ? t = "y^2" : t = `\\left(y${this._center.y.isNegative() ? "+" : "-"}${this._center.y.clone().abs().tex}\\right)^2`, `${e}+${t}=${this._squareRadius.tex}`;
3461
- } else
3462
- return "\\text{le cercle n'existe pas.}";
3463
- }
3464
- get developed() {
3465
- return this._cartesian.tex;
3466
- }
3467
- get display() {
3468
- if (this._exists) {
3469
- let e, t;
3470
- 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}`;
3471
- } else
3472
- return "\\text{le cercle n'existe pas.}";
3473
- }
3474
- clone() {
3475
- return this._center = this._center.clone(), this._squareRadius = this._squareRadius.clone(), this._calculateCartesian(), this;
3476
- }
3477
- _reset() {
3478
- return this._center = null, this._squareRadius = null, this._cartesian = null, this._exists = !1, this;
3479
- }
3480
- parse(...e) {
3481
- return this._reset(), typeof e[0] == "string" ? this._parseEquation(new k(e[0])) : e[0] instanceof k ? this._parseEquation(e[0]) : e[0] instanceof G ? this._parseCopyCircle(e[0]) : e[0] instanceof y && e.length > 1 && (e[1] instanceof y ? e[2] instanceof y ? this._parseThroughtThreePoints(e[0], e[1], e[2]) : this._parseCenterAndPointThrough(e[0], e[1]) : (e[1] instanceof h || typeof e[1] == "number") && this._parseCenterAndRadius(e[0], e[1], typeof e[2] == "boolean" ? e[2] : !1)), this._exists && (this._calculateCartesian(), this._squareRadius !== void 0 && this._squareRadius.isNegative() && (this._exists = !1)), this;
3482
- }
3483
- _calculateCartesian() {
3484
- this._cartesian = new k(new u(`(x-(${this._center.x.display}))^2+(y-(${this._center.y.display}))^2`), new u(`${this._squareRadius.display}`)).moveLeft();
3485
- }
3486
- _parseCopyCircle(e) {
3487
- return this._center = e.center.clone(), this._squareRadius = e.squareRadius.clone(), this._calculateCartesian(), this._exists = e.exists, this;
3488
- }
3489
- _parseCenterAndRadius(e, t, i) {
3490
- return this._center = e.clone(), i ? this._squareRadius = new h(t) : this._squareRadius = new h(t).pow(2), this._exists = !0, this;
3491
- }
3492
- _parseCenterAndPointThrough(e, t) {
3493
- return this._center = e.clone(), this._squareRadius = new N(this._center, t).normSquare, this._exists = !0, this;
3494
- }
3495
- _parseEquation(e) {
3496
- if (this._exists = !1, e.moveLeft(), e.degree("x").value === 2 && e.degree("y").value === 2) {
3497
- let t = e.left.monomByDegree(2, "x"), i = e.left.monomByDegree(2, "y"), s, n, o;
3498
- t.coefficient.isEqual(i.coefficient) ? (e.divide(t.coefficient), s = e.left.monomByDegree(1, "x"), n = e.left.monomByDegree(1, "y"), o = e.left.monomByDegree(0), this._center = new y(s.coefficient.clone().divide(2).opposed(), n.coefficient.clone().divide(2).opposed()), this._squareRadius = o.coefficient.clone().opposed().add(this._center.x.clone().pow(2)).add(this._center.y.clone().pow(2)), this._calculateCartesian(), this._exists = !0) : (this._center = null, this._squareRadius = null, this._exists = !1);
3499
- }
3500
- return this;
3501
- }
3502
- _parseThroughtThreePoints(e, t, i) {
3503
- let s = new j(e, t, i), n = s.remarquables.mediators.AB.clone(), o = s.remarquables.mediators.AC.clone();
3504
- return this.parse(n.intersection(o).point, e), this;
3505
- }
3506
- }
3507
- class ae extends D {
3508
- constructor(t) {
3509
- super();
3510
- r(this, "generate", () => {
3511
- const t = w.Geometry.point(this._config.center);
3512
- let i, s;
3513
- return this._config.pointsOnCircle === 8 ? (i = w.number(1, 3), s = i ** 2 + (i + 1) ** 2) : s = w.number(1, 20), new G(t, s, !0);
3505
+ r(this, "angleWith", (e, t, i) => {
3506
+ let s = this.scalarProductWithVector(e).value, n = i ? 1 : 180 / Math.PI;
3507
+ return t && (s = Math.abs(s)), n * Math.acos(s / (this.norm * e.norm));
3514
3508
  });
3515
- this._defaultConfig = {}, this._config = this.mergeConfig(t, this._defaultConfig);
3516
- }
3517
- }
3518
- var w;
3519
- ((c) => {
3520
- function e(d) {
3521
- return new se(d).generate();
3509
+ r(this, "_parseString", (e) => {
3510
+ let t = e.split(/[,;\s]/g);
3511
+ return this.x = new h(t[0] || null), this.y = new h(t[1] || null), this;
3512
+ });
3513
+ this._x = new h().zero(), this._y = new h().zero(), e !== void 0 && this.parse(...e);
3522
3514
  }
3523
- c.polynom = e;
3524
- function t(d) {
3525
- return new Q(d).generate();
3515
+ // ------------------------------------------
3516
+ // Getter and setter
3517
+ // ------------------------------------------
3518
+ get x() {
3519
+ return this._x;
3526
3520
  }
3527
- c.monom = t;
3528
- function i(d) {
3529
- return new re(d).generate();
3521
+ set x(e) {
3522
+ this._x = new h(e);
3530
3523
  }
3531
- c.fraction = i;
3532
- function s(d, p, _) {
3533
- return T.randomInt(d, p, _);
3524
+ get y() {
3525
+ return this._y;
3534
3526
  }
3535
- c.number = s;
3536
- function n(d, p) {
3537
- return T.randomIntSym(d, p);
3527
+ set y(e) {
3528
+ this._y = new h(e);
3538
3529
  }
3539
- c.numberSym = n;
3540
- function o(d) {
3541
- return T.randomPrime(d);
3530
+ get normSquare() {
3531
+ return this._x.clone().pow(2).add(this._y.clone().pow(2));
3542
3532
  }
3543
- c.prime = o;
3544
- function l(d) {
3545
- return T.randomBool(d);
3533
+ get norm() {
3534
+ return Math.sqrt(this.normSquare.value);
3546
3535
  }
3547
- c.bool = l;
3548
- function a(d, p) {
3549
- return T.randomArray(d, p);
3536
+ get tex() {
3537
+ return `\\begin{pmatrix}${this._x.tex} \\\\ ${this._y.tex} \\end{pmatrix}`;
3550
3538
  }
3551
- c.array = a;
3552
- function f(d) {
3553
- return T.randomItem(d);
3539
+ get asPoint() {
3540
+ return new y(this.x, this.y);
3554
3541
  }
3555
- c.item = f;
3556
- function m(d) {
3557
- return T.shuffleArray(d);
3542
+ // ------------------------------------------
3543
+ // Creation / parsing functions
3544
+ // ------------------------------------------
3545
+ get isNull() {
3546
+ return this.x.isZero() && this.y.isZero();
3558
3547
  }
3559
- c.shuffle = m, ((d) => {
3560
- function p(v) {
3561
- return new oe(v).generate();
3562
- }
3563
- d.line = p;
3564
- function _(v) {
3565
- return new le(v).generate();
3566
- }
3567
- d.point = _;
3568
- function q(v) {
3569
- return new ae(v).generate();
3570
- }
3571
- d.circle = q;
3572
- })(c.Geometry || (c.Geometry = {}));
3573
- })(w || (w = {}));
3574
- class Y {
3548
+ };
3549
+ r(O, "scalarProduct", (e, t) => e.x.clone().multiply(t.x).add(e.y.clone().multiply(t.y))), r(O, "determinant", (e, t) => e.x.clone().multiply(t.y).subtract(e.y.clone().multiply(t.x)));
3550
+ let N = O;
3551
+ var ee = /* @__PURE__ */ ((c) => (c[c.None = 0] = "None", c.Parallel = "parallel", c.Perpendicular = "perpendicular", c.Tangent = "tangent", c))(ee || {});
3552
+ const z = class z {
3553
+ /**
3554
+ * Value can be a mix of:
3555
+ *
3556
+ * @param values
3557
+ */
3575
3558
  constructor(...e) {
3576
- // Stores the original equations
3577
- r(this, "_equations");
3578
- // Determine the letters in the linear system, usually ['x', 'y']
3579
- r(this, "_letters");
3580
- // Resolution steps contains each steps
3581
- // letter : target letter
3582
- // steps: {system: current LinearSystem, operations: [*3,/5] or [[*3,*2], [,*5], [*2,]]}
3583
- r(this, "_resolutionSteps");
3584
- // Get the solution of the equation
3585
- r(this, "_solutions");
3586
- r(this, "buildTex", (e, t) => {
3587
- let i, s = [], n, o = [];
3588
- for (let a of e)
3589
- o = o.concat(a.letters());
3590
- o = [...new Set(o)], o.sort();
3591
- for (let a = 0; a < e.length; a++) {
3592
- let f = e[a];
3593
- i = [];
3594
- for (let m of o)
3595
- n = f.left.monomByLetter(m), i.length === 0 ? i.push(n.isZero() ? "" : n.tex) : i.push(n.isZero() ? "" : (n.coefficient.sign() === 1 ? "+" : "") + n.tex);
3596
- if (i.push("="), i.push(f.right.tex), t !== void 0 && t[a] !== void 0) {
3597
- i[i.length - 1] = i[i.length - 1] + " \\phantom{\\quad}";
3598
- for (let m of t[a])
3599
- i.push(`\\ \\cdot\\ ${m.startsWith("-") ? "\\left(" + m + "\\right)" : m}`);
3600
- }
3601
- s.push(i.join("&"));
3602
- }
3603
- let l = 0;
3604
- return t !== void 0 && t.length > 0 && (l = t[0].length), `\\left\\{\\begin{array}{${"r".repeat(o.length)}cl ${"|l".repeat(l)}}${s.join("\\\\ ")}\\end{array}\\right.`;
3605
- });
3606
- r(this, "stepTex", (e) => {
3607
- const t = this._resolutionSteps[e];
3608
- if (t === void 0)
3609
- return "";
3610
- let i = [];
3611
- for (let s = 0; s < t.length; s++)
3612
- i.push(this.buildTex(t[s].equations, t[s].operations));
3613
- return `\\begin{aligned}&${i.join("\\\\&")}\\end{aligned}`;
3559
+ r(this, "_referencePropriety");
3560
+ r(this, "_referenceLine");
3561
+ r(this, "_reduceBeforeDisplay");
3562
+ // ax + by + c = 0
3563
+ r(this, "_a");
3564
+ r(this, "_b");
3565
+ r(this, "_c");
3566
+ r(this, "_OA");
3567
+ r(this, "_d");
3568
+ r(this, "_n");
3569
+ r(this, "_exists");
3570
+ r(this, "randomPoint", (e) => this._d.clone().multiplyByScalar(w.numberSym(e === void 0 || e <= 1 ? 3 : e, !1)).add(this._OA.asVector).asPoint);
3571
+ r(this, "randomNearPoint", (e) => {
3572
+ let t = this.randomPoint(e), i = 10;
3573
+ for (; this.isOnLine(t) && i > 0; )
3574
+ t.x.add(w.numberSym(1, !1)), t.y.add(w.numberSym(1, !1)), i--;
3575
+ return t;
3614
3576
  });
3615
3577
  // ------------------------------------------
3616
3578
  // Creation / parsing functions
3617
3579
  // ------------------------------------------
3618
- r(this, "parse", (...e) => (this._equations = e.map((t) => new k(t)), this._findLetters(), this));
3619
- r(this, "clone", () => new Y().parse(...this._equations.map((e) => e.clone())));
3580
+ /**
3581
+ * Parse data to a line
3582
+ * @param {any} values
3583
+ * @returns {Line}
3584
+ */
3585
+ r(this, "parse", (...e) => {
3586
+ if (this._exists = !1, e.length === 0)
3587
+ return this;
3588
+ if (e.length === 1) {
3589
+ if (e[0] instanceof z)
3590
+ return e[0].clone();
3591
+ if (e[0] instanceof k)
3592
+ return this.parseEquation(e[0]);
3593
+ if (typeof e[0] == "string")
3594
+ try {
3595
+ let t = new k(e[0]);
3596
+ return this.parse(t);
3597
+ } catch {
3598
+ return this;
3599
+ }
3600
+ }
3601
+ if (e.length === 2) {
3602
+ if (e[0] instanceof y && e[1] instanceof N)
3603
+ return this.parseByPointAndVector(e[0], e[1]);
3604
+ if (e[0] instanceof y && e[1] instanceof y)
3605
+ return this.parseByPointAndVector(e[0], new N(e[0], e[1]));
3606
+ if (e[0] instanceof N && e[1] instanceof y)
3607
+ return this.parseByPointAndNormal(e[1], e[0]);
3608
+ }
3609
+ if (e.length === 3) {
3610
+ if ((e[0] instanceof h || typeof e[0] == "number") && (e[1] instanceof h || typeof e[1] == "number") && (e[2] instanceof h || typeof e[2] == "number"))
3611
+ return this.parseByCoefficient(e[0], e[1], e[2]);
3612
+ if (e[0] instanceof y && e[1] instanceof N) {
3613
+ if (e[2] === "perpendicular")
3614
+ return this.parseByPointAndNormal(e[0], e[1]);
3615
+ if (e[2] === "parallel")
3616
+ return this.parseByPointAndVector(e[0], e[1]);
3617
+ } else if (e[0] instanceof y && e[1] instanceof z)
3618
+ return e[2] === "parallel" || e[2] === null ? this.parseByPointAndLine(
3619
+ e[0],
3620
+ e[1],
3621
+ "parallel"
3622
+ /* Parallel */
3623
+ ) : this.parseByPointAndLine(
3624
+ e[0],
3625
+ e[1],
3626
+ "perpendicular"
3627
+ /* Perpendicular */
3628
+ );
3629
+ }
3630
+ return console.log("Someting wrong happend while creating the line"), this;
3631
+ });
3632
+ r(this, "parseEquation", (e) => {
3633
+ e.reorder(!0);
3634
+ let t = new Set(e.letters());
3635
+ if (!(t.has("x") || t.has("y")))
3636
+ return this;
3637
+ for (let i of ["x", "y"])
3638
+ t.has(i) && t.delete(i);
3639
+ return t.size > 0 ? this : this.parseByCoefficient(e.left.monomByLetter("x").coefficient, e.left.monomByLetter("y").coefficient, e.left.monomByDegree(0).coefficient);
3640
+ });
3641
+ r(this, "parseByCoefficient", (e, t, i) => (this._a = new h(e), this._b = new h(t), this._c = new h(i), this._d = new N(this._b.clone(), this._a.clone().opposed()), this._OA = new y(new h().zero(), this._c.clone()), this._n = this._d.clone().normal(), this._exists = !0, this));
3642
+ r(this, "parseByPointAndVector", (e, t) => (this.parseByCoefficient(
3643
+ t.y,
3644
+ t.x.clone().opposed(),
3645
+ e.x.clone().multiply(t.y).subtract(e.y.clone().multiply(t.x)).opposed()
3646
+ ), this._OA = e.clone(), this._d = t.clone(), this._n = this._d.clone().normal(), this._exists = !0, this));
3647
+ r(this, "parseByPointAndNormal", (e, t) => this.parseByCoefficient(
3648
+ t.x,
3649
+ t.y,
3650
+ e.x.clone().multiply(t.x).add(e.y.clone().multiply(t.y)).opposed()
3651
+ ));
3652
+ r(this, "parseByPointAndLine", (e, t, i) => (i === void 0 && (i = "parallel"), i === "parallel" ? this.parseByPointAndNormal(e, t.normal) : i === "perpendicular" ? this.parseByPointAndNormal(e, t.director) : (this._exists = !1, this)));
3653
+ r(this, "clone", () => (this._a = this._a.clone(), this._b = this._b.clone(), this._c = this._c.clone(), this._d = this._d.clone(), this._OA = this._OA.clone(), this._n = this._n.clone(), this._exists = this.exists, this));
3620
3654
  // ------------------------------------------
3621
- r(this, "reorder", () => {
3622
- for (let e of this._equations)
3623
- e.reorder();
3624
- return this;
3655
+ // Mathematical operations
3656
+ // ------------------------------------------
3657
+ r(this, "isOnLine", (e) => this._a.clone().multiply(e.x).add(
3658
+ this._b.clone().multiply(e.y)
3659
+ ).add(this._c).isZero());
3660
+ r(this, "isParallelTo", (e) => this.slope.isEqual(e.slope) && this.height.isNotEqual(e.height));
3661
+ r(this, "isSameAs", (e) => this.slope.isEqual(e.slope) && this.height.isEqual(e.height));
3662
+ r(this, "isPerpendicularTo", (e) => this.d.isNormalTo(e.d));
3663
+ r(this, "isVertical", () => this.slope.isInfinity());
3664
+ r(this, "simplify", () => {
3665
+ let e = x.lcm(this._a.denominator, this._b.denominator, this._c.denominator), t = x.gcd(this._a.numerator, this._b.numerator, this._c.numerator);
3666
+ return this.parseByCoefficient(
3667
+ this._a.clone().multiply(e).divide(t),
3668
+ this._b.clone().multiply(e).divide(t),
3669
+ this._c.clone().multiply(e).divide(t)
3670
+ ), this;
3625
3671
  });
3626
- // -----------------------------------------------
3627
- // Equations solving algorithms
3628
- r(this, "solve", (e) => {
3629
- this._solutions = {}, this._resolutionSteps = {}, this.reorder(), e === void 0 && (e = !1);
3630
- for (let t of this.variables)
3631
- this._solutions[t] = this._solveOneLetter(t, e);
3632
- return this;
3672
+ r(this, "simplifyDirection", () => (this._d.simplifyDirection(), this));
3673
+ r(this, "intersection", (e) => {
3674
+ let t = new y(), i = !1, s = !1;
3675
+ return this._b.isZero() || e.b.isZero(), this.isParallelTo(e) ? (t.x = null, t.y = null, i = !0) : this.isSameAs(e) ? (t.x = null, t.y = null, s = !0) : (t.x = this._b.clone().multiply(e.c).subtract(this._c.clone().multiply(e.b)).divide(this._a.clone().multiply(e.b).subtract(this._b.clone().multiply(e.a))), t.y = this._a.clone().multiply(e.c).subtract(this._c.clone().multiply(e.a)).divide(this._b.clone().multiply(e.a).subtract(this._a.clone().multiply(e.b)))), {
3676
+ point: t,
3677
+ hasIntersection: !(i || s),
3678
+ isParallel: i,
3679
+ isSame: s
3680
+ };
3633
3681
  });
3634
- r(this, "mergeEquations", (e, t, i, s) => {
3635
- let n = e.clone().multiply(new h(i)), o = t.clone().multiply(new h(s));
3636
- return n.left.add(o.left), n.right.add(o.right), n;
3682
+ r(this, "getValueAtX", (e) => {
3683
+ const t = this.equation.clone().isolate("y"), i = new h(e);
3684
+ if (t instanceof k)
3685
+ return t.right.evaluate({ x: i });
3637
3686
  });
3638
- r(this, "_findLetters", () => {
3639
- let e = /* @__PURE__ */ new Set();
3640
- for (let t of this._equations)
3641
- e = /* @__PURE__ */ new Set([...e, ...t.variables]);
3642
- return this._letters = [...e], this._letters.sort(), this;
3687
+ r(this, "getValueAtY", (e) => {
3688
+ const t = this.equation.clone().isolate("x"), i = new h(e);
3689
+ if (t instanceof k)
3690
+ return t.right.evaluate({ y: i });
3643
3691
  });
3644
- return this._equations = [], this._letters = "xyz".split(""), e !== void 0 && e.length > 0 && this.parse(...e), this;
3692
+ return this._exists = !1, this._reduceBeforeDisplay = !0, e.length > 0 && this.parse(...e), this;
3693
+ }
3694
+ get a() {
3695
+ return this._a;
3645
3696
  }
3646
3697
  // ------------------------------------------
3647
3698
  // Getter and setter
3648
- // ------------------------------------------
3649
- get equations() {
3650
- return this._equations;
3651
- }
3652
- set equations(e) {
3653
- this._equations = e;
3699
+ set a(e) {
3700
+ this._a = e;
3654
3701
  }
3655
- get letters() {
3656
- return this._letters.join("");
3702
+ get b() {
3703
+ return this._b;
3657
3704
  }
3658
- set letters(e) {
3659
- this._letters = e.split("");
3705
+ set b(e) {
3706
+ this._b = e;
3660
3707
  }
3661
- get isSolvable() {
3662
- return this.variables.length === this._equations.length;
3708
+ get c() {
3709
+ return this._c;
3663
3710
  }
3664
- get variables() {
3665
- return this._letters;
3711
+ set c(e) {
3712
+ this._c = e;
3666
3713
  }
3667
- get tex() {
3668
- let e = this.clone().reorder();
3669
- return e.variables, this.buildTex(e.equations);
3714
+ get OA() {
3715
+ return this._OA;
3670
3716
  }
3671
- get solution() {
3672
- let e = [];
3673
- this._solutions === void 0 && this.solve();
3674
- for (let t in this._solutions) {
3675
- if (this._solutions[t].display === "RR")
3676
- return `\\left\\{ \\left(${this._letters.join(";")}\\right) \\big\\vert ${this.equations[0].tex} \\right\\}`;
3677
- if (this._solutions[t].display === "O/")
3678
- return "\\varnothing";
3679
- e.push(this._solutions[t].tex);
3680
- }
3681
- return `\\left(${e.join(";")}\\right)`;
3717
+ set OA(e) {
3718
+ this._OA = e;
3682
3719
  }
3683
- get solutionAsDisplay() {
3684
- let e = [];
3685
- this._solutions === void 0 && this.solve();
3686
- for (let t in this._solutions) {
3687
- if (this._solutions[t].display === "RR")
3688
- return `{(${this._letters.join(";")}) | ${this.equations[0].display} }`;
3689
- if (this._solutions[t].display === "O/")
3690
- return "O/";
3691
- e.push(this._solutions[t].display);
3692
- }
3693
- return `(${e.join(";")})`;
3720
+ get d() {
3721
+ return this._d;
3694
3722
  }
3695
- get resolutionSteps() {
3696
- return this._resolutionSteps;
3723
+ set d(e) {
3724
+ this._d = e;
3697
3725
  }
3698
- _linearReduction(e, t, i) {
3699
- let s = e.left.monomByDegree(1, i).coefficient.clone(), n = t.left.monomByDegree(1, i).coefficient.clone().opposed();
3700
- const o = x.gcd(s.numerator, n.numerator), l = x.gcd(s.denominator, n.denominator);
3701
- return s.divide(o).multiply(l), n.divide(o).multiply(l), (n.isNegativeOne() || s.isNegativeOne()) && (s.opposed(), n.opposed()), {
3702
- merged: this.mergeEquations(e, t, n, s),
3703
- factors: [n, s]
3704
- };
3726
+ get n() {
3727
+ return this._n;
3705
3728
  }
3706
- /**
3707
- * Linear reduction of the equations to have only one letter
3708
- * @param letter letter to isolate
3709
- * @private
3710
- */
3711
- _solveOneLetter(e, t) {
3712
- let i = this.clone().equations, s = [], n;
3713
- this._resolutionSteps[e] = [];
3714
- for (let a of this.variables)
3715
- if (s = [], a !== e) {
3716
- t && (this._resolutionSteps[e].push({
3717
- equations: i.map((f) => f.clone()),
3718
- operations: [...new Array(i.length)].map((f) => [...new Array(i.length - 1)].map((m) => ""))
3719
- }), n = this._resolutionSteps[e].length - 1);
3720
- for (let f = 0; f < i.length - 1; f++) {
3721
- const m = this._linearReduction(i[f], i[f + 1], a);
3722
- s.push(m.merged), t && (this._resolutionSteps[e][n].operations[f][f] = m.factors[0].tex, this._resolutionSteps[e][n].operations[f + 1][f] = m.factors[1].tex);
3723
- }
3724
- i = [...s];
3725
- }
3726
- let o = i[0];
3727
- o.solve();
3728
- const l = o.solutions[0];
3729
- if (t) {
3730
- this._resolutionSteps[e].push({
3731
- equations: [i[0]],
3732
- operations: [[i[0].left.monoms[0].coefficient.tex]]
3733
- });
3734
- let a;
3735
- l.exact instanceof h || typeof l.exact == "string" ? a = new u(l.exact) : a = new u(l.value), this._resolutionSteps[e].push({
3736
- equations: [new k(new u(e), a)],
3737
- operations: []
3738
- });
3739
- }
3740
- return o.solutions[0];
3729
+ get exists() {
3730
+ return this._exists;
3741
3731
  }
3742
- }
3743
- var L = /* @__PURE__ */ ((c) => (c.ZERO = "z", c.DEFENCE = "d", c.NOTHING = "t", c))(L || {}), M = /* @__PURE__ */ ((c) => (c.VERTICAL = "av", c.HORIZONTAL = "ah", c.SLOPE = "ao", c.HOLE = "hole", c))(M || {}), E = /* @__PURE__ */ ((c) => (c.LT = "LT", c.RT = "RT", c.LB = "LB", c.RB = "RB", c))(E || {}), H = /* @__PURE__ */ ((c) => (c.MIN = "min", c.MAX = "max", c.FLAT = "flat", c.NOTHING = "", c))(H || {}), W = /* @__PURE__ */ ((c) => (c.SIGNS = "signs", c.GROWS = "grows", c.VARIATIONS = "variatins", c))(W || {});
3744
- class he {
3745
- constructor(e, t) {
3746
- r(this, "fx");
3747
- r(this, "_asymptotes");
3748
- r(this, "_derivative");
3749
- r(this, "_signs");
3750
- r(this, "_variations");
3751
- r(this, "_zeroes");
3752
- r(this, "_config");
3753
- r(this, "_name");
3754
- r(this, "makeStudy", () => {
3755
- this._zeroes = this.makeZeroes(), this._config.signs && (this._signs = this.makeSigns()), this._config.asymptotes && (this._asymptotes = this.makeAsymptotes()), this._config.derivative && (this._derivative = this.makeDerivative()), this._config.variations && (this._variations = this.makeVariation()), this._config.signs && (this._signs.tex = this.texSigns), this._config.derivative && (this._derivative.tex = this.texGrows), this._config.variations && (this._variations.tex = this.texVariations);
3756
- });
3757
- r(this, "indexOfZero", (e, t) => {
3758
- for (let i = 0; i < e.length; i++)
3759
- if (e[i].tex === t.tex)
3760
- return i;
3761
- return -1;
3762
- });
3763
- r(this, "makeOneLineForSigns", (e, t, i) => {
3764
- let s = [], n = e.getZeroes().map((o) => o.tex);
3765
- s.push(""), e.degree().isZero() ? s.push(e.monoms[0].coefficient.sign() === 1 ? "+" : "-") : s.push(e.evaluate(t[0].value - 1).sign() === 1 ? "+" : "-");
3766
- for (let o = 0; o < t.length; o++)
3767
- s.push(
3768
- n.includes(t[o].tex) ? i : "t"
3769
- /* NOTHING */
3770
- ), o < t.length - 1 ? s.push(e.evaluate((t[o].value + t[o + 1].value) / 2).sign() === 1 ? "+" : "-") : o === t.length - 1 && s.push(e.evaluate(t[o].value + 1).sign() === 1 ? "+" : "-");
3771
- return s.push(""), s;
3772
- });
3773
- r(this, "makeSignsResult", (e) => {
3774
- let t = e[0].map((i, s) => s === 0 || s === e[0].length - 1 ? "" : s % 2 === 0 ? "t" : "+");
3775
- for (let i of e)
3776
- for (let s = 0; s < i.length; s++)
3777
- if (s % 2 === 0) {
3778
- if (t[s] === "d")
3779
- continue;
3780
- i[s] !== "t" && (t[s] = i[s]);
3781
- } else
3782
- i[s] === "-" && (t[s] = t[s] === "+" ? "-" : "+");
3783
- return t;
3784
- });
3785
- r(this, "makeGrowsResult", (e) => {
3786
- let t = Object.values(e.signs), i = t[t.length - 1], s = [], n = {}, o = e.zeroes;
3787
- for (let l = 0; l < o.length; l++) {
3788
- let a = 2 * l + 2;
3789
- if (i[a] === "z") {
3790
- let f, m, d = o[l].exact, p, _, q, v = new K(this.fx.plotFunction);
3791
- if (d instanceof h) {
3792
- let B = d, S = this.fx.evaluate(B);
3793
- f = d.value, m = S.value, p = d.tex, _ = S.tex;
3794
- } else
3795
- f = o[l].value, m = v.evaluate({ x: f }), p = f.toFixed(2), _ = m.toFixed(2);
3796
- i[a - 1] === i[a + 1] ? q = "flat" : i[a - 1] === "+" ? q = "max" : q = "min", n[o[l].tex] = {
3797
- type: q,
3798
- tex: { x: p, y: _ },
3799
- value: { x: f, y: m }
3800
- };
3801
- }
3802
- }
3803
- s.push(i[1] === "+" ? "-/" : "+/");
3804
- for (let l = 1; l < i.length - 1; l++)
3805
- if (i[l] === "z") {
3806
- let a = n[o[(l - 2) / 2].tex];
3807
- s.push(`${i[l - 1]}/\\(${a.type}(${a.tex.x};${a.tex.y})\\)`);
3808
- } else
3809
- i[l] === "d" && s.push(`${i[l - 1]}D${i[l + 1] === "+" ? "-" : "+"}/`);
3810
- return s.push(`${i[i.length - 2]}/`), { growsLine: s, extremes: n };
3811
- });
3812
- r(this, "makeVariationsResult", (e) => ({ varsLine: [], extremes: {} }));
3813
- r(this, "drawCode", () => {
3814
- let e = `f(x)=${this.fx.plotFunction}`, t = 1;
3815
- this.asymptotes.forEach((i) => {
3816
- i.type === "av" ? (e += `
3817
- av_${t}=line x=${i.zero.value}->red,dash`, t++) : i.type === "ah" ? e += `
3818
- ah=line y=${i.fx.monoms[0].coefficient.value}->orange,dash` : i.type === "ao" && (e += `
3819
- ao=line y=${i.fx.plotFunction}->red,dash`), t++;
3820
- });
3821
- for (let i in this.derivative.extremes) {
3822
- let s = this.derivative.extremes[i];
3823
- e += `
3824
- M_${t}(${s.value.x},${s.value.y})*`, t++;
3825
- }
3826
- return this.zeroes.forEach((i) => {
3827
- i.type === "z" && (e += `
3828
- Z_${t}(${i.value},0)*`, t++);
3829
- }), e;
3830
- });
3831
- r(this, "_makeTexFromTableOfSigns", (e) => {
3832
- let t = e.factors.map((l) => `\\(${l.tex}\\)/1`), i = `\\(${this._config.name}(${this._config.variable})\\)/1.2`, s = e.zeroes;
3833
- e.type === "grows" ? i = `\\(${this._config.name}'(${this._config.variable})\\)/1.2,\\(f(x${this._config.variable})\\)/2` : e.type === "variatins" && (i = `\\(${this._config.name}''(${this._config.variable})\\)/1.2,\\(f(${this._config.variable})\\)/2`);
3834
- let n = `\\begin{tikzpicture}
3835
- \\tkzTabInit[lgt=3,espcl=2,deltacl=0]{/1.2,${t.join(",")},/.1,${i} }{{\\scriptsize \\hspace{1cm} \\(-\\infty\\)},\\(${s.map((l) => l.tex).join("\\),\\(")}\\),{\\scriptsize \\hspace{-1cm} \\(+\\infty\\)}}`, o;
3836
- for (o = 0; o < e.factors.length; o++)
3837
- n += `
3838
- \\tkzTabLine{${e.signs[o].join(",")}}`;
3839
- return n += `
3840
- \\tkzTabLine{${e.signs[o].join(",")}}`, e.type === "grows" ? n += `
3841
- \\tkzTabVar{${e.signs[o + 1].join(",")}}` : e.type === "variatins" && (n += `
3842
- \\tkzTabVar{${e.signs[o + 1].join(",")}}`), n += `
3843
- \\end{tikzpicture}`, n;
3844
- });
3845
- if (this.fx = e, this._config = {
3846
- name: "f",
3847
- variable: "x",
3848
- domain: !0,
3849
- asymptotes: !0,
3850
- signs: !0,
3851
- derivative: !0,
3852
- variations: !0
3853
- }, t)
3854
- if (typeof t == "string") {
3855
- const i = t.split(",");
3856
- this._config = {};
3857
- let s = i.filter((n) => n.includes("(") && n.includes(")"));
3858
- s.length === 1 && (this._config.name = s[0].split("(")[0], this._config.variable = s[0].split("(")[1].split(")")[0]), this._config.domain = i.includes("d"), this._config.asymptotes = i.includes("a"), this._config.signs = i.includes("signs"), this._config.derivative = i.includes("dx"), this._config.variations = i.includes("ddx");
3859
- } else
3860
- this._config = t;
3861
- return this.makeStudy(), this;
3732
+ // ------------------------------------------
3733
+ get equation() {
3734
+ let e = new k(new u().parse("xy", this._a, this._b, this._c), new u("0"));
3735
+ return this._reduceBeforeDisplay ? e.simplify() : e;
3862
3736
  }
3863
- get name() {
3864
- return this._config.name;
3737
+ get system() {
3738
+ let e = new k(
3739
+ new u("x"),
3740
+ new u(this._OA.x).add(new g("k").multiplyByNumber(this._d.x))
3741
+ ), t = new k(
3742
+ new u("y"),
3743
+ new u(this._OA.y).add(new g("k").multiplyByNumber(this._d.y))
3744
+ );
3745
+ return { x: e, y: t };
3865
3746
  }
3866
- set name(e) {
3867
- this._config.name = e;
3747
+ get tex() {
3748
+ let e = this.equation.clone().reorder(!0);
3749
+ this._a.isNegative() && e.multiply(-1);
3750
+ let t = this._d.clone();
3751
+ return this._reduceBeforeDisplay && t.simplifyDirection(), {
3752
+ canonical: e.tex,
3753
+ equation: e.clone().reorder().tex,
3754
+ mxh: this.slope.isInfinity() ? "x=" + this.OA.x.tex : "y=" + new u().parse("x", this.slope, this.height).tex,
3755
+ parametric: `${y.pmatrix("x", "y")} = ${y.pmatrix(this._OA.x, this._OA.y)} + k\\cdot ${y.pmatrix(t.x, t.y)}`,
3756
+ system: `\\left\\{\\begin{aligned}
3757
+ x &= ${new u(this._OA.x).add(new g(this._d.x).multiply(new g("k"))).reorder("k", !0).tex}\\\\
3758
+ y &= ${new u(this._OA.y).add(new g(this._d.y).multiply(new g("k"))).reorder("k", !0).tex}
3759
+ \\end{aligned}\\right.`
3760
+ };
3868
3761
  }
3869
- get config() {
3870
- return this._config;
3762
+ get reduceBeforeDisplay() {
3763
+ return this._reduceBeforeDisplay;
3871
3764
  }
3872
- set config(e) {
3873
- this._config = e;
3765
+ set reduceBeforeDisplay(e) {
3766
+ this._reduceBeforeDisplay = e;
3767
+ }
3768
+ get display() {
3769
+ let e = this.equation;
3770
+ return this._a.isNegative() && e.multiply(-1), {
3771
+ canonical: e.display,
3772
+ mxh: this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new u().parse("x", this.slope, this.height).display,
3773
+ parametric: ""
3774
+ };
3874
3775
  }
3875
- get zeroes() {
3876
- return this._zeroes;
3776
+ get normal() {
3777
+ return new N(this._a, this._b);
3877
3778
  }
3878
- get domain() {
3879
- return this.fx.domain();
3779
+ get director() {
3780
+ return this._d.clone();
3880
3781
  }
3881
- get signs() {
3882
- return this._signs;
3782
+ get slope() {
3783
+ return this._a.clone().opposed().divide(this._b);
3883
3784
  }
3884
- get asymptotes() {
3885
- return this._asymptotes;
3785
+ get height() {
3786
+ return this._c.clone().opposed().divide(this._b);
3886
3787
  }
3887
- get derivative() {
3888
- return this._derivative;
3788
+ distanceTo(e) {
3789
+ let t = e.x.clone().multiply(this._a).add(e.y.clone().multiply(this._b)).add(this._c).abs(), i = this.normal.normSquare;
3790
+ if (i.isZero())
3791
+ return {
3792
+ value: NaN,
3793
+ tex: "Not a line",
3794
+ fraction: new h().infinite()
3795
+ };
3796
+ let s = t.value / Math.sqrt(i.value), n = t.clone().divide(i.clone().sqrt());
3797
+ return i.isSquare() ? {
3798
+ value: s,
3799
+ tex: n.tex,
3800
+ fraction: n
3801
+ } : {
3802
+ value: s,
3803
+ tex: `\\frac{${t.tex}}{\\sqrt{${i.tex}}}`,
3804
+ fraction: n
3805
+ };
3889
3806
  }
3890
- get texSigns() {
3891
- return this._makeTexFromTableOfSigns(this._signs);
3807
+ hitSegment(e, t) {
3808
+ let i = this.intersection(
3809
+ new z(e, t)
3810
+ );
3811
+ 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;
3892
3812
  }
3893
- get texGrows() {
3894
- return this._makeTexFromTableOfSigns(this._derivative);
3813
+ // ------------------------------------------
3814
+ // Special functions
3815
+ // ------------------------------------------
3816
+ canonicalAsFloatCoefficient(e) {
3817
+ e === void 0 && (e = 2), this._a.value, this._b.value, this._c.value;
3818
+ let t = "";
3819
+ return this._a.isZero() || (this._a.isOne() ? t = "x" : this._a.clone().opposed().isOne() ? t = "-x" : t = this._a.value.toFixed(e) + "x"), this._b.isZero() || (this._b.isPositive() && (t += "+"), t += this._b.value.toFixed(e) + "y"), this._c.isZero() || (this._c.isPositive() && (t += "+"), t += this._c.value.toFixed(e)), t + "=0";
3895
3820
  }
3896
- get texVariations() {
3897
- return this._makeTexFromTableOfSigns(this._variations);
3821
+ };
3822
+ // A line is defined as the canonical form
3823
+ r(z, "PERPENDICULAR", "perpendicular"), r(z, "PARALLEL", "parallel");
3824
+ let A = z;
3825
+ class he extends D {
3826
+ constructor(t) {
3827
+ super();
3828
+ r(this, "generate", () => {
3829
+ const t = new N(
3830
+ w.numberSym(10),
3831
+ w.numberSym(10)
3832
+ );
3833
+ for (; t.isNull; )
3834
+ t.x = w.numberSym(10), t.y = w.numberSym(10);
3835
+ return this._config.slope === 1 ? t.x.sign() !== t.y.sign() && t.y.opposed() : this._config.slope === -1 && t.x.sign() !== t.y.sign() && t.y.opposed(), new A(new y(this._config.A.x, this._config.A.y), t);
3836
+ });
3837
+ this._defaultConfig = {
3838
+ A: {
3839
+ x: w.numberSym(10),
3840
+ y: w.numberSym(10)
3841
+ }
3842
+ }, this._config = this.mergeConfig(t, this._defaultConfig);
3898
3843
  }
3899
- makeZeroes() {
3900
- return [];
3844
+ }
3845
+ class ce extends D {
3846
+ constructor(t) {
3847
+ super();
3848
+ r(this, "generate", () => {
3849
+ let t, i, s = this._config.axis === !0 || this._config.axis === "x", n = this._config.axis === !0 || this._config.axis === "y";
3850
+ return t = this._config.fraction ? w.fraction({ max: this._config.max, zero: s }) : new h(w.numberSym(this._config.max, s)), i = this._config.fraction ? w.fraction({ max: this._config.max, zero: n }) : new h(w.numberSym(this._config.max, n)), +this._config.quadrant == 1 && (t.abs(), i.abs()), +this._config.quadrant == 2 && (t.isPositive() && t.opposed(), i.isNegative() && i.opposed()), +this._config.quadrant == 3 && (t.isPositive() && t.opposed(), i.isPositive() && i.opposed()), +this._config.quadrant == 4 && (t.isNegative() && t.opposed(), i.isPositive() && i.opposed()), new y(t, i);
3851
+ });
3852
+ this._defaultConfig = {
3853
+ axis: !0,
3854
+ fraction: !1,
3855
+ max: 10
3856
+ }, this._config = this.mergeConfig(t, this._defaultConfig);
3901
3857
  }
3902
- makeSigns() {
3903
- return {
3904
- type: "signs",
3905
- fx: null,
3906
- factors: [],
3907
- zeroes: [],
3908
- signs: [],
3909
- extremes: {},
3910
- tex: ""
3911
- };
3858
+ }
3859
+ class j {
3860
+ constructor(...e) {
3861
+ r(this, "_A");
3862
+ r(this, "_B");
3863
+ r(this, "_C");
3864
+ r(this, "_lines");
3865
+ r(this, "_middles");
3866
+ r(this, "_remarquables");
3867
+ // ------------------------------------------
3868
+ // Creation / parsing functions
3869
+ // ------------------------------------------
3870
+ /**
3871
+ * Parse values to a triangle. Supported formats:
3872
+ * Point, Point, Point
3873
+ * x1, y1, x2, y2, x3, y3
3874
+ * TODO: Something else ?
3875
+ * @param values
3876
+ */
3877
+ r(this, "parse", (...e) => {
3878
+ if (e.length === 6) {
3879
+ let t = e.map((i) => new h(i));
3880
+ return this.parse(
3881
+ new y(t[0], t[1]),
3882
+ new y(t[2], t[3]),
3883
+ new y(t[4], t[5])
3884
+ );
3885
+ } else if (e.length === 3) {
3886
+ if (e.filter((t) => typeof t == "string").length === 3)
3887
+ return this.parse(...e.map((t) => new A(t)));
3888
+ if (e.filter((t) => t instanceof A).length === 3) {
3889
+ this._lines = {
3890
+ AB: e[0],
3891
+ BC: e[1],
3892
+ AC: e[2]
3893
+ };
3894
+ let t = e[0].intersection(e[1]);
3895
+ if (t.hasIntersection)
3896
+ this._B = t.point.clone();
3897
+ else
3898
+ return this;
3899
+ if (t = e[1].intersection(e[2]), t.hasIntersection)
3900
+ this._C = t.point.clone();
3901
+ else
3902
+ return this;
3903
+ if (t = e[2].intersection(e[0]), t.hasIntersection)
3904
+ this._A = t.point.clone();
3905
+ else
3906
+ return this;
3907
+ } else {
3908
+ if (e.filter((t) => t instanceof y).length < 3)
3909
+ return this.parse(
3910
+ new y(e[0]),
3911
+ new y(e[1]),
3912
+ new y(e[2])
3913
+ );
3914
+ this._A = e[0].clone(), this._B = e[1].clone(), this._C = e[2].clone(), this._lines = {
3915
+ AB: new A(this._A, this._B),
3916
+ BC: new A(this._B, this._C),
3917
+ AC: new A(this._A, this._C)
3918
+ };
3919
+ }
3920
+ } else if (e.length === 1 && e[0] instanceof j)
3921
+ return e[0].clone();
3922
+ return this._updateTriangle(), this;
3923
+ });
3924
+ /**
3925
+ * Clone the Triangle class
3926
+ */
3927
+ r(this, "clone", () => (this._A = this._A.clone(), this._B = this._B.clone(), this._C = this._C.clone(), this._lines = {
3928
+ AB: this._lines.AB.clone(),
3929
+ BC: this._lines.BC.clone(),
3930
+ AC: this._lines.AC.clone()
3931
+ }, this._updateTriangle(), this));
3932
+ // ------------------------------------------
3933
+ // Triangle operations and properties
3934
+ // ------------------------------------------
3935
+ /**
3936
+ * Generate the Line object for the three segments of the triangle
3937
+ */
3938
+ r(this, "_updateTriangle", () => {
3939
+ this._middles = {
3940
+ AB: new y().middleOf(this._A, this._B),
3941
+ AC: new y().middleOf(this._A, this._C),
3942
+ BC: new y().middleOf(this._B, this._C)
3943
+ }, this._remarquables = this._calculateRemarquableLines();
3944
+ });
3945
+ /**
3946
+ * Get the Point class for the given name
3947
+ * @param ptName
3948
+ */
3949
+ r(this, "getPointByName", (e) => {
3950
+ switch (e.toUpperCase()) {
3951
+ case "A":
3952
+ return this._A;
3953
+ case "B":
3954
+ return this._B;
3955
+ case "C":
3956
+ return this._C;
3957
+ }
3958
+ return this._A;
3959
+ });
3960
+ /**
3961
+ * Get the vector for the segment given by name.
3962
+ * @param ptName1
3963
+ * @param ptName2
3964
+ */
3965
+ r(this, "getSegment", (e, t) => new N(
3966
+ this.getPointByName(e),
3967
+ this.getPointByName(t)
3968
+ ));
3969
+ r(this, "_calculateRemarquableLines", () => {
3970
+ const e = this._calculateBisectors("A"), t = this._calculateBisectors("B"), i = this._calculateBisectors("C");
3971
+ let s = {
3972
+ medians: {
3973
+ A: new A(this._A, this._middles.BC),
3974
+ B: new A(this._B, this._middles.AC),
3975
+ C: new A(this._C, this._middles.AB),
3976
+ intersection: null
3977
+ },
3978
+ mediators: {
3979
+ AB: new A(this._middles.AB, new N(this._A, this._B).normal()),
3980
+ AC: new A(this._middles.AC, new N(this._A, this._C).normal()),
3981
+ BC: new A(this._middles.BC, new N(this._B, this._C).normal()),
3982
+ intersection: null
3983
+ },
3984
+ heights: {
3985
+ A: new A(this._A, new N(this._B, this._C).normal()),
3986
+ B: new A(this._B, new N(this._A, this._C).normal()),
3987
+ C: new A(this._C, new N(this._A, this._B).normal()),
3988
+ intersection: null
3989
+ },
3990
+ bisectors: {
3991
+ A: e.internal,
3992
+ B: t.internal,
3993
+ C: t.internal,
3994
+ intersection: null
3995
+ },
3996
+ externalBisectors: {
3997
+ A: e.external,
3998
+ B: t.external,
3999
+ C: i.external,
4000
+ intersection: null
4001
+ }
4002
+ };
4003
+ return s.medians.intersection = s.medians.A.intersection(s.medians.B).point, s.mediators.intersection = s.mediators.AB.intersection(s.mediators.BC).point, s.heights.intersection = s.heights.A.intersection(s.heights.B).point, s.bisectors.intersection = s.bisectors.A.intersection(s.bisectors.B).point, s;
4004
+ });
4005
+ r(this, "_calculateBisectors", (e) => {
4006
+ let t = this.lines, i, s;
4007
+ e === "A" ? (i = t.AB, s = t.AC) : e === "B" ? (i = t.AB, s = t.BC) : e === "C" && (i = t.BC, s = t.AC);
4008
+ let n = new A(new k(i.equation.left.clone().multiply(s.n.simplify().norm), s.equation.left.clone().multiply(i.n.simplify().norm)).reorder(!0).simplify()), o = new A(new k(i.equation.left.clone().multiply(s.n.simplify().norm), s.equation.left.clone().multiply(i.n.simplify().norm).opposed()).reorder(!0).simplify());
4009
+ return e === "A" ? n.hitSegment(this.B, this.C) ? { internal: n, external: o } : { internal: o, external: n } : e === "B" ? n.hitSegment(this.A, this.C) ? { internal: n, external: o } : { internal: o, external: n } : e === "C" ? n.hitSegment(this.B, this.A) ? { internal: n, external: o } : { internal: o, external: n } : { internal: n, external: o };
4010
+ });
4011
+ return e.length > 0 && this.parse(...e), this;
3912
4012
  }
3913
- makeAsymptotes() {
3914
- return [];
4013
+ // ------------------------------------------
4014
+ // Getter and setters
4015
+ // ------------------------------------------
4016
+ get A() {
4017
+ return this._A;
3915
4018
  }
3916
- makeDerivative() {
3917
- return {
3918
- type: "grows",
3919
- fx: null,
3920
- factors: [],
3921
- zeroes: [],
3922
- signs: [],
3923
- extremes: {},
3924
- tex: ""
3925
- };
4019
+ get B() {
4020
+ return this._B;
3926
4021
  }
3927
- makeVariation() {
3928
- return {
3929
- type: "variatins",
3930
- fx: null,
3931
- factors: [],
3932
- zeroes: [],
3933
- signs: [],
3934
- extremes: {},
3935
- tex: ""
3936
- };
4022
+ get C() {
4023
+ return this._C;
3937
4024
  }
3938
- }
3939
- class ce extends he {
3940
- constructor(e, t) {
3941
- return super(e, t), this;
4025
+ get AB() {
4026
+ return this.getSegment("A", "B");
3942
4027
  }
3943
- makeZeroes() {
3944
- return this._getZeroes(this.fx);
4028
+ get BA() {
4029
+ return this.getSegment("B", "A");
3945
4030
  }
3946
- makeSigns() {
3947
- return this._getSigns(this.fx, this.zeroes);
4031
+ get BC() {
4032
+ return this.getSegment("B", "C");
3948
4033
  }
3949
- makeAsymptotes() {
3950
- const e = this.fx.clone().reduce();
3951
- let t = [];
3952
- this.zeroes.filter((n) => n.type === L.DEFENCE).forEach((n) => {
3953
- let o = M.VERTICAL, l = `x=${n.tex}`, a = `x=${n.display}`;
3954
- n.exact instanceof h ? e.denominator.evaluate(n.exact).isNotZero() && (o = M.HOLE, l = `(${n.tex};${e.evaluate(n.exact).tex})`, a = `(${n.display};${e.evaluate(n.exact).display})`) : e.denominator.evaluate(n.value).isNotZero() && (o = M.HOLE, l = `(${n.tex};${e.evaluate(n.value).tex})`, a = `(${n.display};${e.evaluate(n.value).display})`);
3955
- const f = 1e-6;
3956
- let m = this.fx.evaluateAsNumeric(n.value - f), d = this.fx.evaluateAsNumeric(n.value + f), p = [], _ = "";
3957
- d < -1e4 ? (p.push(E.RB), _ += "m") : d > 1e4 && (p.push(E.RT), _ += "p"), m < -1e4 ? (p.push(E.LB), _ += "m") : m > 1e4 && (p.push(E.LT), _ += "p"), _ === "pp" ? _ = "+" : _ === "mm" ? _ = "-" : _ = `\\${_}`, t.push({
3958
- fx: null,
3959
- type: o,
3960
- tex: l,
3961
- display: a,
3962
- zero: n,
3963
- limits: `\\lim_{x\\to${n.tex} }\\ f(x) = ${_}\\infty`,
3964
- deltaX: null,
3965
- tableOfSign: null,
3966
- position: p
3967
- });
3968
- });
3969
- let i = this.fx.numerator.degree(), s = this.fx.denominator.degree();
3970
- if (i.isEqual(s)) {
3971
- let n = this.fx.numerator.monomByDegree().coefficient.clone().divide(this.fx.denominator.monomByDegree().coefficient), o = n.tex, { reminder: l } = e.euclidian(), a = new R(l, e.denominator);
3972
- t.push({
3973
- fx: new u(n),
3974
- type: M.HORIZONTAL,
3975
- tex: `y=${o}`,
3976
- display: `y=${n.display}`,
3977
- zero: null,
3978
- limits: `\\lim_{x\\to\\infty}\\ f(x) = ${o}`,
3979
- deltaX: a,
3980
- tableOfSign: this._getSigns(a),
3981
- position: this._getHorizontalAsymptoteRelativePositon(a)
3982
- });
3983
- } else if (s.greater(i))
3984
- t.push({
3985
- fx: new u("0"),
3986
- type: M.HORIZONTAL,
3987
- tex: "y=0",
3988
- display: "y=0",
3989
- zero: null,
3990
- limits: "\\lim_{x\\to\\infty}\\ f(x) = 0",
3991
- deltaX: null,
3992
- tableOfSign: null,
3993
- position: this._getHorizontalAsymptoteRelativePositon(this.fx)
3994
- });
3995
- else if (i.value - 1 === s.value) {
3996
- let { quotient: n, reminder: o } = e.euclidian(), l = new R(o, e.denominator);
3997
- t.push({
3998
- fx: n.clone(),
3999
- type: M.SLOPE,
4000
- tex: `y=${n.tex}`,
4001
- display: `y=${n.display}`,
4002
- zero: null,
4003
- limits: "",
4004
- deltaX: new R(o, e.denominator),
4005
- tableOfSign: this._getSigns(l),
4006
- position: this._getHorizontalAsymptoteRelativePositon(l)
4007
- });
4008
- }
4009
- return t;
4034
+ get CB() {
4035
+ return this.getSegment("C", "B");
4010
4036
  }
4011
- _getHorizontalAsymptoteRelativePositon(e, t = 1e6) {
4012
- let i = [], s = e.evaluateAsNumeric(-t), n = e.evaluateAsNumeric(t);
4013
- return s >= 0 ? i.push(E.LT) : i.push(E.LB), n >= 0 ? i.push(E.RT) : i.push(E.RB), i;
4037
+ get AC() {
4038
+ return this.getSegment("A", "C");
4014
4039
  }
4015
- makeDerivative() {
4016
- let e = this.fx.clone().derivative(), t = this._getSigns(e, this._getZeroes(e), W.GROWS), i = this.makeGrowsResult(t);
4017
- return t.signs.push(i.growsLine), t.extremes = i.extremes, t;
4040
+ get CA() {
4041
+ return this.getSegment("C", "A");
4018
4042
  }
4019
- makeVariation() {
4020
- let e = this.derivative.fx.clone().derivative(), t = this._getSigns(e, this._getZeroes(e), W.VARIATIONS), i = this.makeVariationsResult(t);
4021
- return t.signs.push(i.varsLine), t.extremes = i.extremes, t;
4043
+ get isRectangle() {
4044
+ return !!(this.AB.isNormalTo(this.BC) || this.AB.isNormalTo(this.AC) || this.BC.isNormalTo(this.AC));
4022
4045
  }
4023
- _getZeroes(e) {
4024
- let t = [];
4025
- return e.numerator.getZeroes().filter((i) => !isNaN(i.value)).forEach((i) => {
4026
- t.push({
4027
- tex: i.tex,
4028
- display: i.display,
4029
- value: i.value,
4030
- exact: i.exact,
4031
- extrema: H.NOTHING,
4032
- type: L.ZERO
4033
- });
4034
- }), e.denominator.getZeroes().filter((i) => !isNaN(i.value)).forEach((i) => {
4035
- let s = this.indexOfZero(t, i);
4036
- s !== -1 ? t[s].type = L.DEFENCE : t.push({
4037
- tex: i.tex,
4038
- display: i.display,
4039
- value: i.value,
4040
- exact: i.exact,
4041
- extrema: H.NOTHING,
4042
- type: L.DEFENCE
4043
- });
4044
- }), t.sort((i, s) => i.value - s.value), t;
4046
+ get isEquilateral() {
4047
+ return this.AB.normSquare.isEqual(this.BC.normSquare) && this.AB.normSquare.isEqual(this.AC.normSquare);
4045
4048
  }
4046
- _getSigns(e, t, i) {
4047
- let s = [], n = [];
4048
- return t === void 0 && (t = this._getZeroes(e)), e.numerator.factors.forEach((o) => {
4049
- s.push(this.makeOneLineForSigns(o, t, L.ZERO)), n.push(o.clone());
4050
- }), e.denominator.factors.forEach((o) => {
4051
- s.push(this.makeOneLineForSigns(o, t, L.DEFENCE)), n.push(o.clone());
4052
- }), s.push(this.makeSignsResult(s)), {
4053
- type: i,
4054
- fx: e,
4055
- factors: n,
4056
- zeroes: t,
4057
- signs: s,
4058
- extremes: {},
4059
- tex: ""
4060
- };
4049
+ get isIsocele() {
4050
+ return this.AB.normSquare.isEqual(this.BC.normSquare) || this.AB.normSquare.isEqual(this.AC.normSquare) || this.BC.normSquare.isEqual(this.AC.normSquare);
4051
+ }
4052
+ get lines() {
4053
+ return this._lines;
4054
+ }
4055
+ get remarquables() {
4056
+ return this._remarquables;
4061
4057
  }
4062
4058
  }
4063
- class R {
4064
- /**
4065
- *
4066
- * @param numerator
4067
- * @param denominator
4068
- */
4069
- constructor(e, t) {
4070
- r(this, "_denominator");
4071
- r(this, "_numerator");
4072
- r(this, "_rawString");
4073
- r(this, "clone", () => new R(
4074
- this._numerator.clone(),
4075
- this._denominator.clone()
4076
- ));
4077
- r(this, "domain", () => {
4078
- let e = this._denominator.getZeroes();
4079
- return e.length === 0 || e[0].tex === F.real ? F.varnothing : e[0].tex === F.varnothing ? F.real : "\\mathbb{R}\\setminus\\left\\{" + e.map((t) => t.tex).join(";") + "\\right\\}";
4080
- });
4081
- r(this, "amplify", (e) => (this._numerator.multiply(e), this._denominator.multiply(e), this));
4082
- r(this, "derivative", (e) => {
4083
- let t = this._numerator.clone(), i = this._denominator.clone(), s = t.clone().derivative(e), n = i.clone().derivative(e);
4084
- return this._numerator = s.clone().multiply(i).subtract(t.clone().multiply(n)), this._denominator = i.clone().pow(2), this;
4085
- });
4086
- r(this, "factorize", (e) => (this._numerator.factorize(e), this._denominator.factorize(e), this));
4087
- r(this, "simplify", (e) => {
4088
- let t = this._numerator.euclidian(e);
4089
- if (!t.reminder.isZero())
4090
- return this;
4091
- let i = this._denominator.euclidian(e);
4092
- return i.reminder.isZero() ? (this._numerator = t.quotient, this._denominator = i.quotient, this) : this;
4093
- });
4094
- r(this, "reduce", () => {
4095
- this._numerator.factorize();
4096
- for (let e of this._numerator.factors)
4097
- e.degree().isZero() ? this._denominator.commonMonom().coefficient.clone().divide(e.monomByDegree().coefficient).isNatural() && this.simplify(e) : this.simplify(e);
4098
- return this;
4099
- });
4100
- r(this, "opposed", () => (this._numerator.opposed(), this));
4101
- r(this, "add", (e) => {
4102
- let t = this._denominator.clone();
4103
- return this.amplify(e._denominator), this._numerator.add(e._numerator.clone().multiply(t)), this;
4059
+ class G {
4060
+ constructor(...e) {
4061
+ r(this, "_center");
4062
+ r(this, "_squareRadius");
4063
+ r(this, "_cartesian");
4064
+ r(this, "_exists");
4065
+ /**
4066
+ * Get the relative position between circle and line. It corresponds to the number of intersection.
4067
+ * @param {Line} L
4068
+ * @returns {number}
4069
+ */
4070
+ r(this, "relativePosition", (e) => {
4071
+ let t = e.distanceTo(this.center), i = Math.sqrt(this._squareRadius.value);
4072
+ return t.value - i > 1e-10 ? 0 : Math.abs(t.value - i) < 1e-10 ? 1 : 2;
4104
4073
  });
4105
- r(this, "subtract", (e) => this.add(e.clone().opposed()));
4106
- r(this, "euclidian", () => this._numerator.euclidian(this._denominator));
4107
- // TODO : where and how is used limits ?
4108
- r(this, "limits", (e, t, i) => {
4109
- if (e === 1 / 0 || e === -1 / 0) {
4110
- let { quotient: s, reminder: n } = this._numerator.clone().euclidian(this._denominator);
4111
- return s.degree(i).isStrictlyPositive() ? e === 1 / 0 ? s.limitToInfinity(i) : s.limitToNegativeInfinity(i) : s.monomByDegree(void 0, i).coefficient;
4112
- } else {
4113
- let s = {}, n = {}, o, l, a = this.clone().reduce();
4114
- return s[i === void 0 ? "x" : i] = new h(e), t !== "above" && t !== "below" ? (o = a._numerator.evaluate(s).divide(a._denominator.evaluate(s)), o.isInfinity() ? o.abs() : o) : (t === "above" ? n[i === void 0 ? "x" : i] = new h(e).add(1e-6) : t === "below" && (n[i === void 0 ? "x" : i] = new h(e).subtract(1e-6)), o = a._numerator.evaluate(s).divide(a._denominator.evaluate(s)), l = a._numerator.evaluate(n).divide(a._denominator.evaluate(n)).sign(), o.isInfinity() ? l === 1 ? o.abs() : o.abs().opposed() : o);
4074
+ r(this, "lineIntersection", (e) => {
4075
+ let t = [], i;
4076
+ if (this._cartesian === null)
4077
+ return [];
4078
+ const s = this._cartesian.clone(), n = e.equation.clone().isolate("x"), o = e.equation.clone().isolate("y");
4079
+ if (n instanceof k && o instanceof k) {
4080
+ s.replaceBy("y", o.right).simplify(), s.solve();
4081
+ for (let l of s.solutions)
4082
+ l.exact === !1 && isNaN(l.value) || (i = new h(l.exact === !1 ? l.value : l.exact), t.push(new y(i.clone(), o.right.evaluate(i))));
4115
4083
  }
4084
+ return t;
4085
+ });
4086
+ r(this, "tangents", (e) => e instanceof h ? this._tangentsWithSlope(e) : this.isPointOnCircle(e) ? this._tangentsThroughOnePointOnTheCircle(e) : this.center.distanceTo(e).value > this.radius.value ? this._tangentsThroughOnePointOutsideTheCircle(e) : (console.log("No tangents as the point is inside !"), []));
4087
+ r(this, "isPointOnCircle", (e) => this._cartesian.test({ x: e.x, y: e.y }));
4088
+ r(this, "getPointsOnCircle", (e) => {
4089
+ let t = x.pythagoricianTripletsWithTarget(this._squareRadius.value, !0), i = [], s;
4090
+ return t.forEach((n) => {
4091
+ for (let o of [[1, 1], [-1, 1], [-1, -1], [1, -1]])
4092
+ s = new y(
4093
+ this.center.x.clone().add(o[0] * n[0]),
4094
+ this.center.y.clone().add(o[1] * n[1])
4095
+ ), s.isInListOfPoints(i) || i.push(s);
4096
+ }), i;
4116
4097
  });
4117
- r(this, "evaluate", (e) => {
4118
- new h().zero();
4119
- let t = this._numerator.evaluate(e), i = this._denominator.evaluate(e);
4120
- return t.divide(i);
4098
+ r(this, "_tangentsThroughOnePointOnTheCircle", (e) => {
4099
+ let t = new N(this._center, e);
4100
+ return [new A(e, t, ee.Perpendicular)];
4121
4101
  });
4122
- r(this, "evaluateAsNumeric", (e) => this._numerator.evaluateAsNumeric(e) / this._denominator.evaluateAsNumeric(e));
4123
- r(this, "study", (e) => new ce(this, e));
4124
- e instanceof u ? this._numerator = e.clone() : typeof e == "string" ? this._numerator = new u(e) : this._numerator = new u(), t instanceof u ? this._denominator = t.clone() : typeof t == "string" ? this._denominator = new u(t) : this._denominator = new u();
4102
+ r(this, "_tangentsThroughOnePointOutsideTheCircle", (e) => {
4103
+ let t = this.center.x.clone().subtract(e.x), i = this.center.y.clone().subtract(e.y), s = new u("x"), n = new u("x^2+1");
4104
+ s.multiply(t).subtract(i).pow(2), n.multiply(this.squareRadius);
4105
+ let o = new k(s, n);
4106
+ return o.moveLeft().simplify().solve(), o.solutions.map((l) => {
4107
+ let a, f = new k("y", "x");
4108
+ return l.exact instanceof h ? (a = e.x.clone().opposed().multiply(l.exact).add(e.y), f.right.multiply(l.exact).add(a)) : (a = e.x.clone().opposed().multiply(l.value).add(e.y), f.right.multiply(l.value).add(a)), new A(f);
4109
+ });
4110
+ });
4111
+ r(this, "_tangentsWithSlope", (e) => {
4112
+ const t = e.numerator, i = -e.denominator, s = this._center.x.clone(), n = this._center.y.clone();
4113
+ this._squareRadius;
4114
+ let o = this._squareRadius.clone().multiply(e.numerator ** 2 + e.denominator ** 2), l = s.clone().multiply(t).opposed().subtract(n.clone().multiply(i)).add(o.clone().sqrt()), a = s.clone().multiply(t).opposed().subtract(n.clone().multiply(i)).subtract(o.clone().sqrt());
4115
+ return [new A(t, i, l), new A(t, i, a)];
4116
+ });
4117
+ this._exists = !1, e !== void 0 && this.parse(...e);
4125
4118
  }
4126
- get numerator() {
4127
- return this._numerator;
4119
+ get center() {
4120
+ return this._center;
4128
4121
  }
4129
- get denominator() {
4130
- return this._denominator;
4122
+ get squareRadius() {
4123
+ return this._squareRadius;
4124
+ }
4125
+ get cartesian() {
4126
+ return this._cartesian;
4127
+ }
4128
+ get exists() {
4129
+ return this._exists;
4130
+ }
4131
+ get radius() {
4132
+ return this._squareRadius.isSquare() ? {
4133
+ tex: this._squareRadius.clone().sqrt().tex,
4134
+ display: this._squareRadius.clone().sqrt().display,
4135
+ value: this._squareRadius.clone().sqrt().value
4136
+ } : {
4137
+ tex: `\\sqrt{${this._squareRadius.tex}}`,
4138
+ display: `sqrt(${this._squareRadius.display})`,
4139
+ value: this._squareRadius.clone().sqrt().value
4140
+ };
4131
4141
  }
4132
4142
  get tex() {
4133
- return `\\frac{ ${this._numerator.tex} }{ ${this._denominator.tex} }`;
4143
+ if (this._exists) {
4144
+ let e, t;
4145
+ return this._center.x.isZero() ? e = "x^2" : e = `\\left(x${this._center.x.isNegative() ? "+" : "-"}${this._center.x.clone().abs().tex}\\right)^2`, this._center.y.isZero() ? t = "y^2" : t = `\\left(y${this._center.y.isNegative() ? "+" : "-"}${this._center.y.clone().abs().tex}\\right)^2`, `${e}+${t}=${this._squareRadius.tex}`;
4146
+ } else
4147
+ return "\\text{le cercle n'existe pas.}";
4148
+ }
4149
+ get developed() {
4150
+ return this._cartesian.tex;
4134
4151
  }
4135
4152
  get display() {
4136
- return `(${this._numerator.display})/(${this._denominator.display})`;
4153
+ if (this._exists) {
4154
+ let e, t;
4155
+ 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}`;
4156
+ } else
4157
+ return "\\text{le cercle n'existe pas.}";
4137
4158
  }
4138
- get texFactors() {
4139
- return `\\frac{ ${this._numerator.texFactors} }{ ${this._denominator.texFactors} }`;
4159
+ clone() {
4160
+ return this._center = this._center.clone(), this._squareRadius = this._squareRadius.clone(), this._calculateCartesian(), this;
4140
4161
  }
4141
- get displayFactors() {
4142
- return `(${this._numerator.displayFactors})/(${this._denominator.displayFactors})`;
4162
+ _reset() {
4163
+ return this._center = null, this._squareRadius = null, this._cartesian = null, this._exists = !1, this;
4143
4164
  }
4144
- get plotFunction() {
4145
- return `(${this._numerator.plotFunction})/(${this._denominator.plotFunction})`;
4165
+ parse(...e) {
4166
+ return this._reset(), typeof e[0] == "string" ? this._parseEquation(new k(e[0])) : e[0] instanceof k ? this._parseEquation(e[0]) : e[0] instanceof G ? this._parseCopyCircle(e[0]) : e[0] instanceof y && e.length > 1 && (e[1] instanceof y ? e[2] instanceof y ? this._parseThroughtThreePoints(e[0], e[1], e[2]) : this._parseCenterAndPointThrough(e[0], e[1]) : (e[1] instanceof h || typeof e[1] == "number") && this._parseCenterAndRadius(e[0], e[1], typeof e[2] == "boolean" ? e[2] : !1)), this._exists && (this._calculateCartesian(), this._squareRadius !== void 0 && this._squareRadius.isNegative() && (this._exists = !1)), this;
4146
4167
  }
4147
- }
4148
- class fe {
4149
- /**
4150
- *
4151
- * @param {string} value (optional) Default polynom to parse on class creation
4152
- */
4153
- constructor(e) {
4154
- r(this, "_rawString");
4155
- r(this, "_rpn");
4156
- r(this, "parse", (e) => (this._rpn = new P(U.SET).parse(e).rpn, this));
4157
- return this._rawString = e, this.parse(e), this;
4168
+ _calculateCartesian() {
4169
+ this._cartesian = new k(new u(`(x-(${this._center.x.display}))^2+(y-(${this._center.y.display}))^2`), new u(`${this._squareRadius.display}`)).moveLeft();
4158
4170
  }
4159
- get isLogicalset() {
4160
- return !0;
4171
+ _parseCopyCircle(e) {
4172
+ return this._center = e.center.clone(), this._squareRadius = e.squareRadius.clone(), this._calculateCartesian(), this._exists = e.exists, this;
4161
4173
  }
4162
- get rpn() {
4163
- return this._rpn;
4174
+ _parseCenterAndRadius(e, t, i) {
4175
+ return this._center = e.clone(), i ? this._squareRadius = new h(t) : this._squareRadius = new h(t).pow(2), this._exists = !0, this;
4164
4176
  }
4165
- get tex() {
4166
- let e = [];
4167
- for (let t of this._rpn)
4168
- if (t.tokenType === "variable")
4169
- e.push(t);
4170
- else
4171
- switch (t.token) {
4172
- case "&":
4173
- if (e.length >= 2) {
4174
- let i = e.pop(), s = e.pop();
4175
- s.tokenType === "mix" && (s.token = `( ${s.token} )`), i.tokenType === "mix" && (i.token = `( ${i.token} )`), e.push({ token: `${s.token} \\cap ${i.token}`, tokenType: "mix" });
4176
- }
4177
- break;
4178
- case "|":
4179
- if (e.length >= 2) {
4180
- let i = e.pop(), s = e.pop();
4181
- s.tokenType === "mix" && (s.token = `( ${s.token} )`), i.tokenType === "mix" && (i.token = `( ${i.token} )`), e.push({ token: `${s.token} \\cup ${i.token}`, tokenType: "mix" });
4182
- }
4183
- break;
4184
- case "-":
4185
- if (e.length >= 2) {
4186
- let i = e.pop(), s = e.pop();
4187
- s.tokenType === "mix" && (s.token = `( ${s.token} )`), i.tokenType === "mix" && (i.token = `( ${i.token} )`), e.push({ token: `${s.token} \\setminus ${i.token}`, tokenType: "mix" });
4188
- }
4189
- break;
4190
- case "!":
4191
- if (e.length >= 1) {
4192
- let i = e.pop();
4193
- e.push({ token: `\\overline{ ${i.token} }`, tokenType: "variable" });
4194
- }
4195
- break;
4196
- }
4197
- return e[0].token;
4177
+ _parseCenterAndPointThrough(e, t) {
4178
+ return this._center = e.clone(), this._squareRadius = new N(this._center, t).normSquare, this._exists = !0, this;
4198
4179
  }
4199
- evaluate(e, t) {
4200
- let i = [], s;
4201
- if (t === void 0) {
4202
- s = /* @__PURE__ */ new Set();
4203
- for (let n in e)
4204
- s = /* @__PURE__ */ new Set([...s, ...e[n]]);
4205
- } else
4206
- s = new Set(t);
4207
- for (let n of this._rpn)
4208
- if (n.tokenType === "variable")
4209
- e[n.token] === void 0 ? i.push(/* @__PURE__ */ new Set()) : i.push(new Set(e[n.token]));
4210
- else
4211
- switch (n.token) {
4212
- case "&":
4213
- if (i.length >= 2) {
4214
- let o = i.pop(), l = i.pop();
4215
- i.push(new Set([...l].filter((a) => o.has(a))));
4216
- }
4217
- break;
4218
- case "|":
4219
- if (i.length >= 2) {
4220
- let o = i.pop(), l = i.pop();
4221
- i.push(/* @__PURE__ */ new Set([...l, ...o]));
4222
- }
4223
- break;
4224
- case "-":
4225
- if (i.length >= 2) {
4226
- let o = i.pop(), l = i.pop();
4227
- i.push(new Set([...l].filter((a) => !o.has(a))));
4228
- }
4229
- break;
4230
- case "!":
4231
- if (i.length >= 1) {
4232
- let o = i.pop();
4233
- i.push(new Set([...s].filter((l) => !o.has(l))));
4234
- }
4235
- break;
4236
- }
4237
- return [...i[0]].sort();
4180
+ _parseEquation(e) {
4181
+ if (this._exists = !1, e.moveLeft(), e.degree("x").value === 2 && e.degree("y").value === 2) {
4182
+ let t = e.left.monomByDegree(2, "x"), i = e.left.monomByDegree(2, "y"), s, n, o;
4183
+ t.coefficient.isEqual(i.coefficient) ? (e.divide(t.coefficient), s = e.left.monomByDegree(1, "x"), n = e.left.monomByDegree(1, "y"), o = e.left.monomByDegree(0), this._center = new y(s.coefficient.clone().divide(2).opposed(), n.coefficient.clone().divide(2).opposed()), this._squareRadius = o.coefficient.clone().opposed().add(this._center.x.clone().pow(2)).add(this._center.y.clone().pow(2)), this._calculateCartesian(), this._exists = !0) : (this._center = null, this._squareRadius = null, this._exists = !1);
4184
+ }
4185
+ return this;
4238
4186
  }
4239
- vennAB() {
4240
- return this.evaluate(
4241
- {
4242
- A: ["A", "AB"],
4243
- B: ["B", "AB"]
4244
- },
4245
- ["A", "B", "AB", "E"]
4246
- );
4187
+ _parseThroughtThreePoints(e, t, i) {
4188
+ let s = new j(e, t, i), n = s.remarquables.mediators.AB.clone(), o = s.remarquables.mediators.AC.clone();
4189
+ return this.parse(n.intersection(o).point, e), this;
4247
4190
  }
4248
- vennABC() {
4249
- return this.evaluate(
4250
- {
4251
- A: ["A", "AB", "AC", "ABC"],
4252
- B: ["B", "AB", "BC", "ABC"],
4253
- C: ["C", "AC", "BC", "ABC"]
4254
- },
4255
- ["A", "B", "C", "AB", "AC", "BC", "E"]
4256
- );
4191
+ }
4192
+ class fe extends D {
4193
+ constructor(t) {
4194
+ super();
4195
+ r(this, "generate", () => {
4196
+ const t = w.Geometry.point(this._config.center);
4197
+ let i, s;
4198
+ return this._config.pointsOnCircle === 8 ? (i = w.number(1, 3), s = i ** 2 + (i + 1) ** 2) : s = w.number(1, 20), new G(t, s, !0);
4199
+ });
4200
+ this._defaultConfig = {}, this._config = this.mergeConfig(t, this._defaultConfig);
4257
4201
  }
4258
4202
  }
4203
+ var w;
4204
+ ((c) => {
4205
+ function e(d) {
4206
+ return new oe(d).generate();
4207
+ }
4208
+ c.polynom = e;
4209
+ function t(d) {
4210
+ return new J(d).generate();
4211
+ }
4212
+ c.monom = t;
4213
+ function i(d) {
4214
+ return new le(d).generate();
4215
+ }
4216
+ c.fraction = i;
4217
+ function s(d, p, _) {
4218
+ return T.randomInt(d, p, _);
4219
+ }
4220
+ c.number = s;
4221
+ function n(d, p) {
4222
+ return T.randomIntSym(d, p);
4223
+ }
4224
+ c.numberSym = n;
4225
+ function o(d) {
4226
+ return T.randomPrime(d);
4227
+ }
4228
+ c.prime = o;
4229
+ function l(d) {
4230
+ return T.randomBool(d);
4231
+ }
4232
+ c.bool = l;
4233
+ function a(d, p) {
4234
+ return T.randomArray(d, p);
4235
+ }
4236
+ c.array = a;
4237
+ function f(d) {
4238
+ return T.randomItem(d);
4239
+ }
4240
+ c.item = f;
4241
+ function m(d) {
4242
+ return T.shuffleArray(d);
4243
+ }
4244
+ c.shuffle = m, ((d) => {
4245
+ function p(v) {
4246
+ return new he(v).generate();
4247
+ }
4248
+ d.line = p;
4249
+ function _(v) {
4250
+ return new ce(v).generate();
4251
+ }
4252
+ d.point = _;
4253
+ function q(v) {
4254
+ return new fe(v).generate();
4255
+ }
4256
+ d.circle = q;
4257
+ })(c.Geometry || (c.Geometry = {}));
4258
+ })(w || (w = {}));
4259
4259
  const de = {
4260
4260
  ShutingYard: P,
4261
4261
  Numeric: x,
4262
4262
  NumExp: K,
4263
4263
  Fraction: h,
4264
- Root: J,
4264
+ Root: Q,
4265
4265
  Monom: g,
4266
4266
  Polynom: u,
4267
4267
  Equation: k,
4268
4268
  LinearSystem: Y,
4269
4269
  Rational: R,
4270
- Logicalset: fe,
4270
+ Logicalset: ne,
4271
4271
  Random: w,
4272
4272
  Geometry: {
4273
4273
  Vector: N,