math-exercises 3.0.134 → 3.0.135
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.
- package/lib/exercises/math/calcul/arithmetics/coprime.d.ts +8 -0
- package/lib/exercises/math/calcul/arithmetics/coprime.d.ts.map +1 -0
- package/lib/exercises/math/calcul/arithmetics/coprime.js +113 -0
- package/lib/exercises/math/calcul/arithmetics/index.d.ts +1 -0
- package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/index.js +1 -0
- package/lib/exercises/math/calcul/decimals/decimalFractionToDecimal.d.ts +11 -0
- package/lib/exercises/math/calcul/decimals/decimalFractionToDecimal.d.ts.map +1 -0
- package/lib/exercises/math/calcul/decimals/decimalFractionToDecimal.js +243 -0
- package/lib/exercises/math/calcul/decimals/index.d.ts +1 -0
- package/lib/exercises/math/calcul/decimals/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/decimals/index.js +1 -0
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityAdd.d.ts +12 -0
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityAdd.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityAdd.js +173 -0
- package/lib/exercises/math/calculLitteral/distributivity/index.d.ts +1 -0
- package/lib/exercises/math/calculLitteral/distributivity/index.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/index.js +1 -0
- package/lib/exercises/math/calculLitteral/equation/equationSecondDegreeWithNoB.d.ts +7 -0
- package/lib/exercises/math/calculLitteral/equation/equationSecondDegreeWithNoB.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/equation/equationSecondDegreeWithNoB.js +160 -0
- package/lib/exercises/math/calculLitteral/simplifying/compareMinusA.js +1 -1
- package/lib/exercises/math/dataRepresentations/barChartInterpreting.d.ts.map +1 -1
- package/lib/exercises/math/dataRepresentations/barChartInterpreting.js +0 -1
- package/lib/exercises/math/derivation/derivative/composition/functionCompositionDerivative.d.ts +11 -0
- package/lib/exercises/math/derivation/derivative/composition/functionCompositionDerivative.d.ts.map +1 -0
- package/lib/exercises/math/derivation/derivative/composition/functionCompositionDerivative.js +372 -0
- package/lib/exercises/math/derivation/derivative/composition/index.d.ts +2 -0
- package/lib/exercises/math/derivation/derivative/composition/index.d.ts.map +1 -0
- package/lib/exercises/math/derivation/derivative/composition/index.js +1 -0
- package/lib/exercises/math/derivation/derivative/index.d.ts +1 -0
- package/lib/exercises/math/derivation/derivative/index.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/index.js +1 -0
- package/lib/exercises/math/functions/affines/recognizeAffineGraph.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/recognizeAffineGraph.js +3 -3
- package/lib/exercises/math/functions/affines/recognizeExprAffine.js +2 -2
- package/lib/exercises/math/functions/composition/functionComposition.js +1 -1
- package/lib/exercises/math/functions/composition/functionDecompositionFindPossibleUVs.d.ts +13 -0
- package/lib/exercises/math/functions/composition/functionDecompositionFindPossibleUVs.d.ts.map +1 -0
- package/lib/exercises/math/functions/composition/functionDecompositionFindPossibleUVs.js +223 -0
- package/lib/exercises/math/functions/composition/functionDecompositionFindUOrV.d.ts +9 -0
- package/lib/exercises/math/functions/composition/functionDecompositionFindUOrV.d.ts.map +1 -0
- package/lib/exercises/math/functions/composition/functionDecompositionFindUOrV.js +252 -0
- package/lib/exercises/math/functions/composition/index.d.ts +2 -0
- package/lib/exercises/math/functions/composition/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/composition/index.js +2 -0
- package/lib/exercises/math/geometry/vectors/constructions/index.d.ts +1 -0
- package/lib/exercises/math/geometry/vectors/constructions/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/constructions/index.js +1 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorCL.d.ts +13 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorCL.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorCL.js +178 -0
- package/lib/exercises/math/percent/evolutions/findEndValueAfterEvolution.d.ts.map +1 -1
- package/lib/exercises/math/percent/evolutions/findEndValueAfterEvolution.js +1 -1
- package/lib/exercises/math/powers/powersMixOperations.d.ts +4 -1
- package/lib/exercises/math/powers/powersMixOperations.d.ts.map +1 -1
- package/lib/exercises/math/powers/powersMixOperations.js +17 -7
- package/lib/exercises/math/probaStat/stats1var/plausibilityOfAverage.js +1 -1
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormula.d.ts.map +1 -1
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormula.js +2 -1
- package/lib/exercises/math/sequences/geometric/geometricFirstTermsGeneralSum.d.ts +5 -1
- package/lib/exercises/math/sequences/geometric/geometricFirstTermsGeneralSum.d.ts.map +1 -1
- package/lib/exercises/math/sequences/geometric/geometricFirstTermsGeneralSum.js +23 -6
- package/lib/exercises/math/sequences/recurrenceFormulaUsage.js +1 -1
- package/lib/index.d.ts +42 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/math/utils/arithmetic/isCoprime.d.ts +2 -0
- package/lib/math/utils/arithmetic/isCoprime.d.ts.map +1 -0
- package/lib/math/utils/arithmetic/isCoprime.js +10 -0
- package/lib/math/utils/arithmetic/primeDecompNode.d.ts +3 -0
- package/lib/math/utils/arithmetic/primeDecompNode.d.ts.map +1 -0
- package/lib/math/utils/arithmetic/primeDecompNode.js +24 -0
- package/lib/math/utils/functions/functionComparison.d.ts +3 -0
- package/lib/math/utils/functions/functionComparison.d.ts.map +1 -0
- package/lib/math/utils/functions/functionComparison.js +58 -0
- package/lib/math/utils/functions/functionComposition.d.ts +13 -0
- package/lib/math/utils/functions/functionComposition.d.ts.map +1 -0
- package/lib/math/utils/functions/functionComposition.js +117 -0
- package/lib/math/utils/functions/functionDecomposition.d.ts +10 -0
- package/lib/math/utils/functions/functionDecomposition.d.ts.map +1 -0
- package/lib/math/utils/functions/functionDecomposition.js +256 -0
- package/lib/server.js +25 -29
- package/lib/tree/nodes/operators/powerNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/powerNode.js +4 -0
- package/lib/utils/strings/joinanded.d.ts +2 -0
- package/lib/utils/strings/joinanded.d.ts.map +1 -0
- package/lib/utils/strings/joinanded.js +11 -0
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
uov: NodeIdentifiers;
|
|
5
|
+
items: Item[];
|
|
6
|
+
};
|
|
7
|
+
type Item = {
|
|
8
|
+
tex: string;
|
|
9
|
+
isValid: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare const functionDecompositionFindPossibleUVs: Exercise<Identifiers>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=functionDecompositionFindPossibleUVs.d.ts.map
|
package/lib/exercises/math/functions/composition/functionDecompositionFindPossibleUVs.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functionDecompositionFindPossibleUVs.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/composition/functionDecompositionFindPossibleUVs.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAO7C,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,eAAe,CAAC;IACrB,KAAK,EAAE,IAAI,EAAE,CAAC;CACf,CAAC;AAEF,KAAK,IAAI,GAAG;IACV,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAqQF,eAAO,MAAM,oCAAoC,EAAE,QAAQ,CAAC,WAAW,CAqBtE,CAAC"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { isEquivalentNodes } from "../../../../math/utils/functions/functionComparison.js";
|
|
4
|
+
import { nodeBySubstitutingVar } from "../../../../math/utils/functions/functionComposition.js";
|
|
5
|
+
import { functionDecompositions } from "../../../../math/utils/functions/functionDecomposition.js";
|
|
6
|
+
import { realize } from "../../../../math/utils/latex/realize.js";
|
|
7
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
8
|
+
import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
9
|
+
import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
|
|
10
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
11
|
+
import { probaLawFlip } from "../../../../utils/alea/probaLawFlip.js";
|
|
12
|
+
import { random } from "../../../../utils/alea/random.js";
|
|
13
|
+
import { permute } from "../../../../utils/arrays/permutations.js";
|
|
14
|
+
const getInstruction = (identifiers) => {
|
|
15
|
+
const { uov } = identifiers;
|
|
16
|
+
const nodeUOV = NodeConstructor.fromIdentifiers(uov);
|
|
17
|
+
return `Parmi les propositions, quelles sont les fonctions $u$ et $v$ telles que, pour tout $x$ réel :
|
|
18
|
+
|
|
19
|
+
$$
|
|
20
|
+
u \\circ v(x)=${nodeUOV.toTex()}
|
|
21
|
+
$$
|
|
22
|
+
|
|
23
|
+
`;
|
|
24
|
+
};
|
|
25
|
+
const getHint = () => {
|
|
26
|
+
return `Pour tout $x$ réel on a:
|
|
27
|
+
|
|
28
|
+
$$
|
|
29
|
+
u \\circ v(x) = u(v(x))
|
|
30
|
+
$$
|
|
31
|
+
|
|
32
|
+
`;
|
|
33
|
+
};
|
|
34
|
+
const getCorrection = (identifiers) => {
|
|
35
|
+
const { uov } = identifiers;
|
|
36
|
+
const nodeUOV = NodeConstructor.fromIdentifiers(uov);
|
|
37
|
+
const decompositions = functionDecompositions(nodeUOV);
|
|
38
|
+
return `Pour tout réel $x$, voici quelques couples ($u$,$v$) qui conviennent :
|
|
39
|
+
|
|
40
|
+
${decompositions.map(({ nodeU, nodeV }) => {
|
|
41
|
+
return `
|
|
42
|
+
|
|
43
|
+
$$
|
|
44
|
+
u(x) = ${nodeU.toTex()}
|
|
45
|
+
$$
|
|
46
|
+
|
|
47
|
+
$$
|
|
48
|
+
v(x) = ${nodeV.toTex()}
|
|
49
|
+
$$
|
|
50
|
+
|
|
51
|
+
`;
|
|
52
|
+
}).join(`
|
|
53
|
+
|
|
54
|
+
$\\ $
|
|
55
|
+
|
|
56
|
+
`)}`;
|
|
57
|
+
};
|
|
58
|
+
const getPropositions = (n, { answer, ...identifiers }) => {
|
|
59
|
+
const { items } = identifiers;
|
|
60
|
+
const propositions = [];
|
|
61
|
+
items.forEach((item) => {
|
|
62
|
+
if (item.isValid) {
|
|
63
|
+
addValidProp(propositions, item.tex, "raw");
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
tryToAddWrongProp(propositions, item.tex, "raw");
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return shuffleProps(propositions, n);
|
|
70
|
+
};
|
|
71
|
+
const getFunctionDecompositionFindPossibleUVsQuestion = (_) => {
|
|
72
|
+
function getRandomDict() {
|
|
73
|
+
function getRandomNode() {
|
|
74
|
+
return random([
|
|
75
|
+
...[
|
|
76
|
+
realize({ a: "I" })(`x+a`),
|
|
77
|
+
realize({ a: { custom: () => randint(2, 10).toTree() } })(`ax`),
|
|
78
|
+
realize({ a: "I", b: "I" })(`ax+b`),
|
|
79
|
+
realize({ a: "I", b: "I" })(`(ax+b)^2`),
|
|
80
|
+
realize({ a: "RI", b: "RI" })(`(x+a)(x+b)`),
|
|
81
|
+
`\\sin(x)`,
|
|
82
|
+
realize({ a: "I" })(`\\sin(ax)`),
|
|
83
|
+
`\\cos(x)`,
|
|
84
|
+
realize({ a: "I" })(`\\cos(ax)`),
|
|
85
|
+
].map((tex) => parseAlgebraic(tex)),
|
|
86
|
+
//! TODO: simplify({maxSimplificationSteps: 100}) to allow using fracs
|
|
87
|
+
// frac(randomNodeWithType("I"), "x"),
|
|
88
|
+
// frac(1, "x"),
|
|
89
|
+
]);
|
|
90
|
+
}
|
|
91
|
+
let [nodeF1, nodeF2, nodeF3, nodeA, nodeB, nodeU, nodeV, nodeUOV,] = [];
|
|
92
|
+
do {
|
|
93
|
+
[nodeF1, nodeF2] = [0, 1].map(() => getRandomNode());
|
|
94
|
+
nodeF3 = (() => {
|
|
95
|
+
let outNode;
|
|
96
|
+
do {
|
|
97
|
+
outNode = getRandomNode();
|
|
98
|
+
} while (outNode.toTex() === nodeF1.toTex() ||
|
|
99
|
+
outNode.toTex() === nodeF2.toTex());
|
|
100
|
+
return outNode;
|
|
101
|
+
})();
|
|
102
|
+
[nodeA, nodeB] = [
|
|
103
|
+
nodeF1,
|
|
104
|
+
(coinFlip()
|
|
105
|
+
? nodeBySubstitutingVar(nodeF2.simplify(), nodeF3.simplify())
|
|
106
|
+
: nodeBySubstitutingVar(nodeF3.simplify(), nodeF2.simplify())).simplify(),
|
|
107
|
+
];
|
|
108
|
+
[nodeU, nodeV] = coinFlip() ? [nodeA, nodeB] : [nodeB, nodeA];
|
|
109
|
+
nodeUOV = nodeBySubstitutingVar(nodeU.simplify(), nodeV.simplify()).simplify();
|
|
110
|
+
} while (nodeUOV.toTex().length > 60);
|
|
111
|
+
const decompositions = functionDecompositions(nodeUOV).filter(({ nodeU, nodeV }) => nodeU.toTex() !== "x" && nodeV.toTex() !== "x");
|
|
112
|
+
return { decompositions, nodeF1, nodeF2, nodeF3, nodeUOV };
|
|
113
|
+
}
|
|
114
|
+
let counter = -1;
|
|
115
|
+
let isFound = false;
|
|
116
|
+
let randomDict;
|
|
117
|
+
while (!isFound && counter < 100) {
|
|
118
|
+
counter++;
|
|
119
|
+
randomDict = getRandomDict();
|
|
120
|
+
if (randomDict.decompositions.length > 0) {
|
|
121
|
+
isFound = true;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const { decompositions, nodeF1, nodeF2, nodeF3, nodeUOV } = randomDict;
|
|
125
|
+
function texForUV(nodeU, nodeV) {
|
|
126
|
+
return `
|
|
127
|
+
|
|
128
|
+
$$
|
|
129
|
+
u(x) = ${nodeU.toTex()}
|
|
130
|
+
$$
|
|
131
|
+
|
|
132
|
+
$$
|
|
133
|
+
v(x) = ${nodeV.toTex()}
|
|
134
|
+
$$
|
|
135
|
+
|
|
136
|
+
`;
|
|
137
|
+
}
|
|
138
|
+
const validItems = decompositions.map(({ nodeU, nodeV }) => {
|
|
139
|
+
return {
|
|
140
|
+
tex: texForUV(nodeU, nodeV),
|
|
141
|
+
isValid: true,
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
const checkIsInvalid = (nodeU, nodeV) => {
|
|
145
|
+
return decompositions.every(({ nodeU: nodeUDec, nodeV: nodeVDec }) => {
|
|
146
|
+
return !(isEquivalentNodes(nodeU, nodeUDec) && isEquivalentNodes(nodeV, nodeVDec));
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
const invalidItems = [
|
|
150
|
+
//u is v, v is u
|
|
151
|
+
...decompositions.map(({ nodeU, nodeV }) => {
|
|
152
|
+
return {
|
|
153
|
+
tex: texForUV(nodeV, nodeU),
|
|
154
|
+
isValid: false,
|
|
155
|
+
};
|
|
156
|
+
}),
|
|
157
|
+
//node mash
|
|
158
|
+
...permute([nodeF1, nodeF2, nodeF3])
|
|
159
|
+
.filter(([node1, node2, node3]) => {
|
|
160
|
+
return (node1.toTex() !== nodeF1.toTex() &&
|
|
161
|
+
node2.toTex() !== nodeF2.toTex() &&
|
|
162
|
+
node3.toTex() !== nodeF3.toTex());
|
|
163
|
+
})
|
|
164
|
+
.map(([node1, node2, node3]) => {
|
|
165
|
+
const nodeU = node1;
|
|
166
|
+
const nodeV = nodeBySubstitutingVar(node2.simplify(), node3.simplify()).simplify();
|
|
167
|
+
return { nodeU, nodeV };
|
|
168
|
+
})
|
|
169
|
+
.filter(({ nodeU, nodeV }) => {
|
|
170
|
+
checkIsInvalid(nodeU, nodeV);
|
|
171
|
+
})
|
|
172
|
+
.map(({ nodeU, nodeV }) => {
|
|
173
|
+
return {
|
|
174
|
+
tex: texForUV(nodeV, nodeU),
|
|
175
|
+
isValid: false,
|
|
176
|
+
};
|
|
177
|
+
}),
|
|
178
|
+
];
|
|
179
|
+
const nbTotal = 4;
|
|
180
|
+
const nbValidItems = Math.min(validItems.length, probaLawFlip([
|
|
181
|
+
[1, 0.5],
|
|
182
|
+
[2, 0.3],
|
|
183
|
+
[3, 0.15],
|
|
184
|
+
[4, 0.05],
|
|
185
|
+
]));
|
|
186
|
+
const nbInvalidItems = nbTotal - nbValidItems;
|
|
187
|
+
const items = [
|
|
188
|
+
...validItems.slice(0, nbValidItems),
|
|
189
|
+
...invalidItems.slice(0, nbInvalidItems),
|
|
190
|
+
];
|
|
191
|
+
const identifiers = {
|
|
192
|
+
uov: nodeUOV.toIdentifiers(),
|
|
193
|
+
items,
|
|
194
|
+
};
|
|
195
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
196
|
+
};
|
|
197
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
198
|
+
return {
|
|
199
|
+
instruction: getInstruction(identifiers),
|
|
200
|
+
keys: [],
|
|
201
|
+
answerFormat: "tex",
|
|
202
|
+
identifiers,
|
|
203
|
+
hint: getHint(identifiers),
|
|
204
|
+
correction: getCorrection(identifiers),
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
export const functionDecompositionFindPossibleUVs = {
|
|
208
|
+
id: "functionDecompositionFindPossibleUVs",
|
|
209
|
+
label: "Déterminer les fonctions $u$ et $v$ possibles à partir de l'expression de $u \\circ v$",
|
|
210
|
+
isSingleStep: true,
|
|
211
|
+
generator: (nb, opts) => getDistinctQuestions(() => getFunctionDecompositionFindPossibleUVsQuestion(opts), nb),
|
|
212
|
+
qcmTimer: 60,
|
|
213
|
+
freeTimer: 60,
|
|
214
|
+
getPropositions,
|
|
215
|
+
subject: "Mathématiques",
|
|
216
|
+
getInstruction,
|
|
217
|
+
getHint,
|
|
218
|
+
getCorrection,
|
|
219
|
+
getQuestionFromIdentifiers,
|
|
220
|
+
hasHintAndCorrection: true,
|
|
221
|
+
answerType: "QCM",
|
|
222
|
+
isQCM: true,
|
|
223
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
isFindU: boolean;
|
|
5
|
+
nodeIds: NodeIdentifiers[];
|
|
6
|
+
};
|
|
7
|
+
export declare const functionDecompositionFindUOrV: Exercise<Identifiers>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=functionDecompositionFindUOrV.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functionDecompositionFindUOrV.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/composition/functionDecompositionFindUOrV.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AASrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAgE7C,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B,CAAC;AAyOF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAqB/D,CAAC"}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { realize } from "../../../../math/utils/latex/realize.js";
|
|
4
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
5
|
+
import { isFunctionNode, } from "../../../../tree/nodes/functions/functionNode.js";
|
|
6
|
+
import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
7
|
+
// import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
8
|
+
import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
9
|
+
import { isOperatorNode } from "../../../../tree/nodes/operators/operatorNode.js";
|
|
10
|
+
import { substract } from "../../../../tree/nodes/operators/substractNode.js";
|
|
11
|
+
import { parseAlgebraic, parseLatex } from "../../../../tree/parsers/latexParser.js";
|
|
12
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
13
|
+
import { random } from "../../../../utils/alea/random.js";
|
|
14
|
+
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
15
|
+
const nodeBySubstitutingX = (node, strVar) => {
|
|
16
|
+
return parseAlgebraic(node.toTex({ forceParenthesis: true }).replaceAll("x", `("${strVar}")`));
|
|
17
|
+
};
|
|
18
|
+
const functionNameForFunctionId = (functionId) => {
|
|
19
|
+
return [
|
|
20
|
+
"opposite",
|
|
21
|
+
"sqrt",
|
|
22
|
+
"cos",
|
|
23
|
+
"sin",
|
|
24
|
+
"tan",
|
|
25
|
+
"log",
|
|
26
|
+
"log10",
|
|
27
|
+
"exp",
|
|
28
|
+
"abs",
|
|
29
|
+
"arcsin",
|
|
30
|
+
"arccos",
|
|
31
|
+
"arctan",
|
|
32
|
+
][functionId];
|
|
33
|
+
};
|
|
34
|
+
const extractElementaryFunctionNamesDict = (nodes, functionNamesDictIn = {}) => {
|
|
35
|
+
let functionNamesDict = functionNamesDictIn;
|
|
36
|
+
nodes.forEach((node) => {
|
|
37
|
+
if (isFunctionNode(node)) {
|
|
38
|
+
const functionId = node.id;
|
|
39
|
+
const functionName = functionNameForFunctionId(functionId);
|
|
40
|
+
if (!(functionName in functionNamesDict)) {
|
|
41
|
+
functionNamesDict[functionName] = functionName;
|
|
42
|
+
}
|
|
43
|
+
functionNamesDict = Object.assign(functionNamesDict, extractElementaryFunctionNamesDict([node.child], functionNamesDict));
|
|
44
|
+
}
|
|
45
|
+
else if (isOperatorNode(node)) {
|
|
46
|
+
functionNamesDict = Object.assign(functionNamesDict, extractElementaryFunctionNamesDict([node.leftChild, node.rightChild], functionNamesDict));
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return functionNamesDict;
|
|
50
|
+
};
|
|
51
|
+
const getInstruction = (identifiers) => {
|
|
52
|
+
const { isFindU, nodeIds } = identifiers;
|
|
53
|
+
const [nodeU, nodeV, nodeUOV] = nodeIds.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
|
|
54
|
+
if (isFindU) {
|
|
55
|
+
return `Soient $u$ et $v$ deux fonctions telles que, pour tout $x$ réel :
|
|
56
|
+
|
|
57
|
+
$$
|
|
58
|
+
v(x)=${nodeV.toTex()}
|
|
59
|
+
$$
|
|
60
|
+
|
|
61
|
+
$$
|
|
62
|
+
u \\circ v(x)=${nodeUOV.toTex()}
|
|
63
|
+
$$
|
|
64
|
+
|
|
65
|
+
Pour tout $x$ réel, donner l'expression de $u(x)$.`;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
return `Soient $u$ et $v$ deux fonctions telles que, pour tout $x$ réel :
|
|
69
|
+
|
|
70
|
+
$$
|
|
71
|
+
u(x)=${nodeU.toTex()}
|
|
72
|
+
$$
|
|
73
|
+
|
|
74
|
+
$$
|
|
75
|
+
u \\circ v(x)=${nodeUOV.toTex()}
|
|
76
|
+
$$
|
|
77
|
+
|
|
78
|
+
Pour tout $x$ réel, donner l'expression de $v(x)$.`;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const getHint = () => {
|
|
82
|
+
return `Pour tout $x$ réel on a:
|
|
83
|
+
|
|
84
|
+
$$
|
|
85
|
+
u \\circ v(x) = u(v(x))
|
|
86
|
+
$$
|
|
87
|
+
|
|
88
|
+
`;
|
|
89
|
+
};
|
|
90
|
+
const getCorrection = (identifiers) => {
|
|
91
|
+
const { isFindU, nodeIds } = identifiers;
|
|
92
|
+
const [nodeU, nodeV, nodeUOV] = nodeIds.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
|
|
93
|
+
return `Pour tout réel $x$, on a :
|
|
94
|
+
|
|
95
|
+
${alignTex([
|
|
96
|
+
[`u \\circ v(x)`, `=`, `u(v(x))`],
|
|
97
|
+
[``, `=`, `${nodeUOV.toTex()}`],
|
|
98
|
+
[
|
|
99
|
+
``,
|
|
100
|
+
`=`,
|
|
101
|
+
isFindU
|
|
102
|
+
? `${nodeU.toTex().replaceAll("x", "v(x)")}`
|
|
103
|
+
: `u(${nodeV.toTex()})`,
|
|
104
|
+
],
|
|
105
|
+
])}
|
|
106
|
+
|
|
107
|
+
On en déduit donc :
|
|
108
|
+
|
|
109
|
+
$$
|
|
110
|
+
${isFindU ? `u(x) = ${nodeU.toTex()}` : `v(x) = ${nodeV.toTex()}`}
|
|
111
|
+
$$
|
|
112
|
+
|
|
113
|
+
`;
|
|
114
|
+
};
|
|
115
|
+
const getAnswerNode = (identifiers) => {
|
|
116
|
+
const { isFindU, nodeIds } = identifiers;
|
|
117
|
+
const [nodeU, nodeV] = nodeIds.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
|
|
118
|
+
return isFindU ? nodeU : nodeV;
|
|
119
|
+
};
|
|
120
|
+
const getAnswer = (identifiers) => {
|
|
121
|
+
return getAnswerNode(identifiers).toTex();
|
|
122
|
+
};
|
|
123
|
+
const isAnswerValid = (ans, { answer, ...identifiers }) => {
|
|
124
|
+
const nodeAns = parseLatex(ans);
|
|
125
|
+
const nodeAnswer = getAnswerNode(identifiers);
|
|
126
|
+
const nodeDiff = substract(nodeAns, nodeAnswer).simplify();
|
|
127
|
+
return (nodeDiff.evaluate({ x: 1 }) === 0 &&
|
|
128
|
+
nodeDiff.evaluate({ x: 10 }) === 0 &&
|
|
129
|
+
nodeDiff.evaluate({ x: 100 }) === 0);
|
|
130
|
+
};
|
|
131
|
+
const getPropositions = (n, { answer, ...identifiers }) => {
|
|
132
|
+
const { nodeIds } = identifiers;
|
|
133
|
+
const [nodeU, nodeV] = nodeIds.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
|
|
134
|
+
const propositions = [];
|
|
135
|
+
addValidProp(propositions, answer);
|
|
136
|
+
const wrongTexs = [
|
|
137
|
+
//mauvais ordre
|
|
138
|
+
`${nodeBySubstitutingX(nodeV, nodeU.toTex()).toTex({
|
|
139
|
+
forceParenthesis: true,
|
|
140
|
+
})}`,
|
|
141
|
+
`${nodeBySubstitutingX(nodeV, nodeU.toTex()).simplify().toTex()}`,
|
|
142
|
+
//multiplication
|
|
143
|
+
`${multiply(nodeU, nodeV).toTex({
|
|
144
|
+
forceParenthesis: true,
|
|
145
|
+
})}`,
|
|
146
|
+
//\\circ is 0
|
|
147
|
+
`${multiply(nodeU, multiply(0, nodeV)).toTex({
|
|
148
|
+
forceTimesSign: true,
|
|
149
|
+
forceParenthesis: true,
|
|
150
|
+
})}`,
|
|
151
|
+
//substitution littéraire
|
|
152
|
+
`${nodeU
|
|
153
|
+
.toTex({ forceParenthesis: true })
|
|
154
|
+
.replaceAll("x", `${nodeV.toTex()}`)}`,
|
|
155
|
+
`${nodeU
|
|
156
|
+
.toTex({ forceParenthesis: true })
|
|
157
|
+
.replaceAll("x", `${nodeV.toTex()}`)}`,
|
|
158
|
+
];
|
|
159
|
+
wrongTexs.forEach((wrongTex) => {
|
|
160
|
+
tryToAddWrongProp(propositions, wrongTex);
|
|
161
|
+
});
|
|
162
|
+
if (propositions.length < n) {
|
|
163
|
+
[
|
|
164
|
+
`${nodeBySubstitutingX(nodeU, nodeU.toTex()).toTex({
|
|
165
|
+
forceParenthesis: true,
|
|
166
|
+
})}`,
|
|
167
|
+
`${nodeBySubstitutingX(nodeU, nodeU.toTex()).simplify().toTex()}`,
|
|
168
|
+
`${nodeBySubstitutingX(nodeV, nodeV.toTex()).toTex({
|
|
169
|
+
forceParenthesis: true,
|
|
170
|
+
})}`,
|
|
171
|
+
`${nodeBySubstitutingX(nodeV, nodeV.toTex()).simplify().toTex()}`,
|
|
172
|
+
].forEach((wrongTex) => {
|
|
173
|
+
tryToAddWrongProp(propositions, wrongTex);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
return shuffleProps(propositions, n);
|
|
177
|
+
};
|
|
178
|
+
const getKeys = (identifiers) => {
|
|
179
|
+
const { nodeIds } = identifiers;
|
|
180
|
+
const nodes = nodeIds.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
|
|
181
|
+
const functionNamesDict = extractElementaryFunctionNamesDict(nodes);
|
|
182
|
+
return [
|
|
183
|
+
"x",
|
|
184
|
+
...Object.values(functionNamesDict).map((functionName) => {
|
|
185
|
+
return {
|
|
186
|
+
id: "custom",
|
|
187
|
+
label: functionName,
|
|
188
|
+
labelType: "tex",
|
|
189
|
+
mathfieldInstructions: {
|
|
190
|
+
method: "write",
|
|
191
|
+
content: functionName,
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
}),
|
|
195
|
+
];
|
|
196
|
+
};
|
|
197
|
+
const getFunctionDecompositionFindUOrVQuestion = (_) => {
|
|
198
|
+
function getRandomNode() {
|
|
199
|
+
return random([
|
|
200
|
+
...[
|
|
201
|
+
realize({ a: "I" })(`x+a`),
|
|
202
|
+
realize({ a: { custom: () => randint(2, 10).toTree() } })(`ax`),
|
|
203
|
+
realize({ a: "I", b: "I" })(`ax+b`),
|
|
204
|
+
realize({ a: "I", b: "I" })(`(ax+b)^2`),
|
|
205
|
+
realize({ a: "RI", b: "RI" })(`(x+a)(x+b)`),
|
|
206
|
+
`\\sin(x)`,
|
|
207
|
+
realize({ a: "I" })(`\\sin(ax)`),
|
|
208
|
+
`\\cos(x)`,
|
|
209
|
+
realize({ a: "I" })(`\\cos(ax)`),
|
|
210
|
+
].map((tex) => parseAlgebraic(tex)),
|
|
211
|
+
//! TODO: simplify({maxSimplificationSteps: 100}) to allow using fracs
|
|
212
|
+
// frac(randomNodeWithType("I"), "x"),
|
|
213
|
+
// frac(1, "x"),
|
|
214
|
+
]);
|
|
215
|
+
}
|
|
216
|
+
const [nodeU, nodeV] = [0, 1].map(() => getRandomNode());
|
|
217
|
+
const nodeUOV = nodeBySubstitutingX(nodeU.simplify(), nodeV.simplify().toTex()).simplify();
|
|
218
|
+
const isFindU = coinFlip();
|
|
219
|
+
const identifiers = {
|
|
220
|
+
isFindU,
|
|
221
|
+
nodeIds: [nodeU, nodeV, nodeUOV].map((node) => node.toIdentifiers()),
|
|
222
|
+
};
|
|
223
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
224
|
+
};
|
|
225
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
226
|
+
return {
|
|
227
|
+
answer: getAnswer(identifiers),
|
|
228
|
+
instruction: getInstruction(identifiers),
|
|
229
|
+
keys: getKeys(identifiers),
|
|
230
|
+
answerFormat: "tex",
|
|
231
|
+
identifiers,
|
|
232
|
+
hint: getHint(identifiers),
|
|
233
|
+
correction: getCorrection(identifiers),
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
export const functionDecompositionFindUOrV = {
|
|
237
|
+
id: "functionDecompositionFindUOrV",
|
|
238
|
+
label: "Déterminer la fonction dont on connaît l'expression de la composée avec une autre fonction",
|
|
239
|
+
isSingleStep: true,
|
|
240
|
+
isAnswerValid,
|
|
241
|
+
generator: (nb, opts) => getDistinctQuestions(() => getFunctionDecompositionFindUOrVQuestion(opts), nb),
|
|
242
|
+
qcmTimer: 60,
|
|
243
|
+
freeTimer: 60,
|
|
244
|
+
getPropositions,
|
|
245
|
+
subject: "Mathématiques",
|
|
246
|
+
getInstruction,
|
|
247
|
+
getHint,
|
|
248
|
+
getCorrection,
|
|
249
|
+
getAnswer,
|
|
250
|
+
getQuestionFromIdentifiers,
|
|
251
|
+
hasHintAndCorrection: true,
|
|
252
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/composition/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/composition/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,oCAAoC,CAAC;AACnD,cAAc,2CAA2C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/geometry/vectors/constructions/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mCAAmC,CAAC;AAClD,cAAc,uCAAuC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/geometry/vectors/constructions/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mCAAmC,CAAC;AAClD,cAAc,uCAAuC,CAAC;AACtD,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Exercise } from "../../../../../exercises/exercise.js";
|
|
2
|
+
import { PointIdentifiers } from "../../../../../math/geometry/point.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
points: PointIdentifiers[];
|
|
5
|
+
startPointIndex: number;
|
|
6
|
+
firstVectorPointsIndexes: number[];
|
|
7
|
+
secondVectorPointsIndexes: number[];
|
|
8
|
+
a: number;
|
|
9
|
+
b: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const traceVectorCL: Exercise<Identifiers>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=traceVectorCL.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traceVectorCL.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/geometry/vectors/constructions/traceVectorCL.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAMtC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,wBAAwB,EAAE,MAAM,EAAE,CAAC;IACnC,yBAAyB,EAAE,MAAM,EAAE,CAAC;IACpC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAiQF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAe/C,CAAC"}
|