math-exercises 1.4.5 → 1.4.6
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/lib/exercises/calcul/proportionality/proportionalityTable.d.ts.map +1 -1
- package/lib/exercises/calcul/proportionality/proportionalityTable.js +8 -7
- package/lib/exercises/derivation/derivative/expDerivativeOne.d.ts.map +1 -1
- package/lib/exercises/derivation/derivative/expDerivativeOne.js +4 -2
- package/lib/exercises/derivation/derivative/thirdDegreeDerivative.d.ts.map +1 -1
- package/lib/exercises/derivation/derivative/thirdDegreeDerivative.js +5 -4
- package/lib/exercises/exercises.d.ts.map +1 -1
- package/lib/exercises/exercises.js +4 -1
- package/lib/exercises/functions/trinoms/niceRootsFromDevForm.d.ts +4 -0
- package/lib/exercises/functions/trinoms/niceRootsFromDevForm.d.ts.map +1 -0
- package/lib/exercises/functions/trinoms/niceRootsFromDevForm.js +63 -0
- package/lib/exercises/functions/trinoms/rootsFromDevForm.d.ts.map +1 -1
- package/lib/exercises/functions/trinoms/rootsFromDevForm.js +8 -3
- package/lib/exercises/geometry/cartesian/distanceBetweenTwoPoints.d.ts.map +1 -1
- package/lib/exercises/geometry/cartesian/distanceBetweenTwoPoints.js +7 -36
- package/lib/exercises/limits/rationalFracForbiddenValueLimit.d.ts.map +1 -1
- package/lib/exercises/limits/rationalFracForbiddenValueLimit.js +5 -5
- package/lib/exercises/powers/calculateNegativePower.js +1 -1
- package/lib/exercises/powers/decimalToScientific.d.ts.map +1 -1
- package/lib/exercises/powers/decimalToScientific.js +1 -2
- package/lib/exercises/powers/powersOfTenToDecimal.d.ts.map +1 -1
- package/lib/exercises/powers/powersOfTenToDecimal.js +0 -1
- package/lib/exercises/powers/powersPower.js +1 -1
- package/lib/exercises/powers/scientificToDecimal.d.ts.map +1 -1
- package/lib/exercises/powers/scientificToDecimal.js +4 -4
- package/lib/exercises/probaStat/medianList.d.ts.map +1 -1
- package/lib/exercises/probaStat/medianList.js +1 -2
- package/lib/exercises/probaStat/quartilesList.d.ts.map +1 -1
- package/lib/exercises/probaStat/quartilesList.js +1 -3
- package/lib/index.d.ts +8 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +8 -2
- package/lib/math/numbers/integer/integer.d.ts +1 -0
- package/lib/math/numbers/integer/integer.d.ts.map +1 -1
- package/lib/math/numbers/integer/integer.js +11 -0
- package/lib/math/numbers/reals/extendedRingElement.d.ts +13 -0
- package/lib/math/numbers/reals/extendedRingElement.d.ts.map +1 -0
- package/lib/math/numbers/reals/extendedRingElement.js +41 -0
- package/lib/math/numbers/reals/real.d.ts +1 -0
- package/lib/math/numbers/reals/real.d.ts.map +1 -1
- package/lib/math/numbers/reals/real.js +5 -1
- package/lib/math/polynomials/polynomial.d.ts.map +1 -1
- package/lib/math/polynomials/polynomial.js +26 -7
- package/lib/math/polynomials/trinom.d.ts.map +1 -1
- package/lib/math/polynomials/trinom.js +28 -5
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proportionalityTable.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calcul/proportionality/proportionalityTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"proportionalityTable.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calcul/proportionality/proportionalityTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAO/E,eAAO,MAAM,oBAAoB,EAAE,YAYlC,CAAC;AAEF,wBAAgB,uBAAuB,IAAI,QAAQ,CAyElD"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getProportionalityTable = exports.proportionalityTable = void 0;
|
|
4
4
|
const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
|
|
5
|
+
const integer_1 = require("../../../math/numbers/integer/integer");
|
|
5
6
|
const randint_1 = require("../../../math/utils/random/randint");
|
|
6
7
|
const shuffle_1 = require("../../../utils/shuffle");
|
|
7
8
|
const uuid_1 = require("uuid");
|
|
@@ -20,25 +21,25 @@ exports.proportionalityTable = {
|
|
|
20
21
|
};
|
|
21
22
|
function getProportionalityTable() {
|
|
22
23
|
const fact = (0, randint_1.randint)(2, 10);
|
|
23
|
-
let [x1, x2] =
|
|
24
|
+
let [x1, x2] = integer_1.IntegerConstructor.randomDifferents(1, 100 / fact, 2);
|
|
24
25
|
let [x3, x4] = [x1 * fact, x2 * fact];
|
|
25
|
-
let answer;
|
|
26
|
+
let answer = '';
|
|
26
27
|
const randQuation = (0, randint_1.randint)(0, 4);
|
|
27
28
|
switch (randQuation) {
|
|
28
29
|
case 0:
|
|
29
|
-
answer = x1;
|
|
30
|
+
answer = x1 + '';
|
|
30
31
|
x1 = '?';
|
|
31
32
|
break;
|
|
32
33
|
case 1:
|
|
33
|
-
answer = x2;
|
|
34
|
+
answer = +x2 + '';
|
|
34
35
|
x2 = '?';
|
|
35
36
|
break;
|
|
36
37
|
case 2:
|
|
37
|
-
answer = x3;
|
|
38
|
+
answer = x3 + '';
|
|
38
39
|
x3 = '?';
|
|
39
40
|
break;
|
|
40
41
|
case 3:
|
|
41
|
-
answer = x4;
|
|
42
|
+
answer = x4 + '';
|
|
42
43
|
x4 = '?';
|
|
43
44
|
break;
|
|
44
45
|
}
|
|
@@ -75,7 +76,7 @@ function getProportionalityTable() {
|
|
|
75
76
|
|${x2}|${x4}|
|
|
76
77
|
|
|
77
78
|
Déterminer le nombre manquant.`,
|
|
78
|
-
answer: answer
|
|
79
|
+
answer: answer,
|
|
79
80
|
keys: [],
|
|
80
81
|
getPropositions,
|
|
81
82
|
answerFormat: 'tex',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expDerivativeOne.d.ts","sourceRoot":"","sources":["../../../../src/exercises/derivation/derivative/expDerivativeOne.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAmC,MAAM,0BAA0B,CAAC;AAWhH,eAAO,MAAM,gBAAgB,EAAE,YAY9B,CAAC;AAEF,wBAAgB,gBAAgB,IAAI,QAAQ,
|
|
1
|
+
{"version":3,"file":"expDerivativeOne.d.ts","sourceRoot":"","sources":["../../../../src/exercises/derivation/derivative/expDerivativeOne.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAmC,MAAM,0BAA0B,CAAC;AAWhH,eAAO,MAAM,gBAAgB,EAAE,YAY9B,CAAC;AAEF,wBAAgB,gBAAgB,IAAI,QAAQ,CAwC3C"}
|
|
@@ -39,8 +39,10 @@ function getExpDerivative() {
|
|
|
39
39
|
});
|
|
40
40
|
(0, exercise_1.tryToAddWrongProp)(propositions, myfunction.toTex());
|
|
41
41
|
(0, exercise_1.tryToAddWrongProp)(propositions, (0, simplify_1.simplifyNode)(new multiplyNode_1.MultiplyNode(affine.toTree(), myfunction)).toTex());
|
|
42
|
-
(0, exercise_1.tryToAddWrongProp)(propositions, new expNode_1.ExpNode(new numberNode_1.NumberNode(
|
|
43
|
-
(0, exercise_1.tryToAddWrongProp)(propositions, (0, simplify_1.simplifyNode)(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(
|
|
42
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, new expNode_1.ExpNode(new numberNode_1.NumberNode(a)).toTex());
|
|
43
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, (0, simplify_1.simplifyNode)(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(b), myfunction)).toTex());
|
|
44
|
+
while (propositions.length < numOptions)
|
|
45
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, (0, simplify_1.simplifyNode)(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode((0, randint_1.randint)(-9, 10)), myfunction)).toTex());
|
|
44
46
|
return (0, exercise_1.shuffleProps)(propositions, numOptions);
|
|
45
47
|
};
|
|
46
48
|
const question = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thirdDegreeDerivative.d.ts","sourceRoot":"","sources":["../../../../src/exercises/derivation/derivative/thirdDegreeDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,
|
|
1
|
+
{"version":3,"file":"thirdDegreeDerivative.d.ts","sourceRoot":"","sources":["../../../../src/exercises/derivation/derivative/thirdDegreeDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAmC,MAAM,0BAA0B,CAAC;AAOhH,eAAO,MAAM,qBAAqB,EAAE,YAYnC,CAAC;AAEF,wBAAgB,wBAAwB,IAAI,QAAQ,CAmEnD"}
|
|
@@ -5,7 +5,6 @@ const exercise_1 = require("../../../exercises/exercise");
|
|
|
5
5
|
const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
|
|
6
6
|
const polynomial_1 = require("../../../math/polynomials/polynomial");
|
|
7
7
|
const randint_1 = require("../../../math/utils/random/randint");
|
|
8
|
-
const shuffle_1 = require("../../../utils/shuffle");
|
|
9
8
|
const uuid_1 = require("uuid");
|
|
10
9
|
exports.thirdDegreeDerivative = {
|
|
11
10
|
id: 'thirdDegreeDerivative',
|
|
@@ -35,8 +34,10 @@ function getThirdDegreeDerivative() {
|
|
|
35
34
|
isRightAnswer: true,
|
|
36
35
|
format: 'tex',
|
|
37
36
|
});
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
if (coefficients[2] !== 0)
|
|
38
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, new polynomial_1.Polynomial([coefficients[0], coefficients[1], coefficients[2]]).toTree().toTex());
|
|
39
|
+
if (coefficients[2] !== 0)
|
|
40
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, new polynomial_1.Polynomial([coefficients[0] + coefficients[1], coefficients[1], coefficients[2]]).toTree().toTex());
|
|
40
41
|
const missing = numOptions - propositions.length;
|
|
41
42
|
for (let i = 0; i < missing; i++) {
|
|
42
43
|
let isDuplicate;
|
|
@@ -57,7 +58,7 @@ function getThirdDegreeDerivative() {
|
|
|
57
58
|
} while (isDuplicate);
|
|
58
59
|
propositions.push(proposition);
|
|
59
60
|
}
|
|
60
|
-
return (0,
|
|
61
|
+
return (0, exercise_1.shuffleProps)(propositions, numOptions);
|
|
61
62
|
};
|
|
62
63
|
const question = {
|
|
63
64
|
instruction: `Déterminer la fonction dérivée $f'$ de la fonction $f$ définie par $f(x) = ${polynomial.toString()}$.`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exercises.d.ts","sourceRoot":"","sources":["../../src/exercises/exercises.ts"],"names":[],"mappings":"AAkLA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"exercises.d.ts","sourceRoot":"","sources":["../../src/exercises/exercises.ts"],"names":[],"mappings":"AAkLA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAW1C,eAAO,MAAM,SAAS,EAAE,YAAY,EA6QnC,CAAC"}
|
|
@@ -159,6 +159,7 @@ const firstDegreeInequationsType2_1 = require("./calculLitteral/inequations/firs
|
|
|
159
159
|
const firstDegreeInequationsType3_1 = require("./calculLitteral/inequations/firstDegreeInequationsType3");
|
|
160
160
|
const firstDegreeInequationsType0_1 = require("./calculLitteral/inequations/firstDegreeInequationsType0");
|
|
161
161
|
const chasles_1 = require("./geometry/vectors/chasles");
|
|
162
|
+
const deltaTrinom_1 = require("./functions/trinoms/deltaTrinom");
|
|
162
163
|
const rootsFromFactorizedForm_1 = require("./functions/trinoms/rootsFromFactorizedForm");
|
|
163
164
|
const rootsFromDevForm_1 = require("./functions/trinoms/rootsFromDevForm");
|
|
164
165
|
const inequalityToInterval_1 = require("./sets/intervals/inequalityToInterval");
|
|
@@ -177,6 +178,7 @@ const calculatePower_1 = require("./powers/calculatePower");
|
|
|
177
178
|
const calculateNegativePower_1 = require("./powers/calculateNegativePower");
|
|
178
179
|
const decimalToScientific_1 = require("./powers/decimalToScientific");
|
|
179
180
|
const powerDefinition_1 = require("./powers/powerDefinition");
|
|
181
|
+
const niceRootsFromDevForm_1 = require("./functions/trinoms/niceRootsFromDevForm");
|
|
180
182
|
exports.exercises = [
|
|
181
183
|
/**
|
|
182
184
|
* calcul litteral
|
|
@@ -394,9 +396,10 @@ exports.exercises = [
|
|
|
394
396
|
extremumFromCanonicalForm_1.extremumFromCanonicalForm,
|
|
395
397
|
extremumTypeFromAlgebricForm_1.extremumTypeFromAlgebricForm,
|
|
396
398
|
variationsFromAlgebricForm_1.variationsFromAlgebricForm,
|
|
397
|
-
|
|
399
|
+
deltaTrinom_1.deltaTrinom,
|
|
398
400
|
rootsFromFactorizedForm_1.rootsFromFactorizedForm,
|
|
399
401
|
rootsFromDevForm_1.rootsFromDevForm,
|
|
402
|
+
niceRootsFromDevForm_1.niceRootsFromDevForm,
|
|
400
403
|
/**Complexes */
|
|
401
404
|
mutiplyComplex_1.mutiplyComplex,
|
|
402
405
|
reAndIm_1.reAndIm,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"niceRootsFromDevForm.d.ts","sourceRoot":"","sources":["../../../../src/exercises/functions/trinoms/niceRootsFromDevForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAqB,MAAM,0BAA0B,CAAC;AAOlG,eAAO,MAAM,oBAAoB,EAAE,YAWlC,CAAC;AAEF,wBAAgB,2BAA2B,IAAI,QAAQ,CAgDtD"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRootsFromDevFormQuestion = exports.niceRootsFromDevForm = void 0;
|
|
4
|
+
const exercise_1 = require("../../../exercises/exercise");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const trinom_1 = require("../../../math/polynomials/trinom");
|
|
7
|
+
const randint_1 = require("../../../math/utils/random/randint");
|
|
8
|
+
const shuffle_1 = require("../../../utils/shuffle");
|
|
9
|
+
const uuid_1 = require("uuid");
|
|
10
|
+
exports.niceRootsFromDevForm = {
|
|
11
|
+
id: 'niceRootsFromDevForm',
|
|
12
|
+
connector: '\\iff',
|
|
13
|
+
instruction: '',
|
|
14
|
+
label: 'Résoudre une équation du second degré (solutions entières)',
|
|
15
|
+
levels: ['1reSpé', 'TermSpé', 'MathComp'],
|
|
16
|
+
isSingleStep: true,
|
|
17
|
+
sections: ['Second degré'],
|
|
18
|
+
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getRootsFromDevFormQuestion, nb),
|
|
19
|
+
qcmTimer: 60,
|
|
20
|
+
freeTimer: 60,
|
|
21
|
+
};
|
|
22
|
+
function getRootsFromDevFormQuestion() {
|
|
23
|
+
const trinom = trinom_1.TrinomConstructor.randomFactorized();
|
|
24
|
+
const answer = trinom.getRootsEquationSolutionTex();
|
|
25
|
+
const getPropositions = (n) => {
|
|
26
|
+
const res = [];
|
|
27
|
+
res.push({
|
|
28
|
+
id: (0, uuid_1.v4)(),
|
|
29
|
+
statement: answer,
|
|
30
|
+
isRightAnswer: true,
|
|
31
|
+
format: 'tex',
|
|
32
|
+
});
|
|
33
|
+
(0, exercise_1.tryToAddWrongProp)(res, 'S=\\emptyset');
|
|
34
|
+
const missing = n - res.length;
|
|
35
|
+
for (let i = 0; i < missing; i++) {
|
|
36
|
+
let isDuplicate;
|
|
37
|
+
let proposition;
|
|
38
|
+
do {
|
|
39
|
+
let wrongX1 = (0, randint_1.randint)(-19, 0);
|
|
40
|
+
let wrongX2 = (0, randint_1.randint)(0, 20);
|
|
41
|
+
const wrongAnswer = `S=\\left\\{${wrongX1};${wrongX2}\\right\\}`;
|
|
42
|
+
proposition = {
|
|
43
|
+
id: (0, uuid_1.v4)() + ``,
|
|
44
|
+
statement: wrongAnswer,
|
|
45
|
+
isRightAnswer: false,
|
|
46
|
+
format: 'tex',
|
|
47
|
+
};
|
|
48
|
+
isDuplicate = res.some((p) => p.statement === proposition.statement);
|
|
49
|
+
} while (isDuplicate);
|
|
50
|
+
res.push(proposition);
|
|
51
|
+
}
|
|
52
|
+
return (0, shuffle_1.shuffle)(res);
|
|
53
|
+
};
|
|
54
|
+
const question = {
|
|
55
|
+
answer: answer,
|
|
56
|
+
instruction: `Soit $f(x) = ${trinom.toTree().toTex()}$. Résoudre l'équation $f(x) = 0$.`,
|
|
57
|
+
keys: ['S', 'equal', 'lbrace', 'semicolon', 'rbrace', 'emptyset'],
|
|
58
|
+
getPropositions,
|
|
59
|
+
answerFormat: 'tex',
|
|
60
|
+
};
|
|
61
|
+
return question;
|
|
62
|
+
}
|
|
63
|
+
exports.getRootsFromDevFormQuestion = getRootsFromDevFormQuestion;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rootsFromDevForm.d.ts","sourceRoot":"","sources":["../../../../src/exercises/functions/trinoms/rootsFromDevForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,
|
|
1
|
+
{"version":3,"file":"rootsFromDevForm.d.ts","sourceRoot":"","sources":["../../../../src/exercises/functions/trinoms/rootsFromDevForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAqB,MAAM,0BAA0B,CAAC;AAOlG,eAAO,MAAM,gBAAgB,EAAE,YAW9B,CAAC;AAEF,wBAAgB,2BAA2B,IAAI,QAAQ,CA+CtD"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getRootsFromDevFormQuestion = exports.rootsFromDevForm = void 0;
|
|
4
|
+
const exercise_1 = require("../../../exercises/exercise");
|
|
4
5
|
const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
|
|
5
6
|
const trinom_1 = require("../../../math/polynomials/trinom");
|
|
7
|
+
const randint_1 = require("../../../math/utils/random/randint");
|
|
6
8
|
const shuffle_1 = require("../../../utils/shuffle");
|
|
7
9
|
const uuid_1 = require("uuid");
|
|
8
10
|
exports.rootsFromDevForm = {
|
|
@@ -12,7 +14,7 @@ exports.rootsFromDevForm = {
|
|
|
12
14
|
label: 'Résoudre une équation du second degré',
|
|
13
15
|
levels: ['1reSpé', 'TermSpé', 'MathComp'],
|
|
14
16
|
isSingleStep: true,
|
|
15
|
-
sections: [],
|
|
17
|
+
sections: ['Second degré'],
|
|
16
18
|
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getRootsFromDevFormQuestion, nb),
|
|
17
19
|
qcmTimer: 60,
|
|
18
20
|
freeTimer: 60,
|
|
@@ -28,12 +30,15 @@ function getRootsFromDevFormQuestion() {
|
|
|
28
30
|
isRightAnswer: true,
|
|
29
31
|
format: 'tex',
|
|
30
32
|
});
|
|
33
|
+
(0, exercise_1.tryToAddWrongProp)(res, 'S=\\emptyset');
|
|
31
34
|
const missing = n - res.length;
|
|
32
35
|
for (let i = 0; i < missing; i++) {
|
|
33
36
|
let isDuplicate;
|
|
34
37
|
let proposition;
|
|
35
38
|
do {
|
|
36
|
-
|
|
39
|
+
let wrongX1 = (0, randint_1.randint)(-19, 0);
|
|
40
|
+
let wrongX2 = (0, randint_1.randint)(0, 20);
|
|
41
|
+
const wrongAnswer = `S=\\left\\{${wrongX1};${wrongX2}\\right\\}`;
|
|
37
42
|
proposition = {
|
|
38
43
|
id: (0, uuid_1.v4)() + ``,
|
|
39
44
|
statement: wrongAnswer,
|
|
@@ -49,7 +54,7 @@ function getRootsFromDevFormQuestion() {
|
|
|
49
54
|
const question = {
|
|
50
55
|
answer: answer,
|
|
51
56
|
instruction: `Soit $f(x) = ${trinom.toTree().toTex()}$. Résoudre l'équation $f(x) = 0$.`,
|
|
52
|
-
keys: [],
|
|
57
|
+
keys: ['S', 'equal', 'lbrace', 'semicolon', 'rbrace', 'emptyset'],
|
|
53
58
|
getPropositions,
|
|
54
59
|
answerFormat: 'tex',
|
|
55
60
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distanceBetweenTwoPoints.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/cartesian/distanceBetweenTwoPoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,
|
|
1
|
+
{"version":3,"file":"distanceBetweenTwoPoints.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/cartesian/distanceBetweenTwoPoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAmC,MAAM,0BAA0B,CAAC;AAUhH,eAAO,MAAM,wBAAwB,EAAE,YAYtC,CAAC;AAEF,wBAAgB,2BAA2B,IAAI,QAAQ,CAkEtD"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDistanceBetweenTwoPoints = exports.distanceBetweenTwoPoints = void 0;
|
|
4
|
+
const exercise_1 = require("../../../exercises/exercise");
|
|
4
5
|
const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
|
|
5
6
|
const point_1 = require("../../../math/geometry/point");
|
|
6
7
|
const real_1 = require("../../../math/numbers/reals/real");
|
|
7
8
|
const randTupleInt_1 = require("../../../math/utils/random/randTupleInt");
|
|
8
9
|
const round_1 = require("../../../math/utils/round");
|
|
9
10
|
const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
|
|
10
|
-
const shuffle_1 = require("../../../utils/shuffle");
|
|
11
11
|
const uuid_1 = require("uuid");
|
|
12
12
|
exports.distanceBetweenTwoPoints = {
|
|
13
13
|
id: 'distanceBetweenTwoPoints',
|
|
@@ -30,54 +30,26 @@ function getDistanceBetweenTwoPoints() {
|
|
|
30
30
|
const getPropositions = (n) => {
|
|
31
31
|
const res = [];
|
|
32
32
|
let isDuplicate;
|
|
33
|
-
let temp = n;
|
|
34
33
|
res.push({
|
|
35
34
|
id: (0, uuid_1.v4)() + '',
|
|
36
35
|
statement: answer,
|
|
37
36
|
isRightAnswer: true,
|
|
38
37
|
format: 'tex',
|
|
39
38
|
});
|
|
40
|
-
temp--;
|
|
41
39
|
A = new point_1.Point('A', new numberNode_1.NumberNode(coords1[0]), new numberNode_1.NumberNode(coords1[1]));
|
|
42
40
|
B = new point_1.Point('B', new numberNode_1.NumberNode(-coords2[0]), new numberNode_1.NumberNode(-coords2[1]));
|
|
43
41
|
let wrongStatement = new real_1.SquareRoot((0, round_1.round)(A.distanceTo(B) ** 2, 0)).simplify().toTree().toTex();
|
|
44
|
-
|
|
45
|
-
if (!isDuplicate) {
|
|
46
|
-
res.push({
|
|
47
|
-
id: (0, uuid_1.v4)() + '',
|
|
48
|
-
statement: wrongStatement,
|
|
49
|
-
isRightAnswer: false,
|
|
50
|
-
format: 'tex',
|
|
51
|
-
});
|
|
52
|
-
temp--;
|
|
53
|
-
}
|
|
42
|
+
(0, exercise_1.tryToAddWrongProp)(res, wrongStatement);
|
|
54
43
|
A = new point_1.Point('A', new numberNode_1.NumberNode(coords1[1]), new numberNode_1.NumberNode(coords1[0]));
|
|
55
44
|
B = new point_1.Point('B', new numberNode_1.NumberNode(coords2[0]), new numberNode_1.NumberNode(coords2[1]));
|
|
56
45
|
wrongStatement = new real_1.SquareRoot((0, round_1.round)(A.distanceTo(B) ** 2, 0)).simplify().toTree().toTex();
|
|
57
|
-
|
|
58
|
-
if (n > 0 && !isDuplicate) {
|
|
59
|
-
res.push({
|
|
60
|
-
id: (0, uuid_1.v4)() + '',
|
|
61
|
-
statement: wrongStatement,
|
|
62
|
-
isRightAnswer: false,
|
|
63
|
-
format: 'tex',
|
|
64
|
-
});
|
|
65
|
-
temp--;
|
|
66
|
-
}
|
|
46
|
+
(0, exercise_1.tryToAddWrongProp)(res, wrongStatement);
|
|
67
47
|
A = new point_1.Point('A', new numberNode_1.NumberNode(coords1[0]), new numberNode_1.NumberNode(coords2[0]));
|
|
68
48
|
B = new point_1.Point('B', new numberNode_1.NumberNode(coords1[1]), new numberNode_1.NumberNode(coords2[1]));
|
|
69
49
|
wrongStatement = new real_1.SquareRoot((0, round_1.round)(A.distanceTo(B) ** 2, 0)).simplify().toTree().toTex();
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
id: (0, uuid_1.v4)() + '',
|
|
74
|
-
statement: wrongStatement,
|
|
75
|
-
isRightAnswer: false,
|
|
76
|
-
format: 'tex',
|
|
77
|
-
});
|
|
78
|
-
temp--;
|
|
79
|
-
}
|
|
80
|
-
for (let i = 0; i < temp; i++) {
|
|
50
|
+
(0, exercise_1.tryToAddWrongProp)(res, wrongStatement);
|
|
51
|
+
const missing = n - res.length;
|
|
52
|
+
for (let i = 0; i < missing; i++) {
|
|
81
53
|
let proposition;
|
|
82
54
|
do {
|
|
83
55
|
const [tempCoords1, tempsCoords2] = (0, randTupleInt_1.distinctRandTupleInt)(2, 2, { from: -9, to: 10 });
|
|
@@ -92,9 +64,8 @@ function getDistanceBetweenTwoPoints() {
|
|
|
92
64
|
isDuplicate = res.some((p) => p.statement === proposition.statement);
|
|
93
65
|
} while (isDuplicate);
|
|
94
66
|
res.push(proposition);
|
|
95
|
-
temp--;
|
|
96
67
|
}
|
|
97
|
-
return (0,
|
|
68
|
+
return (0, exercise_1.shuffleProps)(res, n);
|
|
98
69
|
};
|
|
99
70
|
const question = {
|
|
100
71
|
instruction: `Soit $${A.toTexWithCoords()}$ et $${B.toTexWithCoords()}$. Calculer la distance $AB$.`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rationalFracForbiddenValueLimit.d.ts","sourceRoot":"","sources":["../../../src/exercises/limits/rationalFracForbiddenValueLimit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,
|
|
1
|
+
{"version":3,"file":"rationalFracForbiddenValueLimit.d.ts","sourceRoot":"","sources":["../../../src/exercises/limits/rationalFracForbiddenValueLimit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAmC,MAAM,0BAA0B,CAAC;AAchH,eAAO,MAAM,+BAA+B,EAAE,YAW7C,CAAC;AAEF,wBAAgB,oCAAoC,IAAI,QAAQ,CAoE/D"}
|
|
@@ -10,7 +10,6 @@ const discreteSet_1 = require("../../math/sets/discreteSet");
|
|
|
10
10
|
const intervals_1 = require("../../math/sets/intervals/intervals");
|
|
11
11
|
const randint_1 = require("../../math/utils/random/randint");
|
|
12
12
|
const coinFlip_1 = require("../../utils/coinFlip");
|
|
13
|
-
const shuffle_1 = require("../../utils/shuffle");
|
|
14
13
|
const uuid_1 = require("uuid");
|
|
15
14
|
exports.rationalFracForbiddenValueLimit = {
|
|
16
15
|
id: 'rationalFracForbiddenValueLimit',
|
|
@@ -28,14 +27,15 @@ function getSequenceRationalFracLimitQuestion() {
|
|
|
28
27
|
const polyDenum = new affine_1.Affine(1, (0, randint_1.randint)(-9, 10, [0]));
|
|
29
28
|
const forbiddenValue = -polyDenum.b;
|
|
30
29
|
const interval = new intervals_1.Interval('[[-10;10]]').difference(new discreteSet_1.DiscreteSet([new integer_1.Integer(forbiddenValue)]));
|
|
31
|
-
const
|
|
30
|
+
const intervalStar = new intervals_1.Interval('[[-10;10]]').difference(new discreteSet_1.DiscreteSet([new integer_1.Integer(0)]));
|
|
31
|
+
const polyNum = trinom_1.TrinomConstructor.randomFactorized(intervalStar, interval, interval);
|
|
32
32
|
const numLimit = polyNum.calculate(-polyDenum.b);
|
|
33
33
|
const getSign = (nb) => {
|
|
34
34
|
return nb >= 0 ? '+' : '-';
|
|
35
35
|
};
|
|
36
36
|
const isRight = (0, coinFlip_1.coinFlip)();
|
|
37
37
|
const to = isRight ? `${forbiddenValue}` : `${forbiddenValue}`;
|
|
38
|
-
const from = isRight ? `x
|
|
38
|
+
const from = isRight ? `x>${forbiddenValue}` : `x<${forbiddenValue}`;
|
|
39
39
|
const answer = isRight ? `${getSign(numLimit)}\\infty` : `${getSign(-numLimit)}\\infty`;
|
|
40
40
|
const getPropositions = (n) => {
|
|
41
41
|
const res = [];
|
|
@@ -65,13 +65,13 @@ function getSequenceRationalFracLimitQuestion() {
|
|
|
65
65
|
} while (isDuplicate);
|
|
66
66
|
res.push(proposition);
|
|
67
67
|
}
|
|
68
|
-
return (0,
|
|
68
|
+
return (0, exercise_1.shuffleProps)(res, n);
|
|
69
69
|
};
|
|
70
70
|
const question = {
|
|
71
71
|
answer,
|
|
72
72
|
instruction: `Soit $f$ la fonction définie par : $f(x) = \\dfrac{${polyNum.toTree().toTex()}}{${polyDenum
|
|
73
73
|
.toTree()
|
|
74
|
-
.toTex()}}$. Déterminer $\\lim\\limits_{x \\to ${to}, ${from}}f(x).$
|
|
74
|
+
.toTex()}}$. Déterminer $\\lim\\limits_{x \\to ${to}, \\ ${from}}f(x).$
|
|
75
75
|
`,
|
|
76
76
|
keys: ['infty'],
|
|
77
77
|
getPropositions,
|
|
@@ -24,7 +24,7 @@ function getCalculatePowerQuestion() {
|
|
|
24
24
|
const int = (0, randint_1.randint)(0, 11);
|
|
25
25
|
const power = (0, randint_1.randint)(-5, 0);
|
|
26
26
|
const statement = new powerNode_1.PowerNode(new numberNode_1.NumberNode(int), new numberNode_1.NumberNode(power)).toTex();
|
|
27
|
-
const answer = new rational_1.Rational(1, int ** Math.abs(power)).simplify().toTree().toTex();
|
|
27
|
+
const answer = int === 0 ? '0' : new rational_1.Rational(1, int ** Math.abs(power)).simplify().toTree().toTex();
|
|
28
28
|
const getPropositions = (n) => {
|
|
29
29
|
const res = [];
|
|
30
30
|
res.push({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decimalToScientific.d.ts","sourceRoot":"","sources":["../../../src/exercises/powers/decimalToScientific.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAmC,MAAM,aAAa,CAAC;AAInG,eAAO,MAAM,mBAAmB,EAAE,YA0BjC,CAAC;AAEF,wBAAgB,8BAA8B,IAAI,QAAQ,
|
|
1
|
+
{"version":3,"file":"decimalToScientific.d.ts","sourceRoot":"","sources":["../../../src/exercises/powers/decimalToScientific.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAmC,MAAM,aAAa,CAAC;AAInG,eAAO,MAAM,mBAAmB,EAAE,YA0BjC,CAAC;AAEF,wBAAgB,8BAA8B,IAAI,QAAQ,CAwDzD"}
|
|
@@ -15,7 +15,7 @@ exports.decimalToScientific = {
|
|
|
15
15
|
id: 'decimalToScientific',
|
|
16
16
|
connector: '=',
|
|
17
17
|
instruction: '',
|
|
18
|
-
label: "Passer d'écriture
|
|
18
|
+
label: "Passer d'écriture décimale à écriture scientifique",
|
|
19
19
|
levels: [
|
|
20
20
|
'5ème',
|
|
21
21
|
'4ème',
|
|
@@ -38,7 +38,6 @@ exports.decimalToScientific = {
|
|
|
38
38
|
freeTimer: 60,
|
|
39
39
|
};
|
|
40
40
|
function getDecimalToScientificQuestion() {
|
|
41
|
-
//! manque le cas 0.000
|
|
42
41
|
const isZero = (0, probaFlip_1.probaFlip)(0.2);
|
|
43
42
|
let intPart, dec;
|
|
44
43
|
if (isZero) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"powersOfTenToDecimal.d.ts","sourceRoot":"","sources":["../../../src/exercises/powers/powersOfTenToDecimal.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIlE,eAAO,MAAM,oBAAoB,EAAE,YA0BlC,CAAC;AAEF,wBAAgB,+BAA+B,IAAI,QAAQ,
|
|
1
|
+
{"version":3,"file":"powersOfTenToDecimal.d.ts","sourceRoot":"","sources":["../../../src/exercises/powers/powersOfTenToDecimal.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIlE,eAAO,MAAM,oBAAoB,EAAE,YA0BlC,CAAC;AAEF,wBAAgB,+BAA+B,IAAI,QAAQ,CAkD1D"}
|
|
@@ -57,7 +57,6 @@ function getPowersOfTenToDecimalQuestion() {
|
|
|
57
57
|
const wrongPower = randPower + (0, randint_1.randint)(-3, 4, [0]);
|
|
58
58
|
const wrongAnswerTree = new power_1.Power(10, wrongPower).toDecimalWriting().toTree();
|
|
59
59
|
const wrongAnswer = wrongAnswerTree.toTex();
|
|
60
|
-
console.log(wrongPower, wrongAnswer);
|
|
61
60
|
proposition = {
|
|
62
61
|
id: (0, uuid_1.v4)() + '',
|
|
63
62
|
statement: wrongAnswer,
|
|
@@ -37,7 +37,7 @@ exports.powersPower = {
|
|
|
37
37
|
freeTimer: 60,
|
|
38
38
|
};
|
|
39
39
|
function getPowersPowerQuestion(useOnlyPowersOfTen = false) {
|
|
40
|
-
const a = useOnlyPowersOfTen ? 10 : (0, randint_1.randint)(-11, 11);
|
|
40
|
+
const a = useOnlyPowersOfTen ? 10 : (0, randint_1.randint)(-11, 11, [0, 1]);
|
|
41
41
|
const [b, c] = [1, 2].map((el) => (0, randint_1.randint)(-11, 11));
|
|
42
42
|
const statement = new powerNode_1.PowerNode(new powerNode_1.PowerNode(new numberNode_1.NumberNode(a), new numberNode_1.NumberNode(b)), new numberNode_1.NumberNode(c));
|
|
43
43
|
let answerTree = new power_1.Power(a, b * c).simplify();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scientificToDecimal.d.ts","sourceRoot":"","sources":["../../../src/exercises/powers/scientificToDecimal.ts"],"names":[],"mappings":"AAAA;;MAEM;AASN,OAAO,EAAE,YAAY,EAAe,QAAQ,
|
|
1
|
+
{"version":3,"file":"scientificToDecimal.d.ts","sourceRoot":"","sources":["../../../src/exercises/powers/scientificToDecimal.ts"],"names":[],"mappings":"AAAA;;MAEM;AASN,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAmC,MAAM,aAAa,CAAC;AAInG,eAAO,MAAM,mBAAmB,EAAE,YA0BjC,CAAC;AAEF,wBAAgB,8BAA8B,IAAI,QAAQ,CAqDzD"}
|
|
@@ -9,7 +9,6 @@ const randint_1 = require("../../math/utils/random/randint");
|
|
|
9
9
|
const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
|
|
10
10
|
const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
|
|
11
11
|
const powerNode_1 = require("../../tree/nodes/operators/powerNode");
|
|
12
|
-
const shuffle_1 = require("../../utils/shuffle");
|
|
13
12
|
const exercise_1 = require("../exercise");
|
|
14
13
|
const getDistinctQuestions_1 = require("../utils/getDistinctQuestions");
|
|
15
14
|
const uuid_1 = require("uuid");
|
|
@@ -17,7 +16,7 @@ exports.scientificToDecimal = {
|
|
|
17
16
|
id: 'scientificToDecimal',
|
|
18
17
|
connector: '=',
|
|
19
18
|
instruction: '',
|
|
20
|
-
label: "Passer d'écriture scientifique à écriture
|
|
19
|
+
label: "Passer d'écriture scientifique à écriture décimale",
|
|
21
20
|
levels: [
|
|
22
21
|
'5ème',
|
|
23
22
|
'4ème',
|
|
@@ -53,7 +52,8 @@ function getScientificToDecimalQuestion() {
|
|
|
53
52
|
format: 'tex',
|
|
54
53
|
});
|
|
55
54
|
(0, exercise_1.tryToAddWrongProp)(res, decScientific.multiplyByPowerOfTen(-tenPower).toTree().toTex());
|
|
56
|
-
|
|
55
|
+
const missing = n - res.length;
|
|
56
|
+
for (let i = 0; i < missing; i++) {
|
|
57
57
|
let isDuplicate;
|
|
58
58
|
let proposition;
|
|
59
59
|
do {
|
|
@@ -69,7 +69,7 @@ function getScientificToDecimalQuestion() {
|
|
|
69
69
|
} while (isDuplicate);
|
|
70
70
|
res.push(proposition);
|
|
71
71
|
}
|
|
72
|
-
return (0,
|
|
72
|
+
return (0, exercise_1.shuffleProps)(res, n);
|
|
73
73
|
};
|
|
74
74
|
const question = {
|
|
75
75
|
instruction: `Donner l'écriture décimale de : $${statement.toTex()}$`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"medianList.d.ts","sourceRoot":"","sources":["../../../src/exercises/probaStat/medianList.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAe,QAAQ,
|
|
1
|
+
{"version":3,"file":"medianList.d.ts","sourceRoot":"","sources":["../../../src/exercises/probaStat/medianList.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAmC,MAAM,aAAa,CAAC;AAInG,eAAO,MAAM,cAAc,EAAE,YAY5B,CAAC;AAEF,wBAAgB,aAAa,IAAI,QAAQ,CA8DxC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getMedianList = exports.medianWithList = void 0;
|
|
4
4
|
const randint_1 = require("../../math/utils/random/randint");
|
|
5
|
-
const shuffle_1 = require("../../utils/shuffle");
|
|
6
5
|
const exercise_1 = require("../exercise");
|
|
7
6
|
const getDistinctQuestions_1 = require("../utils/getDistinctQuestions");
|
|
8
7
|
const uuid_1 = require("uuid");
|
|
@@ -57,7 +56,7 @@ function getMedianList() {
|
|
|
57
56
|
} while (isDuplicate);
|
|
58
57
|
res.push(proposition);
|
|
59
58
|
}
|
|
60
|
-
return (0,
|
|
59
|
+
return (0, exercise_1.shuffleProps)(res, n);
|
|
61
60
|
};
|
|
62
61
|
const question = {
|
|
63
62
|
instruction: `On considère la liste suivante : $${randomValeurs.join(';\\ ')}.$
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quartilesList.d.ts","sourceRoot":"","sources":["../../../src/exercises/probaStat/quartilesList.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAe,QAAQ,
|
|
1
|
+
{"version":3,"file":"quartilesList.d.ts","sourceRoot":"","sources":["../../../src/exercises/probaStat/quartilesList.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAmC,MAAM,aAAa,CAAC;AAInG,eAAO,MAAM,aAAa,EAAE,YAY3B,CAAC;AAEF,wBAAgB,YAAY,IAAI,QAAQ,CAqFvC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getQuartiles = exports.quartilesList = void 0;
|
|
4
4
|
const randint_1 = require("../../math/utils/random/randint");
|
|
5
|
-
const shuffle_1 = require("../../utils/shuffle");
|
|
6
5
|
const exercise_1 = require("../exercise");
|
|
7
6
|
const getDistinctQuestions_1 = require("../utils/getDistinctQuestions");
|
|
8
7
|
const uuid_1 = require("uuid");
|
|
@@ -70,12 +69,11 @@ function getQuartiles() {
|
|
|
70
69
|
isRightAnswer: false,
|
|
71
70
|
format: 'tex',
|
|
72
71
|
};
|
|
73
|
-
console.log('iter', randomValeurs);
|
|
74
72
|
isDuplicate = res.some((p) => p.statement === proposition.statement);
|
|
75
73
|
} while (isDuplicate);
|
|
76
74
|
res.push(proposition);
|
|
77
75
|
}
|
|
78
|
-
return (0,
|
|
76
|
+
return (0, exercise_1.shuffleProps)(res, n);
|
|
79
77
|
};
|
|
80
78
|
const question = {
|
|
81
79
|
instruction: `On considère la liste suivante : $${randomValeurs.join(';\\ ')}.$
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { MathExercise, MathSection } from './exercises/exercise';
|
|
2
|
+
/**
|
|
3
|
+
* TODO
|
|
4
|
+
* Décimal : permettre facilement -0.xxx
|
|
5
|
+
* Tree shaking export
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
|
|
9
|
+
*/
|
|
2
10
|
declare const allMathExercises: MathExercise[];
|
|
3
11
|
declare const getAllMathExercisesBySection: () => {
|
|
4
12
|
section: MathSection;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIjE,QAAA,MAAM,gBAAgB,gBAAiB,CAAC;AAExC,QAAA,MAAM,4BAA4B;aACT,WAAW;UAAQ,YAAY,EAAE;GAkBzD,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIjE;;;;;;;EAOE;AACF,QAAA,MAAM,gBAAgB,gBAAiB,CAAC;AAExC,QAAA,MAAM,4BAA4B;aACT,WAAW;UAAQ,YAAY,EAAE;GAkBzD,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -2,7 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAllMathExercisesBySection = exports.allMathExercises = void 0;
|
|
4
4
|
const exercises_1 = require("./exercises/exercises");
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* TODO
|
|
7
|
+
* Décimal : permettre facilement -0.xxx
|
|
8
|
+
* Tree shaking export
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
|
|
12
|
+
*/
|
|
6
13
|
const allMathExercises = [...exercises_1.exercises];
|
|
7
14
|
exports.allMathExercises = allMathExercises;
|
|
8
15
|
const getAllMathExercisesBySection = () => {
|
|
@@ -24,4 +31,3 @@ const getAllMathExercisesBySection = () => {
|
|
|
24
31
|
return data;
|
|
25
32
|
};
|
|
26
33
|
exports.getAllMathExercisesBySection = getAllMathExercisesBySection;
|
|
27
|
-
console.log(decimalToScientific_1.decimalToScientific.generator(10).forEach((q) => q.getPropositions(4)));
|
|
@@ -3,6 +3,7 @@ import { Nombre, NumberType } from '../nombre';
|
|
|
3
3
|
export declare abstract class IntegerConstructor {
|
|
4
4
|
static random(nbOfDigits: number, excludes?: number[]): number;
|
|
5
5
|
static randomPrime(max?: number): number;
|
|
6
|
+
static randomDifferents(min: number, max: number, nb: number, excludes?: number[]): number[];
|
|
6
7
|
}
|
|
7
8
|
export declare class Integer implements Nombre {
|
|
8
9
|
value: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integer.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/integer/integer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAG7C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAI/C,8BAAsB,kBAAkB;IACtC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE;IAGrD,MAAM,CAAC,WAAW,CAAC,GAAG,GAAE,MAAW;
|
|
1
|
+
{"version":3,"file":"integer.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/integer/integer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAG7C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAI/C,8BAAsB,kBAAkB;IACtC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE;IAGrD,MAAM,CAAC,WAAW,CAAC,GAAG,GAAE,MAAW;IAGnC,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE;CAWlF;AAED,qBAAa,OAAQ,YAAW,MAAM;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;gBAEL,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;IAMvC,MAAM,IAAI,IAAI;IAId,KAAK,CAAC,SAAS,EAAE,MAAM;IAiCvB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;CAW3B"}
|
|
@@ -14,6 +14,17 @@ class IntegerConstructor {
|
|
|
14
14
|
static randomPrime(max = 20) {
|
|
15
15
|
return (0, random_1.random)(primes_1.primes.filter((p) => p < 20));
|
|
16
16
|
}
|
|
17
|
+
static randomDifferents(min, max, nb, excludes) {
|
|
18
|
+
const res = [];
|
|
19
|
+
for (let i = 0; i < nb; i++) {
|
|
20
|
+
let newNb;
|
|
21
|
+
do {
|
|
22
|
+
newNb = (0, randint_1.randint)(min, max, excludes);
|
|
23
|
+
} while (res.includes(newNb));
|
|
24
|
+
res.push(newNb);
|
|
25
|
+
}
|
|
26
|
+
return res;
|
|
27
|
+
}
|
|
17
28
|
}
|
|
18
29
|
exports.IntegerConstructor = IntegerConstructor;
|
|
19
30
|
class Integer {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Nombre } from '../nombre';
|
|
2
|
+
/**
|
|
3
|
+
* element of Q(x)
|
|
4
|
+
* exp 2+3sqrt(5)
|
|
5
|
+
*/
|
|
6
|
+
export declare class ExtendedRingElement {
|
|
7
|
+
a: number;
|
|
8
|
+
b: number;
|
|
9
|
+
algebraicElement: Nombre;
|
|
10
|
+
constructor(a: number, b: number, algebraicElement: Nombre);
|
|
11
|
+
toTree(): import("../../../tree/nodes/node").Node;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=extendedRingElement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extendedRingElement.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/reals/extendedRingElement.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;GAGG;AACH,qBAAa,mBAAmB;IAM9B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,gBAAgB,EAAE,MAAM,CAAC;gBACb,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM;IAM1D,MAAM;CAeP"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExtendedRingElement = void 0;
|
|
4
|
+
const oppositeNode_1 = require("../../../tree/nodes/functions/oppositeNode");
|
|
5
|
+
const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
|
|
6
|
+
const addNode_1 = require("../../../tree/nodes/operators/addNode");
|
|
7
|
+
const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
|
|
8
|
+
const substractNode_1 = require("../../../tree/nodes/operators/substractNode");
|
|
9
|
+
/**
|
|
10
|
+
* element of Q(x)
|
|
11
|
+
* exp 2+3sqrt(5)
|
|
12
|
+
*/
|
|
13
|
+
class ExtendedRingElement {
|
|
14
|
+
constructor(a, b, algebraicElement) {
|
|
15
|
+
this.a = a;
|
|
16
|
+
this.b = b;
|
|
17
|
+
this.algebraicElement = algebraicElement;
|
|
18
|
+
}
|
|
19
|
+
toTree() {
|
|
20
|
+
if (this.b === 0) {
|
|
21
|
+
return new numberNode_1.NumberNode(this.a);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
if (this.a === 0) {
|
|
25
|
+
if (this.b === 1)
|
|
26
|
+
return this.algebraicElement.toTree();
|
|
27
|
+
if (this.b === -1)
|
|
28
|
+
return new oppositeNode_1.OppositeNode(this.algebraicElement.toTree());
|
|
29
|
+
return new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(this.b), this.algebraicElement.toTree());
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
if (this.b === 1)
|
|
33
|
+
return new addNode_1.AddNode(new numberNode_1.NumberNode(this.a), this.algebraicElement.toTree());
|
|
34
|
+
if (this.b === -1)
|
|
35
|
+
return new substractNode_1.SubstractNode(new numberNode_1.NumberNode(this.a), this.algebraicElement.toTree());
|
|
36
|
+
return new addNode_1.AddNode(new numberNode_1.NumberNode(this.a), this.algebraicElement.toTree());
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.ExtendedRingElement = ExtendedRingElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"real.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/reals/real.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAQ7C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,8BAAsB,eAAe;IACnC,MAAM,CAAC,MAAM;CAUd;AACD,qBAAa,IAAK,YAAW,MAAM;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;gBACL,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAKtC,MAAM,IAAI,IAAI;CAIf;AAED,8BAAsB,qBAAqB;IACzC;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,EAAE,kBAA0B,EAAE,SAAc,EAAE;;;KAAA,GAAG,UAAU;IASrF,MAAM,CAAC,kBAAkB,CAAC,GAAG,GAAE,MAAW,GAAG,UAAU;CAIxD;AAED,qBAAa,UAAW,SAAQ,IAAI;IAClC,OAAO,EAAE,MAAM,CAAC;gBACJ,OAAO,EAAE,MAAM;IAK3B,QAAQ,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"real.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/reals/real.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAQ7C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,8BAAsB,eAAe;IACnC,MAAM,CAAC,MAAM;CAUd;AACD,qBAAa,IAAK,YAAW,MAAM;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;gBACL,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAKtC,MAAM,IAAI,IAAI;CAIf;AAED,8BAAsB,qBAAqB;IACzC;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,EAAE,kBAA0B,EAAE,SAAc,EAAE;;;KAAA,GAAG,UAAU;IASrF,MAAM,CAAC,kBAAkB,CAAC,GAAG,GAAE,MAAW,GAAG,UAAU;CAIxD;AAED,qBAAa,UAAW,SAAQ,IAAI;IAClC,OAAO,EAAE,MAAM,CAAC;gBACJ,OAAO,EAAE,MAAM;IAK3B,mBAAmB,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;IAevC,QAAQ,IAAI,IAAI;IAoBhB,KAAK,IAAI,MAAM;IAIf,MAAM,IAAI,IAAI;CAGf"}
|
|
@@ -62,7 +62,7 @@ class SquareRoot extends Real {
|
|
|
62
62
|
super(Math.sqrt(operand), `\\sqrt{${operand}}`);
|
|
63
63
|
this.operand = operand;
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
getSimplifiedCoeffs() {
|
|
66
66
|
const factors = (0, primeFactors_1.primeFactors)(this.operand);
|
|
67
67
|
// finds primes with even exponents
|
|
68
68
|
const multiples = [1];
|
|
@@ -75,6 +75,10 @@ class SquareRoot extends Real {
|
|
|
75
75
|
}
|
|
76
76
|
const outsideSqrt = multiples.reduce((x, y) => x * y);
|
|
77
77
|
const insideSqrt = factors.length === 0 ? 1 : factors.reduce((x, y) => x * y);
|
|
78
|
+
return [outsideSqrt, insideSqrt];
|
|
79
|
+
}
|
|
80
|
+
simplify() {
|
|
81
|
+
const [outsideSqrt, insideSqrt] = this.getSimplifiedCoeffs();
|
|
78
82
|
const simplified = insideSqrt !== 1
|
|
79
83
|
? new Real(outsideSqrt * Math.sqrt(insideSqrt), `${outsideSqrt === 1 ? '' : `${outsideSqrt}`}\\sqrt{${insideSqrt}}`)
|
|
80
84
|
: new Real(outsideSqrt, outsideSqrt + '');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polynomial.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/polynomial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAW7C,8BAAsB,qBAAqB;IACzC,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IAa5D,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IActD,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IAmBhF,MAAM,CAAC,4BAA4B,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IAmB5F,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,GAAG,UAAU,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;CAyBzG;AAED,qBAAa,UAAU;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IAEvB;;;;OAIG;gBACS,YAAY,EAAE,MAAM,EAAE,EAAE,QAAQ,GAAE,MAAY;IAS1D,MAAM,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO;IAG9B,QAAQ,IAAI,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"polynomial.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/polynomial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAW7C,8BAAsB,qBAAqB;IACzC,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IAa5D,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IActD,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IAmBhF,MAAM,CAAC,4BAA4B,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IAmB5F,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,GAAG,UAAU,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;CAyBzG;AAED,qBAAa,UAAU;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IAEvB;;;;OAIG;gBACS,YAAY,EAAE,MAAM,EAAE,EAAE,QAAQ,GAAE,MAAY;IAS1D,MAAM,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO;IAG9B,QAAQ,IAAI,MAAM,EAAE;IAkCpB,GAAG,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU;IAkB9B,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU;IAO7B,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU;IAsBnC,QAAQ,IAAI,UAAU;IAOtB,QAAQ,IAAI,UAAU;IAQtB,SAAS,IAAI,UAAU;IAMvB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAM5B,QAAQ,CAAC,EAAE,EAAE,UAAU,GAAG,UAAU,GAAG,MAAM;IAiB7C,MAAM,IAAI,IAAI;IAmCd,KAAK,IAAI,MAAM;IAkBf,QAAQ,IAAI,MAAM;CAGnB"}
|
|
@@ -108,7 +108,7 @@ class Polynomial {
|
|
|
108
108
|
constructor(coefficients, variable = 'x') {
|
|
109
109
|
if (coefficients.length === 0)
|
|
110
110
|
throw Error('coeffs must be not null');
|
|
111
|
-
if (coefficients[coefficients.length - 1] === 0) {
|
|
111
|
+
if (coefficients.length > 1 && coefficients[coefficients.length - 1] === 0) {
|
|
112
112
|
throw Error('n-th coeff must be not null');
|
|
113
113
|
}
|
|
114
114
|
this.coefficients = coefficients;
|
|
@@ -120,6 +120,9 @@ class Polynomial {
|
|
|
120
120
|
}
|
|
121
121
|
getRoots() {
|
|
122
122
|
const roots = [];
|
|
123
|
+
if (this.degree === 0) {
|
|
124
|
+
return this.coefficients[0] === 0 ? [0] : [];
|
|
125
|
+
}
|
|
123
126
|
if (this.degree === 1) {
|
|
124
127
|
// Polynôme de degré 1 : ax + b = 0
|
|
125
128
|
const a = this.coefficients[1];
|
|
@@ -144,22 +147,32 @@ class Polynomial {
|
|
|
144
147
|
}
|
|
145
148
|
else {
|
|
146
149
|
//méthode de Newton-Raphson ou des bibliothèques de calcul symbolique pour obtenir les racines.
|
|
150
|
+
throw Error('general roots not implemented yet');
|
|
147
151
|
}
|
|
148
152
|
return roots.sort((a, b) => a - b);
|
|
149
153
|
}
|
|
150
154
|
add(P) {
|
|
151
155
|
if (P.variable !== this.variable)
|
|
152
156
|
throw Error("Can't add two polynomials with different variables");
|
|
153
|
-
const
|
|
154
|
-
? P.degree - 1
|
|
155
|
-
: Math.max(P.degree, this.degree);
|
|
157
|
+
const maxDegree = Math.max(P.degree, this.degree);
|
|
156
158
|
const res = [];
|
|
157
|
-
for (let i = 0; i <
|
|
159
|
+
for (let i = 0; i < maxDegree + 1; i++) {
|
|
158
160
|
res[i] = (P.coefficients[i] ?? 0) + (this.coefficients[i] ?? 0);
|
|
159
161
|
}
|
|
160
|
-
|
|
162
|
+
let firstNonZeroIndex = res.length;
|
|
163
|
+
for (let i = res.length - 1; i > -1; i--) {
|
|
164
|
+
if (res[i] !== 0)
|
|
165
|
+
break;
|
|
166
|
+
firstNonZeroIndex = i;
|
|
167
|
+
}
|
|
168
|
+
let coeffs = res.slice(0, firstNonZeroIndex);
|
|
169
|
+
if (!coeffs.length)
|
|
170
|
+
coeffs = [0];
|
|
171
|
+
return new Polynomial(coeffs, this.variable);
|
|
161
172
|
}
|
|
162
173
|
times(nb) {
|
|
174
|
+
if (nb === 0)
|
|
175
|
+
return new Polynomial([0], this.variable);
|
|
163
176
|
return new Polynomial(this.coefficients.map((coeff) => coeff * nb), this.variable);
|
|
164
177
|
}
|
|
165
178
|
multiply(Q) {
|
|
@@ -175,7 +188,13 @@ class Polynomial {
|
|
|
175
188
|
}
|
|
176
189
|
res[k] = sum;
|
|
177
190
|
}
|
|
178
|
-
|
|
191
|
+
let firstNonZeroIndex = res.length;
|
|
192
|
+
for (let i = res.length - 1; i > -1; i--) {
|
|
193
|
+
if (res[i] !== 0)
|
|
194
|
+
break;
|
|
195
|
+
firstNonZeroIndex = i;
|
|
196
|
+
}
|
|
197
|
+
return new Polynomial(res.slice(0, firstNonZeroIndex), this.variable);
|
|
179
198
|
}
|
|
180
199
|
opposite() {
|
|
181
200
|
return new Polynomial(this.coefficients.map((coeff) => -coeff), this.variable);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trinom.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/trinom.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"trinom.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/trinom.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAgBjE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,8BAAsB,iBAAiB;IACrC,MAAM,CAAC,MAAM,CACX,OAAO,GAAE,OAAmF,EAC5F,OAAO,GAAE,OAAqC,EAC9C,OAAO,GAAE,OAAqC,GAC7C,MAAM;IAQT,MAAM,CAAC,eAAe,CACpB,OAAO,GAAE,OAAmF,EAC5F,WAAW,GAAE,OAAqC,EAClD,UAAU,GAAE,OAAqC,GAChD,MAAM;IAST,MAAM,CAAC,gBAAgB,CACrB,OAAO,GAAE,OAAmF,EAC5F,QAAQ,GAAE,OAAqC,EAC/C,QAAQ,GAAE,OAAqC,GAC9C,MAAM;CASV;AAED,qBAAa,MAAO,SAAQ,UAAU;IACpC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;gBACL,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IAQnE,QAAQ;IAGR,YAAY,IAAI,UAAU;IAI1B,QAAQ;IAOR,YAAY,IAAI,IAAI,EAAE;IAiCtB,2BAA2B;IAO3B,QAAQ;IAGR,YAAY,IAAI,IAAI;IAIpB,OAAO;IAIP,WAAW,IAAI,IAAI;IAInB,iBAAiB,IAAI,IAAI;IAqBzB,gBAAgB,IAAI,IAAI;IAYxB,SAAS;CAGV"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Trinom = exports.TrinomConstructor = void 0;
|
|
4
|
+
const sqrtNode_1 = require("../../tree/nodes/functions/sqrtNode");
|
|
4
5
|
const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
|
|
5
6
|
const addNode_1 = require("../../tree/nodes/operators/addNode");
|
|
6
7
|
const fractionNode_1 = require("../../tree/nodes/operators/fractionNode");
|
|
@@ -9,6 +10,7 @@ const powerNode_1 = require("../../tree/nodes/operators/powerNode");
|
|
|
9
10
|
const substractNode_1 = require("../../tree/nodes/operators/substractNode");
|
|
10
11
|
const variableNode_1 = require("../../tree/nodes/variables/variableNode");
|
|
11
12
|
const simplify_1 = require("../../tree/parsers/simplify");
|
|
13
|
+
const mathjs_1 = require("mathjs");
|
|
12
14
|
const point_1 = require("../geometry/point");
|
|
13
15
|
const integer_1 = require("../numbers/integer/integer");
|
|
14
16
|
const rational_1 = require("../numbers/rationals/rational");
|
|
@@ -16,6 +18,7 @@ const real_1 = require("../numbers/reals/real");
|
|
|
16
18
|
const discreteSet_1 = require("../sets/discreteSet");
|
|
17
19
|
const intervals_1 = require("../sets/intervals/intervals");
|
|
18
20
|
const polynomial_1 = require("./polynomial");
|
|
21
|
+
const oppositeNode_1 = require("../../tree/nodes/functions/oppositeNode");
|
|
19
22
|
class TrinomConstructor {
|
|
20
23
|
static random(domainA = new intervals_1.Interval('[[-10; 10]]').difference(new discreteSet_1.DiscreteSet([new integer_1.Integer(0)])), domainB = new intervals_1.Interval('[[-10; 10]]'), domainC = new intervals_1.Interval('[[-10; 10]]')) {
|
|
21
24
|
const a = domainA.getRandomElement();
|
|
@@ -68,17 +71,37 @@ class Trinom extends polynomial_1.Polynomial {
|
|
|
68
71
|
return [-this.b / (2 * this.a)];
|
|
69
72
|
return [(-this.b - Math.sqrt(delta)) / (2 * this.a), (-this.b + Math.sqrt(delta)) / (2 * this.a)];
|
|
70
73
|
}
|
|
71
|
-
//! la simplification de mathjs est foireuse, exemple (4+4sqrt(3))/16 est simplifiée mais pas (4-4sqrt(3))/16 ??
|
|
72
74
|
getRootsNode() {
|
|
73
75
|
const delta = this.getDelta();
|
|
74
76
|
if (delta < 0)
|
|
75
77
|
return [];
|
|
76
78
|
if (delta === 0)
|
|
77
79
|
return [new rational_1.Rational(-this.b, 2 * this.a).simplify().toTree()];
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
const sqrtDelta = Math.sqrt(delta);
|
|
81
|
+
const isDeltaPerfectSquare = Math.sqrt(delta) === Math.floor(Math.sqrt(delta));
|
|
82
|
+
if (isDeltaPerfectSquare) {
|
|
83
|
+
const addNode = new rational_1.Rational(-this.b + sqrtDelta, 2 * this.a).simplify().toTree();
|
|
84
|
+
const subNode = new rational_1.Rational(-this.b - sqrtDelta, 2 * this.a).simplify().toTree();
|
|
85
|
+
return this.a > 0 ? [subNode, addNode] : [addNode, subNode];
|
|
86
|
+
}
|
|
87
|
+
let [sqrtA, sqrtB] = new real_1.SquareRoot(delta).getSimplifiedCoeffs();
|
|
88
|
+
let denum = 2 * this.a;
|
|
89
|
+
let trueB = this.b;
|
|
90
|
+
const pgcd = (0, mathjs_1.gcd)(sqrtA, trueB, denum);
|
|
91
|
+
[sqrtA, trueB, denum] = [sqrtA, trueB, denum].map((n) => n / pgcd);
|
|
92
|
+
const sqrtNode = sqrtA === 1
|
|
93
|
+
? new sqrtNode_1.SqrtNode(new numberNode_1.NumberNode(sqrtB))
|
|
94
|
+
: new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(sqrtA), new sqrtNode_1.SqrtNode(new numberNode_1.NumberNode(sqrtB)));
|
|
95
|
+
const subNode = trueB === 0 ? new oppositeNode_1.OppositeNode(sqrtNode) : new substractNode_1.SubstractNode(new numberNode_1.NumberNode(-trueB), sqrtNode);
|
|
96
|
+
const addNode = trueB === 0 ? sqrtNode : new addNode_1.AddNode(new numberNode_1.NumberNode(-trueB), sqrtNode);
|
|
97
|
+
if (denum === 1) {
|
|
98
|
+
return this.a > 0 ? [subNode, addNode] : [addNode, subNode];
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
return this.a > 0
|
|
102
|
+
? [new fractionNode_1.FractionNode(subNode, new numberNode_1.NumberNode(denum)), new fractionNode_1.FractionNode(addNode, new numberNode_1.NumberNode(denum))]
|
|
103
|
+
: [new fractionNode_1.FractionNode(addNode, new numberNode_1.NumberNode(denum)), new fractionNode_1.FractionNode(subNode, new numberNode_1.NumberNode(denum))];
|
|
104
|
+
}
|
|
82
105
|
}
|
|
83
106
|
getRootsEquationSolutionTex() {
|
|
84
107
|
const roots = this.getRootsNode();
|