math-exercises 3.0.208 → 3.0.211

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.
Files changed (101) hide show
  1. package/lib/exercises/math/arithmetic/congruenceBasicComputation.d.ts +8 -0
  2. package/lib/exercises/math/arithmetic/congruenceBasicComputation.d.ts.map +1 -0
  3. package/lib/exercises/math/arithmetic/congruenceBasicComputation.js +93 -0
  4. package/lib/exercises/math/arithmetic/index.d.ts +2 -0
  5. package/lib/exercises/math/arithmetic/index.d.ts.map +1 -0
  6. package/lib/exercises/math/arithmetic/index.js +1 -0
  7. package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.d.ts.map +1 -1
  8. package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.js +15 -0
  9. package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.d.ts.map +1 -1
  10. package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.js +15 -0
  11. package/lib/exercises/math/functions/continuity/index.d.ts +2 -0
  12. package/lib/exercises/math/functions/continuity/index.d.ts.map +1 -1
  13. package/lib/exercises/math/functions/continuity/index.js +2 -0
  14. package/lib/exercises/math/functions/continuity/pyContinuityBalayageInstructionCompletion.d.ts +11 -0
  15. package/lib/exercises/math/functions/continuity/pyContinuityBalayageInstructionCompletion.d.ts.map +1 -0
  16. package/lib/exercises/math/functions/continuity/pyContinuityBalayageInstructionCompletion.js +276 -0
  17. package/lib/exercises/math/functions/continuity/pyContinuityDichotomyInstructionCompletion.d.ts +10 -0
  18. package/lib/exercises/math/functions/continuity/pyContinuityDichotomyInstructionCompletion.d.ts.map +1 -0
  19. package/lib/exercises/math/functions/continuity/pyContinuityDichotomyInstructionCompletion.js +265 -0
  20. package/lib/exercises/math/functions/logarithm/log10Simplifying.d.ts.map +1 -1
  21. package/lib/exercises/math/functions/logarithm/log10Simplifying.js +72 -33
  22. package/lib/exercises/math/functions/logarithm/logEquation.d.ts.map +1 -1
  23. package/lib/exercises/math/functions/logarithm/logEquation.js +40 -2
  24. package/lib/exercises/math/functions/logarithm/logPowerEquation.d.ts.map +1 -1
  25. package/lib/exercises/math/functions/logarithm/logPowerEquation.js +55 -6
  26. package/lib/exercises/math/functions/logarithm/logSimplifiying.d.ts.map +1 -1
  27. package/lib/exercises/math/functions/logarithm/logSimplifiying.js +45 -5
  28. package/lib/exercises/math/index.d.ts +1 -0
  29. package/lib/exercises/math/index.d.ts.map +1 -1
  30. package/lib/exercises/math/index.js +1 -0
  31. package/lib/exercises/math/integration/algorithms/index.d.ts +2 -0
  32. package/lib/exercises/math/integration/algorithms/index.d.ts.map +1 -0
  33. package/lib/exercises/math/integration/algorithms/index.js +1 -0
  34. package/lib/exercises/math/integration/algorithms/pyIntegrationInstructionCompletion.d.ts +10 -0
  35. package/lib/exercises/math/integration/algorithms/pyIntegrationInstructionCompletion.d.ts.map +1 -0
  36. package/lib/exercises/math/integration/algorithms/pyIntegrationInstructionCompletion.js +273 -0
  37. package/lib/exercises/math/integration/index.d.ts +1 -0
  38. package/lib/exercises/math/integration/index.d.ts.map +1 -1
  39. package/lib/exercises/math/integration/index.js +1 -0
  40. package/lib/exercises/math/limits/algorithms/index.d.ts +2 -0
  41. package/lib/exercises/math/limits/algorithms/index.d.ts.map +1 -0
  42. package/lib/exercises/math/limits/algorithms/index.js +1 -0
  43. package/lib/exercises/math/limits/algorithms/pyLimitProgramExecution.d.ts +17 -0
  44. package/lib/exercises/math/limits/algorithms/pyLimitProgramExecution.d.ts.map +1 -0
  45. package/lib/exercises/math/limits/algorithms/pyLimitProgramExecution.js +353 -0
  46. package/lib/exercises/math/limits/index.d.ts +1 -0
  47. package/lib/exercises/math/limits/index.d.ts.map +1 -1
  48. package/lib/exercises/math/limits/index.js +1 -0
  49. package/lib/exercises/math/probaStat/density/findParamToMakeDensity.d.ts +8 -0
  50. package/lib/exercises/math/probaStat/density/findParamToMakeDensity.d.ts.map +1 -0
  51. package/lib/exercises/math/probaStat/density/findParamToMakeDensity.js +127 -0
  52. package/lib/exercises/math/probaStat/density/index.d.ts +2 -0
  53. package/lib/exercises/math/probaStat/density/index.d.ts.map +1 -0
  54. package/lib/exercises/math/probaStat/density/index.js +1 -0
  55. package/lib/exercises/math/probaStat/exponential/exponentialLawAverage.d.ts +7 -0
  56. package/lib/exercises/math/probaStat/exponential/exponentialLawAverage.d.ts.map +1 -0
  57. package/lib/exercises/math/probaStat/exponential/exponentialLawAverage.js +95 -0
  58. package/lib/exercises/math/probaStat/exponential/exponentialLawComputeIntervalProba.d.ts +9 -0
  59. package/lib/exercises/math/probaStat/exponential/exponentialLawComputeIntervalProba.d.ts.map +1 -0
  60. package/lib/exercises/math/probaStat/exponential/exponentialLawComputeIntervalProba.js +115 -0
  61. package/lib/exercises/math/probaStat/exponential/exponentialLawComputeProba.d.ts +8 -0
  62. package/lib/exercises/math/probaStat/exponential/exponentialLawComputeProba.d.ts.map +1 -0
  63. package/lib/exercises/math/probaStat/exponential/exponentialLawComputeProba.js +110 -0
  64. package/lib/exercises/math/probaStat/exponential/index.d.ts +4 -0
  65. package/lib/exercises/math/probaStat/exponential/index.d.ts.map +1 -0
  66. package/lib/exercises/math/probaStat/exponential/index.js +3 -0
  67. package/lib/exercises/math/probaStat/geometric/geometricLawAverage.d.ts +8 -0
  68. package/lib/exercises/math/probaStat/geometric/geometricLawAverage.d.ts.map +1 -0
  69. package/lib/exercises/math/probaStat/geometric/geometricLawAverage.js +124 -0
  70. package/lib/exercises/math/probaStat/geometric/geometricLawComputeProba.d.ts +9 -0
  71. package/lib/exercises/math/probaStat/geometric/geometricLawComputeProba.d.ts.map +1 -0
  72. package/lib/exercises/math/probaStat/geometric/geometricLawComputeProba.js +121 -0
  73. package/lib/exercises/math/probaStat/geometric/index.d.ts +3 -0
  74. package/lib/exercises/math/probaStat/geometric/index.d.ts.map +1 -0
  75. package/lib/exercises/math/probaStat/geometric/index.js +2 -0
  76. package/lib/exercises/math/probaStat/index.d.ts +4 -0
  77. package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
  78. package/lib/exercises/math/probaStat/index.js +4 -0
  79. package/lib/exercises/math/probaStat/stats2var/fineAdjustementExercise.d.ts.map +1 -1
  80. package/lib/exercises/math/probaStat/stats2var/fineAdjustementExercise.js +15 -0
  81. package/lib/exercises/math/probaStat/uniform/index.d.ts +3 -0
  82. package/lib/exercises/math/probaStat/uniform/index.d.ts.map +1 -0
  83. package/lib/exercises/math/probaStat/uniform/index.js +2 -0
  84. package/lib/exercises/math/probaStat/uniform/uniformAverage.d.ts +8 -0
  85. package/lib/exercises/math/probaStat/uniform/uniformAverage.d.ts.map +1 -0
  86. package/lib/exercises/math/probaStat/uniform/uniformAverage.js +100 -0
  87. package/lib/exercises/math/probaStat/uniform/uniformLawComputeProba.d.ts +10 -0
  88. package/lib/exercises/math/probaStat/uniform/uniformLawComputeProba.d.ts.map +1 -0
  89. package/lib/exercises/math/probaStat/uniform/uniformLawComputeProba.js +105 -0
  90. package/lib/index.d.ts +52 -1
  91. package/lib/index.d.ts.map +1 -1
  92. package/lib/latexTester.js +1 -0
  93. package/lib/tests/pdfs/formatMdToLatex.js +1 -1
  94. package/lib/tests/singleExo.test.js +2 -2
  95. package/lib/tree/nodes/functions/log10Node.d.ts +1 -0
  96. package/lib/tree/nodes/functions/log10Node.d.ts.map +1 -1
  97. package/lib/tree/nodes/functions/log10Node.js +12 -1
  98. package/lib/tree/nodes/functions/logNode.d.ts +1 -0
  99. package/lib/tree/nodes/functions/logNode.d.ts.map +1 -1
  100. package/lib/tree/nodes/functions/logNode.js +12 -1
  101. package/package.json +1 -1
@@ -0,0 +1,353 @@
1
+ import { addValidProp, tryToAddWrongProp, shuffleProps, GeneratorOptionTarget, GeneratorOptionType, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { defaultArrayedOptsWhereNeeded } from "../../../../exercises/utils/options/arrayedOptions.js";
4
+ import { randint } from "../../../../math/utils/random/randint.js";
5
+ import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
6
+ import { MinusInfinityNode, PlusInfinityNode, } from "../../../../tree/nodes/numbers/infiniteNode.js";
7
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
8
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
9
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
10
+ import { square } from "../../../../tree/nodes/operators/powerNode.js";
11
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
12
+ import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
13
+ import { random } from "../../../../utils/alea/random.js";
14
+ import { getCartesiansProducts } from "../../../../utils/arrays/cartesianProducts.js";
15
+ const codify = (strPython) => {
16
+ return `\`\`\`python
17
+ ${strPython}
18
+ \`\`\``;
19
+ };
20
+ const codifyChunk = (strPython) => {
21
+ return `\`${strPython}\``;
22
+ };
23
+ const createStrPythonForNode = (node) => {
24
+ return node.toMathString().replaceAll("^", "**");
25
+ };
26
+ const getHydrated = (identifiers) => {
27
+ const { nodeIdsF, nodeIdsAbscissa, nodeIdsPrecision, nodeIdsImage } = identifiers;
28
+ const [nodeF, nodeAbsissa, nodeImage] = [
29
+ nodeIdsF,
30
+ nodeIdsAbscissa,
31
+ nodeIdsImage,
32
+ ].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
33
+ const nodePrecision = nodeIdsPrecision &&
34
+ NodeConstructor.fromIdentifiers(nodeIdsPrecision);
35
+ return {
36
+ nodeF,
37
+ nodeAbsissa,
38
+ nodeImage,
39
+ nodePrecision,
40
+ };
41
+ };
42
+ const getStrPythonProgram = (identifiers) => {
43
+ const { abscissaType, imageType } = identifiers;
44
+ const { nodeF, nodeAbsissa, nodeImage, nodePrecision } = getHydrated(identifiers);
45
+ const [strAbscissa, strImage] = [nodeAbsissa, nodeImage].map((node) => createStrPythonForNode(node));
46
+ const strPrecision = nodePrecision && createStrPythonForNode(nodePrecision);
47
+ return `def f(x):
48
+ return ${createStrPythonForNode(nodeF)}
49
+
50
+ ${(() => {
51
+ switch (abscissaType) {
52
+ case "$-\\infty$":
53
+ switch (imageType) {
54
+ case "$-\\infty$":
55
+ case "$+\\infty$":
56
+ return `x = 0
57
+ while abs(f(x)) < 10000 :
58
+ x = x - 10`;
59
+ case "$x \\in \\mathbb{R}$":
60
+ return `x = 0
61
+ while abs(f(x) - ${strImage}) > ${strPrecision} :
62
+ x = x - 10`;
63
+ default:
64
+ throw new Error("Unsupported imageType: " + imageType);
65
+ }
66
+ case "$+\\infty$": {
67
+ switch (imageType) {
68
+ case "$-\\infty$":
69
+ case "$+\\infty$":
70
+ return `x = 0
71
+ while abs(f(x)) < 10000 :
72
+ x = x + 10`;
73
+ case "$x \\in \\mathbb{R}$":
74
+ return `x = 0
75
+ while abs(f(x) - ${strImage}) > ${strPrecision} :
76
+ x = x + 10`;
77
+ default:
78
+ throw new Error("Unsupported imageType: " + imageType);
79
+ }
80
+ }
81
+ case "$x \\in \\mathbb{R}$": {
82
+ switch (imageType) {
83
+ case "$-\\infty$":
84
+ case "$+\\infty$":
85
+ return `x = ${strAbscissa} + 1
86
+ while abs(f(x)) < 10000 :
87
+ x = x - 0.01`;
88
+ default:
89
+ throw new Error("Unsupported imageType: " + imageType);
90
+ }
91
+ }
92
+ default:
93
+ throw new Error("Unsupported abscissaType: " + abscissaType);
94
+ }
95
+ })()}`;
96
+ };
97
+ const getXValueForPythonProgram = (identifiers) => {
98
+ const { abscissaType, imageType } = identifiers;
99
+ const { nodeF, nodeAbsissa, nodeImage, nodePrecision } = getHydrated(identifiers);
100
+ switch (abscissaType) {
101
+ case "$-\\infty$":
102
+ switch (imageType) {
103
+ case "$-\\infty$":
104
+ case "$+\\infty$": {
105
+ let x = 0;
106
+ while (Math.abs(nodeF.evaluate({ x })) < 10000) {
107
+ x = x - 10;
108
+ }
109
+ return x;
110
+ }
111
+ case "$x \\in \\mathbb{R}$": {
112
+ let x = 0;
113
+ while (Math.abs(nodeF.evaluate({ x }) - nodeImage.evaluate()) >
114
+ nodePrecision.evaluate()) {
115
+ x = x - 10;
116
+ }
117
+ return x;
118
+ }
119
+ default:
120
+ throw new Error("Unsupported imageType: " + imageType);
121
+ }
122
+ case "$+\\infty$":
123
+ switch (imageType) {
124
+ case "$-\\infty$":
125
+ case "$+\\infty$": {
126
+ let x = 0;
127
+ while (Math.abs(nodeF.evaluate({ x })) < 10000) {
128
+ x = x - 10;
129
+ }
130
+ return x;
131
+ }
132
+ case "$x \\in \\mathbb{R}$": {
133
+ let x = 0;
134
+ while (Math.abs(nodeF.evaluate({ x }) - nodeImage.evaluate()) >
135
+ nodePrecision.evaluate()) {
136
+ x = x - 10;
137
+ }
138
+ return x;
139
+ }
140
+ default:
141
+ throw new Error("Unsupported imageType: " + imageType);
142
+ }
143
+ case "$x \\in \\mathbb{R}$": {
144
+ switch (imageType) {
145
+ case "$-\\infty$":
146
+ case "$+\\infty$": {
147
+ let x = nodeAbsissa.evaluate() + 1;
148
+ while (Math.abs(nodeF.evaluate({ x })) < 10000) {
149
+ x = x - 0.01;
150
+ }
151
+ return x;
152
+ }
153
+ default:
154
+ throw new Error("Unsupported imageType: " + imageType);
155
+ }
156
+ }
157
+ default:
158
+ throw new Error("Unsupported abscissaType: " + abscissaType);
159
+ }
160
+ };
161
+ const getInstruction = (identifiers) => {
162
+ return `On considère le script suivant en langage Python. Quelle valeur contient la variable $x$ après son exécution ?
163
+
164
+ ${codify(getStrPythonProgram(identifiers))}
165
+
166
+ `;
167
+ };
168
+ const getAnswer = (identifiers) => {
169
+ return codifyChunk(createStrPythonForNode(getXValueForPythonProgram(identifiers).toTree()));
170
+ };
171
+ const getHint = (_identifiers) => {
172
+ return "Trouve la valeur qui semble la plus probable dans la liste des valeurs proposées.";
173
+ };
174
+ const getCorrection = (identifiers) => {
175
+ return `La valeur de $x$ quand on exécute le script est $${getAnswer(identifiers)}$.`;
176
+ };
177
+ const getPropositions = (n, { answer, ...identifiers }) => {
178
+ const propositions = [];
179
+ addValidProp(propositions, getAnswer(identifiers), "raw");
180
+ const { nodeAbsissa } = getHydrated(identifiers);
181
+ const x = getXValueForPythonProgram(identifiers);
182
+ if (nodeAbsissa.toTex() === "+\\infty") {
183
+ [
184
+ (-8000).toTree(),
185
+ (-4290).toTree(),
186
+ (-19800).toTree(),
187
+ randint(-50, 50, [0]).toTree(),
188
+ ].forEach((node) => {
189
+ tryToAddWrongProp(propositions, codifyChunk(createStrPythonForNode(node)), "raw");
190
+ });
191
+ }
192
+ else if (nodeAbsissa.toTex() === "-\\infty") {
193
+ [
194
+ (+8000).toTree(),
195
+ (+4290).toTree(),
196
+ (+19800).toTree(),
197
+ randint(-50, 50, [0]).toTree(),
198
+ ].forEach((node) => {
199
+ tryToAddWrongProp(propositions, codifyChunk(createStrPythonForNode(node)), "raw");
200
+ });
201
+ }
202
+ else {
203
+ [(8000).toTree(), (-8000).toTree(), (-x).toTree()].forEach((node) => {
204
+ tryToAddWrongProp(propositions, codifyChunk(createStrPythonForNode(node)), "raw");
205
+ });
206
+ }
207
+ return shuffleProps(propositions, n);
208
+ };
209
+ const getPyLimitProgramExecutionQuestion = (optsIn) => {
210
+ const arrayedOpts = defaultArrayedOptsWhereNeeded(optsIn, arrayedOptsDefault);
211
+ const pool = getCartesiansProducts([
212
+ arrayedOpts.abscissaType,
213
+ arrayedOpts.imageType,
214
+ ]).filter(([abscissaType, imageType]) => {
215
+ return !(abscissaType === "$x \\in \\mathbb{R}$" &&
216
+ imageType === "$x \\in \\mathbb{R}$");
217
+ });
218
+ const [abscissaType, imageType] = random(pool);
219
+ const [nodeF, nodeAbsissa, nodeImage, nodePrecision] = (() => {
220
+ const nodeVarX = new VariableNode("x");
221
+ switch (abscissaType) {
222
+ case "$-\\infty$":
223
+ case "$+\\infty$": {
224
+ const nodeAbsissa = abscissaType === "$-\\infty$" ? PlusInfinityNode : MinusInfinityNode;
225
+ const [nodeF, nodeImage, nodePrecision] = (() => {
226
+ switch (imageType) {
227
+ case "$-\\infty$": {
228
+ const nodePrecision = random([0.1, 0.01, 0.001]).toTree();
229
+ const nodeF = (() => {
230
+ const [a, b, c, d] = [...Array(4).keys()].reduce((acc, _i) => {
231
+ acc = [...acc, randint(1, 10, acc)];
232
+ return acc;
233
+ }, []);
234
+ const nodeNum = add(multiply(-a, square(nodeVarX)), b);
235
+ const nodeDen = add(multiply(c, nodeVarX), d);
236
+ return frac(nodeNum, nodeDen);
237
+ })();
238
+ const nodeImage = MinusInfinityNode;
239
+ return [nodeF, nodeImage, nodePrecision];
240
+ }
241
+ case "$x \\in \\mathbb{R}$": {
242
+ const nodeImage = randint(-50, 51).toTree();
243
+ const a = randint(-9, 10, [0]);
244
+ const nodeF = add(nodeImage, frac(a, nodeVarX));
245
+ return [nodeF, nodeImage, undefined];
246
+ }
247
+ case "$+\\infty$": {
248
+ const nodePrecision = random([0.1, 0.01, 0.001]).toTree();
249
+ const nodeF = (() => {
250
+ const [a, b, c, d] = [...Array(4).keys()].reduce((acc, _i) => {
251
+ acc = [...acc, randint(1, 10, acc)];
252
+ return acc;
253
+ }, []);
254
+ const nodeNum = add(multiply(+a, square(nodeVarX)), b);
255
+ const nodeDen = add(multiply(c, nodeVarX), d);
256
+ return frac(nodeNum, nodeDen);
257
+ })();
258
+ const nodeImage = MinusInfinityNode;
259
+ return [nodeF, nodeImage, nodePrecision];
260
+ }
261
+ default:
262
+ throw new Error("Unsupported imageType: " + imageType);
263
+ }
264
+ })();
265
+ return [nodeF, nodeAbsissa, nodeImage, nodePrecision];
266
+ }
267
+ case "$x \\in \\mathbb{R}$": {
268
+ const nodeAbsissa = randint(-50, 51).toTree();
269
+ const [nodeF, nodeImage] = (() => {
270
+ switch (imageType) {
271
+ case "$-\\infty$": {
272
+ const a = randint(-9, 0);
273
+ const nodeF = frac(a, square(substract(nodeVarX, nodeAbsissa)));
274
+ const nodeImage = MinusInfinityNode;
275
+ return [nodeF, nodeImage];
276
+ }
277
+ case "$+\\infty$": {
278
+ const a = randint(1, 10);
279
+ const nodeF = frac(a, square(substract(nodeVarX, nodeAbsissa)));
280
+ const nodeImage = PlusInfinityNode;
281
+ return [nodeF, nodeImage];
282
+ }
283
+ default:
284
+ throw new Error("Unsupported imageType: " + imageType);
285
+ }
286
+ })();
287
+ return [nodeF, nodeAbsissa, nodeImage, undefined];
288
+ }
289
+ default:
290
+ throw new Error("Unsupported abscissaType: " + abscissaType);
291
+ }
292
+ })();
293
+ const identifiers = {
294
+ abscissaType,
295
+ imageType,
296
+ nodeIdsF: nodeF.toIdentifiers(),
297
+ nodeIdsAbscissa: nodeAbsissa.toIdentifiers(),
298
+ nodeIdsImage: nodeImage.toIdentifiers(),
299
+ nodeIdsPrecision: nodePrecision?.toIdentifiers(),
300
+ };
301
+ return getQuestionFromIdentifiers(identifiers);
302
+ };
303
+ const getQuestionFromIdentifiers = (identifiers) => {
304
+ const question = {
305
+ instruction: getInstruction(identifiers),
306
+ answer: getAnswer(identifiers),
307
+ hint: getHint(identifiers),
308
+ correction: getCorrection(identifiers),
309
+ keys: [],
310
+ answerFormat: "raw",
311
+ identifiers,
312
+ };
313
+ return question;
314
+ };
315
+ const arrayedOptsDefault = {
316
+ abscissaType: ["$-\\infty$", "$x \\in \\mathbb{R}$", "$+\\infty$"],
317
+ imageType: ["$-\\infty$", "$+\\infty$"],
318
+ };
319
+ const options = [
320
+ {
321
+ id: "abscissaType",
322
+ label: "Type d'abscisse",
323
+ target: GeneratorOptionTarget.generation,
324
+ type: GeneratorOptionType.multiselect,
325
+ values: ["$-\\infty$", "$x \\in \\mathbb{R}$", "$+\\infty$"],
326
+ defaultValue: arrayedOptsDefault.abscissaType,
327
+ },
328
+ {
329
+ id: "imageType",
330
+ label: "Type d'image",
331
+ target: GeneratorOptionTarget.generation,
332
+ type: GeneratorOptionType.multiselect,
333
+ values: ["$-\\infty$", "$x \\in \\mathbb{R}$", "$+\\infty$"],
334
+ defaultValue: arrayedOptsDefault.imageType,
335
+ },
336
+ ];
337
+ export const pyLimitProgramExecution = {
338
+ id: "pyLimitProgramExecution",
339
+ label: "Exécuter un script Python de manifestation d'une limite de fonction",
340
+ isSingleStep: true,
341
+ generator: (nb, opts) => getDistinctQuestions(() => getPyLimitProgramExecutionQuestion(opts), nb),
342
+ options,
343
+ qcmTimer: 60,
344
+ freeTimer: 60,
345
+ getPropositions,
346
+ getInstruction,
347
+ getHint,
348
+ getCorrection,
349
+ subject: "Mathématiques",
350
+ getQuestionFromIdentifiers,
351
+ hasHintAndCorrection: true,
352
+ answerType: "QCU",
353
+ };
@@ -7,4 +7,5 @@ export * from "./frac1XTimesALogXPlusBLimit.js";
7
7
  export * from "./kLogXPlusTrinomLimit.js";
8
8
  export * from "./logOfPolynomialLimit.js";
9
9
  export * from "./sequences/index.js";
10
+ export * from "./algorithms/index.js";
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/limits/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sCAAsC,CAAC;AACrD,cAAc,wBAAwB,CAAC;AAEvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iCAAiC,CAAC;AAChD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/limits/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sCAAsC,CAAC;AACrD,cAAc,wBAAwB,CAAC;AAEvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iCAAiC,CAAC;AAChD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AAErC,cAAc,uBAAuB,CAAC"}
@@ -7,3 +7,4 @@ export * from "./frac1XTimesALogXPlusBLimit.js";
7
7
  export * from "./kLogXPlusTrinomLimit.js";
8
8
  export * from "./logOfPolynomialLimit.js";
9
9
  export * from "./sequences/index.js";
10
+ export * from "./algorithms/index.js";
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ a: number;
4
+ b: number;
5
+ };
6
+ export declare const findParamToMakeDensity: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=findParamToMakeDensity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findParamToMakeDensity.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/density/findParamToMakeDensity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CAEX,CAAC;AAyHF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAmBxD,CAAC"}
@@ -0,0 +1,127 @@
1
+ import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
4
+ import { RationalConstructor } from "../../../../math/numbers/rationals/rational.js";
5
+ import { randint } from "../../../../math/utils/random/randint.js";
6
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
7
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
8
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
9
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
10
+ const getPropositions = (n, { answer }) => {
11
+ const propositions = [];
12
+ addValidProp(propositions, answer);
13
+ propWhile(propositions, n, () => {
14
+ tryToAddWrongProp(propositions, RationalConstructor.randomIrreductibleProba().toTree().toTex());
15
+ });
16
+ return shuffleProps(propositions, n);
17
+ };
18
+ const getAnswer = (identifiers) => {
19
+ const { a, b } = identifiers;
20
+ // k = 2/(b^2-a^2)
21
+ return frac(2, substract(b ** 2, a ** 2))
22
+ .simplify()
23
+ .toTex();
24
+ };
25
+ const getInstruction = (identifiers) => {
26
+ const { a, b } = identifiers;
27
+ return `On considère la fonction $f$ définie sur $I = [${a};${b}]$ par :
28
+
29
+ $$
30
+ f(t) = kt
31
+ $$
32
+
33
+ où $k$ est un réel strictement positif.
34
+
35
+ Déterminer la valeur de $k$ pour que $f$ soit une densité de probabilité sur $I$.`;
36
+ };
37
+ const getHint = (identifiers) => {
38
+ const { a, b } = identifiers;
39
+ return `Une fonction $f$ est une densité de probabilité sur un intervalle $[a;b]$ si et seulement si $f$ est continue et positive sur $[a;b]$ et :
40
+
41
+ $$
42
+ \\int_{a}^{b} f(x)\\ \\mathrm{d}x = 1
43
+ $$
44
+
45
+ Ici, il faut donc vérifier que $f$ est continue et positive sur $[${a};${b}]$ et déterminer la valeur de $k$ pour laquelle :
46
+
47
+ $$
48
+ \\int_{${a}}^{${b}} kt\\ \\mathrm{d}t = 1
49
+ $$`;
50
+ };
51
+ const getCorrection = (identifiers) => {
52
+ const { a, b } = identifiers;
53
+ const k = frac(2, substract(b ** 2, a ** 2)).simplify();
54
+ return `$f$ est une fonction affine, elle est donc continue sur $[${a};${b}]$. Puisque $k$ est positif, $f$ est également positive sur $[${a};${b}]$.
55
+
56
+ Une primitive de $f$ sur $[${a};${b}]$ est :
57
+
58
+ $$
59
+ F(t) = \\frac{k}{2}t^2
60
+ $$
61
+
62
+ On intègre alors $f$ sur $[${a};${b}]$ :
63
+
64
+ $$
65
+ \\int_{${a}}^{${b}} f(t)\\ \\mathrm{d}t = F(${b})-F(${a}) = \\frac{k}{2}(${b}^2-${a}^2)
66
+ $$
67
+
68
+ On doit donc résoudre l'équation suivante :
69
+
70
+ $$
71
+ ${multiply(b ** 2 - a ** 2, frac("k", 2)).toTex()} = 1
72
+ $$
73
+
74
+ On trouve $k = ${k.toTex()}$.
75
+
76
+ La fonction $f$ définie par $f(t) = ${multiply(k, "t").toTex()}$ est donc une densité de probabilité sur $[${a};${b}]$.
77
+ `;
78
+ };
79
+ const getKeys = () => {
80
+ return [];
81
+ };
82
+ const isAnswerValid = (ans, { answer }) => {
83
+ try {
84
+ return rationalVEA(ans, answer);
85
+ }
86
+ catch (err) {
87
+ return handleVEAError(err);
88
+ }
89
+ };
90
+ const getFindParamToMakeDensityQuestion = () => {
91
+ const a = randint(1, 10);
92
+ const b = randint(a + 1, a + 8);
93
+ const identifiers = {
94
+ a,
95
+ b,
96
+ };
97
+ return getQuestionFromIdentifiers(identifiers);
98
+ };
99
+ const getQuestionFromIdentifiers = (identifiers) => {
100
+ return {
101
+ answer: getAnswer(identifiers),
102
+ instruction: getInstruction(identifiers),
103
+ keys: getKeys(identifiers),
104
+ answerFormat: "tex",
105
+ identifiers,
106
+ hint: getHint(identifiers),
107
+ correction: getCorrection(identifiers),
108
+ };
109
+ };
110
+ export const findParamToMakeDensity = {
111
+ id: "findParamToMakeDensity",
112
+ connector: "=",
113
+ label: "Déterminer un paramètre pour qu'une fonction soit une densité de probabilité",
114
+ isSingleStep: true,
115
+ generator: (nb, opts) => getDistinctQuestions(() => getFindParamToMakeDensityQuestion(opts), nb),
116
+ qcmTimer: 60,
117
+ freeTimer: 60,
118
+ getPropositions,
119
+ isAnswerValid,
120
+ subject: "Mathématiques",
121
+ getInstruction,
122
+ getHint,
123
+ getCorrection,
124
+ getAnswer,
125
+ getQuestionFromIdentifiers,
126
+ hasHintAndCorrection: true,
127
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./findParamToMakeDensity.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/density/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./findParamToMakeDensity.js";
@@ -0,0 +1,7 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ lambda: number;
4
+ };
5
+ export declare const exponentialLawAverage: Exercise<Identifiers>;
6
+ export {};
7
+ //# sourceMappingURL=exponentialLawAverage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exponentialLawAverage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/exponential/exponentialLawAverage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAgFF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAkBvD,CAAC"}
@@ -0,0 +1,95 @@
1
+ import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
4
+ import { randfloat } from "../../../../math/utils/random/randfloat.js";
5
+ import { round } from "../../../../math/utils/round.js";
6
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
7
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
8
+ import { approxOrEqual } from "../../../../utils/latex/approxOrEqual.js";
9
+ const getPropositions = (n, { answer }) => {
10
+ const propositions = [];
11
+ addValidProp(propositions, answer);
12
+ propWhile(propositions, n, () => {
13
+ tryToAddWrongProp(propositions, randfloat(0.01, 0.9, 2).frenchify());
14
+ });
15
+ return shuffleProps(propositions, n);
16
+ };
17
+ const getAnswer = (identifiers) => {
18
+ const { lambda } = identifiers;
19
+ return round(frac(1, lambda).evaluate(), 2).frenchify();
20
+ };
21
+ const getInstruction = (identifiers) => {
22
+ const { lambda } = identifiers;
23
+ return `Soit $X$ une variable aléatoire qui suit une loi exponentielle de paramètre $${lambda.frenchify()}$.
24
+
25
+ Quelle est l'espérance $E(X)$ de $X$ ? Donner une valeur arrondie au centième.`;
26
+ };
27
+ const getHint = () => {
28
+ return `L'espérance d'une variable aléatoire $X$ de loi exponentielle de paramètre $\\lambda>0$ est égale à :
29
+
30
+ $$
31
+ E(X) = \\frac{1}{\\lambda}
32
+ $$`;
33
+ };
34
+ const getCorrection = (identifiers) => {
35
+ const { lambda } = identifiers;
36
+ const ans = frac(1, lambda).evaluate();
37
+ return `L'espérance d'une variable aléatoire $X$ de loi exponentielle de paramètre $\\lambda>0$ est égale à :
38
+
39
+ $$
40
+ E(X) = \\frac{1}{\\lambda}
41
+ $$
42
+
43
+ Ici, on a donc :
44
+
45
+ $$
46
+ E(X) = ${frac(1, lambda).toTex()} ${approxOrEqual(ans, 2).join("")}
47
+ $$`;
48
+ };
49
+ const getKeys = () => {
50
+ return [];
51
+ };
52
+ const isAnswerValid = (ans, { answer }) => {
53
+ try {
54
+ return numberVEA(ans, answer);
55
+ }
56
+ catch (err) {
57
+ return handleVEAError(err);
58
+ }
59
+ };
60
+ const getExponentialLawAverageQuestion = () => {
61
+ const lambda = randfloat(0.01, 1, 2);
62
+ const identifiers = {
63
+ lambda,
64
+ };
65
+ return getQuestionFromIdentifiers(identifiers);
66
+ };
67
+ const getQuestionFromIdentifiers = (identifiers) => {
68
+ return {
69
+ answer: getAnswer(identifiers),
70
+ instruction: getInstruction(identifiers),
71
+ keys: getKeys(identifiers),
72
+ answerFormat: "tex",
73
+ identifiers,
74
+ hint: getHint(identifiers),
75
+ correction: getCorrection(identifiers),
76
+ };
77
+ };
78
+ export const exponentialLawAverage = {
79
+ id: "exponentialLawAverage",
80
+ connector: "=",
81
+ label: "Calculer l'espérance d'une loi exponentielle",
82
+ isSingleStep: true,
83
+ generator: (nb, opts) => getDistinctQuestions(() => getExponentialLawAverageQuestion(opts), nb),
84
+ qcmTimer: 60,
85
+ freeTimer: 60,
86
+ getPropositions,
87
+ isAnswerValid,
88
+ subject: "Mathématiques",
89
+ getInstruction,
90
+ getHint,
91
+ getCorrection,
92
+ getAnswer,
93
+ getQuestionFromIdentifiers,
94
+ hasHintAndCorrection: true,
95
+ };
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ lambda: number;
4
+ a: number;
5
+ b: number;
6
+ };
7
+ export declare const exponentialLawComputeIntervalProba: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=exponentialLawComputeIntervalProba.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exponentialLawComputeIntervalProba.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/exponential/exponentialLawComputeIntervalProba.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CAEX,CAAC;AA8GF,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CAAC,WAAW,CAmBpE,CAAC"}