math-exercises 3.0.215 → 3.0.216

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 (114) hide show
  1. package/lib/exercises/math/arithmetic/whichDayInXDays.d.ts.map +1 -1
  2. package/lib/exercises/math/arithmetic/whichDayInXDays.js +2 -1
  3. package/lib/exercises/math/complex/unitRoots/giveOneSolutionToComplexPowNEqualsOne.js +1 -1
  4. package/lib/exercises/math/conversion/clock/index.d.ts +0 -1
  5. package/lib/exercises/math/conversion/clock/index.d.ts.map +1 -1
  6. package/lib/exercises/math/conversion/clock/index.js +1 -1
  7. package/lib/exercises/math/graphs/adjacentMatrixPath.d.ts +10 -0
  8. package/lib/exercises/math/graphs/adjacentMatrixPath.d.ts.map +1 -0
  9. package/lib/exercises/math/graphs/adjacentMatrixPath.js +89 -0
  10. package/lib/exercises/math/graphs/edgesNumberFromSummitsDegrees.d.ts +7 -0
  11. package/lib/exercises/math/graphs/edgesNumberFromSummitsDegrees.d.ts.map +1 -0
  12. package/lib/exercises/math/graphs/edgesNumberFromSummitsDegrees.js +98 -0
  13. package/lib/exercises/math/graphs/eulerianChainFromAdjacentMatrix.d.ts +8 -0
  14. package/lib/exercises/math/graphs/eulerianChainFromAdjacentMatrix.d.ts.map +1 -0
  15. package/lib/exercises/math/graphs/eulerianChainFromAdjacentMatrix.js +96 -0
  16. package/lib/exercises/math/graphs/graphsChainOrPathOfLengthN.d.ts +15 -0
  17. package/lib/exercises/math/graphs/graphsChainOrPathOfLengthN.d.ts.map +1 -0
  18. package/lib/exercises/math/graphs/graphsChainOrPathOfLengthN.js +262 -0
  19. package/lib/exercises/math/graphs/graphsCheckIsConnectedUndirectedGraph.d.ts +11 -0
  20. package/lib/exercises/math/graphs/graphsCheckIsConnectedUndirectedGraph.d.ts.map +1 -0
  21. package/lib/exercises/math/graphs/graphsCheckIsConnectedUndirectedGraph.js +178 -0
  22. package/lib/exercises/math/graphs/graphsCheckIsSameGraph.d.ts +19 -0
  23. package/lib/exercises/math/graphs/graphsCheckIsSameGraph.d.ts.map +1 -0
  24. package/lib/exercises/math/graphs/graphsCheckIsSameGraph.js +301 -0
  25. package/lib/exercises/math/graphs/graphsCheckIsVerticesAdjacent.d.ts +16 -0
  26. package/lib/exercises/math/graphs/graphsCheckIsVerticesAdjacent.d.ts.map +1 -0
  27. package/lib/exercises/math/graphs/graphsCheckIsVerticesAdjacent.js +207 -0
  28. package/lib/exercises/math/graphs/graphsDegreeOfVertex.d.ts +15 -0
  29. package/lib/exercises/math/graphs/graphsDegreeOfVertex.d.ts.map +1 -0
  30. package/lib/exercises/math/graphs/graphsDegreeOfVertex.js +232 -0
  31. package/lib/exercises/math/graphs/graphsOrderOfGraph.d.ts +14 -0
  32. package/lib/exercises/math/graphs/graphsOrderOfGraph.d.ts.map +1 -0
  33. package/lib/exercises/math/graphs/graphsOrderOfGraph.js +222 -0
  34. package/lib/exercises/math/graphs/index.d.ts +10 -0
  35. package/lib/exercises/math/graphs/index.d.ts.map +1 -0
  36. package/lib/exercises/math/graphs/index.js +9 -0
  37. package/lib/exercises/math/index.d.ts +1 -0
  38. package/lib/exercises/math/index.d.ts.map +1 -1
  39. package/lib/exercises/math/index.js +1 -0
  40. package/lib/exercises/math/matrices/areMatricesInverse.d.ts +9 -0
  41. package/lib/exercises/math/matrices/areMatricesInverse.d.ts.map +1 -0
  42. package/lib/exercises/math/matrices/areMatricesInverse.js +106 -0
  43. package/lib/exercises/math/matrices/computeFixedMatrixInRecurrenceSequence.d.ts +9 -0
  44. package/lib/exercises/math/matrices/computeFixedMatrixInRecurrenceSequence.d.ts.map +1 -0
  45. package/lib/exercises/math/matrices/computeFixedMatrixInRecurrenceSequence.js +144 -0
  46. package/lib/exercises/math/matrices/findInversedMatrixFromSystem.d.ts +8 -0
  47. package/lib/exercises/math/matrices/findInversedMatrixFromSystem.d.ts.map +1 -0
  48. package/lib/exercises/math/matrices/findInversedMatrixFromSystem.js +148 -0
  49. package/lib/exercises/math/matrices/index.d.ts +12 -0
  50. package/lib/exercises/math/matrices/index.d.ts.map +1 -1
  51. package/lib/exercises/math/matrices/index.js +12 -0
  52. package/lib/exercises/math/matrices/isMatrixTransitionMatrix.d.ts +8 -0
  53. package/lib/exercises/math/matrices/isMatrixTransitionMatrix.d.ts.map +1 -0
  54. package/lib/exercises/math/matrices/isMatrixTransitionMatrix.js +132 -0
  55. package/lib/exercises/math/matrices/matrixBuildMatrixFromCoefficients.d.ts +8 -0
  56. package/lib/exercises/math/matrices/matrixBuildMatrixFromCoefficients.d.ts.map +1 -0
  57. package/lib/exercises/math/matrices/matrixBuildMatrixFromCoefficients.js +152 -0
  58. package/lib/exercises/math/matrices/matrixCheckIsSymmetrical.d.ts +8 -0
  59. package/lib/exercises/math/matrices/matrixCheckIsSymmetrical.d.ts.map +1 -0
  60. package/lib/exercises/math/matrices/matrixCheckIsSymmetrical.js +155 -0
  61. package/lib/exercises/math/matrices/matrixComputeDetOfMat2.d.ts +8 -0
  62. package/lib/exercises/math/matrices/matrixComputeDetOfMat2.d.ts.map +1 -0
  63. package/lib/exercises/math/matrices/matrixComputeDetOfMat2.js +142 -0
  64. package/lib/exercises/math/matrices/matrixComputeInverseOfMat2.d.ts +8 -0
  65. package/lib/exercises/math/matrices/matrixComputeInverseOfMat2.d.ts.map +1 -0
  66. package/lib/exercises/math/matrices/matrixComputeInverseOfMat2.js +237 -0
  67. package/lib/exercises/math/matrices/matrixComputeLinearCombination.d.ts +15 -0
  68. package/lib/exercises/math/matrices/matrixComputeLinearCombination.d.ts.map +1 -0
  69. package/lib/exercises/math/matrices/matrixComputeLinearCombination.js +232 -0
  70. package/lib/exercises/math/matrices/matrixComputePower.d.ts +12 -0
  71. package/lib/exercises/math/matrices/matrixComputePower.d.ts.map +1 -0
  72. package/lib/exercises/math/matrices/matrixComputePower.js +230 -0
  73. package/lib/exercises/math/matrices/matrixComputeProduct.d.ts +9 -0
  74. package/lib/exercises/math/matrices/matrixComputeProduct.d.ts.map +1 -0
  75. package/lib/exercises/math/matrices/matrixComputeProduct.js +178 -0
  76. package/lib/exercises/math/matrices/writeMatrixAssociatedToSystem.d.ts +8 -0
  77. package/lib/exercises/math/matrices/writeMatrixAssociatedToSystem.d.ts.map +1 -0
  78. package/lib/exercises/math/matrices/writeMatrixAssociatedToSystem.js +105 -0
  79. package/lib/exercises/vea/matrixVEA.d.ts +2 -0
  80. package/lib/exercises/vea/matrixVEA.d.ts.map +1 -0
  81. package/lib/exercises/vea/matrixVEA.js +1 -0
  82. package/lib/index.d.ts +86 -13
  83. package/lib/index.d.ts.map +1 -1
  84. package/lib/math/geometry/point.d.ts.map +1 -1
  85. package/lib/math/geometry/point.js +3 -1
  86. package/lib/math/graphs/graph.d.ts +43 -0
  87. package/lib/math/graphs/graph.d.ts.map +1 -0
  88. package/lib/math/graphs/graph.js +391 -0
  89. package/lib/math/matrices/matrix.d.ts +42 -3
  90. package/lib/math/matrices/matrix.d.ts.map +1 -1
  91. package/lib/math/matrices/matrix.js +173 -7
  92. package/lib/math/matrices/parseMatrix.d.ts +3 -0
  93. package/lib/math/matrices/parseMatrix.d.ts.map +1 -0
  94. package/lib/math/matrices/parseMatrix.js +22 -0
  95. package/lib/math/systems/generalSystem.d.ts +2 -0
  96. package/lib/math/systems/generalSystem.d.ts.map +1 -1
  97. package/lib/math/systems/generalSystem.js +5 -0
  98. package/lib/math/utils/graphs/graphRenderer.d.ts +25 -0
  99. package/lib/math/utils/graphs/graphRenderer.d.ts.map +1 -0
  100. package/lib/math/utils/graphs/graphRenderer.js +123 -0
  101. package/lib/playground.d.ts +6 -1
  102. package/lib/playground.d.ts.map +1 -1
  103. package/lib/playground.js +6 -5
  104. package/lib/tree/parsers/latexParser.d.ts +1 -1
  105. package/lib/tree/utilities/nodeSimplifier.d.ts +1 -1
  106. package/lib/types/keyIds.d.ts +2 -0
  107. package/lib/types/keyIds.d.ts.map +1 -1
  108. package/lib/utils/arrays/arrayChunks.d.ts +9 -0
  109. package/lib/utils/arrays/arrayChunks.d.ts.map +1 -0
  110. package/lib/utils/arrays/arrayChunks.js +34 -0
  111. package/lib/utils/strings/ordinalSuffixed.d.ts +2 -0
  112. package/lib/utils/strings/ordinalSuffixed.d.ts.map +1 -0
  113. package/lib/utils/strings/ordinalSuffixed.js +5 -0
  114. package/package.json +7 -1
@@ -0,0 +1,230 @@
1
+ import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
+ import { Matrix, MatrixConstructor, } from "../../../math/matrices/matrix.js";
4
+ import { parseMatrix } from "../../../math/matrices/parseMatrix.js";
5
+ import { multiply } from "../../../tree/nodes/operators/multiplyNode.js";
6
+ import { power } from "../../../tree/nodes/operators/powerNode.js";
7
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
8
+ import { alignTex } from "../../../utils/latex/alignTex.js";
9
+ const getHydrated = (identifiers) => {
10
+ const { matIdsA, exponent } = identifiers;
11
+ const [matA] = [matIdsA].map((matIds) => MatrixConstructor.fromIdentifiers(matIds));
12
+ const nodeExprInstruction = power("A".toTree(), exponent);
13
+ return {
14
+ matA,
15
+ nodeExprInstruction,
16
+ };
17
+ };
18
+ const getInstruction = (identifiers) => {
19
+ const { matA, nodeExprInstruction } = getHydrated(identifiers);
20
+ return `Soit :
21
+
22
+ $$
23
+ A = ${matA.toTex()}
24
+ $$
25
+
26
+ Calculer $${nodeExprInstruction.toTex()}$.`;
27
+ };
28
+ const getAnswer = (identifiers) => {
29
+ const { exponent } = identifiers;
30
+ const { matA } = getHydrated(identifiers);
31
+ const matProduct = matA.power(exponent);
32
+ const matProductSimplified = matProduct.simplify({ towardsDistribute: true });
33
+ return matProductSimplified.toTex();
34
+ };
35
+ const getHint = () => {
36
+ const matA = new Matrix([
37
+ ["a".toTree(), "b".toTree()],
38
+ ["c".toTree(), "d".toTree()],
39
+ ]);
40
+ const matASpaced = new Matrix([
41
+ ["\\ \\ \\ a".toTree(), "\\ \\ \\ \\ \\ b \\ \\ \\ ".toTree()],
42
+ ["\\ \\ \\ c".toTree(), "\\ \\ \\ \\ \\ d \\ \\ \\ ".toTree()],
43
+ ]);
44
+ return `Soient $A$ une matrice à $2$ lignes et $2$ colonnes à coefficients réels.
45
+
46
+ $$
47
+ A = ${matA.toTex()}
48
+ $$
49
+
50
+ Pour calculer $A^2=AA$,
51
+ tu peux disposer les matrices de cette façon pour ne pas te tromper :
52
+
53
+ $$
54
+ \\begin{matrix} {\\begin{matrix} \\ & \\ \\\\ \\ & \\ \\end{matrix}} & {${matASpaced.toTex()}} \\\\ {${matA.toTex()}} & {\\begin{pmatrix} {...} & {ab+bd} \\\\ {...} & {...} \\end{pmatrix}} \\end{matrix}
55
+ $$
56
+
57
+ Ce qui donne :
58
+
59
+ $$
60
+ A^2 = AA = ${matA.matrixProduct(matA).toTex()}
61
+ $$
62
+
63
+ Continue ainsi pour les autres puissances de $A$ :
64
+
65
+ $$
66
+ A^3 = AAA = A^2 A
67
+ $$
68
+
69
+ etc.
70
+
71
+ `;
72
+ };
73
+ const getCorrection = (identifiers) => {
74
+ const { exponent } = identifiers;
75
+ const { matA } = getHydrated(identifiers);
76
+ const matA2 = matA.matrixProduct(matA);
77
+ const matA2Simplified = matA2.simplify({ towardsDistribute: true });
78
+ const matA3 = matA2Simplified.matrixProduct(matA);
79
+ const matA3Simplified = matA3.simplify({ towardsDistribute: true });
80
+ switch (exponent) {
81
+ case 2:
82
+ return `${alignTex([
83
+ ["", "A^2"],
84
+ ["=", `${matA.toTex()} ${matA.toTex()}`],
85
+ ["=", matA2.toTex()],
86
+ ["=", matA2Simplified.toTex()],
87
+ ])}`;
88
+ case 3:
89
+ return `
90
+
91
+ ${alignTex([
92
+ ["", "A^2"],
93
+ ["=", `${matA.toTex()} ${matA.toTex()}`],
94
+ ["=", matA2.toTex()],
95
+ ["=", matA2Simplified.toTex()],
96
+ ])}
97
+
98
+ ${alignTex([
99
+ ["", "A^3"],
100
+ ["=", "A^2 A"],
101
+ ["=", `${matA2Simplified.toTex()} ${matA.toTex()}`],
102
+ ["=", matA3.toTex()],
103
+ ["=", matA3Simplified.toTex()],
104
+ ])}
105
+
106
+ `;
107
+ default:
108
+ throw new Error("Unsupported exponent: " + exponent);
109
+ }
110
+ };
111
+ const getPropositions = (n, { answer, ...identifiers }, optsIn) => {
112
+ const opts = optsIn ?? optsDefault;
113
+ const propositions = [];
114
+ addValidProp(propositions, answer);
115
+ const { exponent } = identifiers;
116
+ const { matA } = getHydrated(identifiers);
117
+ function createPowerFuncWrong(funcAB) {
118
+ const func = (matA, exponent) => [...Array(exponent).keys()].reduce((acc, i) => {
119
+ if (i === 0) {
120
+ return matA;
121
+ }
122
+ else {
123
+ return funcAB(acc, matA);
124
+ }
125
+ }, matA);
126
+ return func;
127
+ }
128
+ //student: AB = A+B
129
+ {
130
+ const powerFuncWrong = createPowerFuncWrong((matA, matB) => matA.add(matB));
131
+ const matWrong = powerFuncWrong(matA, exponent);
132
+ tryToAddWrongProp(propositions, matWrong.simplify({ towardsDistribute: true }).toTex());
133
+ }
134
+ //student: AB = (a_{ij}b_{ij})
135
+ {
136
+ function matrixProductWrong(mat1, mat2) {
137
+ const arrElementSumWrong = mat1.elements.map((row, i) => row.map((elt1, j) => {
138
+ const elt2 = mat2.elements[i][j];
139
+ return multiply(elt1, elt2);
140
+ }));
141
+ return new Matrix(arrElementSumWrong);
142
+ }
143
+ const powerFuncWrong = createPowerFuncWrong(matrixProductWrong);
144
+ const matWrong = powerFuncWrong(matA, exponent);
145
+ tryToAddWrongProp(propositions, matWrong.simplify({ towardsDistribute: true }).toTex());
146
+ }
147
+ //student: AB = (sum(a_{ik}b_{jk}))
148
+ {
149
+ const powerFuncWrong = createPowerFuncWrong((matA, matB) => matA.matrixProduct(matB.transposed()));
150
+ const matWrong = powerFuncWrong(matA, exponent);
151
+ tryToAddWrongProp(propositions, matWrong.simplify({ towardsDistribute: true }).toTex());
152
+ }
153
+ //filler
154
+ {
155
+ propWhile(propositions, n, () => {
156
+ const identifiersWrong = createRandomIdentifiers(opts);
157
+ tryToAddWrongProp(propositions, getAnswer(identifiersWrong));
158
+ });
159
+ }
160
+ return shuffleProps(propositions, n);
161
+ };
162
+ const getKeys = () => {
163
+ return ["mat-2-2"];
164
+ };
165
+ const isAnswerValid = (ans, { answer }) => {
166
+ try {
167
+ const matAns = parseMatrix(ans);
168
+ const matAnswer = parseMatrix(answer);
169
+ return matAns.equals(matAnswer);
170
+ }
171
+ catch (e) {
172
+ handleVEAError(e);
173
+ return false;
174
+ }
175
+ };
176
+ const createRandomIdentifiers = (opts) => {
177
+ const matA = MatrixConstructor.random(2, 2);
178
+ const exponent = parseInt(opts.exponent);
179
+ const identifiers = {
180
+ matIdsA: matA.toIdentifiers(),
181
+ exponent,
182
+ };
183
+ return identifiers;
184
+ };
185
+ const getMatrixComputePowerQuestion = (optsIn) => {
186
+ const opts = optsIn ?? optsDefault;
187
+ const identifiers = createRandomIdentifiers(opts);
188
+ return getQuestionFromIdentifiers(identifiers, opts);
189
+ };
190
+ const getQuestionFromIdentifiers = (identifiers, optsIn) => {
191
+ const question = {
192
+ answer: getAnswer(identifiers),
193
+ instruction: getInstruction(identifiers),
194
+ keys: getKeys(identifiers),
195
+ answerFormat: "tex",
196
+ identifiers,
197
+ hint: getHint(identifiers),
198
+ correction: getCorrection(identifiers),
199
+ options: optsIn,
200
+ };
201
+ return question;
202
+ };
203
+ const optsDefault = {
204
+ exponent: "2",
205
+ };
206
+ const options = [
207
+ {
208
+ id: "exponent",
209
+ label: "Valeur de l'exposant",
210
+ target: GeneratorOptionTarget.generation,
211
+ type: GeneratorOptionType.select,
212
+ values: ["2", "3"],
213
+ defaultValue: optsDefault.exponent,
214
+ },
215
+ ];
216
+ export const matrixComputePower = {
217
+ id: "matrixComputePower",
218
+ connector: "=",
219
+ label: "Calculer une puissance d'une matrice",
220
+ isSingleStep: true,
221
+ generator: (nb, opts) => getDistinctQuestions(() => getMatrixComputePowerQuestion(opts), nb),
222
+ options,
223
+ qcmTimer: 60,
224
+ freeTimer: 60,
225
+ getPropositions,
226
+ isAnswerValid,
227
+ subject: "Mathématiques",
228
+ getQuestionFromIdentifiers,
229
+ hasHintAndCorrection: true,
230
+ };
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ import { MatrixIdentifiers } from "../../../math/matrices/matrix.js";
3
+ type Identifiers = {
4
+ matIdsA: MatrixIdentifiers;
5
+ matIdsB: MatrixIdentifiers;
6
+ };
7
+ export declare const matrixComputeProduct: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=matrixComputeProduct.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matrixComputeProduct.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/matrices/matrixComputeProduct.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAGL,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AAOvC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,OAAO,EAAE,iBAAiB,CAAC;CAC5B,CAAC;AA0MF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CActD,CAAC"}
@@ -0,0 +1,178 @@
1
+ import { addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
+ import { Matrix, MatrixConstructor, } from "../../../math/matrices/matrix.js";
4
+ import { parseMatrix } from "../../../math/matrices/parseMatrix.js";
5
+ import { multiply } from "../../../tree/nodes/operators/multiplyNode.js";
6
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
7
+ import { alignTex } from "../../../utils/latex/alignTex.js";
8
+ const getHydrated = (identifiers) => {
9
+ const { matIdsA, matIdsB } = identifiers;
10
+ const [matA, matB] = [matIdsA, matIdsB].map((matIds) => MatrixConstructor.fromIdentifiers(matIds));
11
+ const nodeExprInstruction = multiply("A".toTree(), "B".toTree()).simplify();
12
+ return {
13
+ matA,
14
+ matB,
15
+ nodeExprInstruction,
16
+ };
17
+ };
18
+ const getInstruction = (identifiers) => {
19
+ const { matA, matB, nodeExprInstruction } = getHydrated(identifiers);
20
+ return `Soient :
21
+
22
+ $$
23
+ A = ${matA.toTex()}
24
+ $$
25
+
26
+ $$
27
+ B = ${matB.toTex()}
28
+ $$
29
+
30
+ Calculer $${nodeExprInstruction.toTex()}$.`;
31
+ };
32
+ const getAnswer = (identifiers) => {
33
+ const { matA, matB } = getHydrated(identifiers);
34
+ const matProduct = matA.matrixProduct(matB);
35
+ const matProductSimplified = matProduct.simplify({ towardsDistribute: true });
36
+ return matProductSimplified.toTex();
37
+ };
38
+ const getHint = () => {
39
+ const matA = new Matrix([
40
+ ["a".toTree(), "b".toTree()],
41
+ ["c".toTree(), "d".toTree()],
42
+ ]);
43
+ const matB = new Matrix([
44
+ ["r".toTree(), "s".toTree()],
45
+ ["t".toTree(), "u".toTree()],
46
+ ]);
47
+ const matBSpaced = new Matrix([
48
+ ["\\ \\ \\ r".toTree(), "\\ \\ \\ \\ \\ s \\ \\ \\ ".toTree()],
49
+ ["\\ \\ \\ t".toTree(), "\\ \\ \\ \\ \\ u \\ \\ \\ ".toTree()],
50
+ ]);
51
+ return `Soient $A$ et $B$ deux matrices à $2$ lignes et $2$ colonnes à coefficients réels.
52
+
53
+ $$
54
+ A = ${matA.toTex()}
55
+ $$
56
+
57
+ $$
58
+ B = ${matB.toTex()}
59
+ $$
60
+
61
+ Pour calculer le produit matriciel $AB$,
62
+ tu peux disposer les matrices $A$ et $B$ de cette façon pour ne pas te tromper :
63
+
64
+ $$
65
+ \\begin{matrix} {\\begin{matrix} \\ & \\ \\\\ \\ & \\ \\end{matrix}} & {${matBSpaced.toTex()}} \\\\ {${matA.toTex()}} & {\\begin{pmatrix} {...} & {as+bu} \\\\ {...} & {...} \\end{pmatrix}} \\end{matrix}
66
+ $$
67
+
68
+ Ce qui donne :
69
+
70
+ $$
71
+ AB = ${matA.matrixProduct(matB).toTex()}
72
+ $$
73
+
74
+ `;
75
+ };
76
+ const getCorrection = (identifiers) => {
77
+ const { matA, matB, nodeExprInstruction } = getHydrated(identifiers);
78
+ const matProduct = matA.matrixProduct(matB);
79
+ const matProductSimplified = matProduct.simplify({ towardsDistribute: true });
80
+ return `${alignTex([
81
+ ["", nodeExprInstruction.toTex()],
82
+ ["=", `${matA.toTex()} ${matB.toTex()}`],
83
+ ["=", matProduct.toTex()],
84
+ ["=", matProductSimplified.toTex()],
85
+ ])}`;
86
+ };
87
+ const getPropositions = (n, { answer, ...identifiers }) => {
88
+ const propositions = [];
89
+ addValidProp(propositions, answer);
90
+ const { matA, matB } = getHydrated(identifiers);
91
+ //student: AB = A+B
92
+ {
93
+ const matWrong = matA.add(matB);
94
+ tryToAddWrongProp(propositions, matWrong.simplify({ towardsDistribute: true }).toTex());
95
+ }
96
+ //student: AB = (a_{ij}b_{ij})
97
+ {
98
+ function matrixProductWrong(mat1, mat2) {
99
+ const arrElementSumWrong = mat1.elements.map((row, i) => row.map((elt1, j) => {
100
+ const elt2 = mat2.elements[i][j];
101
+ return multiply(elt1, elt2);
102
+ }));
103
+ return new Matrix(arrElementSumWrong);
104
+ }
105
+ const matWrong = matrixProductWrong(matA, matB);
106
+ tryToAddWrongProp(propositions, matWrong.simplify({ towardsDistribute: true }).toTex());
107
+ }
108
+ //student: AB = (sum(a_{ik}b_{jk}))
109
+ {
110
+ const matWrong = matA.matrixProduct(matB.transposed());
111
+ tryToAddWrongProp(propositions, matWrong.simplify({ towardsDistribute: true }).toTex());
112
+ }
113
+ //filler
114
+ {
115
+ propWhile(propositions, n, () => {
116
+ const identifiersWrong = createRandomIdentifiers();
117
+ tryToAddWrongProp(propositions, getAnswer(identifiersWrong));
118
+ });
119
+ }
120
+ return shuffleProps(propositions, n);
121
+ };
122
+ const getKeys = () => {
123
+ return ["mat-2-2"];
124
+ };
125
+ const isAnswerValid = (ans, { answer }) => {
126
+ try {
127
+ const matAns = parseMatrix(ans);
128
+ const matAnswer = parseMatrix(answer);
129
+ return matAns.equals(matAnswer);
130
+ }
131
+ catch (e) {
132
+ handleVEAError(e);
133
+ return false;
134
+ }
135
+ };
136
+ const createRandomIdentifiers = () => {
137
+ const nodeKA = (1).toTree();
138
+ const nodeKB = (2).toTree();
139
+ const matA = MatrixConstructor.random(2, 2);
140
+ const matB = MatrixConstructor.random(2, 2);
141
+ const identifiers = {
142
+ matIdsA: matA.toIdentifiers(),
143
+ matIdsB: matB.toIdentifiers(),
144
+ nodeIdsKA: nodeKA.toIdentifiers(),
145
+ nodeIdsKB: nodeKB.toIdentifiers(),
146
+ };
147
+ return identifiers;
148
+ };
149
+ const getMatrixComputeProductQuestion = () => {
150
+ const identifiers = createRandomIdentifiers();
151
+ return getQuestionFromIdentifiers(identifiers);
152
+ };
153
+ const getQuestionFromIdentifiers = (identifiers) => {
154
+ const question = {
155
+ answer: getAnswer(identifiers),
156
+ instruction: getInstruction(identifiers),
157
+ keys: getKeys(identifiers),
158
+ answerFormat: "tex",
159
+ identifiers,
160
+ hint: getHint(identifiers),
161
+ correction: getCorrection(identifiers),
162
+ };
163
+ return question;
164
+ };
165
+ export const matrixComputeProduct = {
166
+ id: "matrixComputeProduct",
167
+ connector: "=",
168
+ label: "Calculer le produit de deux matrices",
169
+ isSingleStep: true,
170
+ generator: (nb) => getDistinctQuestions(getMatrixComputeProductQuestion, nb),
171
+ qcmTimer: 60,
172
+ freeTimer: 60,
173
+ getPropositions,
174
+ isAnswerValid,
175
+ subject: "Mathématiques",
176
+ getQuestionFromIdentifiers,
177
+ hasHintAndCorrection: true,
178
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ import { GeneralSystemIdentifiers } from "../../../math/systems/generalSystem.js";
3
+ type Identifiers = {
4
+ systemIds: GeneralSystemIdentifiers;
5
+ };
6
+ export declare const writeMatrixAssociatedToSystem: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=writeMatrixAssociatedToSystem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeMatrixAssociatedToSystem.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/matrices/writeMatrixAssociatedToSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAEL,wBAAwB,EACzB,MAAM,qCAAqC,CAAC;AAG7C,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,wBAAwB,CAAC;CACrC,CAAC;AA6FF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAqB/D,CAAC"}
@@ -0,0 +1,105 @@
1
+ import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
+ import { Matrix, MatrixConstructor } from "../../../math/matrices/matrix.js";
4
+ import { parseMatrix } from "../../../math/matrices/parseMatrix.js";
5
+ import { GeneralSystemConstructor, } from "../../../math/systems/generalSystem.js";
6
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
7
+ const getPropositions = (n, { answer }) => {
8
+ const propositions = [];
9
+ addValidProp(propositions, answer);
10
+ propWhile(propositions, n, () => {
11
+ tryToAddWrongProp(propositions, MatrixConstructor.random(2, 2).toTex());
12
+ });
13
+ return shuffleProps(propositions, n);
14
+ };
15
+ const getAnswer = (identifiers) => {
16
+ const { systemIds } = identifiers;
17
+ const system = GeneralSystemConstructor.fromIdentifiers(systemIds);
18
+ const matrix = system.getMatrix();
19
+ return matrix.toTex();
20
+ };
21
+ const getInstruction = (identifiers) => {
22
+ const { systemIds } = identifiers;
23
+ const system = GeneralSystemConstructor.fromIdentifiers(systemIds);
24
+ return `On considère le système $(S)$ suivant :
25
+
26
+ $$
27
+ ${system.toTex()}
28
+ $$
29
+
30
+ On cherche à écrire ce système sous forme matricielle :
31
+
32
+ $$
33
+ AX = B
34
+ $$
35
+
36
+ avec $X = \\begin{pmatrix}x\\\\ y\\end{pmatrix}$ et $B = \\begin{pmatrix}${system.coeffs[0][2].toTex()}\\\\ ${system.coeffs[1][2].toTex()}\\end{pmatrix}$.
37
+
38
+
39
+ Écrire $A$.`;
40
+ };
41
+ const getHint = () => {
42
+ return `En faisant le produit de $A$ par $X$, on doit obtenir la partie gauche du système.`;
43
+ };
44
+ const getCorrection = (identifiers) => {
45
+ const { systemIds } = identifiers;
46
+ const system = GeneralSystemConstructor.fromIdentifiers(systemIds);
47
+ const coeffs = system.coeffs.map((row) => row.slice(0, 2));
48
+ const matrix = new Matrix(coeffs).toTex();
49
+ return `En posant $X = \\begin{pmatrix}x\\\\ y\\end{pmatrix}$, $B = \\begin{pmatrix}${system.coeffs[0][2].toTex()}\\\\ ${system.coeffs[1][2].toTex()}\\end{pmatrix}$ et :
50
+
51
+ $$
52
+ A = ${matrix}
53
+ $$
54
+
55
+ on obtient bien $(S)\\iff AX=B$.`;
56
+ };
57
+ const getKeys = () => {
58
+ return ["mat-2-2"];
59
+ };
60
+ const isAnswerValid = (ans, { answer }) => {
61
+ try {
62
+ const matAns = parseMatrix(ans);
63
+ const matAnswer = parseMatrix(answer);
64
+ return matAns.equals(matAnswer);
65
+ }
66
+ catch (err) {
67
+ return handleVEAError(err);
68
+ }
69
+ };
70
+ const getWriteMatrixAssociatedToSystemQuestion = () => {
71
+ const sys = GeneralSystemConstructor.random();
72
+ const identifiers = {
73
+ systemIds: sys.toIdentifiers(),
74
+ };
75
+ return getQuestionFromIdentifiers(identifiers);
76
+ };
77
+ const getQuestionFromIdentifiers = (identifiers) => {
78
+ return {
79
+ answer: getAnswer(identifiers),
80
+ instruction: getInstruction(identifiers),
81
+ keys: getKeys(identifiers),
82
+ answerFormat: "tex",
83
+ identifiers,
84
+ hint: getHint(identifiers),
85
+ correction: getCorrection(identifiers),
86
+ };
87
+ };
88
+ export const writeMatrixAssociatedToSystem = {
89
+ id: "writeMatrixAssociatedToSystem",
90
+ connector: "=",
91
+ label: "Écrire la matrice associée à un système d'équations linéaires",
92
+ isSingleStep: true,
93
+ generator: (nb, opts) => getDistinctQuestions(() => getWriteMatrixAssociatedToSystemQuestion(opts), nb),
94
+ qcmTimer: 60,
95
+ freeTimer: 60,
96
+ getPropositions,
97
+ isAnswerValid,
98
+ subject: "Mathématiques",
99
+ getInstruction,
100
+ getHint,
101
+ getCorrection,
102
+ getAnswer,
103
+ getQuestionFromIdentifiers,
104
+ hasHintAndCorrection: true,
105
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=matrixVEA.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matrixVEA.d.ts","sourceRoot":"","sources":["../../../src/exercises/vea/matrixVEA.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export {};
package/lib/index.d.ts CHANGED
@@ -1042,19 +1042,6 @@ declare const mathExercises: (Exercise<{
1042
1042
  minutes: number;
1043
1043
  }, {
1044
1044
  amPmType: string;
1045
- }> | Exercise<{
1046
- dateTimeStart: {
1047
- day: number;
1048
- hours: number;
1049
- minutes: number;
1050
- };
1051
- dateTimeDuration: {
1052
- day: number;
1053
- hours: number;
1054
- minutes: number;
1055
- };
1056
- }, {
1057
- hoursMinutesType: string;
1058
1045
  }> | Exercise<{
1059
1046
  point: import("./math/geometry/point.js").PointIdentifiers;
1060
1047
  }, Record<string, string | boolean | string[]>> | Exercise<{
@@ -3283,6 +3270,41 @@ declare const mathExercises: (Exercise<{
3283
3270
  BjCoeff: number;
3284
3271
  i: number;
3285
3272
  j: number;
3273
+ }, Record<string, string | boolean | string[]>> | Exercise<{
3274
+ matIdsA: import("./math/matrices/matrix.js").MatrixIdentifiers;
3275
+ matIdsB: import("./math/matrices/matrix.js").MatrixIdentifiers;
3276
+ nodeIdsKA: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
3277
+ nodeIdsKB: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
3278
+ }, {
3279
+ typeLinComb: string;
3280
+ }> | Exercise<{
3281
+ matIdsA: import("./math/matrices/matrix.js").MatrixIdentifiers;
3282
+ matIdsB: import("./math/matrices/matrix.js").MatrixIdentifiers;
3283
+ }, Record<string, string | boolean | string[]>> | Exercise<{
3284
+ matIdsA: import("./math/matrices/matrix.js").MatrixIdentifiers;
3285
+ exponent: number;
3286
+ }, {
3287
+ exponent: string;
3288
+ }> | Exercise<{
3289
+ matIdsA: import("./math/matrices/matrix.js").MatrixIdentifiers;
3290
+ }, Record<string, string | boolean | string[]>> | Exercise<{
3291
+ matIdsA: import("./math/matrices/matrix.js").MatrixIdentifiers;
3292
+ }, Record<string, string | boolean | string[]>> | Exercise<{
3293
+ matIdsA: import("./math/matrices/matrix.js").MatrixIdentifiers;
3294
+ }, Record<string, string | boolean | string[]>> | Exercise<{
3295
+ matIdsA: import("./math/matrices/matrix.js").MatrixIdentifiers;
3296
+ }, Record<string, string | boolean | string[]>> | Exercise<{
3297
+ aIds: import("./math/matrices/matrix.js").MatrixIdentifiers;
3298
+ bIds: import("./math/matrices/matrix.js").MatrixIdentifiers;
3299
+ }, Record<string, string | boolean | string[]>> | Exercise<{
3300
+ systemIds: import("./math/systems/generalSystem.js").GeneralSystemIdentifiers;
3301
+ }, Record<string, string | boolean | string[]>> | Exercise<{
3302
+ systemIds: import("./math/systems/generalSystem.js").GeneralSystemIdentifiers;
3303
+ }, Record<string, string | boolean | string[]>> | Exercise<{
3304
+ matrixIds: import("./math/matrices/matrix.js").MatrixIdentifiers;
3305
+ }, Record<string, string | boolean | string[]>> | Exercise<{
3306
+ aIds: import("./math/matrices/matrix.js").MatrixIdentifiers;
3307
+ bIds: import("./math/matrices/matrix.js").MatrixIdentifiers;
3286
3308
  }, Record<string, string | boolean | string[]>> | Exercise<{
3287
3309
  isPercentToDecimal: boolean;
3288
3310
  nb: number;
@@ -5895,6 +5917,57 @@ declare const mathExercises: (Exercise<{
5895
5917
  nodeIdsInterval: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
5896
5918
  nodeIdsDistanceMax: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
5897
5919
  keyIncomplete: string;
5920
+ }, Record<string, string | boolean | string[]>> | Exercise<{
5921
+ graphIds: import("./math/graphs/graph.js").GraphIdentifiers;
5922
+ graphNodes: import("./math/utils/graphs/graphRenderer.js").GraphNode[];
5923
+ graphEdges: import("./math/utils/graphs/graphRenderer.js").GraphEdge[];
5924
+ }, {
5925
+ graphType: string;
5926
+ }> | Exercise<{
5927
+ graphIds: import("./math/graphs/graph.js").GraphIdentifiers;
5928
+ indexAsked: number;
5929
+ graphNodes: import("./math/utils/graphs/graphRenderer.js").GraphNode[];
5930
+ graphEdges: import("./math/utils/graphs/graphRenderer.js").GraphEdge[];
5931
+ }, {
5932
+ graphType: string;
5933
+ }> | Exercise<{
5934
+ graphIds: import("./math/graphs/graph.js").GraphIdentifiers;
5935
+ nameVertex1: string;
5936
+ nameVertex2: string;
5937
+ graphNodes: import("./math/utils/graphs/graphRenderer.js").GraphNode[];
5938
+ graphEdges: import("./math/utils/graphs/graphRenderer.js").GraphEdge[];
5939
+ }, {
5940
+ graphType: string;
5941
+ }> | Exercise<{
5942
+ graphIds1: import("./math/graphs/graph.js").GraphIdentifiers;
5943
+ graphIds2: import("./math/graphs/graph.js").GraphIdentifiers;
5944
+ graphNodes1: import("./math/utils/graphs/graphRenderer.js").GraphNode[];
5945
+ graphEdges1: import("./math/utils/graphs/graphRenderer.js").GraphEdge[];
5946
+ scale1: number;
5947
+ graphNodes2: import("./math/utils/graphs/graphRenderer.js").GraphNode[];
5948
+ graphEdges2: import("./math/utils/graphs/graphRenderer.js").GraphEdge[];
5949
+ scale2: number;
5950
+ }, {
5951
+ graphType: string;
5952
+ }> | Exercise<{
5953
+ graphIds: import("./math/graphs/graph.js").GraphIdentifiers;
5954
+ graphNodes: import("./math/utils/graphs/graphRenderer.js").GraphNode[];
5955
+ graphEdges: import("./math/utils/graphs/graphRenderer.js").GraphEdge[];
5956
+ }, Record<string, string | boolean | string[]>> | Exercise<{
5957
+ graphIds: import("./math/graphs/graph.js").GraphIdentifiers;
5958
+ lengthAsked: number;
5959
+ graphNodes: import("./math/utils/graphs/graphRenderer.js").GraphNode[];
5960
+ graphEdges: import("./math/utils/graphs/graphRenderer.js").GraphEdge[];
5961
+ }, {
5962
+ graphType: string;
5963
+ }> | Exercise<{
5964
+ degrees: number[];
5965
+ }, Record<string, string | boolean | string[]>> | Exercise<{
5966
+ matrixIds: import("./math/matrices/matrix.js").MatrixIdentifiers;
5967
+ startIndex: number;
5968
+ endIndex: number;
5969
+ }, Record<string, string | boolean | string[]>> | Exercise<{
5970
+ matrixIds: import("./math/matrices/matrix.js").MatrixIdentifiers;
5898
5971
  }, Record<string, string | boolean | string[]>> | Exercise<{
5899
5972
  a: number;
5900
5973
  mod: number;