math-exercises 3.0.108 → 3.0.109

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 (81) hide show
  1. package/lib/exercises/math/calcul/arithmetics/divisibiltyCriteria.d.ts.map +1 -1
  2. package/lib/exercises/math/calcul/rounding/getPhysicalOrderOfMagnitude.d.ts +7 -0
  3. package/lib/exercises/math/calcul/rounding/getPhysicalOrderOfMagnitude.d.ts.map +1 -0
  4. package/lib/exercises/math/calcul/rounding/getPhysicalOrderOfMagnitude.js +197 -0
  5. package/lib/exercises/math/calcul/rounding/index.d.ts +1 -0
  6. package/lib/exercises/math/calcul/rounding/index.d.ts.map +1 -1
  7. package/lib/exercises/math/calcul/rounding/index.js +1 -0
  8. package/lib/exercises/math/calcul/writing/numberToFrenchWriting.js +0 -1
  9. package/lib/exercises/math/calculLitteral/factorisation/factoType2.d.ts.map +1 -1
  10. package/lib/exercises/math/calculLitteral/formulas/index.d.ts +2 -0
  11. package/lib/exercises/math/calculLitteral/formulas/index.d.ts.map +1 -0
  12. package/lib/exercises/math/calculLitteral/formulas/index.js +1 -0
  13. package/lib/exercises/math/calculLitteral/formulas/useFormula.d.ts +18 -0
  14. package/lib/exercises/math/calculLitteral/formulas/useFormula.d.ts.map +1 -0
  15. package/lib/exercises/math/calculLitteral/formulas/useFormula.js +208 -0
  16. package/lib/exercises/math/calculLitteral/index.d.ts +1 -0
  17. package/lib/exercises/math/calculLitteral/index.d.ts.map +1 -1
  18. package/lib/exercises/math/calculLitteral/index.js +1 -0
  19. package/lib/exercises/math/calculLitteral/writing/index.d.ts +2 -0
  20. package/lib/exercises/math/calculLitteral/writing/index.d.ts.map +1 -0
  21. package/lib/exercises/math/calculLitteral/writing/index.js +1 -0
  22. package/lib/exercises/math/calculLitteral/writing/writeLitExpFromFrenchExp.d.ts +33 -0
  23. package/lib/exercises/math/calculLitteral/writing/writeLitExpFromFrenchExp.d.ts.map +1 -0
  24. package/lib/exercises/math/calculLitteral/writing/writeLitExpFromFrenchExp.js +348 -0
  25. package/lib/exercises/math/dataRepresentations/functionGraphReading.d.ts.map +1 -1
  26. package/lib/exercises/math/dataRepresentations/pieChartReading.d.ts.map +1 -1
  27. package/lib/exercises/math/derivation/tangent/derivativeTangentEquationReading.d.ts.map +1 -1
  28. package/lib/exercises/math/derivation/variations/index.d.ts +1 -0
  29. package/lib/exercises/math/derivation/variations/index.d.ts.map +1 -1
  30. package/lib/exercises/math/derivation/variations/index.js +1 -0
  31. package/lib/exercises/math/derivation/variations/thirdDegreeDerivativeVariation.d.ts +10 -0
  32. package/lib/exercises/math/derivation/variations/thirdDegreeDerivativeVariation.d.ts.map +1 -0
  33. package/lib/exercises/math/derivation/variations/thirdDegreeDerivativeVariation.js +201 -0
  34. package/lib/exercises/math/functions/basics/graphicInequationAffine.d.ts.map +1 -1
  35. package/lib/exercises/math/functions/logarithm/index.d.ts +1 -0
  36. package/lib/exercises/math/functions/logarithm/index.d.ts.map +1 -1
  37. package/lib/exercises/math/functions/logarithm/index.js +1 -0
  38. package/lib/exercises/math/functions/logarithm/powerEquation.d.ts +11 -0
  39. package/lib/exercises/math/functions/logarithm/powerEquation.d.ts.map +1 -0
  40. package/lib/exercises/math/functions/logarithm/powerEquation.js +148 -0
  41. package/lib/exercises/math/functions/trinoms/parabole/paraboleExpressionReading.d.ts.map +1 -1
  42. package/lib/exercises/math/functions/trinoms/roots/rootsReading.d.ts.map +1 -1
  43. package/lib/exercises/math/functions/trinoms/roots/rootsReading.js +28 -5
  44. package/lib/exercises/math/functions/variations/varTableExtremaReading.d.ts.map +1 -1
  45. package/lib/exercises/math/geometry/angles/recognizeAngleType.d.ts.map +1 -1
  46. package/lib/exercises/math/geometry/cartesian/placeAPoint.d.ts.map +1 -1
  47. package/lib/exercises/math/geometry/cartesian/placeAPoint.js +14 -0
  48. package/lib/exercises/math/geometry/cartesian/readAbscissOnLine.d.ts.map +1 -1
  49. package/lib/exercises/math/geometry/cartesian/readAbscissOnSemiLine.d.ts.map +1 -1
  50. package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.d.ts.map +1 -1
  51. package/lib/exercises/math/geometry/lines/linesRelativePositions.d.ts.map +1 -1
  52. package/lib/exercises/math/geometry/quadrilaterals/parallelogramAngles.d.ts.map +1 -1
  53. package/lib/exercises/math/geometry/quadrilaterals/quadrilateralRecognition.d.ts.map +1 -1
  54. package/lib/exercises/math/geometry/thales/thalesCalcul.d.ts.map +1 -1
  55. package/lib/exercises/math/geometry/triangles/triangleNature.d.ts.map +1 -1
  56. package/lib/exercises/math/geometry/triangles/triangleThirdAngleValue.d.ts.map +1 -1
  57. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOrthoInSquare.d.ts.map +1 -1
  58. package/lib/exercises/math/percent/evolutions/evolutionRateFromValues.d.ts.map +1 -1
  59. package/lib/exercises/math/percent/evolutions/findEndValueAfterEvolution.d.ts.map +1 -1
  60. package/lib/exercises/math/percent/evolutions/findStartValueAfterEvolution.d.ts.map +1 -1
  61. package/lib/exercises/math/percent/populationEffectifFromSubPopulation.d.ts.map +1 -1
  62. package/lib/exercises/math/percent/subPopulationEffectifFromPercent.d.ts.map +1 -1
  63. package/lib/exercises/math/sequences/arithmetic/arithmeticFindAntecedent.d.ts +9 -0
  64. package/lib/exercises/math/sequences/arithmetic/arithmeticFindAntecedent.d.ts.map +1 -0
  65. package/lib/exercises/math/sequences/arithmetic/arithmeticFindAntecedent.js +110 -0
  66. package/lib/exercises/math/sequences/arithmetic/index.d.ts +1 -0
  67. package/lib/exercises/math/sequences/arithmetic/index.d.ts.map +1 -1
  68. package/lib/exercises/math/sequences/arithmetic/index.js +1 -0
  69. package/lib/exercises/math/spaceGeometry/basis/spaceCoordinatesInPrism.d.ts.map +1 -1
  70. package/lib/exercises/math/trigonometry/arcLength.d.ts.map +1 -1
  71. package/lib/exercises/math/trigonometry/basicEquationCos.d.ts.map +1 -1
  72. package/lib/exercises/math/trigonometry/basicEquationSin.d.ts.map +1 -1
  73. package/lib/exercises/math/trigonometry/basicTrigoSystemEquation.d.ts.map +1 -1
  74. package/lib/exercises/math/trigonometry/degreeToRadians.d.ts.map +1 -1
  75. package/lib/exercises/math/trigonometry/mainAngleMeasure.d.ts.map +1 -1
  76. package/lib/index.d.ts +25 -0
  77. package/lib/index.d.ts.map +1 -1
  78. package/lib/tree/nodes/equations/equalNode.d.ts +1 -1
  79. package/lib/tree/nodes/equations/equalNode.d.ts.map +1 -1
  80. package/lib/tree/nodes/equations/equalNode.js +5 -5
  81. package/package.json +1 -1
@@ -0,0 +1,348 @@
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 { opposite } from '../../../../tree/nodes/functions/oppositeNode.js';
5
+ import { add } from '../../../../tree/nodes/operators/addNode.js';
6
+ import { divide } from '../../../../tree/nodes/operators/divideNode.js';
7
+ import { frac } from '../../../../tree/nodes/operators/fractionNode.js';
8
+ import { multiply } from '../../../../tree/nodes/operators/multiplyNode.js';
9
+ import { substract } from '../../../../tree/nodes/operators/substractNode.js';
10
+ import { parseAlgebraic } from '../../../../tree/parsers/latexParser.js';
11
+ import { coinFlip } from '../../../../utils/alea/coinFlip.js';
12
+ import { random } from '../../../../utils/alea/random.js';
13
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
14
+ const capitalize = (str) => {
15
+ if (!str)
16
+ return ''; // Handle empty strings
17
+ return str.charAt(0).toUpperCase() + str.slice(1);
18
+ };
19
+ const arr_operator = [
20
+ { outputName: "Opposite", arity: 1 },
21
+ { outputName: "Inverse", arity: 1 },
22
+ { outputName: "Sum", arity: 2 },
23
+ { outputName: "Difference", arity: 2 },
24
+ { outputName: "Product", arity: 2 },
25
+ { outputName: "Quotient", arity: 2 },
26
+ ];
27
+ const getNodeFromOperation = (operation) => {
28
+ let outNode;
29
+ if (!("b" in operation.operands)) {
30
+ const { a } = operation.operands;
31
+ switch (operation.operator.outputName) {
32
+ case "Opposite":
33
+ outNode = opposite(a);
34
+ break;
35
+ case "Inverse":
36
+ outNode = frac(1, a);
37
+ break;
38
+ }
39
+ }
40
+ else {
41
+ const { a, b } = operation.operands;
42
+ switch (operation.operator.outputName) {
43
+ case "Sum":
44
+ outNode = add(a, b);
45
+ break;
46
+ case "Difference":
47
+ outNode = substract(a, b);
48
+ break;
49
+ case "Product":
50
+ outNode = multiply(a, b);
51
+ break;
52
+ case "Quotient":
53
+ outNode = frac(a, b);
54
+ break;
55
+ }
56
+ }
57
+ return outNode;
58
+ };
59
+ const dict_texFactor_to_frenchFactor = {
60
+ [frac(1, 2).toTex()]: "la moitié",
61
+ [frac(1, 3).toTex()]: "le tiers",
62
+ [frac(1, 4).toTex()]: "le quart",
63
+ [frac(1, 5).toTex()]: "le cinquième",
64
+ [frac(1, 10).toTex()]: "le dixième",
65
+ [frac(1, 100).toTex()]: "le centième",
66
+ [frac(1, 1_000).toTex()]: "le millième",
67
+ [(2).frenchify()]: "le double",
68
+ [(3).frenchify()]: "le triple",
69
+ [(4).frenchify()]: "le quadruple",
70
+ [(5).frenchify()]: "le quintuple",
71
+ };
72
+ const buildFactorFrenchString = (tex__factor) => {
73
+ const str__french = dict_texFactor_to_frenchFactor[tex__factor];
74
+ return str__french;
75
+ };
76
+ const buildFrenchString = (identifiers) => {
77
+ const { operation, isUsingFrenchFactorNouns } = identifiers;
78
+ let str__french = "";
79
+ if (!("b" in operation.operands)) {
80
+ const { a } = operation.operands;
81
+ switch (operation.operator.outputName) {
82
+ case "Opposite":
83
+ str__french = `L'opposé de $ ${a} $`;
84
+ break;
85
+ case "Inverse":
86
+ str__french = `L'inverse de $ ${a} $`;
87
+ break;
88
+ }
89
+ }
90
+ else {
91
+ const { a, b } = operation.operands;
92
+ switch (operation.operator.outputName) {
93
+ case "Sum":
94
+ str__french = `La somme de $ ${a} $ et de $ ${b} $`;
95
+ break;
96
+ case "Difference":
97
+ str__french = `La différence entre $ ${a} $ et $ ${b} $`;
98
+ break;
99
+ case "Product":
100
+ {
101
+ str__french = `Le produit de $ ${a} $ par $ ${b} $`;
102
+ if (typeof b == 'string' && isUsingFrenchFactorNouns) {
103
+ //"le double de x"
104
+ const str__a__french = buildFactorFrenchString(a.frenchify());
105
+ if (str__a__french) {
106
+ str__french = `${str__a__french} de $ ${b} $`;
107
+ }
108
+ }
109
+ }
110
+ break;
111
+ case "Quotient":
112
+ {
113
+ str__french = `Le quotient de $ ${a} $ par $ ${b} $`;
114
+ if (typeof a == 'string' && isUsingFrenchFactorNouns) {
115
+ //"le tiers de x"
116
+ const oneOverB = frac(1, b);
117
+ const str__oneOverB__french = buildFactorFrenchString(oneOverB.toTex());
118
+ if (str__oneOverB__french) {
119
+ str__french = `${str__oneOverB__french} de $ ${a} $`;
120
+ }
121
+ }
122
+ }
123
+ break;
124
+ }
125
+ }
126
+ return str__french;
127
+ };
128
+ const getPropositions = (n, { answer, operation, isUsingFrenchFactorNouns }) => {
129
+ const propositions = [];
130
+ if (!("b" in operation.operands)) {
131
+ const { a } = operation.operands;
132
+ switch (operation.operator.outputName) {
133
+ case "Opposite":
134
+ addValidProp(propositions, answer);
135
+ tryToAddWrongProp(propositions, add(a, 1).toTex());
136
+ tryToAddWrongProp(propositions, frac(1, a).toTex());
137
+ tryToAddWrongProp(propositions, substract(1, a).toTex());
138
+ break;
139
+ case "Inverse":
140
+ if (coinFlip()) {
141
+ addValidProp(propositions, answer);
142
+ }
143
+ else {
144
+ addValidProp(propositions, divide(1, a).toTex());
145
+ }
146
+ tryToAddWrongProp(propositions, add(a, 1).toTex());
147
+ tryToAddWrongProp(propositions, opposite(a).toTex());
148
+ tryToAddWrongProp(propositions, frac(0, a).toTex());
149
+ break;
150
+ }
151
+ }
152
+ else {
153
+ const { a, b } = operation.operands;
154
+ switch (operation.operator.outputName) {
155
+ case "Sum":
156
+ if (coinFlip()) {
157
+ addValidProp(propositions, answer);
158
+ }
159
+ else {
160
+ addValidProp(propositions, add(b, a).toTex());
161
+ }
162
+ tryToAddWrongProp(propositions, multiply(a, b).toTex());
163
+ tryToAddWrongProp(propositions, substract(a, b).toTex());
164
+ tryToAddWrongProp(propositions, frac(a, b).toTex());
165
+ break;
166
+ case "Difference":
167
+ addValidProp(propositions, answer);
168
+ tryToAddWrongProp(propositions, substract(b, a).toTex());
169
+ tryToAddWrongProp(propositions, frac(a, b).toTex());
170
+ tryToAddWrongProp(propositions, frac(b, a).toTex());
171
+ break;
172
+ case "Product":
173
+ if (coinFlip()) {
174
+ addValidProp(propositions, answer);
175
+ }
176
+ else {
177
+ addValidProp(propositions, multiply(b, a).toTex());
178
+ }
179
+ tryToAddWrongProp(propositions, frac(a, b).toTex());
180
+ tryToAddWrongProp(propositions, substract(a, b).toTex());
181
+ tryToAddWrongProp(propositions, add(a, b).toTex());
182
+ break;
183
+ case "Quotient":
184
+ if (coinFlip()) {
185
+ addValidProp(propositions, answer);
186
+ }
187
+ else {
188
+ addValidProp(propositions, divide(a, b).toTex());
189
+ }
190
+ tryToAddWrongProp(propositions, frac(b, a).toTex());
191
+ tryToAddWrongProp(propositions, substract(a, b).toTex());
192
+ tryToAddWrongProp(propositions, multiply(a, b).toTex());
193
+ break;
194
+ }
195
+ }
196
+ return shuffleProps(propositions, n);
197
+ };
198
+ const getAnswer = (identifiers) => {
199
+ const { operation, isUsingFrenchFactorNouns } = identifiers;
200
+ const node = getNodeFromOperation(operation).simplify();
201
+ return node.toTex();
202
+ };
203
+ const getInstruction = (identifiers) => {
204
+ const statementString = buildFrenchString(identifiers);
205
+ return `Écrire l'expression littérale pour :
206
+
207
+ ${statementString}
208
+ `;
209
+ };
210
+ const getHint = (identifiers) => {
211
+ const { operation } = identifiers;
212
+ switch (operation.operator.outputName) {
213
+ case "Opposite":
214
+ //return `L'opposé de $ ${"a".toTree().toTex()} $, c'est $ ${(0).frenchify()} $ moins $ ${"a".toTree().toTex()} $ (l'0pposé)`
215
+ return `L'opposé d'un nombre $x$ est $-x$.`;
216
+ case "Inverse":
217
+ //return `L'inverse de $ ${"a".toTree().toTex()} $, c'est $ ${(1).frenchify()} $ sur $ ${"a".toTree().toTex()} $ (l'1verse)`
218
+ return `L'inverse d'un nombre $x$ (différent de $0$) est $\\frac{1}{x}$.`;
219
+ case "Sum":
220
+ return `La somme est le résultat de l'addition de deux nombres ($ + $).`;
221
+ case "Difference":
222
+ return `La différence est le résultat de la soustraction d'un nombre à un autre ($ - $).`;
223
+ case "Product":
224
+ return `Le produit est le résultat de la multiplication de deux nombres ($ \\times $).`;
225
+ case "Quotient":
226
+ return `Le quotient est le résultat de la division d'un nombre par un autre ($ \\div $).`;
227
+ }
228
+ };
229
+ const getCorrection = (identifiers) => {
230
+ const statementString = buildFrenchString(identifiers);
231
+ let outString = `${capitalize(statementString)} est $ ${getAnswer(identifiers)} $.`;
232
+ //explain rewriting if needed
233
+ const { operation, isUsingFrenchFactorNouns } = identifiers;
234
+ const node__raw = getNodeFromOperation(operation);
235
+ const node__refined = node__raw.simplify();
236
+ const tex__raw = node__raw.toTex({
237
+ allowDoubleMinus: true,
238
+ forceTimesSign: true,
239
+ forceParenthesis: true,
240
+ forceNoSimplification: true,
241
+ allowMinusAnywhereInFraction: true,
242
+ });
243
+ const tex__refined = node__refined.toTex();
244
+ if (tex__raw != tex__refined) {
245
+ outString += `
246
+
247
+ En effet,
248
+ $$
249
+ ${tex__raw}
250
+ $$
251
+ peut se réécrire :
252
+ $$
253
+ ${tex__refined}
254
+ $$
255
+ `;
256
+ }
257
+ return outString;
258
+ };
259
+ const getKeys = (identifiers) => {
260
+ const { operation } = identifiers;
261
+ const arr_operands = [operation.operands.a];
262
+ if ("b" in operation.operands) {
263
+ arr_operands.push(operation.operands.b);
264
+ }
265
+ return arr_operands.filter(elt => typeof elt === "string").map(elt => elt);
266
+ };
267
+ const isAnswerValid = (ans, { answer }) => {
268
+ //return LitExpVEA(ans, answer);
269
+ try {
270
+ const parsed = parseAlgebraic(ans);
271
+ return (parsed
272
+ .simplify()
273
+ .toTex() === answer);
274
+ }
275
+ catch (err) {
276
+ return handleVEAError(err);
277
+ }
278
+ };
279
+ const getWriteLitExprFromFrenchQuestion = (ops) => {
280
+ const operator = random(arr_operator);
281
+ const isUsingFrenchFactorNouns = coinFlip();
282
+ const str__var = random(["x", "y", "z", "t"]);
283
+ let a = "";
284
+ let b = undefined;
285
+ if (coinFlip()) {
286
+ a = str__var;
287
+ if (operator.outputName === "Quotient" && isUsingFrenchFactorNouns) {
288
+ const arr_fr = [2, 3, 4, 5, 10, 100, 1_000];
289
+ b = random([randint(-10, 21, [-1, 0, 1]), random(arr_fr)]);
290
+ }
291
+ else {
292
+ b = randint(-10, 11, [-1, 0, 1]);
293
+ }
294
+ }
295
+ else {
296
+ b = str__var;
297
+ if (operator.outputName === "Product" && isUsingFrenchFactorNouns) {
298
+ const arr_fr = [2, 3, 4, 5];
299
+ a = random([randint(-10, 21, [-1, 0, 1]), random(arr_fr)]);
300
+ }
301
+ else {
302
+ a = randint(-10, 11, [-1, 0, 1]);
303
+ }
304
+ }
305
+ let operands;
306
+ switch (operator.arity) {
307
+ case 1:
308
+ operands = { a };
309
+ break;
310
+ case 2:
311
+ operands = { a, b };
312
+ break;
313
+ }
314
+ const operation = {
315
+ operator: operator,
316
+ operands: operands,
317
+ };
318
+ const identifiers = { operation, isUsingFrenchFactorNouns };
319
+ return getQuestionFromIdentifiers(identifiers);
320
+ };
321
+ const getQuestionFromIdentifiers = (identifiers) => {
322
+ return {
323
+ answer: getAnswer(identifiers),
324
+ instruction: getInstruction(identifiers),
325
+ keys: getKeys(identifiers),
326
+ answerFormat: 'tex',
327
+ identifiers,
328
+ hint: getHint(identifiers),
329
+ correction: getCorrection(identifiers)
330
+ };
331
+ };
332
+ export const writeLitExprFromFrench = {
333
+ id: 'writeLitExprFromFrench',
334
+ label: "Ecrire une expression littérale à partir d'une expression en français",
335
+ isSingleStep: true,
336
+ generator: (nb, opts) => getDistinctQuestions(() => getWriteLitExprFromFrenchQuestion(opts), nb),
337
+ qcmTimer: 60,
338
+ freeTimer: 60,
339
+ getPropositions,
340
+ isAnswerValid,
341
+ subject: "Mathématiques",
342
+ getInstruction,
343
+ getHint,
344
+ getCorrection,
345
+ getAnswer,
346
+ getQuestionFromIdentifiers,
347
+ hasHintAndCorrection: true
348
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"functionGraphReading.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/dataRepresentations/functionGraphReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAmBT,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAgIF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAkBtD,CAAC;;AAEF,UAAU;AACV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsGE"}
1
+ {"version":3,"file":"functionGraphReading.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/dataRepresentations/functionGraphReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAgIF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAkBtD,CAAC;;AAEF,UAAU;AACV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsGE"}
@@ -1 +1 @@
1
- {"version":3,"file":"pieChartReading.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/dataRepresentations/pieChartReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAmBT,MAAM,6BAA6B,CAAC;AA0BrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AA+NF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAmBjD,CAAC"}
1
+ {"version":3,"file":"pieChartReading.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/dataRepresentations/pieChartReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AA0BrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AA+NF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAmBjD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"derivativeTangentEquationReading.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/tangent/derivativeTangentEquationReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAmBT,MAAM,6BAA6B,CAAC;AAyBrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,GAAG,CAAC;IACb,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAwQF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,CAmBlE,CAAC;;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG"}
1
+ {"version":3,"file":"derivativeTangentEquationReading.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/tangent/derivativeTangentEquationReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAyBrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,GAAG,CAAC;IACb,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAwQF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,CAmBlE,CAAC;;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG"}
@@ -1,3 +1,4 @@
1
1
  export * from "./thirdDegreeFunctionVariation.js";
2
+ export * from "./thirdDegreeDerivativeVariation.js";
2
3
  export * from "./variationArrowAmount.js";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/variations/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/variations/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,2BAA2B,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export * from "./thirdDegreeFunctionVariation.js";
2
+ export * from "./thirdDegreeDerivativeVariation.js";
2
3
  export * from "./variationArrowAmount.js";
@@ -0,0 +1,10 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ a: number;
4
+ coin: number;
5
+ r1: number;
6
+ r2: number;
7
+ };
8
+ export declare const thirdDegreeDerivativeVariation: Exercise<Identifiers>;
9
+ export {};
10
+ //# sourceMappingURL=thirdDegreeDerivativeVariation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thirdDegreeDerivativeVariation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/variations/thirdDegreeDerivativeVariation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAuBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAmOF,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,WAAW,CAehE,CAAC"}
@@ -0,0 +1,201 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randomColor } from "../../../../geogebra/colors.js";
4
+ import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
5
+ import { Polynomial } from "../../../../math/polynomials/polynomial.js";
6
+ import { randint } from "../../../../math/utils/random/randint.js";
7
+ import { randTupleInt } from "../../../../math/utils/random/randTupleInt.js";
8
+ import { MinusInfinityNode, PlusInfinityNode, } from "../../../../tree/nodes/numbers/infiniteNode.js";
9
+ import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
10
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
11
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
12
+ import { ClosureType } from "../../../../tree/nodes/sets/closure.js";
13
+ import { IntervalNode } from "../../../../tree/nodes/sets/intervalNode.js";
14
+ import { intervalParser } from "../../../../tree/parsers/intervalParser.js";
15
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
16
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
17
+ const getInstruction = (identifiers) => {
18
+ const { coin } = identifiers;
19
+ return `Soit $f$ une fonction définie et dérivable sur $\\mathbb{R}$, dont la dérivée $f'$ est représentée ci-dessous.
20
+
21
+ Sur quel(s) intervalle(s) la fonction $f$ est-elle ${coin < 0 ? "croissante" : "décroissante"} ?`;
22
+ };
23
+ const getHint = (identifiers) => {
24
+ return `Si la fonction dérivée $f'$ est positif sur un intervalle, alors la fonction $f$ est croissante sur cet intervalle.
25
+
26
+ À l'inverse, si la fonction dérivée $f'$ est négative sur un intervalle, alors la fonction $f$ est décroissante sur cet intervalle`;
27
+ };
28
+ const getCorrection = (identifiers) => {
29
+ const { coin } = identifiers;
30
+ const variation = coin < 0 ? "croissante" : "décroissante";
31
+ const sign = coin < 0 ? "positive" : "négative";
32
+ const intervals = getIntervalsSolution(identifiers);
33
+ return `Si la fonction dérivée $f'$ est ${sign} sur un intervalle, alors la fonction $f$ est ${variation} sur cet intervalle.
34
+
35
+ Ici, on lit graphiquement que $f'$ est ${sign} sur $${intervals[0].toTex()}$${intervals[1] ? ` et sur $${intervals[1].toTex()}$` : ""}.
36
+
37
+ On en déduit que $f$ est donc ${variation} sur :
38
+
39
+ $$
40
+ ${getAnswer(identifiers)}
41
+ $$`;
42
+ };
43
+ const getIntervalsSolution = (identifiers) => {
44
+ const { a, coin, r1, r2 } = identifiers;
45
+ const racine1Tree = new NumberNode(r1);
46
+ const racine2Tree = new NumberNode(r2);
47
+ const intervals = coin * a > 0
48
+ ? [new IntervalNode(racine1Tree, racine2Tree, ClosureType.FF)]
49
+ : [
50
+ new IntervalNode(MinusInfinityNode, racine1Tree, ClosureType.OF),
51
+ new IntervalNode(racine2Tree, PlusInfinityNode, ClosureType.FO),
52
+ ];
53
+ return intervals;
54
+ };
55
+ const getAnswer = (identifiers) => {
56
+ const intervals = getIntervalsSolution(identifiers);
57
+ if (intervals.length === 1)
58
+ return intervals[0].toTex();
59
+ else
60
+ return intervals.map((e) => e.toTex()).join("\\text{ et }\\ ");
61
+ };
62
+ const getGGBOptions = (identifiers) => {
63
+ const { a, r1, r2 } = identifiers;
64
+ // a/3 x^3 + (-a*(r1+r2))/2 x^2 + (a*r1*r2) * x + c
65
+ // La derive f' est
66
+ // ax^2 + -a(r1+r2)x + (a*r1*r2)
67
+ const polynomeDerivative = new Polynomial([a * r1 * r2, -a * (r1 + r2), a]);
68
+ const commands = [
69
+ `f'(x) = ${polynomeDerivative.toMathString()}`,
70
+ `SetColor(f', "${randomColor()}")`,
71
+ ];
72
+ // yMax dans un polynome racine 2 (ax^2 + -a(r1+r2)x + (a*r1*r2))
73
+ // => (2ax - a(r1+r2) = 0) => x = (r1+r2)/2x
74
+ const padding = 2;
75
+ const localMaxima = (r1 + r2) / 2;
76
+ const xMin = Math.min(r1, r2) - padding;
77
+ const xMax = Math.max(r1, r2) + padding;
78
+ const yMax = Math.abs(polynomeDerivative.calculate(localMaxima)) + padding;
79
+ const yMin = Math.min(-yMax, -2);
80
+ const ggb = new GeogebraConstructor({
81
+ commands,
82
+ lockedAxesRatio: false,
83
+ // gridDistance: false,
84
+ });
85
+ return ggb.getOptions({
86
+ coords: ggb.getAdaptedCoords({ xMin, xMax, yMin, yMax }),
87
+ });
88
+ };
89
+ const getThirdDegreeDerivativeVariation = () => {
90
+ const a = randint(-3, 4, [0]);
91
+ let [r1, r2] = randTupleInt(2, {
92
+ from: -5,
93
+ to: 6,
94
+ allDifferent: true,
95
+ });
96
+ if (r2 < r1)
97
+ [r1, r2] = [r2, r1];
98
+ const coin = coinFlip() ? -1 : 1;
99
+ const identifiers = { coin, a, r1, r2 };
100
+ return getQuestionFromIdentifiers(identifiers);
101
+ };
102
+ const getQuestionFromIdentifiers = (identifiers) => {
103
+ const question = {
104
+ instruction: getInstruction(identifiers),
105
+ startStatement: "S",
106
+ answer: getAnswer(identifiers),
107
+ keys: ["lbracket", "rbracket", "semicolon", "infty", "et"],
108
+ answerFormat: "tex",
109
+ ggbOptions: getGGBOptions(identifiers),
110
+ identifiers,
111
+ hint: getHint(identifiers),
112
+ correction: getCorrection(identifiers),
113
+ };
114
+ return question;
115
+ };
116
+ const getPropositions = (n, { answer, r1: racine1, r2: racine2, a, coin }) => {
117
+ const racine1Tree = new NumberNode(racine1);
118
+ const racine2Tree = new NumberNode(racine2);
119
+ const propositions = [];
120
+ addValidProp(propositions, answer);
121
+ const alpha = frac(add(racine1, racine2), 2).simplify();
122
+ //a>0 : parabole sourit
123
+ //coin1 = décroissant, coin -1 = croissant
124
+ //a>0 coin1 : -inf alpha
125
+ //a>0 coin -1 : alpha inf
126
+ //a<0 coin1 : alpha inf
127
+ //a<0 coin -1 : -inf alpha
128
+ if (a > 0 === coin > 0) {
129
+ tryToAddWrongProp(propositions, new IntervalNode(MinusInfinityNode, alpha, ClosureType.OF).toTex());
130
+ }
131
+ else {
132
+ tryToAddWrongProp(propositions, new IntervalNode(alpha, PlusInfinityNode, ClosureType.FF).toTex());
133
+ }
134
+ tryToAddWrongProp(propositions, new IntervalNode(racine1Tree, racine2Tree, coin > 0 ? ClosureType.FF : ClosureType.OF).toTex());
135
+ // tryToAddWrongProp(
136
+ // propositions,
137
+ // new IntervalNode(racine2Tree, PlusInfinityNode, ClosureType.FO).toTex(),
138
+ // );
139
+ // tryToAddWrongProp(
140
+ // propositions,
141
+ // new IntervalNode(MinusInfinityNode, racine1Tree, ClosureType.OF).toTex(),
142
+ // );
143
+ tryToAddWrongProp(propositions, [
144
+ new IntervalNode(MinusInfinityNode, racine1Tree, ClosureType.OF),
145
+ new IntervalNode(racine2Tree, PlusInfinityNode, ClosureType.FO),
146
+ ]
147
+ .map((e) => e.toTex())
148
+ .join("\\text{ et }\\ "));
149
+ while (propositions.length < n) {
150
+ const root1 = randint(-5, 4);
151
+ const root2 = randint(root1 + 1, 6);
152
+ const root1Tree = new NumberNode(root1);
153
+ const root2Tree = new NumberNode(root2);
154
+ const wrongAnswer = new IntervalNode(root1Tree, root2Tree, ClosureType.FF).toTex();
155
+ tryToAddWrongProp(propositions, wrongAnswer);
156
+ }
157
+ return shuffleProps(propositions, n);
158
+ };
159
+ const isAnswerValid = (ans, { answer, r1: racine1, r2: racine2, coin, a }) => {
160
+ try {
161
+ const intervals = ans
162
+ .split("\\text{ et }")
163
+ .map((s) => s.replaceAll("\\text{ }", "").replaceAll("\\ ", "").replaceAll(" ", ""));
164
+ const simped = intervals.map((e) => intervalParser(e, {
165
+ allowCommaInsteadOfSemicolon: true,
166
+ allowNoBrackets: true,
167
+ }));
168
+ if (simped.some((e) => e === false))
169
+ return false;
170
+ return (simped
171
+ .map((e) => e.simplify())
172
+ .sort((i1, i2) => i1.a.evaluate() - i2.a.evaluate())
173
+ .map((e, i) => e
174
+ .toClosure(simped.length === 2
175
+ ? i === 0
176
+ ? ClosureType.OF
177
+ : ClosureType.FO
178
+ : ClosureType.FF)
179
+ .toTex())
180
+ .join("\\text{ et }\\ ") === answer);
181
+ return false;
182
+ }
183
+ catch (err) {
184
+ return handleVEAError(err);
185
+ }
186
+ };
187
+ export const thirdDegreeDerivativeVariation = {
188
+ id: "thirdDegreeDerivativeVariation",
189
+ connector: "=",
190
+ label: "Lecture des variations d'une fonction via le signe de sa dérivée",
191
+ isSingleStep: true,
192
+ generator: (nb) => getDistinctQuestions(getThirdDegreeDerivativeVariation, nb),
193
+ qcmTimer: 60,
194
+ freeTimer: 60,
195
+ getPropositions,
196
+ isAnswerValid,
197
+ hasGeogebra: true,
198
+ subject: "Mathématiques",
199
+ hasHintAndCorrection: true,
200
+ getQuestionFromIdentifiers,
201
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"graphicInequationAffine.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/graphicInequationAffine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAmBT,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EACL,gBAAgB,EAGjB,MAAM,sCAAsC,CAAC;AAe9C,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,gBAAgB,CAAC;IAClC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAgKF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAezD,CAAC"}
1
+ {"version":3,"file":"graphicInequationAffine.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/graphicInequationAffine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EACL,gBAAgB,EAGjB,MAAM,sCAAsC,CAAC;AAe9C,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,gBAAgB,CAAC;IAClC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAgKF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAezD,CAAC"}
@@ -3,4 +3,5 @@ export * from "./logSimplifiying.js";
3
3
  export * from "./log10PowerSimplifying.js";
4
4
  export * from "./logPowerEquation.js";
5
5
  export * from "./log10Simplifying.js";
6
+ export * from "./powerEquation.js";
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/logarithm/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/logarithm/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC"}
@@ -3,3 +3,4 @@ export * from "./logSimplifiying.js";
3
3
  export * from "./log10PowerSimplifying.js";
4
4
  export * from "./logPowerEquation.js";
5
5
  export * from "./log10Simplifying.js";
6
+ export * from "./powerEquation.js";
@@ -0,0 +1,11 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ a: number;
4
+ b: number;
5
+ };
6
+ type Options = {
7
+ useLog10?: boolean;
8
+ };
9
+ export declare const powerEquation: Exercise<Identifiers, Options>;
10
+ export {};
11
+ //# sourceMappingURL=powerEquation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"powerEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/logarithm/powerEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAsBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAoJF,KAAK,OAAO,GAAG;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAUF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkBxD,CAAC"}