math-exercises 2.2.46 → 2.2.47
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/math/functions/affines/affineExpressionFromTwoImages.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/affineExpressionFromTwoImages.js +35 -19
- package/lib/exercises/math/percent/reciprocalPercentage.d.ts.map +1 -1
- package/lib/exercises/math/percent/reciprocalPercentage.js +32 -17
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"affineExpressionFromTwoImages.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineExpressionFromTwoImages.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"affineExpressionFromTwoImages.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineExpressionFromTwoImages.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAalC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA2GF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAgB/D,CAAC"}
|
|
@@ -7,32 +7,27 @@ const rational_1 = require("../../../../math/numbers/rationals/rational");
|
|
|
7
7
|
const affine_1 = require("../../../../math/polynomials/affine");
|
|
8
8
|
const randint_1 = require("../../../../math/utils/random/randint");
|
|
9
9
|
const addNode_1 = require("../../../../tree/nodes/operators/addNode");
|
|
10
|
+
const fractionNode_1 = require("../../../../tree/nodes/operators/fractionNode");
|
|
10
11
|
const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
|
|
11
12
|
const substractNode_1 = require("../../../../tree/nodes/operators/substractNode");
|
|
12
13
|
const variableNode_1 = require("../../../../tree/nodes/variables/variableNode");
|
|
13
14
|
const shuffle_1 = require("../../../../utils/alea/shuffle");
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
//yA = axA+b donc b = yA-axA
|
|
15
|
+
const alignTex_1 = require("../../../../utils/latex/alignTex");
|
|
16
|
+
const getCorrection = (identifiers) => {
|
|
17
|
+
const { xA, xB, yA, yB } = identifiers;
|
|
18
|
+
const a = new fractionNode_1.FractionNode(new substractNode_1.SubstractNode(yB.toTree(), yA.toTree()), new substractNode_1.SubstractNode(xB.toTree(), xA.toTree()));
|
|
19
|
+
const aSimplified = a.simplify();
|
|
20
20
|
const b = new substractNode_1.SubstractNode(yA.toTree(), new multiplyNode_1.MultiplyNode(a, xA.toTree())).simplify();
|
|
21
21
|
const answer = new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(a, new variableNode_1.VariableNode("x")), b)
|
|
22
22
|
.simplify({ forceDistributeFractions: true })
|
|
23
23
|
.toTex();
|
|
24
|
-
|
|
25
|
-
instruction: `Soit $f$ une fonction affine telle que $f(${xA}) = ${yA}$ et $f(${xB}) = ${yB}$.
|
|
24
|
+
return `On calcule d'abord le taux d'accroissement $a$ :
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
$$
|
|
34
|
-
a = \\frac{y_2-y_1}{x_2-x_1} = \\frac{${yB}-${yA}}{${xB}-${xA}} = ${a.toTex()}
|
|
35
|
-
$$
|
|
26
|
+
${(0, alignTex_1.alignTex)([
|
|
27
|
+
["a", "=", `\\frac{y_2-y_1}{x_2-x_1}`],
|
|
28
|
+
["", "=", `${a.toTex()}`],
|
|
29
|
+
["", "=", `${aSimplified.toTex()}`],
|
|
30
|
+
])}
|
|
36
31
|
|
|
37
32
|
Il faut ensuite trouver l'ordonnée à l'origine $b$. On sait que $f(${xA}) = ${yA}$. Or pour tout $x$ réel, on a $f(x) = ax+b$.
|
|
38
33
|
|
|
@@ -49,10 +44,30 @@ b = ${new substractNode_1.SubstractNode(yA.toTree(), new multiplyNode_1.Multiply
|
|
|
49
44
|
$$
|
|
50
45
|
|
|
51
46
|
Ainsi, $f(x) = ${answer}$.
|
|
52
|
-
|
|
47
|
+
`;
|
|
48
|
+
};
|
|
49
|
+
const getAffineExpressionFromTwoImagesQuestion = () => {
|
|
50
|
+
const [xA, yA] = [1, 2].map((el) => (0, randint_1.randint)(-9, 10));
|
|
51
|
+
const xB = (0, randint_1.randint)(-9, 10, [xA]);
|
|
52
|
+
const yB = (0, randint_1.randint)(-9, 10);
|
|
53
|
+
const a = new rational_1.Rational(yB - yA, xB - xA).simplify().toTree();
|
|
54
|
+
//yA = axA+b donc b = yA-axA
|
|
55
|
+
const b = new substractNode_1.SubstractNode(yA.toTree(), new multiplyNode_1.MultiplyNode(a, xA.toTree())).simplify();
|
|
56
|
+
const answer = new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(a, new variableNode_1.VariableNode("x")), b)
|
|
57
|
+
.simplify({ forceDistributeFractions: true })
|
|
58
|
+
.toTex();
|
|
59
|
+
const identifiers = { xA, xB, yA, yB };
|
|
60
|
+
const question = {
|
|
61
|
+
instruction: `Soit $f$ une fonction affine telle que $f(${xA}) = ${yA}$ et $f(${xB}) = ${yB}$.
|
|
62
|
+
|
|
63
|
+
Quelle est l'expression algébrique de $f$ ?`,
|
|
64
|
+
startStatement: "a",
|
|
65
|
+
answer,
|
|
66
|
+
hint: "Calcule d'abord le taux d'accroissement de $f$ en utilisant la formule $a = \\frac{y_2-y_1}{x_2-x_1}$. Ensuite, utilise les coordonnées d'un des deux points pour déterminer l'ordonnée à l'origine.",
|
|
67
|
+
correction: getCorrection(identifiers),
|
|
53
68
|
answerFormat: "tex",
|
|
54
69
|
keys: ["x"],
|
|
55
|
-
identifiers
|
|
70
|
+
identifiers,
|
|
56
71
|
};
|
|
57
72
|
return question;
|
|
58
73
|
};
|
|
@@ -89,4 +104,5 @@ exports.affineExpressionFromTwoImages = {
|
|
|
89
104
|
isAnswerValid,
|
|
90
105
|
subject: "Mathématiques",
|
|
91
106
|
hasHintAndCorrection: true,
|
|
107
|
+
getCorrection,
|
|
92
108
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reciprocalPercentage.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/reciprocalPercentage.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"reciprocalPercentage.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/reciprocalPercentage.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAST,MAAM,gBAAgB,CAAC;AAMxB,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AA2GF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAgBtD,CAAC"}
|
|
@@ -8,27 +8,18 @@ const shuffle_1 = require("../../../utils/alea/shuffle");
|
|
|
8
8
|
const coinFlip_1 = require("../../../utils/alea/coinFlip");
|
|
9
9
|
const round_1 = require("../../../math/utils/round");
|
|
10
10
|
const percentParser_1 = require("../../../tree/parsers/percentParser");
|
|
11
|
-
const
|
|
12
|
-
const randPercent = (0, randint_1.randint)(1, 50);
|
|
11
|
+
const getCorrection = (identifiers) => {
|
|
13
12
|
let ans = 0;
|
|
14
|
-
const isUp =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
: (1 / (1 - randPercent / 100) - 1) * 100;
|
|
13
|
+
const { isUp, randPercent } = identifiers;
|
|
14
|
+
ans = identifiers.isUp
|
|
15
|
+
? (1 / (1 + identifiers.randPercent / 100) - 1) * 100
|
|
16
|
+
: (1 / (1 - identifiers.randPercent / 100) - 1) * 100;
|
|
19
17
|
const answer = `${(ans > 0
|
|
20
18
|
? "+" + (0, round_1.round)(ans, 2)
|
|
21
19
|
: "" + (0, round_1.round)(ans, 2)).replace(".", ",")}\\%`;
|
|
22
|
-
const cm = (0, round_1.round)(1 + (isUp ? randPercent / 100 : -randPercent / 100), 4);
|
|
20
|
+
const cm = (0, round_1.round)(1 + (identifiers.isUp ? identifiers.randPercent / 100 : -randPercent / 100), 4);
|
|
23
21
|
const recipCm = (0, round_1.round)(1 / cm, 4);
|
|
24
|
-
|
|
25
|
-
instruction,
|
|
26
|
-
answer,
|
|
27
|
-
keys: ["percent"],
|
|
28
|
-
answerFormat: "tex",
|
|
29
|
-
identifiers: { isUp, randPercent },
|
|
30
|
-
hint: `Calcule le coefficient multiplicateur associé à une ${isUp ? "hausse" : "baisse"} de $${randPercent}\\%$. Puis, calcule le coefficient multiplicateur réciproque : c'est l'inverse du coefficient multiplicateur. Il ne reste alors plus qu'à transformer le coefficient multiplicateur réciproque en taux d'évolution.`,
|
|
31
|
-
correction: `Le coefficient multiplicateur correspondant à une ${isUp ? "hausse" : "baisse"} de $${randPercent}\\%$ est :
|
|
22
|
+
return `Le coefficient multiplicateur correspondant à une ${isUp ? "hausse" : "baisse"} de $${randPercent}\\%$ est :
|
|
32
23
|
|
|
33
24
|
$$
|
|
34
25
|
1${isUp ? "+" : "-"}\\frac{${randPercent}}{100} = ${cm.frenchify()}
|
|
@@ -47,7 +38,30 @@ $$
|
|
|
47
38
|
$$
|
|
48
39
|
|
|
49
40
|
Ainsi, le taux d'évolution permettant de revenir au prix initial est de $${answer}$.
|
|
50
|
-
|
|
41
|
+
`;
|
|
42
|
+
};
|
|
43
|
+
const getReciprocalPercentageQuestion = () => {
|
|
44
|
+
const randPercent = (0, randint_1.randint)(1, 50);
|
|
45
|
+
let ans = 0;
|
|
46
|
+
const isUp = (0, coinFlip_1.coinFlip)();
|
|
47
|
+
let instruction = `Le prix d'un article subit une ${isUp ? "hausse" : "baisse"} de $${randPercent}\\%$. Quelle évolution devra-t-il subir pour revenir à son prix initial (arrondir au centième de pourcentage) ?`;
|
|
48
|
+
ans = isUp
|
|
49
|
+
? (1 / (1 + randPercent / 100) - 1) * 100
|
|
50
|
+
: (1 / (1 - randPercent / 100) - 1) * 100;
|
|
51
|
+
const answer = `${(ans > 0
|
|
52
|
+
? "+" + (0, round_1.round)(ans, 2)
|
|
53
|
+
: "" + (0, round_1.round)(ans, 2)).replace(".", ",")}\\%`;
|
|
54
|
+
const cm = (0, round_1.round)(1 + (isUp ? randPercent / 100 : -randPercent / 100), 4);
|
|
55
|
+
const recipCm = (0, round_1.round)(1 / cm, 4);
|
|
56
|
+
const identifiers = { isUp, randPercent };
|
|
57
|
+
const question = {
|
|
58
|
+
instruction,
|
|
59
|
+
answer,
|
|
60
|
+
keys: ["percent"],
|
|
61
|
+
answerFormat: "tex",
|
|
62
|
+
identifiers: { isUp, randPercent },
|
|
63
|
+
hint: `Calcule le coefficient multiplicateur associé à une ${isUp ? "hausse" : "baisse"} de $${randPercent}\\%$. Puis, calcule le coefficient multiplicateur réciproque : c'est l'inverse du coefficient multiplicateur. Il ne reste alors plus qu'à transformer le coefficient multiplicateur réciproque en taux d'évolution.`,
|
|
64
|
+
correction: getCorrection(identifiers),
|
|
51
65
|
};
|
|
52
66
|
return question;
|
|
53
67
|
};
|
|
@@ -82,4 +96,5 @@ exports.reciprocalPercentage = {
|
|
|
82
96
|
isAnswerValid,
|
|
83
97
|
subject: "Mathématiques",
|
|
84
98
|
hasHintAndCorrection: true,
|
|
99
|
+
getCorrection,
|
|
85
100
|
};
|