pimath 0.0.125 → 0.0.127
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/.idea/inspectionProfiles/Project_Default.xml +5 -5
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]/shelved.patch +192 -192
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43_[Default_Changelist]/shelved.patch +2404 -2404
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01_[Default_Changelist]/shelved.patch +1362 -1362
- package/dev/pimath.js +7945 -0
- package/dev/pimath.js.map +1 -0
- package/dist/pimath.js +192 -221
- package/dist/pimath.js.map +1 -1
- package/dist/pimath.min.js +1 -1
- package/dist/pimath.min.js.map +1 -1
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +78 -0
- package/docs/assets/main.js +59 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1383 -0
- package/docs/classes/Logicalset.Logicalset.html +217 -0
- package/docs/classes/Polynom.Rational.html +397 -0
- package/docs/classes/Vector-1.Vector.html +490 -0
- package/docs/classes/Vector.Point.html +337 -0
- package/docs/classes/algebra_equation.Equation.html +790 -0
- package/docs/classes/algebra_linearSystem.LinearSystem.html +404 -0
- package/docs/classes/algebra_monom.Monom.html +962 -0
- package/docs/classes/algebra_polynom.Polynom.html +1275 -0
- package/docs/classes/coefficients_fraction.Fraction.html +934 -0
- package/docs/classes/geometry_circle.Circle.html +472 -0
- package/docs/classes/geometry_line.Line.html +774 -0
- package/docs/classes/geometry_triangle.Triangle.html +429 -0
- package/docs/classes/numeric.Numeric.html +265 -0
- package/docs/classes/shutingyard.Shutingyard.html +250 -0
- package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +83 -0
- package/docs/enums/geometry_line.LinePropriety.html +97 -0
- package/docs/enums/shutingyard.ShutingyardMode.html +97 -0
- package/docs/enums/shutingyard.ShutingyardType.html +111 -0
- package/docs/index.html +63 -0
- package/docs/interfaces/algebra_equation.ISolution.html +105 -0
- package/docs/interfaces/algebra_polynom.IEuclidian.html +87 -0
- package/docs/interfaces/geometry_triangle.remarquableLines.html +163 -0
- package/docs/modules/Logicalset.html +65 -0
- package/docs/modules/Polynom.html +65 -0
- package/docs/modules/Vector-1.html +65 -0
- package/docs/modules/Vector.html +65 -0
- package/docs/modules/algebra_equation.html +69 -0
- package/docs/modules/algebra_linearSystem.html +61 -0
- package/docs/modules/algebra_monom.html +65 -0
- package/docs/modules/algebra_polynom.html +69 -0
- package/docs/modules/coefficients_fraction.html +65 -0
- package/docs/modules/geometry_circle.html +61 -0
- package/docs/modules/geometry_line.html +65 -0
- package/docs/modules/geometry_triangle.html +65 -0
- package/docs/modules/numeric.html +61 -0
- package/docs/modules/shutingyard.html +75 -0
- package/docs/types/algebra_monom.literalType.html +61 -0
- package/docs/types/algebra_polynom.PolynomParsingType.html +56 -0
- package/docs/types/coefficients_fraction.FractionParsingType.html +56 -0
- package/docs/types/shutingyard.Token.html +63 -0
- package/docs/types/shutingyard.tokenType.html +68 -0
- package/docs/variables/shutingyard.tokenConstant.html +61 -0
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/maths/algebra/monom.d.ts +19 -19
- package/esm/maths/algebra/monom.js +66 -66
- package/esm/maths/algebra/monom.js.map +1 -1
- package/esm/maths/algebra/polynom.d.ts +14 -14
- package/esm/maths/algebra/polynom.js +72 -50
- package/esm/maths/algebra/polynom.js.map +1 -1
- package/esm/maths/numeric.js +3 -48
- package/esm/maths/numeric.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/maths/algebra/monom.ts +138 -130
- package/src/maths/algebra/polynom.ts +97 -82
- package/src/maths/geometry/line.ts +22 -25
- package/src/maths/geometry/point.ts +43 -29
- package/src/maths/numeric.ts +61 -90
- package/src/maths/randomization/random.ts +7 -0
- package/src/maths/randomization/rndGeometryCircle.ts +50 -0
- package/src/maths/randomization/rndTypes.ts +10 -4
- package/tests/algebra/linear.test.ts +1 -1
- package/tests/algebra/polynom.test.ts +162 -1
- package/tests/algebra/study.test.ts +1 -0
- package/tests/geometry/circle.test.ts +320 -115
- package/tests/geometry/line.test.ts +8 -17
- package/tests/numeric.test.ts +19 -3
package/src/maths/numeric.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export class Numeric{
|
|
2
|
-
static round(value:number, decimals:number=2):number {
|
|
3
|
-
return Number(Math.round(Number(value+'e'+decimals))+'e-'+decimals);
|
|
1
|
+
export class Numeric {
|
|
2
|
+
static round(value: number, decimals: number = 2): number {
|
|
3
|
+
return Number(Math.round(Number(value + 'e' + decimals)) + 'e-' + decimals);
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Get the list of the nth first prime numbers.
|
|
8
8
|
* @param nb : number of primes to choose from
|
|
9
9
|
*/
|
|
10
|
-
static primes(nb?:number):number[]{
|
|
11
|
-
let primesValues:number[] = [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];
|
|
12
|
-
if(nb === undefined){
|
|
10
|
+
static primes(nb?: number): number[] {
|
|
11
|
+
let primesValues: number[] = [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];
|
|
12
|
+
if (nb === undefined) {
|
|
13
13
|
return primesValues;
|
|
14
|
-
}else{
|
|
15
|
-
return primesValues.slice(0,Math.min(primesValues.length,nb));
|
|
14
|
+
} else {
|
|
15
|
+
return primesValues.slice(0, Math.min(primesValues.length, nb));
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -20,88 +20,102 @@ export class Numeric{
|
|
|
20
20
|
* Get the list of all dividers of a number.
|
|
21
21
|
* @param value
|
|
22
22
|
*/
|
|
23
|
-
static dividers(value:number):number[]{
|
|
23
|
+
static dividers(value: number): number[] {
|
|
24
24
|
let D: number[];
|
|
25
25
|
const maxV = Math.sqrt(Math.abs(value));
|
|
26
26
|
|
|
27
27
|
// Initialize the list of dividers.
|
|
28
28
|
D = [];
|
|
29
29
|
|
|
30
|
-
for(let i=1; i<=maxV; i++){
|
|
31
|
-
if(value%i===0){
|
|
30
|
+
for (let i = 1; i <= maxV; i++) {
|
|
31
|
+
if (value % i === 0) {
|
|
32
32
|
D.push(i);
|
|
33
|
-
D.push(value/i);
|
|
33
|
+
D.push(value / i);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
// Order numbers.
|
|
38
|
-
D.sort(function(a, b){
|
|
38
|
+
D.sort(function (a, b) {
|
|
39
|
+
return a - b;
|
|
40
|
+
});
|
|
39
41
|
|
|
40
42
|
// Make sure the array of value is unique.
|
|
41
43
|
return [...new Set(D)];
|
|
42
44
|
}
|
|
45
|
+
|
|
43
46
|
/**
|
|
44
47
|
* Great Common Divisor
|
|
45
48
|
* @param values : number values
|
|
46
49
|
*/
|
|
47
|
-
static gcd(...values:number[]):number{
|
|
50
|
+
static gcd(...values: number[]): number {
|
|
48
51
|
// Define the gcd for two number
|
|
49
|
-
let gcd2 = function(a:number,b:number):number{
|
|
50
|
-
if(b===0){
|
|
51
|
-
|
|
52
|
+
let gcd2 = function (a: number, b: number): number {
|
|
53
|
+
if (b === 0) {
|
|
54
|
+
return a;
|
|
55
|
+
}
|
|
56
|
+
return gcd2(b, a % b);
|
|
52
57
|
};
|
|
53
58
|
|
|
54
|
-
let g:number = 1,
|
|
55
|
-
i:number = 2;
|
|
59
|
+
let g: number = 1,
|
|
60
|
+
i: number = 2;
|
|
56
61
|
|
|
57
62
|
// Nothing is given
|
|
58
|
-
if(values.length===0){
|
|
63
|
+
if (values.length === 0) {
|
|
64
|
+
return 1;
|
|
65
|
+
}
|
|
59
66
|
// Only one number is given
|
|
60
|
-
if(values.length===1){
|
|
67
|
+
if (values.length === 1) {
|
|
61
68
|
// The first number is zero
|
|
62
|
-
if(values[0]===0){
|
|
69
|
+
if (values[0] === 0) {
|
|
70
|
+
return 1;
|
|
71
|
+
}
|
|
63
72
|
// Return the number
|
|
64
73
|
return values[0];
|
|
65
74
|
}
|
|
66
75
|
|
|
67
76
|
// We have at least 2 numbers.
|
|
68
|
-
g = gcd2(values[0],values[1]);
|
|
77
|
+
g = gcd2(values[0], values[1]);
|
|
69
78
|
|
|
70
79
|
// The gcd of the two first value is one ? It's already finished.
|
|
71
|
-
if(g===1){
|
|
80
|
+
if (g === 1) {
|
|
81
|
+
return 1;
|
|
82
|
+
}
|
|
72
83
|
|
|
73
84
|
// The current gcd isn't one. Continue with all next values.
|
|
74
|
-
for(i=2; i<values.length; i++){
|
|
85
|
+
for (i = 2; i < values.length; i++) {
|
|
75
86
|
g = gcd2(g, values[i]);
|
|
76
87
|
// Escape if gcd is already one.
|
|
77
|
-
if(g===1){
|
|
88
|
+
if (g === 1) {
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
78
91
|
}
|
|
79
92
|
|
|
80
93
|
return Math.abs(g);
|
|
81
94
|
}
|
|
82
95
|
|
|
83
|
-
static divideNumbersByGCD(...values: number[]): number[]{
|
|
96
|
+
static divideNumbersByGCD(...values: number[]): number[] {
|
|
84
97
|
let gcd = Numeric.gcd(...values)
|
|
85
98
|
|
|
86
|
-
return values.map(x=>x/gcd)
|
|
99
|
+
return values.map(x => x / gcd)
|
|
87
100
|
}
|
|
101
|
+
|
|
88
102
|
/**
|
|
89
103
|
* Least Common Multiple
|
|
90
104
|
* @param values: list of numbers
|
|
91
105
|
*/
|
|
92
|
-
static lcm(...values:number[]):number{
|
|
93
|
-
return values.reduce(function(a,b){
|
|
106
|
+
static lcm(...values: number[]): number {
|
|
107
|
+
return values.reduce(function (a, b) {
|
|
94
108
|
return Math.abs(a * b / Numeric.gcd(a, b));
|
|
95
109
|
});
|
|
96
110
|
}
|
|
97
111
|
|
|
98
|
-
static pythagoricianTripletsWithTarget(target: number, targetIsSquare?:boolean): number[][] {
|
|
112
|
+
static pythagoricianTripletsWithTarget(target: number, targetIsSquare?: boolean): number[][] {
|
|
99
113
|
// méthode inverse, à partir du triplet.
|
|
100
114
|
const triplets = [],
|
|
101
|
-
targetValue = targetIsSquare===true
|
|
102
|
-
for(let u = 0; u <= target; u++){
|
|
103
|
-
for(let v = 0; v <=target; v++){
|
|
104
|
-
if(u**2+v**2===targetValue){
|
|
115
|
+
targetValue = targetIsSquare === true ? +target : target ** 2
|
|
116
|
+
for (let u = 0; u <= target; u++) {
|
|
117
|
+
for (let v = 0; v <= target; v++) {
|
|
118
|
+
if (u ** 2 + v ** 2 === targetValue) {
|
|
105
119
|
triplets.push([u, v, target])
|
|
106
120
|
}
|
|
107
121
|
}
|
|
@@ -110,80 +124,37 @@ export class Numeric{
|
|
|
110
124
|
return triplets
|
|
111
125
|
}
|
|
112
126
|
|
|
113
|
-
static numberCorrection(value: number, epsilonDigit:number = 1, epsilonNumberOfDigits: number = 10, number_of_digits: number = 8){
|
|
127
|
+
static numberCorrection(value: number, epsilonDigit: number = 1, epsilonNumberOfDigits: number = 10, number_of_digits: number = 8) {
|
|
114
128
|
return +value.toFixed(number_of_digits)
|
|
115
|
-
//
|
|
116
|
-
// // Must modify the number if it's like:
|
|
117
|
-
// // a: 3.0000000000000003
|
|
118
|
-
// // b: 3.9999999999999994
|
|
119
|
-
// // remove the last character
|
|
120
|
-
// // check if around n last characters are either 0 or 9
|
|
121
|
-
// // if it is, 'round' the number.
|
|
122
|
-
// function extractDecimalPart(valueToExtract: number, decimalLength: number){
|
|
123
|
-
// let decimal = valueToExtract.toString()
|
|
124
|
-
//
|
|
125
|
-
// if (!decimal.includes('.')) {
|
|
126
|
-
// return ''
|
|
127
|
-
// }
|
|
128
|
-
//
|
|
129
|
-
// decimal = decimal.split('.')[1]
|
|
130
|
-
// return decimal.substring(0, decimalLength)
|
|
131
|
-
// }
|
|
132
|
-
//
|
|
133
|
-
// const epsilon = Number(`0.${"0".repeat(epsilonNumberOfDigits-1)}${epsilonDigit}`)
|
|
134
|
-
// const decimal = extractDecimalPart(value, epsilonNumberOfDigits)
|
|
135
|
-
// if(decimal===''){return value}
|
|
136
|
-
//
|
|
137
|
-
// const n9 = decimal.match(/9+$/g)
|
|
138
|
-
// const n0 = decimal.match(/0+$/g)
|
|
139
|
-
//
|
|
140
|
-
// if (n9 && n9[0].length >= number_of_digits) {
|
|
141
|
-
// // New tested values.
|
|
142
|
-
// const mod = extractDecimalPart(value + epsilon, epsilonNumberOfDigits),
|
|
143
|
-
// mod0 = mod.match(/0+$/g)
|
|
144
|
-
//
|
|
145
|
-
// if(mod0 && mod0[0].length>= number_of_digits){
|
|
146
|
-
// return +((value+epsilon).toString().split(mod0[0])[0])
|
|
147
|
-
// }
|
|
148
|
-
// }
|
|
149
|
-
//
|
|
150
|
-
// if (n0 && n0[0].length >= number_of_digits) {
|
|
151
|
-
// // New tested values.
|
|
152
|
-
// const mod = extractDecimalPart(value - epsilon, epsilonNumberOfDigits),
|
|
153
|
-
// mod9 = mod.match(/9+$/g)
|
|
154
|
-
//
|
|
155
|
-
// if(mod9 && mod9[0].length>= number_of_digits){
|
|
156
|
-
// // The value can be changed. Remove all nines!
|
|
157
|
-
// return +(value.toString().split(n0[0])[0])
|
|
158
|
-
// }
|
|
159
|
-
// }
|
|
160
|
-
//
|
|
161
|
-
// return value
|
|
162
129
|
}
|
|
163
130
|
|
|
164
|
-
static periodic(value: number):number{
|
|
165
|
-
if(Number.isSafeInteger(value)){
|
|
131
|
+
static periodic(value: number): number {
|
|
132
|
+
if (Number.isSafeInteger(value)) {
|
|
133
|
+
return 0
|
|
134
|
+
}
|
|
166
135
|
|
|
167
136
|
// Assume it's with decimal.
|
|
168
137
|
let decimal = (value.toString()).split('.')[0]
|
|
169
138
|
|
|
170
139
|
// The decimal part is limited
|
|
171
|
-
if(decimal.length<10){
|
|
140
|
+
if (decimal.length < 10) {
|
|
141
|
+
return 0
|
|
142
|
+
}
|
|
172
143
|
|
|
173
144
|
// Find the periodic if it exists.
|
|
174
145
|
}
|
|
175
146
|
|
|
176
|
-
static decompose(value: number): number[][]{
|
|
147
|
+
static decompose(value: number): number[][] {
|
|
177
148
|
let dividers = Numeric.dividers(value),
|
|
178
149
|
limit = Math.sqrt(value),
|
|
179
150
|
arr = [],
|
|
180
151
|
u, v
|
|
181
152
|
|
|
182
|
-
while(dividers.length>0){
|
|
153
|
+
while (dividers.length > 0) {
|
|
183
154
|
u = dividers.shift()
|
|
184
|
-
v = dividers.length>0?dividers.pop()
|
|
155
|
+
v = dividers.length > 0 ? dividers.pop() : +u
|
|
185
156
|
|
|
186
|
-
arr.push([u,v])
|
|
157
|
+
arr.push([u, v])
|
|
187
158
|
}
|
|
188
159
|
|
|
189
160
|
return arr
|
|
@@ -3,6 +3,7 @@ import {rndMonom} from "./rndMonom";
|
|
|
3
3
|
import {rndHelpers} from "./rndHelpers";
|
|
4
4
|
import {
|
|
5
5
|
randomCoefficientConfig,
|
|
6
|
+
randomGeometryCircleConfig,
|
|
6
7
|
randomGeometryLineConfig,
|
|
7
8
|
randomGeometryPointConfig,
|
|
8
9
|
randomMonomConfig,
|
|
@@ -16,6 +17,8 @@ import {Line} from "../geometry/line";
|
|
|
16
17
|
import {rndGeometryLine} from "./rndGeometryLine";
|
|
17
18
|
import {Point} from "../geometry/point";
|
|
18
19
|
import {rndGeometryPoint} from "./rndGeometryPoint";
|
|
20
|
+
import {Circle} from "../geometry/circle";
|
|
21
|
+
import {rndGeometryCircle} from "./rndGeometryCircle";
|
|
19
22
|
|
|
20
23
|
export * from "./rndTypes"
|
|
21
24
|
|
|
@@ -69,5 +72,9 @@ export namespace Random {
|
|
|
69
72
|
return (new rndGeometryPoint(config).generate())
|
|
70
73
|
}
|
|
71
74
|
|
|
75
|
+
export function circle(config?: randomGeometryCircleConfig): Circle {
|
|
76
|
+
return (new rndGeometryCircle(config).generate())
|
|
77
|
+
}
|
|
78
|
+
|
|
72
79
|
}
|
|
73
80
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {randomCore} from "./randomCore";
|
|
2
|
+
import {Random, randomGeometryCircleConfig} from "./random";
|
|
3
|
+
import {Circle} from "../geometry/circle";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Create a random monom based on a based configuration
|
|
7
|
+
*/
|
|
8
|
+
export class rndGeometryCircle extends randomCore {
|
|
9
|
+
declare protected _config: randomGeometryCircleConfig
|
|
10
|
+
declare protected _defaultConfig: randomGeometryCircleConfig
|
|
11
|
+
|
|
12
|
+
generate = (): Circle => {
|
|
13
|
+
const center = Random.Geometry.point(this._config.center)
|
|
14
|
+
|
|
15
|
+
let rv, r
|
|
16
|
+
if (this._config.pointsOnCircle === 8) {
|
|
17
|
+
rv = Random.number(1, 3),
|
|
18
|
+
r = rv ** 2 + (rv + 1) ** 2
|
|
19
|
+
} else {
|
|
20
|
+
r = Random.number(1, 20)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const c = new Circle(center, r, true)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// let pts = c.getPointsOnCircle(true)
|
|
27
|
+
//
|
|
28
|
+
// pts = Random.shuffle(pts)
|
|
29
|
+
// let ptt = pts.shift(),
|
|
30
|
+
// pt1 = pts.shift(),
|
|
31
|
+
// pt2
|
|
32
|
+
//
|
|
33
|
+
// for (let pt of pts) {
|
|
34
|
+
// if (!pt1.x.isEqual(pt.x) && !pt1.y.isEqual(pt.y) && !A.isEqual(new Point().middleOf(pt1, pt))) {
|
|
35
|
+
// pt2 = pt.clone()
|
|
36
|
+
// break
|
|
37
|
+
// }
|
|
38
|
+
// }
|
|
39
|
+
|
|
40
|
+
return c
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
constructor(userConfig?: randomGeometryCircleConfig) {
|
|
45
|
+
super();
|
|
46
|
+
|
|
47
|
+
this._defaultConfig = {}
|
|
48
|
+
this._config = this.mergeConfig(userConfig, this._defaultConfig)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -4,14 +4,14 @@ export type randomCoefficientConfig = {
|
|
|
4
4
|
negative?: boolean,
|
|
5
5
|
max?: number,
|
|
6
6
|
reduced?: boolean,
|
|
7
|
-
zero?:boolean,
|
|
8
|
-
natural?:boolean
|
|
7
|
+
zero?: boolean,
|
|
8
|
+
natural?: boolean
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export type randomMonomConfig = {
|
|
12
12
|
letters?: string,
|
|
13
13
|
degree?: number,
|
|
14
|
-
fraction?: boolean|randomCoefficientConfig,
|
|
14
|
+
fraction?: boolean | randomCoefficientConfig,
|
|
15
15
|
zero?: boolean
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -29,9 +29,15 @@ export type randomGeometryLineConfig = {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
export type randomGeometryPointConfig
|
|
32
|
+
export type randomGeometryPointConfig = {
|
|
33
33
|
quadrant?: number,
|
|
34
34
|
axis?: string | boolean,
|
|
35
35
|
fraction?: boolean,
|
|
36
36
|
max?: number
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type randomGeometryCircleConfig = {
|
|
40
|
+
center?: randomGeometryPointConfig,
|
|
41
|
+
radius?: number,
|
|
42
|
+
pointsOnCircle?: number
|
|
37
43
|
}
|
|
@@ -40,7 +40,7 @@ describe('Linear systems tests', () => {
|
|
|
40
40
|
E2 = new Polynom('-6x+21y-3z')
|
|
41
41
|
|
|
42
42
|
E1.add(E2);
|
|
43
|
-
expect(E1.display).to.be.equal('42y-6z')
|
|
43
|
+
expect(E1.reduce().display).to.be.equal('42y-6z')
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
it('should use a reduced linear reducation', function () {
|
|
@@ -67,6 +67,23 @@ describe('Polynom tests', () => {
|
|
|
67
67
|
expect(euclidian.reminder.tex).to.be.equal('12')
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
+
it('should calculate the quotient and reminder with similar polynom', () => {
|
|
71
|
+
let P = new Polynom('6x^5+12x^4+3x^3+x^2-7x+6'),
|
|
72
|
+
D = new Polynom('x^3+2x^2-2x-4')
|
|
73
|
+
|
|
74
|
+
let euclidian = P.euclidian(D);
|
|
75
|
+
|
|
76
|
+
expect(euclidian.quotient.display).to.be.equal('6x^(2)+15')
|
|
77
|
+
expect(euclidian.reminder.display).to.be.equal('-5x^(2)+23x+66')
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('should reduce', () => {
|
|
81
|
+
let P = new Polynom('15x-19x+24+4x-12')
|
|
82
|
+
P.reduce()
|
|
83
|
+
expect(P.tex).to.be.equal('12')
|
|
84
|
+
|
|
85
|
+
})
|
|
86
|
+
|
|
70
87
|
it('should factorize the polynom', () => {
|
|
71
88
|
let P = new Polynom('x^2-5x+6')
|
|
72
89
|
|
|
@@ -99,7 +116,7 @@ describe('Polynom tests', () => {
|
|
|
99
116
|
expect(P2.texFactors).to.be.equal('-2x\\left( x+3 \\right)\\left( x-3 \\right)')
|
|
100
117
|
});
|
|
101
118
|
|
|
102
|
-
it('should detect if a polynom is factorized', function (){
|
|
119
|
+
it('should detect if a polynom is factorized', function () {
|
|
103
120
|
let P = new Polynom('x-1')
|
|
104
121
|
expect(P.isFactorized('x-1')).to.be.true
|
|
105
122
|
expect(P.isFactorized('x-2')).to.be.false
|
|
@@ -164,6 +181,12 @@ describe('Polynom parsing with rational power', () => {
|
|
|
164
181
|
})
|
|
165
182
|
})
|
|
166
183
|
|
|
184
|
+
describe("Polynom with multiple variables", () => {
|
|
185
|
+
it('should parse with multiple variables', () => {
|
|
186
|
+
const P = new Polynom('ax')
|
|
187
|
+
expect(P.display).to.be.equal('ax')
|
|
188
|
+
})
|
|
189
|
+
})
|
|
167
190
|
|
|
168
191
|
// describe("test simple", ()=>{
|
|
169
192
|
// it('should parce this one correctly', ()=>{
|
|
@@ -180,3 +203,141 @@ describe('Polynom parsing with rational power', () => {
|
|
|
180
203
|
// expect(P.degree().value).to.be.equal(0.5)
|
|
181
204
|
// })
|
|
182
205
|
// })
|
|
206
|
+
//
|
|
207
|
+
// describe('Polynom used as complex number', () => {
|
|
208
|
+
// let P = new Polynom('4+3i')
|
|
209
|
+
//
|
|
210
|
+
// P.pow(2)
|
|
211
|
+
//
|
|
212
|
+
// P.monoms.forEach(m => {
|
|
213
|
+
// const d = m.degree('i').value
|
|
214
|
+
// if (d >= 2) {
|
|
215
|
+
// if (d % 2 === 0) {
|
|
216
|
+
// m.coefficient = m.coefficient.multiply((-1) ** (d / 2))
|
|
217
|
+
// m.setLetter('i', 0)
|
|
218
|
+
// } else {
|
|
219
|
+
// m.coefficient = m.coefficient.multiply((-1) ** ((d - 1) / 2))
|
|
220
|
+
// m.setLetter('i', 1)
|
|
221
|
+
// }
|
|
222
|
+
// }
|
|
223
|
+
// })
|
|
224
|
+
// // console.log(P.reduce().tex)
|
|
225
|
+
//
|
|
226
|
+
// })
|
|
227
|
+
//
|
|
228
|
+
// describe("making my test", () => {
|
|
229
|
+
// let models = [
|
|
230
|
+
// {
|
|
231
|
+
// question: 'B \\cdot A^{K}=C',
|
|
232
|
+
// answer: {
|
|
233
|
+
// log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(c, b),
|
|
234
|
+
// poly: (k: Polynom, p: Polynom) => k.clone()
|
|
235
|
+
// }
|
|
236
|
+
// },
|
|
237
|
+
// {
|
|
238
|
+
// question: 'B \\cdot A^{K}=C',
|
|
239
|
+
// answer: {
|
|
240
|
+
// log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(c, b),
|
|
241
|
+
// poly: (k: Polynom, p: Polynom) => k.clone()
|
|
242
|
+
// }
|
|
243
|
+
// },
|
|
244
|
+
// {
|
|
245
|
+
// question: 'A^{K}=B \\cdot A^{P}',
|
|
246
|
+
// answer: {
|
|
247
|
+
// log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(b),
|
|
248
|
+
// poly: (k: Polynom, p: Polynom) => k.clone().subtract(p)
|
|
249
|
+
// }
|
|
250
|
+
// },
|
|
251
|
+
// {
|
|
252
|
+
// question: 'A^{K}=B \\cdot A^{P}',
|
|
253
|
+
// answer: {
|
|
254
|
+
// log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(b),
|
|
255
|
+
// poly: (k: Polynom, p: Polynom) => k.clone().subtract(p)
|
|
256
|
+
// }
|
|
257
|
+
// },
|
|
258
|
+
// {
|
|
259
|
+
// question: 'B \\cdot A^{K} = C \\cdot A^{P}',
|
|
260
|
+
// answer: {
|
|
261
|
+
// log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(c, b),
|
|
262
|
+
// poly: (k: Polynom, p: Polynom) => k.clone().subtract(p)
|
|
263
|
+
// }
|
|
264
|
+
// },
|
|
265
|
+
// {
|
|
266
|
+
// question: 'B \\cdot A^{K} = \\frac{ C }{ A^{P} }',
|
|
267
|
+
// answer: {
|
|
268
|
+
// log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(c, b),
|
|
269
|
+
// poly: (k: Polynom, p: Polynom) => k.clone().add(p)
|
|
270
|
+
// }
|
|
271
|
+
// },
|
|
272
|
+
// {
|
|
273
|
+
// question: 'C \\cdot A^{K} - B = D',
|
|
274
|
+
// answer: {
|
|
275
|
+
// log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(d + b, c),
|
|
276
|
+
// poly: (k: Polynom, p: Polynom) => k.clone()
|
|
277
|
+
// }
|
|
278
|
+
// },
|
|
279
|
+
// {
|
|
280
|
+
// question: 'C \\cdot A^{K} - B = D \\cdot A^{P} ',
|
|
281
|
+
// answer: {
|
|
282
|
+
// log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(b, c - e),
|
|
283
|
+
// poly: (k: Polynom, p: Polynom) => k.clone()
|
|
284
|
+
// }
|
|
285
|
+
// },
|
|
286
|
+
// ]
|
|
287
|
+
//
|
|
288
|
+
//
|
|
289
|
+
// for (let i = 0; i < 15; i++) {
|
|
290
|
+
// console.log(`{\\centering \\huge équations logarithmiques \\\\ }\n\nRésoudre les équations suivantes. Donner la réponse sous forme exacte et avec 4 décimales.`)
|
|
291
|
+
//
|
|
292
|
+
// console.log(`\\begin{enumerate}[(i),itemsep=4em]\n`)
|
|
293
|
+
//
|
|
294
|
+
// for (let m of models) {
|
|
295
|
+
// let a = PiMath.Random.number(2, 9),
|
|
296
|
+
// b = PiMath.Random.number(2, 9),
|
|
297
|
+
// c = PiMath.Random.number(2, 9),
|
|
298
|
+
// d = PiMath.Random.number(1, 9),
|
|
299
|
+
// e = PiMath.Random.number(1, c - 1),
|
|
300
|
+
// k = PiMath.Random.polynom({degree: 1}),
|
|
301
|
+
// p = PiMath.Random.polynom({degree: 1})
|
|
302
|
+
//
|
|
303
|
+
// if (k.monomByDegree(1).coefficient.isNegative()) {
|
|
304
|
+
// k.opposed()
|
|
305
|
+
// }
|
|
306
|
+
// if (p.monomByDegree(1).coefficient.isNegative()) {
|
|
307
|
+
// p.opposed()
|
|
308
|
+
// }
|
|
309
|
+
//
|
|
310
|
+
// let poly = m.answer.poly(k, p),
|
|
311
|
+
// pa = poly.monomByDegree(1).coefficient,
|
|
312
|
+
// pb = poly.monomByDegree(0).coefficient
|
|
313
|
+
//
|
|
314
|
+
// if (pa.isZero()) {
|
|
315
|
+
// k = k.add('x')
|
|
316
|
+
// poly = m.answer.poly(k, p),
|
|
317
|
+
// pa = poly.monomByDegree(1).coefficient,
|
|
318
|
+
// pb = poly.monomByDegree(0).coefficient
|
|
319
|
+
// }
|
|
320
|
+
//
|
|
321
|
+
// const question = m.question
|
|
322
|
+
// .replaceAll('A', a.toString())
|
|
323
|
+
// .replaceAll('B', b.toString())
|
|
324
|
+
// .replaceAll('C', c.toString())
|
|
325
|
+
// .replaceAll('D', d.toString())
|
|
326
|
+
// .replaceAll('K', k.tex)
|
|
327
|
+
// .replaceAll('P', p.tex)
|
|
328
|
+
//
|
|
329
|
+
//
|
|
330
|
+
// const log = m.answer.log(a, b, c, d, e).reduce()
|
|
331
|
+
// let answer = `\\log_{ ${a} }\\left( ${log.tex} \\right)`
|
|
332
|
+
// if (!pb.isZero()) answer = `${answer}${pb.clone().opposed().texWithSign}`
|
|
333
|
+
// if (!pa.isOne()) answer = `\\frac{ ${answer} }{ ${pa.tex} }`
|
|
334
|
+
//
|
|
335
|
+
// let value = ((Math.log10(log.value) / Math.log10(a) - pb.value) / pa.value).toFixed(4)
|
|
336
|
+
//
|
|
337
|
+
// console.log(`\\item \\(\\displaystyle ${question}\\) \\hfill \\( \\trou{ ${answer}=${value} } \\)`)
|
|
338
|
+
// }
|
|
339
|
+
//
|
|
340
|
+
// console.log(`\\end{enumerate}\n\\newpage`)
|
|
341
|
+
// }
|
|
342
|
+
//
|
|
343
|
+
// })
|