math-exercises 3.0.183 → 3.0.185
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/functions/composition/functionComposition.d.ts.map +1 -1
- package/lib/exercises/math/functions/composition/functionComposition.js +11 -22
- package/lib/exercises/math/functions/exponential/algebraic/approxExpAPlusB.d.ts.map +1 -1
- package/lib/exercises/math/functions/exponential/algebraic/approxExpAPlusB.js +91 -38
- package/lib/exercises/math/functions/exponential/algebraic/rewriteExpUsingExpA.d.ts.map +1 -1
- package/lib/exercises/math/functions/exponential/algebraic/rewriteExpUsingExpA.js +18 -3
- package/lib/exercises/math/functions/exponential/expKT/derivativeOfAExpKT.d.ts +8 -0
- package/lib/exercises/math/functions/exponential/expKT/derivativeOfAExpKT.d.ts.map +1 -0
- package/lib/exercises/math/functions/exponential/expKT/derivativeOfAExpKT.js +108 -0
- package/lib/exercises/math/functions/exponential/expKT/drugConcentrationMaximum.d.ts +8 -0
- package/lib/exercises/math/functions/exponential/expKT/drugConcentrationMaximum.d.ts.map +1 -0
- package/lib/exercises/math/functions/exponential/expKT/drugConcentrationMaximum.js +144 -0
- package/lib/exercises/math/functions/exponential/expKT/index.d.ts +3 -0
- package/lib/exercises/math/functions/exponential/expKT/index.d.ts.map +1 -0
- package/lib/exercises/math/functions/exponential/expKT/index.js +2 -0
- package/lib/exercises/math/functions/exponential/expSimplifiying.d.ts.map +1 -1
- package/lib/exercises/math/functions/exponential/expSimplifiying.js +94 -4
- package/lib/exercises/math/functions/exponential/index.d.ts +3 -0
- package/lib/exercises/math/functions/exponential/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/exponential/index.js +3 -0
- package/lib/exercises/math/functions/exponential/sign/expFunctionBasicSign.d.ts +9 -0
- package/lib/exercises/math/functions/exponential/sign/expFunctionBasicSign.d.ts.map +1 -0
- package/lib/exercises/math/functions/exponential/sign/expFunctionBasicSign.js +101 -0
- package/lib/exercises/math/functions/exponential/sign/index.d.ts +2 -0
- package/lib/exercises/math/functions/exponential/sign/index.d.ts.map +1 -0
- package/lib/exercises/math/functions/exponential/sign/index.js +1 -0
- package/lib/exercises/math/functions/exponential/variations/index.d.ts +3 -0
- package/lib/exercises/math/functions/exponential/variations/index.d.ts.map +1 -0
- package/lib/exercises/math/functions/exponential/variations/index.js +2 -0
- package/lib/exercises/math/functions/exponential/variations/varSignTableOfAffineTimesExp.d.ts +7 -0
- package/lib/exercises/math/functions/exponential/variations/varSignTableOfAffineTimesExp.d.ts.map +1 -0
- package/lib/exercises/math/functions/exponential/variations/varSignTableOfAffineTimesExp.js +144 -0
- package/lib/exercises/math/functions/exponential/variations/varSignTableOfExpMinusX.d.ts +7 -0
- package/lib/exercises/math/functions/exponential/variations/varSignTableOfExpMinusX.d.ts.map +1 -0
- package/lib/exercises/math/functions/exponential/variations/varSignTableOfExpMinusX.js +139 -0
- package/lib/exercises/math/probaStat/independancy/independantSuccessiveEventsComputeTwoSuccess.d.ts +7 -0
- package/lib/exercises/math/probaStat/independancy/independantSuccessiveEventsComputeTwoSuccess.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/independancy/independantSuccessiveEventsComputeTwoSuccess.js +100 -0
- package/lib/exercises/math/probaStat/independancy/index.d.ts +1 -0
- package/lib/exercises/math/probaStat/independancy/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/independancy/index.js +1 -0
- package/lib/exercises/math/probaStat/trees/index.d.ts +4 -1
- package/lib/exercises/math/probaStat/trees/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/trees/index.js +4 -11
- package/lib/exercises/math/probaStat/trees/probabilityTree.d.ts +9 -3
- package/lib/exercises/math/probaStat/trees/probabilityTree.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/trees/probabilityTree.js +419 -45
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.d.ts.map +1 -1
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.js +3 -3
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.d.ts.map +1 -1
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.js +2 -2
- package/lib/exercises/math/sequences/arithmetic/situations/index.d.ts +2 -0
- package/lib/exercises/math/sequences/arithmetic/situations/index.d.ts.map +1 -1
- package/lib/exercises/math/sequences/arithmetic/situations/index.js +2 -2
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoConsecutiveTerms.d.ts.map +1 -1
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoConsecutiveTerms.js +37 -39
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.d.ts.map +1 -1
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.js +14 -4
- package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.d.ts.map +1 -1
- package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.js +12 -3
- package/lib/exercises/vea/treeTableVEA.d.ts.map +1 -1
- package/lib/exercises/vea/treeTableVEA.js +3 -0
- package/lib/index.d.ts +46 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/latexTester.js +1 -1
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts +2 -0
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts.map +1 -1
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.js +150 -128
- package/lib/math/utils/sequences/situations/seqArithmeticUtils.d.ts +1 -1
- package/lib/math/utils/sequences/situations/seqArithmeticUtils.d.ts.map +1 -1
- package/lib/math/utils/sequences/situations/seqArithmeticUtils.js +4 -1
- package/lib/tests/questionTest.d.ts.map +1 -1
- package/lib/tests/questionTest.js +1 -0
- package/lib/tests/singleExo.test.js +2 -2
- package/lib/tree/nodes/functions/expNode.d.ts +1 -1
- package/lib/tree/nodes/functions/expNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/expNode.js +3 -6
- package/lib/tree/nodes/operators/addNode.d.ts +1 -1
- package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.js +2 -2
- package/lib/tree/nodes/operators/substractNode.d.ts +1 -1
- package/lib/tree/nodes/operators/substractNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/substractNode.js +2 -2
- package/lib/tree/utilities/nodeComparator.d.ts +7 -0
- package/lib/tree/utilities/nodeComparator.d.ts.map +1 -0
- package/lib/tree/utilities/nodeComparator.js +88 -0
- package/lib/tree/utilities/nodeInspector.d.ts +5 -0
- package/lib/tree/utilities/nodeInspector.d.ts.map +1 -0
- package/lib/tree/utilities/nodeInspector.js +15 -0
- package/lib/tree/utilities/nodeRewriter.d.ts +9 -0
- package/lib/tree/utilities/nodeRewriter.d.ts.map +1 -0
- package/lib/tree/utilities/nodeRewriter.js +172 -0
- package/lib/tree/utilities/nodeShuffler.d.ts +2 -4
- package/lib/tree/utilities/nodeShuffler.d.ts.map +1 -1
- package/lib/tree/utilities/nodeShuffler.js +13 -104
- package/lib/tree/utilities/nodeSimplifier.d.ts +1 -2
- package/lib/tree/utilities/nodeSimplifier.d.ts.map +1 -1
- package/lib/tree/utilities/nodeSimplifier.js +14 -88
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functionComposition.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/composition/functionComposition.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AASrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"functionComposition.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/composition/functionComposition.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,eAAe,EAAE,CAAC;CAC5B,CAAC;AAgNF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAiBrD,CAAC"}
|
|
@@ -8,6 +8,8 @@ import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
|
8
8
|
import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
9
9
|
import { isOperatorNode } from "../../../../tree/nodes/operators/operatorNode.js";
|
|
10
10
|
import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
|
|
11
|
+
import { NodeComparator } from "../../../../tree/utilities/nodeComparator.js";
|
|
12
|
+
import { NodeRewriter } from "../../../../tree/utilities/nodeRewriter.js";
|
|
11
13
|
import { random } from "../../../../utils/alea/random.js";
|
|
12
14
|
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
13
15
|
const nodeBySubstitutingX = (node, strVar) => {
|
|
@@ -99,28 +101,15 @@ const getAnswer = (identifiers) => {
|
|
|
99
101
|
const isAnswerValid = (ans, { answer }) => {
|
|
100
102
|
const nodeAns = parseAlgebraic(ans);
|
|
101
103
|
const nodeAnswer = parseAlgebraic(answer);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
// const nodeAnswerOfAns = nodeBySubstitutingX(
|
|
112
|
-
// nodeAnswer.simplify(),
|
|
113
|
-
// nodeAns.simplify().toTex(),
|
|
114
|
-
// ).simplify();
|
|
115
|
-
// return [0, 1, 1000].every((x) => {
|
|
116
|
-
// return (
|
|
117
|
-
// substract(
|
|
118
|
-
// nodeAnsOfAnswer.evaluate({ x }),
|
|
119
|
-
// nodeAnswerOfAns.evaluate({ x }),
|
|
120
|
-
// ).evaluate() === 0
|
|
121
|
-
// );
|
|
122
|
-
// });
|
|
123
|
-
return nodeAns.simplify().toTex() === nodeAnswer.simplify().toTex();
|
|
104
|
+
const isEquivalentFound = () => {
|
|
105
|
+
const arrNodeAnswerEquivalent = NodeRewriter.getArrNodeEquivalent(nodeAnswer);
|
|
106
|
+
return arrNodeAnswerEquivalent.some((nodeAnswerRefined) => {
|
|
107
|
+
const isEqual = NodeComparator.isEqualViaSub(nodeAns, nodeAnswerRefined);
|
|
108
|
+
return isEqual;
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
const isValid = isEquivalentFound();
|
|
112
|
+
return isValid;
|
|
124
113
|
};
|
|
125
114
|
const getPropositions = (n, { answer, ...identifiers }) => {
|
|
126
115
|
const { nodeIds } = identifiers;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approxExpAPlusB.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/exponential/algebraic/approxExpAPlusB.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"approxExpAPlusB.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/exponential/algebraic/approxExpAPlusB.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAa7C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,eAAe,CAAC;IAC1B,WAAW,EAAE,eAAe,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA8cF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAmBjD,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
|
|
2
2
|
import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
3
|
import { nodeBySubstitutingVar } from "../../../../../math/utils/functions/functionComposition.js";
|
|
4
|
-
import { randfloat } from "../../../../../math/utils/random/randfloat.js";
|
|
5
4
|
import { randint } from "../../../../../math/utils/random/randint.js";
|
|
6
5
|
import { round } from "../../../../../math/utils/round.js";
|
|
7
6
|
import { exp } from "../../../../../tree/nodes/functions/expNode.js";
|
|
@@ -13,7 +12,8 @@ import { power } from "../../../../../tree/nodes/operators/powerNode.js";
|
|
|
13
12
|
import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
|
|
14
13
|
import { VariableNode } from "../../../../../tree/nodes/variables/variableNode.js";
|
|
15
14
|
import { parseAlgebraic } from "../../../../../tree/parsers/latexParser.js";
|
|
16
|
-
import {
|
|
15
|
+
import { NodeComparator } from "../../../../../tree/utilities/nodeComparator.js";
|
|
16
|
+
import { probaFlip } from "../../../../../utils/alea/probaFlip.js";
|
|
17
17
|
import { random } from "../../../../../utils/alea/random.js";
|
|
18
18
|
import { shuffle } from "../../../../../utils/alea/shuffle.js";
|
|
19
19
|
const getInstruction = (identifiers) => {
|
|
@@ -152,8 +152,8 @@ $$
|
|
|
152
152
|
}
|
|
153
153
|
};
|
|
154
154
|
const getPropositions = (n, { answer, ...identifiers }) => {
|
|
155
|
-
const { nodeIdsA, nodeIdsB, expARounded, expBRounded, precision } = identifiers;
|
|
156
|
-
const [nodeA, nodeB] = [nodeIdsA, nodeIdsB].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
|
|
155
|
+
const { nodeIdsA, nodeIdsB, nodeIdsAOpB, expARounded, expBRounded, precision, } = identifiers;
|
|
156
|
+
const [nodeA, nodeB, nodeAOpB] = [nodeIdsA, nodeIdsB, nodeIdsAOpB].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
|
|
157
157
|
const propositions = [];
|
|
158
158
|
addValidProp(propositions, answer);
|
|
159
159
|
//exp(a)+exp(b)
|
|
@@ -188,6 +188,22 @@ const getPropositions = (n, { answer, ...identifiers }) => {
|
|
|
188
188
|
}
|
|
189
189
|
});
|
|
190
190
|
}
|
|
191
|
+
//terror: student computes round(exp(aOpB),precision) with their calculator
|
|
192
|
+
{
|
|
193
|
+
const nodeAOpBSubstituted = [
|
|
194
|
+
["a", nodeA],
|
|
195
|
+
["b", nodeB],
|
|
196
|
+
]
|
|
197
|
+
.reduce((acc, [varName, nodeInjected]) => {
|
|
198
|
+
return nodeBySubstitutingVar(acc, nodeInjected, new VariableNode(varName));
|
|
199
|
+
}, nodeAOpB)
|
|
200
|
+
.simplify({ fractionsToDecimal: true });
|
|
201
|
+
const nodeWrong = round(nodeAOpBSubstituted.evaluate(), 0).toTree();
|
|
202
|
+
const tex = nodeWrong.toTex();
|
|
203
|
+
if (tex !== "NaN") {
|
|
204
|
+
tryToAddWrongProp(propositions, tex);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
191
207
|
//filler
|
|
192
208
|
if (propositions.length < n) {
|
|
193
209
|
//exp(b)-exp(a)
|
|
@@ -220,33 +236,35 @@ const getPropositions = (n, { answer, ...identifiers }) => {
|
|
|
220
236
|
const isAnswerValid = (ans, { answer }) => {
|
|
221
237
|
return ans === answer;
|
|
222
238
|
};
|
|
239
|
+
const createRandomIdentifiers = () => {
|
|
240
|
+
const precision = randint(0);
|
|
241
|
+
const a = randint(0, 6);
|
|
242
|
+
const nodeA = a.toTree();
|
|
243
|
+
const expARounded = round(exp(nodeA).evaluate(), precision);
|
|
244
|
+
const nodeB = random([
|
|
245
|
+
// //-1
|
|
246
|
+
// (-1).toTree(),
|
|
247
|
+
//1/2
|
|
248
|
+
frac(1, 2),
|
|
249
|
+
//int
|
|
250
|
+
(() => randint(a, a + 5, [nodeA.evaluate()]).toTree())(),
|
|
251
|
+
]);
|
|
252
|
+
const expBRounded = round(exp(nodeB).evaluate(), precision);
|
|
253
|
+
const nodeAOpB = parseAlgebraic(probaFlip(0.8) ? "a+b" : "a-b");
|
|
254
|
+
const identifiers = {
|
|
255
|
+
nodeIdsA: nodeA.toIdentifiers(),
|
|
256
|
+
nodeIdsB: nodeB.toIdentifiers(),
|
|
257
|
+
nodeIdsAOpB: nodeAOpB.toIdentifiers(),
|
|
258
|
+
expARounded,
|
|
259
|
+
expBRounded,
|
|
260
|
+
precision,
|
|
261
|
+
nodeA,
|
|
262
|
+
nodeB,
|
|
263
|
+
nodeAOpB,
|
|
264
|
+
};
|
|
265
|
+
return identifiers;
|
|
266
|
+
};
|
|
223
267
|
const getApproxExpAPlusBQuestion = () => {
|
|
224
|
-
function createRandomIdentifiers() {
|
|
225
|
-
const precision = randint(1, 6);
|
|
226
|
-
const nodeA = randfloat(0, 3, 2, [0]).toTree();
|
|
227
|
-
const expARounded = round(exp(nodeA).evaluate(), precision);
|
|
228
|
-
const nodeB = random([
|
|
229
|
-
//-1
|
|
230
|
-
(-1).toTree(),
|
|
231
|
-
//1/2
|
|
232
|
-
frac(1, 2),
|
|
233
|
-
//int
|
|
234
|
-
(() => randint(2, 11).toTree())(),
|
|
235
|
-
]);
|
|
236
|
-
const expBRounded = round(exp(nodeB).evaluate(), precision);
|
|
237
|
-
const nodeAOpB = parseAlgebraic(coinFlip() ? "a+b" : "a-b");
|
|
238
|
-
const identifiers = {
|
|
239
|
-
nodeIdsA: nodeA.toIdentifiers(),
|
|
240
|
-
nodeIdsB: nodeB.toIdentifiers(),
|
|
241
|
-
nodeIdsAOpB: nodeAOpB.toIdentifiers(),
|
|
242
|
-
expARounded,
|
|
243
|
-
expBRounded,
|
|
244
|
-
precision,
|
|
245
|
-
nodeA,
|
|
246
|
-
nodeB,
|
|
247
|
-
};
|
|
248
|
-
return identifiers;
|
|
249
|
-
}
|
|
250
268
|
let identifiers;
|
|
251
269
|
let counter = -1;
|
|
252
270
|
let isValid = false;
|
|
@@ -254,21 +272,56 @@ const getApproxExpAPlusBQuestion = () => {
|
|
|
254
272
|
counter++;
|
|
255
273
|
const identifiersCandidate = createRandomIdentifiers();
|
|
256
274
|
isValid = (() => {
|
|
257
|
-
const { nodeA, nodeB } = identifiersCandidate;
|
|
258
|
-
|
|
275
|
+
const { nodeA, nodeB, nodeAOpB, expARounded, expBRounded } = identifiersCandidate;
|
|
276
|
+
const nodeAOpBSubstituted = [
|
|
277
|
+
["a", nodeA],
|
|
278
|
+
["b", nodeB],
|
|
279
|
+
]
|
|
280
|
+
.reduce((acc, [varName, nodeInjected]) => {
|
|
281
|
+
return nodeBySubstitutingVar(acc, nodeInjected, new VariableNode(varName));
|
|
282
|
+
}, nodeAOpB)
|
|
283
|
+
.simplify({ fractionsToDecimal: true });
|
|
284
|
+
const isAOpBEqualToAorB = () => {
|
|
285
|
+
return (NodeComparator.isEqualViaSub(nodeB, nodeAOpBSubstituted) ||
|
|
286
|
+
NodeComparator.isEqualViaSub(nodeA, nodeAOpBSubstituted));
|
|
287
|
+
};
|
|
288
|
+
const isMentallyCalculable = () => {
|
|
289
|
+
function countDigits(num) {
|
|
290
|
+
if (!Number.isFinite(num)) {
|
|
291
|
+
throw new Error("Input must be a finite number.");
|
|
292
|
+
}
|
|
293
|
+
// Remove sign and decimal part
|
|
294
|
+
const integerPart = Math.abs(Math.trunc(num));
|
|
295
|
+
// Special case for 0
|
|
296
|
+
if (integerPart === 0)
|
|
297
|
+
return 1;
|
|
298
|
+
return integerPart.toString().length;
|
|
299
|
+
}
|
|
300
|
+
const product = expARounded * expBRounded;
|
|
301
|
+
return countDigits(product) <= 4 && product < 5555;
|
|
302
|
+
};
|
|
303
|
+
return !isAOpBEqualToAorB() && isMentallyCalculable();
|
|
259
304
|
})();
|
|
260
305
|
if (isValid) {
|
|
261
|
-
|
|
306
|
+
const { nodeIdsA, nodeIdsB, nodeIdsAOpB, expARounded, expBRounded, precision, } = identifiersCandidate;
|
|
307
|
+
identifiers = {
|
|
308
|
+
nodeIdsA,
|
|
309
|
+
nodeIdsB,
|
|
310
|
+
nodeIdsAOpB,
|
|
311
|
+
expARounded,
|
|
312
|
+
expBRounded,
|
|
313
|
+
precision,
|
|
314
|
+
};
|
|
262
315
|
}
|
|
263
316
|
}
|
|
264
317
|
if (!isValid) {
|
|
265
318
|
const identifiersDefault = {
|
|
266
319
|
nodeIdsA: (2).toTree().toIdentifiers(),
|
|
267
|
-
nodeIdsB:
|
|
320
|
+
nodeIdsB: (3).toTree().toIdentifiers(),
|
|
268
321
|
nodeIdsAOpB: parseAlgebraic("a+b").toIdentifiers(),
|
|
269
|
-
precision:
|
|
270
|
-
expARounded: round(exp(2).evaluate(),
|
|
271
|
-
expBRounded: round(exp(
|
|
322
|
+
precision: 0,
|
|
323
|
+
expARounded: round(exp(2).evaluate(), 0),
|
|
324
|
+
expBRounded: round(exp(3).evaluate(), 0),
|
|
272
325
|
};
|
|
273
326
|
identifiers = identifiersDefault;
|
|
274
327
|
}
|
|
@@ -287,7 +340,7 @@ const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
|
287
340
|
};
|
|
288
341
|
export const approxExpAPlusB = {
|
|
289
342
|
id: "approxExpAPlusB",
|
|
290
|
-
label: "Déterminer une valeur approchée de $\\exp(a \\pm b)$ à partir de $\\exp(a)$ et $\\exp(b)$",
|
|
343
|
+
label: "Déterminer une valeur approchée de $\\exp(a \\pm b)$ à partir de valeurs approchées de $\\exp(a)$ et de $\\exp(b)$",
|
|
291
344
|
isSingleStep: true,
|
|
292
345
|
generator: (nb, opts) => getDistinctQuestions(() => getApproxExpAPlusBQuestion(opts), nb),
|
|
293
346
|
qcmTimer: 60,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rewriteExpUsingExpA.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/exponential/algebraic/rewriteExpUsingExpA.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"rewriteExpUsingExpA.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/exponential/algebraic/rewriteExpUsingExpA.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAkB7C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,eAAe,CAAC;IAC1B,WAAW,EAAE,eAAe,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAiZF,KAAK,OAAO,GAAG;IACb,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAcF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkB9D,CAAC"}
|
|
@@ -12,6 +12,8 @@ import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
|
|
|
12
12
|
import { power } from "../../../../../tree/nodes/operators/powerNode.js";
|
|
13
13
|
import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
|
|
14
14
|
import { parseAlgebraic } from "../../../../../tree/parsers/latexParser.js";
|
|
15
|
+
import { NodeComparator } from "../../../../../tree/utilities/nodeComparator.js";
|
|
16
|
+
import { NodeRewriter } from "../../../../../tree/utilities/nodeRewriter.js";
|
|
15
17
|
import { random } from "../../../../../utils/alea/random.js";
|
|
16
18
|
const myExpFunc = (opts) => {
|
|
17
19
|
return (nodeChild) => new ExpNode(nodeChild, { useExpNotation: opts.isUseExpNotation });
|
|
@@ -170,13 +172,18 @@ $$
|
|
|
170
172
|
const getPropositions = (n, { answer, ...identifiers }, optsIn) => {
|
|
171
173
|
const opts = optsIn ?? optsDefault;
|
|
172
174
|
const myExp = myExpFunc(opts);
|
|
175
|
+
const nodeAnswer = getAnswerNode(identifiers, opts);
|
|
176
|
+
const nodeAnswerSameOrEquivalent = random(NodeRewriter.getArrNodeEquivalent(nodeAnswer));
|
|
173
177
|
const { nodeIdsA, nodeIdsB } = identifiers;
|
|
174
178
|
const [nodeA, nodeB] = [nodeIdsA, nodeIdsB].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
|
|
175
179
|
const propositions = [];
|
|
176
|
-
addValidProp(propositions,
|
|
180
|
+
addValidProp(propositions, nodeAnswerSameOrEquivalent.toTex());
|
|
177
181
|
[0, 1, 2].forEach((rand) => {
|
|
178
182
|
const identifiersWrong = Object.assign({}, identifiers, { rand });
|
|
179
|
-
|
|
183
|
+
const nodeWrong = getAnswerNode(identifiersWrong, opts);
|
|
184
|
+
if (!NodeComparator.isEqualViaSub(nodeWrong, nodeAnswerSameOrEquivalent)) {
|
|
185
|
+
tryToAddWrongProp(propositions, getAnswer(identifiersWrong, opts));
|
|
186
|
+
}
|
|
180
187
|
});
|
|
181
188
|
//exp(a)+exp(b)
|
|
182
189
|
{
|
|
@@ -225,7 +232,15 @@ const isAnswerValid = (ans, { answer, ...identifiers }, optsIn) => {
|
|
|
225
232
|
}
|
|
226
233
|
}
|
|
227
234
|
const nodeAnswer = parseAlgebraic(answer);
|
|
228
|
-
|
|
235
|
+
const isEquivalentFound = () => {
|
|
236
|
+
const arrNodeAnswerEquivalent = NodeRewriter.getArrNodeEquivalent(nodeAnswer);
|
|
237
|
+
return arrNodeAnswerEquivalent.some((nodeAnswerRefined) => {
|
|
238
|
+
const isEqual = NodeComparator.isEqualViaSub(nodeAns, nodeAnswerRefined);
|
|
239
|
+
return isEqual;
|
|
240
|
+
});
|
|
241
|
+
};
|
|
242
|
+
const isValid = isEquivalentFound();
|
|
243
|
+
return isValid;
|
|
229
244
|
};
|
|
230
245
|
const getRewriteExpUsingExpAQuestion = (optsIn) => {
|
|
231
246
|
const opts = optsIn ?? optsDefault;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derivativeOfAExpKT.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/exponential/expKT/derivativeOfAExpKT.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IAEjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAgGF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAkBpD,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { randint } from "../../../../../math/utils/random/randint.js";
|
|
4
|
+
import { exp } from "../../../../../tree/nodes/functions/expNode.js";
|
|
5
|
+
import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
|
|
6
|
+
import { parseAlgebraic } from "../../../../../tree/parsers/latexParser.js";
|
|
7
|
+
import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
|
|
8
|
+
import { alignTex } from "../../../../../utils/latex/alignTex.js";
|
|
9
|
+
const getPropositions = (n, { answer, a, k }) => {
|
|
10
|
+
const propositions = [];
|
|
11
|
+
addValidProp(propositions, answer);
|
|
12
|
+
tryToAddWrongProp(propositions, multiply(a, exp(multiply(k, "t"))).toTex());
|
|
13
|
+
tryToAddWrongProp(propositions, multiply(a, exp("t")).toTex());
|
|
14
|
+
propWhile(propositions, n, () => {
|
|
15
|
+
tryToAddWrongProp(propositions, multiply(randint(-10, 10, [0]), exp(multiply(k, "t"))).toTex());
|
|
16
|
+
});
|
|
17
|
+
return shuffleProps(propositions, n);
|
|
18
|
+
};
|
|
19
|
+
const getAnswer = (identifiers) => {
|
|
20
|
+
const { a, k } = identifiers;
|
|
21
|
+
return multiply(multiply(a, k), exp(multiply(k, "t")))
|
|
22
|
+
.simplify()
|
|
23
|
+
.toTex();
|
|
24
|
+
};
|
|
25
|
+
const getInstruction = (identifiers) => {
|
|
26
|
+
const { a, k } = identifiers;
|
|
27
|
+
return `Soit $f$ la fonction définie sur $\\mathbb{R}$ par :
|
|
28
|
+
|
|
29
|
+
$$
|
|
30
|
+
f(t) = ${multiply(a, exp(multiply(k, "t"))).toTex()}
|
|
31
|
+
$$
|
|
32
|
+
|
|
33
|
+
Calculer la dérivée $f'$ de $f$.`;
|
|
34
|
+
};
|
|
35
|
+
const getHint = () => {
|
|
36
|
+
return `Pour tout $k$ réel, on a :
|
|
37
|
+
|
|
38
|
+
$$
|
|
39
|
+
\\left(e^{kt}\\right)' = ke^{kt}
|
|
40
|
+
$$`;
|
|
41
|
+
};
|
|
42
|
+
const getCorrection = (identifiers) => {
|
|
43
|
+
const { a, k } = identifiers;
|
|
44
|
+
return `Pour tout $k$ réel, on a :
|
|
45
|
+
|
|
46
|
+
$$
|
|
47
|
+
\\left(e^{kt}\\right)' = ke^{kt}
|
|
48
|
+
$$
|
|
49
|
+
|
|
50
|
+
Ici, on a donc pour tout $t$ réel :
|
|
51
|
+
|
|
52
|
+
${alignTex([
|
|
53
|
+
["f'(t)", "=", multiply(a, multiply(k, exp(multiply(k, "t")))).toTex()],
|
|
54
|
+
["", "=", getAnswer(identifiers)],
|
|
55
|
+
])}`;
|
|
56
|
+
};
|
|
57
|
+
const getKeys = () => {
|
|
58
|
+
return ["epower", "t"];
|
|
59
|
+
};
|
|
60
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
61
|
+
try {
|
|
62
|
+
const parsed = parseAlgebraic(ans);
|
|
63
|
+
if (!parsed)
|
|
64
|
+
return false;
|
|
65
|
+
return parsed.simplify().toTex() === answer;
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
return handleVEAError(err);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const getDerivativeOfAExpKtQuestion = () => {
|
|
72
|
+
const a = randint(-10, 10, [0, 1]);
|
|
73
|
+
const k = randint(-10, 10, [0, 1]);
|
|
74
|
+
const identifiers = {
|
|
75
|
+
a,
|
|
76
|
+
k,
|
|
77
|
+
};
|
|
78
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
79
|
+
};
|
|
80
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
81
|
+
return {
|
|
82
|
+
answer: getAnswer(identifiers),
|
|
83
|
+
instruction: getInstruction(identifiers),
|
|
84
|
+
keys: getKeys(identifiers),
|
|
85
|
+
answerFormat: "tex",
|
|
86
|
+
identifiers,
|
|
87
|
+
hint: getHint(identifiers),
|
|
88
|
+
correction: getCorrection(identifiers),
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
export const derivativeOfAExpKT = {
|
|
92
|
+
id: "derivativeOfAExpKT",
|
|
93
|
+
connector: "=",
|
|
94
|
+
label: "Dérivée du type $ae^{kt}$",
|
|
95
|
+
isSingleStep: true,
|
|
96
|
+
generator: (nb, opts) => getDistinctQuestions(() => getDerivativeOfAExpKtQuestion(opts), nb),
|
|
97
|
+
qcmTimer: 60,
|
|
98
|
+
freeTimer: 60,
|
|
99
|
+
getPropositions,
|
|
100
|
+
isAnswerValid,
|
|
101
|
+
subject: "Mathématiques",
|
|
102
|
+
getInstruction,
|
|
103
|
+
getHint,
|
|
104
|
+
getCorrection,
|
|
105
|
+
getAnswer,
|
|
106
|
+
getQuestionFromIdentifiers,
|
|
107
|
+
hasHintAndCorrection: true,
|
|
108
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drugConcentrationMaximum.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/exponential/expKT/drugConcentrationMaximum.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CAEX,CAAC;AAyIF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAmB1D,CAAC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { rationalVEA } from "../../../../../exercises/vea/rationalVEA.js";
|
|
4
|
+
import { randfloat } from "../../../../../math/utils/random/randfloat.js";
|
|
5
|
+
import { randint } from "../../../../../math/utils/random/randint.js";
|
|
6
|
+
import { round } from "../../../../../math/utils/round.js";
|
|
7
|
+
import { exp } from "../../../../../tree/nodes/functions/expNode.js";
|
|
8
|
+
import { frac } from "../../../../../tree/nodes/operators/fractionNode.js";
|
|
9
|
+
import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
|
|
10
|
+
import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
|
|
11
|
+
import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
|
|
12
|
+
import { alignTex } from "../../../../../utils/latex/alignTex.js";
|
|
13
|
+
const getPropositions = (n, { answer }) => {
|
|
14
|
+
const propositions = [];
|
|
15
|
+
addValidProp(propositions, answer);
|
|
16
|
+
propWhile(propositions, n, () => {
|
|
17
|
+
tryToAddWrongProp(propositions, randfloat(0.1, 4, 2).frenchify());
|
|
18
|
+
});
|
|
19
|
+
return shuffleProps(propositions, n);
|
|
20
|
+
};
|
|
21
|
+
const getAnswer = (identifiers) => {
|
|
22
|
+
//t = 1/k
|
|
23
|
+
return round(frac(1, identifiers.k).evaluate(), 2).frenchify();
|
|
24
|
+
};
|
|
25
|
+
const getFunc = (identifiers) => {
|
|
26
|
+
const { a, k } = identifiers;
|
|
27
|
+
return multiply(a, multiply("t", exp(multiply(-k, "t")))).simplify();
|
|
28
|
+
};
|
|
29
|
+
const getInstruction = (identifiers) => {
|
|
30
|
+
return `On fait absorber un médicament, sous forme de compriné, à un patient. On modélise la quantité de médicament présente dans le sang du patient, exprimé en $\\textrm{mg}$, par la fonction $f$ définie sur l'intervalle $[0; +\\infty[$ par :
|
|
31
|
+
|
|
32
|
+
$$
|
|
33
|
+
f(t)=${getFunc(identifiers).toTex()}
|
|
34
|
+
$$
|
|
35
|
+
|
|
36
|
+
où $t$ définit le temps, exprimé en heure, écoulé depuis
|
|
37
|
+
la prise du comprimé.
|
|
38
|
+
|
|
39
|
+
Au bout de combien de temps la quantité de médicament présente dans le sang du patient sera-t-elle maximale ?
|
|
40
|
+
|
|
41
|
+
Donner une valeur arrondie au centième.`;
|
|
42
|
+
};
|
|
43
|
+
const getHint = () => {
|
|
44
|
+
return `Dérive la fonction $f$, puis étudie le signe de $f'(x)$. Tu pourras alors en déduire les variations de $f$, et ainsi déterminer la valeur de $t$ pour laquelle la quantité de médicament dans le sang du patient sera maximale.`;
|
|
45
|
+
};
|
|
46
|
+
const getCorrection = (identifiers) => {
|
|
47
|
+
const { a, k } = identifiers;
|
|
48
|
+
//atexp(-kt)
|
|
49
|
+
//f' = aexp(-kt) + at(-kexp(-kt))
|
|
50
|
+
//f' = exp(-kt)(a-kat)
|
|
51
|
+
//f' = (aexp(-kt)(1-kt)
|
|
52
|
+
//t = 1/k
|
|
53
|
+
const expo = exp(multiply(-k, "t"));
|
|
54
|
+
return `On calcule $f'(t)$. Pour cela, on utilise les deux propriétés suivantes :
|
|
55
|
+
|
|
56
|
+
$$
|
|
57
|
+
(uv)' = u'v+uv'
|
|
58
|
+
$$
|
|
59
|
+
|
|
60
|
+
et
|
|
61
|
+
|
|
62
|
+
$$
|
|
63
|
+
\\left(e^{kx}\\right)' = ke^{kx}
|
|
64
|
+
$$
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
On a donc :
|
|
68
|
+
|
|
69
|
+
${alignTex([
|
|
70
|
+
[
|
|
71
|
+
"f'(t)",
|
|
72
|
+
"=",
|
|
73
|
+
substract(multiply(a, expo), multiply(multiply(a, "t"), multiply(-k, expo))).toTex(),
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
"",
|
|
77
|
+
"=",
|
|
78
|
+
multiply(multiply(a, expo), substract(1, multiply(k, "t"))).toTex(),
|
|
79
|
+
],
|
|
80
|
+
])}
|
|
81
|
+
|
|
82
|
+
On étudie alors le signe de $f'(t)$ :
|
|
83
|
+
|
|
84
|
+
- $${multiply(a, expo).toTex()}$ est positif sur $\\mathbb{R}$ car l'exponentielle est strictement positive sur $\\mathbb{R}$.
|
|
85
|
+
|
|
86
|
+
- $${substract(1, multiply(k, "t")).toTex()}\\geq 0 \\iff t\\leq ${frac(1, k).toTex()}$
|
|
87
|
+
|
|
88
|
+
La fonction $f$ admet donc un maximum pour $t\\approx ${getAnswer(identifiers)}$.
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
`;
|
|
92
|
+
};
|
|
93
|
+
const getKeys = () => {
|
|
94
|
+
return [];
|
|
95
|
+
};
|
|
96
|
+
const isAnswerValid = (ans, { k }) => {
|
|
97
|
+
try {
|
|
98
|
+
return rationalVEA(ans, frac(1, k).toTex(), {
|
|
99
|
+
allowDecimal: true,
|
|
100
|
+
decimalPrecision: 2,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
return handleVEAError(err);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const getDrugConcentrationMaximumQuestion = () => {
|
|
108
|
+
const a = 0.5 * randint(1, 20);
|
|
109
|
+
const k = randfloat(0.1, 3, 1, [1]);
|
|
110
|
+
const identifiers = {
|
|
111
|
+
a,
|
|
112
|
+
k,
|
|
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 drugConcentrationMaximum = {
|
|
128
|
+
id: "drugConcentrationMaximum",
|
|
129
|
+
connector: "=",
|
|
130
|
+
label: "Déterminer la concentration maximale d'un médicament dans le sang pour une fonction avec exponentielle du type $f(t) = ate^{-kt}$",
|
|
131
|
+
isSingleStep: true,
|
|
132
|
+
generator: (nb, opts) => getDistinctQuestions(() => getDrugConcentrationMaximumQuestion(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 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/exponential/expKT/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expSimplifiying.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/exponential/expSimplifiying.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"expSimplifiying.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/exponential/expSimplifiying.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAkBrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AA0PF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAajD,CAAC"}
|