math-exercises 3.0.186 → 3.0.188

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 (79) hide show
  1. package/lib/exercises/math/derivation/derivative/exp/expDerivativeProductFExp.d.ts.map +1 -1
  2. package/lib/exercises/math/derivation/derivative/exp/expDerivativeProductFExp.js +22 -6
  3. package/lib/exercises/math/derivation/derivative/exp/expDerivativeQuotientFExp.d.ts.map +1 -1
  4. package/lib/exercises/math/derivation/derivative/exp/expDerivativeQuotientFExp.js +16 -8
  5. package/lib/exercises/math/derivation/derivativeNumber/derivativeNumberAndImageReading.d.ts +9 -0
  6. package/lib/exercises/math/derivation/derivativeNumber/derivativeNumberAndImageReading.d.ts.map +1 -0
  7. package/lib/exercises/math/derivation/derivativeNumber/derivativeNumberAndImageReading.js +155 -0
  8. package/lib/exercises/math/derivation/derivativeNumber/index.d.ts +1 -0
  9. package/lib/exercises/math/derivation/derivativeNumber/index.d.ts.map +1 -1
  10. package/lib/exercises/math/derivation/derivativeNumber/index.js +1 -0
  11. package/lib/exercises/math/derivation/problems/problemMaximizeBoxVolumeFindX.d.ts.map +1 -1
  12. package/lib/exercises/math/derivation/problems/problemMaximizeBoxVolumeFindX.js +80 -29
  13. package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.d.ts.map +1 -1
  14. package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.js +30 -2
  15. package/lib/exercises/math/derivation/problems/problemMovementOnLineFindSpeedAtPoint.d.ts.map +1 -1
  16. package/lib/exercises/math/derivation/problems/problemMovementOnLineFindSpeedAtPoint.js +59 -16
  17. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingSecant.d.ts.map +1 -1
  18. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingSecant.js +0 -4
  19. package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.d.ts.map +1 -1
  20. package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.js +23 -9
  21. package/lib/exercises/math/derivation/variations/findAbscissaOfExtremaFromFunctionExpression.d.ts.map +1 -1
  22. package/lib/exercises/math/derivation/variations/findAbscissaOfExtremaFromFunctionExpression.js +5 -29
  23. package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.d.ts.map +1 -1
  24. package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.js +2 -7
  25. package/lib/exercises/math/functions/basics/inverseImageFunction.js +1 -1
  26. package/lib/exercises/math/functions/sign/affineSignTable.d.ts.map +1 -1
  27. package/lib/exercises/math/functions/sign/affineSignTable.js +1 -1
  28. package/lib/exercises/math/functions/sign/equationFromSignTable.d.ts +1 -0
  29. package/lib/exercises/math/functions/sign/equationFromSignTable.d.ts.map +1 -1
  30. package/lib/exercises/math/functions/sign/equationFromSignTable.js +60 -33
  31. package/lib/exercises/math/functions/sign/partialSignTableFromGraph.d.ts +6 -4
  32. package/lib/exercises/math/functions/sign/partialSignTableFromGraph.d.ts.map +1 -1
  33. package/lib/exercises/math/functions/sign/partialSignTableFromGraph.js +160 -63
  34. package/lib/exercises/math/functions/sign/readSignTable.d.ts +4 -1
  35. package/lib/exercises/math/functions/sign/readSignTable.d.ts.map +1 -1
  36. package/lib/exercises/math/functions/sign/readSignTable.js +32 -9
  37. package/lib/exercises/math/functions/sign/signTableFromGraph.d.ts +6 -4
  38. package/lib/exercises/math/functions/sign/signTableFromGraph.d.ts.map +1 -1
  39. package/lib/exercises/math/functions/sign/signTableFromGraph.js +160 -57
  40. package/lib/exercises/math/percent/evolutions/averageEvolutionRateFromStartAndEndValue.d.ts +9 -0
  41. package/lib/exercises/math/percent/evolutions/averageEvolutionRateFromStartAndEndValue.d.ts.map +1 -0
  42. package/lib/exercises/math/percent/evolutions/averageEvolutionRateFromStartAndEndValue.js +135 -0
  43. package/lib/exercises/math/percent/evolutions/index.d.ts +1 -0
  44. package/lib/exercises/math/percent/evolutions/index.d.ts.map +1 -1
  45. package/lib/exercises/math/percent/evolutions/index.js +1 -0
  46. package/lib/exercises/math/powers/equationOnePlusTPowerN.d.ts +9 -0
  47. package/lib/exercises/math/powers/equationOnePlusTPowerN.d.ts.map +1 -0
  48. package/lib/exercises/math/powers/equationOnePlusTPowerN.js +118 -0
  49. package/lib/exercises/math/powers/estimateNthRoot.d.ts +13 -0
  50. package/lib/exercises/math/powers/estimateNthRoot.d.ts.map +1 -0
  51. package/lib/exercises/math/powers/estimateNthRoot.js +126 -0
  52. package/lib/exercises/math/powers/index.d.ts +3 -0
  53. package/lib/exercises/math/powers/index.d.ts.map +1 -1
  54. package/lib/exercises/math/powers/index.js +3 -0
  55. package/lib/exercises/math/powers/solveNthRootEquation.d.ts +9 -0
  56. package/lib/exercises/math/powers/solveNthRootEquation.d.ts.map +1 -0
  57. package/lib/exercises/math/powers/solveNthRootEquation.js +111 -0
  58. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRecurrenceFormulaFromSituation.d.ts.map +1 -1
  59. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRecurrenceFormulaFromSituation.js +2 -2
  60. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoConsecutiveTerms.js +1 -1
  61. package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoConsecutiveTerms.js +1 -1
  62. package/lib/exercises/vea/percentVEA.d.ts +6 -1
  63. package/lib/exercises/vea/percentVEA.d.ts.map +1 -1
  64. package/lib/exercises/vea/percentVEA.js +15 -1
  65. package/lib/index.d.ts +34 -9
  66. package/lib/index.d.ts.map +1 -1
  67. package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts.map +1 -1
  68. package/lib/math/utils/sequences/situations/seqArithmeticSituations.js +5 -8
  69. package/lib/math/utils/sequences/situations/seqArithmeticUtils.d.ts +1 -1
  70. package/lib/math/utils/sequences/situations/seqArithmeticUtils.d.ts.map +1 -1
  71. package/lib/math/utils/sequences/situations/seqArithmeticUtils.js +1 -3
  72. package/lib/math/utils/sequences/situations/seqGeometricSituations.d.ts.map +1 -1
  73. package/lib/math/utils/sequences/situations/seqGeometricSituations.js +8 -10
  74. package/lib/tests/questionTest.d.ts.map +1 -1
  75. package/lib/tests/questionTest.js +8 -0
  76. package/lib/tree/nodes/sets/closure.d.ts +1 -0
  77. package/lib/tree/nodes/sets/closure.d.ts.map +1 -1
  78. package/lib/tree/nodes/sets/closure.js +12 -0
  79. package/package.json +1 -1
@@ -1,4 +1,6 @@
1
+ import { GeneratorOptionTarget, GeneratorOptionType, } from "../../../../exercises/exercise.js";
1
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { signTableVEA } from "../../../../exercises/vea/signTableVEA.js";
2
4
  import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
3
5
  import { randfloat } from "../../../../math/utils/random/randfloat.js";
4
6
  import { randint } from "../../../../math/utils/random/randint.js";
@@ -6,7 +8,7 @@ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
6
8
  const getInstruction = () => {
7
9
  return `On donne la représentation graphique d'une fonction $f$ définie sur $\\mathbb{R}$.
8
10
 
9
- Dresser le tableau de signes de $f$.`;
11
+ Compléter le tableau de signes de $f$.`;
10
12
  };
11
13
  const getHint = () => {
12
14
  return `La fonction est définie sur $\\mathbb{R}$, donc les valeurs de $x$ vont de $-\\infty$ à $+\\infty$.
@@ -15,35 +17,73 @@ Repère ensuite les points de la courbe à l'intersection de l'axe des abscisses
15
17
  };
16
18
  const getCorrection = (identifiers) => {
17
19
  const { a, x1, x2, x3 } = identifiers;
18
- const signs = a > 0
19
- ? ["négatif", "positif", "négatif", "positif"]
20
- : ["positif", "négatif", "positif", "négatif"];
21
- return `On lit graphiquement que $f(x)$ s'annule pour les valeurs de $x$ suivantes : $${x1}$, $${x2}$ et $${x3}$.
20
+ const rootsNb = x2 === undefined ? 1 : x3 === undefined ? 2 : 3;
21
+ const signs = rootsNb === 1
22
+ ? a > 0
23
+ ? ["-", "+"]
24
+ : ["+", "-"]
25
+ : rootsNb === 2
26
+ ? a > 0
27
+ ? ["+", "-", "+"]
28
+ : ["-", "+", "-"]
29
+ : a > 0
30
+ ? ["-", "+", "-", "+"]
31
+ : ["+", "-", "+", "-"];
32
+ const signWords = signs.map((e) => (e === "-" ? "négatif" : "positif"));
33
+ return rootsNb === 1
34
+ ? `On lit graphiquement que $f(x)$ s'annule pour $x$ valant $${x1}$.
22
35
 
23
- De plus, $f(x)$ est ${signs[0]} pour $x \\in ]-\\infty;${x1}]$, puis ${signs[1]} pour $x \\in [${x1}, ${x2}]$, puis ${signs[2]} pour $x \\in [${x2}, ${x3}]$, et enfin ${signs[3]} pour $x \\in [${x3}, +\\infty[$.`;
36
+ De plus, $f(x)$ est ${signWords[0]} pour $x \\in ]-\\infty;${x1}]$, puis ${signWords[1]} pour $x \\in [${x1}, +\\infty[$.`
37
+ : rootsNb === 2
38
+ ? `On lit graphiquement que $f(x)$ s'annule pour $x$ valant $${x1}$ et $${x2}$.
39
+
40
+ De plus, $f(x)$ est ${signWords[0]} pour $x \\in ]-\\infty;${x1}]$, puis ${signWords[1]} pour $x \\in [${x1}, ${x2}]$, puis ${signWords[2]} pour $x \\in [${x2}, +\\infty[$.`
41
+ : `On lit graphiquement que $f(x)$ s'annule pour les valeurs de $x$ suivantes : $${x1}$, $${x2}$ et $${x3}$.
42
+
43
+ De plus, $f(x)$ est ${signWords[0]} pour $x \\in ]-\\infty;${x1}]$, puis ${signWords[1]} pour $x \\in [${x1}, ${x2}]$, puis ${signWords[2]} pour $x \\in [${x2}, ${x3}]$, et enfin ${signWords[3]} pour $x \\in [${x3}, +\\infty[$.`;
24
44
  };
25
45
  const getGGBOptions = (identifiers) => {
26
46
  const { a, x1, x2, x3 } = identifiers;
27
47
  const ggb = new GeogebraConstructor({
28
- commands: [`f(x) = ${a}*(x-${x1})*(x-${x2})*(x-${x3})`],
48
+ commands: [
49
+ x2 === undefined
50
+ ? `f(x) = ${a}*(x-${x1})`
51
+ : x3 === undefined
52
+ ? `f(x) = ${a}*(x-${x1})*(x-${x2})`
53
+ : `f(x) = ${a}*(x-${x1})*(x-${x2})*(x-${x3})`,
54
+ ],
29
55
  lockedAxesRatio: false,
30
56
  gridDistance: false,
31
57
  xAxis: {
32
58
  steps: 1,
33
59
  },
34
60
  });
35
- const func = (x) => a * (x - x1) * (x - x2) * (x - x3);
36
- const xMin = Math.min(x1, x2, x3);
37
- const xMax = Math.max(x1, x2, x3);
38
- const root1 = (2 * (x1 + x2 + x3) -
39
- Math.sqrt(4 * (x1 + x2 + x3) ** 2 - 12 * (x1 * x2 + x1 * x3 + x2 * x3))) /
40
- 6;
41
- const root2 = (2 * (x1 + x2 + x3) +
42
- Math.sqrt(4 * (x1 + x2 + x3) ** 2 - 12 * (x1 * x2 + x1 * x3 + x2 * x3))) /
43
- 6;
61
+ const func = (x) => {
62
+ if (x2 === undefined)
63
+ return a * (x - x1);
64
+ if (x3 === undefined)
65
+ return a * (x - x1) * (x - x2);
66
+ return a * (x - x1) * (x - x2) * (x - x3);
67
+ };
68
+ const xMin = Math.min(-2, Math.min(x1, x2 ?? x1, x3 ?? x2 ?? x1));
69
+ const xMax = Math.max(2, Math.max(x1, x2 ?? x1, x3 ?? x2 ?? x1));
70
+ const root1 = x2 === undefined
71
+ ? 0
72
+ : x3 === undefined
73
+ ? (x1 + x2) / 2
74
+ : (2 * (x1 + x2 + x3) -
75
+ Math.sqrt(4 * (x1 + x2 + x3) ** 2 - 12 * (x1 * x2 + x1 * x3 + x2 * x3))) /
76
+ 6;
77
+ const root2 = x2 === undefined
78
+ ? 0
79
+ : x3 === undefined
80
+ ? (x1 + x2) / 2
81
+ : (2 * (x1 + x2 + x3) +
82
+ Math.sqrt(4 * (x1 + x2 + x3) ** 2 - 12 * (x1 * x2 + x1 * x3 + x2 * x3))) /
83
+ 6;
44
84
  const [fx1, fx2] = [func(root1), func(root2)];
45
- const yMin = Math.min(fx1, fx2);
46
- const yMax = Math.max(fx1, fx2);
85
+ const yMin = Math.min(-2, Math.min(fx1, fx2));
86
+ const yMax = Math.max(2, Math.max(fx1, fx2));
47
87
  return ggb.getOptions({
48
88
  coords: [xMin - 2, xMax + 2, yMin - 2, yMax + 2],
49
89
  });
@@ -51,61 +91,113 @@ const getGGBOptions = (identifiers) => {
51
91
  const getKeys = () => {
52
92
  return ["infty"];
53
93
  };
94
+ const getFirstLine = (identifiers) => {
95
+ const { x1, x2, x3 } = identifiers;
96
+ const firstLine = x2 === undefined
97
+ ? ["$x$", "-\\infty", "\\ ", x1.frenchify(), "\\ ", "+\\infty"]
98
+ : x3 === undefined
99
+ ? [
100
+ "$x$",
101
+ "-\\infty",
102
+ "\\ ",
103
+ x1.frenchify(),
104
+ "\\ ",
105
+ x2.frenchify(),
106
+ "\\ ",
107
+ "+\\infty",
108
+ ]
109
+ : [
110
+ "$x$",
111
+ "-\\infty",
112
+ "\\ ",
113
+ x1.frenchify(),
114
+ "\\ ",
115
+ x2.frenchify(),
116
+ "\\ ",
117
+ x3.frenchify(),
118
+ "\\ ",
119
+ "+\\infty",
120
+ ];
121
+ return firstLine;
122
+ };
123
+ const getSecondLine = (identifiers) => {
124
+ const { a, x2, x3 } = identifiers;
125
+ //affine a>0 ? ["-", "+"] : ["+","-"]
126
+ //degré 2 a>0 ? ["+", "-", "+"] : ["-", "+", "-"]
127
+ //degré 3 a > 0 ? ["-", "+", "-", "+"] : ["+", "-", "+", "-"];
128
+ const rootsNb = x2 === undefined ? 1 : x3 === undefined ? 2 : 3;
129
+ const signs = rootsNb === 1
130
+ ? a > 0
131
+ ? ["-", "+"]
132
+ : ["+", "-"]
133
+ : rootsNb === 2
134
+ ? a > 0
135
+ ? ["+", "-", "+"]
136
+ : ["-", "+", "-"]
137
+ : a > 0
138
+ ? ["-", "+", "-", "+"]
139
+ : ["+", "-", "+", "-"];
140
+ return rootsNb === 1
141
+ ? ["$f(x)$", "\\ ", signs[0], "0", signs[1], "\\ "]
142
+ : rootsNb === 2
143
+ ? ["$f(x)$", "\\ ", signs[0], "0", signs[1], "0", signs[2], "\\ "]
144
+ : [
145
+ "$f(x)$",
146
+ "\\ ",
147
+ signs[0],
148
+ "0",
149
+ signs[1],
150
+ "0",
151
+ signs[2],
152
+ "0",
153
+ signs[3],
154
+ "\\ ",
155
+ ];
156
+ };
54
157
  const getAnswerTable = (identifiers) => {
55
- const { a, x1, x2, x3 } = identifiers;
56
- const signs = a > 0 ? ["-", "+", "-", "+"] : ["+", "-", "+", "-"];
57
- return [
58
- [
59
- "$x$",
60
- "-\\infty",
61
- "\\ ",
62
- x1.frenchify(),
63
- "\\ ",
64
- x2.frenchify(),
65
- "\\ ",
66
- x3.frenchify(),
67
- "\\ ",
68
- "+\\infty",
69
- ],
70
- [
71
- "$f(x)$",
72
- "\\ ",
73
- signs[0],
74
- "0",
75
- signs[1],
76
- "0",
77
- signs[2],
78
- "0",
79
- signs[3],
80
- "\\ ",
81
- ],
82
- ];
158
+ return [getFirstLine(identifiers), getSecondLine(identifiers)];
83
159
  };
84
160
  const isAnswerTableValid = (ans, { answerTable }) => {
85
161
  try {
86
- return ans.every((row, i) => row.every((cell, j) => cell === answerTable[i][j]));
162
+ return signTableVEA(ans, answerTable);
87
163
  }
88
164
  catch (err) {
89
165
  return handleVEAError(err);
90
166
  }
91
167
  };
92
- const getSignTableFromGraphQuestion = () => {
168
+ const getSignTableFromGraphQuestion = (opts) => {
93
169
  const x1 = randint(-9, 10);
170
+ const type = opts?.functionType === "Affine"
171
+ ? 0
172
+ : opts?.functionType === "Degré $2$"
173
+ ? 1
174
+ : 2;
94
175
  const x2 = randint(-9, 10, [x1]);
95
176
  const x3 = randint(-9, 10, [x1, x2]);
96
177
  const sorted = [x1, x2, x3].sort((a, b) => a - b);
97
- const a = randfloat(-1, 1, 4, [0]);
178
+ const a = type === 0 ? randint(-5, 5, [0]) : randfloat(-1, 1, 4, [0]);
98
179
  const identifiers = {
99
180
  a,
100
181
  x1: sorted[0],
101
- x2: sorted[1],
102
- x3: sorted[2],
103
- initTable: [
104
- ["$x$", "", "\\ ", "", "\\ ", "", "\\ ", "", "\\ ", ""],
105
- ["$f(x)$", "\\ ", "", "", "", "", "", "", "", "\\ "],
106
- ],
182
+ x2: type < 1 ? undefined : sorted[1],
183
+ x3: type < 2 ? undefined : sorted[2],
107
184
  };
108
- return getQuestionFromIdentifiers(identifiers);
185
+ return getQuestionFromIdentifiers(identifiers, opts);
186
+ };
187
+ const getInitTable = (identifiers) => {
188
+ const { x2, x3 } = identifiers;
189
+ const rootsNb = x2 === undefined ? 1 : x3 === undefined ? 2 : 3;
190
+ const firstLine = rootsNb === 1
191
+ ? ["$x$", "", "\\ ", "", "\\ ", ""]
192
+ : rootsNb === 2
193
+ ? ["$x$", "", "\\ ", "", "\\ ", "", "\\ ", ""]
194
+ : ["$x$", "", "\\ ", "", "\\ ", "", "\\ ", "", "\\ ", ""];
195
+ const secondLine = rootsNb === 1
196
+ ? ["$f(x)$", "\\ ", "", "", "", "\\ "]
197
+ : rootsNb === 2
198
+ ? ["$f(x)$", "\\ ", "", "", "", "", "", "\\ "]
199
+ : ["$f(x)$", "\\ ", "", "", "", "", "", "", "", "\\ "];
200
+ return [firstLine, secondLine];
109
201
  };
110
202
  const getQuestionFromIdentifiers = (identifiers) => {
111
203
  return {
@@ -117,9 +209,19 @@ const getQuestionFromIdentifiers = (identifiers) => {
117
209
  hint: getHint(identifiers),
118
210
  correction: getCorrection(identifiers),
119
211
  ggbOptions: getGGBOptions(identifiers),
120
- initTable: identifiers.initTable,
212
+ initTable: getInitTable(identifiers),
121
213
  };
122
214
  };
215
+ const options = [
216
+ {
217
+ id: "functionType",
218
+ label: "Type de fonction",
219
+ target: GeneratorOptionTarget.generation,
220
+ type: GeneratorOptionType.select,
221
+ values: ["Affine", "Degré $2$", "Degré $3$"],
222
+ defaultValue: "Degré $3$",
223
+ },
224
+ ];
123
225
  export const signTableFromGraph = {
124
226
  id: "signTableFromGraph",
125
227
  label: "Dresser le tableau de signes d'une fonction à partir de sa représentation graphique",
@@ -138,4 +240,5 @@ export const signTableFromGraph = {
138
240
  getQuestionFromIdentifiers,
139
241
  answerType: "signTable",
140
242
  hasHintAndCorrection: true,
243
+ options,
141
244
  };
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ vi: number;
4
+ vf: number;
5
+ nbEvolutions: number;
6
+ };
7
+ export declare const averageEvolutionRateFromStartAndEndValue: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=averageEvolutionRateFromStartAndEndValue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"averageEvolutionRateFromStartAndEndValue.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/percent/evolutions/averageEvolutionRateFromStartAndEndValue.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAwHF,eAAO,MAAM,wCAAwC,EAAE,QAAQ,CAAC,WAAW,CAsB1E,CAAC"}
@@ -0,0 +1,135 @@
1
+ import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { percentVEA } from "../../../../exercises/vea/percentVEA.js";
4
+ import { randfloat } from "../../../../math/utils/random/randfloat.js";
5
+ import { randint } from "../../../../math/utils/random/randint.js";
6
+ import { round } from "../../../../math/utils/round.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 { power } from "../../../../tree/nodes/operators/powerNode.js";
11
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
12
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
13
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
14
+ const getPropositions = (n, { answer }) => {
15
+ const propositions = [];
16
+ addValidProp(propositions, answer);
17
+ propWhile(propositions, n, () => {
18
+ tryToAddWrongProp(propositions, randfloat(-20, 20, 2).frenchify() + "\\%");
19
+ });
20
+ return shuffleProps(propositions, n);
21
+ };
22
+ const getAnswer = (identifiers) => {
23
+ const { nbEvolutions, vf, vi } = identifiers;
24
+ const cm = vf / vi;
25
+ const cmMoy = Math.pow(cm, 1 / nbEvolutions);
26
+ const answer = round((cmMoy - 1) * 100, 2).frenchify();
27
+ return answer + "\\%";
28
+ };
29
+ const getInstruction = (identifiers) => {
30
+ const { nbEvolutions, vf, vi } = identifiers;
31
+ return `Le prix d'un article est passé de $${vi}\\ €$ à $${vf}\\ €$ sur une durée de $${nbEvolutions}$ mois.
32
+
33
+ Quel est le taux d'évolution moyen par mois du prix de cet article ? Arrondir au centième de pourcentage.`;
34
+ };
35
+ const getHint = () => {
36
+ // const { nbEvolutions, vf, vi } = identifiers;
37
+ return `Si une quantité passe d'une valeur initiale $V_i$ à une valeur finale $V_f$ après $n$ évolutions, alors on a :
38
+
39
+
40
+ $$
41
+ V_i \\times (1+t)^n = V_f
42
+ $$
43
+
44
+ où $t$ est le taux d'évolution moyen.
45
+
46
+ Il suffit donc de résoudre cette équation d'inconnue $t$.`;
47
+ };
48
+ const getCorrection = (identifiers) => {
49
+ const { nbEvolutions, vf, vi } = identifiers;
50
+ return `Si une quantité passe d'une valeur initiale $V_i$ à une valeur finale $V_f$ après $n$ évolutions, alors on a :
51
+
52
+
53
+ $$
54
+ V_i \\times (1+t)^n = V_f
55
+ $$
56
+
57
+ où $t$ est le taux d'évolution moyen.
58
+
59
+ Il suffit donc de résoudre cette équation d'inconnue $t$.
60
+
61
+ Ici, on a donc :
62
+
63
+ $$
64
+ ${multiply(vi, power(add(1, "t"), nbEvolutions)).toTex()} = ${vf.frenchify()}
65
+ $$
66
+
67
+ d'où :
68
+
69
+ $$
70
+ (1+t)^{${nbEvolutions.frenchify()}} = ${frac(vf, vi).toTex()}
71
+ $$
72
+
73
+ donc
74
+
75
+ ${alignTex([
76
+ ["t", "=", power(frac(vf, vi).toTex(), frac(1, nbEvolutions)).toTex() + "-1"],
77
+ [
78
+ "",
79
+ "\\approx",
80
+ round(substract(power(frac(vf, vi), frac(1, nbEvolutions)), 1).evaluate(), 4).frenchify(),
81
+ ],
82
+ ["", "\\approx", getAnswer(identifiers)],
83
+ ])}`;
84
+ };
85
+ const getKeys = () => {
86
+ return ["percent"];
87
+ };
88
+ const isAnswerValid = (ans, { answer }) => {
89
+ try {
90
+ return percentVEA(ans, answer);
91
+ }
92
+ catch (err) {
93
+ return handleVEAError(err);
94
+ }
95
+ };
96
+ const getAverageEvolutionRateFromStartAndEndValueQuestion = () => {
97
+ const vi = randint(10, 100);
98
+ const vf = randint(10, 100, [vi]);
99
+ const nbEvolutions = randint(4, 10);
100
+ const identifiers = {
101
+ nbEvolutions,
102
+ vi,
103
+ vf,
104
+ };
105
+ return getQuestionFromIdentifiers(identifiers);
106
+ };
107
+ const getQuestionFromIdentifiers = (identifiers) => {
108
+ return {
109
+ answer: getAnswer(identifiers),
110
+ instruction: getInstruction(identifiers),
111
+ keys: getKeys(identifiers),
112
+ answerFormat: "tex",
113
+ identifiers,
114
+ hint: getHint(identifiers),
115
+ correction: getCorrection(identifiers),
116
+ };
117
+ };
118
+ export const averageEvolutionRateFromStartAndEndValue = {
119
+ id: "averageEvolutionRateFromStartAndEndValue",
120
+ connector: "=",
121
+ label: "Déterminer le taux d'évolution moyen en connaissant la valeur initiale, la valeur finale et le nombre d'évolutions",
122
+ isSingleStep: true,
123
+ generator: (nb, opts) => getDistinctQuestions(() => getAverageEvolutionRateFromStartAndEndValueQuestion(opts), nb),
124
+ qcmTimer: 60,
125
+ freeTimer: 60,
126
+ getPropositions,
127
+ isAnswerValid,
128
+ subject: "Mathématiques",
129
+ getInstruction,
130
+ getHint,
131
+ getCorrection,
132
+ getAnswer,
133
+ getQuestionFromIdentifiers,
134
+ hasHintAndCorrection: true,
135
+ };
@@ -9,4 +9,5 @@ export * from "./findStartValueAfterEvolution.js";
9
9
  export * from "./findEndValueAfterEvolution.js";
10
10
  export * from "./findRightCalculForPriceEvolution.js";
11
11
  export * from "./globalCM.js";
12
+ export * from "./averageEvolutionRateFromStartAndEndValue.js";
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/percent/evolutions/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,uCAAuC,CAAC;AACtD,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/percent/evolutions/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,uCAAuC,CAAC;AACtD,cAAc,eAAe,CAAC;AAC9B,cAAc,+CAA+C,CAAC"}
@@ -9,3 +9,4 @@ export * from "./findStartValueAfterEvolution.js";
9
9
  export * from "./findEndValueAfterEvolution.js";
10
10
  export * from "./findRightCalculForPriceEvolution.js";
11
11
  export * from "./globalCM.js";
12
+ export * from "./averageEvolutionRateFromStartAndEndValue.js";
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ nIds: NodeIdentifiers;
5
+ kIds: NodeIdentifiers;
6
+ };
7
+ export declare const equationOnePlusTPowerN: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=equationOnePlusTPowerN.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"equationOnePlusTPowerN.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/equationOnePlusTPowerN.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAQ7C,KAAK,WAAW,GAAG;IAEjB,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AAmGF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAkBxD,CAAC"}
@@ -0,0 +1,118 @@
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 { randint } from "../../../math/utils/random/randint.js";
6
+ import { round } from "../../../math/utils/round.js";
7
+ import { reifyAlgebraic, } from "../../../tree/nodes/nodeConstructor.js";
8
+ import { add } from "../../../tree/nodes/operators/addNode.js";
9
+ import { frac } from "../../../tree/nodes/operators/fractionNode.js";
10
+ import { power } from "../../../tree/nodes/operators/powerNode.js";
11
+ import { substract } from "../../../tree/nodes/operators/substractNode.js";
12
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
13
+ import { alignTex } from "../../../utils/latex/alignTex.js";
14
+ const getPropositions = (n, { answer }) => {
15
+ const propositions = [];
16
+ addValidProp(propositions, answer);
17
+ propWhile(propositions, n, () => {
18
+ tryToAddWrongProp(propositions, randfloat(0.1, 1.1, 2).frenchify());
19
+ });
20
+ return shuffleProps(propositions, n);
21
+ };
22
+ const getAnswer = (identifiers) => {
23
+ const { nIds, kIds } = identifiers;
24
+ const n = reifyAlgebraic(nIds);
25
+ const k = reifyAlgebraic(kIds);
26
+ return round(substract(power(k, frac(1, n)), 1).evaluate(), 2).frenchify();
27
+ };
28
+ const getInstruction = (identifiers) => {
29
+ const { nIds, kIds } = identifiers;
30
+ const n = reifyAlgebraic(nIds);
31
+ const k = reifyAlgebraic(kIds);
32
+ return `Résoudre l'équation suivante :
33
+
34
+ $$
35
+ ${power(add(1, "t"), n).toTex()}= ${k.toTex()}
36
+ $$
37
+
38
+ Donner la solution arrondie au centième.`;
39
+ };
40
+ const getHint = () => {
41
+ return `Utilise la propriété suivante :
42
+
43
+ $$
44
+ a^n = k \\iff a = k^{\\frac{1}{n}}
45
+ $$`;
46
+ };
47
+ const getCorrection = (identifiers) => {
48
+ const { nIds, kIds } = identifiers;
49
+ const n = reifyAlgebraic(nIds);
50
+ const k = reifyAlgebraic(kIds);
51
+ return `On sait que :
52
+
53
+ $$
54
+ a^n = k \\iff a = k^{\\frac{1}{n}}
55
+ $$
56
+
57
+ Ici, on a donc :
58
+
59
+ ${alignTex([
60
+ ["1+t", "=", power(k, frac(1, n)).toTex()],
61
+ ["", "\\approx", round(power(k, frac(1, n)).evaluate(), 2).frenchify()],
62
+ ])}
63
+
64
+ On en déduit donc :
65
+
66
+ $$
67
+ t \\approx ${getAnswer(identifiers)}
68
+ $$`;
69
+ };
70
+ const getKeys = () => {
71
+ return [];
72
+ };
73
+ const isAnswerValid = (ans, { answer }) => {
74
+ try {
75
+ return numberVEA(ans, answer);
76
+ }
77
+ catch (err) {
78
+ return handleVEAError(err);
79
+ }
80
+ };
81
+ const getEquationOnePlusTPowerNQuestion = () => {
82
+ const n = randint(3, 10);
83
+ const k = randint(2, 10);
84
+ const identifiers = {
85
+ kIds: k.toTree().toIdentifiers(),
86
+ nIds: n.toTree().toIdentifiers(),
87
+ };
88
+ return getQuestionFromIdentifiers(identifiers);
89
+ };
90
+ const getQuestionFromIdentifiers = (identifiers) => {
91
+ return {
92
+ answer: getAnswer(identifiers),
93
+ instruction: getInstruction(identifiers),
94
+ keys: getKeys(identifiers),
95
+ answerFormat: "tex",
96
+ identifiers,
97
+ hint: getHint(identifiers),
98
+ correction: getCorrection(identifiers),
99
+ };
100
+ };
101
+ export const equationOnePlusTPowerN = {
102
+ id: "equationOnePlusTPowerN",
103
+ connector: "=",
104
+ label: "Résoudre une équation du type $(1 + t)^n = k$, d'inconnue $t$",
105
+ isSingleStep: true,
106
+ generator: (nb, opts) => getDistinctQuestions(() => getEquationOnePlusTPowerNQuestion(opts), nb),
107
+ qcmTimer: 60,
108
+ freeTimer: 60,
109
+ getPropositions,
110
+ isAnswerValid,
111
+ subject: "Mathématiques",
112
+ getInstruction,
113
+ getHint,
114
+ getCorrection,
115
+ getAnswer,
116
+ getQuestionFromIdentifiers,
117
+ hasHintAndCorrection: true,
118
+ };
@@ -0,0 +1,13 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ writeAsRoot: boolean;
5
+ aIds: NodeIdentifiers;
6
+ nIds: NodeIdentifiers;
7
+ };
8
+ type Options = {
9
+ writeAsRoot: boolean;
10
+ };
11
+ export declare const estimateNthRoot: Exercise<Identifiers, Options>;
12
+ export {};
13
+ //# sourceMappingURL=estimateNthRoot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimateNthRoot.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/estimateNthRoot.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAK7C,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,OAAO,CAAC;IAErB,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AA0GF,KAAK,OAAO,GAAG;IACb,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAYF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAoB1D,CAAC"}