math-exercises 3.0.163 → 3.0.165

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 (66) hide show
  1. package/lib/exercises/exercise.d.ts +1 -1
  2. package/lib/exercises/exercise.d.ts.map +1 -1
  3. package/lib/exercises/math/functions/basics/inverseImageFunctionGeogebra.d.ts.map +1 -1
  4. package/lib/exercises/math/functions/basics/inverseImageFunctionGeogebra.js +3 -1
  5. package/lib/exercises/math/functions/trinoms/devForm/variationsFromAlgebricForm.d.ts +6 -2
  6. package/lib/exercises/math/functions/trinoms/devForm/variationsFromAlgebricForm.d.ts.map +1 -1
  7. package/lib/exercises/math/functions/trinoms/devForm/variationsFromAlgebricForm.js +85 -13
  8. package/lib/exercises/math/functions/trinoms/equation/index.d.ts +2 -0
  9. package/lib/exercises/math/functions/trinoms/equation/index.d.ts.map +1 -1
  10. package/lib/exercises/math/functions/trinoms/equation/index.js +2 -0
  11. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationByFactorisation.d.ts +4 -1
  12. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationByFactorisation.d.ts.map +1 -1
  13. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationByFactorisation.js +169 -8
  14. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationEqualsC.d.ts +10 -0
  15. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationEqualsC.d.ts.map +1 -0
  16. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationEqualsC.js +146 -0
  17. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationFromCano.d.ts.map +1 -1
  18. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationFromCano.js +73 -3
  19. package/lib/exercises/math/functions/trinoms/equation/trinomSelectEquationWithoutDeltaNeeded.d.ts +13 -0
  20. package/lib/exercises/math/functions/trinoms/equation/trinomSelectEquationWithoutDeltaNeeded.d.ts.map +1 -0
  21. package/lib/exercises/math/functions/trinoms/equation/trinomSelectEquationWithoutDeltaNeeded.js +204 -0
  22. package/lib/exercises/math/functions/trinoms/roots/index.d.ts +1 -0
  23. package/lib/exercises/math/functions/trinoms/roots/index.d.ts.map +1 -1
  24. package/lib/exercises/math/functions/trinoms/roots/index.js +1 -0
  25. package/lib/exercises/math/functions/trinoms/roots/rootsFromFactorizedForm.d.ts.map +1 -1
  26. package/lib/exercises/math/functions/trinoms/roots/rootsFromFactorizedForm.js +42 -9
  27. package/lib/exercises/math/functions/trinoms/roots/trinomAlgebraicFormFromRootsAndPoint.d.ts +13 -0
  28. package/lib/exercises/math/functions/trinoms/roots/trinomAlgebraicFormFromRootsAndPoint.d.ts.map +1 -0
  29. package/lib/exercises/math/functions/trinoms/roots/trinomAlgebraicFormFromRootsAndPoint.js +252 -0
  30. package/lib/exercises/math/functions/trinoms/sign/index.d.ts +2 -0
  31. package/lib/exercises/math/functions/trinoms/sign/index.d.ts.map +1 -1
  32. package/lib/exercises/math/functions/trinoms/sign/index.js +2 -0
  33. package/lib/exercises/math/functions/trinoms/sign/parabolaSignTable.d.ts +9 -0
  34. package/lib/exercises/math/functions/trinoms/sign/parabolaSignTable.d.ts.map +1 -0
  35. package/lib/exercises/math/functions/trinoms/sign/parabolaSignTable.js +123 -0
  36. package/lib/exercises/math/functions/trinoms/sign/trinomSignTableFromAlgebraicForm.d.ts +13 -0
  37. package/lib/exercises/math/functions/trinoms/sign/trinomSignTableFromAlgebraicForm.d.ts.map +1 -0
  38. package/lib/exercises/math/functions/trinoms/sign/trinomSignTableFromAlgebraicForm.js +209 -0
  39. package/lib/exercises/math/functions/trinoms/summitAndCanonical/devFormFromSummitAndPoint.d.ts +4 -1
  40. package/lib/exercises/math/functions/trinoms/summitAndCanonical/devFormFromSummitAndPoint.d.ts.map +1 -1
  41. package/lib/exercises/math/functions/trinoms/summitAndCanonical/devFormFromSummitAndPoint.js +70 -46
  42. package/lib/exercises/math/probaStat/index.js +1 -0
  43. package/lib/exercises/math/probaStat/trees/index.d.ts +2 -0
  44. package/lib/exercises/math/probaStat/trees/index.d.ts.map +1 -0
  45. package/lib/exercises/math/probaStat/trees/index.js +1 -0
  46. package/lib/exercises/math/probaStat/trees/treeInInstruction.d.ts +8 -0
  47. package/lib/exercises/math/probaStat/trees/treeInInstruction.d.ts.map +1 -0
  48. package/lib/exercises/math/probaStat/trees/treeInInstruction.js +110 -0
  49. package/lib/exercises/math/sequences/arithmetic/arithmeticVariations.d.ts +13 -0
  50. package/lib/exercises/math/sequences/arithmetic/arithmeticVariations.d.ts.map +1 -0
  51. package/lib/exercises/math/sequences/arithmetic/arithmeticVariations.js +163 -0
  52. package/lib/exercises/math/sequences/arithmetic/index.d.ts +1 -0
  53. package/lib/exercises/math/sequences/arithmetic/index.d.ts.map +1 -1
  54. package/lib/exercises/math/sequences/arithmetic/index.js +1 -0
  55. package/lib/index.d.ts +45 -4
  56. package/lib/index.d.ts.map +1 -1
  57. package/lib/math/polynomials/trinom.d.ts +1 -1
  58. package/lib/math/polynomials/trinom.d.ts.map +1 -1
  59. package/lib/math/polynomials/trinom.js +5 -2
  60. package/lib/tree/nodes/numbers/constantNode.d.ts +1 -0
  61. package/lib/tree/nodes/numbers/constantNode.d.ts.map +1 -1
  62. package/lib/tree/nodes/numbers/constantNode.js +7 -0
  63. package/lib/tree/nodes/numbers/numberNode.d.ts +1 -0
  64. package/lib/tree/nodes/numbers/numberNode.d.ts.map +1 -1
  65. package/lib/tree/nodes/numbers/numberNode.js +7 -0
  66. package/package.json +1 -1
@@ -0,0 +1,252 @@
1
+ import { addValidProp, shuffleProps, GeneratorOptionTarget, GeneratorOptionType, propWhile, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { Point, PointConstructor, } from "../../../../../math/geometry/point.js";
4
+ import { randint } from "../../../../../math/utils/random/randint.js";
5
+ import { randTupleInt } from "../../../../../math/utils/random/randTupleInt.js";
6
+ import { reifyAlgebraic, } from "../../../../../tree/nodes/nodeConstructor.js";
7
+ import { frac } from "../../../../../tree/nodes/operators/fractionNode.js";
8
+ import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
9
+ import { square } from "../../../../../tree/nodes/operators/powerNode.js";
10
+ import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
11
+ import { parseAlgebraic } from "../../../../../tree/parsers/latexParser.js";
12
+ import { coinFlip } from "../../../../../utils/alea/coinFlip.js";
13
+ import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
14
+ import { alignTex } from "../../../../../utils/latex/alignTex.js";
15
+ const getPropositions = (n, { answer }, opts) => {
16
+ const propositions = [];
17
+ addValidProp(propositions, answer);
18
+ propWhile(propositions, n, () => {
19
+ tryToAddWrongProp(propositions, getAnswer(generateIdentifiers(), opts));
20
+ });
21
+ return shuffleProps(propositions, n);
22
+ };
23
+ const getAnswerNode = (identifiers, options) => {
24
+ const { pointIds, rootsIds } = identifiers;
25
+ const point = PointConstructor.fromIdentifiers(pointIds);
26
+ const roots = rootsIds.map((rootId) => reifyAlgebraic(rootId));
27
+ const partialTrinom = roots.length === 1
28
+ ? square(substract("x", roots[0]).simplify())
29
+ : multiply(substract("x", roots[0]).simplify(), substract("x", roots[1]).simplify());
30
+ const partialImage = partialTrinom
31
+ .toDetailedEvaluation({ x: point.x })
32
+ .simplify();
33
+ const a = frac(point.y, partialImage).simplify();
34
+ const facto = multiply(a, partialTrinom).simplify({ forbidFactorize: true });
35
+ if (options?.expectedForm === "Forme développée")
36
+ return facto.simplify({ towardsDistribute: true, forbidFactorize: true });
37
+ return facto;
38
+ };
39
+ const getAnswer = (identifiers, opts) => {
40
+ return getAnswerNode(identifiers, opts).toTex();
41
+ };
42
+ const getInstruction = (identifiers, opts) => {
43
+ const { pointIds, rootsIds } = identifiers;
44
+ const point = PointConstructor.fromIdentifiers(pointIds);
45
+ const roots = rootsIds.map((rootId) => reifyAlgebraic(rootId));
46
+ return `Soit $f$ une fonction polynôme du second degré, dont la parabole passe par le point $${point.toTexWithCoords()}$, et qui a ${roots.length === 1
47
+ ? `pour seule racine : $${roots[0].toTex()}$`
48
+ : `deux racines : $${roots[0].toTex()}$ et $${roots[1].toTex()}$`}
49
+
50
+ Déterminer la forme ${opts?.expectedForm === "Forme développée" ? "développée" : "factorisée"} de $f(x)$.
51
+ `;
52
+ };
53
+ const getHint = () => {
54
+ return `Si $f$ est une fonction polynôme du second degré ayant deux racines $x_1$ et $x_2$, alors sa forme factorisée est :
55
+
56
+ $$
57
+ f(x) = a(x-x_1)(x-x_2)
58
+ $$
59
+
60
+ Si elle n'admet qu'une racine $x_0$, alors sa forme factorisée est :
61
+
62
+ $$
63
+ f(x) = a(x-x_0)^2
64
+ $$
65
+
66
+ Sers-toi ensuite du fait que $A$ appartient à la courbe de $f$ pour déterminer $a$.
67
+ `;
68
+ };
69
+ const getCorrection = (identifiers, opts) => {
70
+ const { pointIds, rootsIds } = identifiers;
71
+ const point = PointConstructor.fromIdentifiers(pointIds);
72
+ const roots = rootsIds.map((rootId) => reifyAlgebraic(rootId));
73
+ const partialTrinom = roots.length === 1
74
+ ? square(substract("x", roots[0]).simplify())
75
+ : multiply(substract("x", roots[0]).simplify(), substract("x", roots[1]).simplify());
76
+ const partialImage = partialTrinom
77
+ .toDetailedEvaluation({ x: point.x })
78
+ .simplify();
79
+ const a = frac(point.y, partialImage).simplify();
80
+ if (roots.length === 1) {
81
+ return `Puisque $f$ a une seule racine $${roots[0].toTex()}$, sa forme factorisée est :
82
+
83
+ $$
84
+ f(x) = ${multiply("a", square(substract("x", roots[0]).simplify())).toTex()}
85
+ $$
86
+
87
+ Pour déterminer $a$, on utilise le fait que $${point.toTexWithCoords()}$ appartient à la parabole représentative de $f$. Cela implique que $f(${point.x.toTex()})=${point.y.toTex()}$. Donc :
88
+
89
+ $$
90
+ ${multiply("a", square(substract(point.x, roots[0]))).toTex()}=${point.y.toTex()}
91
+ $$
92
+
93
+ d'où $a =${a.toTex()}$.
94
+
95
+ La forme factorisée de $f$ est donc :
96
+
97
+ $$
98
+ f(x) = ${multiply(a, partialTrinom).toTex()}
99
+ $$
100
+
101
+ ${opts?.expectedForm === "Forme développée"
102
+ ? `
103
+ Il suffit alors de développer et réduire pour obtenir la forme développée :
104
+
105
+ ${alignTex([
106
+ ["f(x)", "=", multiply(a, partialTrinom).toTex()],
107
+ [
108
+ "",
109
+ "=",
110
+ multiply(a, partialTrinom.simplify({
111
+ towardsDistribute: true,
112
+ forbidFactorize: true,
113
+ })).toTex(),
114
+ ],
115
+ [
116
+ "",
117
+ "=",
118
+ multiply(a, partialTrinom)
119
+ .simplify({ towardsDistribute: true, forbidFactorize: true })
120
+ .toTex(),
121
+ ],
122
+ ])}
123
+ `
124
+ : ""}
125
+ `;
126
+ }
127
+ return `Puisque $f$ a deux racines $${roots[0].toTex()}$ et $${roots[1].toTex()}$, sa forme factorisée est :
128
+
129
+ $$
130
+ f(x) = ${multiply("a", multiply(substract("x", roots[0]).simplify(), substract("x", roots[1]).simplify())).toTex()}
131
+ $$
132
+
133
+ Pour déterminer $a$, on utilise le fait que $${point.toTexWithCoords()}$ appartient à la parabole représentative de $f$. Cela implique que $f(${point.x.toTex()})=${point.y.toTex()}$. Donc :
134
+
135
+ $$
136
+ ${multiply("a", multiply(substract(point.x, roots[0]).simplify(), substract(point.x, roots[1]).simplify())).toTex()}=${point.y.toTex()}
137
+ $$
138
+
139
+ d'où $a =${a.toTex()}$.
140
+
141
+ La forme factorisée de $f$ est donc :
142
+
143
+ $$
144
+ f(x) = ${multiply(a, partialTrinom).toTex()}
145
+ $$
146
+
147
+ ${opts?.expectedForm === "Forme développée"
148
+ ? `
149
+ Il suffit alors de développer et réduire pour obtenir la forme développée :
150
+
151
+ ${alignTex([
152
+ ["f(x)", "=", multiply(a, partialTrinom).toTex()],
153
+ [
154
+ "",
155
+ "=",
156
+ multiply(a, partialTrinom.simplify({
157
+ towardsDistribute: true,
158
+ forbidFactorize: true,
159
+ })).toTex(),
160
+ ],
161
+ [
162
+ "",
163
+ "=",
164
+ multiply(a, partialTrinom)
165
+ .simplify({ towardsDistribute: true, forbidFactorize: true })
166
+ .toTex(),
167
+ ],
168
+ ])}
169
+ `
170
+ : ""}`;
171
+ };
172
+ const getKeys = () => {
173
+ return ["xsquare", "x"];
174
+ };
175
+ const isAnswerValid = (ans, { answer, ...identifiers }, opts) => {
176
+ try {
177
+ const parsed = parseAlgebraic(ans);
178
+ const ansNode = getAnswerNode(identifiers, opts);
179
+ return (parsed
180
+ .simplify({ towardsDistribute: true, forbidFactorize: true })
181
+ .toTex() ===
182
+ ansNode
183
+ .simplify({ towardsDistribute: true, forbidFactorize: true })
184
+ .toTex());
185
+ }
186
+ catch (err) {
187
+ return handleVEAError(err);
188
+ }
189
+ };
190
+ const generateIdentifiers = (_options) => {
191
+ const uniqueRoot = coinFlip();
192
+ const roots = uniqueRoot
193
+ ? [randint(-9, 10, [0])]
194
+ : randTupleInt(2, {
195
+ from: -9,
196
+ to: 10,
197
+ allDifferent: true,
198
+ }).sort((a, b) => a - b);
199
+ const a = randint(-9, 10, [0]);
200
+ const pointX = randint(-9, 10, roots);
201
+ const pointY = multiply(a, uniqueRoot
202
+ ? square(substract(pointX, roots[0]))
203
+ : multiply(substract(pointX, roots[0]), substract(pointX, roots[1]))).simplify();
204
+ const point = new Point("A", pointX, pointY);
205
+ return {
206
+ pointIds: point.toIdentifiers(),
207
+ rootsIds: roots.map((r) => r.toTree().toIdentifiers()),
208
+ };
209
+ };
210
+ const getTrinomAlgebraicFormFromRootsAndPointQuestion = (opts) => {
211
+ return getQuestionFromIdentifiers(generateIdentifiers(opts), opts);
212
+ };
213
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
214
+ return {
215
+ answer: getAnswer(identifiers, opts),
216
+ instruction: getInstruction(identifiers, opts),
217
+ keys: getKeys(identifiers),
218
+ answerFormat: "tex",
219
+ identifiers,
220
+ hint: getHint(identifiers, opts),
221
+ correction: getCorrection(identifiers, opts),
222
+ };
223
+ };
224
+ const options = [
225
+ {
226
+ id: "expectedForm",
227
+ label: "Forme attendue",
228
+ target: GeneratorOptionTarget.answer,
229
+ type: GeneratorOptionType.select,
230
+ values: ["Forme développée", "Forme factorisée"],
231
+ defaultValue: "Forme factorisée",
232
+ },
233
+ ];
234
+ export const trinomAlgebraicFormFromRootsAndPoint = {
235
+ id: "trinomAlgebraicFormFromRootsAndPoint",
236
+ connector: "=",
237
+ label: "Déterminer l'expression algébrique d'un trinôme en connaissant ses racines et un point de la parabole",
238
+ isSingleStep: true,
239
+ generator: (nb, opts) => getDistinctQuestions(() => getTrinomAlgebraicFormFromRootsAndPointQuestion(opts), nb),
240
+ qcmTimer: 60,
241
+ freeTimer: 60,
242
+ getPropositions,
243
+ isAnswerValid,
244
+ subject: "Mathématiques",
245
+ getInstruction,
246
+ getHint,
247
+ getCorrection,
248
+ getAnswer,
249
+ getQuestionFromIdentifiers,
250
+ hasHintAndCorrection: true,
251
+ options,
252
+ };
@@ -1,3 +1,5 @@
1
1
  export * from "./trinomSignFromRoots.js";
2
2
  export * from "./trinomSignFromFacto.js";
3
+ export * from "./trinomSignTableFromAlgebraicForm.js";
4
+ export * from "./parabolaSignTable.js";
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/sign/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/sign/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uCAAuC,CAAC;AACtD,cAAc,wBAAwB,CAAC"}
@@ -1,2 +1,4 @@
1
1
  export * from "./trinomSignFromRoots.js";
2
2
  export * from "./trinomSignFromFacto.js";
3
+ export * from "./trinomSignTableFromAlgebraicForm.js";
4
+ export * from "./parabolaSignTable.js";
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ a: number;
4
+ b: number;
5
+ c: number;
6
+ };
7
+ export declare const parabolaSignTable: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=parabolaSignTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parabolaSignTable.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/sign/parabolaSignTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAuHF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAoBnD,CAAC"}
@@ -0,0 +1,123 @@
1
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
2
+ import { GeogebraConstructor } from "../../../../../geogebra/geogebraConstructor.js";
3
+ import { Trinom, TrinomConstructor } from "../../../../../math/polynomials/trinom.js";
4
+ import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
5
+ const getInstruction = () => {
6
+ return `Ci-dessous est tracée la parabole qui représente graphiquement une fonction polynôme du second degré $f$ définie sur $\\mathbb{R}$.
7
+
8
+ Dresser le tableau de signes de $f$.`;
9
+ };
10
+ const getHint = () => {
11
+ return `La fonction est définie sur $\\mathbb{R}$, donc les valeurs de $x$ vont de $-\\infty$ à $+\\infty$.
12
+
13
+ Repère ensuite les points de la courbe à l'intersection de l'axe des abscisses. Dans la première ligne du tableau, il faut mettre les abscisses de ces points, et dans la deuxième ligne, le signe de $f(x)$.`;
14
+ };
15
+ const getCorrection = (identifiers) => {
16
+ const { a, b, c } = identifiers;
17
+ const trinom = new Trinom(a, b, c);
18
+ const roots = trinom.getRootsNode();
19
+ const sign = a > 0 ? "positive" : "négative";
20
+ const oppSign = a > 0 ? "négative" : "positive";
21
+ return `On lit graphiquement que les racines de $f$ sont $${roots[0].toTex()}$ et $${roots[1].toTex()}$.
22
+
23
+ Entre ces racines, c'est à dire sur l'intervalle $\\left[${roots[0].toTex()};${roots[1].toTex()}\\right]$, $f(x)$ est ${oppSign}.
24
+
25
+ Pour les valeurs de l'intervalle $\\left]-\\infty;${roots[0].toTex()}\\right]$ et de l'intervalle $\\left[${roots[1].toTex()};+\\infty \\right[$, $f(x)$ est ${sign}.
26
+ `;
27
+ };
28
+ const getGGBOptions = (identifiers) => {
29
+ const { a, b, c } = identifiers;
30
+ const trinom = new Trinom(a, b, c);
31
+ const roots = trinom.getRoots();
32
+ const beta = trinom.getBeta();
33
+ const ggb = new GeogebraConstructor({
34
+ commands: [`f(x) = ${a}*x^2 + ${b}*x + ${c}`],
35
+ lockedAxesRatio: false,
36
+ gridDistance: false,
37
+ xAxis: {
38
+ steps: 1,
39
+ },
40
+ });
41
+ const xMin = roots[0] - 2;
42
+ const xMax = roots[1] + 2;
43
+ const yMin = a > 0 ? beta : -5;
44
+ const yMax = a < 0 ? beta : 5;
45
+ return ggb.getOptions({
46
+ coords: [xMin, xMax, yMin, yMax],
47
+ });
48
+ };
49
+ const getKeys = () => {
50
+ return ["infty"];
51
+ };
52
+ const getAnswerTable = (identifiers) => {
53
+ const { a, b, c } = identifiers;
54
+ const trinom = new Trinom(a, b, c);
55
+ const roots = trinom.getRootsNode();
56
+ const opp = a > 0 ? "-" : "+";
57
+ const sign = a > 0 ? "+" : "-";
58
+ return [
59
+ [
60
+ "$x$",
61
+ "-\\infty",
62
+ "\\ ",
63
+ roots[0].toTex(),
64
+ "\\ ",
65
+ roots[1].toTex(),
66
+ "\\ ",
67
+ "+\\infty",
68
+ ],
69
+ ["$f(x)$", "\\ ", sign, "0", opp, "0", sign, "\\ "],
70
+ ];
71
+ };
72
+ const isAnswerTableValid = (ans, { answerTable }) => {
73
+ try {
74
+ return ans.every((row, i) => row.every((cell, j) => cell === answerTable[i][j]));
75
+ }
76
+ catch (err) {
77
+ return handleVEAError(err);
78
+ }
79
+ };
80
+ const getSignTableFromGraphQuestion = () => {
81
+ const trinom = TrinomConstructor.randomNiceRoots(2);
82
+ const identifiers = {
83
+ a: trinom.a,
84
+ b: trinom.b,
85
+ c: trinom.c,
86
+ };
87
+ return getQuestionFromIdentifiers(identifiers);
88
+ };
89
+ const getQuestionFromIdentifiers = (identifiers) => {
90
+ return {
91
+ answerTable: getAnswerTable(identifiers),
92
+ instruction: getInstruction(identifiers),
93
+ keys: getKeys(identifiers),
94
+ answerFormat: "tex",
95
+ identifiers,
96
+ hint: getHint(identifiers),
97
+ correction: getCorrection(identifiers),
98
+ ggbOptions: getGGBOptions(identifiers),
99
+ initTable: [
100
+ ["$x$", "", "\\ ", "", "\\ ", "", "\\ ", ""],
101
+ ["$f(x)$", "\\ ", "", "", "", "", "", "\\ "],
102
+ ],
103
+ };
104
+ };
105
+ export const parabolaSignTable = {
106
+ id: "parabolaSignTable",
107
+ label: "Dresser le tableau de signes d'une parabole représentée graphiquement",
108
+ isSingleStep: true,
109
+ generator: (nb, opts) => getDistinctQuestions(() => getSignTableFromGraphQuestion(opts), nb),
110
+ qcmTimer: 60,
111
+ freeTimer: 60,
112
+ isAnswerTableValid,
113
+ subject: "Mathématiques",
114
+ getHint,
115
+ getCorrection,
116
+ getInstruction,
117
+ getAnswerTable,
118
+ getGGBOptions,
119
+ hasGeogebra: true,
120
+ getQuestionFromIdentifiers,
121
+ answerType: "signTable",
122
+ hasHintAndCorrection: true,
123
+ };
@@ -0,0 +1,13 @@
1
+ import { Exercise } from "../../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ a: number;
4
+ b: number;
5
+ c: number;
6
+ form: "dev" | "cano" | "facto";
7
+ };
8
+ type Options = {
9
+ givenForm: string;
10
+ };
11
+ export declare const trinomSignTableFromAlgebraicForm: Exercise<Identifiers, Options>;
12
+ export {};
13
+ //# sourceMappingURL=trinomSignTableFromAlgebraicForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trinomSignTableFromAlgebraicForm.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/sign/trinomSignTableFromAlgebraicForm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;CAChC,CAAC;AAwMF,KAAK,OAAO,GAAG;IACb,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAWF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAoBzE,CAAC"}
@@ -0,0 +1,209 @@
1
+ import { GeneratorOptionTarget, GeneratorOptionType, } from "../../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { Trinom, TrinomConstructor } from "../../../../../math/polynomials/trinom.js";
4
+ import { opposite } from "../../../../../tree/nodes/functions/oppositeNode.js";
5
+ import { sqrt } from "../../../../../tree/nodes/functions/sqrtNode.js";
6
+ import { add } from "../../../../../tree/nodes/operators/addNode.js";
7
+ import { frac } from "../../../../../tree/nodes/operators/fractionNode.js";
8
+ import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
9
+ import { square } from "../../../../../tree/nodes/operators/powerNode.js";
10
+ import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
11
+ import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
12
+ const getAnswerTable = (identifiers) => {
13
+ const { a, b, c } = identifiers;
14
+ const trinom = new Trinom(a, b, c);
15
+ const roots = trinom.getRootsNode();
16
+ const sign = a > 0 ? "+" : "-";
17
+ if (!roots.length) {
18
+ return [
19
+ ["$x$", "-\\infty", "\\ ", "+\\infty"],
20
+ ["$f(x)$", "\\ ", sign, "\\ "],
21
+ ];
22
+ }
23
+ if (roots.length === 1) {
24
+ const sign = a > 0 ? "+" : "-";
25
+ return [
26
+ ["$x$", "-\\infty", "\\ ", roots[0].toTex(), "\\ ", "+\\infty"],
27
+ ["$f(x)$", "\\ ", sign, "0", sign, "\\ "],
28
+ ];
29
+ }
30
+ const opp = a > 0 ? "-" : "+";
31
+ return [
32
+ [
33
+ "$x$",
34
+ "-\\infty",
35
+ "\\ ",
36
+ roots[0].toTex(),
37
+ "\\ ",
38
+ roots[1].toTex(),
39
+ "\\ ",
40
+ "+\\infty",
41
+ ],
42
+ ["$f(x)$", "\\ ", sign, "0", opp, "0", sign, "\\ "],
43
+ ];
44
+ };
45
+ const getInstruction = (identifiers) => {
46
+ const { a, b, c, form } = identifiers;
47
+ const trinom = new Trinom(a, b, c);
48
+ const eq = form === "dev"
49
+ ? trinom.toTree()
50
+ : form === "cano"
51
+ ? trinom.getCanonicalForm()
52
+ : trinom.toFactorized();
53
+ return `Soit $f$ la fonction polynôme du second degré définie sur $\\mathbb{R}$ par :
54
+
55
+ $$
56
+ f(x)=${eq.toTex()}
57
+ $$
58
+
59
+ Dresser le tableau de signes de $f$.
60
+ `;
61
+ };
62
+ const getHint = () => {
63
+ return `Un trinôme est du signe de son coefficient $a$, sauf entre ses éventuelles racines.
64
+
65
+ Il faut donc commencer par déterminer les solutions de l'équation $f(x) = 0$.`;
66
+ };
67
+ const getCorrection = (identifiers) => {
68
+ const { a, b, c, form } = identifiers;
69
+ const aSign = a > 0 ? "positive" : "négative";
70
+ const aInvSign = a > 0 ? "négative" : "positive";
71
+ const trinom = new Trinom(a, b, c);
72
+ const roots = trinom.getRootsNode();
73
+ let rootsTex = ``;
74
+ if (form === "dev") {
75
+ const delta = trinom.getDeltaNode();
76
+ rootsTex = `On calcule le discriminant :
77
+
78
+ $$
79
+ \\Delta = b^2 - 4ac= ${delta.toTex()}
80
+ $$
81
+
82
+ Puisque $\\Delta>0$, $f$ possède deux racines :
83
+
84
+ $$
85
+ x_1 = \\frac{-b-\\sqrt{\\Delta}}{2a} = ${frac(substract(opposite(b), sqrt(delta)), multiply(2, a))
86
+ .simplify()
87
+ .toTex()}
88
+ $$
89
+
90
+ $$
91
+ x_2 = \\frac{-b+\\sqrt{\\Delta}}{2a} = ${frac(add(opposite(b), sqrt(delta)), multiply(2, a))
92
+ .simplify()
93
+ .toTex()}
94
+ $$`;
95
+ }
96
+ else if (form === "cano") {
97
+ const alpha = trinom.getAlphaNode();
98
+ const beta = trinom.getBetaNode();
99
+ const cano = trinom.getCanonicalForm();
100
+ rootsTex = `On a :
101
+
102
+ $$
103
+ ${cano.toTex()}=0 \\iff ${square(substract("x", alpha).simplify()).toTex()} = ${frac(opposite(beta), a).simplify().toTex()}
104
+ $$
105
+
106
+ Cela donne deux équations à résoudre :
107
+
108
+ $$
109
+ ${substract("x", alpha).simplify().toTex()} = ${sqrt(frac(opposite(beta), a).simplify()).toTex()}
110
+ $$
111
+
112
+ d'où $x = ${substract(sqrt(frac(opposite(beta), a)), alpha)
113
+ .simplify()
114
+ .toTex()}$, et :
115
+
116
+ $$
117
+ ${substract("x", alpha).simplify().toTex()} = ${opposite(sqrt(frac(opposite(beta), a).simplify())).toTex()}
118
+ $$
119
+
120
+ d'où $x = ${substract(opposite(sqrt(frac(opposite(beta), a))), alpha)
121
+ .simplify()
122
+ .toTex()}$.
123
+
124
+ `;
125
+ }
126
+ else {
127
+ rootsTex = `Puisque $f$ est donnée sous forme factorisée, on peut facilement déterminer ses racines : ce sont $${roots[0].toTex()}$ et $${roots[1].toTex()}$.`;
128
+ }
129
+ return `Un trinôme est du signe de son coefficient $a$, sauf entre ses éventuelles racines. Ici, $f$ est donc ${aSign} sauf entre ses racines (si elle en a) où elle est ${aInvSign}.
130
+
131
+ On commence donc par déterminer les racines de $f$.
132
+
133
+ ${rootsTex}
134
+
135
+ On en conclut donc que $f$ est ${aSign} sur $\\left]-\\infty; ${roots[0].toTex()}\\right]$ et sur $\\left[${roots[1].toTex()}; +\\infty\\right[$, et ${aInvSign} sur $\\left[${roots[0].toTex()}; ${roots[1].toTex()}\\right]$.
136
+ `;
137
+ };
138
+ const isAnswerTableValid = (ans, { answerTable }) => {
139
+ try {
140
+ return ans.every((row, i) => row.every((cell, j) => cell === answerTable[i][j]));
141
+ }
142
+ catch (err) {
143
+ return handleVEAError(err);
144
+ }
145
+ };
146
+ const getTrinomSignTableFromAlgebraicFormQuestion = (opts) => {
147
+ const form = opts?.givenForm === "Forme canonique"
148
+ ? "cano"
149
+ : opts?.givenForm === "Forme factorisée"
150
+ ? "facto"
151
+ : "dev";
152
+ let trinom;
153
+ if (form === "cano") {
154
+ trinom = TrinomConstructor.randomNiceRootsAndSummit(2);
155
+ }
156
+ else {
157
+ trinom = TrinomConstructor.randomNiceRoots(2);
158
+ }
159
+ const identifiers = {
160
+ form,
161
+ a: trinom.a,
162
+ b: trinom.b,
163
+ c: trinom.c,
164
+ };
165
+ return getQuestionFromIdentifiers(identifiers, opts);
166
+ };
167
+ const getKeys = () => {
168
+ return ["infty"];
169
+ };
170
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
171
+ return {
172
+ answerTable: getAnswerTable(identifiers, opts),
173
+ instruction: getInstruction(identifiers, opts),
174
+ answerFormat: "tex",
175
+ keys: getKeys(identifiers),
176
+ identifiers,
177
+ hint: getHint(identifiers, opts),
178
+ correction: getCorrection(identifiers, opts),
179
+ initTable: [
180
+ ["$x$", "", "\\ ", "", "\\ ", "", "\\ ", ""],
181
+ ["$f(x)$", "\\ ", "", "", "", "", "", "\\ "],
182
+ ],
183
+ };
184
+ };
185
+ const options = [
186
+ {
187
+ id: "givenForm",
188
+ label: "Forme donnée",
189
+ target: GeneratorOptionTarget.generation,
190
+ type: GeneratorOptionType.select,
191
+ values: ["Forme développée", "Forme factorisée", "Forme canonique"],
192
+ defaultValue: "Forme développée",
193
+ },
194
+ ];
195
+ export const trinomSignTableFromAlgebraicForm = {
196
+ id: "trinomSignTableFromAlgebraicForm",
197
+ label: "Dresser le tableau de signes d'un trinôme donné sous forme algébrique",
198
+ isSingleStep: true,
199
+ generator: (nb, opts) => getDistinctQuestions(() => getTrinomSignTableFromAlgebraicFormQuestion(opts), nb),
200
+ qcmTimer: 60,
201
+ freeTimer: 60,
202
+ subject: "Mathématiques",
203
+ getQuestionFromIdentifiers,
204
+ hasHintAndCorrection: true,
205
+ answerType: "signTable",
206
+ options,
207
+ isAnswerTableValid,
208
+ getKeys,
209
+ };
@@ -4,6 +4,9 @@ type Identifiers = {
4
4
  summitIds: PointIdentifiers;
5
5
  pointIds: PointIdentifiers;
6
6
  };
7
- export declare const devFormFromSummitAndPoint: Exercise<Identifiers>;
7
+ type Options = {
8
+ expectedForm: string;
9
+ };
10
+ export declare const devFormFromSummitAndPoint: Exercise<Identifiers, Options>;
8
11
  export {};
9
12
  //# sourceMappingURL=devFormFromSummitAndPoint.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"devFormFromSummitAndPoint.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/summitAndCanonical/devFormFromSummitAndPoint.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAWtC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,gBAAgB,CAAC;IAC5B,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AAyLF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAmB3D,CAAC"}
1
+ {"version":3,"file":"devFormFromSummitAndPoint.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/summitAndCanonical/devFormFromSummitAndPoint.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAWtC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,gBAAgB,CAAC;IAC5B,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AAyNF,KAAK,OAAO,GAAG;IACb,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAaF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAoBpE,CAAC"}