math-exercises 3.0.178 → 3.0.179
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/derivativeEquationSolving1.d.ts +14 -0
- package/lib/exercises/math/derivation/derivative/derivativeEquationSolving1.d.ts.map +1 -0
- package/lib/exercises/math/derivation/derivative/derivativeEquationSolving1.js +283 -0
- package/lib/exercises/math/derivation/derivative/derivativeEquationSolving3.d.ts +15 -0
- package/lib/exercises/math/derivation/derivative/derivativeEquationSolving3.d.ts.map +1 -0
- package/lib/exercises/math/derivation/derivative/derivativeEquationSolving3.js +296 -0
- package/lib/exercises/math/derivation/derivative/exp/expDerivativeOne.js +3 -3
- package/lib/exercises/math/derivation/derivative/exp/expDerivativeProductFExp.d.ts +14 -0
- package/lib/exercises/math/derivation/derivative/exp/expDerivativeProductFExp.d.ts.map +1 -0
- package/lib/exercises/math/derivation/derivative/exp/expDerivativeProductFExp.js +346 -0
- package/lib/exercises/math/derivation/derivative/exp/expDerivativeQuotientFExp.d.ts +15 -0
- package/lib/exercises/math/derivation/derivative/exp/expDerivativeQuotientFExp.d.ts.map +1 -0
- package/lib/exercises/math/derivation/derivative/exp/expDerivativeQuotientFExp.js +435 -0
- package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.d.ts +13 -0
- package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.d.ts.map +1 -0
- package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.js +326 -0
- package/lib/exercises/math/derivation/derivativeNumber/signOfDerivativeNumberFromFunctionCurve.d.ts +14 -0
- package/lib/exercises/math/derivation/derivativeNumber/signOfDerivativeNumberFromFunctionCurve.d.ts.map +1 -0
- package/lib/exercises/math/derivation/derivativeNumber/signOfDerivativeNumberFromFunctionCurve.js +181 -0
- package/lib/exercises/math/derivation/derivativeNumber/valueTableImageAndDerivativeFromFunctionExpression.d.ts +10 -0
- package/lib/exercises/math/derivation/derivativeNumber/valueTableImageAndDerivativeFromFunctionExpression.d.ts.map +1 -0
- package/lib/exercises/math/derivation/derivativeNumber/valueTableImageAndDerivativeFromFunctionExpression.js +272 -0
- package/lib/exercises/math/derivation/problems/index.d.ts +5 -0
- package/lib/exercises/math/derivation/problems/index.d.ts.map +1 -0
- package/lib/exercises/math/derivation/problems/index.js +4 -0
- package/lib/exercises/math/derivation/problems/problemMaximizeBoxVolumeFindX.d.ts +8 -0
- package/lib/exercises/math/derivation/problems/problemMaximizeBoxVolumeFindX.d.ts.map +1 -0
- package/lib/exercises/math/derivation/problems/problemMaximizeBoxVolumeFindX.js +171 -0
- package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.d.ts +15 -0
- package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.d.ts.map +1 -0
- package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.js +328 -0
- package/lib/exercises/math/derivation/problems/problemMovementOnLineFindSpeedAtPoint.d.ts +13 -0
- package/lib/exercises/math/derivation/problems/problemMovementOnLineFindSpeedAtPoint.d.ts.map +1 -0
- package/lib/exercises/math/derivation/problems/problemMovementOnLineFindSpeedAtPoint.js +275 -0
- package/lib/exercises/math/derivation/problems/problemProjectileHeightFindAbscissa.d.ts +8 -0
- package/lib/exercises/math/derivation/problems/problemProjectileHeightFindAbscissa.d.ts.map +1 -0
- package/lib/exercises/math/derivation/problems/problemProjectileHeightFindAbscissa.js +137 -0
- package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineY.d.ts +10 -0
- package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineY.d.ts.map +1 -0
- package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineY.js +478 -0
- package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineYAndSlope.d.ts +10 -0
- package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineYAndSlope.d.ts.map +1 -0
- package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineYAndSlope.js +499 -0
- package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingPoint.d.ts +10 -0
- package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingPoint.d.ts.map +1 -0
- package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingPoint.js +240 -0
- package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingBuildingTangent.d.ts +12 -0
- package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingBuildingTangent.d.ts.map +1 -0
- package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingBuildingTangent.js +436 -0
- package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingPoint.d.ts +12 -0
- package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingPoint.d.ts.map +1 -0
- package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingPoint.js +219 -0
- package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingSecant.d.ts +13 -0
- package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingSecant.d.ts.map +1 -0
- package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingSecant.js +273 -0
- package/lib/exercises/math/derivation/tangent/placePointsOfDerivativeFromGraph.d.ts +18 -0
- package/lib/exercises/math/derivation/tangent/placePointsOfDerivativeFromGraph.d.ts.map +1 -0
- package/lib/exercises/math/derivation/tangent/placePointsOfDerivativeFromGraph.js +295 -0
- package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.d.ts +13 -0
- package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.d.ts.map +1 -0
- package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.js +388 -0
- package/lib/exercises/math/derivation/tangent/tangentEquationFromGraph.d.ts +9 -0
- package/lib/exercises/math/derivation/tangent/tangentEquationFromGraph.d.ts.map +1 -0
- package/lib/exercises/math/derivation/tangent/tangentEquationFromGraph.js +308 -0
- package/lib/exercises/math/derivation/variations/findAbscissaOfExtremaFromFunctionExpression.d.ts +14 -0
- package/lib/exercises/math/derivation/variations/findAbscissaOfExtremaFromFunctionExpression.d.ts.map +1 -0
- package/lib/exercises/math/derivation/variations/findAbscissaOfExtremaFromFunctionExpression.js +439 -0
- package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.d.ts +14 -0
- package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.d.ts.map +1 -0
- package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.js +547 -0
- package/lib/exercises/math/derivation/variations/plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.d.ts +15 -0
- package/lib/exercises/math/derivation/variations/plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.d.ts.map +1 -0
- package/lib/exercises/math/derivation/variations/plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.js +537 -0
- package/lib/exercises/math/derivation/variations/plausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomial.d.ts +15 -0
- package/lib/exercises/math/derivation/variations/plausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomial.d.ts.map +1 -0
- package/lib/exercises/math/derivation/variations/plausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomial.js +639 -0
- package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.d.ts +14 -0
- package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.d.ts.map +1 -0
- package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.js +530 -0
- package/lib/exercises/math/derivation/variations/signVarTableProductFExp.d.ts +10 -0
- package/lib/exercises/math/derivation/variations/signVarTableProductFExp.d.ts.map +1 -0
- package/lib/exercises/math/derivation/variations/signVarTableProductFExp.js +451 -0
- package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.d.ts +11 -0
- package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.d.ts.map +1 -0
- package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.js +514 -0
- package/lib/exercises/math/functions/composition/index.d.ts +0 -1
- package/lib/exercises/math/functions/composition/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/composition/index.js +1 -1
- package/lib/exercises/math/functions/exponential/algebraic/index.d.ts +0 -1
- package/lib/exercises/math/functions/exponential/algebraic/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/exponential/algebraic/index.js +1 -1
- package/lib/exercises/math/functions/trinoms/sign/signOfProductOfAffineAndTrinom.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/sign/signOfProductOfAffineAndTrinom.js +4 -11
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOrthoInSquare.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOrthoInSquare.js +32 -17
- package/lib/exercises/math/probaStat/conditional/conditionalProbaFromTableWithContext.d.ts +13 -0
- package/lib/exercises/math/probaStat/conditional/conditionalProbaFromTableWithContext.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/conditional/conditionalProbaFromTableWithContext.js +195 -0
- package/lib/exercises/math/probaStat/conditional/conditionalProbaWriteFromFrench.d.ts +9 -0
- package/lib/exercises/math/probaStat/conditional/conditionalProbaWriteFromFrench.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/conditional/conditionalProbaWriteFromFrench.js +220 -0
- package/lib/exercises/math/probaStat/conditional/conditionalProbability.d.ts +15 -0
- package/lib/exercises/math/probaStat/conditional/conditionalProbability.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/conditional/conditionalProbability.js +332 -0
- package/lib/exercises/math/probaStat/conditional/fillTableConditionalProbabilitySituation.d.ts +8 -0
- package/lib/exercises/math/probaStat/conditional/fillTableConditionalProbabilitySituation.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/conditional/fillTableConditionalProbabilitySituation.js +222 -0
- package/lib/exercises/math/probaStat/conditional/index.d.ts +5 -0
- package/lib/exercises/math/probaStat/conditional/index.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/conditional/index.js +4 -0
- package/lib/exercises/math/probaStat/index.d.ts +1 -2
- package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/index.js +1 -2
- package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts +1 -0
- package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probaFromTableWithContext.js +26 -199
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationProbabilityLaw.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationProbabilityLaw.js +6 -2
- package/lib/exercises/math/probaStat/randomVariable/utils/randomVariableSituations.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/randomVariable/utils/randomVariableSituations.js +6 -5
- package/lib/exercises/math/probaStat/trees/buildTreeFromSituation.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/trees/buildTreeFromSituation.js +4 -27
- package/lib/exercises/math/probaStat/twoEventsSituations.d.ts +29 -0
- package/lib/exercises/math/probaStat/twoEventsSituations.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/twoEventsSituations.js +145 -0
- package/lib/exercises/math/sequences/explicitFormulaUsage.d.ts +4 -1
- package/lib/exercises/math/sequences/explicitFormulaUsage.d.ts.map +1 -1
- package/lib/exercises/math/sequences/explicitFormulaUsage.js +47 -7
- package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoTerms.js +1 -1
- package/lib/exercises/math/sequences/geometric/index.d.ts +0 -3
- package/lib/exercises/math/sequences/geometric/index.d.ts.map +1 -1
- package/lib/exercises/math/sequences/geometric/index.js +3 -3
- package/lib/exercises/math/sequences/geometric/situations/index.d.ts +0 -1
- package/lib/exercises/math/sequences/geometric/situations/index.d.ts.map +1 -1
- package/lib/exercises/math/sequences/geometric/situations/index.js +1 -1
- package/lib/exercises/math/sequences/recurrenceFormulaUsage.d.ts +5 -1
- package/lib/exercises/math/sequences/recurrenceFormulaUsage.d.ts.map +1 -1
- package/lib/exercises/math/sequences/recurrenceFormulaUsage.js +89 -9
- package/lib/exercises/math/trigonometry/circle/associatePoint.d.ts.map +1 -1
- package/lib/exercises/math/trigonometry/circle/associatePoint.js +55 -6
- package/lib/exercises/math/trigonometry/circle/selectQuadrantOnTrigoCircle.d.ts.map +1 -1
- package/lib/exercises/math/trigonometry/circle/selectQuadrantOnTrigoCircle.js +5 -6
- package/lib/exercises/math/trigonometry/functions/associateAngleSimplification.d.ts.map +1 -1
- package/lib/exercises/math/trigonometry/functions/associateAngleSimplification.js +1 -3
- package/lib/exercises/vea/polynomialVEA.d.ts +2 -0
- package/lib/exercises/vea/polynomialVEA.d.ts.map +1 -0
- package/lib/exercises/vea/polynomialVEA.js +17 -0
- package/lib/exercises/vea/valueTableVEA.d.ts +8 -0
- package/lib/exercises/vea/valueTableVEA.d.ts.map +1 -0
- package/lib/exercises/vea/valueTableVEA.js +12 -0
- package/lib/index.d.ts +27 -47
- package/lib/index.d.ts.map +1 -1
- package/lib/latexTester.d.ts.map +1 -1
- package/lib/latexTester.js +1 -1
- package/lib/math/utils/polynomial/polynomialInterpolationUtils.d.ts +19 -0
- package/lib/math/utils/polynomial/polynomialInterpolationUtils.d.ts.map +1 -0
- package/lib/math/utils/polynomial/polynomialInterpolationUtils.js +53 -0
- package/lib/math/utils/polynomial/polynomialUtils.d.ts +37 -0
- package/lib/math/utils/polynomial/polynomialUtils.d.ts.map +1 -0
- package/lib/math/utils/polynomial/polynomialUtils.js +223 -0
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts.map +1 -1
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.js +6 -6
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +1 -1
- package/lib/tree/nodes/operators/substractNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/substractNode.js +2 -1
- package/lib/tree/utilities/nodeUtils.d.ts +6 -0
- package/lib/tree/utilities/nodeUtils.d.ts.map +1 -0
- package/lib/tree/utilities/nodeUtils.js +24 -0
- package/lib/utils/strings/prependArticle.d.ts +2 -0
- package/lib/utils/strings/prependArticle.d.ts.map +1 -0
- package/lib/utils/strings/prependArticle.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
|
|
4
|
+
import { blueMain, greenMain, orange, red } from "../../../../geogebra/colors.js";
|
|
5
|
+
import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
|
|
6
|
+
import { Rational } from "../../../../math/numbers/rationals/rational.js";
|
|
7
|
+
import { randfloat } from "../../../../math/utils/random/randfloat.js";
|
|
8
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
9
|
+
import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
10
|
+
import { add } from "../../../../tree/nodes/operators/addNode.js";
|
|
11
|
+
import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
12
|
+
import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
13
|
+
import { power } from "../../../../tree/nodes/operators/powerNode.js";
|
|
14
|
+
import { substract } from "../../../../tree/nodes/operators/substractNode.js";
|
|
15
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
16
|
+
import { shuffle } from "../../../../utils/alea/shuffle.js";
|
|
17
|
+
const [xMin, xMax] = [-6, 6];
|
|
18
|
+
const getInstruction = (identifiers) => {
|
|
19
|
+
const { k } = identifiers;
|
|
20
|
+
return `Ci-dessous est tracée la courbe $\\mathcal C_f$ de la fonction $f$.
|
|
21
|
+
|
|
22
|
+
En manipulant le curseur ou le point sur l'axe des abscisses,
|
|
23
|
+
on peut faire apparaître la tangente à cette courbe au point d'abscisse de son choix.
|
|
24
|
+
|
|
25
|
+
Résoudre l'équation $f'(x) = ${k.frenchify()}$.
|
|
26
|
+
|
|
27
|
+
*On précise qu'ici, il y a une seule solution à cette équation.*`;
|
|
28
|
+
};
|
|
29
|
+
const getAnswerNode = (identifiers) => {
|
|
30
|
+
const { x } = identifiers;
|
|
31
|
+
return x.toTree();
|
|
32
|
+
};
|
|
33
|
+
const getAnswer = (identifiers) => {
|
|
34
|
+
return getAnswerNode(identifiers).toTex();
|
|
35
|
+
};
|
|
36
|
+
const getHint = () => {
|
|
37
|
+
return `Le nombre dérivé de $f$ en $x$, aussi noté $f'(x)$, est le coefficient directeur la tangente à la courbe représentative de $f$ au point d'abscisse $x$.
|
|
38
|
+
|
|
39
|
+
Résoudre l'équation $f'(x) = k$,
|
|
40
|
+
c'est trouver toutes les abscisses $x$
|
|
41
|
+
pour lesquelles le coefficient directeur la tangente à la courbe représentative de $f$ vaut $k$.`;
|
|
42
|
+
};
|
|
43
|
+
const getCorrection = (identifiers) => {
|
|
44
|
+
const { x, k } = identifiers;
|
|
45
|
+
return `Le nombre dérivé de $f$ en $x$, aussi noté $f'(x)$, est le coefficient directeur la tangente à la courbe représentative de $f$ au point d'abscisse $x$.
|
|
46
|
+
|
|
47
|
+
En manipulant le curseur, on observe que $f'(${x}) = ${k.frenchify()}$.
|
|
48
|
+
|
|
49
|
+
La solution de l'équation est donc $x = ${x}$.
|
|
50
|
+
`;
|
|
51
|
+
};
|
|
52
|
+
const getCorrectionGGBOptions = (identifiers) => {
|
|
53
|
+
const { x, nodeIds } = identifiers;
|
|
54
|
+
const [nodeC, nodeB, nodeA] = nodeIds.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
|
|
55
|
+
const nodeX = "x".toTree();
|
|
56
|
+
const nodeF = add(nodeC, add(multiply(nodeB, nodeX), multiply(nodeA, power(nodeX, 2))));
|
|
57
|
+
const commands = [
|
|
58
|
+
`f(x) = ${nodeF.toMathString()}`,
|
|
59
|
+
`SetColor(f, "${blueMain}")`,
|
|
60
|
+
`SetCaption(f, "$\\mathcal C_f$")`,
|
|
61
|
+
`ShowLabel(f, true)`,
|
|
62
|
+
//tangent
|
|
63
|
+
`t(x) = f(${x}) + (x-${x}) f'(${x})`,
|
|
64
|
+
`SetColor(t, "${orange}")`,
|
|
65
|
+
//curve point
|
|
66
|
+
`B = (${x},f(${x}))`,
|
|
67
|
+
"SetPointStyle(B, 1)",
|
|
68
|
+
//slope label
|
|
69
|
+
`Lbl = Text("pente = " + f'(${x}), B, true, true, 0, -1)`, //pas réussi à changer le point en virgule
|
|
70
|
+
//solution
|
|
71
|
+
//arrow
|
|
72
|
+
`v = Vector(B, Point({${x},0}))`,
|
|
73
|
+
`SetColor(v, "${greenMain}")`,
|
|
74
|
+
//point
|
|
75
|
+
`C = (${x},0)`,
|
|
76
|
+
"SetPointStyle(C, 1)",
|
|
77
|
+
`SetColor(C, "${greenMain}")`,
|
|
78
|
+
`SetCaption(C, "$${x.frenchify()}$")`,
|
|
79
|
+
"ShowLabel(C, true)",
|
|
80
|
+
];
|
|
81
|
+
const [yMin, yMax] = [xMin, xMax].map((x) => nodeF.evaluate({ x }));
|
|
82
|
+
const ggb = new GeogebraConstructor({
|
|
83
|
+
commands,
|
|
84
|
+
});
|
|
85
|
+
return ggb.getOptions({
|
|
86
|
+
coords: ggb.getAdaptedCoords({
|
|
87
|
+
xMin,
|
|
88
|
+
xMax,
|
|
89
|
+
yMin: Math.min(yMin, -2),
|
|
90
|
+
yMax,
|
|
91
|
+
}),
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
const getGGBOptions = (identifiers) => {
|
|
95
|
+
const { x, nodeIds } = identifiers;
|
|
96
|
+
const [nodeC, nodeB, nodeA] = nodeIds.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
|
|
97
|
+
const nodeX = "x".toTree();
|
|
98
|
+
const nodeF = add(nodeC, add(multiply(nodeB, nodeX), multiply(nodeA, power(nodeX, 2))));
|
|
99
|
+
const [minSlider, maxSlider] = [-6, 6];
|
|
100
|
+
const stepSlider = 0.5;
|
|
101
|
+
const valueSliderInitial = randint(minSlider, maxSlider, [x]);
|
|
102
|
+
const commands = [
|
|
103
|
+
`f(x) = ${nodeF.toMathString()}`,
|
|
104
|
+
`SetColor(f, "${blueMain}")`,
|
|
105
|
+
`SetCaption(f, "$\\mathcal C_f$")`,
|
|
106
|
+
`ShowLabel(f, true)`,
|
|
107
|
+
`SetColor(f, "${blueMain}")`,
|
|
108
|
+
//slider
|
|
109
|
+
`a = Slider(${minSlider}, ${maxSlider}, ${stepSlider})`,
|
|
110
|
+
`SetValue(a, ${valueSliderInitial})`,
|
|
111
|
+
//moving point
|
|
112
|
+
`A = (a,0)`,
|
|
113
|
+
"SetPointStyle(A, 0)",
|
|
114
|
+
"SetPointSize(A,5)",
|
|
115
|
+
//tangent
|
|
116
|
+
`t(x) = f(a) + (x-a) f'(a)`,
|
|
117
|
+
`SetColor(t, "${red}")`,
|
|
118
|
+
//curve point
|
|
119
|
+
`B = (a,f(a))`,
|
|
120
|
+
"SetPointStyle(B, 1)",
|
|
121
|
+
//slope label
|
|
122
|
+
`Lbl = Text("pente = " + f'(a), B, true, true, 0, -1)`, //pas réussi à changer le point en virgule
|
|
123
|
+
];
|
|
124
|
+
const [yMin, yMax] = [xMin, xMax].map((x) => nodeF.evaluate({ x }));
|
|
125
|
+
const ggb = new GeogebraConstructor({
|
|
126
|
+
commands,
|
|
127
|
+
});
|
|
128
|
+
return ggb.getOptions({
|
|
129
|
+
coords: ggb.getAdaptedCoords({
|
|
130
|
+
xMin,
|
|
131
|
+
xMax,
|
|
132
|
+
yMin: Math.min(yMin, -2),
|
|
133
|
+
yMax,
|
|
134
|
+
}),
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
const getPropositions = (n, { answer, ..._identifiers }) => {
|
|
138
|
+
const propositions = [];
|
|
139
|
+
addValidProp(propositions, answer);
|
|
140
|
+
propWhile(propositions, n, () => {
|
|
141
|
+
const xWrong = (() => {
|
|
142
|
+
const num = randint(-10, 11, [0]);
|
|
143
|
+
const den = 2;
|
|
144
|
+
return new Rational(num, den).simplify();
|
|
145
|
+
})().value;
|
|
146
|
+
tryToAddWrongProp(propositions, xWrong.frenchify());
|
|
147
|
+
});
|
|
148
|
+
return shuffle(propositions);
|
|
149
|
+
};
|
|
150
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
151
|
+
return numberVEA(ans, answer);
|
|
152
|
+
};
|
|
153
|
+
const createRandomIdentifiers = () => {
|
|
154
|
+
//x=m*0.5
|
|
155
|
+
const x = (() => {
|
|
156
|
+
const num = randint(-10, 11, [0]);
|
|
157
|
+
const den = 2;
|
|
158
|
+
return new Rational(num, den).simplify();
|
|
159
|
+
})();
|
|
160
|
+
//k=p*0.1
|
|
161
|
+
const k = (() => {
|
|
162
|
+
const num = (coinFlip() ? +1 : -1) * randint(5, 41);
|
|
163
|
+
const den = 10;
|
|
164
|
+
return new Rational(num, den).simplify();
|
|
165
|
+
})();
|
|
166
|
+
//f(x) = ax²+bx+c
|
|
167
|
+
//f'(x) = 2ax + b = k
|
|
168
|
+
//a = (k-b)/2x
|
|
169
|
+
const nodeB = ((coinFlip() ? +1 : -1) * randfloat(0, 1, 2, [0])).toTree();
|
|
170
|
+
const nodeA = frac(substract(k.toTree(), nodeB), multiply(2, x.toTree()));
|
|
171
|
+
const nodeC = (0).toTree();
|
|
172
|
+
const identifiers = {
|
|
173
|
+
x: x.value,
|
|
174
|
+
k: k.value,
|
|
175
|
+
nodeIds: [nodeC, nodeB, nodeA].map((node) => node.simplify().toIdentifiers()),
|
|
176
|
+
};
|
|
177
|
+
return identifiers;
|
|
178
|
+
};
|
|
179
|
+
const getDerivativeEquationSolvingByManipulatingPointQuestion = (opts) => {
|
|
180
|
+
let identifiers;
|
|
181
|
+
let counter = -1;
|
|
182
|
+
let isValid = false;
|
|
183
|
+
while (!isValid && counter < 100) {
|
|
184
|
+
counter++;
|
|
185
|
+
const identifiersCandidate = createRandomIdentifiers();
|
|
186
|
+
function isValidFrameWise(identifiers) {
|
|
187
|
+
const { nodeIds } = identifiers;
|
|
188
|
+
const [nodeC, nodeB, nodeA] = nodeIds.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
|
|
189
|
+
const nodeX = "x".toTree();
|
|
190
|
+
const nodeF = add(nodeC, add(multiply(nodeB, nodeX), multiply(nodeA, power(nodeX, 2))));
|
|
191
|
+
const arrX = [...Array(xMax - xMin + 1).keys()].map((i) => i + xMin);
|
|
192
|
+
const arrY = arrX.map((x) => nodeF.evaluate({ x }));
|
|
193
|
+
const minY = Math.min(...arrY);
|
|
194
|
+
const maxY = Math.max(...arrY);
|
|
195
|
+
const spanY = maxY - minY;
|
|
196
|
+
return spanY < 15;
|
|
197
|
+
}
|
|
198
|
+
isValid = isValidFrameWise(identifiersCandidate);
|
|
199
|
+
if (isValid) {
|
|
200
|
+
identifiers = identifiersCandidate;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (!isValid) {
|
|
204
|
+
const identifiersDefault = {
|
|
205
|
+
x: -2.5,
|
|
206
|
+
k: 1.8,
|
|
207
|
+
nodeIds: [(0).toTree(), (0.37).toTree(), frac(143, 500)].map((node) => node.toIdentifiers()),
|
|
208
|
+
};
|
|
209
|
+
identifiers = identifiersDefault;
|
|
210
|
+
}
|
|
211
|
+
return getQuestionFromIdentifiers(identifiers, opts);
|
|
212
|
+
};
|
|
213
|
+
const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
214
|
+
return {
|
|
215
|
+
instruction: getInstruction(identifiers, opts),
|
|
216
|
+
answer: getAnswer(identifiers),
|
|
217
|
+
ggbOptions: getGGBOptions(identifiers),
|
|
218
|
+
answerFormat: "tex",
|
|
219
|
+
keys: [],
|
|
220
|
+
hint: getHint(identifiers, opts),
|
|
221
|
+
correction: getCorrection(identifiers, opts),
|
|
222
|
+
correctionGgbOptions: getCorrectionGGBOptions(identifiers, opts),
|
|
223
|
+
identifiers,
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
export const derivativeEquationSolvingByManipulatingPoint = {
|
|
227
|
+
id: "derivativeEquationSolvingByManipulatingPoint",
|
|
228
|
+
connector: "=",
|
|
229
|
+
label: `Résoudre une équation du type "$f'(x) = k$" par la manipulation de l'abscisse du point`,
|
|
230
|
+
isSingleStep: false,
|
|
231
|
+
generator: (nb) => getDistinctQuestions(getDerivativeEquationSolvingByManipulatingPointQuestion, nb),
|
|
232
|
+
qcmTimer: 60,
|
|
233
|
+
freeTimer: 60,
|
|
234
|
+
getPropositions,
|
|
235
|
+
isAnswerValid,
|
|
236
|
+
subject: "Mathématiques",
|
|
237
|
+
getQuestionFromIdentifiers,
|
|
238
|
+
hasHintAndCorrection: true,
|
|
239
|
+
hasGeogebra: true,
|
|
240
|
+
};
|
package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingBuildingTangent.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
nodeIdsF: NodeIdentifiers;
|
|
5
|
+
nodeIdsXAsked: NodeIdentifiers;
|
|
6
|
+
};
|
|
7
|
+
type Options = {
|
|
8
|
+
notationType: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const derivativeReadingByManipulatingBuildingTangent: Exercise<Identifiers, Options>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=derivativeReadingByManipulatingBuildingTangent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derivativeReadingByManipulatingBuildingTangent.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/tangent/derivativeReadingByManipulatingBuildingTangent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAcrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAsC7C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,aAAa,EAAE,eAAe,CAAC;CAChC,CAAC;AAmeF,KAAK,OAAO,GAAG;IACb,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AACF,eAAO,MAAM,8CAA8C,EAAE,QAAQ,CACnE,WAAW,EACX,OAAO,CAqBR,CAAC"}
|
package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingBuildingTangent.js
ADDED
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { blueMain, greenMain } from "../../../../geogebra/colors.js";
|
|
4
|
+
import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
|
|
5
|
+
import { Point } from "../../../../math/geometry/point.js";
|
|
6
|
+
import { nodeBySubstitutingVar } from "../../../../math/utils/functions/functionComposition.js";
|
|
7
|
+
import { createIntegratedPolynomialNode, createNodeFPolynomialFromRoots, } from "../../../../math/utils/polynomial/polynomialUtils.js";
|
|
8
|
+
import { randfloat } from "../../../../math/utils/random/randfloat.js";
|
|
9
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
10
|
+
import { round } from "../../../../math/utils/round.js";
|
|
11
|
+
import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
12
|
+
import { add } from "../../../../tree/nodes/operators/addNode.js";
|
|
13
|
+
import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
14
|
+
import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
|
|
15
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
16
|
+
import { randomMany } from "../../../../utils/alea/random.js";
|
|
17
|
+
import { shuffle } from "../../../../utils/alea/shuffle.js";
|
|
18
|
+
import { zip } from "../../../../utils/arrays/arrayZip.js";
|
|
19
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
20
|
+
function getCoordsFrame(nodeF, xMin, xMax) {
|
|
21
|
+
const stepX = 0.05;
|
|
22
|
+
const arrX = [...Array(Math.floor((xMax - xMin) / stepX)).keys()].map((i) => xMin + i * stepX);
|
|
23
|
+
const yForXMin = nodeF.evaluate({ x: xMin });
|
|
24
|
+
const { yMin, yMax } = arrX.slice(1).reduce((acc, x) => {
|
|
25
|
+
const { yMin, yMax } = acc;
|
|
26
|
+
const y = nodeF.evaluate({ x });
|
|
27
|
+
if (y < yMin) {
|
|
28
|
+
acc.yMin = y;
|
|
29
|
+
}
|
|
30
|
+
else if (y > yMax) {
|
|
31
|
+
acc.yMax = y;
|
|
32
|
+
}
|
|
33
|
+
return acc;
|
|
34
|
+
}, { yMin: yForXMin, yMax: yForXMin });
|
|
35
|
+
return {
|
|
36
|
+
xMin,
|
|
37
|
+
xMax,
|
|
38
|
+
yMin,
|
|
39
|
+
yMax,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const getInstruction = (identifiers, opts) => {
|
|
43
|
+
const { nodeIdsXAsked } = identifiers;
|
|
44
|
+
const nodeXAsked = NodeConstructor.fromIdentifiers(nodeIdsXAsked);
|
|
45
|
+
const notation = opts?.notationType === "Nombre dérivé de $f$ en $a$"
|
|
46
|
+
? `le nombre dérivé de $f$ en $${nodeXAsked.toTex()}$`
|
|
47
|
+
: `$f'(${nodeXAsked.toTex()})$`;
|
|
48
|
+
return `Ci-dessous est tracée la courbe $\\mathcal C_f$ de la fonction $f$.
|
|
49
|
+
|
|
50
|
+
En manipulant les points $A$ et $B$, construire la tangente à $C_f$ au point d'abscisse $${nodeXAsked.toTex()}$ et
|
|
51
|
+
en déduire ${notation} (valeur approximative).`;
|
|
52
|
+
};
|
|
53
|
+
const getAnswerNode = (identifiers) => {
|
|
54
|
+
const { nodeIdsXAsked, nodeIdsF } = identifiers;
|
|
55
|
+
const [nodeXAsked, nodeF] = [nodeIdsXAsked, nodeIdsF].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
|
|
56
|
+
const nodeDerivative = nodeF.derivative();
|
|
57
|
+
const nodeValueDerivative = nodeBySubstitutingVar(nodeDerivative, nodeXAsked, "x".toTree()).simplify();
|
|
58
|
+
return round(nodeValueDerivative.evaluate(), 1).toTree();
|
|
59
|
+
};
|
|
60
|
+
const getAnswer = (identifiers) => {
|
|
61
|
+
return getAnswerNode(identifiers).toTex();
|
|
62
|
+
};
|
|
63
|
+
const getHint = () => {
|
|
64
|
+
return `Le nombre dérivé de $f$ en $a$, aussi noté $f'(a)$, est le coefficient directeur la tangente à la courbe représentative de $f$ au point d'abscisse $a$.`;
|
|
65
|
+
};
|
|
66
|
+
const getCorrection = (identifiers) => {
|
|
67
|
+
const { nodeIdsXAsked } = identifiers;
|
|
68
|
+
const [nodeXAsked] = [nodeIdsXAsked].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
|
|
69
|
+
const texXAsked = nodeXAsked.toTex();
|
|
70
|
+
const texAnswer = getAnswer(identifiers);
|
|
71
|
+
return `Le nombre dérivé de $f$ en $${texXAsked}$, aussi noté $f'(${texXAsked})$,
|
|
72
|
+
est le coefficient directeur la tangente à la courbe représentative de $f$ au point d'abscisse $${texXAsked}$.
|
|
73
|
+
Ici, on doit donc lire le coefficient directeur de la tangente passant par le point d'abscisse $${texXAsked}$.
|
|
74
|
+
|
|
75
|
+
On lit comme coefficient directeur $${texAnswer}$.
|
|
76
|
+
On a donc :
|
|
77
|
+
|
|
78
|
+
$$
|
|
79
|
+
f'(${texXAsked}) \\approx ${texAnswer}
|
|
80
|
+
$$`;
|
|
81
|
+
};
|
|
82
|
+
const getCorrectionGGBOptions = (identifiers) => {
|
|
83
|
+
const { nodeIdsXAsked, nodeIdsF } = identifiers;
|
|
84
|
+
const [nodeXAsked, nodeF] = [nodeIdsXAsked, nodeIdsF].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
|
|
85
|
+
const xAsked = nodeXAsked.evaluate();
|
|
86
|
+
const nodeDerivative = nodeF.derivative().simplify();
|
|
87
|
+
const valueFunction = nodeF.evaluate({ x: xAsked });
|
|
88
|
+
const valueDerivative = nodeDerivative.evaluate({ x: xAsked });
|
|
89
|
+
const commands = [
|
|
90
|
+
//function
|
|
91
|
+
`f(x) = ${nodeF.toMathString()}`,
|
|
92
|
+
`SetColor(f, "${blueMain}")`,
|
|
93
|
+
`SetCaption(f, "$\\mathcal C_f$")`,
|
|
94
|
+
`ShowLabel(f, true)`,
|
|
95
|
+
//tangent
|
|
96
|
+
`t(x) = ${valueFunction} + (x-${xAsked}) (${valueDerivative})`,
|
|
97
|
+
`SetColor(t, "${greenMain}")`,
|
|
98
|
+
];
|
|
99
|
+
const xMin = xAsked - 2;
|
|
100
|
+
const xMax = xAsked + 2;
|
|
101
|
+
const { yMin, yMax } = getCoordsFrame(nodeF, xMin, xMax);
|
|
102
|
+
const ggb = new GeogebraConstructor({
|
|
103
|
+
commands,
|
|
104
|
+
});
|
|
105
|
+
return ggb.getOptions({
|
|
106
|
+
coords: ggb.getAdaptedCoords({
|
|
107
|
+
xMin,
|
|
108
|
+
xMax,
|
|
109
|
+
yMin: Math.min(yMin, -2),
|
|
110
|
+
yMax,
|
|
111
|
+
}),
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
const getGGBOptions = (identifiers) => {
|
|
115
|
+
const { nodeIdsXAsked, nodeIdsF } = identifiers;
|
|
116
|
+
const [nodeXAsked, nodeF] = [nodeIdsXAsked, nodeIdsF].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
|
|
117
|
+
const xAsked = nodeXAsked.evaluate();
|
|
118
|
+
const xMin = xAsked - 2;
|
|
119
|
+
const xMax = xAsked + 2;
|
|
120
|
+
const { yMin, yMax } = getCoordsFrame(nodeF, xMin, xMax);
|
|
121
|
+
const pointA = new Point("A", xMin + 0.25 * (xMax - xMin), yMin + 0.75 * (yMax - yMin));
|
|
122
|
+
const pointB = new Point("B", xMin + 0.75 * (xMax - xMin), yMin + 0.25 * (yMax - yMin));
|
|
123
|
+
const commands = [
|
|
124
|
+
`f(x) = ${nodeF.toMathString()}`,
|
|
125
|
+
`SetColor(f, "${blueMain}")`,
|
|
126
|
+
`SetCaption(f, "$\\mathcal C_f$")`,
|
|
127
|
+
`ShowLabel(f, true)`,
|
|
128
|
+
//line with slope
|
|
129
|
+
...pointA.toGGBCommand({
|
|
130
|
+
isFixed: false,
|
|
131
|
+
isSelectionnable: true,
|
|
132
|
+
showLabel: true,
|
|
133
|
+
style: 0,
|
|
134
|
+
size: 5,
|
|
135
|
+
}),
|
|
136
|
+
...pointB.toGGBCommand({
|
|
137
|
+
isFixed: false,
|
|
138
|
+
isSelectionnable: true,
|
|
139
|
+
showLabel: true,
|
|
140
|
+
style: 0,
|
|
141
|
+
size: 5,
|
|
142
|
+
}),
|
|
143
|
+
`lineAB = Line(A,B)`,
|
|
144
|
+
`s = Slope(lineAB)`,
|
|
145
|
+
];
|
|
146
|
+
const ggb = new GeogebraConstructor({
|
|
147
|
+
commands,
|
|
148
|
+
});
|
|
149
|
+
return ggb.getOptions({
|
|
150
|
+
coords: ggb.getAdaptedCoords({
|
|
151
|
+
xMin,
|
|
152
|
+
xMax,
|
|
153
|
+
yMin: Math.min(yMin, -2),
|
|
154
|
+
yMax,
|
|
155
|
+
}),
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
const getPropositions = (n, { answer, ...identifiers }) => {
|
|
159
|
+
const propositions = [];
|
|
160
|
+
addValidProp(propositions, answer);
|
|
161
|
+
propWhile(propositions, n, () => {
|
|
162
|
+
const maxSlopeAbs = 1.5;
|
|
163
|
+
const nodeK = randfloat(-maxSlopeAbs, maxSlopeAbs, 2, [0]).toTree();
|
|
164
|
+
const texWrong = nodeK.toTex();
|
|
165
|
+
if (!isAnswerValid(texWrong, { answer, ...identifiers })) {
|
|
166
|
+
tryToAddWrongProp(propositions, texWrong);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
return shuffle(propositions);
|
|
170
|
+
};
|
|
171
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
172
|
+
try {
|
|
173
|
+
const [nodeAns, nodeAnswer] = [ans, answer].map((tex) => parseAlgebraic(tex));
|
|
174
|
+
const [valueAns, valueAnswer] = [nodeAns, nodeAnswer].map((node) => node.evaluate());
|
|
175
|
+
//+/-5°
|
|
176
|
+
const [angleAns, angleAnswer] = [valueAns, valueAnswer].map((value) => (Math.atan2(value, 1) * 180.0) / Math.PI);
|
|
177
|
+
const [angleMin, angleMax] = [-5, +5].map((offset) => angleAnswer + offset);
|
|
178
|
+
const isValid = angleMin < angleAns && angleAns < angleMax;
|
|
179
|
+
return isValid;
|
|
180
|
+
}
|
|
181
|
+
catch (err) {
|
|
182
|
+
return handleVEAError(err);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
const createRandomIdentifiers = () => {
|
|
186
|
+
const nbX = randint(2, 4);
|
|
187
|
+
const arrX = (() => {
|
|
188
|
+
function createRandomArrX() {
|
|
189
|
+
const poolX = [...Array(11).keys()].map((i) => i - 5);
|
|
190
|
+
return randomMany(poolX, nbX).toSorted((v1, v2) => v1 - v2);
|
|
191
|
+
}
|
|
192
|
+
let arrX = [];
|
|
193
|
+
let isValid = false;
|
|
194
|
+
let counter = -1;
|
|
195
|
+
while (!isValid && counter < 100) {
|
|
196
|
+
counter++;
|
|
197
|
+
const arrXCandidate = createRandomArrX();
|
|
198
|
+
const isSeparatedNicely = () => zip(arrXCandidate.slice(0, -1), arrXCandidate.slice(1))
|
|
199
|
+
.map(([x1, x2]) => x2 - x1)
|
|
200
|
+
.find((elt) => elt === 1) === undefined;
|
|
201
|
+
isValid = isSeparatedNicely();
|
|
202
|
+
if (isValid) {
|
|
203
|
+
arrX = arrXCandidate;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (!isValid) {
|
|
207
|
+
switch (nbX) {
|
|
208
|
+
case 0:
|
|
209
|
+
return [-3];
|
|
210
|
+
case 1:
|
|
211
|
+
return [-2, 3];
|
|
212
|
+
case 2:
|
|
213
|
+
return [-4, 2, 5];
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return arrX;
|
|
217
|
+
})();
|
|
218
|
+
const arrNodeX = arrX.map((x) => x.toTree());
|
|
219
|
+
//f'(x) = a(x-x1)...(x-xn) + k
|
|
220
|
+
//=> f'(x1) = ... = f'(xn) = k
|
|
221
|
+
const nodeA = frac(coinFlip() ? -1 : +1, 5 * nbX);
|
|
222
|
+
const maxSlopeAbs = 1.5;
|
|
223
|
+
const nodeK = randfloat(-maxSlopeAbs, maxSlopeAbs, 2, [0]).toTree();
|
|
224
|
+
const nodeDerivative = add(createNodeFPolynomialFromRoots(nodeA, arrNodeX), nodeK);
|
|
225
|
+
const nodeC = randint(-3, 3).toTree();
|
|
226
|
+
const nodeF = createIntegratedPolynomialNode(nodeDerivative, nodeC);
|
|
227
|
+
const indexAsked = randint(0, arrNodeX.length);
|
|
228
|
+
const nodeXAsked = arrNodeX[indexAsked];
|
|
229
|
+
const identifiers = {
|
|
230
|
+
nodeIdsSlope: nodeK.toIdentifiers(),
|
|
231
|
+
nodeIdsF: nodeF.toIdentifiers(),
|
|
232
|
+
nodeIdsXAsked: nodeXAsked.toIdentifiers(),
|
|
233
|
+
};
|
|
234
|
+
return identifiers;
|
|
235
|
+
};
|
|
236
|
+
const getDerivativeReadingByManipulatingBuildingTangentQuestion = (opts) => {
|
|
237
|
+
let identifiers;
|
|
238
|
+
let isValid = false;
|
|
239
|
+
let counter = -1;
|
|
240
|
+
while (!isValid && counter < 100) {
|
|
241
|
+
counter++;
|
|
242
|
+
const identifiersCandidate = createRandomIdentifiers();
|
|
243
|
+
const isReadable = (identifiers) => {
|
|
244
|
+
const { nodeIdsXAsked, nodeIdsF } = identifiers;
|
|
245
|
+
const arrNodeX = [nodeIdsXAsked].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
|
|
246
|
+
const nodeF = NodeConstructor.fromIdentifiers(nodeIdsF);
|
|
247
|
+
const arrX = arrNodeX.map((node) => node.evaluate());
|
|
248
|
+
const xMin = Math.min(...arrX) - 2;
|
|
249
|
+
const xMax = Math.max(...arrX) + 2;
|
|
250
|
+
const { yMin, yMax } = getCoordsFrame(nodeF, xMin, xMax);
|
|
251
|
+
return frac(yMax - yMin, xMax - xMin).evaluate() <= 0.888;
|
|
252
|
+
};
|
|
253
|
+
const isDerivativeOk = (identifiers) => {
|
|
254
|
+
const { nodeIdsXAsked, nodeIdsSlope, nodeIdsF } = identifiers;
|
|
255
|
+
const arrNodeX = [nodeIdsXAsked].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
|
|
256
|
+
const [nodeSlope, nodeF] = [nodeIdsSlope, nodeIdsF].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
|
|
257
|
+
const nodeDerivative = nodeF.derivative().simplify();
|
|
258
|
+
return arrNodeX.every((nodeX) => nodeDerivative.evaluate({ x: nodeX.evaluate() }) ===
|
|
259
|
+
nodeSlope.evaluate());
|
|
260
|
+
};
|
|
261
|
+
const isNaNing = (identifiers) => {
|
|
262
|
+
return getAnswer(identifiers) === "NaN";
|
|
263
|
+
};
|
|
264
|
+
isValid =
|
|
265
|
+
isReadable(identifiersCandidate) &&
|
|
266
|
+
isDerivativeOk(identifiersCandidate) &&
|
|
267
|
+
!isNaNing(identifiersCandidate);
|
|
268
|
+
if (isValid) {
|
|
269
|
+
identifiers = identifiersCandidate;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (!isValid) {
|
|
273
|
+
//copié-collé depuis le dashboard::viewer
|
|
274
|
+
const identifiersDefault = {
|
|
275
|
+
nodeIdsSlope: {
|
|
276
|
+
id: 7,
|
|
277
|
+
value: -0.2,
|
|
278
|
+
},
|
|
279
|
+
nodeIdsF: {
|
|
280
|
+
id: 3,
|
|
281
|
+
leftChild: {
|
|
282
|
+
id: 0,
|
|
283
|
+
leftChild: {
|
|
284
|
+
id: 2,
|
|
285
|
+
leftChild: {
|
|
286
|
+
id: 7,
|
|
287
|
+
value: 2025,
|
|
288
|
+
},
|
|
289
|
+
rightChild: {
|
|
290
|
+
id: 5,
|
|
291
|
+
leftChild: {
|
|
292
|
+
id: 10,
|
|
293
|
+
name: "x",
|
|
294
|
+
},
|
|
295
|
+
rightChild: {
|
|
296
|
+
id: 7,
|
|
297
|
+
value: 4,
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
rightChild: {
|
|
302
|
+
id: 2,
|
|
303
|
+
leftChild: {
|
|
304
|
+
id: 7,
|
|
305
|
+
value: 60,
|
|
306
|
+
},
|
|
307
|
+
rightChild: {
|
|
308
|
+
id: 0,
|
|
309
|
+
leftChild: {
|
|
310
|
+
id: 2,
|
|
311
|
+
leftChild: {
|
|
312
|
+
id: 7,
|
|
313
|
+
value: -225,
|
|
314
|
+
},
|
|
315
|
+
rightChild: {
|
|
316
|
+
id: 5,
|
|
317
|
+
leftChild: {
|
|
318
|
+
id: 10,
|
|
319
|
+
name: "x",
|
|
320
|
+
},
|
|
321
|
+
rightChild: {
|
|
322
|
+
id: 7,
|
|
323
|
+
value: 3,
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
rightChild: {
|
|
328
|
+
id: 2,
|
|
329
|
+
leftChild: {
|
|
330
|
+
id: 7,
|
|
331
|
+
value: 9,
|
|
332
|
+
},
|
|
333
|
+
rightChild: {
|
|
334
|
+
id: 0,
|
|
335
|
+
leftChild: {
|
|
336
|
+
id: 2,
|
|
337
|
+
leftChild: {
|
|
338
|
+
id: 7,
|
|
339
|
+
value: -30,
|
|
340
|
+
},
|
|
341
|
+
rightChild: {
|
|
342
|
+
id: 5,
|
|
343
|
+
leftChild: {
|
|
344
|
+
id: 10,
|
|
345
|
+
name: "x",
|
|
346
|
+
},
|
|
347
|
+
rightChild: {
|
|
348
|
+
id: 7,
|
|
349
|
+
value: 2,
|
|
350
|
+
},
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
rightChild: {
|
|
354
|
+
id: 2,
|
|
355
|
+
leftChild: {
|
|
356
|
+
id: 7,
|
|
357
|
+
value: 15,
|
|
358
|
+
},
|
|
359
|
+
rightChild: {
|
|
360
|
+
id: 0,
|
|
361
|
+
leftChild: {
|
|
362
|
+
id: 2,
|
|
363
|
+
leftChild: {
|
|
364
|
+
id: 7,
|
|
365
|
+
value: 17,
|
|
366
|
+
},
|
|
367
|
+
rightChild: {
|
|
368
|
+
id: 10,
|
|
369
|
+
name: "x",
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
rightChild: {
|
|
373
|
+
id: 7,
|
|
374
|
+
value: -30,
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
},
|
|
379
|
+
},
|
|
380
|
+
},
|
|
381
|
+
},
|
|
382
|
+
},
|
|
383
|
+
rightChild: {
|
|
384
|
+
id: 7,
|
|
385
|
+
value: 121500,
|
|
386
|
+
},
|
|
387
|
+
},
|
|
388
|
+
nodeIdsXAsked: {
|
|
389
|
+
id: 7,
|
|
390
|
+
value: 2,
|
|
391
|
+
},
|
|
392
|
+
};
|
|
393
|
+
identifiers = identifiersDefault;
|
|
394
|
+
}
|
|
395
|
+
return getQuestionFromIdentifiers(identifiers, opts);
|
|
396
|
+
};
|
|
397
|
+
const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
398
|
+
return {
|
|
399
|
+
instruction: getInstruction(identifiers, opts),
|
|
400
|
+
startStatement: "a",
|
|
401
|
+
answer: getAnswer(identifiers),
|
|
402
|
+
ggbOptions: getGGBOptions(identifiers),
|
|
403
|
+
answerFormat: "tex",
|
|
404
|
+
keys: [],
|
|
405
|
+
hint: getHint(identifiers, opts),
|
|
406
|
+
correction: getCorrection(identifiers, opts),
|
|
407
|
+
correctionGgbOptions: getCorrectionGGBOptions(identifiers, opts),
|
|
408
|
+
identifiers,
|
|
409
|
+
};
|
|
410
|
+
};
|
|
411
|
+
const options = [
|
|
412
|
+
{
|
|
413
|
+
id: "notationType",
|
|
414
|
+
label: "",
|
|
415
|
+
type: GeneratorOptionType.select,
|
|
416
|
+
target: GeneratorOptionTarget.instruction,
|
|
417
|
+
values: ["Nombre dérivé de $f$ en $a$", "$f'(a)$"],
|
|
418
|
+
defaultValue: "$f'(a)$",
|
|
419
|
+
},
|
|
420
|
+
];
|
|
421
|
+
export const derivativeReadingByManipulatingBuildingTangent = {
|
|
422
|
+
id: "derivativeReadingByManipulatingBuildingTangent",
|
|
423
|
+
connector: "=",
|
|
424
|
+
label: "Lire graphiquement un nombre dérivé par la manipulation (construction de la tangente)",
|
|
425
|
+
isSingleStep: false,
|
|
426
|
+
generator: (nb, opts) => getDistinctQuestions(() => getDerivativeReadingByManipulatingBuildingTangentQuestion(opts), nb),
|
|
427
|
+
options,
|
|
428
|
+
qcmTimer: 60,
|
|
429
|
+
freeTimer: 60,
|
|
430
|
+
getPropositions,
|
|
431
|
+
isAnswerValid,
|
|
432
|
+
hasGeogebra: true,
|
|
433
|
+
subject: "Mathématiques",
|
|
434
|
+
getQuestionFromIdentifiers,
|
|
435
|
+
hasHintAndCorrection: true,
|
|
436
|
+
};
|