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.
Files changed (173) 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/composition/index.d.ts +0 -1
  87. package/lib/exercises/math/functions/composition/index.d.ts.map +1 -1
  88. package/lib/exercises/math/functions/composition/index.js +1 -1
  89. package/lib/exercises/math/functions/exponential/algebraic/index.d.ts +0 -1
  90. package/lib/exercises/math/functions/exponential/algebraic/index.d.ts.map +1 -1
  91. package/lib/exercises/math/functions/exponential/algebraic/index.js +1 -1
  92. package/lib/exercises/math/functions/trinoms/sign/signOfProductOfAffineAndTrinom.d.ts.map +1 -1
  93. package/lib/exercises/math/functions/trinoms/sign/signOfProductOfAffineAndTrinom.js +4 -11
  94. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOrthoInSquare.d.ts.map +1 -1
  95. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOrthoInSquare.js +32 -17
  96. package/lib/exercises/math/probaStat/conditional/conditionalProbaFromTableWithContext.d.ts +13 -0
  97. package/lib/exercises/math/probaStat/conditional/conditionalProbaFromTableWithContext.d.ts.map +1 -0
  98. package/lib/exercises/math/probaStat/conditional/conditionalProbaFromTableWithContext.js +195 -0
  99. package/lib/exercises/math/probaStat/conditional/conditionalProbaWriteFromFrench.d.ts +9 -0
  100. package/lib/exercises/math/probaStat/conditional/conditionalProbaWriteFromFrench.d.ts.map +1 -0
  101. package/lib/exercises/math/probaStat/conditional/conditionalProbaWriteFromFrench.js +220 -0
  102. package/lib/exercises/math/probaStat/conditional/conditionalProbability.d.ts +15 -0
  103. package/lib/exercises/math/probaStat/conditional/conditionalProbability.d.ts.map +1 -0
  104. package/lib/exercises/math/probaStat/conditional/conditionalProbability.js +332 -0
  105. package/lib/exercises/math/probaStat/conditional/fillTableConditionalProbabilitySituation.d.ts +8 -0
  106. package/lib/exercises/math/probaStat/conditional/fillTableConditionalProbabilitySituation.d.ts.map +1 -0
  107. package/lib/exercises/math/probaStat/conditional/fillTableConditionalProbabilitySituation.js +222 -0
  108. package/lib/exercises/math/probaStat/conditional/index.d.ts +5 -0
  109. package/lib/exercises/math/probaStat/conditional/index.d.ts.map +1 -0
  110. package/lib/exercises/math/probaStat/conditional/index.js +4 -0
  111. package/lib/exercises/math/probaStat/index.d.ts +1 -2
  112. package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
  113. package/lib/exercises/math/probaStat/index.js +1 -2
  114. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts +1 -0
  115. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
  116. package/lib/exercises/math/probaStat/probaFromTableWithContext.js +26 -199
  117. package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationProbabilityLaw.d.ts.map +1 -1
  118. package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationProbabilityLaw.js +6 -2
  119. package/lib/exercises/math/probaStat/randomVariable/utils/randomVariableSituations.d.ts.map +1 -1
  120. package/lib/exercises/math/probaStat/randomVariable/utils/randomVariableSituations.js +6 -5
  121. package/lib/exercises/math/probaStat/trees/buildTreeFromSituation.d.ts.map +1 -1
  122. package/lib/exercises/math/probaStat/trees/buildTreeFromSituation.js +4 -27
  123. package/lib/exercises/math/probaStat/twoEventsSituations.d.ts +29 -0
  124. package/lib/exercises/math/probaStat/twoEventsSituations.d.ts.map +1 -0
  125. package/lib/exercises/math/probaStat/twoEventsSituations.js +145 -0
  126. package/lib/exercises/math/sequences/explicitFormulaUsage.d.ts +4 -1
  127. package/lib/exercises/math/sequences/explicitFormulaUsage.d.ts.map +1 -1
  128. package/lib/exercises/math/sequences/explicitFormulaUsage.js +47 -7
  129. package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoTerms.js +1 -1
  130. package/lib/exercises/math/sequences/geometric/index.d.ts +0 -3
  131. package/lib/exercises/math/sequences/geometric/index.d.ts.map +1 -1
  132. package/lib/exercises/math/sequences/geometric/index.js +3 -3
  133. package/lib/exercises/math/sequences/geometric/situations/index.d.ts +0 -1
  134. package/lib/exercises/math/sequences/geometric/situations/index.d.ts.map +1 -1
  135. package/lib/exercises/math/sequences/geometric/situations/index.js +1 -1
  136. package/lib/exercises/math/sequences/recurrenceFormulaUsage.d.ts +5 -1
  137. package/lib/exercises/math/sequences/recurrenceFormulaUsage.d.ts.map +1 -1
  138. package/lib/exercises/math/sequences/recurrenceFormulaUsage.js +89 -9
  139. package/lib/exercises/math/trigonometry/circle/associatePoint.d.ts.map +1 -1
  140. package/lib/exercises/math/trigonometry/circle/associatePoint.js +55 -6
  141. package/lib/exercises/math/trigonometry/circle/selectQuadrantOnTrigoCircle.d.ts.map +1 -1
  142. package/lib/exercises/math/trigonometry/circle/selectQuadrantOnTrigoCircle.js +5 -6
  143. package/lib/exercises/math/trigonometry/functions/associateAngleSimplification.d.ts.map +1 -1
  144. package/lib/exercises/math/trigonometry/functions/associateAngleSimplification.js +1 -3
  145. package/lib/exercises/vea/polynomialVEA.d.ts +2 -0
  146. package/lib/exercises/vea/polynomialVEA.d.ts.map +1 -0
  147. package/lib/exercises/vea/polynomialVEA.js +17 -0
  148. package/lib/exercises/vea/valueTableVEA.d.ts +8 -0
  149. package/lib/exercises/vea/valueTableVEA.d.ts.map +1 -0
  150. package/lib/exercises/vea/valueTableVEA.js +12 -0
  151. package/lib/index.d.ts +27 -47
  152. package/lib/index.d.ts.map +1 -1
  153. package/lib/latexTester.d.ts.map +1 -1
  154. package/lib/latexTester.js +1 -1
  155. package/lib/math/utils/polynomial/polynomialInterpolationUtils.d.ts +19 -0
  156. package/lib/math/utils/polynomial/polynomialInterpolationUtils.d.ts.map +1 -0
  157. package/lib/math/utils/polynomial/polynomialInterpolationUtils.js +53 -0
  158. package/lib/math/utils/polynomial/polynomialUtils.d.ts +37 -0
  159. package/lib/math/utils/polynomial/polynomialUtils.d.ts.map +1 -0
  160. package/lib/math/utils/polynomial/polynomialUtils.js +223 -0
  161. package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts.map +1 -1
  162. package/lib/math/utils/sequences/situations/seqArithmeticSituations.js +6 -6
  163. package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
  164. package/lib/tree/nodes/operators/multiplyNode.js +1 -1
  165. package/lib/tree/nodes/operators/substractNode.d.ts.map +1 -1
  166. package/lib/tree/nodes/operators/substractNode.js +2 -1
  167. package/lib/tree/utilities/nodeUtils.d.ts +6 -0
  168. package/lib/tree/utilities/nodeUtils.d.ts.map +1 -0
  169. package/lib/tree/utilities/nodeUtils.js +24 -0
  170. package/lib/utils/strings/prependArticle.d.ts +2 -0
  171. package/lib/utils/strings/prependArticle.d.ts.map +1 -0
  172. package/lib/utils/strings/prependArticle.js +1 -0
  173. package/package.json +1 -1
@@ -0,0 +1,272 @@
1
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
2
+ import { AffineConstructor } from "../../../../math/polynomials/affine.js";
3
+ import { TrinomConstructor } from "../../../../math/polynomials/trinom.js";
4
+ import { nodeBySubstitutingVar } from "../../../../math/utils/functions/functionComposition.js";
5
+ import { randint } from "../../../../math/utils/random/randint.js";
6
+ import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
7
+ import { frac, isFractionNode, } from "../../../../tree/nodes/operators/fractionNode.js";
8
+ import { power } from "../../../../tree/nodes/operators/powerNode.js";
9
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
10
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
11
+ import { random, randomMany } from "../../../../utils/alea/random.js";
12
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
13
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
14
+ import { mdTable } from "../../../../utils/markdown/mdTable.js";
15
+ const getPrettyDerivativeNode = (nodeF) => {
16
+ const nodeDerivativeRaw = nodeF.derivative().simplify();
17
+ if (isFractionNode(nodeDerivativeRaw)) {
18
+ const nodeNumSimplified = nodeDerivativeRaw.leftChild.simplify({
19
+ towardsDistribute: true,
20
+ forbidFactorize: true,
21
+ });
22
+ const nodeDenSimplified = nodeDerivativeRaw.rightChild.simplify();
23
+ return frac(nodeNumSimplified, nodeDenSimplified);
24
+ }
25
+ else {
26
+ return nodeDerivativeRaw;
27
+ }
28
+ };
29
+ const getInstruction = (identifiers) => {
30
+ const { nodeIdsF } = identifiers;
31
+ const nodeF = NodeConstructor.fromIdentifiers(nodeIdsF);
32
+ const nodeDerivative = getPrettyDerivativeNode(nodeF);
33
+ return `Soit $f$ une fonction telle que, pour tout $x$ bien choisi :
34
+
35
+ $$
36
+ f(x) = ${nodeF.toTex()}
37
+ $$
38
+
39
+ On a alors :
40
+
41
+ $$
42
+ f'(x) = ${nodeDerivative.toTex()}
43
+ $$
44
+
45
+ Compléter le tableau de valeurs.`;
46
+ };
47
+ const getAnswerTable = (identifiers) => {
48
+ const { arrNodeIdsX, nodeIdsF } = identifiers;
49
+ const arrNodeX = arrNodeIdsX.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
50
+ const nodeF = NodeConstructor.fromIdentifiers(nodeIdsF);
51
+ const nodeDerivative = getPrettyDerivativeNode(nodeF);
52
+ const nodeVarX = "x".toTree();
53
+ const arrNodeValueFunction = arrNodeX.map((nodeX) => nodeBySubstitutingVar(nodeF, nodeX, nodeVarX).simplify());
54
+ const arrNodeValueDerivative = arrNodeX.map((nodeX) => nodeBySubstitutingVar(nodeDerivative, nodeX, nodeVarX).simplify());
55
+ return [
56
+ ["a", ...arrNodeX.map((node) => node.toTex())],
57
+ ["f'(a)", ...arrNodeValueDerivative.map((node) => node.toTex())],
58
+ ["f(a)", ...arrNodeValueFunction.map((node) => node.toTex())],
59
+ ];
60
+ };
61
+ const getHint = () => {
62
+ return `Dans ce tableau de valeurs, la deuxième ligne contient les images, par la fonction $f'$, des valeurs sur la première ligne.
63
+ La troisième ligne contient, quant à elle, les images des valeurs sur la première ligne par la fonction $f$.`;
64
+ };
65
+ const getCorrection = (identifiers) => {
66
+ const { arrNodeIdsX, nodeIdsF } = identifiers;
67
+ const arrNodeX = arrNodeIdsX.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
68
+ const nodeF = NodeConstructor.fromIdentifiers(nodeIdsF);
69
+ const nodeDerivative = getPrettyDerivativeNode(nodeF);
70
+ const nodeVarX = "x".toTree();
71
+ return `
72
+ On calcule :
73
+
74
+ ${arrNodeX.map((nodeX) => {
75
+ const nodeValueFunction = nodeBySubstitutingVar(nodeF, nodeX, nodeVarX);
76
+ const nodeValueDerivative = nodeBySubstitutingVar(nodeDerivative, nodeX, nodeVarX);
77
+ return `${alignTex([
78
+ [`f'(${nodeX.toTex()})`, "=", nodeValueDerivative.toTex()],
79
+ [`f'(${nodeX.toTex()})`, "=", nodeValueDerivative.simplify().toTex()],
80
+ ])}
81
+
82
+ ${alignTex([
83
+ [`f(${nodeX.toTex()})`, "=", nodeValueFunction.toTex()],
84
+ [`f(${nodeX.toTex()})`, "=", nodeValueFunction.simplify().toTex()],
85
+ ])}`;
86
+ }).join(`
87
+
88
+ `)}
89
+
90
+ Le tableau de valeurs complété est donc :
91
+
92
+ ${mdTable(getAnswerTable(identifiers), true)}
93
+
94
+ `;
95
+ };
96
+ const getKeys = () => {
97
+ return [];
98
+ };
99
+ const isAnswerTableValid = (ansTable, { answerTable }) => {
100
+ try {
101
+ for (let i = 0; i < answerTable.length; i++) {
102
+ for (let j = 1; j < ansTable[i].length; j++) {
103
+ const ans = ansTable[i][j];
104
+ const answer = answerTable[i][j];
105
+ const nodeAns = parseAlgebraic(ans);
106
+ const nodeAnswer = parseAlgebraic(answer);
107
+ const valid = substract(nodeAns, nodeAnswer).evaluate() === 0;
108
+ if (!valid)
109
+ return false;
110
+ }
111
+ }
112
+ return true;
113
+ }
114
+ catch (err) {
115
+ return handleVEAError(err);
116
+ }
117
+ };
118
+ const createRandomIdentifiers = () => {
119
+ const nbX = 2;
120
+ const poolX = [...Array(11).keys()].map((i) => i - 5);
121
+ const arrX = randomMany(poolX, nbX);
122
+ const arrNodeX = arrX.map((x) => x.toTree());
123
+ const typeF = random(["affine", "trinom", "k/x", "k/x^2", "(ax+b)/(cx+d)"]);
124
+ const nodeF = (() => {
125
+ switch (typeF) {
126
+ case "affine":
127
+ return AffineConstructor.random().toTree();
128
+ case "trinom":
129
+ return TrinomConstructor.random().toTree();
130
+ case "k/x":
131
+ return frac(randint(-5, 6, [0]), "x".toTree());
132
+ case "k/x^2":
133
+ return frac(randint(-5, 6, [0]), power("x".toTree(), 2));
134
+ case "(ax+b)/(cx+d)": {
135
+ const [nodeNum, nodeDen] = AffineConstructor.differentRandoms(2).map((affine) => affine.toTree());
136
+ return frac(nodeNum, nodeDen);
137
+ }
138
+ default:
139
+ throw new Error("Unsupported typeF: " + typeF);
140
+ }
141
+ })();
142
+ const initTable = [
143
+ ["a", ...arrNodeX.map((node) => node.toTex())],
144
+ ["f'(a)", ...arrNodeX.map(() => "")],
145
+ ["f(a)", ...arrNodeX.map(() => "")],
146
+ ];
147
+ const identifiers = {
148
+ arrNodeIdsX: arrNodeX.map((node) => node.toIdentifiers()),
149
+ nodeIdsF: nodeF.toIdentifiers(),
150
+ initTable,
151
+ };
152
+ return identifiers;
153
+ };
154
+ const getValueTableImageAndDerivativeFromFunctionExpressionQuestion = () => {
155
+ let identifiers;
156
+ let isValid = false;
157
+ let counter = -1;
158
+ while (!isValid && counter < 100) {
159
+ counter++;
160
+ const identifiersCandidate = createRandomIdentifiers();
161
+ const isExploding = (identifiers) => {
162
+ const { arrNodeIdsX, nodeIdsF } = identifiers;
163
+ const arrNodeX = arrNodeIdsX.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
164
+ const nodeF = NodeConstructor.fromIdentifiers(nodeIdsF);
165
+ const nodeDerivative = getPrettyDerivativeNode(nodeF);
166
+ let isExploding = false;
167
+ try {
168
+ arrNodeX.forEach((nodeX) => {
169
+ const _nodeValueFunction = nodeBySubstitutingVar(nodeF, nodeX, "x".toTree()).simplify();
170
+ const _nodeValueDerivative = nodeBySubstitutingVar(nodeDerivative, nodeX, "x".toTree()).simplify();
171
+ });
172
+ }
173
+ catch (_) {
174
+ isExploding = true;
175
+ }
176
+ return isExploding;
177
+ };
178
+ isValid = !isExploding(identifiersCandidate);
179
+ if (isValid) {
180
+ identifiers = identifiersCandidate;
181
+ }
182
+ }
183
+ if (!isValid) {
184
+ const identifiersDefault = {
185
+ arrNodeIdsX: [
186
+ {
187
+ id: 7,
188
+ value: -1,
189
+ },
190
+ {
191
+ id: 7,
192
+ value: 2,
193
+ },
194
+ ],
195
+ nodeIdsF: {
196
+ id: 0,
197
+ leftChild: {
198
+ id: 2,
199
+ leftChild: {
200
+ id: 7,
201
+ value: -5,
202
+ },
203
+ rightChild: {
204
+ id: 5,
205
+ leftChild: {
206
+ id: 10,
207
+ name: "x",
208
+ },
209
+ rightChild: {
210
+ id: 7,
211
+ value: 2,
212
+ },
213
+ },
214
+ },
215
+ rightChild: {
216
+ id: 0,
217
+ leftChild: {
218
+ id: 2,
219
+ leftChild: {
220
+ id: 7,
221
+ value: -9,
222
+ },
223
+ rightChild: {
224
+ id: 10,
225
+ name: "x",
226
+ },
227
+ },
228
+ rightChild: {
229
+ id: 7,
230
+ value: 3,
231
+ },
232
+ },
233
+ },
234
+ initTable: [
235
+ ["a", "-1", "2"],
236
+ ["f'(a)", "", ""],
237
+ ["f(a)", "", ""],
238
+ ],
239
+ };
240
+ identifiers = identifiersDefault;
241
+ }
242
+ return getQuestionFromIdentifiers(identifiers);
243
+ };
244
+ const getQuestionFromIdentifiers = (identifiers) => {
245
+ return {
246
+ answerTable: getAnswerTable(identifiers),
247
+ instruction: getInstruction(identifiers),
248
+ keys: getKeys(identifiers),
249
+ answerFormat: "tex",
250
+ identifiers,
251
+ hint: getHint(identifiers),
252
+ correction: getCorrection(identifiers),
253
+ initTable: identifiers.initTable,
254
+ };
255
+ };
256
+ export const valueTableImageAndDerivativeFromFunctionExpression = {
257
+ id: "valueTableImageAndDerivativeFromFunctionExpression",
258
+ connector: "=",
259
+ label: "Déterminer $f(a)$ et $f'(a)$ avec $f(x)$ et $f'(x)$ donnés",
260
+ isSingleStep: true,
261
+ generator: (nb, opts) => getDistinctQuestions(() => getValueTableImageAndDerivativeFromFunctionExpressionQuestion(opts), nb),
262
+ valueTableTimer: 120,
263
+ subject: "Mathématiques",
264
+ getInstruction,
265
+ getHint,
266
+ getCorrection,
267
+ getAnswerTable,
268
+ getQuestionFromIdentifiers,
269
+ hasHintAndCorrection: true,
270
+ answerType: "valueTable",
271
+ isAnswerTableValid,
272
+ };
@@ -0,0 +1,5 @@
1
+ export * from "./problemMaximizeBoxVolumeFindX.js";
2
+ export * from "./problemProjectileHeightFindAbscissa.js";
3
+ export * from "./problemMaximizeProfitFindProduction.js";
4
+ export * from "./problemMovementOnLineFindSpeedAtPoint.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/problems/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,0CAA0C,CAAC;AACzD,cAAc,0CAA0C,CAAC;AACzD,cAAc,4CAA4C,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./problemMaximizeBoxVolumeFindX.js";
2
+ export * from "./problemProjectileHeightFindAbscissa.js";
3
+ export * from "./problemMaximizeProfitFindProduction.js";
4
+ export * from "./problemMovementOnLineFindSpeedAtPoint.js";
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ a: number;
4
+ b: number;
5
+ };
6
+ export declare const problemMaximizeBoxVolumeFindX: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=problemMaximizeBoxVolumeFindX.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"problemMaximizeBoxVolumeFindX.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/problems/problemMaximizeBoxVolumeFindX.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAgCrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAyKF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAgB/D,CAAC"}
@@ -0,0 +1,171 @@
1
+ import { addValidProp, tryToAddWrongProp, propWhile, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { SetVEA } from "../../../../exercises/vea/setVEA.js";
4
+ import { createNodeFPolynomialFromCoeffs, getAnswerStuffSolveSecondDegreePolynomial, getArrNodeCoeffOfPolynomialNode, getTexSolveSecondDegreeEquation, } from "../../../../math/utils/polynomial/polynomialUtils.js";
5
+ import { round } from "../../../../math/utils/round.js";
6
+ import { EquationSolutionNode } from "../../../../tree/nodes/equations/equationSolutionNode.js";
7
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
8
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
9
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
10
+ import { DiscreteSetNode } from "../../../../tree/nodes/sets/discreteSetNode.js";
11
+ import { discreteSetParser } from "../../../../tree/parsers/discreteSetParser.js";
12
+ import { randomMany } from "../../../../utils/alea/random.js";
13
+ import { shuffle } from "../../../../utils/alea/shuffle.js";
14
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
15
+ const getNodeF = (a, b) => {
16
+ const nodeVarX = "x".toTree();
17
+ return multiply(multiply(substract(a, multiply(2, nodeVarX)), substract(b, multiply(2, nodeVarX))), nodeVarX);
18
+ };
19
+ const getInstruction = (identifiers) => {
20
+ const { a, b } = identifiers;
21
+ return `Dans une feuille rectangulaire de dimensions $${a.frenchify()} \\ \\times \\ ${b.frenchify()}$,
22
+ on découpe dans les coins des carrés de côté $x$ pour former une boîte sans couvercle.
23
+
24
+ Donner toutes les valeurs de $x$ (arrondies à $2$ décimales) pour lesquelles le volume de la boîte est maximal.`;
25
+ };
26
+ const getAnswerStuff = (identifiers) => {
27
+ const { a, b } = identifiers;
28
+ const nodeF = getNodeF(a, b);
29
+ const nodeDerivative = nodeF.derivative();
30
+ return getAnswerStuffSolveSecondDegreePolynomial(nodeDerivative);
31
+ };
32
+ const getAnswerNode = (identifiers) => {
33
+ const { a } = identifiers;
34
+ const { arrNodeX } = getAnswerStuff(identifiers);
35
+ const arrNodeXPossible = arrNodeX.filter((node) => {
36
+ const value = node.evaluate();
37
+ return 0 <= value && value <= a / 2.0;
38
+ });
39
+ const arrNodeXRounded = arrNodeXPossible.map((node) => round(node.evaluate(), 2).toTree());
40
+ return new EquationSolutionNode(new DiscreteSetNode(arrNodeXRounded));
41
+ };
42
+ const getAnswer = (identifiers) => {
43
+ return getAnswerNode(identifiers).toTex();
44
+ };
45
+ const getHint = () => {
46
+ return `Le volume de la boîte peut être calculé avec la formule :
47
+
48
+ ${alignTex([
49
+ [`\\text{Volume}`, "=", `\\ \\ \\text{longueur}`],
50
+ ["", "", `\\times \\ \\text{largeur}`],
51
+ ["", "", `\\times \\ \\text{profondeur}`],
52
+ ])}
53
+
54
+ Ici, la largeur est $a-2x$,
55
+ la longueur est $b-2x$
56
+ et la profondeur est $x$.`;
57
+ };
58
+ const getCorrection = (identifiers) => {
59
+ const { a, b } = identifiers;
60
+ const nodeF = getNodeF(a, b);
61
+ const nodeDerivative = nodeF.derivative();
62
+ const nodeDerivativeExpanded = (() => {
63
+ const arrNodeCoeff = getArrNodeCoeffOfPolynomialNode(nodeDerivative);
64
+ return createNodeFPolynomialFromCoeffs(arrNodeCoeff);
65
+ })();
66
+ const nodeMaxBound = frac(a, 2);
67
+ return `On calcule le volume en fonction de $x$ :
68
+
69
+ $$
70
+ V(x) = ${nodeF.toTex()}
71
+ $$
72
+
73
+ $x$ est compris entre $0$ et $${[
74
+ ...new Set([nodeMaxBound.toTex(), nodeMaxBound.simplify().toTex()]),
75
+ ].join("=")}$.
76
+
77
+ On a :
78
+
79
+ $$
80
+ V(0) = V(${nodeMaxBound.simplify().toTex()}) = 0
81
+ $$
82
+
83
+ et pour $x$ différent de $0$ et de $${nodeMaxBound.simplify().toTex()}$ :
84
+
85
+ $$
86
+ V(x)>0
87
+ $$
88
+
89
+ On cherche à maximiser $V$.
90
+ $V$ est continue et dérivable. On calcule :
91
+
92
+ ${alignTex([
93
+ [`V'(x)`, "=", nodeDerivative.toTex()],
94
+ [``, "=", nodeDerivativeExpanded.toTex()],
95
+ ])}
96
+
97
+ On résout $V'(x)=0$ :
98
+
99
+ ${getTexSolveSecondDegreeEquation(nodeDerivativeExpanded)}
100
+
101
+ On ne garde que les valeurs de $x$ qui sont possibles (c'est-à-dire entre $0$ et $${nodeMaxBound
102
+ .simplify()
103
+ .toTex()}$) :
104
+
105
+ $$
106
+ ${getAnswer(identifiers)}
107
+ $$
108
+
109
+ `;
110
+ };
111
+ const getPropositions = (n, { answer }) => {
112
+ const propositions = [];
113
+ addValidProp(propositions, answer);
114
+ propWhile(propositions, n, () => {
115
+ const identifierWrong = createRandomIdentifiers();
116
+ tryToAddWrongProp(propositions, getAnswer(identifierWrong));
117
+ });
118
+ return shuffle(propositions);
119
+ };
120
+ const getKeys = () => {
121
+ return [];
122
+ };
123
+ const isAnswerValid = (ans, { answer, ...identifiers }, _optsIn) => {
124
+ const answerNode = getAnswerNode(identifiers);
125
+ const arrNodeAnswer = answerNode.solutionsSet.elements;
126
+ const parsed = discreteSetParser(ans);
127
+ if (!parsed) {
128
+ return false;
129
+ }
130
+ const arrAns = parsed.elements;
131
+ return SetVEA.isArrayOfNodesValid(arrAns, arrNodeAnswer);
132
+ };
133
+ const createRandomIdentifiers = () => {
134
+ const pool = [...Array(30).keys()].map((i) => i + 1);
135
+ const [a, b] = randomMany(pool, 2).toSorted((v1, v2) => v1 - v2);
136
+ const identifiers = {
137
+ a,
138
+ b,
139
+ };
140
+ return identifiers;
141
+ };
142
+ const getProblemMaximizeBoxVolumeFindXQuestion = () => {
143
+ const identifiers = createRandomIdentifiers();
144
+ return getQuestionFromIdentifiers(identifiers);
145
+ };
146
+ const getQuestionFromIdentifiers = (identifiers) => {
147
+ return {
148
+ answer: getAnswer(identifiers),
149
+ instruction: getInstruction(identifiers),
150
+ keys: getKeys(identifiers),
151
+ answerFormat: "tex",
152
+ identifiers,
153
+ hint: getHint(identifiers),
154
+ correction: getCorrection(identifiers),
155
+ };
156
+ };
157
+ export const problemMaximizeBoxVolumeFindX = {
158
+ id: "problemMaximizeBoxVolumeFindX",
159
+ connector: "=",
160
+ label: "Problème d'optimisation géométrique : Trouver $x$ pour maximiser le volume d'une boîte",
161
+ isSingleStep: true,
162
+ generator: (nb) => getDistinctQuestions(() => getProblemMaximizeBoxVolumeFindXQuestion(), nb),
163
+ subject: "Mathématiques",
164
+ getInstruction,
165
+ getHint,
166
+ getCorrection,
167
+ isAnswerValid,
168
+ getPropositions,
169
+ getQuestionFromIdentifiers,
170
+ hasHintAndCorrection: true,
171
+ };
@@ -0,0 +1,15 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { PointOfFunctionIdentifiers } from "../../../../math/utils/polynomial/polynomialInterpolationUtils.js";
3
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
4
+ type Identifiers = {
5
+ nodeIdsF: NodeIdentifiers;
6
+ pofIds: PointOfFunctionIdentifiers[];
7
+ boundPHigh: number;
8
+ typeF: string;
9
+ };
10
+ type Options = {
11
+ typeF: string;
12
+ };
13
+ export declare const problemMaximizeProfitFindProduction: Exercise<Identifiers, Options>;
14
+ export {};
15
+ //# sourceMappingURL=problemMaximizeProfitFindProduction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"problemMaximizeProfitFindProduction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAIL,0BAA0B,EAC3B,MAAM,6DAA6D,CAAC;AAYrE,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAQ7C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,MAAM,EAAE,0BAA0B,EAAE,CAAC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAwYF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAsBF,eAAO,MAAM,mCAAmC,EAAE,QAAQ,CACxD,WAAW,EACX,OAAO,CAoBR,CAAC"}