math-exercises 3.0.203 → 3.0.205

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 (36) hide show
  1. package/lib/exercises/exercise.d.ts +4 -0
  2. package/lib/exercises/exercise.d.ts.map +1 -1
  3. package/lib/exercises/math/derivation/variations/index.d.ts.map +1 -1
  4. package/lib/exercises/math/derivation/variations/index.js +1 -0
  5. package/lib/exercises/math/derivation/variations/signVarTableWithExtremumTestExercise.d.ts +9 -0
  6. package/lib/exercises/math/derivation/variations/signVarTableWithExtremumTestExercise.d.ts.map +1 -0
  7. package/lib/exercises/math/derivation/variations/signVarTableWithExtremumTestExercise.js +191 -0
  8. package/lib/exercises/math/functions/continuity/equationNumberOfSolutionsFromVarTable.d.ts +9 -0
  9. package/lib/exercises/math/functions/continuity/equationNumberOfSolutionsFromVarTable.d.ts.map +1 -0
  10. package/lib/exercises/math/functions/continuity/equationNumberOfSolutionsFromVarTable.js +176 -0
  11. package/lib/exercises/math/functions/continuity/index.d.ts +6 -0
  12. package/lib/exercises/math/functions/continuity/index.d.ts.map +1 -0
  13. package/lib/exercises/math/functions/continuity/index.js +5 -0
  14. package/lib/exercises/math/functions/continuity/isFunctionContinuousFromGraph.d.ts +9 -0
  15. package/lib/exercises/math/functions/continuity/isFunctionContinuousFromGraph.d.ts.map +1 -0
  16. package/lib/exercises/math/functions/continuity/isFunctionContinuousFromGraph.js +193 -0
  17. package/lib/exercises/math/functions/continuity/piecewiseFunctionContinuity.d.ts +10 -0
  18. package/lib/exercises/math/functions/continuity/piecewiseFunctionContinuity.d.ts.map +1 -0
  19. package/lib/exercises/math/functions/continuity/piecewiseFunctionContinuity.js +150 -0
  20. package/lib/exercises/math/functions/continuity/signTableFromVarTableWithZeroes.d.ts +9 -0
  21. package/lib/exercises/math/functions/continuity/signTableFromVarTableWithZeroes.d.ts.map +1 -0
  22. package/lib/exercises/math/functions/continuity/signTableFromVarTableWithZeroes.js +162 -0
  23. package/lib/exercises/math/functions/continuity/thirdDegreeZeroesFramingWithCalculator.d.ts +8 -0
  24. package/lib/exercises/math/functions/continuity/thirdDegreeZeroesFramingWithCalculator.d.ts.map +1 -0
  25. package/lib/exercises/math/functions/continuity/thirdDegreeZeroesFramingWithCalculator.js +199 -0
  26. package/lib/exercises/math/functions/index.d.ts +1 -0
  27. package/lib/exercises/math/functions/index.d.ts.map +1 -1
  28. package/lib/exercises/math/functions/index.js +1 -0
  29. package/lib/exercises/math/functions/variations/index.d.ts.map +1 -1
  30. package/lib/exercises/math/functions/variations/index.js +1 -0
  31. package/lib/exercises/math/functions/variations/varTableWithExtremumTestExercise.d.ts +9 -0
  32. package/lib/exercises/math/functions/variations/varTableWithExtremumTestExercise.d.ts.map +1 -0
  33. package/lib/exercises/math/functions/variations/varTableWithExtremumTestExercise.js +183 -0
  34. package/lib/index.d.ts +19 -0
  35. package/lib/index.d.ts.map +1 -1
  36. package/package.json +1 -1
@@ -0,0 +1,193 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
4
+ import { AffineConstructor } from "../../../../math/polynomials/affine.js";
5
+ import { Polynomial } from "../../../../math/polynomials/polynomial.js";
6
+ import { TrinomConstructor } from "../../../../math/polynomials/trinom.js";
7
+ import { randint } from "../../../../math/utils/random/randint.js";
8
+ import { abs } from "../../../../tree/nodes/functions/absNode.js";
9
+ import { exp } from "../../../../tree/nodes/functions/expNode.js";
10
+ import { LogNode } from "../../../../tree/nodes/functions/logNode.js";
11
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
12
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
13
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
14
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
15
+ import { doWhile } from "../../../../utils/doWhile.js";
16
+ const getPropositions = (n, { answer }) => {
17
+ const propositions = [];
18
+ addValidProp(propositions, answer, "raw");
19
+ tryToAddWrongProp(propositions, "Oui", "raw");
20
+ tryToAddWrongProp(propositions, "Non", "raw");
21
+ return shuffleProps(propositions, n);
22
+ };
23
+ const getAnswer = (identifiers) => {
24
+ return identifiers.type < 5 ? "Oui" : "Non";
25
+ };
26
+ const getInstruction = () => {
27
+ return `On considère la fonction $f$ représentée ci-dessous.
28
+
29
+ $f$ semble-t-elle continue sur son ensemble de définition ?`;
30
+ };
31
+ const getHint = () => {
32
+ return `On reconnaît graphiquement une fonction continue au fait qu'on peut la tracer "sans lever le crayon". Est-ce le cas ici ?`;
33
+ };
34
+ const getCorrection = (identifiers) => {
35
+ const isContinuous = getAnswer(identifiers) === "Oui";
36
+ if (isContinuous)
37
+ return `On voit graphiquement que la courbe représentative de $f$ semble pouvoir être tracée sans avoir besoin de "lever le crayon". La fonction $f$ semble donc continue sur son ensemble de définition.`;
38
+ return `On voit graphiquement que la courbe représentative de $f$ ne semble pas pouvoir être tracée sans avoir besoin de "lever le crayon". La fonction $f$ ne semble donc pas continue sur son ensemble de définition.`;
39
+ };
40
+ const getGGBOptions = (identifiers) => {
41
+ const ggb = new GeogebraConstructor({
42
+ commands: [identifiers.functionCmd],
43
+ lockedAxesRatio: false,
44
+ gridDistance: false,
45
+ });
46
+ return ggb.getOptions({
47
+ coords: identifiers.coords,
48
+ });
49
+ };
50
+ const getKeys = () => {
51
+ return [];
52
+ };
53
+ const getIsFunctionContinuousFromGraphQuestion = () => {
54
+ const isContinuous = coinFlip();
55
+ const type = isContinuous ? randint(1, 5) : randint(5, 8);
56
+ let functionCmd = "";
57
+ let coords = [];
58
+ switch (type) {
59
+ case 1:
60
+ {
61
+ const k = randint(-10, 10, [0]);
62
+ const f = multiply(k, abs("x"));
63
+ const xs = new Array(22).fill(0).map((_, i) => i - 10);
64
+ const ys = xs.map((x) => f.evaluate({ x }));
65
+ const yMin = Math.min(...ys);
66
+ const yMax = Math.max(...ys);
67
+ functionCmd = `f(x) = ${k}*abs(x)`;
68
+ coords = [-10, 10, yMin, yMax];
69
+ }
70
+ break;
71
+ case 2:
72
+ {
73
+ const a = randint(-10, 10);
74
+ const b = randint(-10, 10);
75
+ const c = randint(-10, 10);
76
+ const d = randint(-10, 10, [0]);
77
+ const f = new Polynomial([a, b, c, d]).toTree();
78
+ functionCmd = `f(x) = ${f.toMathString()}`;
79
+ const xs = new Array(22).fill(0).map((_, i) => i - 10);
80
+ const ys = xs.map((x) => f.evaluate({ x }));
81
+ const yMin = Math.min(...ys);
82
+ const yMax = Math.max(...ys);
83
+ coords = [-10, 10, yMin, yMax];
84
+ }
85
+ break;
86
+ case 3:
87
+ {
88
+ const k = randint(-10, 10, [0]);
89
+ const m = randint(-10, 10, [0]);
90
+ const f = multiply(k, exp(multiply(m, "x")));
91
+ functionCmd = `f(x) = ${f.toMathString()}`;
92
+ const xs = new Array(22).fill(0).map((_, i) => i - 10);
93
+ const ys = xs
94
+ .map((x) => f.evaluate({ x }))
95
+ .filter((y) => !isNaN(y) && y > -10000 && y < 10000);
96
+ const yMin = Math.min(...ys, -2);
97
+ const yMax = Math.max(...ys, 2);
98
+ coords = [-10, 10, yMin, yMax];
99
+ }
100
+ break;
101
+ case 4:
102
+ {
103
+ const k = randint(-10, 10, [0]);
104
+ const m = randint(-10, 10, [0]);
105
+ const f = multiply(k, new LogNode(multiply(m, "x")));
106
+ functionCmd = `f(x) = ${f.toMathString()}`;
107
+ const xs = new Array(22).fill(0).map((_, i) => i - 10);
108
+ const ys = xs
109
+ .map((x) => f.evaluate({ x }))
110
+ .filter((y) => !isNaN(y) && y > -10000 && y < 10000);
111
+ const yMin = Math.min(...ys, -2);
112
+ const yMax = Math.max(...ys, 2);
113
+ coords = [m > 0 ? -1 : -10, m > 0 ? 10 : 1, yMin, yMax];
114
+ }
115
+ break;
116
+ case 5:
117
+ {
118
+ const k = randint(-10, 10, [0]);
119
+ const f = (x) => k * Math.floor(x);
120
+ functionCmd = `f(x) = ${k}*floor(x)`;
121
+ const xs = new Array(22).fill(0).map((_, i) => i - 10);
122
+ const ys = xs.map((x) => f(x));
123
+ const yMin = Math.min(...ys, -2);
124
+ const yMax = Math.max(...ys, 2);
125
+ coords = [-10, 10, yMin, yMax];
126
+ }
127
+ break;
128
+ case 6:
129
+ {
130
+ const a = randint(-10, 10, [0]);
131
+ const b = randint(-10, 10, [0]);
132
+ const c = randint(-10, 10, [0]);
133
+ const d = doWhile(() => randint(-10, 10, [0]), (x) => a / c === b / x);
134
+ const root = -d / c;
135
+ const f = frac(add(multiply(a, "x"), b), add(multiply(c, "x"), d));
136
+ functionCmd = `f(x) = ${f.toMathString()}`;
137
+ coords = [root - 10, root + 10, -100, 100];
138
+ }
139
+ break;
140
+ case 7:
141
+ {
142
+ const a = randint(-10, 10);
143
+ const aff = AffineConstructor.random().toTree();
144
+ const fa = aff.evaluate({ x: a });
145
+ const trinom = doWhile(() => TrinomConstructor.random().toTree(), (t) => Math.abs(t.evaluate({ x: a }) - fa) < 5);
146
+ const f = (x) => x < a ? aff.evaluate({ x }) : trinom.evaluate({ x });
147
+ functionCmd = `f(x) = If(x<${a}, ${aff.toMathString()}, ${trinom.toMathString()})`;
148
+ const xs = new Array(11).fill(0).map((_, i) => i - 5 + a);
149
+ const ys = xs.map((x) => f(x));
150
+ const yMin = Math.min(...ys, -2);
151
+ const yMax = Math.max(...ys, 2);
152
+ coords = [a - 5, a + 5, yMin, yMax];
153
+ }
154
+ break;
155
+ }
156
+ const identifiers = {
157
+ type,
158
+ functionCmd,
159
+ coords,
160
+ };
161
+ return getQuestionFromIdentifiers(identifiers);
162
+ };
163
+ const getQuestionFromIdentifiers = (identifiers) => {
164
+ return {
165
+ answer: getAnswer(identifiers),
166
+ instruction: getInstruction(identifiers),
167
+ keys: getKeys(identifiers),
168
+ answerFormat: "raw",
169
+ identifiers,
170
+ hint: getHint(identifiers),
171
+ correction: getCorrection(identifiers),
172
+ ggbOptions: getGGBOptions(identifiers),
173
+ };
174
+ };
175
+ export const isFunctionContinuousFromGraph = {
176
+ id: "isFunctionContinuousFromGraph",
177
+ label: "Déterminer si une fonction semble continue à partir de sa représentation graphique",
178
+ isSingleStep: true,
179
+ generator: (nb, opts) => getDistinctQuestions(() => getIsFunctionContinuousFromGraphQuestion(opts), nb),
180
+ qcmTimer: 60,
181
+ freeTimer: 60,
182
+ getPropositions,
183
+ subject: "Mathématiques",
184
+ getHint,
185
+ getCorrection,
186
+ getInstruction,
187
+ getAnswer,
188
+ getGGBOptions,
189
+ hasGeogebra: true,
190
+ getQuestionFromIdentifiers,
191
+ hasHintAndCorrection: true,
192
+ answerType: "QCU",
193
+ };
@@ -0,0 +1,10 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ aIds: NodeIdentifiers;
5
+ f1Ids: NodeIdentifiers;
6
+ f2Ids: NodeIdentifiers;
7
+ };
8
+ export declare const piecewiseFunctionContinuity: Exercise<Identifiers>;
9
+ export {};
10
+ //# sourceMappingURL=piecewiseFunctionContinuity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"piecewiseFunctionContinuity.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/continuity/piecewiseFunctionContinuity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAK7C,KAAK,WAAW,GAAG;IAGjB,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,eAAe,CAAC;CACxB,CAAC;AAwJF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAqB7D,CAAC"}
@@ -0,0 +1,150 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { AffineConstructor } from "../../../../math/polynomials/affine.js";
4
+ import { Trinom } from "../../../../math/polynomials/trinom.js";
5
+ import { randint } from "../../../../math/utils/random/randint.js";
6
+ import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
7
+ import { LimitNode } from "../../../../tree/nodes/operators/limitNode.js";
8
+ import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
9
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
10
+ const getPropositions = (n, { answer }) => {
11
+ const propositions = [];
12
+ addValidProp(propositions, answer, "raw");
13
+ tryToAddWrongProp(propositions, "Oui", "raw");
14
+ tryToAddWrongProp(propositions, "Non", "raw");
15
+ tryToAddWrongProp(propositions, "On ne peut pas savoir", "raw");
16
+ return shuffleProps(propositions, n);
17
+ };
18
+ const getAnswer = (identifiers) => {
19
+ const { aIds, f1Ids, f2Ids } = identifiers;
20
+ const a = reifyAlgebraic(aIds).evaluate();
21
+ const f1 = reifyAlgebraic(f1Ids);
22
+ const f2 = reifyAlgebraic(f2Ids);
23
+ return Math.abs(f1.evaluate({ x: a }) - f2.evaluate({ x: a })) < 0.01
24
+ ? "Oui"
25
+ : "Non";
26
+ };
27
+ const getInstruction = (identifiers) => {
28
+ const { aIds, f1Ids, f2Ids } = identifiers;
29
+ const a = reifyAlgebraic(aIds);
30
+ const f1 = reifyAlgebraic(f1Ids);
31
+ const f2 = reifyAlgebraic(f2Ids);
32
+ return `Soit $f$ la fonction définie sur $\\mathbb{R}$ par :
33
+
34
+ $$
35
+ f(x) = \\begin{cases} ${f1.toTex()} & \\text{si } x \\leq ${a.toTex()} \\\\ ${f2.toTex()} & \\text{si } x > ${a.toTex()} \\end{cases}
36
+ $$
37
+
38
+
39
+ La fonction $f$ est-elle continue sur $\\mathbb{R}$ ?`;
40
+ };
41
+ const getHint = (identifiers) => {
42
+ const { aIds } = identifiers;
43
+ const a = reifyAlgebraic(aIds);
44
+ return `La fonction $f$ est une fonction définie par morceaux. Pour savoir si elle est continue sur $\\mathbb{R}$, il faut :
45
+
46
+ - s'assurer que chaque "morceau" définissant $f$ soit continue;
47
+ - puis s'assurer que $f$ soit continue en $${a.toTex()}$. Pour cela, il faut vérifier si on a bien :
48
+
49
+ $$
50
+ ${new LimitNode(a, new VariableNode("f(x)"), "-").toTex()} = ${new LimitNode(a, new VariableNode("f(x)"), "+").toTex()} = f(${a.toTex()})
51
+ $$`;
52
+ };
53
+ const getCorrection = (identifiers) => {
54
+ const { aIds, f1Ids, f2Ids } = identifiers;
55
+ const a = reifyAlgebraic(aIds);
56
+ const f1 = reifyAlgebraic(f1Ids);
57
+ const f2 = reifyAlgebraic(f2Ids);
58
+ const fa = f1.evaluate({ x: a.evaluate() });
59
+ const f2a = f2.toDetailedEvaluation({ x: a });
60
+ const isContinuous = getAnswer(identifiers) === "Oui";
61
+ return `
62
+
63
+ La fonction $x \\mapsto ${f1.toTex()}$ est une fonction affine, donc elle est continue sur $]-\\infty; ${a.toTex()}]$.
64
+
65
+
66
+ La fonction $x \\mapsto ${f1.toTex()}$ est un polynôme du second degré, donc elle est continue sur $]${a.toTex()}; +\\infty[$.
67
+
68
+ Il reste à analyser la continuité de $f$ en $${a.toTex()}$. On a :
69
+
70
+ - $f(${a.toTex()}) = ${f1.toDetailedEvaluation({ x: a }).toTex()} = ${fa}$
71
+
72
+ - $${new LimitNode(a, new VariableNode("f(x)"), "-").toTex()} = f(${a.toTex()}) =${fa}$
73
+
74
+ - $${new LimitNode(a, new VariableNode("f(x)"), "+").toTex()} = ${new LimitNode(a, f2, "+").toTex()} = ${f2a.simplify().toTex()}$
75
+
76
+ ${isContinuous
77
+ ? `On a donc :
78
+
79
+ $$
80
+ ${new LimitNode(a, new VariableNode("f(x)")).toTex()} = f(${a.toTex()})
81
+ $$
82
+
83
+ On en déduit que $f$ est continue en $${a.toTex()}$, et donc continue sur $\\mathbb{R}$.
84
+
85
+ `
86
+ : `On a donc :
87
+
88
+ $$
89
+ ${new LimitNode(a, new VariableNode("f(x)")).toTex()} \\neq f(${a.toTex()})
90
+ $$
91
+
92
+ On en déduit que $f$ n'est pas continue en $${a.toTex()}$, et donc n'est pas continue sur $\\mathbb{R}$.
93
+ `} `;
94
+ };
95
+ const getKeys = () => {
96
+ return [];
97
+ };
98
+ const getPiecewiseFunctionContinuityQuestion = () => {
99
+ const isContinuous = coinFlip();
100
+ const a = randint(-5, 6);
101
+ const f1Aff = AffineConstructor.random();
102
+ let f2Ids;
103
+ const fa = f1Aff.calculate(a);
104
+ if (isContinuous) {
105
+ const m = randint(-9, 10, [0]);
106
+ const n = randint(-9, 10);
107
+ const p = fa - m * a ** 2 - n * a;
108
+ f2Ids = new Trinom(m, n, p).toTree().toIdentifiers();
109
+ }
110
+ else {
111
+ const m = randint(-9, 10, [0]);
112
+ const n = randint(-9, 10);
113
+ const p = fa - m * a ** 2 - n * a + randint(-9, 10, [0]);
114
+ f2Ids = new Trinom(m, n, p).toTree().toIdentifiers();
115
+ }
116
+ const identifiers = {
117
+ aIds: a.toTree().toIdentifiers(),
118
+ f1Ids: f1Aff.toTree().toIdentifiers(),
119
+ f2Ids,
120
+ };
121
+ return getQuestionFromIdentifiers(identifiers);
122
+ };
123
+ const getQuestionFromIdentifiers = (identifiers) => {
124
+ return {
125
+ answer: getAnswer(identifiers),
126
+ instruction: getInstruction(identifiers),
127
+ keys: getKeys(identifiers),
128
+ answerFormat: "raw",
129
+ identifiers,
130
+ hint: getHint(identifiers),
131
+ correction: getCorrection(identifiers),
132
+ };
133
+ };
134
+ export const piecewiseFunctionContinuity = {
135
+ id: "piecewiseFunctionContinuity",
136
+ label: "Déterminer si une fonction définie par morceaux est continue sur $\\mathbb{R}$.",
137
+ isSingleStep: true,
138
+ generator: (nb, opts) => getDistinctQuestions(() => getPiecewiseFunctionContinuityQuestion(opts), nb),
139
+ qcmTimer: 60,
140
+ freeTimer: 60,
141
+ getPropositions,
142
+ subject: "Mathématiques",
143
+ getInstruction,
144
+ getHint,
145
+ getCorrection,
146
+ getAnswer,
147
+ getQuestionFromIdentifiers,
148
+ hasHintAndCorrection: true,
149
+ answerType: "QCU",
150
+ };
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ xValues: number[];
4
+ yValues: number[];
5
+ xZeroes: number[];
6
+ };
7
+ export declare const signTableFromVarTableWithZeroes: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=signTableFromVarTableWithZeroes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signTableFromVarTableWithZeroes.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/continuity/signTableFromVarTableWithZeroes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAyJF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,CAqBjE,CAAC"}
@@ -0,0 +1,162 @@
1
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
2
+ import { signTableVEA } from "../../../../exercises/vea/signTableVEA.js";
3
+ import { randint } from "../../../../math/utils/random/randint.js";
4
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
5
+ const getAnswerTable = (identifiers) => {
6
+ const { xValues, yValues, xZeroes } = identifiers;
7
+ const signs = yValues[0] > 0 ? ["+", "-", "+"] : ["-", "+", "-"];
8
+ return [
9
+ [
10
+ "$x$",
11
+ xValues[0].frenchify(),
12
+ "\\ ",
13
+ xZeroes[0].frenchify(),
14
+ "\\ ",
15
+ xZeroes[1].frenchify(),
16
+ "\\ ",
17
+ xValues[3].frenchify(),
18
+ ],
19
+ ["$f(x)$", "\\ ", signs[0], "0", signs[1], "0", signs[2], "\\ "],
20
+ ];
21
+ };
22
+ const getTable = (identifiers) => {
23
+ const { xValues, yValues, xZeroes } = identifiers;
24
+ const isFirstAscending = yValues[0] < yValues[1];
25
+ const arrows = isFirstAscending
26
+ ? ["\\nearrow", "\\searrow", "\\nearrow"]
27
+ : ["\\searrow", "\\nearrow", "\\searrow"];
28
+ const xs = [];
29
+ for (let i = 0; i < xValues.length; i++) {
30
+ xs.push(xValues[i].frenchify());
31
+ const x = xZeroes.find((e) => e > xValues[i] && e < xValues[i + 1]);
32
+ xs.push(x !== undefined ? x.frenchify() : "\\ ");
33
+ if (x !== undefined)
34
+ arrows[i] = "0" + arrows[i];
35
+ }
36
+ return [
37
+ ["£x£", ...xs],
38
+ [
39
+ " ",
40
+ isFirstAscending ? "\\ " : yValues[0].frenchify(),
41
+ "\\ ",
42
+ isFirstAscending ? yValues[1].frenchify() : "\\ ",
43
+ "\\ ",
44
+ isFirstAscending ? "\\ " : yValues[2].frenchify(),
45
+ "\\ ",
46
+ isFirstAscending ? yValues[3].frenchify() : "\\ ",
47
+ ],
48
+ ["£f(x)£", "\\ ", arrows[0], "\\ ", arrows[1], "\\ ", arrows[2], "\\ "],
49
+ [
50
+ " ",
51
+ !isFirstAscending ? "\\ " : yValues[0].frenchify(),
52
+ "\\ ",
53
+ !isFirstAscending ? yValues[1].frenchify() : "\\ ",
54
+ "\\ ",
55
+ !isFirstAscending ? "\\ " : yValues[2].frenchify(),
56
+ "\\ ",
57
+ !isFirstAscending ? yValues[3].frenchify() : "\\ ",
58
+ ],
59
+ ];
60
+ };
61
+ const getInstruction = (identifiers) => {
62
+ const table = getTable(identifiers);
63
+ return `On donne ci-dessous le tableau de variations d'une fonction $f$, avec les antécédents de $0$ apparents.
64
+
65
+ <svg id="varTable">${JSON.stringify(table)}</svg>
66
+
67
+ Dresser le tableau de signes de $f$.
68
+ `;
69
+ };
70
+ const getHint = () => {
71
+ return `Dans le tableau de variations, les antécédents de $0$ sont apparents. Sers-toi de ces informations pour dresser le tableau de signes de $f$.`;
72
+ };
73
+ const getCorrection = (identifiers) => {
74
+ const answer = getAnswerTable(identifiers);
75
+ const signs = [answer[1][2], answer[1][4], answer[1][6]];
76
+ const words = signs.map((s) => (s === "+" ? "positive" : "négative"));
77
+ const intervals = [answer[0][1], answer[0][3], answer[0][5], answer[0][7]];
78
+ return `Puisque $f$ est une fonction continue, d'après son tableau de variations, elle est ${words[0]} sur $[${intervals[0]}; ${intervals[1]}]$, puis ${words[1]} sur $[${intervals[1]}; ${intervals[2]}]$, puis ${words[2]} sur $[${intervals[2]}; ${intervals[3]}]$.`;
79
+ };
80
+ const getKeys = () => {
81
+ return ["infty"];
82
+ };
83
+ const isAnswerTableValid = (ans, { answerTable }) => {
84
+ try {
85
+ return signTableVEA(ans, answerTable);
86
+ }
87
+ catch (err) {
88
+ return handleVEAError(err);
89
+ }
90
+ };
91
+ const getSignTableFromVarTableWithZeroesQuestion = () => {
92
+ const xValues = [
93
+ randint(-12, -3),
94
+ randint(-4, 2),
95
+ randint(3, 7),
96
+ randint(8, 10),
97
+ ];
98
+ const yValues = [randint(-9, 10, [-1, 0, 1])];
99
+ // x = [a,b,c,d]
100
+ // deux zéros
101
+ const nonZeroInterval = randint(0, 3);
102
+ for (let i = 0; i < 3; i++) {
103
+ const prevY = yValues[i];
104
+ if (nonZeroInterval === i) {
105
+ if (prevY < 0) {
106
+ //on doit descendre car on remontera post 0 après
107
+ yValues.push(randint(-15, prevY));
108
+ }
109
+ else {
110
+ //on doit monter car on descendra post 0 après
111
+ yValues.push(randint(prevY, 15));
112
+ }
113
+ }
114
+ else {
115
+ yValues.push(prevY < 0 ? randint(1, 10) : randint(-10, 0));
116
+ }
117
+ }
118
+ const xZeroes = [];
119
+ for (let i = 0; i < 3; i++) {
120
+ if (nonZeroInterval === i)
121
+ continue;
122
+ xZeroes.push(randint(xValues[i] + 1, xValues[i + 1]));
123
+ }
124
+ const identifiers = {
125
+ xValues,
126
+ yValues,
127
+ xZeroes,
128
+ };
129
+ return getQuestionFromIdentifiers(identifiers);
130
+ };
131
+ const getQuestionFromIdentifiers = (identifiers) => {
132
+ return {
133
+ answerTable: getAnswerTable(identifiers),
134
+ instruction: getInstruction(identifiers),
135
+ keys: getKeys(identifiers),
136
+ answerFormat: "tex",
137
+ identifiers,
138
+ hint: getHint(identifiers),
139
+ correction: getCorrection(identifiers),
140
+ initTable: [
141
+ ["$x$", "", "\\ ", "", "\\ ", "", "\\ ", ""],
142
+ ["$f(x)$", "\\ ", "", "", "", "", "", "\\ "],
143
+ ],
144
+ };
145
+ };
146
+ export const signTableFromVarTableWithZeroes = {
147
+ id: "signTableFromVarTableWithZeroes",
148
+ label: "Dresser le tableau de signes d'une fonction à partir de son tableau de variations",
149
+ isSingleStep: true,
150
+ generator: (nb, opts) => getDistinctQuestions(() => getSignTableFromVarTableWithZeroesQuestion(opts), nb),
151
+ qcmTimer: 60,
152
+ freeTimer: 60,
153
+ isAnswerTableValid,
154
+ subject: "Mathématiques",
155
+ getInstruction,
156
+ getHint,
157
+ getCorrection,
158
+ getAnswerTable,
159
+ getQuestionFromIdentifiers,
160
+ hasHintAndCorrection: true,
161
+ answerType: "signTable",
162
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ coeffs: number[];
4
+ xValues: number[];
5
+ };
6
+ export declare const thirdDegreeZeroesFramingWithCalculator: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=thirdDegreeZeroesFramingWithCalculator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thirdDegreeZeroesFramingWithCalculator.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/continuity/thirdDegreeZeroesFramingWithCalculator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAkMF,eAAO,MAAM,sCAAsC,EAAE,QAAQ,CAAC,WAAW,CAsBxE,CAAC"}