math-exercises 3.0.180 → 3.0.182

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 (72) hide show
  1. package/lib/exercises/math/derivation/applications/index.d.ts +3 -0
  2. package/lib/exercises/math/derivation/applications/index.d.ts.map +1 -0
  3. package/lib/exercises/math/derivation/applications/index.js +2 -0
  4. package/lib/exercises/math/derivation/applications/maxBenefice.d.ts +11 -0
  5. package/lib/exercises/math/derivation/applications/maxBenefice.d.ts.map +1 -0
  6. package/lib/exercises/math/derivation/applications/maxBenefice.js +184 -0
  7. package/lib/exercises/math/derivation/applications/minimalCost.d.ts +11 -0
  8. package/lib/exercises/math/derivation/applications/minimalCost.d.ts.map +1 -0
  9. package/lib/exercises/math/derivation/applications/minimalCost.js +181 -0
  10. package/lib/exercises/math/derivation/index.d.ts +1 -0
  11. package/lib/exercises/math/derivation/index.d.ts.map +1 -1
  12. package/lib/exercises/math/derivation/index.js +1 -0
  13. package/lib/exercises/math/derivation/tangent/horizontalTangentFromAlgebraic.d.ts.map +1 -1
  14. package/lib/exercises/math/derivation/tangent/horizontalTangentFromAlgebraic.js +8 -4
  15. package/lib/exercises/math/functions/composition/functionComposition.d.ts.map +1 -1
  16. package/lib/exercises/math/functions/composition/functionComposition.js +20 -15
  17. package/lib/exercises/math/functions/exponential/algebraic/index.d.ts +0 -1
  18. package/lib/exercises/math/functions/exponential/algebraic/index.d.ts.map +1 -1
  19. package/lib/exercises/math/functions/exponential/algebraic/index.js +1 -1
  20. package/lib/exercises/math/probaStat/independancy/independancyFromEffectifTable.d.ts +10 -0
  21. package/lib/exercises/math/probaStat/independancy/independancyFromEffectifTable.d.ts.map +1 -0
  22. package/lib/exercises/math/probaStat/independancy/independancyFromEffectifTable.js +154 -0
  23. package/lib/exercises/math/probaStat/independancy/independancyFromProbaTree.d.ts +10 -0
  24. package/lib/exercises/math/probaStat/independancy/independancyFromProbaTree.d.ts.map +1 -0
  25. package/lib/exercises/math/probaStat/independancy/independancyFromProbaTree.js +152 -0
  26. package/lib/exercises/math/probaStat/independancy/index.d.ts +2 -0
  27. package/lib/exercises/math/probaStat/independancy/index.d.ts.map +1 -1
  28. package/lib/exercises/math/probaStat/independancy/index.js +2 -0
  29. package/lib/exercises/math/probaStat/trees/index.d.ts +4 -1
  30. package/lib/exercises/math/probaStat/trees/index.d.ts.map +1 -1
  31. package/lib/exercises/math/probaStat/trees/index.js +4 -8
  32. package/lib/exercises/math/probaStat/trees/probaTreeSituationTotalProbaFormula.d.ts +6 -0
  33. package/lib/exercises/math/probaStat/trees/probaTreeSituationTotalProbaFormula.d.ts.map +1 -1
  34. package/lib/exercises/math/probaStat/trees/probaTreeSituationTotalProbaFormula.js +125 -80
  35. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRecurrenceFormulaFromSituation.d.ts.map +1 -1
  36. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRecurrenceFormulaFromSituation.js +0 -4
  37. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoConsecutiveTerms.d.ts.map +1 -1
  38. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoConsecutiveTerms.js +38 -26
  39. package/lib/exercises/math/sequences/geometric/index.d.ts +0 -3
  40. package/lib/exercises/math/sequences/geometric/index.d.ts.map +1 -1
  41. package/lib/exercises/math/sequences/geometric/index.js +3 -3
  42. package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.js +1 -1
  43. package/lib/exercises/math/sequences/geometric/situations/index.d.ts +0 -1
  44. package/lib/exercises/math/sequences/geometric/situations/index.d.ts.map +1 -1
  45. package/lib/exercises/math/sequences/geometric/situations/index.js +1 -1
  46. package/lib/exercises/math/sequences/index.d.ts +1 -1
  47. package/lib/exercises/math/sequences/index.d.ts.map +1 -1
  48. package/lib/exercises/math/sequences/index.js +1 -2
  49. package/lib/exercises/math/sequences/limits/index.d.ts +2 -1
  50. package/lib/exercises/math/sequences/limits/index.d.ts.map +1 -1
  51. package/lib/exercises/math/sequences/limits/index.js +2 -2
  52. package/lib/exercises/math/sequences/limits/readSequenceConvergencyType.d.ts +9 -0
  53. package/lib/exercises/math/sequences/limits/readSequenceConvergencyType.d.ts.map +1 -0
  54. package/lib/exercises/math/sequences/limits/readSequenceConvergencyType.js +256 -0
  55. package/lib/exercises/math/sequences/limits/sequenceLimitReading.d.ts +7 -0
  56. package/lib/exercises/math/sequences/limits/sequenceLimitReading.d.ts.map +1 -1
  57. package/lib/exercises/math/sequences/limits/sequenceLimitReading.js +232 -163
  58. package/lib/exercises/math/sequences/variations/genericSequenceVariations.d.ts +7 -0
  59. package/lib/exercises/math/sequences/variations/genericSequenceVariations.d.ts.map +1 -0
  60. package/lib/exercises/math/sequences/variations/genericSequenceVariations.js +122 -0
  61. package/lib/exercises/math/sequences/variations/index.d.ts +2 -0
  62. package/lib/exercises/math/sequences/variations/index.d.ts.map +1 -1
  63. package/lib/exercises/math/sequences/variations/index.js +2 -0
  64. package/lib/exercises/math/sequences/variations/sequenceVariationFromTermsDifference.d.ts +9 -0
  65. package/lib/exercises/math/sequences/variations/sequenceVariationFromTermsDifference.d.ts.map +1 -0
  66. package/lib/exercises/math/sequences/variations/sequenceVariationFromTermsDifference.js +155 -0
  67. package/lib/index.d.ts +47 -39
  68. package/lib/index.d.ts.map +1 -1
  69. package/lib/tests/singleExo.test.js +2 -2
  70. package/lib/tree/parsers/rationalParser.d.ts.map +1 -1
  71. package/lib/tree/parsers/rationalParser.js +7 -1
  72. package/package.json +1 -1
@@ -1,163 +1,232 @@
1
- // import {
2
- // Exercise,
3
- // Proposition,
4
- // QCMGenerator,
5
- // QuestionGenerator,
6
- // VEA,
7
- // addValidProp,
8
- // shuffleProps,
9
- // GetAnswer,
10
- // GetHint,
11
- // GetCorrection,
12
- // GetInstruction,
13
- // GetKeys,
14
- // GetGGBOptions,
15
- // GetQuestionFromIdentifiers,
16
- // propWhile,
17
- // tryToAddWrongProp,
18
- // } from "../../../../exercises/exercise.js";
19
- // import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
20
- // import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
21
- // import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
22
- // import { Point } from "../../../../math/geometry/point.js";
23
- // import { AffineConstructor } from "../../../../math/polynomials/affine.js";
24
- // import { randint } from "../../../../math/utils/random/randint.js";
25
- // import {
26
- // NodeIdentifiers,
27
- // reifyAlgebraic,
28
- // } from "../../../../tree/nodes/nodeConstructor.js";
29
- // import { add } from "../../../../tree/nodes/operators/addNode.js";
30
- // import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
31
- // import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
32
- export {};
33
- // type Identifiers = {
34
- // formula: NodeIdentifiers;
35
- // type: number;
36
- // };
37
- // const getPropositions: QCMGenerator<Identifiers> = (n, { answer }) => {
38
- // const propositions: Proposition[] = [];
39
- // addValidProp(propositions, answer);
40
- // tryToAddWrongProp(propositions, "\\text{Aucun}");
41
- // propWhile(propositions, n, () => {
42
- // throw Error("QCM not implemented");
43
- // });
44
- // return shuffleProps(propositions, n);
45
- // };
46
- // const getAnswer: GetAnswer<Identifiers> = (identifiers) => {
47
- // const { formula, type } = identifiers;
48
- // const u = reifyAlgebraic(formula);
49
- // switch (type) {
50
- // case 0:
51
- // default: {
52
- // const value = u.toDetailedEvaluation({ n: (100).toTree() }).evaluate();
53
- // if (value > 0) return "+\\infty";
54
- // return "-\\infty";
55
- // }
56
- // }
57
- // };
58
- // const getInstruction: GetInstruction<Identifiers> = () => {
59
- // return `Ci-dessous est tracé le nuage de points représentant une suite $u$.
60
- // Quelle semble être la limite de la suite $u$ quand $n$ tend vers $+\\infty$ ? Si elle n'en a pas, on écrira "Aucun".`;
61
- // };
62
- // const getHint: GetHint<Identifiers> = () => {
63
- // return `Observe les termes de la suite lorsque $n$ devient très grand. Si ces termes semblent se rapprocher d'une certaine valeur, alors on peut conjecturer que cette valeur est la limite de la suite. Cette valeur peut être $+\\infty$ ou $-\\infty$.`;
64
- // };
65
- // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {
66
- // return ``;
67
- // };
68
- // const getGGBOptions: GetGGBOptions<Identifiers> = (identifiers) => {
69
- // const { formula } = identifiers;
70
- // const u = reifyAlgebraic(formula);
71
- // const values = Array.from({ length: 50 }).map((_, index) => {
72
- // return u.toDetailedEvaluation({ n: index.toTree() }).evaluate();
73
- // });
74
- // const points = values.map((v, i) => new Point(`A_{${i}}`, i, v));
75
- // const ggb = new GeogebraConstructor({
76
- // commands: points.flatMap((e) =>
77
- // e.toGGBCommand({
78
- // showLabel: false,
79
- // size: 3,
80
- // }),
81
- // ),
82
- // lockedAxesRatio: false,
83
- // });
84
- // const yMin = Math.min(-1, Math.min(...values.slice(0, 10))) - 2;
85
- // const yMax = Math.max(1, Math.max(...values.slice(0, 10))) + 2;
86
- // return ggb.getOptions({
87
- // coords: [-1, 10, yMin, yMax],
88
- // });
89
- // };
90
- // const getKeys: GetKeys<Identifiers> = () => {
91
- // return ["aucun"];
92
- // };
93
- // const isAnswerValid: VEA<Identifiers> = (ans, { answer }) => {
94
- // try {
95
- // if (answer.includes("\\infty")) return ans === answer;
96
- // return numberVEA(ans, answer, undefined, 0.3);
97
- // } catch (err) {
98
- // return handleVEAError(err);
99
- // }
100
- // };
101
- // const getSequenceLimitReadingQuestion: QuestionGenerator<Identifiers> = () => {
102
- // const type = randint(10);
103
- // let formula: NodeIdentifiers;
104
- // switch (type) {
105
- // case 0:
106
- // formula = AffineConstructor.random(undefined, undefined, "n")
107
- // .toTree()
108
- // .toIdentifiers();
109
- // break;
110
- // case 1:
111
- // default:
112
- // {
113
- // const k = randint(-10, 10);
114
- // formula = add(frac(1, add("n", 1)), k).toIdentifiers();
115
- // }
116
- // break;
117
- // }
118
- // const identifiers: Identifiers = {
119
- // formula,
120
- // type,
121
- // };
122
- // //0: affine
123
- // //1: 1/n+k
124
- // //2: an+b/cn+d
125
- // //3: exp
126
- // //4:
127
- // //styles:
128
- // //exp, lineaire, alternée, exp décroissant, anarchique
129
- // return getQuestionFromIdentifiers(identifiers);
130
- // };
131
- // const getQuestionFromIdentifiers: GetQuestionFromIdentifiers<Identifiers> = (
132
- // identifiers,
133
- // ) => {
134
- // return {
135
- // answer: getAnswer(identifiers),
136
- // instruction: getInstruction(identifiers),
137
- // keys: getKeys(identifiers),
138
- // answerFormat: "tex",
139
- // identifiers,
140
- // hint: getHint(identifiers),
141
- // correction: getCorrection(identifiers),
142
- // ggbOptions: getGGBOptions(identifiers),
143
- // };
144
- // };
145
- // export const sequenceLimitReading: Exercise<Identifiers> = {
146
- // id: "sequenceLimitReading",
147
- // label: "Conjecturer graphiquement la limite d'une suite",
148
- // isSingleStep: true,
149
- // generator: (nb, opts) =>
150
- // getDistinctQuestions(() => getSequenceLimitReadingQuestion(opts), nb),
151
- // qcmTimer: 60,
152
- // freeTimer: 60,
153
- // getPropositions,
154
- // isAnswerValid,
155
- // subject: "Mathématiques",
156
- // getHint,
157
- // getCorrection,
158
- // getInstruction,
159
- // getAnswer,
160
- // getGGBOptions,
161
- // hasGeogebra: true,
162
- // getQuestionFromIdentifiers,
163
- // };
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, propWhile, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
4
+ import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
5
+ import { Point } from "../../../../math/geometry/point.js";
6
+ import { AffineConstructor } from "../../../../math/polynomials/affine.js";
7
+ import { TrinomConstructor } from "../../../../math/polynomials/trinom.js";
8
+ import { randfloat } from "../../../../math/utils/random/randfloat.js";
9
+ import { randint } from "../../../../math/utils/random/randint.js";
10
+ import { round } from "../../../../math/utils/round.js";
11
+ import { exp } from "../../../../tree/nodes/functions/expNode.js";
12
+ import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
13
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
14
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
15
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
16
+ import { power } from "../../../../tree/nodes/operators/powerNode.js";
17
+ import { doWhile } from "../../../../utils/doWhile.js";
18
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
19
+ const getPropositions = (n, { answer }) => {
20
+ const propositions = [];
21
+ addValidProp(propositions, answer);
22
+ tryToAddWrongProp(propositions, "+\\infty");
23
+ tryToAddWrongProp(propositions, "-\\infty");
24
+ propWhile(propositions, n, () => {
25
+ tryToAddWrongProp(propositions, randint(-10, 10) + "");
26
+ });
27
+ return shuffleProps(propositions, n);
28
+ };
29
+ const getAnswer = (identifiers) => {
30
+ return getLimit(identifiers);
31
+ };
32
+ const getInstruction = () => {
33
+ return `On considère une suite $u$ représentée graphiquement ci-dessous.
34
+
35
+ Quelle semble être la limite de la suite $u$ lorsque $n$ tend vers $+\\infty$ ?`;
36
+ };
37
+ const getHint = () => {
38
+ return `Observe les termes de la suite lorsque $n$ devient très grand.
39
+
40
+ Si ces termes semblent se rapprocher autant que l'on veut d'une certaine valeur, alors on peut conjecturer que la suite admet une limite finie.
41
+
42
+ Si ces termes semblent devenir aussi grands ou aussi petits que l'on veut, alors on peut conjecturer que la suite admet une limite infinie.
43
+
44
+ Sinon, on peut conjecturer que la suite n'a pas de limite.`;
45
+ };
46
+ const getLimit = (identifiers) => {
47
+ const { formulaIds, type } = identifiers;
48
+ const formula = reifyAlgebraic(formulaIds);
49
+ switch (type) {
50
+ case 0:
51
+ return round(formula.toDetailedEvaluation({ n: (10).toTree() }).evaluate(), 0).frenchify();
52
+ case 1:
53
+ default: {
54
+ const pos = formula.toDetailedEvaluation({ n: (10).toTree() }).evaluate() > 0;
55
+ return pos ? "+\\infty" : "-\\infty";
56
+ }
57
+ }
58
+ };
59
+ const getCorrection = (identifiers) => {
60
+ const { type } = identifiers;
61
+ const limit = getLimit(identifiers);
62
+ let corr = `On observe les termes de la suite lorsque $n$ devient très grand : c'est à dire qu'on observe les ordonnées des points qui ont une abscisse très grande.
63
+
64
+ `;
65
+ switch (type) {
66
+ case 0:
67
+ corr += `Les termes semblent se rapprocher autant que l'on veut de $${limit}$. On peut donc conjecturer que la suite $u$ a une limite finie :
68
+
69
+ $$
70
+ \\lim_{n \\to +\\infty} u_{n} = ${limit}
71
+ $$`;
72
+ break;
73
+ case 1:
74
+ corr += `Les termes semblent devenir aussi ${limit === "+\\infty" ? "grands" : "petits"} que l'on veut. On peut donc conjecturer que la suite $u$ a une limite infinie :
75
+
76
+ $$
77
+ \\lim_{n \\to +\\infty} u_{n} = ${limit}
78
+ $$`;
79
+ break;
80
+ }
81
+ return corr;
82
+ };
83
+ const getGGBOptions = (identifiers) => {
84
+ const { formulaIds } = identifiers;
85
+ const formula = reifyAlgebraic(formulaIds);
86
+ console.log(formula.toTex());
87
+ const points = Array.from({ length: 50 }).map((_, index) => {
88
+ return new Point(`A_{${index}}`, index, formula.toDetailedEvaluation({ n: index.toTree() }).evaluate());
89
+ });
90
+ const yMin = Math.min(Math.min(...points.slice(0, 10).map((p) => p.y.evaluate())) - 2, -2);
91
+ const yMax = Math.max(Math.max(...points.slice(0, 10).map((p) => p.y.evaluate())) + 2, 2);
92
+ const ggb = new GeogebraConstructor({
93
+ commands: points.flatMap((point) => point.toGGBCommand({
94
+ showLabel: false,
95
+ isFixed: true,
96
+ isSelectionnable: false,
97
+ size: 3,
98
+ })),
99
+ lockedAxesRatio: false,
100
+ gridDistance: false,
101
+ });
102
+ return ggb.getOptions({
103
+ coords: [-1, 15, yMin, yMax],
104
+ });
105
+ };
106
+ const getReadSequenceConvergencyTypeQuestion = () => {
107
+ const type = randint(0, 2);
108
+ //type0 limites finies :
109
+ //1/n+k , an+b/cn+d, q^n avec q<1, exp(-kx)
110
+ //type1 limites infinie :
111
+ //affine, trinom, q^n avec q>1, exp(kx)
112
+ //
113
+ let formulaIds;
114
+ switch (type) {
115
+ case 0: {
116
+ const subtype = randint(0, 4);
117
+ switch (subtype) {
118
+ case 0: {
119
+ //1/(n+1)+k
120
+ const k = randint(-5, 5);
121
+ formulaIds = add(frac(1, add("n", 1)), k).toIdentifiers();
122
+ break;
123
+ }
124
+ case 1: {
125
+ //an+b/cn+d
126
+ const c = randint(-5, 5, [0]);
127
+ const a = c * randint(-5, 5, [0]);
128
+ const b = randint(-5, 5, [0]);
129
+ const d = doWhile(() => randint(-5, 5, [0]), (x) => c / a === x / b || (Math.floor(-x / c) === -x / c && -x / c > 0));
130
+ formulaIds = frac(add(multiply(a, "n"), b), add(multiply(c, "n"), d)).toIdentifiers();
131
+ break;
132
+ }
133
+ case 2: {
134
+ //aq^n q<1
135
+ const q = randfloat(0.1, 0.9, 2);
136
+ const a = randint(-5, 5, [0]);
137
+ formulaIds = multiply(a, power(q, "n")).toIdentifiers();
138
+ break;
139
+ }
140
+ case 3:
141
+ default: {
142
+ //aexp(-kx)
143
+ const k = randfloat(0.1, 0.9, 2);
144
+ const a = randint(-5, 5, [0]);
145
+ formulaIds = multiply(a, exp(multiply(-k, "n"))).toIdentifiers();
146
+ break;
147
+ }
148
+ }
149
+ break;
150
+ }
151
+ case 1:
152
+ default: {
153
+ const subtype = randint(0, 4);
154
+ switch (subtype) {
155
+ case 0: {
156
+ //affine
157
+ const affine = AffineConstructor.random(undefined, undefined, "n").toTree();
158
+ formulaIds = affine.toIdentifiers();
159
+ break;
160
+ }
161
+ case 1: {
162
+ //trinom
163
+ const trinom = TrinomConstructor.random(undefined, undefined, undefined, "n").toTree();
164
+ formulaIds = trinom.toIdentifiers();
165
+ break;
166
+ }
167
+ case 2: {
168
+ //q^n
169
+ const q = randfloat(1.1, 1.4, 2);
170
+ const a = randint(-5, 5, [0]);
171
+ formulaIds = multiply(a, power(q, "n")).toIdentifiers();
172
+ break;
173
+ }
174
+ case 3:
175
+ default: {
176
+ //aexp(kx)
177
+ const k = randfloat(1.1, 1.4, 2);
178
+ const a = randint(-5, 5, [0]);
179
+ formulaIds = multiply(a, exp(multiply(k, "n"))).toIdentifiers();
180
+ break;
181
+ }
182
+ }
183
+ break;
184
+ }
185
+ }
186
+ const identifiers = {
187
+ type,
188
+ formulaIds,
189
+ };
190
+ return getQuestionFromIdentifiers(identifiers);
191
+ };
192
+ const getQuestionFromIdentifiers = (identifiers) => {
193
+ return {
194
+ answer: getAnswer(identifiers),
195
+ instruction: getInstruction(identifiers),
196
+ keys: ["infty"],
197
+ answerFormat: "tex",
198
+ identifiers,
199
+ hint: getHint(identifiers),
200
+ correction: getCorrection(identifiers),
201
+ ggbOptions: getGGBOptions(identifiers),
202
+ };
203
+ };
204
+ const isAnswerValid = (ans, { answer }) => {
205
+ try {
206
+ if (answer.includes("\\infty"))
207
+ return ans === answer;
208
+ return numberVEA(ans, answer);
209
+ }
210
+ catch (err) {
211
+ return handleVEAError(err);
212
+ }
213
+ };
214
+ export const sequenceLimitReading = {
215
+ id: "sequenceLimitReading",
216
+ label: "Conjecturer graphiquement la limite d'une suite",
217
+ isSingleStep: true,
218
+ generator: (nb, opts) => getDistinctQuestions(() => getReadSequenceConvergencyTypeQuestion(opts), nb),
219
+ qcmTimer: 60,
220
+ freeTimer: 60,
221
+ getPropositions,
222
+ subject: "Mathématiques",
223
+ getHint,
224
+ getCorrection,
225
+ getInstruction,
226
+ getAnswer,
227
+ getGGBOptions,
228
+ hasGeogebra: true,
229
+ getQuestionFromIdentifiers,
230
+ isAnswerValid,
231
+ hasHintAndCorrection: true,
232
+ };
@@ -0,0 +1,7 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ coeffs: number[];
4
+ };
5
+ export declare const genericSequenceVariations: Exercise<Identifiers>;
6
+ export {};
7
+ //# sourceMappingURL=genericSequenceVariations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genericSequenceVariations.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/variations/genericSequenceVariations.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AA0HF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAe3D,CAAC"}
@@ -0,0 +1,122 @@
1
+ import { shuffleProps, tryToAddWrongProp, addValidProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { Affine } from "../../../../math/polynomials/affine.js";
4
+ import { Polynomial, PolynomialConstructor, } from "../../../../math/polynomials/polynomial.js";
5
+ import { randint } from "../../../../math/utils/random/randint.js";
6
+ import { firstDegreeInequationResolutionTex } from "../../../../tree/nodes/inequations/inequationNode.js";
7
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
8
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
9
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
10
+ const getInstruction = (identifiers) => {
11
+ const { coeffs } = identifiers;
12
+ const u = new Polynomial(coeffs, "n");
13
+ return `Soit $u$ la suite définie par :
14
+
15
+ $$
16
+ u_n = ${u.toTree().toTex()}
17
+ $$
18
+
19
+ En étudiant le signe de $u_{n+1}-u_n$, déterminer le sens de variations de $u$.`;
20
+ };
21
+ const getAnswer = (identifiers) => {
22
+ const { coeffs } = identifiers;
23
+ const u = new Polynomial(coeffs, "n");
24
+ const [b, a] = u.coefficients.slice(1);
25
+ const root = Math.ceil((-a - b) / (2 * a));
26
+ const answer = root <= 0
27
+ ? a > 0
28
+ ? "Croissante"
29
+ : "Décroissante"
30
+ : `${a > 0 ? "Croissante" : "Décroissante"} à partir du rang $${root}$`;
31
+ return answer;
32
+ };
33
+ const getHint = () => {
34
+ return `Exprime $u_{n+1}$ en fonction de $n$, puis calcule $u_{n+1}-u_n$.
35
+
36
+ Ensuite, étudie le signe de ce résultat. Sur les intervalles où il est positif, la suite est croissante. Sur ceux où il est négatif, la suite est décroissante.`;
37
+ };
38
+ const getCorrection = (identifiers) => {
39
+ const { coeffs } = identifiers;
40
+ const u = new Polynomial(coeffs, "n").toTree();
41
+ const unP1 = u.toDetailedEvaluation({ n: add("n", 1) });
42
+ const unP1Simp = unP1.simplify({
43
+ towardsDistribute: true,
44
+ forbidFactorize: true,
45
+ });
46
+ const diff = substract(unP1Simp, u).simplify({
47
+ towardsDistribute: true,
48
+ forbidFactorize: true,
49
+ });
50
+ const b = diff
51
+ .toDetailedEvaluation({ n: (0).toTree() })
52
+ .simplify()
53
+ .evaluate();
54
+ const a = substract(diff.toDetailedEvaluation({ n: (1).toTree() }), b)
55
+ .simplify()
56
+ .evaluate();
57
+ const aff = new Affine(a, b, "n");
58
+ return `On exprime $u_{n+1}$ :
59
+
60
+ ${alignTex([
61
+ ["u_{n+1}", "=", unP1.toTex()],
62
+ ["", "=", unP1Simp.toTex()],
63
+ ])}
64
+
65
+ On a donc pour tout entier $n$ :
66
+
67
+ $$
68
+ u_{n+1}-u_n = ${diff.toTex()}
69
+ $$
70
+
71
+ On étudie le signe de $${diff.toTex()}$ :
72
+
73
+ $$
74
+ ${firstDegreeInequationResolutionTex(aff, "\\ge", (0).toTree())}
75
+ $$
76
+
77
+ On en conclut que $u$ est ${getAnswer(identifiers).toLocaleLowerCase()}.
78
+ `;
79
+ };
80
+ const getQuestionFromIdentifiers = (identifiers) => {
81
+ const question = {
82
+ answer: getAnswer(identifiers),
83
+ instruction: getInstruction(identifiers),
84
+ keys: [],
85
+ answerFormat: "raw",
86
+ identifiers,
87
+ hint: getHint(identifiers),
88
+ correction: getCorrection(identifiers),
89
+ };
90
+ return question;
91
+ };
92
+ const getGenericSequenceVariationsQuestion = () => {
93
+ const u = PolynomialConstructor.randomWithOrder(2, "n");
94
+ const identifiers = { coeffs: u.coefficients };
95
+ return getQuestionFromIdentifiers(identifiers);
96
+ };
97
+ const getPropositions = (n, { answer, coeffs }) => {
98
+ const [b, a] = coeffs.slice(1);
99
+ const root = Math.ceil((-a - b) / (2 * a));
100
+ const propositions = [];
101
+ addValidProp(propositions, answer, "raw");
102
+ tryToAddWrongProp(propositions, "Croissante", "raw");
103
+ tryToAddWrongProp(propositions, "Décroissante", "raw");
104
+ const fakeRoot = root <= 0 ? randint(1, 10) : root;
105
+ tryToAddWrongProp(propositions, `Croissante à partir du rang $${fakeRoot}$`, "raw");
106
+ tryToAddWrongProp(propositions, `Décroissante à partir du rang $${fakeRoot}$`, "raw");
107
+ return shuffleProps(propositions, n);
108
+ };
109
+ export const genericSequenceVariations = {
110
+ id: "genericSequenceVariations",
111
+ connector: "=",
112
+ label: "Déterminer le sens de variations d'une suite en étudiant la différence de deux termes",
113
+ isSingleStep: true,
114
+ generator: (nb) => getDistinctQuestions(getGenericSequenceVariationsQuestion, nb),
115
+ qcmTimer: 60,
116
+ freeTimer: 60,
117
+ answerType: "QCU",
118
+ getPropositions,
119
+ subject: "Mathématiques",
120
+ getQuestionFromIdentifiers,
121
+ hasHintAndCorrection: true,
122
+ };
@@ -1,2 +1,4 @@
1
1
  export * from "./expressConsecutiveTermsDifference.js";
2
+ export * from "./sequenceVariationFromTermsDifference.js";
3
+ export * from "./genericSequenceVariations.js";
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/variations/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/variations/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC;AACvD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,gCAAgC,CAAC"}
@@ -1 +1,3 @@
1
1
  export * from "./expressConsecutiveTermsDifference.js";
2
+ export * from "./sequenceVariationFromTermsDifference.js";
3
+ export * from "./genericSequenceVariations.js";
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ diffIdentifiers: NodeIdentifiers;
5
+ type: number;
6
+ };
7
+ export declare const sequenceVariationFromTermsDifference: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=sequenceVariationFromTermsDifference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sequenceVariationFromTermsDifference.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/variations/sequenceVariationFromTermsDifference.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAK7C,KAAK,WAAW,GAAG;IACjB,eAAe,EAAE,eAAe,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;CAEd,CAAC;AAmJF,eAAO,MAAM,oCAAoC,EAAE,QAAQ,CAAC,WAAW,CAqBtE,CAAC"}