math-exercises 3.0.190 → 3.0.191

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 (76) hide show
  1. package/lib/exercises/math/dataRepresentations/scatterPlot/index.d.ts +6 -0
  2. package/lib/exercises/math/dataRepresentations/scatterPlot/index.d.ts.map +1 -0
  3. package/lib/exercises/math/dataRepresentations/scatterPlot/index.js +5 -0
  4. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotBuildScatterPlotFromDataTable.d.ts +12 -0
  5. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotBuildScatterPlotFromDataTable.d.ts.map +1 -0
  6. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotBuildScatterPlotFromDataTable.js +206 -0
  7. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotCommenting.d.ts +9 -0
  8. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotCommenting.d.ts.map +1 -0
  9. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotCommenting.js +210 -0
  10. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableFromScatterPlotData.d.ts +10 -0
  11. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableFromScatterPlotData.d.ts.map +1 -0
  12. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableFromScatterPlotData.js +252 -0
  13. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableWithDataClassesFromScatterPlotData.d.ts +12 -0
  14. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableWithDataClassesFromScatterPlotData.d.ts.map +1 -0
  15. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableWithDataClassesFromScatterPlotData.js +352 -0
  16. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotInterpreting.d.ts +11 -0
  17. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotInterpreting.d.ts.map +1 -0
  18. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotInterpreting.js +403 -0
  19. package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.js +1 -1
  20. package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.d.ts.map +1 -1
  21. package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.js +4 -1
  22. package/lib/exercises/math/functions/affines/affineCompareTwoImagesFromVariations.d.ts +13 -0
  23. package/lib/exercises/math/functions/affines/affineCompareTwoImagesFromVariations.d.ts.map +1 -0
  24. package/lib/exercises/math/functions/affines/affineCompareTwoImagesFromVariations.js +205 -0
  25. package/lib/exercises/math/functions/affines/affineVarTableOnBoundedInterval.d.ts +9 -0
  26. package/lib/exercises/math/functions/affines/affineVarTableOnBoundedInterval.d.ts.map +1 -0
  27. package/lib/exercises/math/functions/affines/affineVarTableOnBoundedInterval.js +157 -0
  28. package/lib/exercises/math/functions/affines/affineVariations.d.ts +12 -0
  29. package/lib/exercises/math/functions/affines/affineVariations.d.ts.map +1 -0
  30. package/lib/exercises/math/functions/affines/affineVariations.js +176 -0
  31. package/lib/exercises/math/functions/affines/affineVariationsFromGraph.d.ts +8 -0
  32. package/lib/exercises/math/functions/affines/affineVariationsFromGraph.d.ts.map +1 -0
  33. package/lib/exercises/math/functions/affines/affineVariationsFromGraph.js +203 -0
  34. package/lib/exercises/math/functions/affines/affineVariationsFromTwoImages.d.ts +12 -0
  35. package/lib/exercises/math/functions/affines/affineVariationsFromTwoImages.d.ts.map +1 -0
  36. package/lib/exercises/math/functions/affines/affineVariationsFromTwoImages.js +259 -0
  37. package/lib/exercises/math/functions/exponentials/exponentialFunctionImage.d.ts +9 -0
  38. package/lib/exercises/math/functions/exponentials/exponentialFunctionImage.d.ts.map +1 -0
  39. package/lib/exercises/math/functions/exponentials/exponentialFunctionImage.js +99 -0
  40. package/lib/exercises/math/functions/exponentials/index.d.ts +5 -0
  41. package/lib/exercises/math/functions/exponentials/index.d.ts.map +1 -1
  42. package/lib/exercises/math/functions/exponentials/index.js +5 -0
  43. package/lib/exercises/math/functions/exponentials/realPowersFraction.d.ts +10 -0
  44. package/lib/exercises/math/functions/exponentials/realPowersFraction.d.ts.map +1 -0
  45. package/lib/exercises/math/functions/exponentials/realPowersFraction.js +125 -0
  46. package/lib/exercises/math/functions/exponentials/realPowersMixOperations.d.ts +12 -0
  47. package/lib/exercises/math/functions/exponentials/realPowersMixOperations.d.ts.map +1 -0
  48. package/lib/exercises/math/functions/exponentials/realPowersMixOperations.js +148 -0
  49. package/lib/exercises/math/functions/exponentials/realPowersPower.d.ts +10 -0
  50. package/lib/exercises/math/functions/exponentials/realPowersPower.d.ts.map +1 -0
  51. package/lib/exercises/math/functions/exponentials/realPowersPower.js +128 -0
  52. package/lib/exercises/math/functions/exponentials/realPowersProduct.d.ts +10 -0
  53. package/lib/exercises/math/functions/exponentials/realPowersProduct.d.ts.map +1 -0
  54. package/lib/exercises/math/functions/exponentials/realPowersProduct.js +128 -0
  55. package/lib/exercises/math/sequences/geometric/geometricFindNextTermFromTwoConsecutiveTerms.d.ts +12 -0
  56. package/lib/exercises/math/sequences/geometric/geometricFindNextTermFromTwoConsecutiveTerms.d.ts.map +1 -0
  57. package/lib/exercises/math/sequences/geometric/geometricFindNextTermFromTwoConsecutiveTerms.js +217 -0
  58. package/lib/exercises/math/sequences/geometric/geometricFindRecurrenceFormula.d.ts +10 -0
  59. package/lib/exercises/math/sequences/geometric/geometricFindRecurrenceFormula.d.ts.map +1 -0
  60. package/lib/exercises/math/sequences/geometric/geometricFindRecurrenceFormula.js +186 -0
  61. package/lib/exercises/math/sequences/geometric/graph/geometricPlaceFirstPoints.d.ts +14 -0
  62. package/lib/exercises/math/sequences/geometric/graph/geometricPlaceFirstPoints.d.ts.map +1 -0
  63. package/lib/exercises/math/sequences/geometric/graph/geometricPlaceFirstPoints.js +189 -0
  64. package/lib/exercises/math/sequences/geometric/graph/index.d.ts +2 -0
  65. package/lib/exercises/math/sequences/geometric/graph/index.d.ts.map +1 -0
  66. package/lib/exercises/math/sequences/geometric/graph/index.js +1 -0
  67. package/lib/index.d.ts +21 -0
  68. package/lib/index.d.ts.map +1 -1
  69. package/lib/tree/nodes/algebraicNode.d.ts +3 -0
  70. package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
  71. package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
  72. package/lib/tree/nodes/operators/fractionNode.js +5 -3
  73. package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
  74. package/lib/tree/nodes/operators/multiplyNode.js +5 -3
  75. package/lib/tree/nodes/operators/powerNode.js +1 -1
  76. package/package.json +1 -1
@@ -0,0 +1,157 @@
1
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
2
+ import { varTableVEA } from "../../../../exercises/vea/varTableVEA.js";
3
+ import { AffineConstructor } from "../../../../math/polynomials/affine.js";
4
+ import { nodeBySubstitutingVar } from "../../../../math/utils/functions/functionComposition.js";
5
+ import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
6
+ import { randomMany } from "../../../../utils/alea/random.js";
7
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
8
+ const getInstruction = (identifiers) => {
9
+ const { nodeIdsBounds, nodeIdsF } = identifiers;
10
+ const [nodeX1, nodeX2] = nodeIdsBounds.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
11
+ const nodeF = NodeConstructor.fromIdentifiers(nodeIdsF);
12
+ const strInterval = `[${nodeX1.toTex()};${nodeX2.toTex()}]`;
13
+ return `Dresser le tableau de variations de la fonction $f$ sur l'intervalle $${strInterval}$.
14
+
15
+ On donne, pour tout $x$ dans $${strInterval}$ :
16
+
17
+ $$
18
+ f(x) = ${nodeF.toTex()}
19
+ $$
20
+
21
+ `;
22
+ };
23
+ const getAnswerTable = (identifiers) => {
24
+ const { nodeIdsBounds, nodeIdsF } = identifiers;
25
+ const [nodeX1, nodeX2] = nodeIdsBounds.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
26
+ const nodeF = NodeConstructor.fromIdentifiers(nodeIdsF);
27
+ const [nodeImage1, nodeImage2] = [nodeX1, nodeX2].map((nodeX) => nodeBySubstitutingVar(nodeF, nodeX, "x".toTree()));
28
+ if (nodeImage1.evaluate() < nodeImage2.evaluate()) {
29
+ return [
30
+ ["$x$", nodeX1.toTex(), "\\ ", nodeX2.toTex()],
31
+ [
32
+ "$\\ $",
33
+ "\\ ",
34
+ "\\ ",
35
+ nodeImage2.simplify({ towardsDistribute: true }).toTex(),
36
+ ],
37
+ ["$f(x)$", "\\ ", "\\nearrow", "\\ "],
38
+ [
39
+ "$\\ $",
40
+ nodeImage1.simplify({ towardsDistribute: true }).toTex(),
41
+ "\\ ",
42
+ "\\ ",
43
+ ],
44
+ ];
45
+ }
46
+ else {
47
+ return [
48
+ ["$x$", nodeX1.toTex(), "\\ ", nodeX2.toTex()],
49
+ [
50
+ "$\\ $",
51
+ nodeImage1.simplify({ towardsDistribute: true }).toTex(),
52
+ "\\ ",
53
+ "\\ ",
54
+ ],
55
+ ["$f(x)$", "\\ ", "\\searrow", "\\ "],
56
+ [
57
+ "$\\ $",
58
+ "\\ ",
59
+ "\\ ",
60
+ nodeImage2.simplify({ towardsDistribute: true }).toTex(),
61
+ ],
62
+ ];
63
+ }
64
+ };
65
+ const getHint = () => {
66
+ return `Inscris les bornes de l'intervalle sur la ligne "$x$".
67
+ Détermine le signe du coefficient directeur de la fonction $f$.
68
+ S'il est strictement positif, $f$ est strictement croissante sur $\\mathbb{R}$.
69
+ S'il est strictement négatif, $f$ est strictement décroissante sur $\\mathbb{R}$.
70
+ Tu peux donc choisir le sens de la flèche sur la ligne "$f(x)$" et monter ou descendre chaque boîte de saisie pour correspondre au sens de la flêche.
71
+ Ensuite, calcule l'image correspondant à chaque borne de l'intervalle pour terminer de remplir le tableau.
72
+ `;
73
+ };
74
+ const getCorrection = (identifiers) => {
75
+ const { nodeIdsBounds, nodeIdsF } = identifiers;
76
+ const [nodeX1, nodeX2] = nodeIdsBounds.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
77
+ const nodeF = NodeConstructor.fromIdentifiers(nodeIdsF);
78
+ const nodeSlope = nodeF.derivative().simplify({ towardsDistribute: true });
79
+ const strInterval = `[${nodeX1.toTex()};${nodeX2.toTex()}]`;
80
+ const [nodeImage1, nodeImage2] = [nodeX1, nodeX2].map((nodeX) => nodeBySubstitutingVar(nodeF, nodeX, "x".toTree()));
81
+ const a = nodeSlope.evaluate();
82
+ return `On inscrit les bornes de $${strInterval}$ sur la ligne "$x$".
83
+ D'après l'expression de $f(x)$, le coefficient directeur de la fonction $f$ est $${nodeSlope.toTex()}$.
84
+ $f$ est donc ${a > 0 ? "strictement croissante" : "strictement décroissante"} sur $\\mathbb{R}$ et a fortiori sur l'intervalle $${strInterval}$.
85
+ On peut donc sélectionner le sens de la flèche (${a > 0 ? "vers le haut" : "vers le bas"}) et positionner les boîtes de saisie des images.
86
+ On calcule enfin l'image de chaque borne de l'intervalle :
87
+
88
+ $$
89
+ f(${nodeX1.toTex()}) = ${nodeImage1.toTex()} = ${nodeImage1
90
+ .simplify({ towardsDistribute: true })
91
+ .toTex()}
92
+ $$
93
+
94
+ $$
95
+ f(${nodeX2.toTex()}) = ${nodeImage2.toTex()} = ${nodeImage2
96
+ .simplify({ towardsDistribute: true })
97
+ .toTex()}
98
+ $$
99
+
100
+ `;
101
+ };
102
+ const getKeys = () => {
103
+ return [];
104
+ };
105
+ const isAnswerTableValid = (ans, { answerTable }) => {
106
+ try {
107
+ return varTableVEA(ans, answerTable);
108
+ }
109
+ catch (err) {
110
+ return handleVEAError(err);
111
+ }
112
+ };
113
+ const getAffineVarTableOnBoundedIntervalQuestion = () => {
114
+ const [nodeX1, nodeX2] = randomMany([...Array(21).keys()].map((i) => i - 10), 2)
115
+ .toSorted((v1, v2) => v1 - v2)
116
+ .map((v) => v.toTree());
117
+ const nodeF = AffineConstructor.random({ excludes: [0] }, { excludes: [0] }).toTree();
118
+ const identifiers = {
119
+ nodeIdsBounds: [nodeX1, nodeX2].map((nodeX) => nodeX.toIdentifiers()),
120
+ nodeIdsF: nodeF.toIdentifiers(),
121
+ };
122
+ return getQuestionFromIdentifiers(identifiers);
123
+ };
124
+ const getQuestionFromIdentifiers = (identifiers) => {
125
+ return {
126
+ answerTable: getAnswerTable(identifiers),
127
+ instruction: getInstruction(identifiers),
128
+ keys: getKeys(identifiers),
129
+ answerFormat: "tex",
130
+ identifiers,
131
+ hint: getHint(identifiers),
132
+ correction: getCorrection(identifiers),
133
+ initTable: [
134
+ ["$x$", "", "\\ ", ""],
135
+ ["$\\ $", "\\ ", "\\ ", "\\ "],
136
+ ["$f(x)$", "", "", ""],
137
+ ["$\\ $", "\\ ", "\\ ", "\\ "],
138
+ ],
139
+ };
140
+ };
141
+ export const affineVarTableOnBoundedInterval = {
142
+ id: "affineVarTableOnBoundedInterval",
143
+ label: "Dresser le tableau de variations d'une fonction affine sur un intervalle borné",
144
+ isSingleStep: true,
145
+ generator: (nb, opts) => getDistinctQuestions(() => getAffineVarTableOnBoundedIntervalQuestion(opts), nb),
146
+ qcmTimer: 60,
147
+ freeTimer: 60,
148
+ subject: "Mathématiques",
149
+ getInstruction,
150
+ getHint,
151
+ getCorrection,
152
+ getAnswerTable,
153
+ isAnswerTableValid,
154
+ getQuestionFromIdentifiers,
155
+ hasHintAndCorrection: true,
156
+ answerType: "varTable",
157
+ };
@@ -0,0 +1,12 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ nodeIdsCoeff: NodeIdentifiers[];
5
+ formatExpr: string;
6
+ };
7
+ type Options = {
8
+ formatExpr: string;
9
+ };
10
+ export declare const affineVariations: Exercise<Identifiers, Options>;
11
+ export {};
12
+ //# sourceMappingURL=affineVariations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"affineVariations.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineVariations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAkC7C,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAuIF,KAAK,OAAO,GAAG;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAsBF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAyB3D,CAAC"}
@@ -0,0 +1,176 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, GeneratorOptionTarget, GeneratorOptionType, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { RationalConstructor } from "../../../../math/numbers/rationals/rational.js";
4
+ import { randint } from "../../../../math/utils/random/randint.js";
5
+ import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
6
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
7
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
8
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
9
+ import { probaLawFlip } from "../../../../utils/alea/probaLawFlip.js";
10
+ import { random } from "../../../../utils/alea/random.js";
11
+ const createNodeF = (formatExpr, nodeA, nodeB) => {
12
+ const nodeVarX = "x".toTree();
13
+ switch (formatExpr) {
14
+ case "$b+ax$": {
15
+ const b = nodeB.evaluate();
16
+ if (b === 0) {
17
+ return multiply(nodeA, nodeVarX).simplify();
18
+ }
19
+ else {
20
+ return add(nodeB, multiply(nodeA, nodeVarX).simplify());
21
+ }
22
+ }
23
+ case "$ax+b$":
24
+ default:
25
+ return add(multiply(nodeA, nodeVarX), nodeB).simplify({
26
+ towardsDistribute: true,
27
+ forbidFactorize: true,
28
+ forceDistributeFractions: true,
29
+ });
30
+ }
31
+ };
32
+ const getPropositions = (n, { answer }) => {
33
+ const propositions = [];
34
+ addValidProp(propositions, answer, "raw");
35
+ tryToAddWrongProp(propositions, "Strictement croissante", "raw");
36
+ tryToAddWrongProp(propositions, "Strictement décroissante", "raw");
37
+ tryToAddWrongProp(propositions, "Constante", "raw");
38
+ tryToAddWrongProp(propositions, "Non monotone", "raw");
39
+ return shuffleProps(propositions, n);
40
+ };
41
+ const getAnswer = (identifiers) => {
42
+ const { nodeIdsCoeff } = identifiers;
43
+ const nodeA = NodeConstructor.fromIdentifiers(nodeIdsCoeff[1]);
44
+ const a = nodeA.evaluate();
45
+ if (a === 0) {
46
+ return "Constante";
47
+ }
48
+ else {
49
+ return a > 0 ? "Strictement croissante" : "Strictement décroissante";
50
+ }
51
+ };
52
+ const getInstruction = (identifiers) => {
53
+ const { nodeIdsCoeff, formatExpr } = identifiers;
54
+ const [nodeB, nodeA] = nodeIdsCoeff.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
55
+ const nodeF = createNodeF(formatExpr, nodeA, nodeB);
56
+ return `Soit $f$ la fonction définie sur $\\mathbb{R}$ par
57
+
58
+ $$
59
+ f(x) = ${nodeF.toTex()}
60
+ $$
61
+
62
+ Quel est le sens de variations de $f$ sur $\\mathbb{R}$ ?`;
63
+ };
64
+ const getHint = () => {
65
+ return `Sur $\\mathbb{R}$, la fonction $f(x) = ax+b = b+ax$ est :
66
+
67
+ - strictement croissante si $a>0$;
68
+ - strictement décroissante si $a<0$;
69
+ - constante si $a=0$.
70
+
71
+ Le coefficient $b$ n'a aucune influence sur les variations de $f$.
72
+ `;
73
+ };
74
+ const getCorrection = (identifiers) => {
75
+ const { nodeIdsCoeff } = identifiers;
76
+ const [_nodeB, nodeA] = nodeIdsCoeff.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
77
+ return `Le coefficient directeur de $f$ est $${nodeA.toTex()}$.
78
+
79
+ La fonction $f$ est donc ${getAnswer(identifiers).toLocaleLowerCase()} sur $\\mathbb{R}$.`;
80
+ };
81
+ const getKeys = () => {
82
+ return [];
83
+ };
84
+ const getAffineVariationsQuestion = (optsIn) => {
85
+ const arrayedOptions = optsIn ?? optsDefault;
86
+ const opts = {
87
+ formatExpr: random(arrayedOptions.formatExpr),
88
+ };
89
+ const { formatExpr } = opts;
90
+ const createRandomNodeCoeff = ({ isAllowZero }) => {
91
+ function createRandomNodeNonZero() {
92
+ return probaLawFlip([
93
+ //>0
94
+ [randint(1, 100).toTree(), 0.6],
95
+ [
96
+ RationalConstructor.randomIrreductible(20, {
97
+ onlySupOne: true,
98
+ }).toTree(),
99
+ 0.16,
100
+ ],
101
+ [RationalConstructor.randomIrreductibleProba(50).toTree(), 0.14],
102
+ ]);
103
+ }
104
+ const nodePos = (() => {
105
+ if (isAllowZero) {
106
+ return probaLawFlip([
107
+ [createRandomNodeNonZero(), 0.9],
108
+ [(0).toTree(), 0.1],
109
+ ]);
110
+ }
111
+ else {
112
+ return createRandomNodeNonZero();
113
+ }
114
+ })();
115
+ const sign = coinFlip() ? +1 : -1;
116
+ return multiply(sign, nodePos).simplify();
117
+ };
118
+ const nodeA = createRandomNodeCoeff({ isAllowZero: true });
119
+ const nodeB = createRandomNodeCoeff({
120
+ isAllowZero: nodeA.evaluate() !== 0,
121
+ });
122
+ const identifiers = {
123
+ nodeIdsCoeff: [nodeB, nodeA].map((node) => node.toIdentifiers()),
124
+ formatExpr,
125
+ };
126
+ return getQuestionFromIdentifiers(identifiers);
127
+ };
128
+ const getQuestionFromIdentifiers = (identifiers) => {
129
+ const question = {
130
+ answer: getAnswer(identifiers),
131
+ instruction: getInstruction(identifiers),
132
+ keys: getKeys(identifiers),
133
+ answerFormat: "raw",
134
+ identifiers,
135
+ hint: getHint(identifiers),
136
+ correction: getCorrection(identifiers),
137
+ };
138
+ return question;
139
+ };
140
+ const optsDefault = {
141
+ formatExpr: ["$ax+b$"],
142
+ };
143
+ const options = [
144
+ {
145
+ id: "formatExpr",
146
+ label: "Formats pour $f(x)$",
147
+ target: GeneratorOptionTarget.generation,
148
+ type: GeneratorOptionType.multiselect,
149
+ values: ["$ax+b$", "$b+ax$"],
150
+ defaultValue: optsDefault.formatExpr,
151
+ },
152
+ ];
153
+ export const affineVariations = {
154
+ id: "affineVariations",
155
+ label: "Déterminer le sens de variations d'une fonction affine à partir de son expression algébrique",
156
+ isSingleStep: true,
157
+ generator: (nb, opts) => getDistinctQuestions(() => getAffineVariationsQuestion(opts), nb),
158
+ options,
159
+ validateOptions: (opts) => {
160
+ return {
161
+ valid: !!(opts?.formatExpr && opts?.formatExpr.length > 0),
162
+ message: "Veuillez choisir au moins un format pour $f(x)$'.",
163
+ };
164
+ },
165
+ qcmTimer: 60,
166
+ freeTimer: 60,
167
+ getPropositions,
168
+ subject: "Mathématiques",
169
+ getInstruction,
170
+ getHint,
171
+ getCorrection,
172
+ getAnswer,
173
+ answerType: "QCU",
174
+ hasHintAndCorrection: true,
175
+ getQuestionFromIdentifiers,
176
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ b: number;
4
+ secondPoint: number[];
5
+ };
6
+ export declare const affineVariationsFromGraph: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=affineVariationsFromGraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"affineVariationsFromGraph.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineVariationsFromGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAsNF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAe3D,CAAC"}
@@ -0,0 +1,203 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { blues, greenMain, oranges, purples, reds, } from "../../../../geogebra/colors.js";
4
+ import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
5
+ import { Point } from "../../../../math/geometry/point.js";
6
+ import { randint } from "../../../../math/utils/random/randint.js";
7
+ import { NodeComparator } from "../../../../tree/utilities/nodeComparator.js";
8
+ import { random } from "../../../../utils/alea/random.js";
9
+ const getInstruction = () => {
10
+ return `Ci-dessous est tracée la courbe représentative $C_f$ d'une fonction affine $f$.
11
+ Déterminer graphiquement le sens de variation de $f$.`;
12
+ };
13
+ const getAnswer = (identifiers) => {
14
+ const { b, secondPoint } = identifiers;
15
+ const point1 = new Point("P1", 0, b);
16
+ const point2 = new Point("P2", secondPoint[0], secondPoint[1]);
17
+ if (NodeComparator.isEqualViaSub(point1.y, point2.y)) {
18
+ return "Constante";
19
+ }
20
+ else {
21
+ const [pointXSmall, pointXBig] = [point1, point2].toSorted((point1, point2) => point1.x.evaluate() - point2.x.evaluate());
22
+ return NodeComparator.compareViaSub(pointXSmall.y, pointXBig.y) === -1
23
+ ? "Strictement croissante"
24
+ : "Strictement décroissante";
25
+ }
26
+ };
27
+ const getHint = () => {
28
+ return `On prend deux points distincts sur $C_f$.
29
+
30
+ On note $x_{1}$ l'abscisse du point avec l'abscisse la plus petite.
31
+ On note $x_{2}$ l'abscisse du point avec l'abscisse la plus grande.
32
+
33
+ Les coordonnées des deux points sont donc $(x_{1};f(x_{1}))$ et $(x_{2};f(x_{2}))$.
34
+
35
+ La fonction $f$ est
36
+
37
+ - strictement croissante si :
38
+
39
+ $$
40
+ f(x_{1})<f(x_{2})
41
+ $$
42
+
43
+ - strictement décroissante si :
44
+
45
+ $$
46
+ f(x_{1})>f(x_{2})
47
+ $$
48
+
49
+ - constante si :
50
+
51
+ $$
52
+ f(x_{1})=f(x_{2})
53
+ $$
54
+
55
+ `;
56
+ };
57
+ const getCorrection = (identifiers) => {
58
+ const { b, secondPoint } = identifiers;
59
+ const point1 = new Point("P1", 0, b);
60
+ const point2 = new Point("P2", secondPoint[0], secondPoint[1]);
61
+ if (NodeComparator.isEqualViaSub(point1.y, point2.y)) {
62
+ return `On a :
63
+
64
+ $$
65
+ f(${point1.x.toTex()}) = f(${point2.x.toTex()}) = ${point1.y.toTex()}
66
+ $$
67
+
68
+ La fonction $f$ est donc constante sur $\\mathbb{R}$.`;
69
+ }
70
+ else {
71
+ const [pointXSmall, pointXBig] = [point1, point2].toSorted((point1, point2) => point1.x.evaluate() - point2.x.evaluate());
72
+ const valueComp = NodeComparator.compareViaSub(pointXSmall.y, pointXBig.y);
73
+ if (valueComp === -1) {
74
+ return `On a :
75
+
76
+ $$
77
+ ${pointXSmall.x.toTex()} < ${pointXBig.x.toTex()}
78
+ $$
79
+
80
+ et
81
+
82
+ $$
83
+ f(${pointXSmall.x.toTex()}) < f(${pointXBig.x.toTex()})
84
+ $$
85
+
86
+
87
+ La fonction $f$ est donc ${getAnswer(identifiers).toLocaleLowerCase()} sur $\\mathbb{R}$.`;
88
+ }
89
+ else {
90
+ return `On a :
91
+
92
+ $$
93
+ ${pointXSmall.x.toTex()} < ${pointXBig.x.toTex()}
94
+ $$
95
+
96
+ et
97
+
98
+ $$
99
+ f(${pointXSmall.x.toTex()}) > f(${pointXBig.x.toTex()})
100
+ $$
101
+
102
+
103
+ La fonction $f$ est donc ${getAnswer(identifiers).toLocaleLowerCase()} sur $\\mathbb{R}$.`;
104
+ }
105
+ }
106
+ };
107
+ const getCorrectionGGBOptions = (identifiers) => {
108
+ const { b, secondPoint } = identifiers;
109
+ const xMin = Math.min(0, secondPoint[0]);
110
+ const xMax = Math.max(0, secondPoint[0]);
111
+ const yMin = Math.min(b, secondPoint[1]);
112
+ const yMax = Math.max(b, secondPoint[1]);
113
+ const point1 = new Point("P1", 0, b);
114
+ const point2 = new Point("P2", secondPoint[0], secondPoint[1]);
115
+ const [pointXSmall, pointXBig] = [point1, point2].toSorted((point1, point2) => point1.x.evaluate() - point2.x.evaluate());
116
+ const colorButGreen = (() => {
117
+ const colors = [...reds, ...oranges, ...blues, ...purples];
118
+ return random(colors);
119
+ })();
120
+ const commands = [
121
+ `l = Line[(0, ${b}), (${secondPoint[0]}, ${secondPoint[1]})]`,
122
+ `SetColor(l, "${colorButGreen}")`,
123
+ "SetFixed(l, true, false)",
124
+ `v = Vector(${pointXSmall.toMathString()}, ${pointXBig.toMathString()})`,
125
+ `SetLineThickness(v, 10)`,
126
+ `SetColor(v, "${greenMain}")`,
127
+ ];
128
+ const ggb = new GeogebraConstructor({
129
+ commands,
130
+ });
131
+ return ggb.getOptions({
132
+ coords: ggb.getAdaptedCoords({ xMin, xMax, yMin, yMax }),
133
+ });
134
+ };
135
+ const getGGBOptions = (identifiers) => {
136
+ const { b, secondPoint } = identifiers;
137
+ const xMin = Math.min(0, secondPoint[0]);
138
+ const xMax = Math.max(0, secondPoint[0]);
139
+ const yMin = Math.min(b, secondPoint[1]);
140
+ const yMax = Math.max(b, secondPoint[1]);
141
+ const colorButGreen = (() => {
142
+ const colors = [...reds, ...oranges, ...blues, ...purples];
143
+ return random(colors);
144
+ })();
145
+ const commands = [
146
+ `l = Line[(0, ${b}), (${secondPoint[0]}, ${secondPoint[1]})]`,
147
+ `SetColor(l, "${colorButGreen}")`,
148
+ "SetFixed(l, true, false)",
149
+ ];
150
+ const ggb = new GeogebraConstructor({
151
+ commands,
152
+ });
153
+ return ggb.getOptions({
154
+ coords: ggb.getAdaptedCoords({ xMin, xMax, yMin, yMax }),
155
+ });
156
+ };
157
+ const getPropositions = (n, { answer }) => {
158
+ const propositions = [];
159
+ addValidProp(propositions, answer, "raw");
160
+ tryToAddWrongProp(propositions, "Strictement croissante", "raw");
161
+ tryToAddWrongProp(propositions, "Strictement décroissante", "raw");
162
+ tryToAddWrongProp(propositions, "Constante", "raw");
163
+ tryToAddWrongProp(propositions, "Non monotone", "raw");
164
+ return shuffleProps(propositions, n);
165
+ };
166
+ const getAffineVariationsFromGraphQuestion = () => {
167
+ const b = randint(-5, 6);
168
+ const secondPoint = [randint(-5, 6, [0]), randint(-5, 6)];
169
+ const identifiers = { b, secondPoint };
170
+ //[0,b] et [x,y]
171
+ //a = (y-b)/x
172
+ return getQuestionFromIdentifiers(identifiers);
173
+ };
174
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
175
+ const question = {
176
+ instruction: getInstruction(identifiers, opts),
177
+ answer: getAnswer(identifiers, opts),
178
+ keys: [],
179
+ ggbOptions: getGGBOptions(identifiers, opts),
180
+ answerFormat: "tex",
181
+ identifiers,
182
+ hint: getHint(identifiers, opts),
183
+ correction: getCorrection(identifiers, opts),
184
+ correctionGgbOptions: getCorrectionGGBOptions(identifiers, opts),
185
+ options: opts,
186
+ };
187
+ return question;
188
+ };
189
+ export const affineVariationsFromGraph = {
190
+ id: "affineVariationsFromGraph",
191
+ connector: "=",
192
+ label: "Lire graphiquement le sens de variation d'une fonction affine",
193
+ isSingleStep: true,
194
+ generator: (nb) => getDistinctQuestions(() => getAffineVariationsFromGraphQuestion(), nb),
195
+ qcmTimer: 60,
196
+ freeTimer: 60,
197
+ getPropositions,
198
+ hasGeogebra: true,
199
+ subject: "Mathématiques",
200
+ getQuestionFromIdentifiers,
201
+ hasHintAndCorrection: true,
202
+ answerType: "QCU",
203
+ };
@@ -0,0 +1,12 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { PointIdentifiers } from "../../../../math/geometry/point.js";
3
+ type Identifiers = {
4
+ pointIds: PointIdentifiers[];
5
+ };
6
+ type Options = {
7
+ typeX: string;
8
+ typeY: string;
9
+ };
10
+ export declare const affineVariationsFromTwoImages: Exercise<Identifiers, Options>;
11
+ export {};
12
+ //# sourceMappingURL=affineVariationsFromTwoImages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"affineVariationsFromTwoImages.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineVariationsFromTwoImages.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AA+CtC,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,gBAAgB,EAAE,CAAC;CAC9B,CAAC;AAyMF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AA+BF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkCxE,CAAC"}