math-exercises 3.0.188 → 3.0.189
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/derivation/derivative/valueDerivativeFromFunctionExpression.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.js +44 -37
- package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.js +16 -61
- package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.js +27 -35
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.d.ts +8 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.js +129 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentComplete.d.ts +8 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentComplete.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentComplete.js +108 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.d.ts +8 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.js +92 -0
- package/lib/exercises/math/functions/affines/adjustment/index.d.ts +4 -0
- package/lib/exercises/math/functions/affines/adjustment/index.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/adjustment/index.js +3 -0
- package/lib/exercises/math/functions/affines/index.d.ts +2 -4
- package/lib/exercises/math/functions/affines/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/index.js +2 -4
- package/lib/exercises/math/functions/affines/situations/affineFromExercise.d.ts +10 -0
- package/lib/exercises/math/functions/affines/situations/affineFromExercise.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/situations/affineFromExercise.js +219 -0
- package/lib/exercises/math/functions/affines/situations/affineModelisationSituations.d.ts +10 -0
- package/lib/exercises/math/functions/affines/situations/affineModelisationSituations.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/situations/affineModelisationSituations.js +69 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationComputeAntecedent.d.ts +10 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationComputeAntecedent.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationComputeAntecedent.js +133 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationComputeImage.d.ts +10 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationComputeImage.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationComputeImage.js +229 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationThreshold.d.ts +10 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationThreshold.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationThreshold.js +166 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationVariation.d.ts +9 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationVariation.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationVariation.js +78 -0
- package/lib/exercises/math/functions/affines/situations/index.d.ts +6 -0
- package/lib/exercises/math/functions/affines/situations/index.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/situations/index.js +5 -0
- package/lib/exercises/math/probaStat/randomVariable/index.d.ts +1 -7
- package/lib/exercises/math/probaStat/randomVariable/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/randomVariable/index.js +1 -7
- package/lib/exercises/math/probaStat/randomVariable/situations/index.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/index.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/index.js +7 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationAverage.d.ts +11 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationAverage.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationAverage.js +112 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationComputeProbability.d.ts +9 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationComputeProbability.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationComputeProbability.js +176 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationIsGameFavorable.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationIsGameFavorable.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationIsGameFavorable.js +94 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationProbabilityLaw.d.ts +9 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationProbabilityLaw.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationProbabilityLaw.js +166 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationStandardDeviation.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationStandardDeviation.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationStandardDeviation.js +133 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationValues.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationValues.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationValues.js +211 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationVariance.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationVariance.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationVariance.js +113 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituations.d.ts +41 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituations.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituations.js +173 -0
- package/lib/exercises/math/python/list/pyListMutationMix.d.ts.map +1 -1
- package/lib/exercises/math/python/list/pyListMutationMix.js +11 -6
- package/lib/index.d.ts +44 -24
- package/lib/index.d.ts.map +1 -1
- package/lib/tree/utilities/nodeUtils.d.ts +2 -0
- package/lib/tree/utilities/nodeUtils.d.ts.map +1 -1
- package/lib/tree/utilities/nodeUtils.js +40 -0
- package/package.json +1 -1
package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"valueDerivativeFromFunctionExpression.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AASrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAgF7C,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,eAAe,CAAC;IAC/B,QAAQ,EAAE,eAAe,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;
|
|
1
|
+
{"version":3,"file":"valueDerivativeFromFunctionExpression.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AASrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAgF7C,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,eAAe,CAAC;IAC/B,QAAQ,EAAE,eAAe,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAqQF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAgDF,eAAO,MAAM,qCAAqC,EAAE,QAAQ,CAC1D,WAAW,EACX,OAAO,CAoBR,CAAC"}
|
|
@@ -155,32 +155,37 @@ const getPropositions = (n, { answer, ...identifiers }) => {
|
|
|
155
155
|
const { nodeIdsXAsked, nodeIdsF } = identifiers;
|
|
156
156
|
const [nodeXAsked, nodeF] = [nodeIdsXAsked, nodeIdsF].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
|
|
157
157
|
const nodeDerivative = getPrettyDerivativeNode(nodeF);
|
|
158
|
-
function tryToAddWrongPropWithSuccess(propositions,
|
|
158
|
+
function tryToAddWrongPropWithSuccess(propositions, func) {
|
|
159
159
|
const nbPropsBefore = propositions.length;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
try {
|
|
161
|
+
tryToAddWrongProp(propositions, func());
|
|
162
|
+
const nbPropsAfter = propositions.length;
|
|
163
|
+
return nbPropsAfter !== nbPropsBefore;
|
|
164
|
+
}
|
|
165
|
+
catch (_) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
163
168
|
}
|
|
164
169
|
propWhile(propositions, n, () => {
|
|
165
|
-
if (!tryToAddWrongPropWithSuccess(propositions, (
|
|
170
|
+
if (!tryToAddWrongPropWithSuccess(propositions, () => {
|
|
166
171
|
const nodeFShuffled = NodeShuffler.deepShuffle(nodeF);
|
|
167
172
|
const identifiersWrong = {
|
|
168
173
|
...identifiers,
|
|
169
174
|
nodeIdsF: nodeFShuffled.toIdentifiers(),
|
|
170
175
|
};
|
|
171
176
|
return getAnswer(identifiersWrong);
|
|
172
|
-
})
|
|
173
|
-
if (!tryToAddWrongPropWithSuccess(propositions, (
|
|
177
|
+
})) {
|
|
178
|
+
if (!tryToAddWrongPropWithSuccess(propositions, () => {
|
|
174
179
|
const nodeDerivativeShuffled = NodeShuffler.deepShuffle(nodeDerivative);
|
|
175
180
|
const nodeWrong = nodeBySubstitutingVar(nodeDerivativeShuffled, nodeXAsked, "x".toTree()).simplify();
|
|
176
181
|
return nodeWrong.simplify().toTex();
|
|
177
|
-
})
|
|
182
|
+
})) {
|
|
178
183
|
try {
|
|
179
|
-
tryToAddWrongPropWithSuccess(propositions, (
|
|
184
|
+
tryToAddWrongPropWithSuccess(propositions, () => {
|
|
180
185
|
const typeF = random(arrayedOptsDefault.typeF);
|
|
181
186
|
const identifiersWrong = createRandomIdentifiers(typeF);
|
|
182
187
|
return getAnswer(identifiersWrong);
|
|
183
|
-
})
|
|
188
|
+
});
|
|
184
189
|
}
|
|
185
190
|
catch (_) {
|
|
186
191
|
tryToAddWrongProp(propositions, randint(-20, 20).frenchify());
|
|
@@ -214,48 +219,50 @@ const createRandomIdentifiers = (typeF) => {
|
|
|
214
219
|
};
|
|
215
220
|
return identifiers;
|
|
216
221
|
};
|
|
217
|
-
const
|
|
218
|
-
const
|
|
219
|
-
|
|
222
|
+
const isIdentifiersQCPassed = (identifiers) => {
|
|
223
|
+
const isExploding = (identifiers) => {
|
|
224
|
+
const { nodeIdsXAsked, nodeIdsF } = identifiers;
|
|
225
|
+
const [nodeXAsked, nodeF] = [nodeIdsXAsked, nodeIdsF].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
|
|
226
|
+
const nodeDerivative = getPrettyDerivativeNode(nodeF);
|
|
227
|
+
let isExploding = false;
|
|
228
|
+
try {
|
|
229
|
+
const _nodeValueFunction = nodeBySubstitutingVar(nodeF, nodeXAsked, "x".toTree()).simplify();
|
|
230
|
+
const _nodeValueDerivative = nodeBySubstitutingVar(nodeDerivative, nodeXAsked, "x".toTree()).simplify();
|
|
231
|
+
getAnswer(identifiers);
|
|
232
|
+
}
|
|
233
|
+
catch (_) {
|
|
234
|
+
isExploding = true;
|
|
235
|
+
}
|
|
236
|
+
return isExploding;
|
|
237
|
+
};
|
|
238
|
+
return !isExploding(identifiers);
|
|
239
|
+
};
|
|
240
|
+
const createQCPassedIdentifiers = (typeF) => {
|
|
220
241
|
let identifiers;
|
|
221
|
-
let isValid = false;
|
|
222
242
|
let counter = -1;
|
|
243
|
+
let isValid = false;
|
|
223
244
|
while (!isValid && counter < 100) {
|
|
224
245
|
counter++;
|
|
225
246
|
const identifiersCandidate = createRandomIdentifiers(typeF);
|
|
226
|
-
|
|
227
|
-
const { nodeIdsXAsked, nodeIdsF } = identifiers;
|
|
228
|
-
const [nodeXAsked, nodeF] = [nodeIdsXAsked, nodeIdsF].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
|
|
229
|
-
const nodeDerivative = getPrettyDerivativeNode(nodeF);
|
|
230
|
-
let isExploding = false;
|
|
231
|
-
try {
|
|
232
|
-
const _nodeValueFunction = nodeBySubstitutingVar(nodeF, nodeXAsked, "x".toTree()).simplify();
|
|
233
|
-
const _nodeValueDerivative = nodeBySubstitutingVar(nodeDerivative, nodeXAsked, "x".toTree()).simplify();
|
|
234
|
-
}
|
|
235
|
-
catch (_) {
|
|
236
|
-
isExploding = true;
|
|
237
|
-
}
|
|
238
|
-
return isExploding;
|
|
239
|
-
};
|
|
240
|
-
isValid = !isExploding(identifiersCandidate);
|
|
247
|
+
isValid = isIdentifiersQCPassed(identifiersCandidate);
|
|
241
248
|
if (isValid) {
|
|
242
249
|
identifiers = identifiersCandidate;
|
|
243
250
|
}
|
|
244
251
|
}
|
|
245
252
|
if (!isValid) {
|
|
246
253
|
const identifiersDefault = {
|
|
247
|
-
nodeIdsXAsked:
|
|
248
|
-
|
|
249
|
-
value: 3,
|
|
250
|
-
},
|
|
251
|
-
nodeIdsF: {
|
|
252
|
-
id: 10,
|
|
253
|
-
name: "x",
|
|
254
|
-
},
|
|
254
|
+
nodeIdsXAsked: (3).toTree().toIdentifiers(),
|
|
255
|
+
nodeIdsF: "x".toTree().toIdentifiers(),
|
|
255
256
|
typeF: "$x$",
|
|
256
257
|
};
|
|
257
258
|
identifiers = identifiersDefault;
|
|
258
259
|
}
|
|
260
|
+
return identifiers;
|
|
261
|
+
};
|
|
262
|
+
const getValueDerivativeFromFunctionExpressionQuestion = (optsIn) => {
|
|
263
|
+
const arrayedOptions = optsIn ?? arrayedOptsDefault;
|
|
264
|
+
const typeF = random(arrayedOptions.typeF);
|
|
265
|
+
const identifiers = createQCPassedIdentifiers(typeF);
|
|
259
266
|
return getQuestionFromIdentifiers(identifiers);
|
|
260
267
|
};
|
|
261
268
|
const getQuestionFromIdentifiers = (identifiers) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findExtremaFromFunctionExpression.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/variations/findExtremaFromFunctionExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"findExtremaFromFunctionExpression.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/variations/findExtremaFromFunctionExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAkS7C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAiSF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAoCF,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAqB1E,CAAC"}
|
|
@@ -14,7 +14,11 @@ import { SetVEA } from "../../../../exercises/vea/setVEA.js";
|
|
|
14
14
|
import { dividersOf } from "../../../../math/utils/arithmetic/dividersOf.js";
|
|
15
15
|
import { probaFlip } from "../../../../utils/alea/probaFlip.js";
|
|
16
16
|
import { nodeBySubstitutingVar } from "../../../../math/utils/functions/functionComposition.js";
|
|
17
|
+
import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
|
|
17
18
|
import { NodeUtils } from "../../../../tree/utilities/nodeUtils.js";
|
|
19
|
+
import { add } from "../../../../tree/nodes/operators/addNode.js";
|
|
20
|
+
import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
21
|
+
import { power } from "../../../../tree/nodes/operators/powerNode.js";
|
|
18
22
|
const tryToSimplify = (node, simplifyOptions) => {
|
|
19
23
|
try {
|
|
20
24
|
return node.simplify(simplifyOptions);
|
|
@@ -399,7 +403,16 @@ const isIdentifiersQCPassed = (identifiers) => {
|
|
|
399
403
|
return false;
|
|
400
404
|
}
|
|
401
405
|
};
|
|
402
|
-
|
|
406
|
+
const isVEAOk = (identifiers) => {
|
|
407
|
+
try {
|
|
408
|
+
const answer = getAnswer(identifiers);
|
|
409
|
+
return isAnswerValid(answer, { answer, ...identifiers });
|
|
410
|
+
}
|
|
411
|
+
catch (_) {
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
return isSolutionPrettyAndNotExploding(identifiers) && isVEAOk(identifiers);
|
|
403
416
|
};
|
|
404
417
|
const getFindExtremaFromFunctionExpressionQuestion = (optsIn) => {
|
|
405
418
|
const arrayedOptions = optsIn ?? arrayedOptsDefault;
|
|
@@ -418,67 +431,9 @@ const getFindExtremaFromFunctionExpressionQuestion = (optsIn) => {
|
|
|
418
431
|
}
|
|
419
432
|
if (!isValid) {
|
|
420
433
|
// console.log("will use identifiersDefault");
|
|
434
|
+
const nodeF = frac(add(multiply(30, new VariableNode("x")), 10), add(add(multiply(6, power(new VariableNode("x"), 2)), multiply(3, new VariableNode("x"))), 1));
|
|
421
435
|
const identifiersDefault = {
|
|
422
|
-
nodeIdsF:
|
|
423
|
-
id: 3,
|
|
424
|
-
leftChild: {
|
|
425
|
-
id: 0,
|
|
426
|
-
leftChild: {
|
|
427
|
-
id: 2,
|
|
428
|
-
leftChild: {
|
|
429
|
-
id: 7,
|
|
430
|
-
value: 30,
|
|
431
|
-
},
|
|
432
|
-
rightChild: {
|
|
433
|
-
id: 10,
|
|
434
|
-
name: "x",
|
|
435
|
-
},
|
|
436
|
-
},
|
|
437
|
-
rightChild: {
|
|
438
|
-
id: 7,
|
|
439
|
-
value: 10,
|
|
440
|
-
},
|
|
441
|
-
},
|
|
442
|
-
rightChild: {
|
|
443
|
-
id: 0,
|
|
444
|
-
leftChild: {
|
|
445
|
-
id: 0,
|
|
446
|
-
leftChild: {
|
|
447
|
-
id: 2,
|
|
448
|
-
leftChild: {
|
|
449
|
-
id: 7,
|
|
450
|
-
value: 6,
|
|
451
|
-
},
|
|
452
|
-
rightChild: {
|
|
453
|
-
id: 5,
|
|
454
|
-
leftChild: {
|
|
455
|
-
id: 10,
|
|
456
|
-
name: "x",
|
|
457
|
-
},
|
|
458
|
-
rightChild: {
|
|
459
|
-
id: 7,
|
|
460
|
-
value: 2,
|
|
461
|
-
},
|
|
462
|
-
},
|
|
463
|
-
},
|
|
464
|
-
rightChild: {
|
|
465
|
-
id: 2,
|
|
466
|
-
leftChild: {
|
|
467
|
-
id: 7,
|
|
468
|
-
value: 3,
|
|
469
|
-
},
|
|
470
|
-
rightChild: {
|
|
471
|
-
id: 10,
|
|
472
|
-
name: "x",
|
|
473
|
-
},
|
|
474
|
-
},
|
|
475
|
-
},
|
|
476
|
-
rightChild: {
|
|
477
|
-
id: 7,
|
|
478
|
-
value: 1,
|
|
479
|
-
},
|
|
480
|
-
},
|
|
481
|
-
},
|
|
436
|
+
nodeIdsF: nodeF.toIdentifiers(),
|
|
482
437
|
typeF: "$\\frac{dx+m}{ax^2+bx+c}$",
|
|
483
438
|
typeRoots: "entières",
|
|
484
439
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signVarTableQuotientFExp.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/variations/signVarTableQuotientFExp.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"signVarTableQuotientFExp.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/variations/signVarTableQuotientFExp.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AA6HrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAqbF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAiBF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAmBnE,CAAC"}
|
|
@@ -10,29 +10,27 @@ import { opposite } from "../../../../tree/nodes/functions/oppositeNode.js";
|
|
|
10
10
|
import { InequationSolutionNode } from "../../../../tree/nodes/inequations/inequationSolutionNode.js";
|
|
11
11
|
import { MinusInfinityNode, PlusInfinityNode, } from "../../../../tree/nodes/numbers/infiniteNode.js";
|
|
12
12
|
import { frac, isFractionNode, } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
13
|
-
import { isMultiplyNode, multiply, } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
14
13
|
import { substract } from "../../../../tree/nodes/operators/substractNode.js";
|
|
15
14
|
import { ClosureType } from "../../../../tree/nodes/sets/closure.js";
|
|
16
15
|
import { IntervalNode } from "../../../../tree/nodes/sets/intervalNode.js";
|
|
17
16
|
import { isUnionIntervalNode, UnionIntervalNode, } from "../../../../tree/nodes/sets/unionIntervalNode.js";
|
|
17
|
+
import { NodeSimplifier } from "../../../../tree/utilities/nodeSimplifier.js";
|
|
18
18
|
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
19
19
|
import { zip } from "../../../../utils/arrays/arrayZip.js";
|
|
20
20
|
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
21
21
|
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
const tryToSimplify = (node) => {
|
|
23
|
+
try {
|
|
24
|
+
return NodeSimplifier.simplifyByVibrating(node, 5, true);
|
|
25
|
+
}
|
|
26
|
+
catch (_) {
|
|
26
27
|
try {
|
|
27
|
-
return
|
|
28
|
+
return NodeSimplifier.simplifyByVibrating(node, 5, false);
|
|
28
29
|
}
|
|
29
30
|
catch (_) {
|
|
30
31
|
return node;
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
|
-
else {
|
|
34
|
-
return node;
|
|
35
|
-
}
|
|
36
34
|
};
|
|
37
35
|
const getInstructionNode = (a, b, c, isFOverExp) => {
|
|
38
36
|
const nodeF = getNodeF(a, b, c);
|
|
@@ -42,10 +40,10 @@ const getInstructionNode = (a, b, c, isFOverExp) => {
|
|
|
42
40
|
};
|
|
43
41
|
const getNodeF = (a, b, c) => {
|
|
44
42
|
if (a !== undefined) {
|
|
45
|
-
return TrinomConstructor.fromCoeffs([c, b, a]).toTree()
|
|
43
|
+
return tryToSimplify(TrinomConstructor.fromCoeffs([c, b, a]).toTree());
|
|
46
44
|
}
|
|
47
45
|
else if (b !== undefined) {
|
|
48
|
-
return AffineConstructor.fromCoeffs([c, b]).toTree()
|
|
46
|
+
return tryToSimplify(AffineConstructor.fromCoeffs([c, b]).toTree());
|
|
49
47
|
}
|
|
50
48
|
else {
|
|
51
49
|
return c.toTree();
|
|
@@ -67,7 +65,7 @@ const getRootNodesOfDerivative = (a, b, c) => {
|
|
|
67
65
|
}
|
|
68
66
|
else {
|
|
69
67
|
const [c, b] = coeffs;
|
|
70
|
-
return [frac(opposite(c), b)
|
|
68
|
+
return [tryToSimplify(frac(opposite(c), b))];
|
|
71
69
|
}
|
|
72
70
|
};
|
|
73
71
|
const getTrinomInequationSolutionNode = (coeffs, ineqType) => {
|
|
@@ -144,11 +142,9 @@ const getAnswerTable = (identifiers) => {
|
|
|
144
142
|
x: rootNodeMinus1.evaluate(),
|
|
145
143
|
});
|
|
146
144
|
const [strSignHPrimeRootMinus1, strSignHPrimeRootPlus1] = hPrimeRootMinus1 > 0 ? ["+", "-"] : ["-", "+"];
|
|
147
|
-
const nodeHRoot = nodeH
|
|
148
|
-
.toDetailedEvaluation({
|
|
145
|
+
const nodeHRoot = tryToSimplify(nodeH.toDetailedEvaluation({
|
|
149
146
|
x: rootNode,
|
|
150
|
-
})
|
|
151
|
-
.simplify();
|
|
147
|
+
}));
|
|
152
148
|
return [
|
|
153
149
|
["$x$", "-\\infty", "\\ ", rootNode.toTex(), "\\ ", "+\\infty"],
|
|
154
150
|
//sign
|
|
@@ -181,11 +177,9 @@ const getAnswerTable = (identifiers) => {
|
|
|
181
177
|
x: root1Minus1.evaluate(),
|
|
182
178
|
});
|
|
183
179
|
const [strSignHPrimeRoot1Minus1, strSignHPrimeRootAvg, strSignHPrimeRoot2Plus1,] = hPrimeRoot1Minus1 > 0 ? ["+", "-", "+"] : ["-", "+", "-"];
|
|
184
|
-
const [nodeHRoot1, nodeHRoot2] = [rootNode1, rootNode2].map((nodeX) => nodeH
|
|
185
|
-
.toDetailedEvaluation({
|
|
180
|
+
const [nodeHRoot1, nodeHRoot2] = [rootNode1, rootNode2].map((nodeX) => tryToSimplify(nodeH.toDetailedEvaluation({
|
|
186
181
|
x: nodeX,
|
|
187
|
-
})
|
|
188
|
-
.simplify());
|
|
182
|
+
})));
|
|
189
183
|
return [
|
|
190
184
|
[
|
|
191
185
|
"$x$",
|
|
@@ -301,32 +295,30 @@ const getCorrection = (identifiers) => {
|
|
|
301
295
|
const signs = hPrimeRootMinus1 > 0 ? ["+", "-"] : ["-", "+"];
|
|
302
296
|
const signWords = signs.map((strSign) => strSign === "+" ? "positive" : "négative");
|
|
303
297
|
const words = signs.map((strSign) => strSign === "+" ? "croissante" : "décroissante");
|
|
304
|
-
const image = nodeH
|
|
305
|
-
.toDetailedEvaluation({
|
|
298
|
+
const image = tryToSimplify(nodeH.toDetailedEvaluation({
|
|
306
299
|
x: rootNode,
|
|
307
|
-
})
|
|
308
|
-
.simplify();
|
|
300
|
+
}));
|
|
309
301
|
return `On calcule $h'$ :
|
|
310
302
|
|
|
311
303
|
$$
|
|
312
|
-
h'(x) = ${nodeHPrime
|
|
304
|
+
h'(x) = ${tryToSimplify(nodeHPrime).toTex()}
|
|
313
305
|
$$
|
|
314
306
|
|
|
315
307
|
On détermine ensuite le signe de $h'(x)$ :
|
|
316
308
|
|
|
317
309
|
${alignTex([
|
|
318
310
|
["", "h'(x) \\geq 0"],
|
|
319
|
-
["\\iff", nodeHPrime
|
|
311
|
+
["\\iff", tryToSimplify(nodeHPrime).toTex() + "\\geq 0"],
|
|
320
312
|
[
|
|
321
313
|
"\\iff",
|
|
322
314
|
(() => {
|
|
323
315
|
if (isFOverExp) {
|
|
324
|
-
return frac(nodeHPrime, exp(opposite("x".toTree())))
|
|
316
|
+
return tryToSimplify(frac(nodeHPrime, exp(opposite("x".toTree()))));
|
|
325
317
|
}
|
|
326
318
|
else {
|
|
327
|
-
const nodeWithoutExp = frac(nodeHPrime, exp("x".toTree()))
|
|
319
|
+
const nodeWithoutExp = tryToSimplify(frac(nodeHPrime, exp("x".toTree())));
|
|
328
320
|
if (isFractionNode(nodeWithoutExp)) {
|
|
329
|
-
return nodeWithoutExp.leftChild
|
|
321
|
+
return tryToSimplify(nodeWithoutExp.leftChild);
|
|
330
322
|
}
|
|
331
323
|
else {
|
|
332
324
|
return nodeWithoutExp;
|
|
@@ -344,7 +336,7 @@ On en conclut que $h$ est ${words[0]} sur $]-\\infty; ${rootTex}]$, puis ${words
|
|
|
344
336
|
Pour compléter le tableau, il ne reste plus qu'à calculer l'image par $h$ de $${rootTex}$ :
|
|
345
337
|
|
|
346
338
|
$$
|
|
347
|
-
h\\left(${rootTex}\\right) = ${image.toTex()} = ${image
|
|
339
|
+
h\\left(${rootTex}\\right) = ${image.toTex()} = ${tryToSimplify(image).toTex()}
|
|
348
340
|
$$`;
|
|
349
341
|
}
|
|
350
342
|
else {
|
|
@@ -361,24 +353,24 @@ $$`;
|
|
|
361
353
|
return `On calcule $h'$ :
|
|
362
354
|
|
|
363
355
|
$$
|
|
364
|
-
h'(x) = ${nodeHPrime
|
|
356
|
+
h'(x) = ${tryToSimplify(nodeHPrime).toTex()}
|
|
365
357
|
$$
|
|
366
358
|
|
|
367
359
|
On détermine ensuite le signe de $h'(x)$ :
|
|
368
360
|
|
|
369
361
|
${alignTex([
|
|
370
362
|
["", "h'(x) \\geq 0"],
|
|
371
|
-
["\\iff", nodeHPrime
|
|
363
|
+
["\\iff", tryToSimplify(nodeHPrime).toTex() + "\\geq 0"],
|
|
372
364
|
[
|
|
373
365
|
"\\iff",
|
|
374
366
|
(() => {
|
|
375
367
|
if (isFOverExp) {
|
|
376
|
-
return frac(nodeHPrime, exp(opposite("x".toTree())))
|
|
368
|
+
return tryToSimplify(frac(nodeHPrime, exp(opposite("x".toTree()))));
|
|
377
369
|
}
|
|
378
370
|
else {
|
|
379
|
-
const nodeWithoutExp = frac(nodeHPrime, exp("x".toTree()))
|
|
371
|
+
const nodeWithoutExp = tryToSimplify(frac(nodeHPrime, exp("x".toTree())));
|
|
380
372
|
if (isFractionNode(nodeWithoutExp)) {
|
|
381
|
-
return nodeWithoutExp.leftChild
|
|
373
|
+
return tryToSimplify(nodeWithoutExp.leftChild);
|
|
382
374
|
}
|
|
383
375
|
else {
|
|
384
376
|
return nodeWithoutExp;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Exercise } from "../../../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
xValues: number[];
|
|
4
|
+
yValues: number[];
|
|
5
|
+
};
|
|
6
|
+
export declare const affineAdjustmentExercise: Exercise<Identifiers>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=affineAdjustment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"affineAdjustment.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/affines/adjustment/affineAdjustment.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAgBrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AA8KF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAa1D,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { randfloat } from "../../../../../math/utils/random/randfloat.js";
|
|
4
|
+
import { randint } from "../../../../../math/utils/random/randint.js";
|
|
5
|
+
import { round } from "../../../../../math/utils/round.js";
|
|
6
|
+
import { leastSquares } from "../../../../../math/utils/stats/leastSquares.js";
|
|
7
|
+
import { EqualNode } from "../../../../../tree/nodes/equations/equalNode.js";
|
|
8
|
+
import { NumberNode } from "../../../../../tree/nodes/numbers/numberNode.js";
|
|
9
|
+
import { AddNode } from "../../../../../tree/nodes/operators/addNode.js";
|
|
10
|
+
import { MultiplyNode } from "../../../../../tree/nodes/operators/multiplyNode.js";
|
|
11
|
+
import { SubstractNode } from "../../../../../tree/nodes/operators/substractNode.js";
|
|
12
|
+
import { VariableNode } from "../../../../../tree/nodes/variables/variableNode.js";
|
|
13
|
+
import { dollarize } from "../../../../../utils/latex/dollarize.js";
|
|
14
|
+
import { mdTable } from "../../../../../utils/markdown/mdTable.js";
|
|
15
|
+
const getInstruction = ({ xValues, yValues }) => {
|
|
16
|
+
const dataTable = mdTable([
|
|
17
|
+
["$x$", ...xValues.map((n) => dollarize(n.frenchify()))],
|
|
18
|
+
["$y$", ...yValues.map((n) => dollarize(n.frenchify()))],
|
|
19
|
+
]);
|
|
20
|
+
return `On considère la série statistique ci-dessous. Déterminer l'équation de la droite d'ajustement obtenue par la méthode des moindres carrés.
|
|
21
|
+
|
|
22
|
+
${dataTable}
|
|
23
|
+
|
|
24
|
+
Arrondir les coefficients au dixième.
|
|
25
|
+
`;
|
|
26
|
+
};
|
|
27
|
+
function generateLinearData(n) {
|
|
28
|
+
const slope = randint(-500, 500, [0]) / 100;
|
|
29
|
+
const intercept = randint(100, 5000) / 100;
|
|
30
|
+
const data = [];
|
|
31
|
+
const generatedXs = new Set();
|
|
32
|
+
let counter = 0;
|
|
33
|
+
while (data.length < n) {
|
|
34
|
+
counter++;
|
|
35
|
+
if (counter > 1000) {
|
|
36
|
+
throw new Error("affineAdjustement too many iterations");
|
|
37
|
+
}
|
|
38
|
+
let x = randint(1, 100);
|
|
39
|
+
let cnt = 0;
|
|
40
|
+
while (generatedXs.has(x)) {
|
|
41
|
+
cnt++;
|
|
42
|
+
if (cnt > 1000) {
|
|
43
|
+
throw new Error("affineAdjustement too many iterations");
|
|
44
|
+
}
|
|
45
|
+
x = randint(1, 100);
|
|
46
|
+
}
|
|
47
|
+
generatedXs.add(x);
|
|
48
|
+
const y = round(slope * x + intercept, 2);
|
|
49
|
+
data.push({ x, y });
|
|
50
|
+
}
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
const getAnswer = (identifiers) => {
|
|
54
|
+
const { xValues, yValues } = identifiers;
|
|
55
|
+
const { a, b } = leastSquares(xValues, yValues);
|
|
56
|
+
const aFixed = round(a, 1);
|
|
57
|
+
const bFixed = round(b, 1);
|
|
58
|
+
const answer = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(aFixed), new VariableNode("x")), new NumberNode(bFixed)).simplify({ forbidFactorize: true })).toTex();
|
|
59
|
+
return answer;
|
|
60
|
+
};
|
|
61
|
+
const getAffineAdjustmentQuestion = () => {
|
|
62
|
+
const data = generateLinearData(5);
|
|
63
|
+
data.sort((a, b) => a.x - b.x);
|
|
64
|
+
const xValues = data.map((point) => point.x);
|
|
65
|
+
const yValues = data.map((point) => point.y);
|
|
66
|
+
const identifiers = { xValues, yValues };
|
|
67
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
68
|
+
};
|
|
69
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
70
|
+
const question = {
|
|
71
|
+
answer: getAnswer(identifiers),
|
|
72
|
+
instruction: getInstruction(identifiers),
|
|
73
|
+
keys: ["equal", "y", "x", "a", "b"],
|
|
74
|
+
answerFormat: "tex",
|
|
75
|
+
identifiers,
|
|
76
|
+
style: {
|
|
77
|
+
tableOptions: {
|
|
78
|
+
firstCellIsDivided: false,
|
|
79
|
+
firstColumnIsHeader: true,
|
|
80
|
+
firstRowIsHeader: false,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
return question;
|
|
85
|
+
};
|
|
86
|
+
const getPropositions = (n, { answer, xValues, yValues }) => {
|
|
87
|
+
const propositions = [];
|
|
88
|
+
addValidProp(propositions, answer, "tex");
|
|
89
|
+
const { a, b } = leastSquares(xValues, yValues);
|
|
90
|
+
const aFixed = round(a, 1);
|
|
91
|
+
const bFixed = round(b, 1);
|
|
92
|
+
const wrongAnswer1 = new EqualNode(new VariableNode("y"), new SubstractNode(new MultiplyNode(new NumberNode(aFixed), new VariableNode("x")), new NumberNode(bFixed)).simplify({ forbidFactorize: true }));
|
|
93
|
+
const awrong = randfloat(-5, 5, 1, [0]);
|
|
94
|
+
const bwrong = randfloat(-20, 20, 1);
|
|
95
|
+
const wrongAnswer2 = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(round(awrong, 1)), new VariableNode("x")), new NumberNode(bFixed)).simplify({ forbidFactorize: true }));
|
|
96
|
+
const wrongAnswer3 = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(aFixed), new VariableNode("x")), new NumberNode(round(bwrong, 1))).simplify({ forbidFactorize: true }));
|
|
97
|
+
const wrongAnswer4 = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(round(awrong, 1)), new VariableNode("x")), new NumberNode(round(bwrong, 1))).simplify({ forbidFactorize: true }));
|
|
98
|
+
tryToAddWrongProp(propositions, wrongAnswer1.toTex());
|
|
99
|
+
tryToAddWrongProp(propositions, wrongAnswer2.toTex());
|
|
100
|
+
tryToAddWrongProp(propositions, wrongAnswer3.toTex());
|
|
101
|
+
tryToAddWrongProp(propositions, wrongAnswer4.toTex());
|
|
102
|
+
propWhile(propositions, n, () => {
|
|
103
|
+
const a = randint(-10, 10, [0]);
|
|
104
|
+
const b = randint(-10, 10);
|
|
105
|
+
const wrongAnswer = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(a), new VariableNode("x")), new NumberNode(b)).simplify({ forbidFactorize: true }));
|
|
106
|
+
tryToAddWrongProp(propositions, wrongAnswer.toTex());
|
|
107
|
+
});
|
|
108
|
+
return shuffleProps(propositions, n);
|
|
109
|
+
};
|
|
110
|
+
const isAnswerValid = (ans, { xValues, yValues }) => {
|
|
111
|
+
const { a, b } = leastSquares(xValues, yValues);
|
|
112
|
+
const aFixed = round(a, 1);
|
|
113
|
+
const bFixed = round(b, 1);
|
|
114
|
+
const valid = new EqualNode(new VariableNode("y"), new AddNode(new MultiplyNode(new NumberNode(aFixed), new VariableNode("x")), new NumberNode(bFixed)).simplify({ forbidFactorize: true }));
|
|
115
|
+
const latexs = valid.toAllValidTexs({ allowRawRightChildAsSolution: true });
|
|
116
|
+
return latexs.includes(ans);
|
|
117
|
+
};
|
|
118
|
+
export const affineAdjustmentExercise = {
|
|
119
|
+
id: "affineAdjustment",
|
|
120
|
+
label: "Déterminer l'équation de la droite d'ajustement à partir d'un tableau de données",
|
|
121
|
+
isSingleStep: true,
|
|
122
|
+
generator: (nb) => getDistinctQuestions(getAffineAdjustmentQuestion, nb),
|
|
123
|
+
qcmTimer: 60,
|
|
124
|
+
freeTimer: 60,
|
|
125
|
+
getPropositions,
|
|
126
|
+
isAnswerValid,
|
|
127
|
+
subject: "Mathématiques",
|
|
128
|
+
getQuestionFromIdentifiers,
|
|
129
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Exercise } from "../../../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
xValues: number[];
|
|
4
|
+
yValues: number[];
|
|
5
|
+
};
|
|
6
|
+
export declare const affineAdjustmentCompleteExercise: Exercise<Identifiers>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=affineAdjustmentComplete.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"affineAdjustmentComplete.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/affines/adjustment/affineAdjustmentComplete.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAmBrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AA4JF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,CAalE,CAAC"}
|