math-exercises 3.0.178 → 3.0.180

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving1.d.ts +14 -0
  2. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving1.d.ts.map +1 -0
  3. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving1.js +283 -0
  4. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving3.d.ts +15 -0
  5. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving3.d.ts.map +1 -0
  6. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving3.js +296 -0
  7. package/lib/exercises/math/derivation/derivative/exp/expDerivativeOne.js +3 -3
  8. package/lib/exercises/math/derivation/derivative/exp/expDerivativeProductFExp.d.ts +14 -0
  9. package/lib/exercises/math/derivation/derivative/exp/expDerivativeProductFExp.d.ts.map +1 -0
  10. package/lib/exercises/math/derivation/derivative/exp/expDerivativeProductFExp.js +346 -0
  11. package/lib/exercises/math/derivation/derivative/exp/expDerivativeQuotientFExp.d.ts +15 -0
  12. package/lib/exercises/math/derivation/derivative/exp/expDerivativeQuotientFExp.d.ts.map +1 -0
  13. package/lib/exercises/math/derivation/derivative/exp/expDerivativeQuotientFExp.js +435 -0
  14. package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.d.ts +13 -0
  15. package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.d.ts.map +1 -0
  16. package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.js +326 -0
  17. package/lib/exercises/math/derivation/derivativeNumber/signOfDerivativeNumberFromFunctionCurve.d.ts +14 -0
  18. package/lib/exercises/math/derivation/derivativeNumber/signOfDerivativeNumberFromFunctionCurve.d.ts.map +1 -0
  19. package/lib/exercises/math/derivation/derivativeNumber/signOfDerivativeNumberFromFunctionCurve.js +181 -0
  20. package/lib/exercises/math/derivation/derivativeNumber/valueTableImageAndDerivativeFromFunctionExpression.d.ts +10 -0
  21. package/lib/exercises/math/derivation/derivativeNumber/valueTableImageAndDerivativeFromFunctionExpression.d.ts.map +1 -0
  22. package/lib/exercises/math/derivation/derivativeNumber/valueTableImageAndDerivativeFromFunctionExpression.js +272 -0
  23. package/lib/exercises/math/derivation/problems/index.d.ts +5 -0
  24. package/lib/exercises/math/derivation/problems/index.d.ts.map +1 -0
  25. package/lib/exercises/math/derivation/problems/index.js +4 -0
  26. package/lib/exercises/math/derivation/problems/problemMaximizeBoxVolumeFindX.d.ts +8 -0
  27. package/lib/exercises/math/derivation/problems/problemMaximizeBoxVolumeFindX.d.ts.map +1 -0
  28. package/lib/exercises/math/derivation/problems/problemMaximizeBoxVolumeFindX.js +171 -0
  29. package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.d.ts +15 -0
  30. package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.d.ts.map +1 -0
  31. package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.js +328 -0
  32. package/lib/exercises/math/derivation/problems/problemMovementOnLineFindSpeedAtPoint.d.ts +13 -0
  33. package/lib/exercises/math/derivation/problems/problemMovementOnLineFindSpeedAtPoint.d.ts.map +1 -0
  34. package/lib/exercises/math/derivation/problems/problemMovementOnLineFindSpeedAtPoint.js +275 -0
  35. package/lib/exercises/math/derivation/problems/problemProjectileHeightFindAbscissa.d.ts +8 -0
  36. package/lib/exercises/math/derivation/problems/problemProjectileHeightFindAbscissa.d.ts.map +1 -0
  37. package/lib/exercises/math/derivation/problems/problemProjectileHeightFindAbscissa.js +137 -0
  38. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineY.d.ts +10 -0
  39. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineY.d.ts.map +1 -0
  40. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineY.js +478 -0
  41. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineYAndSlope.d.ts +10 -0
  42. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineYAndSlope.d.ts.map +1 -0
  43. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineYAndSlope.js +499 -0
  44. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingPoint.d.ts +10 -0
  45. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingPoint.d.ts.map +1 -0
  46. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingPoint.js +240 -0
  47. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingBuildingTangent.d.ts +12 -0
  48. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingBuildingTangent.d.ts.map +1 -0
  49. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingBuildingTangent.js +436 -0
  50. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingPoint.d.ts +12 -0
  51. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingPoint.d.ts.map +1 -0
  52. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingPoint.js +219 -0
  53. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingSecant.d.ts +13 -0
  54. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingSecant.d.ts.map +1 -0
  55. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingSecant.js +273 -0
  56. package/lib/exercises/math/derivation/tangent/placePointsOfDerivativeFromGraph.d.ts +18 -0
  57. package/lib/exercises/math/derivation/tangent/placePointsOfDerivativeFromGraph.d.ts.map +1 -0
  58. package/lib/exercises/math/derivation/tangent/placePointsOfDerivativeFromGraph.js +295 -0
  59. package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.d.ts +13 -0
  60. package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.d.ts.map +1 -0
  61. package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.js +388 -0
  62. package/lib/exercises/math/derivation/tangent/tangentEquationFromGraph.d.ts +9 -0
  63. package/lib/exercises/math/derivation/tangent/tangentEquationFromGraph.d.ts.map +1 -0
  64. package/lib/exercises/math/derivation/tangent/tangentEquationFromGraph.js +308 -0
  65. package/lib/exercises/math/derivation/variations/findAbscissaOfExtremaFromFunctionExpression.d.ts +14 -0
  66. package/lib/exercises/math/derivation/variations/findAbscissaOfExtremaFromFunctionExpression.d.ts.map +1 -0
  67. package/lib/exercises/math/derivation/variations/findAbscissaOfExtremaFromFunctionExpression.js +439 -0
  68. package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.d.ts +14 -0
  69. package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.d.ts.map +1 -0
  70. package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.js +547 -0
  71. package/lib/exercises/math/derivation/variations/plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.d.ts +15 -0
  72. package/lib/exercises/math/derivation/variations/plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.d.ts.map +1 -0
  73. package/lib/exercises/math/derivation/variations/plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.js +537 -0
  74. package/lib/exercises/math/derivation/variations/plausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomial.d.ts +15 -0
  75. package/lib/exercises/math/derivation/variations/plausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomial.d.ts.map +1 -0
  76. package/lib/exercises/math/derivation/variations/plausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomial.js +639 -0
  77. package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.d.ts +14 -0
  78. package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.d.ts.map +1 -0
  79. package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.js +530 -0
  80. package/lib/exercises/math/derivation/variations/signVarTableProductFExp.d.ts +10 -0
  81. package/lib/exercises/math/derivation/variations/signVarTableProductFExp.d.ts.map +1 -0
  82. package/lib/exercises/math/derivation/variations/signVarTableProductFExp.js +451 -0
  83. package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.d.ts +11 -0
  84. package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.d.ts.map +1 -0
  85. package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.js +514 -0
  86. package/lib/exercises/math/functions/trinoms/sign/signOfProductOfAffineAndTrinom.d.ts.map +1 -1
  87. package/lib/exercises/math/functions/trinoms/sign/signOfProductOfAffineAndTrinom.js +4 -11
  88. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOrthoInSquare.d.ts.map +1 -1
  89. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOrthoInSquare.js +32 -17
  90. package/lib/exercises/math/probaStat/conditional/conditionalProbaFromTableWithContext.d.ts +13 -0
  91. package/lib/exercises/math/probaStat/conditional/conditionalProbaFromTableWithContext.d.ts.map +1 -0
  92. package/lib/exercises/math/probaStat/conditional/conditionalProbaFromTableWithContext.js +195 -0
  93. package/lib/exercises/math/probaStat/conditional/conditionalProbaWriteFromFrench.d.ts +9 -0
  94. package/lib/exercises/math/probaStat/conditional/conditionalProbaWriteFromFrench.d.ts.map +1 -0
  95. package/lib/exercises/math/probaStat/conditional/conditionalProbaWriteFromFrench.js +220 -0
  96. package/lib/exercises/math/probaStat/conditional/conditionalProbability.d.ts +15 -0
  97. package/lib/exercises/math/probaStat/conditional/conditionalProbability.d.ts.map +1 -0
  98. package/lib/exercises/math/probaStat/conditional/conditionalProbability.js +332 -0
  99. package/lib/exercises/math/probaStat/conditional/fillTableConditionalProbabilitySituation.d.ts +8 -0
  100. package/lib/exercises/math/probaStat/conditional/fillTableConditionalProbabilitySituation.d.ts.map +1 -0
  101. package/lib/exercises/math/probaStat/conditional/fillTableConditionalProbabilitySituation.js +222 -0
  102. package/lib/exercises/math/probaStat/conditional/index.d.ts +5 -0
  103. package/lib/exercises/math/probaStat/conditional/index.d.ts.map +1 -0
  104. package/lib/exercises/math/probaStat/conditional/index.js +4 -0
  105. package/lib/exercises/math/probaStat/index.d.ts +1 -2
  106. package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
  107. package/lib/exercises/math/probaStat/index.js +1 -2
  108. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts +1 -0
  109. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
  110. package/lib/exercises/math/probaStat/probaFromTableWithContext.js +26 -199
  111. package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationProbabilityLaw.d.ts.map +1 -1
  112. package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationProbabilityLaw.js +6 -2
  113. package/lib/exercises/math/probaStat/randomVariable/utils/randomVariableSituations.d.ts.map +1 -1
  114. package/lib/exercises/math/probaStat/randomVariable/utils/randomVariableSituations.js +6 -5
  115. package/lib/exercises/math/probaStat/trees/buildTreeFromSituation.d.ts.map +1 -1
  116. package/lib/exercises/math/probaStat/trees/buildTreeFromSituation.js +4 -27
  117. package/lib/exercises/math/probaStat/twoEventsSituations.d.ts +29 -0
  118. package/lib/exercises/math/probaStat/twoEventsSituations.d.ts.map +1 -0
  119. package/lib/exercises/math/probaStat/twoEventsSituations.js +145 -0
  120. package/lib/exercises/math/sequences/explicitFormulaUsage.d.ts +4 -1
  121. package/lib/exercises/math/sequences/explicitFormulaUsage.d.ts.map +1 -1
  122. package/lib/exercises/math/sequences/explicitFormulaUsage.js +47 -7
  123. package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoTerms.js +1 -1
  124. package/lib/exercises/math/sequences/recurrenceFormulaUsage.d.ts +5 -1
  125. package/lib/exercises/math/sequences/recurrenceFormulaUsage.d.ts.map +1 -1
  126. package/lib/exercises/math/sequences/recurrenceFormulaUsage.js +89 -9
  127. package/lib/exercises/math/trigonometry/circle/associatePoint.d.ts.map +1 -1
  128. package/lib/exercises/math/trigonometry/circle/associatePoint.js +55 -6
  129. package/lib/exercises/math/trigonometry/circle/selectQuadrantOnTrigoCircle.d.ts.map +1 -1
  130. package/lib/exercises/math/trigonometry/circle/selectQuadrantOnTrigoCircle.js +5 -6
  131. package/lib/exercises/math/trigonometry/functions/associateAngleSimplification.d.ts.map +1 -1
  132. package/lib/exercises/math/trigonometry/functions/associateAngleSimplification.js +1 -3
  133. package/lib/exercises/vea/polynomialVEA.d.ts +2 -0
  134. package/lib/exercises/vea/polynomialVEA.d.ts.map +1 -0
  135. package/lib/exercises/vea/polynomialVEA.js +17 -0
  136. package/lib/exercises/vea/valueTableVEA.d.ts +8 -0
  137. package/lib/exercises/vea/valueTableVEA.d.ts.map +1 -0
  138. package/lib/exercises/vea/valueTableVEA.js +12 -0
  139. package/lib/index.d.ts +27 -11
  140. package/lib/index.d.ts.map +1 -1
  141. package/lib/latexTester.d.ts.map +1 -1
  142. package/lib/latexTester.js +1 -1
  143. package/lib/math/utils/polynomial/polynomialInterpolationUtils.d.ts +19 -0
  144. package/lib/math/utils/polynomial/polynomialInterpolationUtils.d.ts.map +1 -0
  145. package/lib/math/utils/polynomial/polynomialInterpolationUtils.js +53 -0
  146. package/lib/math/utils/polynomial/polynomialUtils.d.ts +37 -0
  147. package/lib/math/utils/polynomial/polynomialUtils.d.ts.map +1 -0
  148. package/lib/math/utils/polynomial/polynomialUtils.js +223 -0
  149. package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts.map +1 -1
  150. package/lib/math/utils/sequences/situations/seqArithmeticSituations.js +6 -6
  151. package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
  152. package/lib/tree/nodes/operators/multiplyNode.js +1 -1
  153. package/lib/tree/nodes/operators/substractNode.d.ts.map +1 -1
  154. package/lib/tree/nodes/operators/substractNode.js +2 -1
  155. package/lib/tree/utilities/nodeUtils.d.ts +6 -0
  156. package/lib/tree/utilities/nodeUtils.d.ts.map +1 -0
  157. package/lib/tree/utilities/nodeUtils.js +24 -0
  158. package/lib/utils/strings/prependArticle.d.ts +2 -0
  159. package/lib/utils/strings/prependArticle.d.ts.map +1 -0
  160. package/lib/utils/strings/prependArticle.js +1 -0
  161. package/package.json +1 -1
@@ -0,0 +1,388 @@
1
+ import { addValidProp, tryToAddWrongProp, propWhile, shuffleProps, GeneratorOptionTarget, GeneratorOptionType, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { polynomialVEA } from "../../../../exercises/vea/polynomialVEA.js";
4
+ import { AffineConstructor } from "../../../../math/polynomials/affine.js";
5
+ import { PolynomialConstructor } from "../../../../math/polynomials/polynomial.js";
6
+ import { TrinomConstructor } from "../../../../math/polynomials/trinom.js";
7
+ import { nodeBySubstitutingVar } from "../../../../math/utils/functions/functionComposition.js";
8
+ import { randint } from "../../../../math/utils/random/randint.js";
9
+ import { sqrt } from "../../../../tree/nodes/functions/sqrtNode.js";
10
+ import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
11
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
12
+ import { frac, isFractionNode, } from "../../../../tree/nodes/operators/fractionNode.js";
13
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
14
+ import { power, square } from "../../../../tree/nodes/operators/powerNode.js";
15
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
16
+ import { random } from "../../../../utils/alea/random.js";
17
+ import { shuffle } from "../../../../utils/alea/shuffle.js";
18
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
19
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
20
+ const getNodeFForTypeF = (typeF) => {
21
+ const nodeVarX = "x".toTree();
22
+ switch (typeF) {
23
+ case "$k$":
24
+ return randint(-10, 11).toTree();
25
+ case "$x$":
26
+ return nodeVarX;
27
+ case "$x^2$":
28
+ return square(nodeVarX);
29
+ case "$x^n \\ (n>=3)$":
30
+ return power(nodeVarX, randint(3, 6));
31
+ case "$\\frac{1}{x}$":
32
+ return frac(1, nodeVarX);
33
+ case "$\\frac{1}{x^n} \\ (n>=2)$":
34
+ return frac(1, power(nodeVarX, randint(3, 6)));
35
+ case "$\\sqrt{x}$":
36
+ return sqrt(nodeVarX);
37
+ case "polynôme (degré $1$)":
38
+ return AffineConstructor.random().toTree();
39
+ case "polynôme (degré $2$)":
40
+ return TrinomConstructor.random().toTree();
41
+ case "polynôme (degré $3$)":
42
+ return PolynomialConstructor.randomWithOrder(3).toTree();
43
+ case "$\\frac{ax+b}{cx+d}$": {
44
+ const [nodeNum, nodeDen] = AffineConstructor.differentRandoms(2).map((affine) => affine.toTree());
45
+ return frac(nodeNum, nodeDen);
46
+ }
47
+ case "$(ax+b)\\sqrt{x}$": {
48
+ const nodeAffine = AffineConstructor.random().toTree();
49
+ return multiply(nodeAffine, sqrt(nodeVarX));
50
+ }
51
+ default:
52
+ throw new Error("Unsupported typeF: " + typeF);
53
+ }
54
+ };
55
+ const getRandomNodeXAskedForTypeF = (typeF) => {
56
+ switch (typeF) {
57
+ case "$\\frac{1}{x}$":
58
+ case "$\\frac{1}{x^n} \\ (n>=2)$":
59
+ return randint(-5, 6, [0]).toTree();
60
+ case "$\\sqrt{x}$":
61
+ case "$(ax+b)\\sqrt{x}$":
62
+ return randint(1, 6).toTree();
63
+ default:
64
+ return randint(-5, 6).toTree();
65
+ }
66
+ };
67
+ const getPrettyDerivativeNode = (nodeF) => {
68
+ const nodeDerivativeRaw = nodeF.derivative().simplify();
69
+ if (isFractionNode(nodeDerivativeRaw)) {
70
+ const nodeNumSimplified = nodeDerivativeRaw.leftChild.simplify({
71
+ towardsDistribute: true,
72
+ forbidFactorize: true,
73
+ });
74
+ const nodeDenSimplified = nodeDerivativeRaw.rightChild.simplify();
75
+ return frac(nodeNumSimplified, nodeDenSimplified);
76
+ }
77
+ else {
78
+ return nodeDerivativeRaw;
79
+ }
80
+ };
81
+ const getInstruction = (identifiers) => {
82
+ const { nodeIdsXAsked, nodeIdsF } = identifiers;
83
+ const [nodeXAsked, nodeF] = [nodeIdsXAsked, nodeIdsF].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
84
+ return `Soit $f$ une fonction telle que, pour tout $x$ dans l'ensemble de dérivation de $f$ :
85
+
86
+ $$
87
+ f(x) = ${nodeF.toTex()}
88
+ $$
89
+
90
+ Déterminer l'équation de la tangente à la courbe représentative de $f$ au point d'abscisse $${nodeXAsked.toTex()}$.`;
91
+ };
92
+ const getAnswerNode = (identifiers) => {
93
+ const { nodeIdsXAsked, nodeIdsF } = identifiers;
94
+ const [nodeXAsked, nodeF] = [nodeIdsXAsked, nodeIdsF].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
95
+ const nodeDerivative = getPrettyDerivativeNode(nodeF);
96
+ const nodeValueImage = nodeBySubstitutingVar(nodeF, nodeXAsked, "x".toTree()).simplify();
97
+ const nodeValueDerivative = nodeBySubstitutingVar(nodeDerivative, nodeXAsked, "x".toTree()).simplify();
98
+ const nodeX = "x".toTree();
99
+ const nodeT = add(multiply(nodeValueDerivative, substract(nodeX, nodeXAsked)), nodeValueImage);
100
+ return nodeT;
101
+ };
102
+ const getAnswer = (identifiers) => {
103
+ return `y = ${getAnswerNode(identifiers)
104
+ .simplify({ towardsDistribute: true, forbidFactorize: true })
105
+ .toTex()}`;
106
+ };
107
+ const getHint = (identifiers) => {
108
+ const { typeF } = identifiers;
109
+ const strHintDerivative = (() => {
110
+ switch (typeF) {
111
+ case "$k$":
112
+ return `Soit $k$ un réel. La dérivée de $x \\mapsto k$ est $x \\mapsto 0$.`;
113
+ case "$x$":
114
+ return `La dérivée de $x \\mapsto x$ est $x \\mapsto 1$.`;
115
+ case "$x^2$":
116
+ return `La dérivée de $x \\mapsto x^2$ est $x \\mapsto 2x$.`;
117
+ case "$x^n \\ (n>=3)$":
118
+ return `Soit $n$ un entier tel que $n \\geq 3$. La dérivée de $x \\mapsto x^n$ est $x \\mapsto nx^{n-1}$.`;
119
+ case "$\\frac{1}{x}$":
120
+ return `Soit $n$ un entier. La dérivée de $x \\mapsto \\frac{1}{x}$ est $x \\mapsto -\\frac{1}{x^2}$.`;
121
+ case "$\\frac{1}{x^n} \\ (n>=2)$":
122
+ return `Soit $n$ un entier tel que $n \\geq 2$. La dérivée de $x \\mapsto \\frac{1}{x^n}$ est $x \\mapsto \\frac{-n}{x^{n+1}}$.`;
123
+ case "$\\sqrt{x}$":
124
+ return `La dérivée de $x \\mapsto \\sqrt{x}$ est $x \\mapsto \\frac{1}{2\\sqrt{x}}$.`;
125
+ case "polynôme (degré $1$)":
126
+ return `Soient $a$ et $b$ deux réels. La dérivée de $x \\mapsto ax+b$ est $x \\mapsto a$.`;
127
+ case "polynôme (degré $2$)":
128
+ return `Soient $a$, $b$ et $c$ trois réels. La dérivée de $x \\mapsto ax^2+bx+c$ est $x \\mapsto 2ax+b$.`;
129
+ case "polynôme (degré $3$)":
130
+ return `Soient $a$, $b$, $c$ et $d$ quatre réels. La dérivée de $x \\mapsto ax^3+bx^2+cx+d$ est $x \\mapsto 3ax^2+2bx+c$.`;
131
+ case "$\\frac{ax+b}{cx+d}$":
132
+ return `Soient $a$, $b$, $c$ et $d$ quatre réels. La dérivée de $x \\mapsto \\frac{ax+b}{cx+d}$ est $x \\mapsto \\frac{a(cx+d)-(ax+b)c}{(cx+d)^2}$.`;
133
+ case "$(ax+b)\\sqrt{x}$":
134
+ return `Soient $a$ et $b$ deux réels. La dérivée de $x \\mapsto (ax+b)\\sqrt{x}$ est $x \\mapsto a\\sqrt{x}+(ax+b)\\frac{1}{2\\sqrt{x}}$.`;
135
+ default:
136
+ throw new Error("Unsupported typeF: " + typeF);
137
+ }
138
+ })();
139
+ return `Si $f$ est une fonction dérivable en $a$, alors l'équation de la tangente à la courbe de $f$ au point d'abscisse $a$ est donné par:
140
+
141
+ $$
142
+ y = f'(a)(x-a)+f(a)
143
+ $$
144
+
145
+ ${strHintDerivative}
146
+ `;
147
+ };
148
+ const getCorrection = (identifiers) => {
149
+ const { nodeIdsXAsked, nodeIdsF } = identifiers;
150
+ const [nodeXAsked, nodeF] = [nodeIdsXAsked, nodeIdsF].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
151
+ const nodeDerivative = getPrettyDerivativeNode(nodeF);
152
+ const nodeValueImage = nodeBySubstitutingVar(nodeF, nodeXAsked, "x".toTree()).simplify();
153
+ const nodeValueDerivative = nodeBySubstitutingVar(nodeDerivative, nodeXAsked, "x".toTree()).simplify();
154
+ const nodeT = getAnswerNode(identifiers);
155
+ return `L'équation de la tangente à la courbe de $f$ au point d'abscisse $a$ est donné par:
156
+
157
+ $$
158
+ y = f'(a)(x-a)+f(a)
159
+ $$
160
+
161
+ Pour $x$ appartenant à l'ensemble de dérivation de $f$, on calcule :
162
+
163
+ ${alignTex([
164
+ ...[...new Set([nodeF.derivative().toTex(), nodeDerivative.toTex()])].map((tex) => [`f'(x)`, "=", tex]),
165
+ ])}
166
+
167
+ Pour $a=${nodeXAsked.toTex()}$, on calcule :
168
+
169
+ $$
170
+ f'(${nodeXAsked.toTex()}) = ${nodeValueDerivative.toTex()}
171
+ $$
172
+
173
+ $$
174
+ f(${nodeXAsked.toTex()}) = ${nodeValueImage.toTex()}
175
+ $$
176
+
177
+ L'équation de la tangente en $${nodeXAsked.toTex()}$ est donc :
178
+
179
+ ${alignTex([
180
+ ["y", "=", nodeT.toTex()],
181
+ [
182
+ "",
183
+ "=",
184
+ nodeT.simplify({ towardsDistribute: true, forbidFactorize: true }).toTex(),
185
+ ],
186
+ ])}
187
+ `;
188
+ };
189
+ const getPropositions = (n, { answer, ...identifiers }) => {
190
+ const { nodeIdsXAsked, nodeIdsF } = identifiers;
191
+ const nodeXAsked = NodeConstructor.fromIdentifiers(nodeIdsXAsked);
192
+ const nodeF = NodeConstructor.fromIdentifiers(nodeIdsF);
193
+ const nodeDerivative = nodeF.derivative().simplify();
194
+ const nodeValueImage = nodeBySubstitutingVar(nodeF, nodeXAsked, "x".toTree()).simplify();
195
+ const nodeValueDerivative = nodeBySubstitutingVar(nodeDerivative, nodeXAsked, "x".toTree()).simplify();
196
+ //mandatory
197
+ const propositionsMandatory = [];
198
+ addValidProp(propositionsMandatory, answer);
199
+ //student: y=f'(a)x + f(a)
200
+ {
201
+ const nodeX = "x".toTree();
202
+ const nodeTWrong = add(multiply(nodeValueDerivative, nodeX), nodeValueImage);
203
+ const texWrong = `y = ${nodeTWrong
204
+ .simplify({ towardsDistribute: true, forbidFactorize: true })
205
+ .toTex()}`;
206
+ tryToAddWrongProp(propositionsMandatory, texWrong);
207
+ }
208
+ //filler
209
+ const propositionsFiller = [];
210
+ //student: y=f(a)(x-a) + f'(a)
211
+ //student: y=f'(a)(x-f(a)) + f(a)
212
+ //student: y=f(a)(x-f'(a)) + f'(a)
213
+ //etc.
214
+ {
215
+ [
216
+ [nodeXAsked, nodeValueDerivative, nodeValueDerivative],
217
+ [nodeXAsked, nodeValueImage, nodeValueImage],
218
+ [nodeXAsked, nodeValueDerivative, nodeValueImage],
219
+ [nodeXAsked, nodeValueDerivative, nodeXAsked],
220
+ [nodeXAsked, nodeValueImage, nodeXAsked],
221
+ [nodeValueImage, nodeValueImage, nodeValueDerivative],
222
+ ].forEach(([nodeXAskedWrong, nodeValueImageWrong, nodeValueDerivativeWrong]) => {
223
+ const nodeX = "x".toTree();
224
+ const nodeTWrong = add(multiply(nodeValueDerivativeWrong, substract(nodeX, nodeXAskedWrong)), nodeValueImageWrong);
225
+ const texWrong = `y = ${nodeTWrong
226
+ .simplify({ towardsDistribute: true, forbidFactorize: true })
227
+ .toTex()}`;
228
+ tryToAddWrongProp(propositionsFiller, texWrong);
229
+ });
230
+ }
231
+ propWhile(propositionsFiller, n, () => {
232
+ const typeF = random(arrayedOptsDefault.typeF);
233
+ const identifiersWrong = createRandomIdentifiers(typeF);
234
+ if (isIdentifiersQCPassed(identifiersWrong)) {
235
+ tryToAddWrongProp(propositionsFiller, getAnswer(identifiersWrong));
236
+ }
237
+ });
238
+ return shuffle([
239
+ ...propositionsMandatory,
240
+ ...shuffleProps(propositionsFiller.filter((propositionFiller) => !propositionsMandatory
241
+ .map((proposition) => proposition.statement)
242
+ .includes(propositionFiller.statement)), n - propositionsMandatory.length),
243
+ ]);
244
+ };
245
+ const getKeys = () => {
246
+ return [];
247
+ };
248
+ const isAnswerValid = (ans, { answer }) => {
249
+ try {
250
+ const ansRefined = (() => {
251
+ const arrComponents = ans.split("=");
252
+ if (arrComponents.length === 1) {
253
+ return arrComponents[0];
254
+ }
255
+ else {
256
+ return arrComponents[1];
257
+ }
258
+ })();
259
+ const answerRefined = answer.split("=")[1];
260
+ return polynomialVEA(ansRefined, answerRefined);
261
+ }
262
+ catch (err) {
263
+ return handleVEAError(err);
264
+ }
265
+ };
266
+ const createRandomIdentifiers = (typeF) => {
267
+ const nodeF = getNodeFForTypeF(typeF);
268
+ const nodeXAsked = getRandomNodeXAskedForTypeF(typeF);
269
+ const identifiers = {
270
+ nodeIdsXAsked: nodeXAsked.toIdentifiers(),
271
+ nodeIdsF: nodeF.toIdentifiers(),
272
+ typeF,
273
+ };
274
+ return identifiers;
275
+ };
276
+ const isIdentifiersQCPassed = (identifiers) => {
277
+ const isExploding = (identifiers) => {
278
+ const { nodeIdsXAsked, nodeIdsF } = identifiers;
279
+ const [nodeXAsked, nodeF] = [nodeIdsXAsked, nodeIdsF].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
280
+ const nodeDerivative = getPrettyDerivativeNode(nodeF);
281
+ let isExploding = false;
282
+ try {
283
+ const _nodeValueFunction = nodeBySubstitutingVar(nodeF, nodeXAsked, "x".toTree()).simplify();
284
+ const _nodeValueDerivative = nodeBySubstitutingVar(nodeDerivative, nodeXAsked, "x".toTree()).simplify();
285
+ }
286
+ catch (_) {
287
+ isExploding = true;
288
+ }
289
+ return isExploding;
290
+ };
291
+ return !isExploding(identifiers);
292
+ };
293
+ const getTangentEquationFromFunctionExpressionQuestion = (optsIn) => {
294
+ const arrayedOptions = optsIn ?? arrayedOptsDefault;
295
+ const typeF = random(arrayedOptions.typeF);
296
+ let identifiers;
297
+ let isValid = false;
298
+ let counter = -1;
299
+ while (!isValid && counter < 100) {
300
+ counter++;
301
+ const identifiersCandidate = createRandomIdentifiers(typeF);
302
+ isValid = isIdentifiersQCPassed(identifiersCandidate);
303
+ if (isValid) {
304
+ identifiers = identifiersCandidate;
305
+ }
306
+ }
307
+ if (!isValid) {
308
+ const identifiersDefault = {
309
+ nodeIdsXAsked: {
310
+ id: 7,
311
+ value: 3,
312
+ },
313
+ nodeIdsF: {
314
+ id: 10,
315
+ name: "x",
316
+ },
317
+ typeF: "$x$",
318
+ };
319
+ identifiers = identifiersDefault;
320
+ }
321
+ return getQuestionFromIdentifiers(identifiers);
322
+ };
323
+ const getQuestionFromIdentifiers = (identifiers) => {
324
+ return {
325
+ answer: getAnswer(identifiers),
326
+ instruction: getInstruction(identifiers),
327
+ keys: getKeys(identifiers),
328
+ answerFormat: "tex",
329
+ identifiers,
330
+ hint: getHint(identifiers),
331
+ correction: getCorrection(identifiers),
332
+ };
333
+ };
334
+ const arrayedOptsDefault = {
335
+ typeF: [
336
+ "$k$",
337
+ "$x$",
338
+ "$x^2$",
339
+ "$x^n \\ (n>=3)$",
340
+ "$\\frac{1}{x}$",
341
+ "$\\frac{1}{x^n} \\ (n>=2)$",
342
+ "$\\sqrt{x}$",
343
+ "polynôme (degré $1$)",
344
+ "polynôme (degré $2$)",
345
+ "polynôme (degré $3$)",
346
+ "$\\frac{ax+b}{cx+d}$",
347
+ "$(ax+b)\\sqrt{x}$",
348
+ ],
349
+ };
350
+ const options = [
351
+ {
352
+ id: "typeF",
353
+ label: "Type de fonction",
354
+ target: GeneratorOptionTarget.generation,
355
+ type: GeneratorOptionType.multiselect,
356
+ values: [
357
+ "$k$",
358
+ "$x$",
359
+ "$x^2$",
360
+ "$x^n \\ (n>=3)$",
361
+ "$\\frac{1}{x}$",
362
+ "$\\frac{1}{x^n} \\ (n>=2)$",
363
+ "$\\sqrt{x}$",
364
+ "polynôme (degré $1$)",
365
+ "polynôme (degré $2$)",
366
+ "polynôme (degré $3$)",
367
+ "$\\frac{ax+b}{cx+d}$",
368
+ "$(ax+b)\\sqrt{x}$",
369
+ ],
370
+ defaultValue: arrayedOptsDefault.typeF,
371
+ },
372
+ ];
373
+ export const tangentEquationFromFunctionExpression = {
374
+ id: "tangentEquationFromFunctionExpression",
375
+ connector: "=",
376
+ label: "Déterminer l'équation de la tangente en $a$ à partir de l'expression d'une fonction",
377
+ isSingleStep: true,
378
+ generator: (nb, opts) => getDistinctQuestions(() => getTangentEquationFromFunctionExpressionQuestion(opts), nb),
379
+ options,
380
+ subject: "Mathématiques",
381
+ getInstruction,
382
+ getHint,
383
+ getCorrection,
384
+ isAnswerValid,
385
+ getPropositions,
386
+ getQuestionFromIdentifiers,
387
+ hasHintAndCorrection: true,
388
+ };
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ nodeIdsXAsked: NodeIdentifiers;
5
+ nodeIdsF: NodeIdentifiers;
6
+ };
7
+ export declare const tangentEquationFromGraph: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=tangentEquationFromGraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tangentEquationFromGraph.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/tangent/tangentEquationFromGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAarC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAqB7C,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,eAAe,CAAC;IAC/B,QAAQ,EAAE,eAAe,CAAC;CAC3B,CAAC;AAwaF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAe1D,CAAC"}