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,265 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randint } from "../../../../math/utils/random/randint.js";
4
+ import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
5
+ import { power } from "../../../../tree/nodes/operators/powerNode.js";
6
+ import { ClosureType } from "../../../../tree/nodes/sets/closure.js";
7
+ import { IntervalNode } from "../../../../tree/nodes/sets/intervalNode.js";
8
+ import { random } from "../../../../utils/alea/random.js";
9
+ const codify = (strPython) => {
10
+ return `\`\`\`python
11
+ ${strPython}
12
+ \`\`\``;
13
+ };
14
+ const codifyChunk = (strPython) => {
15
+ return `\`${strPython}\``;
16
+ };
17
+ const createStrPythonForNode = (node) => {
18
+ return node.toMathString().replaceAll("^", "**");
19
+ };
20
+ const getHydrated = (identifiers) => {
21
+ const { nodeIdsInterval, nodeIdsDistanceMax } = identifiers;
22
+ const nodeInterval = NodeConstructor.fromIdentifiers(nodeIdsInterval);
23
+ const nodeDistanceMax = NodeConstructor.fromIdentifiers(nodeIdsDistanceMax);
24
+ return {
25
+ nodeInterval,
26
+ nodeDistanceMax,
27
+ };
28
+ };
29
+ const _getStrPythonProgram = (identifiers) => {
30
+ const { nodeInterval, nodeDistanceMax } = getHydrated(identifiers);
31
+ const [strIntervalBoundA, strIntervalBoundB] = [
32
+ nodeInterval.a,
33
+ nodeInterval.b,
34
+ ].map(createStrPythonForNode);
35
+ const strDistanceMax = createStrPythonForNode(nodeDistanceMax);
36
+ return `def encadrement(f,a,b, precision):
37
+ xL,xR = a,b #
38
+ while True:
39
+ xL,xR = dichotomie(f,xL,xR) #
40
+ if(xR-xL < precision): #
41
+ return xL,xR
42
+
43
+ def dichotomie(f, a, b):
44
+ m = (a+b) / 2 #
45
+ if f(a) * f(m) <= 0: #
46
+ return a, m #
47
+ else:
48
+ return m,b #
49
+
50
+ xL,xR = encadrement(f, ${strIntervalBoundA} , ${strIntervalBoundB} , ${strDistanceMax})
51
+ print(xL, "<=", "alpha", "<=", xR)`;
52
+ };
53
+ const getStrPythonProgramComplete = (identifiers) => {
54
+ const identifiersTweaked = {
55
+ ...identifiers,
56
+ keyIncomplete: "",
57
+ };
58
+ return getStrPythonProgramIncomplete(identifiersTweaked);
59
+ };
60
+ const getStrPythonProgramIncomplete = (identifiers) => {
61
+ const { keyIncomplete } = identifiers;
62
+ const { strEncadrementInitialization, strEncadrementDichotomie, strEncadrementCondition, strDichotomieM, strDichotomieCondition, strDichotomieBlockValid, strDichotomieBlockInvalid, strCallEncadrement, } = Object.fromEntries(Object.entries(getDictStrCompletion(identifiers)).map(([key, str]) => key === keyIncomplete ? [key, "..."] : [key, str]));
63
+ return `def encadrement(f,a,b, precision):
64
+ ${strEncadrementInitialization}
65
+ while True:
66
+ ${strEncadrementDichotomie}
67
+ ${strEncadrementCondition}
68
+ return xL,xR
69
+
70
+ def dichotomie(f, a, b):
71
+ ${strDichotomieM}
72
+ ${strDichotomieCondition}
73
+ ${strDichotomieBlockValid}
74
+ else:
75
+ ${strDichotomieBlockInvalid}
76
+
77
+ ${strCallEncadrement}
78
+ print(xL, "<=", "alpha", "<=", xR)`;
79
+ };
80
+ const getDictStrCompletion = (identifiers) => {
81
+ const { nodeInterval, nodeDistanceMax } = getHydrated(identifiers);
82
+ const [strIntervalBoundA, strIntervalBoundB] = [
83
+ nodeInterval.a,
84
+ nodeInterval.b,
85
+ ].map(createStrPythonForNode);
86
+ const strDistanceMax = createStrPythonForNode(nodeDistanceMax);
87
+ return {
88
+ strEncadrementInitialization: `xL,xR = a,b`,
89
+ strEncadrementDichotomie: `xL,xR = dichotomie(f,xL,xR)`,
90
+ strEncadrementCondition: `if(xR-xL < precision):`,
91
+ strDichotomieM: `m = (a+b)/2`,
92
+ strDichotomieCondition: `if f(a) * f(m) <= 0:`,
93
+ strDichotomieBlockValid: `return a,m`,
94
+ strDichotomieBlockInvalid: `return m,b`,
95
+ strCallEncadrement: `xL,xR = encadrement(f,${strIntervalBoundA}, ${strIntervalBoundB},${strDistanceMax})`,
96
+ };
97
+ };
98
+ const getInstruction = (identifiers) => {
99
+ const { nodeInterval, nodeDistanceMax } = getHydrated(identifiers);
100
+ return `On considère une fonction $f$ strictement monotone sur $${nodeInterval.toTex()}$ et qui change de signe sur cet intervalle.
101
+ On veut déterminer un encadrement de $\\alpha$ tel que $f(\\alpha)=0$ en utilisant un algorithme de dichotomie.
102
+
103
+ Dans le programme suivant,
104
+ on suppose que l'on dispose d'une fonction ${codifyChunk("f")}
105
+ telle que ${codifyChunk("f(x)")} retourne $f(x)$.
106
+
107
+ Par quoi faut-il remplacer les pointillés dans le programme suivant
108
+ pour qu'il affiche un encadrement de $\\alpha$ avec un écart strictement inférieur à $${nodeDistanceMax.toTex()}$ ?
109
+
110
+ ${codify(getStrPythonProgramIncomplete(identifiers))}
111
+
112
+ `;
113
+ };
114
+ const getAnswer = (identifiers) => {
115
+ const { keyIncomplete } = identifiers;
116
+ const dictStrCompletion = getDictStrCompletion(identifiers);
117
+ return codifyChunk(dictStrCompletion[keyIncomplete]);
118
+ };
119
+ const getHint = (identifiers) => {
120
+ const { keyIncomplete } = identifiers;
121
+ switch (keyIncomplete) {
122
+ case "strEncadrementInitialization":
123
+ return `Au départ, notre première estimation pour l'abscisse "à gauche" est $a$ et notre première estimation pour l'abscisse "à droite" est $b$.`;
124
+ case "strEncadrementDichotomie":
125
+ return `On veut trouver les nouvelles abscisses "à gauche" et "à droite" obtenue après dichotomie.`;
126
+ case "strEncadrementCondition":
127
+ return `Écris en Python "Si la différence de l'abscisse "à droite" avec l'abscisse "à gauche" est inférieure à $precision$ alors"`;
128
+ case "strDichotomieM":
129
+ return `Dans un algorithme par dichotomie, on coupe l'intervalle considéré en $2$ et on détermine si l'on garde le côté gauche ou le côté droit.`;
130
+ case "strDichotomieCondition":
131
+ return `Pour détecter un changement de signe de $f$, on utilise la propriété suivante : Le produit de deux nombres de signes différents est négatif.`;
132
+ case "strDichotomieBlockValid":
133
+ return `On a coupé en deux et dans ce cas, on veut garder le côté gauche.`;
134
+ case "strDichotomieBlockInvalid":
135
+ return `On a coupé en deux et dans ce cas, on veut garder le côté droit.`;
136
+ default:
137
+ throw new Error("Unsupported keyIncomplete: " + keyIncomplete);
138
+ }
139
+ };
140
+ const getCorrection = (identifiers) => {
141
+ return `Voici le programme complet :
142
+
143
+ ${codify(getStrPythonProgramComplete(identifiers))}
144
+
145
+ `;
146
+ };
147
+ const getPropositions = (n, { answer, ...identifiers }) => {
148
+ const propositions = [];
149
+ addValidProp(propositions, answer, "raw");
150
+ const { keyIncomplete } = identifiers;
151
+ switch (keyIncomplete) {
152
+ case "strEncadrementInitialization":
153
+ {
154
+ ["xL,xR = 0,0", "xR,xL = a,b", "xR,xL = 0,0"].forEach((str) => tryToAddWrongProp(propositions, codifyChunk(str), "raw"));
155
+ }
156
+ break;
157
+ case "strEncadrementDichotomie":
158
+ {
159
+ [
160
+ "xR,xL = dichotomie(f,a,b)",
161
+ "a,b = dichotomie(f,xL,xR)",
162
+ `dichotomie(f,xL,xR)`,
163
+ ].forEach((str) => tryToAddWrongProp(propositions, codifyChunk(str), "raw"));
164
+ }
165
+ break;
166
+ case "strEncadrementCondition":
167
+ {
168
+ [
169
+ "if(xR-xL < precision):",
170
+ "if(xR-xL > precision):",
171
+ "if(xL-xR < precision):",
172
+ ].forEach((str) => tryToAddWrongProp(propositions, codifyChunk(str), "raw"));
173
+ }
174
+ break;
175
+ case "strDichotomieM":
176
+ {
177
+ ["m = (b-a)/2", "m = a+b", "m = b-a"].forEach((str) => tryToAddWrongProp(propositions, codifyChunk(str), "raw"));
178
+ }
179
+ break;
180
+ case "strDichotomieCondition":
181
+ {
182
+ [
183
+ "if f(a) - f(m) <= 0:",
184
+ "if f(a) < 0 and f(m) > 0:",
185
+ "if f(a) > 0 and f(m) < 0:",
186
+ ].forEach((str) => tryToAddWrongProp(propositions, codifyChunk(str), "raw"));
187
+ }
188
+ break;
189
+ case "strDichotomieBlockValid":
190
+ {
191
+ [
192
+ "return a, (a+m)/2",
193
+ "return (a+m)/2, m",
194
+ "return (a+m)/2, (b+m)/2",
195
+ ].forEach((str) => tryToAddWrongProp(propositions, codifyChunk(str), "raw"));
196
+ }
197
+ break;
198
+ case "strDichotomieBlockInvalid":
199
+ {
200
+ [
201
+ "return m, (m+b)/2",
202
+ "return (m+b)/2, b",
203
+ "return (a+m)/2, (b+m)/2",
204
+ ].forEach((str) => tryToAddWrongProp(propositions, codifyChunk(str), "raw"));
205
+ }
206
+ break;
207
+ default:
208
+ throw new Error("Unsupported keyIncomplete: " + keyIncomplete);
209
+ }
210
+ return shuffleProps(propositions, n);
211
+ };
212
+ const createRandomIdentifiers = () => {
213
+ const nodeDistanceMax = power(10, randint(-3, 0));
214
+ const keyIncomplete = random([
215
+ "strEncadrementInitialization",
216
+ "strEncadrementDichotomie",
217
+ "strEncadrementCondition",
218
+ "strDichotomieM",
219
+ "strDichotomieCondition",
220
+ "strDichotomieBlockValid",
221
+ "strDichotomieBlockInvalid",
222
+ // "strCallEncadrement",
223
+ ]);
224
+ const nodeInterval = (() => {
225
+ const a = randint(-5, 5);
226
+ const b = a + randint(1, 5);
227
+ return new IntervalNode(a.toTree(), b.toTree(), ClosureType.FF);
228
+ })();
229
+ const identifiers = {
230
+ nodeIdsInterval: nodeInterval.toIdentifiers(),
231
+ nodeIdsDistanceMax: nodeDistanceMax.toIdentifiers(),
232
+ keyIncomplete,
233
+ };
234
+ return identifiers;
235
+ };
236
+ const getPyContinuityDichotomyInstructionCompletionQuestion = () => {
237
+ const identifiers = createRandomIdentifiers();
238
+ return getQuestionFromIdentifiers(identifiers);
239
+ };
240
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
241
+ const question = {
242
+ answer: getAnswer(identifiers, opts),
243
+ instruction: getInstruction(identifiers, opts),
244
+ keys: [],
245
+ answerFormat: "tex",
246
+ identifiers,
247
+ hint: getHint(identifiers, opts),
248
+ correction: getCorrection(identifiers, opts),
249
+ options: opts,
250
+ };
251
+ return question;
252
+ };
253
+ export const pyContinuityDichotomyInstructionCompletion = {
254
+ id: "pyContinuityDichotomyInstructionCompletion",
255
+ label: "Compléter le script d'un algorithme d'encadrement par dichotomie de $\\alpha$ tel que $f(\\alpha)=0$",
256
+ isSingleStep: true,
257
+ generator: (nb, opts) => getDistinctQuestions(() => getPyContinuityDichotomyInstructionCompletionQuestion(opts), nb),
258
+ qcmTimer: 60,
259
+ freeTimer: 60,
260
+ getPropositions,
261
+ subject: "Mathématiques",
262
+ getQuestionFromIdentifiers,
263
+ hasHintAndCorrection: true,
264
+ answerType: "QCU",
265
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"log10Simplifying.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/logarithm/log10Simplifying.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAuIF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgB9D,CAAC;AACF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgB5D,CAAC"}
1
+ {"version":3,"file":"log10Simplifying.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/logarithm/log10Simplifying.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AA8KF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiB9D,CAAC;AACF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiB5D,CAAC"}
@@ -1,16 +1,16 @@
1
1
  import { addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { randint } from "../../../../math/utils/random/randint.js";
4
- import { Log10Node } from "../../../../tree/nodes/functions/log10Node.js";
5
- import { LogNode } from "../../../../tree/nodes/functions/logNode.js";
4
+ import { log10, Log10Node } from "../../../../tree/nodes/functions/log10Node.js";
5
+ import { logn, LogNode } from "../../../../tree/nodes/functions/logNode.js";
6
6
  import { OppositeNode } from "../../../../tree/nodes/functions/oppositeNode.js";
7
7
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
8
8
  import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
9
9
  import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
10
- import { PowerNode } from "../../../../tree/nodes/operators/powerNode.js";
10
+ import { power, PowerNode } from "../../../../tree/nodes/operators/powerNode.js";
11
11
  import { operatorComposition } from "../../../../tree/utilities/operatorComposition.js";
12
12
  import { random } from "../../../../utils/alea/random.js";
13
- const getInstruction = (identifiers, opts) => {
13
+ const getStatement = (identifiers, opts) => {
14
14
  const { nb, powers, signs } = identifiers;
15
15
  const nbNode = new NumberNode(nb);
16
16
  const LNode = opts?.isLog10 ? Log10Node : LogNode;
@@ -21,8 +21,13 @@ const getInstruction = (identifiers, opts) => {
21
21
  : signs[index] > 0
22
22
  ? new LNode(new PowerNode(nbNode, new NumberNode(power)))
23
23
  : new OppositeNode(new LNode(new PowerNode(nbNode, new NumberNode(power)))));
24
- const trueNb = [2, 4, 8].includes(nb) ? 2 : [3, 9].includes(nb) ? 3 : nb;
25
24
  const statement = operatorComposition(AddNode, logs);
25
+ return statement;
26
+ };
27
+ const getInstruction = (identifiers, opts) => {
28
+ const { nb } = identifiers;
29
+ const trueNb = [2, 4, 8].includes(nb) ? 2 : [3, 9].includes(nb) ? 3 : nb;
30
+ const statement = getStatement(identifiers, opts);
26
31
  return `Exprimer le nombre suivant sous la forme $a${opts?.isLog10 ? "\\log" : "\\ln"}\\left(${trueNb}\\right)$ :
27
32
 
28
33
  $$
@@ -30,18 +35,7 @@ ${statement.toTex()}
30
35
  $$`;
31
36
  };
32
37
  const getAnswer = (identifiers, opts) => {
33
- const { nb, powers, signs } = identifiers;
34
- const nbNode = new NumberNode(nb);
35
- const LNode = opts?.isLog10 ? Log10Node : LogNode;
36
- const logs = powers.map((power, index) => nb ** power < 100
37
- ? signs[index] > 0
38
- ? new LNode(new NumberNode(nb ** power))
39
- : new OppositeNode(new LNode(new NumberNode(nb ** power)))
40
- : signs[index] > 0
41
- ? new LNode(new PowerNode(nbNode, new NumberNode(power)))
42
- : new OppositeNode(new LNode(new PowerNode(nbNode, new NumberNode(power)))));
43
- const statement = operatorComposition(AddNode, logs);
44
- const answer = statement.simplify();
38
+ const answer = getStatement(identifiers, opts).simplify();
45
39
  return answer.toTex();
46
40
  };
47
41
  const getQuestionFromIdentifiers = (identifiers, opts) => {
@@ -51,6 +45,9 @@ const getQuestionFromIdentifiers = (identifiers, opts) => {
51
45
  keys: getKeys(identifiers, opts),
52
46
  answerFormat: "tex",
53
47
  identifiers,
48
+ hint: getHint(identifiers, opts),
49
+ correction: getCorrection(identifiers, opts),
50
+ options: opts,
54
51
  };
55
52
  return question;
56
53
  };
@@ -58,7 +55,7 @@ const getKeys = (_identifiers, opts) => {
58
55
  return [opts?.isLog10 ? "logBrackets" : "lnBrackets"];
59
56
  };
60
57
  const getLog10SumSimplifyingQuestion = (opts) => {
61
- const nb = randint(2, 10);
58
+ const nb = random([2, 3, 5, 6, 7]);
62
59
  const nbTerms = randint(2, 4);
63
60
  const powers = [];
64
61
  const signs = [];
@@ -81,25 +78,65 @@ const getPropositions = (n, { answer, nb, isLog10 }) => {
81
78
  });
82
79
  return shuffleProps(propositions, n);
83
80
  };
84
- const isAnswerValid = (ans, { nb, powers, signs, isLog10 }) => {
85
- const nbNode = new NumberNode(nb);
86
- const LNode = isLog10 ? Log10Node : LogNode;
87
- const logs = powers.map((power, index) => nb ** power < 100
88
- ? signs[index] > 0
89
- ? new LNode(new NumberNode(nb ** power))
90
- : new OppositeNode(new LNode(new NumberNode(nb ** power)))
91
- : signs[index] > 0
92
- ? new LNode(new PowerNode(nbNode, new NumberNode(power)))
93
- : new OppositeNode(new LNode(new PowerNode(nbNode, new NumberNode(power)))));
94
- const statement = operatorComposition(AddNode, logs);
95
- const answer = statement.simplify();
96
- const texs = answer.toAllValidTexs();
81
+ const getHint = (_identifiers, opts) => {
82
+ const logString = opts?.isLog10 ? "\\log" : "\\ln";
83
+ return `Pour tous nombres réels $a$ et $b$ strictement positifs, on a :
84
+
85
+ - $${logString}(a) + ${logString}(b) = ${logString}(a\\times b)$
86
+ - $${logString}(a) - ${logString}(b) = ${logString}(\\frac{a}{b})$
87
+ - $${logString}(a^b) = b ${logString}(a)$`;
88
+ };
89
+ const getCorrection = (identifiers, opts) => {
90
+ const { nb, powers } = identifiers;
91
+ const fct = opts?.isLog10 ? log10 : logn;
92
+ const logString = opts?.isLog10 ? "\\log" : "\\ln";
93
+ const trueNb = [2, 4, 8].includes(nb) ? 2 : [3, 9].includes(nb) ? 3 : nb;
94
+ const truePowers = powers.map((pow) => {
95
+ if (nb !== trueNb) {
96
+ const truePow = Math.floor(Math.log(nb) / Math.log(trueNb));
97
+ return power(trueNb, truePow);
98
+ }
99
+ if (pow === 1)
100
+ return trueNb.toTree();
101
+ return power(trueNb, pow);
102
+ });
103
+ return `Pour tous nombres réels $a$ et $b$ strictement positifs, on a :
104
+
105
+ - $${logString}(a) + ${logString}(b) = ${logString}(a\\times b)$
106
+ - $${logString}(a) - ${logString}(b) = ${logString}(\\frac{a}{b})$
107
+ - $${logString}(a^b) = b ${logString}(a)$
108
+
109
+ On applique ces propriétés ici pour simplifier l'expression :
110
+
111
+ ${truePowers
112
+ .map((e) => {
113
+ if (e.evaluate() === trueNb)
114
+ return "";
115
+ if (e.evaluate() < 100)
116
+ return `- $${fct(e.evaluate().frenchify()).toTex()} = ${fct(e).toSimplificationTex()}$`;
117
+ return `- $${fct(e).toSimplificationTex()}$`;
118
+ })
119
+ .filter(Boolean)
120
+ .join("\n \n")}
121
+
122
+ En additionnant, on obtient donc l'expression simplifiée :
123
+
124
+ $$
125
+ ${getStatement(identifiers, opts).toTex()} = ${getAnswer(identifiers, opts)}
126
+ $$
127
+ `;
128
+ };
129
+ const isAnswerValid = (ans, { answer, ...identifiers }, opts) => {
130
+ const statement = getStatement(identifiers, opts);
131
+ console.log(opts, identifiers);
132
+ const answerNode = statement.simplify();
133
+ const texs = answerNode.toAllValidTexs();
97
134
  return texs.includes(ans);
98
135
  };
99
136
  export const log10SumSimplifying = {
100
137
  id: "log10SumSimplifying",
101
138
  connector: "=",
102
- label: "Simplifier une somme de logarithmes décimaux",
139
+ label: "Simplifier une expression avec des logarithmes décimaux",
103
140
  isSingleStep: true,
104
141
  generator: (nb) => getDistinctQuestions(() => getLog10SumSimplifyingQuestion({ isLog10: true }), nb),
105
142
  qcmTimer: 60,
@@ -108,11 +145,12 @@ export const log10SumSimplifying = {
108
145
  isAnswerValid,
109
146
  subject: "Mathématiques",
110
147
  getQuestionFromIdentifiers,
148
+ hasHintAndCorrection: true,
111
149
  };
112
150
  export const logSumSimplifying = {
113
151
  id: "logSumSimplifying",
114
152
  connector: "=",
115
- label: "Simplifier une somme de logarithmes népériens",
153
+ label: "Simplifier une expression avec des logarithmes népériens",
116
154
  isSingleStep: true,
117
155
  generator: (nb) => getDistinctQuestions(() => getLog10SumSimplifyingQuestion({ isLog10: false }), nb),
118
156
  qcmTimer: 60,
@@ -121,4 +159,5 @@ export const logSumSimplifying = {
121
159
  isAnswerValid,
122
160
  subject: "Mathématiques",
123
161
  getQuestionFromIdentifiers,
162
+ hasHintAndCorrection: true,
124
163
  };
@@ -1 +1 @@
1
- {"version":3,"file":"logEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/logarithm/logEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAcrC,cAAc;AACd,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA0FF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,WAAW,CAY7C,CAAC"}
1
+ {"version":3,"file":"logEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/logarithm/logEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAerC,cAAc;AACd,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAgIF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,WAAW,CAa7C,CAAC"}
@@ -3,7 +3,7 @@ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQue
3
3
  import { Rational } from "../../../../math/numbers/rationals/rational.js";
4
4
  import { randint } from "../../../../math/utils/random/randint.js";
5
5
  import { EquationSolutionNode } from "../../../../tree/nodes/equations/equationSolutionNode.js";
6
- import { ExpNode } from "../../../../tree/nodes/functions/expNode.js";
6
+ import { exp, ExpNode } from "../../../../tree/nodes/functions/expNode.js";
7
7
  import { LogNode } from "../../../../tree/nodes/functions/logNode.js";
8
8
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
9
9
  import { EqualNode } from "../../../../tree/nodes/equations/equalNode.js";
@@ -11,6 +11,7 @@ import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
11
11
  import { DiscreteSetNode } from "../../../../tree/nodes/sets/discreteSetNode.js";
12
12
  import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
13
13
  import { shuffle } from "../../../../utils/alea/shuffle.js";
14
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
14
15
  const getKeys = () => {
15
16
  return [
16
17
  "x",
@@ -40,11 +41,45 @@ const getAnswer = (identifiers) => {
40
41
  return answer;
41
42
  };
42
43
  const getLnEquation = () => {
43
- const a = randint(-9, 20, [0]);
44
+ const a = randint(-9, 20, [0, 1]);
44
45
  const k = randint(-9, 20, [0]);
45
46
  const identifiers = { a, k };
46
47
  return getQuestionFromIdentifiers(identifiers);
47
48
  };
49
+ const getHint = () => {
50
+ return `Isole $\\ln(x)$ d'un côté de l'équation. Puis, utilise la propriété suivante : pour tout nombre réel $x>0$ et tout nombre réel $k$, on a :
51
+
52
+ $$
53
+ \\ln(x) = k \\iff x = e^{k}
54
+ $$`;
55
+ };
56
+ const getCorrection = (identifiers) => {
57
+ const { a, k } = identifiers;
58
+ return `On isole $\\ln(x)$ d'un côté de l'équation :
59
+
60
+ $$
61
+ \\ln(x) = ${frac(k, a).toSimplificationTex()}
62
+ $$
63
+
64
+ Puis, on applique l'exponentielle. En effet, pour tout nombre réel $x>0$ et tout nombre réel $k$, on a :
65
+
66
+ $$
67
+ \\ln(x) = k \\iff x = e^{k}
68
+ $$
69
+
70
+ Ici, on a donc :
71
+
72
+ $$
73
+ x = ${exp(frac(k, a).simplify()).toTex()}
74
+ $$
75
+
76
+ La solution de l'équation est donc :
77
+
78
+ $$
79
+ ${getAnswer(identifiers)}
80
+ $$
81
+ `;
82
+ };
48
83
  const getQuestionFromIdentifiers = (identifiers) => {
49
84
  const question = {
50
85
  instruction: getInstruction(identifiers),
@@ -52,6 +87,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
52
87
  keys: getKeys(identifiers),
53
88
  answerFormat: "tex",
54
89
  identifiers,
90
+ hint: getHint(identifiers),
91
+ correction: getCorrection(identifiers),
55
92
  };
56
93
  return question;
57
94
  };
@@ -86,4 +123,5 @@ export const logEquation = {
86
123
  isAnswerValid,
87
124
  subject: "Mathématiques",
88
125
  getQuestionFromIdentifiers,
126
+ hasHintAndCorrection: true,
89
127
  };
@@ -1 +1 @@
1
- {"version":3,"file":"logPowerEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/logarithm/logPowerEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAmBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,EAAE,MAAM,CAAC;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAmHF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAc3D,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiB7D,CAAC"}
1
+ {"version":3,"file":"logPowerEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/logarithm/logPowerEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAwBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,EAAE,MAAM,CAAC;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAyKF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAe3D,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkB7D,CAAC"}
@@ -3,18 +3,20 @@ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQue
3
3
  import { randint } from "../../../../math/utils/random/randint.js";
4
4
  import { EqualNode } from "../../../../tree/nodes/equations/equalNode.js";
5
5
  import { EquationSolutionNode } from "../../../../tree/nodes/equations/equationSolutionNode.js";
6
- import { Log10Node } from "../../../../tree/nodes/functions/log10Node.js";
7
- import { LogNode } from "../../../../tree/nodes/functions/logNode.js";
6
+ import { log10, Log10Node } from "../../../../tree/nodes/functions/log10Node.js";
7
+ import { logn, LogNode } from "../../../../tree/nodes/functions/logNode.js";
8
8
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
9
9
  import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
10
- import { FractionNode } from "../../../../tree/nodes/operators/fractionNode.js";
11
- import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
12
- import { PowerNode } from "../../../../tree/nodes/operators/powerNode.js";
10
+ import { frac, FractionNode } from "../../../../tree/nodes/operators/fractionNode.js";
11
+ import { multiply, MultiplyNode, } from "../../../../tree/nodes/operators/multiplyNode.js";
12
+ import { power, PowerNode } from "../../../../tree/nodes/operators/powerNode.js";
13
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
13
14
  import { DiscreteSetNode } from "../../../../tree/nodes/sets/discreteSetNode.js";
14
15
  import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
15
16
  import { discreteSetParser } from "../../../../tree/parsers/discreteSetParser.js";
16
17
  import { equationSolutionParser } from "../../../../tree/parsers/equationSolutionParser.js";
17
18
  import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
19
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
18
20
  /**a*b^x+c=d */
19
21
  const getKeys = (_identifiers, opts) => {
20
22
  const keys = ["x", "equal", "S", "lbrace", "semicolon", "rbrace"];
@@ -44,12 +46,55 @@ const getAnswer = (identifiers, opts) => {
44
46
  };
45
47
  const getLogPowerEquationQuestion = (opts) => {
46
48
  const powered = randint(2, 8);
47
- const a = randint(1, 10, [powered]);
49
+ const a = randint(2, 10, [powered]);
48
50
  const c = randint(-5, 5, [a]);
49
51
  const k = randint(5, 15, [powered]);
50
52
  const identifiers = { a, c, k, powered, isLog10: opts?.isLog10 ?? false };
51
53
  return getQuestionFromIdentifiers(identifiers, opts);
52
54
  };
55
+ const getHint = (identifiers, opts) => {
56
+ const logString = opts?.isLog10 ? "\\log" : "\\ln";
57
+ const { powered } = identifiers;
58
+ const powerN = power(powered, "x");
59
+ return `Commence par isoler $${powerN.toTex()}$ d'un côté de l'équation.
60
+
61
+ Puis, applique le logarithme sur les deux membres de l'équation.
62
+
63
+ Cela te permettra d'obtenir la solution, en utilisant la propriété suivante : pour tout nombre réel $a>0$ et tout nombre réel $b$,
64
+
65
+ $$
66
+ ${logString}(a^b) = b${logString}(a)
67
+ $$
68
+ `;
69
+ };
70
+ const getCorrection = (identifiers, opts) => {
71
+ const { a, powered, c, k } = identifiers;
72
+ const d = k * a + c;
73
+ const powerN = power(powered, "x");
74
+ const loga = opts?.isLog10 ? log10 : logn;
75
+ //a*powered^x+c = d
76
+ //poweerd^x = (d-c)/a
77
+ const b = frac(substract(d, c), a).simplify();
78
+ return `On commence par isoler $${powerN.toTex()}$ d'un côté de l'équation :
79
+
80
+ $$
81
+ ${powerN.toTex()} = ${frac(substract(d, c), a).toSimplificationTex()}
82
+ $$
83
+
84
+ Ensuite, on applique le logarithme sur les deux membres de l'équation (ce qui est possible car les deux membres sont strictement positifs), et on utilise la propriété $${loga("a^x").toTex()}= x${loga("a").toTex()}$ :
85
+
86
+ ${alignTex([
87
+ [loga(powerN).toTex(), "=", loga(b).toTex()],
88
+ [multiply("x", loga(powered)).toTex(), "=", loga(b).toTex()],
89
+ ["x", "=", frac(loga(b), loga(powered)).toTex()],
90
+ ])}
91
+
92
+ La solution est donc :
93
+
94
+ $$
95
+ ${getAnswer(identifiers, opts)}
96
+ $$`;
97
+ };
53
98
  const getQuestionFromIdentifiers = (identifiers, opts) => {
54
99
  const question = {
55
100
  answer: getAnswer(identifiers, opts),
@@ -57,6 +102,8 @@ const getQuestionFromIdentifiers = (identifiers, opts) => {
57
102
  keys: getKeys(identifiers, opts),
58
103
  answerFormat: "tex",
59
104
  identifiers,
105
+ hint: getHint(identifiers, opts),
106
+ correction: getCorrection(identifiers, opts),
60
107
  };
61
108
  return question;
62
109
  };
@@ -106,6 +153,7 @@ export const logPowerEquation = {
106
153
  isAnswerValid,
107
154
  subject: "Mathématiques",
108
155
  getQuestionFromIdentifiers,
156
+ hasHintAndCorrection: true,
109
157
  };
110
158
  export const log10PowerEquation = {
111
159
  id: "log10PowerEquation",
@@ -119,4 +167,5 @@ export const log10PowerEquation = {
119
167
  isAnswerValid,
120
168
  subject: "Mathématiques",
121
169
  getQuestionFromIdentifiers,
170
+ hasHintAndCorrection: true,
122
171
  };
@@ -1 +1 @@
1
- {"version":3,"file":"logSimplifiying.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/logarithm/logSimplifiying.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA2FF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAYjD,CAAC"}
1
+ {"version":3,"file":"logSimplifiying.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/logarithm/logSimplifiying.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAkIF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAcjD,CAAC"}