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,222 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, propWhile, GeneratorOptionTarget, GeneratorOptionType, } from "../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
+ import { defaultArrayedOptsWhereNeeded } from "../../../exercises/utils/options/arrayedOptions.js";
4
+ import { greenMain } from "../../../geogebra/colors.js";
5
+ import { GeogebraConstructor } from "../../../geogebra/geogebraConstructor.js";
6
+ import { Point } from "../../../math/geometry/point.js";
7
+ import { GraphConstructor } from "../../../math/graphs/graph.js";
8
+ import { GraphRenderer, } from "../../../math/utils/graphs/graphRenderer.js";
9
+ import { randint } from "../../../math/utils/random/randint.js";
10
+ import { parseAlgebraic } from "../../../tree/parsers/latexParser.js";
11
+ import { NodeComparator } from "../../../tree/utilities/nodeComparator.js";
12
+ import { coinFlip } from "../../../utils/alea/coinFlip.js";
13
+ import { probaFlip } from "../../../utils/alea/probaFlip.js";
14
+ import { random } from "../../../utils/alea/random.js";
15
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
16
+ import { joinanded } from "../../../utils/strings/joinanded.js";
17
+ const getHydrated = (identifiers) => {
18
+ const { graphIds } = identifiers;
19
+ const graph = GraphConstructor.fromIdentifiers(graphIds);
20
+ return {
21
+ graph,
22
+ };
23
+ };
24
+ const getInstruction = () => {
25
+ return `Un graphe est représenté ci-dessous.
26
+ Quel est son ordre ?`;
27
+ };
28
+ const getAnswerNode = (identifiers) => {
29
+ const { graph } = getHydrated(identifiers);
30
+ return graph.vertexNames.length.toTree();
31
+ };
32
+ const getAnswer = (identifiers) => {
33
+ return getAnswerNode(identifiers).toTex();
34
+ };
35
+ const getHint = () => {
36
+ return `L'ordre d'un graphe est le nombre de sommets dont il est composé.`;
37
+ };
38
+ const getCorrection = (identifiers) => {
39
+ const { graph } = getHydrated(identifiers);
40
+ return `Le graphe a pour sommets ${joinanded(graph.vertexNames.map((nameVertex) => `$${nameVertex}$`), ", ", " et ")}.
41
+
42
+ L'ordre du graphe est donc $${graph.vertexNames.length.frenchify()}$.`;
43
+ };
44
+ const getCorrectionGGBOptions = (identifiers) => {
45
+ const { graphNodes, graphEdges } = identifiers;
46
+ const { graph } = getHydrated(identifiers);
47
+ const arrPoint = graphNodes.map(({ label, x, y }) => new Point(label, x, y));
48
+ const pointCommands = arrPoint.flatMap((point) => point.toGGBCommand({
49
+ isFixed: false,
50
+ isSelectionnable: true,
51
+ showLabel: true,
52
+ style: 0,
53
+ size: 8,
54
+ color: greenMain,
55
+ }));
56
+ const edgeCommands = graphEdges.flatMap((e, i) => {
57
+ return [
58
+ graph.isDirected
59
+ ? `edge${i + 1} = Vector(${e.from}, ${e.to})`
60
+ : `edge${i + 1} = Segment(${e.from}, ${e.to})`,
61
+ ];
62
+ });
63
+ const ggb = new GeogebraConstructor({
64
+ commands: [...pointCommands, ...edgeCommands],
65
+ fontSize: 16,
66
+ hideAxes: true,
67
+ hideGrid: true,
68
+ });
69
+ return ggb.getOptions({
70
+ coords: ggb.getCoordsForPoints(arrPoint),
71
+ });
72
+ };
73
+ const getGGBOptions = (identifiers) => {
74
+ const { graphNodes, graphEdges } = identifiers;
75
+ const { graph } = getHydrated(identifiers);
76
+ const arrPoint = graphNodes.map(({ label, x, y }) => new Point(label, x, y));
77
+ const pointCommands = arrPoint.flatMap((point) => point.toGGBCommand({
78
+ isFixed: false,
79
+ isSelectionnable: true,
80
+ showLabel: true,
81
+ style: 0,
82
+ size: 8,
83
+ }));
84
+ const edgeCommands = graphEdges.map((e, i) => graph.isDirected
85
+ ? `v${i + 1} = Vector(${e.from}, ${e.to})`
86
+ : `s${i + 1} = Segment(${e.from}, ${e.to})`);
87
+ const arrGGBCommandForGraph = [...pointCommands, ...edgeCommands];
88
+ const ggb = new GeogebraConstructor({
89
+ commands: [...arrGGBCommandForGraph],
90
+ fontSize: 16,
91
+ hideAxes: true,
92
+ hideGrid: true,
93
+ });
94
+ return ggb.getOptions({
95
+ coords: ggb.getCoordsForPoints(arrPoint),
96
+ });
97
+ };
98
+ const getPropositions = (n, { answer, ...identifiers }) => {
99
+ const propositions = [];
100
+ addValidProp(propositions, answer);
101
+ const { graphEdges } = identifiers;
102
+ const { graph } = getHydrated(identifiers);
103
+ const isTerror = probaFlip(0.4);
104
+ //student: number of edges
105
+ {
106
+ const nbWrong = graphEdges.length;
107
+ tryToAddWrongProp(propositions, nbWrong.frenchify());
108
+ if (isTerror) {
109
+ if (coinFlip()) {
110
+ tryToAddWrongProp(propositions, (nbWrong - 1).frenchify());
111
+ }
112
+ if (coinFlip()) {
113
+ tryToAddWrongProp(propositions, (nbWrong + 1).frenchify());
114
+ }
115
+ }
116
+ }
117
+ //student: counting mistake (offset)
118
+ if (!isTerror) {
119
+ const nbAnswer = graph.vertexNames.length;
120
+ if (coinFlip()) {
121
+ tryToAddWrongProp(propositions, (nbAnswer - 1).frenchify());
122
+ }
123
+ if (coinFlip()) {
124
+ tryToAddWrongProp(propositions, (nbAnswer + 1).frenchify());
125
+ }
126
+ }
127
+ //filler
128
+ propWhile(propositions, n, () => {
129
+ const nbWrong = randint(5, 15);
130
+ tryToAddWrongProp(propositions, nbWrong.frenchify());
131
+ });
132
+ return shuffleProps(propositions, n);
133
+ };
134
+ const getKeys = () => {
135
+ return [];
136
+ };
137
+ const isAnswerValid = (ans, { answer }) => {
138
+ try {
139
+ const [nodeAns, nodeAnswer] = [ans, answer].map((str) => parseAlgebraic(str));
140
+ return NodeComparator.isEqualViaSub(nodeAns, nodeAnswer);
141
+ }
142
+ catch (err) {
143
+ return handleVEAError(err);
144
+ }
145
+ };
146
+ const createRandomIdentifiers = (isDirected) => {
147
+ const nbVertices = randint(5, 10);
148
+ const isSimple = true;
149
+ const minDensity = (() => {
150
+ switch (nbVertices) {
151
+ case 5:
152
+ return isDirected ? 0.4 : 0.62;
153
+ case 6:
154
+ return isDirected ? 0.35 : 0.57;
155
+ case 7:
156
+ return isDirected ? 0.3 : 0.52;
157
+ case 8:
158
+ return isDirected ? 0.27 : 0.37;
159
+ case 9:
160
+ return isDirected ? 0.24 : 0.32;
161
+ }
162
+ })();
163
+ const graph = GraphConstructor.random(nbVertices, isSimple, isDirected, minDensity, "ABCDEFGHIJKLM".split(""), true);
164
+ const { nodes: graphNodes, edges: graphEdges } = GraphRenderer.renderToNodesAndEdges(graph);
165
+ const identifiers = {
166
+ graphIds: graph.toIdentifiers(),
167
+ graphNodes,
168
+ graphEdges,
169
+ };
170
+ return identifiers;
171
+ };
172
+ const getGraphsOrderOfGraphQuestion = (optsIn) => {
173
+ const arrayedOpts = defaultArrayedOptsWhereNeeded(optsIn, arrayedOptsDefault);
174
+ const opts = {
175
+ graphType: random(arrayedOpts.graphType),
176
+ };
177
+ const isDirected = opts.graphType === "orienté";
178
+ const identifiers = createRandomIdentifiers(isDirected);
179
+ return getQuestionFromIdentifiers(identifiers);
180
+ };
181
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
182
+ const question = {
183
+ answer: getAnswer(identifiers, opts),
184
+ instruction: getInstruction(identifiers, opts),
185
+ keys: getKeys(identifiers, opts),
186
+ answerFormat: "tex",
187
+ identifiers,
188
+ hint: getHint(identifiers, opts),
189
+ correction: getCorrection(identifiers, opts),
190
+ correctionGgbOptions: getCorrectionGGBOptions(identifiers, opts),
191
+ ggbOptions: getGGBOptions(identifiers, opts),
192
+ };
193
+ return question;
194
+ };
195
+ const arrayedOptsDefault = {
196
+ graphType: ["non orienté"],
197
+ };
198
+ const options = [
199
+ {
200
+ id: "graphType",
201
+ label: "Types de graphes",
202
+ target: GeneratorOptionTarget.generation,
203
+ type: GeneratorOptionType.multiselect,
204
+ values: ["non orienté", "orienté"],
205
+ defaultValue: arrayedOptsDefault.graphType,
206
+ },
207
+ ];
208
+ export const graphsOrderOfGraph = {
209
+ id: "graphsOrderOfGraph",
210
+ label: "Déterminer l'ordre d'un graphe",
211
+ isSingleStep: true,
212
+ generator: (nb, opts) => getDistinctQuestions(() => getGraphsOrderOfGraphQuestion(opts), nb),
213
+ options,
214
+ qcmTimer: 60,
215
+ freeTimer: 60,
216
+ isAnswerValid,
217
+ getPropositions,
218
+ subject: "Mathématiques",
219
+ getQuestionFromIdentifiers,
220
+ hasHintAndCorrection: true,
221
+ hasGeogebra: true,
222
+ };
@@ -0,0 +1,10 @@
1
+ export * from "./graphsOrderOfGraph.js";
2
+ export * from "./graphsDegreeOfVertex.js";
3
+ export * from "./graphsCheckIsVerticesAdjacent.js";
4
+ export * from "./graphsCheckIsSameGraph.js";
5
+ export * from "./graphsCheckIsConnectedUndirectedGraph.js";
6
+ export * from "./graphsChainOrPathOfLengthN.js";
7
+ export * from "./edgesNumberFromSummitsDegrees.js";
8
+ export * from "./adjacentMatrixPath.js";
9
+ export * from "./eulerianChainFromAdjacentMatrix.js";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/graphs/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,iCAAiC,CAAC;AAChD,cAAc,oCAAoC,CAAC;AACnD,cAAc,yBAAyB,CAAC;AACxC,cAAc,sCAAsC,CAAC"}
@@ -0,0 +1,9 @@
1
+ export * from "./graphsOrderOfGraph.js";
2
+ export * from "./graphsDegreeOfVertex.js";
3
+ export * from "./graphsCheckIsVerticesAdjacent.js";
4
+ export * from "./graphsCheckIsSameGraph.js";
5
+ export * from "./graphsCheckIsConnectedUndirectedGraph.js";
6
+ export * from "./graphsChainOrPathOfLengthN.js";
7
+ export * from "./edgesNumberFromSummitsDegrees.js";
8
+ export * from "./adjacentMatrixPath.js";
9
+ export * from "./eulerianChainFromAdjacentMatrix.js";
@@ -26,5 +26,6 @@ export * from "./tests/index.js";
26
26
  export * from "./pcExosInMath.js";
27
27
  export * from "./scratch/index.js";
28
28
  export * from "./integration/index.js";
29
+ export * from "./graphs/index.js";
29
30
  export * from "./arithmetic/index.js";
30
31
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exercises/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exercises/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAElC,cAAc,uBAAuB,CAAC"}
@@ -26,5 +26,6 @@ export * from "./tests/index.js";
26
26
  export * from "./pcExosInMath.js";
27
27
  export * from "./scratch/index.js";
28
28
  export * from "./integration/index.js";
29
+ export * from "./graphs/index.js";
29
30
  // export * from "./_debug/index.js";
30
31
  export * from "./arithmetic/index.js";
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ import { MatrixIdentifiers } from "../../../math/matrices/matrix.js";
3
+ type Identifiers = {
4
+ aIds: MatrixIdentifiers;
5
+ bIds: MatrixIdentifiers;
6
+ };
7
+ export declare const areMatricesInverse: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=areMatricesInverse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"areMatricesInverse.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/matrices/areMatricesInverse.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAEL,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AAKvC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,iBAAiB,CAAC;IACxB,IAAI,EAAE,iBAAiB,CAAC;CACzB,CAAC;AAmGF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAmBpD,CAAC"}
@@ -0,0 +1,106 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
+ import { MatrixConstructor, } from "../../../math/matrices/matrix.js";
4
+ import { randint } from "../../../math/utils/random/randint.js";
5
+ import { add } from "../../../tree/nodes/operators/addNode.js";
6
+ import { coinFlip } from "../../../utils/alea/coinFlip.js";
7
+ const getPropositions = (n, { answer }) => {
8
+ const propositions = [];
9
+ addValidProp(propositions, answer, "raw");
10
+ tryToAddWrongProp(propositions, "Oui", "raw");
11
+ tryToAddWrongProp(propositions, "Non", "raw");
12
+ return shuffleProps(propositions, n);
13
+ };
14
+ const getAnswer = (identifiers) => {
15
+ const { aIds, bIds } = identifiers;
16
+ const a = MatrixConstructor.fromIdentifiers(aIds);
17
+ const b = MatrixConstructor.fromIdentifiers(bIds);
18
+ const inv = a.toInversed();
19
+ return inv.simplify().toTex() === b.simplify().toTex() ? "Oui" : "Non";
20
+ };
21
+ const getInstruction = (identifiers) => {
22
+ const { aIds, bIds } = identifiers;
23
+ const a = MatrixConstructor.fromIdentifiers(aIds);
24
+ const b = MatrixConstructor.fromIdentifiers(bIds);
25
+ return `On considère les matrices :
26
+
27
+ $$
28
+ A = ${a.toTex()}
29
+ $$
30
+
31
+ $$
32
+ B = ${b.toTex()}
33
+ $$
34
+
35
+ $B$ est-elle la matrice inverse de $A$ ?`;
36
+ };
37
+ const getHint = () => {
38
+ return `$B$ est la matrice inverse de $A$ si et seulement si $AB = I$.`;
39
+ };
40
+ const getCorrection = (identifiers) => {
41
+ const { aIds, bIds } = identifiers;
42
+ const a = MatrixConstructor.fromIdentifiers(aIds);
43
+ const b = MatrixConstructor.fromIdentifiers(bIds);
44
+ const ab = a.matrixProduct(b);
45
+ const absimp = ab.simplify();
46
+ const isInv = absimp.isIdentity();
47
+ return `$B$ est la matrice inverse de $A$ si et seulement si $AB = I$.
48
+
49
+ On calcule donc le produit $AB$ :
50
+
51
+ $$
52
+ A\\times B = ${ab.toTex()}
53
+ $$
54
+
55
+ $$
56
+ A\\times B = ${absimp.toTex()}
57
+ $$
58
+
59
+ ${isInv
60
+ ? `On a donc $AB = I$ et donc $B$ est la matrice inverse de $A$.`
61
+ : `On a donc $AB \\neq I$ et donc $B$ n'est pas la matrice inverse de $A$.`}`;
62
+ };
63
+ const getAreMatricesInverseQuestion = () => {
64
+ const isInv = coinFlip();
65
+ const a = MatrixConstructor.randomInversible(2, 2, {
66
+ allowIdentity: false,
67
+ elementsOpts: [-5, 6],
68
+ });
69
+ const b = a.toInversed().simplify();
70
+ if (!isInv) {
71
+ b.elements[randint(0, 2)][randint(0, 2)] = add(b.elements[randint(0, 2)][randint(0, 2)], randint(-2, 2, [0])).simplify();
72
+ }
73
+ const identifiers = {
74
+ aIds: a.toIdentifiers(),
75
+ bIds: b.toIdentifiers(),
76
+ };
77
+ return getQuestionFromIdentifiers(identifiers);
78
+ };
79
+ const getQuestionFromIdentifiers = (identifiers) => {
80
+ return {
81
+ answer: getAnswer(identifiers),
82
+ instruction: getInstruction(identifiers),
83
+ keys: [],
84
+ answerFormat: "raw",
85
+ identifiers,
86
+ hint: getHint(identifiers),
87
+ correction: getCorrection(identifiers),
88
+ };
89
+ };
90
+ export const areMatricesInverse = {
91
+ id: "areMatricesInverse",
92
+ label: "Vérifier si $B$ est la matrice inverse de $A$ (matrices $2 \\times 2$)",
93
+ isSingleStep: true,
94
+ generator: (nb, opts) => getDistinctQuestions(() => getAreMatricesInverseQuestion(opts), nb),
95
+ qcmTimer: 60,
96
+ freeTimer: 60,
97
+ getPropositions,
98
+ subject: "Mathématiques",
99
+ getInstruction,
100
+ getHint,
101
+ getCorrection,
102
+ getAnswer,
103
+ getQuestionFromIdentifiers,
104
+ hasHintAndCorrection: true,
105
+ answerType: "QCU",
106
+ };
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ import { MatrixIdentifiers } from "../../../math/matrices/matrix.js";
3
+ type Identifiers = {
4
+ aIds: MatrixIdentifiers;
5
+ bIds: MatrixIdentifiers;
6
+ };
7
+ export declare const computeFixedMatrixInRecurrenceSequence: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=computeFixedMatrixInRecurrenceSequence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computeFixedMatrixInRecurrenceSequence.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/matrices/computeFixedMatrixInRecurrenceSequence.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAEL,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AAUvC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,iBAAiB,CAAC;IACxB,IAAI,EAAE,iBAAiB,CAAC;CACzB,CAAC;AAqIF,eAAO,MAAM,sCAAsC,EAAE,QAAQ,CAAC,WAAW,CAqBxE,CAAC"}
@@ -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"}