math-exercises 3.0.215 → 3.0.217

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 (128) 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/calculLitteral/equation/exp/expOfFEqualsExpOfGEquation.d.ts.map +1 -1
  4. package/lib/exercises/math/calculLitteral/equation/exp/expOfFEqualsExpOfGEquation.js +19 -32
  5. package/lib/exercises/math/complex/unitRoots/giveOneSolutionToComplexPowNEqualsOne.js +1 -1
  6. package/lib/exercises/math/conversion/clock/index.d.ts +0 -1
  7. package/lib/exercises/math/conversion/clock/index.d.ts.map +1 -1
  8. package/lib/exercises/math/conversion/clock/index.js +1 -1
  9. package/lib/exercises/math/derivation/derivative/trigo/sinCosDerivativeRewriteUsingCos2PlusSin2Equals1.js +2 -2
  10. package/lib/exercises/math/graphs/adjacentMatrixPath.d.ts +10 -0
  11. package/lib/exercises/math/graphs/adjacentMatrixPath.d.ts.map +1 -0
  12. package/lib/exercises/math/graphs/adjacentMatrixPath.js +89 -0
  13. package/lib/exercises/math/graphs/edgesNumberFromSummitsDegrees.d.ts +7 -0
  14. package/lib/exercises/math/graphs/edgesNumberFromSummitsDegrees.d.ts.map +1 -0
  15. package/lib/exercises/math/graphs/edgesNumberFromSummitsDegrees.js +98 -0
  16. package/lib/exercises/math/graphs/eulerianChainFromAdjacentMatrix.d.ts +8 -0
  17. package/lib/exercises/math/graphs/eulerianChainFromAdjacentMatrix.d.ts.map +1 -0
  18. package/lib/exercises/math/graphs/eulerianChainFromAdjacentMatrix.js +96 -0
  19. package/lib/exercises/math/graphs/graphsChainOrPathOfLengthN.d.ts +15 -0
  20. package/lib/exercises/math/graphs/graphsChainOrPathOfLengthN.d.ts.map +1 -0
  21. package/lib/exercises/math/graphs/graphsChainOrPathOfLengthN.js +262 -0
  22. package/lib/exercises/math/graphs/graphsCheckIsConnectedGraph.d.ts +11 -0
  23. package/lib/exercises/math/graphs/graphsCheckIsConnectedGraph.d.ts.map +1 -0
  24. package/lib/exercises/math/graphs/graphsCheckIsConnectedGraph.js +178 -0
  25. package/lib/exercises/math/graphs/graphsCheckIsConnectedUndirectedGraph.d.ts +11 -0
  26. package/lib/exercises/math/graphs/graphsCheckIsConnectedUndirectedGraph.d.ts.map +1 -0
  27. package/lib/exercises/math/graphs/graphsCheckIsConnectedUndirectedGraph.js +178 -0
  28. package/lib/exercises/math/graphs/graphsCheckIsSameGraph.d.ts +19 -0
  29. package/lib/exercises/math/graphs/graphsCheckIsSameGraph.d.ts.map +1 -0
  30. package/lib/exercises/math/graphs/graphsCheckIsSameGraph.js +301 -0
  31. package/lib/exercises/math/graphs/graphsCheckIsVerticesAdjacent.d.ts +16 -0
  32. package/lib/exercises/math/graphs/graphsCheckIsVerticesAdjacent.d.ts.map +1 -0
  33. package/lib/exercises/math/graphs/graphsCheckIsVerticesAdjacent.js +207 -0
  34. package/lib/exercises/math/graphs/graphsDegreeOfVertex.d.ts +15 -0
  35. package/lib/exercises/math/graphs/graphsDegreeOfVertex.d.ts.map +1 -0
  36. package/lib/exercises/math/graphs/graphsDegreeOfVertex.js +232 -0
  37. package/lib/exercises/math/graphs/graphsOrderOfGraph.d.ts +14 -0
  38. package/lib/exercises/math/graphs/graphsOrderOfGraph.d.ts.map +1 -0
  39. package/lib/exercises/math/graphs/graphsOrderOfGraph.js +222 -0
  40. package/lib/exercises/math/graphs/index.d.ts +10 -0
  41. package/lib/exercises/math/graphs/index.d.ts.map +1 -0
  42. package/lib/exercises/math/graphs/index.js +9 -0
  43. package/lib/exercises/math/index.d.ts +1 -0
  44. package/lib/exercises/math/index.d.ts.map +1 -1
  45. package/lib/exercises/math/index.js +1 -0
  46. package/lib/exercises/math/integration/fromExpr/integralFromExpr.d.ts.map +1 -1
  47. package/lib/exercises/math/integration/fromExpr/integralFromExpr.js +2 -0
  48. package/lib/exercises/math/matrices/areMatricesInverse.d.ts +9 -0
  49. package/lib/exercises/math/matrices/areMatricesInverse.d.ts.map +1 -0
  50. package/lib/exercises/math/matrices/areMatricesInverse.js +106 -0
  51. package/lib/exercises/math/matrices/computeFixedMatrixInRecurrenceSequence.d.ts +9 -0
  52. package/lib/exercises/math/matrices/computeFixedMatrixInRecurrenceSequence.d.ts.map +1 -0
  53. package/lib/exercises/math/matrices/computeFixedMatrixInRecurrenceSequence.js +144 -0
  54. package/lib/exercises/math/matrices/findInversedMatrixFromSystem.d.ts +8 -0
  55. package/lib/exercises/math/matrices/findInversedMatrixFromSystem.d.ts.map +1 -0
  56. package/lib/exercises/math/matrices/findInversedMatrixFromSystem.js +148 -0
  57. package/lib/exercises/math/matrices/index.d.ts +12 -0
  58. package/lib/exercises/math/matrices/index.d.ts.map +1 -1
  59. package/lib/exercises/math/matrices/index.js +12 -0
  60. package/lib/exercises/math/matrices/isMatrixTransitionMatrix.d.ts +8 -0
  61. package/lib/exercises/math/matrices/isMatrixTransitionMatrix.d.ts.map +1 -0
  62. package/lib/exercises/math/matrices/isMatrixTransitionMatrix.js +132 -0
  63. package/lib/exercises/math/matrices/matrixBuildMatrixFromCoefficients.d.ts +8 -0
  64. package/lib/exercises/math/matrices/matrixBuildMatrixFromCoefficients.d.ts.map +1 -0
  65. package/lib/exercises/math/matrices/matrixBuildMatrixFromCoefficients.js +152 -0
  66. package/lib/exercises/math/matrices/matrixCheckIsSymmetrical.d.ts +8 -0
  67. package/lib/exercises/math/matrices/matrixCheckIsSymmetrical.d.ts.map +1 -0
  68. package/lib/exercises/math/matrices/matrixCheckIsSymmetrical.js +155 -0
  69. package/lib/exercises/math/matrices/matrixComputeDetOfMat2.d.ts +8 -0
  70. package/lib/exercises/math/matrices/matrixComputeDetOfMat2.d.ts.map +1 -0
  71. package/lib/exercises/math/matrices/matrixComputeDetOfMat2.js +142 -0
  72. package/lib/exercises/math/matrices/matrixComputeInverseOfMat2.d.ts +8 -0
  73. package/lib/exercises/math/matrices/matrixComputeInverseOfMat2.d.ts.map +1 -0
  74. package/lib/exercises/math/matrices/matrixComputeInverseOfMat2.js +237 -0
  75. package/lib/exercises/math/matrices/matrixComputeLinearCombination.d.ts +15 -0
  76. package/lib/exercises/math/matrices/matrixComputeLinearCombination.d.ts.map +1 -0
  77. package/lib/exercises/math/matrices/matrixComputeLinearCombination.js +232 -0
  78. package/lib/exercises/math/matrices/matrixComputePower.d.ts +12 -0
  79. package/lib/exercises/math/matrices/matrixComputePower.d.ts.map +1 -0
  80. package/lib/exercises/math/matrices/matrixComputePower.js +230 -0
  81. package/lib/exercises/math/matrices/matrixComputeProduct.d.ts +9 -0
  82. package/lib/exercises/math/matrices/matrixComputeProduct.d.ts.map +1 -0
  83. package/lib/exercises/math/matrices/matrixComputeProduct.js +178 -0
  84. package/lib/exercises/math/matrices/writeMatrixAssociatedToSystem.d.ts +8 -0
  85. package/lib/exercises/math/matrices/writeMatrixAssociatedToSystem.d.ts.map +1 -0
  86. package/lib/exercises/math/matrices/writeMatrixAssociatedToSystem.js +105 -0
  87. package/lib/exercises/math/spaceGeometry/parametricLine/lineLineRelativePositionsFromParametricLines.d.ts.map +1 -1
  88. package/lib/exercises/math/spaceGeometry/parametricLine/lineLineRelativePositionsFromParametricLines.js +56 -3
  89. package/lib/exercises/math/spaceGeometry/planes/findNormalVectorFromPlaneEquation.d.ts.map +1 -1
  90. package/lib/exercises/math/spaceGeometry/planes/findNormalVectorFromPlaneEquation.js +6 -0
  91. package/lib/exercises/vea/matrixVEA.d.ts +2 -0
  92. package/lib/exercises/vea/matrixVEA.d.ts.map +1 -0
  93. package/lib/exercises/vea/matrixVEA.js +1 -0
  94. package/lib/exercises/vea/treeTableVEA.d.ts.map +1 -1
  95. package/lib/exercises/vea/treeTableVEA.js +2 -0
  96. package/lib/index.d.ts +86 -13
  97. package/lib/index.d.ts.map +1 -1
  98. package/lib/math/geometry/point.d.ts.map +1 -1
  99. package/lib/math/geometry/point.js +3 -1
  100. package/lib/math/graphs/graph.d.ts +43 -0
  101. package/lib/math/graphs/graph.d.ts.map +1 -0
  102. package/lib/math/graphs/graph.js +447 -0
  103. package/lib/math/matrices/matrix.d.ts +42 -3
  104. package/lib/math/matrices/matrix.d.ts.map +1 -1
  105. package/lib/math/matrices/matrix.js +173 -7
  106. package/lib/math/matrices/parseMatrix.d.ts +3 -0
  107. package/lib/math/matrices/parseMatrix.d.ts.map +1 -0
  108. package/lib/math/matrices/parseMatrix.js +22 -0
  109. package/lib/math/systems/generalSystem.d.ts +2 -0
  110. package/lib/math/systems/generalSystem.d.ts.map +1 -1
  111. package/lib/math/systems/generalSystem.js +5 -0
  112. package/lib/math/utils/graphs/graphRenderer.d.ts +25 -0
  113. package/lib/math/utils/graphs/graphRenderer.d.ts.map +1 -0
  114. package/lib/math/utils/graphs/graphRenderer.js +123 -0
  115. package/lib/playground.d.ts +6 -1
  116. package/lib/playground.d.ts.map +1 -1
  117. package/lib/playground.js +6 -5
  118. package/lib/tree/parsers/latexParser.d.ts +1 -1
  119. package/lib/tree/utilities/nodeSimplifier.d.ts +1 -1
  120. package/lib/types/keyIds.d.ts +2 -0
  121. package/lib/types/keyIds.d.ts.map +1 -1
  122. package/lib/utils/arrays/arrayChunks.d.ts +9 -0
  123. package/lib/utils/arrays/arrayChunks.d.ts.map +1 -0
  124. package/lib/utils/arrays/arrayChunks.js +34 -0
  125. package/lib/utils/strings/ordinalSuffixed.d.ts +2 -0
  126. package/lib/utils/strings/ordinalSuffixed.d.ts.map +1 -0
  127. package/lib/utils/strings/ordinalSuffixed.js +5 -0
  128. package/package.json +7 -1
@@ -0,0 +1,144 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, propWhile, } from "../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
+ import { rationalVEA } from "../../../exercises/vea/rationalVEA.js";
4
+ import { Vector, VectorConstructor } from "../../../math/geometry/vector.js";
5
+ import { MatrixConstructor, } from "../../../math/matrices/matrix.js";
6
+ import { binom, isBinomialCoefficientNode, } from "../../../tree/nodes/operators/binomialCoefficientNode.js";
7
+ import { parseAlgebraic } from "../../../tree/parsers/latexParser.js";
8
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
9
+ import { alignTex } from "../../../utils/latex/alignTex.js";
10
+ const getPropositions = (n, { answer }) => {
11
+ const propositions = [];
12
+ addValidProp(propositions, answer);
13
+ propWhile(propositions, n, () => {
14
+ tryToAddWrongProp(propositions, VectorConstructor.random("u").toBinomCoords().toTex());
15
+ });
16
+ return shuffleProps(propositions, n);
17
+ };
18
+ const getAnswer = (identifiers) => {
19
+ //u = (I-A)^(-1) * b
20
+ const { aIds, bIds } = identifiers;
21
+ const a = MatrixConstructor.fromIdentifiers(aIds);
22
+ const b = MatrixConstructor.fromIdentifiers(bIds);
23
+ const id = MatrixConstructor.identity(2);
24
+ const sub = id.substract(a).simplify();
25
+ const inv = sub.toInversed().simplify();
26
+ const u = inv.matrixProduct(b).simplify();
27
+ const vec = binom(u.elements[0][0], u.elements[1][0]);
28
+ return vec.toTex();
29
+ };
30
+ const getInstruction = (identifiers) => {
31
+ const { aIds, bIds } = identifiers;
32
+ const a = MatrixConstructor.fromIdentifiers(aIds);
33
+ const b = MatrixConstructor.fromIdentifiers(bIds);
34
+ return `Soient :
35
+
36
+ $$
37
+ A=${a.toTex()}, B=${b.toTex()}
38
+ $$
39
+
40
+ Déterminer une matrice colonne $U$ tel que :
41
+
42
+ $$
43
+ U = AU+B
44
+ $$
45
+ `;
46
+ };
47
+ const getHint = () => {
48
+ return `Isole $U$ d'un côté de l'équation. Puis, utilise la calculatrice pour déterminer l'inverse d'une certaine matrice.`;
49
+ };
50
+ const getCorrection = (identifiers) => {
51
+ const { aIds, bIds } = identifiers;
52
+ const a = MatrixConstructor.fromIdentifiers(aIds);
53
+ const b = MatrixConstructor.fromIdentifiers(bIds);
54
+ const id = MatrixConstructor.identity(2);
55
+ const iMinusA = id.substract(a);
56
+ const inv = iMinusA.toInversed().simplify();
57
+ return `On a :
58
+
59
+ ${alignTex([
60
+ ["U=AU+B", "\\iff", "U-AU=B"],
61
+ ["", "\\iff", "(I_2-A)U=B"],
62
+ ])}
63
+
64
+ donc $U = (I_2-A)^{-1}B$.
65
+
66
+ Or,
67
+
68
+ $$
69
+ I_2-A = ${iMinusA.toTex()} = ${iMinusA.simplify().toTex()}
70
+ $$
71
+
72
+ Avec la calculatrice, ou en résolvant un système d'équations, on trouve :
73
+
74
+ $$
75
+ (I_2-A)^{-1} = ${inv.toTex()}
76
+ $$
77
+
78
+ et donc
79
+
80
+ $$
81
+ U = ${inv.toTex()}${b.toTex()} = ${getAnswer(identifiers)}
82
+ $$
83
+ `;
84
+ };
85
+ const getKeys = () => {
86
+ return ["binom"];
87
+ };
88
+ const isAnswerValid = (ans, { answer }) => {
89
+ try {
90
+ const sol = parseAlgebraic(answer);
91
+ const solVector = new Vector("u", sol.leftChild, sol.rightChild);
92
+ const parsed = parseAlgebraic(ans);
93
+ if (!isBinomialCoefficientNode(parsed))
94
+ return false;
95
+ const vec = new Vector("u", parsed.leftChild, parsed.rightChild).simplify();
96
+ return (rationalVEA(solVector.x.toTex(), vec.x.toTex()) &&
97
+ rationalVEA(solVector.y.toTex(), vec.y.toTex()));
98
+ }
99
+ catch (err) {
100
+ return handleVEAError(err);
101
+ }
102
+ };
103
+ const getComputeFixedMatrixInRecurrenceSequenceQuestion = () => {
104
+ const iMinusA = MatrixConstructor.randomInversible(2, 2, {
105
+ niceInversible: true,
106
+ });
107
+ const id = MatrixConstructor.identity(2);
108
+ const a = id.substract(iMinusA).simplify();
109
+ const b = MatrixConstructor.random(2, 1);
110
+ const identifiers = {
111
+ aIds: a.toIdentifiers(),
112
+ bIds: b.toIdentifiers(),
113
+ };
114
+ return getQuestionFromIdentifiers(identifiers);
115
+ };
116
+ const getQuestionFromIdentifiers = (identifiers) => {
117
+ return {
118
+ answer: getAnswer(identifiers),
119
+ instruction: getInstruction(identifiers),
120
+ keys: getKeys(identifiers),
121
+ answerFormat: "tex",
122
+ identifiers,
123
+ hint: getHint(identifiers),
124
+ correction: getCorrection(identifiers),
125
+ };
126
+ };
127
+ export const computeFixedMatrixInRecurrenceSequence = {
128
+ id: "computeFixedMatrixInRecurrenceSequence",
129
+ connector: "=",
130
+ label: "Déterminer une matrice $U$ tel que $U = AU+B$",
131
+ isSingleStep: true,
132
+ generator: (nb, opts) => getDistinctQuestions(() => getComputeFixedMatrixInRecurrenceSequenceQuestion(opts), nb),
133
+ qcmTimer: 60,
134
+ freeTimer: 60,
135
+ getPropositions,
136
+ isAnswerValid,
137
+ subject: "Mathématiques",
138
+ getInstruction,
139
+ getHint,
140
+ getCorrection,
141
+ getAnswer,
142
+ getQuestionFromIdentifiers,
143
+ hasHintAndCorrection: true,
144
+ };
@@ -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 findInversedMatrixFromSystem: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=findInversedMatrixFromSystem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findInversedMatrixFromSystem.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/matrices/findInversedMatrixFromSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAGL,wBAAwB,EACzB,MAAM,qCAAqC,CAAC;AAG7C,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,wBAAwB,CAAC;CACrC,CAAC;AA0IF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAsB9D,CAAC"}
@@ -0,0 +1,148 @@
1
+ import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
+ import { MatrixConstructor } from "../../../math/matrices/matrix.js";
4
+ import { parseMatrix } from "../../../math/matrices/parseMatrix.js";
5
+ import { GeneralSystem, 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
+ const matrix = MatrixConstructor.randomInversible(2, 2, {
12
+ niceInversible: true,
13
+ elementsOpts: [-10, 10, [0]],
14
+ });
15
+ const inv = matrix.toInversed().simplify();
16
+ tryToAddWrongProp(propositions, inv.toTex());
17
+ });
18
+ return shuffleProps(propositions, n);
19
+ };
20
+ const getAnswer = (identifiers) => {
21
+ const { systemIds } = identifiers;
22
+ const system = GeneralSystemConstructor.fromIdentifiers(systemIds);
23
+ const matrix = system.getMatrix();
24
+ return matrix.toInversed().simplify().toTex();
25
+ };
26
+ const getInstruction = (identifiers) => {
27
+ const { systemIds } = identifiers;
28
+ const system = GeneralSystemConstructor.fromIdentifiers(systemIds);
29
+ const matrix = system.getMatrix();
30
+ return `On considère la matrice :
31
+
32
+ $$
33
+ A = ${matrix.toTex()}
34
+ $$
35
+
36
+ et le système d'inconnues $x$ et $y$, où $a$ et $b$ sont des réels :
37
+
38
+ $$
39
+ ${system.toTex()}
40
+ $$
41
+
42
+ Résoudre le système, puis en déduire la matrice inverse de $A$.`;
43
+ };
44
+ const getHint = () => {
45
+ return `Commence par résoudre le système.
46
+
47
+ Puis, utilise le fait que si $A$ est inversible, alors $AX=B \\iff X = A^{-1}B$.`;
48
+ };
49
+ const getCorrection = (identifiers) => {
50
+ const { systemIds } = identifiers;
51
+ const system = GeneralSystemConstructor.fromIdentifiers(systemIds);
52
+ const { x, y } = system.solve();
53
+ const matrix = system.getMatrix();
54
+ return `On résout le système, on trouve :
55
+
56
+ $$
57
+ \\left\\{\\begin{matrix}
58
+ x & = & ${x
59
+ .simplify({
60
+ towardsDistribute: true,
61
+ forbidFactorize: true,
62
+ forceDistributeFractions: true,
63
+ })
64
+ .toTex()}\\\\
65
+ y & = & ${y
66
+ .simplify({
67
+ towardsDistribute: true,
68
+ forbidFactorize: true,
69
+ forceDistributeFractions: true,
70
+ })
71
+ .toTex()}
72
+ \\end{matrix}\\right.
73
+ $$
74
+
75
+ Or, ce système est équivalent à $AX = B$ avec :
76
+
77
+ $$
78
+ A=${matrix.toTex()}, X = \\begin{pmatrix}x\\\\ y\\end{pmatrix}, B = \\begin{pmatrix}a\\\\ b\\end{pmatrix}
79
+ $$
80
+
81
+ On a alors :
82
+
83
+ $$
84
+ AX = B \\iff X = A^{-1} B
85
+ $$
86
+
87
+ donc
88
+
89
+ $$
90
+ A^{-1} = ${matrix.toInversed().simplify().toTex()}
91
+ $$`;
92
+ };
93
+ const getKeys = () => {
94
+ return ["mat-2-2"];
95
+ };
96
+ const isAnswerValid = (ans, { answer }) => {
97
+ try {
98
+ const matAns = parseMatrix(ans);
99
+ const matAnswer = parseMatrix(answer);
100
+ return matAns.equals(matAnswer);
101
+ }
102
+ catch (err) {
103
+ return handleVEAError(err);
104
+ }
105
+ };
106
+ const getFindInversedMatrixFromSystemQuestion = () => {
107
+ const matrix = MatrixConstructor.randomInversible(2, 2, {
108
+ niceInversible: true,
109
+ elementsOpts: [-10, 10, [0]],
110
+ });
111
+ const sys = new GeneralSystem(matrix.elements.map((row, i) => [
112
+ ...row,
113
+ String.fromCharCode(97 + i).toTree(),
114
+ ]));
115
+ const identifiers = {
116
+ systemIds: sys.toIdentifiers(),
117
+ };
118
+ return getQuestionFromIdentifiers(identifiers);
119
+ };
120
+ const getQuestionFromIdentifiers = (identifiers) => {
121
+ return {
122
+ answer: getAnswer(identifiers),
123
+ instruction: getInstruction(identifiers),
124
+ keys: getKeys(identifiers),
125
+ answerFormat: "tex",
126
+ identifiers,
127
+ hint: getHint(identifiers),
128
+ correction: getCorrection(identifiers),
129
+ };
130
+ };
131
+ export const findInversedMatrixFromSystem = {
132
+ id: "findInversedMatrixFromSystem",
133
+ connector: "=",
134
+ label: "Déterminer l'inverse d'une matrice en résolvant un système d'équations linéaires",
135
+ isSingleStep: true,
136
+ generator: (nb, opts) => getDistinctQuestions(() => getFindInversedMatrixFromSystemQuestion(opts), nb),
137
+ qcmTimer: 60,
138
+ freeTimer: 60,
139
+ getPropositions,
140
+ isAnswerValid,
141
+ subject: "Mathématiques",
142
+ getInstruction,
143
+ getHint,
144
+ getCorrection,
145
+ getAnswer,
146
+ getQuestionFromIdentifiers,
147
+ hasHintAndCorrection: true,
148
+ };
@@ -1,3 +1,15 @@
1
1
  export * from "./matrixInversibilityDomain.js";
2
2
  export * from "./productCell.js";
3
+ export * from "./matrixComputeLinearCombination.js";
4
+ export * from "./matrixComputeProduct.js";
5
+ export * from "./matrixComputePower.js";
6
+ export * from "./matrixBuildMatrixFromCoefficients.js";
7
+ export * from "./matrixComputeDetOfMat2.js";
8
+ export * from "./matrixComputeInverseOfMat2.js";
9
+ export * from "./matrixCheckIsSymmetrical.js";
10
+ export * from "./areMatricesInverse.js";
11
+ export * from "./writeMatrixAssociatedToSystem.js";
12
+ export * from "./findInversedMatrixFromSystem.js";
13
+ export * from "./isMatrixTransitionMatrix.js";
14
+ export * from "./computeFixedMatrixInRecurrenceSequence.js";
3
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/matrices/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/matrices/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AAGjC,cAAc,qCAAqC,CAAC;AACpD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wCAAwC,CAAC;AACvD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC;AACxC,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6CAA6C,CAAC"}
@@ -1,3 +1,15 @@
1
1
  export * from "./matrixInversibilityDomain.js";
2
2
  export * from "./productCell.js";
3
3
  // export * from "./matrixGeneralTerm.js";
4
+ export * from "./matrixComputeLinearCombination.js";
5
+ export * from "./matrixComputeProduct.js";
6
+ export * from "./matrixComputePower.js";
7
+ export * from "./matrixBuildMatrixFromCoefficients.js";
8
+ export * from "./matrixComputeDetOfMat2.js";
9
+ export * from "./matrixComputeInverseOfMat2.js";
10
+ export * from "./matrixCheckIsSymmetrical.js";
11
+ export * from "./areMatricesInverse.js";
12
+ export * from "./writeMatrixAssociatedToSystem.js";
13
+ export * from "./findInversedMatrixFromSystem.js";
14
+ export * from "./isMatrixTransitionMatrix.js";
15
+ export * from "./computeFixedMatrixInRecurrenceSequence.js";
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ import { MatrixIdentifiers } from "../../../math/matrices/matrix.js";
3
+ type Identifiers = {
4
+ matrixIds: MatrixIdentifiers;
5
+ };
6
+ export declare const isMatrixTransitionMatrix: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=isMatrixTransitionMatrix.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isMatrixTransitionMatrix.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/matrices/isMatrixTransitionMatrix.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAGL,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AAUvC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,iBAAiB,CAAC;CAC9B,CAAC;AAgIF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAiB1D,CAAC"}
@@ -0,0 +1,132 @@
1
+ import { addValidProp, 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 { RationalConstructor } from "../../../math/numbers/rationals/rational.js";
5
+ import { randfloat } from "../../../math/utils/random/randfloat.js";
6
+ import { AddNode } from "../../../tree/nodes/operators/addNode.js";
7
+ import { substract } from "../../../tree/nodes/operators/substractNode.js";
8
+ import { operatorComposition } from "../../../tree/utilities/operatorComposition.js";
9
+ import { coinFlip } from "../../../utils/alea/coinFlip.js";
10
+ import { doWhile } from "../../../utils/doWhile.js";
11
+ const getPropositions = (n, { answer }) => {
12
+ const propositions = [];
13
+ addValidProp(propositions, answer, "raw");
14
+ tryToAddWrongProp(propositions, "Oui", "raw");
15
+ tryToAddWrongProp(propositions, "Non", "raw");
16
+ return shuffleProps(propositions, n);
17
+ };
18
+ const getAnswer = (identifiers) => {
19
+ const { matrixIds } = identifiers;
20
+ const matrix = MatrixConstructor.fromIdentifiers(matrixIds);
21
+ return matrix.isTransition() ? "Oui" : "Non";
22
+ };
23
+ const getInstruction = (identifiers) => {
24
+ const { matrixIds } = identifiers;
25
+ const matrix = MatrixConstructor.fromIdentifiers(matrixIds);
26
+ return `On considère la matrice $P$ ci-dessous :
27
+
28
+ $$
29
+ P = ${matrix.toTex()}
30
+ $$
31
+
32
+ $P$ est-elle une matrice de transition ?`;
33
+ };
34
+ const getHint = () => {
35
+ return `Une matrice de transition est une matrice associée à un graphe probabiliste, où le terme à la $i$-ème ligne et à la $j$-ème colonne est égale au poids de l'arête allant du sommet $i$ au sommet $j$ si elle existe, $0$ sinon.
36
+
37
+ Une matrice de transition est donc composée de probabilités, et la somme de chaque ligne doit valoir $1$.`;
38
+ };
39
+ const getCorrection = (identifiers) => {
40
+ const { matrixIds } = identifiers;
41
+ const matrix = MatrixConstructor.fromIdentifiers(matrixIds);
42
+ const nonProba = matrix.elements
43
+ .flat()
44
+ .find((x) => x.evaluate() < 0 || x.evaluate() > 1);
45
+ const lineNotOne = matrix.elements.find((line) => line.reduce((acc, el) => acc + el.evaluate(), 0) !== 1);
46
+ const hasNoProba = !!nonProba;
47
+ const hasLineNotOne = !!lineNotOne;
48
+ return `Une matrice est une matrice de transition si :
49
+
50
+ - elle est carrée ;
51
+ - ses éléments sont des nombres compris entre $0$ et $1$ ;
52
+ - la somme de chacune de ses lignes vaut $1$.
53
+
54
+ La matrice proposée est bien carrée.
55
+
56
+ ${hasNoProba
57
+ ? `Cependant, au moins un de ses éléments n'est pas compris entre $0$ et $1$, puisque la matrice contient $${nonProba?.toTex()}$.
58
+
59
+ Ce n'est donc pas une matrice de transition.`
60
+ : `Ses éléments sont bien des nombres entre $0$ et $1$.`}
61
+
62
+ ${!hasNoProba &&
63
+ (hasLineNotOne
64
+ ? `Cependant, la somme d'au moins une de ses lignes de vaut pas $1$ :
65
+
66
+ $$
67
+ ${operatorComposition(AddNode, lineNotOne).toSimplificationTex()}
68
+ $$
69
+
70
+ Ce n'est donc pas une matrice de transition.
71
+ `
72
+ : `La somme de chacune de ses lignes vaut bien $1$.
73
+
74
+ C'est donc bien une matrice de transition.`)}
75
+ `;
76
+ };
77
+ const getIsMatrixTransitionMatrixQuestion = () => {
78
+ let b;
79
+ let d;
80
+ const isTransition = coinFlip();
81
+ const isRational = coinFlip();
82
+ const getValue = () => isRational
83
+ ? RationalConstructor.randomIrreductibleProba().toTree()
84
+ : randfloat(0.01, 1, 2).toTree();
85
+ const a = getValue();
86
+ const c = getValue();
87
+ if (isTransition) {
88
+ b = substract(1, a).simplify();
89
+ d = substract(1, c).simplify();
90
+ }
91
+ else {
92
+ [b, d] = doWhile(() => [getValue(), getValue()], ([x, y]) => new Matrix([
93
+ [a, x],
94
+ [c, y],
95
+ ]).isTransition());
96
+ }
97
+ const identifiers = {
98
+ matrixIds: new Matrix([
99
+ [a, b],
100
+ [c, d],
101
+ ]).toIdentifiers(),
102
+ };
103
+ return getQuestionFromIdentifiers(identifiers);
104
+ };
105
+ const getQuestionFromIdentifiers = (identifiers) => {
106
+ return {
107
+ answer: getAnswer(identifiers),
108
+ instruction: getInstruction(identifiers),
109
+ keys: [],
110
+ answerFormat: "tex",
111
+ identifiers,
112
+ hint: getHint(identifiers),
113
+ correction: getCorrection(identifiers),
114
+ };
115
+ };
116
+ export const isMatrixTransitionMatrix = {
117
+ id: "isMatrixTransitionMatrix",
118
+ label: "Déterminer si une matrice est une matrice de transition",
119
+ isSingleStep: true,
120
+ generator: (nb, opts) => getDistinctQuestions(() => getIsMatrixTransitionMatrixQuestion(opts), nb),
121
+ qcmTimer: 60,
122
+ freeTimer: 60,
123
+ getPropositions,
124
+ answerType: "QCU",
125
+ subject: "Mathématiques",
126
+ getInstruction,
127
+ getHint,
128
+ getCorrection,
129
+ getAnswer,
130
+ getQuestionFromIdentifiers,
131
+ hasHintAndCorrection: true,
132
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ import { MatrixIdentifiers } from "../../../math/matrices/matrix.js";
3
+ type Identifiers = {
4
+ matIdsA: MatrixIdentifiers;
5
+ };
6
+ export declare const matrixBuildMatrixFromCoefficients: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=matrixBuildMatrixFromCoefficients.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matrixBuildMatrixFromCoefficients.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/matrices/matrixBuildMatrixFromCoefficients.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAGL,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AAMvC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,iBAAiB,CAAC;CAC5B,CAAC;AA4KF,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,WAAW,CAkBnE,CAAC"}
@@ -0,0 +1,152 @@
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 { arrayRotation } from "../../../utils/arrays/rotation.js";
6
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
7
+ const getHydrated = (identifiers) => {
8
+ const { matIdsA } = identifiers;
9
+ const [matA] = [matIdsA].map((matIds) => MatrixConstructor.fromIdentifiers(matIds));
10
+ const dictCoeffs = Object.fromEntries(matA.elements.flatMap((row, i) => row.map((elt, j) => [`a_{${i + 1},${j + 1}}`, elt])));
11
+ return {
12
+ matA,
13
+ dictCoeffs,
14
+ };
15
+ };
16
+ const getInstruction = (identifiers) => {
17
+ const { dictCoeffs } = getHydrated(identifiers);
18
+ return `Soit :
19
+
20
+ $$
21
+ A = (a_{i,j})
22
+ $$
23
+
24
+ On donne :
25
+
26
+ ${Object.entries(dictCoeffs)
27
+ .map(([tex, node]) => `
28
+
29
+ $$
30
+ ${tex} = ${node.toTex()}
31
+ $$
32
+
33
+ Écrire la matrice $A$.
34
+ `)
35
+ .join("")}`;
36
+ };
37
+ const getAnswer = (identifiers) => {
38
+ const { matA } = getHydrated(identifiers);
39
+ return matA.toTex();
40
+ };
41
+ const getHint = () => {
42
+ const matA = new Matrix([
43
+ ["a".toTree(), "b".toTree()],
44
+ ["c".toTree(), "d".toTree()],
45
+ ]);
46
+ return `Soient $A$ une matrice à $2$ lignes et $2$ colonnes à coefficients réels.
47
+
48
+ $$
49
+ A = ${matA.toTex()}
50
+ $$
51
+
52
+ Dans l'expression des coefficients de $A$ (à savoir $A=(a_{ij})$), $i$ correspond à la ligne et $j$ correspond à la colonne.
53
+ Ici, par exemple :
54
+
55
+ $$
56
+ a_{21} = c
57
+ $$
58
+
59
+ `;
60
+ };
61
+ const getCorrection = (identifiers) => {
62
+ const { matA } = getHydrated(identifiers);
63
+ return `Dans l'expression des coefficients de $A$ (à savoir $A=(a_{ij})$), $i$ correspond à la ligne et $j$ correspond à la colonne.
64
+
65
+ $$
66
+ A = ${matA.toTex()}
67
+ $$
68
+
69
+ `;
70
+ };
71
+ const getPropositions = (n, { answer, ...identifiers }) => {
72
+ const propositions = [];
73
+ addValidProp(propositions, answer);
74
+ const { matA } = getHydrated(identifiers);
75
+ //student a_{ij} -> a_{ji}
76
+ {
77
+ const matWrong = matA.transposed();
78
+ tryToAddWrongProp(propositions, matWrong.toTex());
79
+ }
80
+ //student: a_{12} -> a_{02}
81
+ {
82
+ const elementsShifted = arrayRotation(matA.elements, 1);
83
+ const matWrong = new Matrix(elementsShifted);
84
+ tryToAddWrongProp(propositions, matWrong.toTex());
85
+ }
86
+ //student: a_{ij} -> a_{ji} and a_{12} -> a_{02}
87
+ {
88
+ const elementsShifted = arrayRotation(matA.elements, 1);
89
+ const matWrong = new Matrix(elementsShifted).transposed();
90
+ tryToAddWrongProp(propositions, matWrong.toTex());
91
+ }
92
+ //filler
93
+ {
94
+ propWhile(propositions, n, () => {
95
+ const identifiersWrong = createRandomIdentifiers();
96
+ tryToAddWrongProp(propositions, getAnswer(identifiersWrong));
97
+ });
98
+ }
99
+ return shuffleProps(propositions, n);
100
+ };
101
+ const getKeys = () => {
102
+ return ["mat-2-2"];
103
+ };
104
+ const isAnswerValid = (ans, { answer }) => {
105
+ try {
106
+ const matAns = parseMatrix(ans);
107
+ const matAnswer = parseMatrix(answer);
108
+ return matAns.equals(matAnswer);
109
+ }
110
+ catch (e) {
111
+ handleVEAError(e);
112
+ return false;
113
+ }
114
+ };
115
+ const createRandomIdentifiers = () => {
116
+ const matA = MatrixConstructor.random(2, 2);
117
+ const identifiers = {
118
+ matIdsA: matA.toIdentifiers(),
119
+ };
120
+ return identifiers;
121
+ };
122
+ const getMatrixBuildMatrixFromCoefficientsQuestion = () => {
123
+ const identifiers = createRandomIdentifiers();
124
+ return getQuestionFromIdentifiers(identifiers);
125
+ };
126
+ const getQuestionFromIdentifiers = (identifiers, optsIn) => {
127
+ const question = {
128
+ answer: getAnswer(identifiers),
129
+ instruction: getInstruction(identifiers),
130
+ keys: getKeys(identifiers),
131
+ answerFormat: "tex",
132
+ identifiers,
133
+ hint: getHint(identifiers),
134
+ correction: getCorrection(identifiers),
135
+ options: optsIn,
136
+ };
137
+ return question;
138
+ };
139
+ export const matrixBuildMatrixFromCoefficients = {
140
+ id: "matrixBuildMatrixFromCoefficients",
141
+ connector: "=",
142
+ label: "Écrire une matrice à partir de la donnée de ses coefficients $a_{ij}$",
143
+ isSingleStep: true,
144
+ generator: (nb, opts) => getDistinctQuestions(() => getMatrixBuildMatrixFromCoefficientsQuestion(opts), nb),
145
+ qcmTimer: 60,
146
+ freeTimer: 60,
147
+ getPropositions,
148
+ isAnswerValid,
149
+ subject: "Mathématiques",
150
+ getQuestionFromIdentifiers,
151
+ hasHintAndCorrection: true,
152
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ import { MatrixIdentifiers } from "../../../math/matrices/matrix.js";
3
+ type Identifiers = {
4
+ matIdsA: MatrixIdentifiers;
5
+ };
6
+ export declare const matrixCheckIsSymmetrical: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=matrixCheckIsSymmetrical.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matrixCheckIsSymmetrical.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/matrices/matrixCheckIsSymmetrical.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAGL,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AAsBvC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,iBAAiB,CAAC;CAC5B,CAAC;AAoJF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAc1D,CAAC"}