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,547 @@
1
+ import { addValidProp, tryToAddWrongProp, propWhile, GeneratorOptionTarget, GeneratorOptionType, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randint } from "../../../../math/utils/random/randint.js";
4
+ import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
5
+ import { frac, isFractionNode, } from "../../../../tree/nodes/operators/fractionNode.js";
6
+ import { random } from "../../../../utils/alea/random.js";
7
+ import { shuffle } from "../../../../utils/alea/shuffle.js";
8
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
9
+ import { createNodeFPolynomialFromCoeffs, getAnswerStuffSolveSecondDegreePolynomial, getTexSolveSecondDegreeEquation, } from "../../../../math/utils/polynomial/polynomialUtils.js";
10
+ import { EquationSolutionNode } from "../../../../tree/nodes/equations/equationSolutionNode.js";
11
+ import { DiscreteSetNode } from "../../../../tree/nodes/sets/discreteSetNode.js";
12
+ import { discreteSetParser } from "../../../../tree/parsers/discreteSetParser.js";
13
+ import { SetVEA } from "../../../../exercises/vea/setVEA.js";
14
+ import { dividersOf } from "../../../../math/utils/arithmetic/dividersOf.js";
15
+ import { probaFlip } from "../../../../utils/alea/probaFlip.js";
16
+ import { nodeBySubstitutingVar } from "../../../../math/utils/functions/functionComposition.js";
17
+ import { NodeUtils } from "../../../../tree/utilities/nodeUtils.js";
18
+ const tryToSimplify = (node, simplifyOptions) => {
19
+ try {
20
+ return node.simplify(simplifyOptions);
21
+ }
22
+ catch (_) {
23
+ return node;
24
+ }
25
+ };
26
+ const getNodeFForTypeF = (typeF, typeRoots) => {
27
+ const isIntegerRoots = typeRoots === "entières";
28
+ switch (typeF) {
29
+ case "polynôme (degré $2$)": {
30
+ //f(x)=ax^2+bx+c
31
+ //f'(x)=2ax+b
32
+ //f'(x)=0 <=> x = -b/2a
33
+ if (isIntegerRoots) {
34
+ function getNiceBA() {
35
+ const a = randint(-10, 11, [0]);
36
+ const x = randint(-10, 11, [0]);
37
+ const b = x * (2 * a);
38
+ return [b, a];
39
+ }
40
+ const [b, a] = getNiceBA();
41
+ const [nodeB, nodeA] = [b, a].map((v) => v.toTree());
42
+ const nodeC = randint(-10, 11, [0]).toTree();
43
+ const nodeF = createNodeFPolynomialFromCoeffs([nodeC, nodeB, nodeA]);
44
+ return nodeF;
45
+ }
46
+ else {
47
+ const nodeA = randint(-10, 11, [0]).toTree();
48
+ const nodeB = randint(-10, 11, [0]).toTree();
49
+ const nodeC = randint(-10, 11, [0]).toTree();
50
+ const nodeF = createNodeFPolynomialFromCoeffs([nodeC, nodeB, nodeA]);
51
+ return nodeF;
52
+ }
53
+ }
54
+ case "polynôme (degré $3$)": {
55
+ //3ax^2+2bx+c=0
56
+ //delta = (2b)²-4(3a)(c) = 4b^2 - 12ac = 4(b^2 - 3ac)
57
+ //=> smooth if (b^2 - 3ac) = n^2
58
+ // (b^2 - n^2) % 3 = 0
59
+ function getNiceCBA() {
60
+ let [c, b, a] = [];
61
+ let isValid = false;
62
+ let counter = -1;
63
+ while (!isValid && counter < 1000) {
64
+ counter++;
65
+ b = randint(10, 100);
66
+ const n = probaFlip(0.95) ? randint(1, b) : 0;
67
+ const b2Minusn2 = b * b - n * n;
68
+ isValid = b2Minusn2 % 3 === 0;
69
+ if (isValid) {
70
+ const ac = b2Minusn2 / 3;
71
+ const arrDivisors = dividersOf(ac);
72
+ a = random(arrDivisors);
73
+ c = ac / a;
74
+ //delta = 4n^2 => sqrt(delta) = 2n
75
+ const x1 = (-(2 * b) - 2 * n) / (2 * (3 * a));
76
+ const x2 = (-(2 * b) + 2 * n) / (2 * (3 * a));
77
+ if (isIntegerRoots) {
78
+ isValid = Number.isInteger(x1) && Number.isInteger(x2);
79
+ }
80
+ }
81
+ }
82
+ if (!isValid) {
83
+ [c, b, a] = [1, 3, 3];
84
+ }
85
+ return [c, b, a];
86
+ }
87
+ const [c, b, a] = getNiceCBA();
88
+ const [nodeC, nodeB, nodeA] = [c, b, a].map((v) => v.toTree());
89
+ const nodeD = randint(-10, 10, [0]).toTree();
90
+ const nodeF = createNodeFPolynomialFromCoeffs([
91
+ nodeD,
92
+ nodeC,
93
+ nodeB,
94
+ nodeA,
95
+ ]);
96
+ return nodeF;
97
+ }
98
+ case "$\\frac{ax^2+bx+c}{dx+m}$": {
99
+ //f(x)=(ax^2+bx+c)/(dx+m)
100
+ //f'(x) = ((2ax+b)(dx+m)-(ax^2+bx+c)d)/((dx+m)^2)
101
+ //f'(x) = 0 <=>
102
+ //(2ad)x^2+(2am+bd)x+(bm)-(ad)x^2-(bd)x -(cd) = 0
103
+ //(ad)x^2+(2am)x+(bm-cd)=0
104
+ //delta = (2am)^2 - 4(ad)(bm-cd)
105
+ //=> smooth if bm-cd = 0
106
+ function getNiceMDCBA() {
107
+ let [m, d, c, b, a] = [];
108
+ let isValid = false;
109
+ let counter = -1;
110
+ while (!isValid && counter < 1000) {
111
+ counter++;
112
+ b = randint(1, 30);
113
+ m = randint(1, 30);
114
+ const bm = b * m;
115
+ const arrDivisors = dividersOf(bm);
116
+ c = random(arrDivisors);
117
+ d = bm / c;
118
+ if (isIntegerRoots) {
119
+ isValid = Number.isInteger(m / d);
120
+ }
121
+ else {
122
+ isValid = true;
123
+ }
124
+ a = randint(-10, 11, [0]);
125
+ return [m, d, c, b, a];
126
+ }
127
+ if (!isValid) {
128
+ [m, d, c, b, a] = [19, 19, 2, 2, -8];
129
+ }
130
+ return [m, d, c, b, a];
131
+ }
132
+ const nodeF = (() => {
133
+ let nodeF;
134
+ let isValid = false;
135
+ let counter = -1;
136
+ while (!isValid && counter < 1000) {
137
+ counter++;
138
+ const [m, d, c, b, a] = getNiceMDCBA();
139
+ const [nodeM, nodeD, nodeC, nodeB, nodeA] = [m, d, c, b, a].map((v) => v.toTree());
140
+ const nodeG = createNodeFPolynomialFromCoeffs([nodeC, nodeB, nodeA]);
141
+ const nodeH = createNodeFPolynomialFromCoeffs([nodeM, nodeD]);
142
+ const { arrNodeX: arrNodeRootH } = getAnswerStuffSolveSecondDegreePolynomial(nodeH);
143
+ isValid = arrNodeRootH.every((node) => Number.isInteger(node.evaluate()));
144
+ nodeF = frac(nodeG, nodeH);
145
+ }
146
+ if (!isValid) {
147
+ const [m, d, c, b, a] = [19, 19, 2, 2, -8];
148
+ const [nodeM, nodeD, nodeC, nodeB, nodeA] = [m, d, c, b, a].map((v) => v.toTree());
149
+ const nodeG = createNodeFPolynomialFromCoeffs([nodeC, nodeB, nodeA]);
150
+ const nodeH = createNodeFPolynomialFromCoeffs([nodeM, nodeD]);
151
+ nodeF = frac(nodeG, nodeH);
152
+ }
153
+ return nodeF;
154
+ })();
155
+ return nodeF;
156
+ }
157
+ case "$\\frac{dx+m}{ax^2+bx+c}$": {
158
+ //f(x)=(ax^2+bx+c)/(dx+m)
159
+ //f'(x) = ((2ax+b)(dx+m)-(ax^2+bx+c)d)/((dx+m)^2)
160
+ //f'(x) = 0 <=>
161
+ //(2ad)x^2+(2am+bd)x+(bm)-(ad)x^2-(bd)x -(cd) = 0
162
+ //(ad)x^2+(2am)x+(bm-cd)=0
163
+ //delta = (2am)^2 - 4(ad)(bm-cd)
164
+ //=> smooth if bm-cd = 0
165
+ function getNiceMDCBA() {
166
+ let [m, d, c, b, a] = [];
167
+ let isValid = false;
168
+ let counter = -1;
169
+ while (!isValid && counter < 1000) {
170
+ counter++;
171
+ b = randint(1, 30);
172
+ m = randint(1, 30);
173
+ const bm = b * m;
174
+ const arrDivisors = dividersOf(bm);
175
+ c = random(arrDivisors);
176
+ d = bm / c;
177
+ if (isIntegerRoots) {
178
+ isValid = Number.isInteger(m / d);
179
+ }
180
+ else {
181
+ isValid = true;
182
+ }
183
+ a = randint(-10, 11, [0]);
184
+ return [m, d, c, b, a];
185
+ }
186
+ if (!isValid) {
187
+ [m, d, c, b, a] = [19, 19, 2, 2, -8];
188
+ }
189
+ return [m, d, c, b, a];
190
+ }
191
+ const nodeF = (() => {
192
+ let nodeF;
193
+ let isValid = false;
194
+ let counter = -1;
195
+ while (!isValid && counter < 1000) {
196
+ counter++;
197
+ const [m, d, c, b, a] = getNiceMDCBA();
198
+ const [nodeM, nodeD, nodeC, nodeB, nodeA] = [m, d, c, b, a].map((v) => v.toTree());
199
+ const nodeG = createNodeFPolynomialFromCoeffs([nodeC, nodeB, nodeA]);
200
+ const nodeH = createNodeFPolynomialFromCoeffs([nodeM, nodeD]);
201
+ const { arrNodeX: arrNodeRootH } = getAnswerStuffSolveSecondDegreePolynomial(nodeG);
202
+ isValid = arrNodeRootH.every((node) => Number.isInteger(node.evaluate()));
203
+ nodeF = frac(nodeH, nodeG);
204
+ }
205
+ if (!isValid) {
206
+ const [m, d, c, b, a] = [19, 19, 2, 2, -8];
207
+ const [nodeM, nodeD, nodeC, nodeB, nodeA] = [m, d, c, b, a].map((v) => v.toTree());
208
+ const nodeG = createNodeFPolynomialFromCoeffs([nodeC, nodeB, nodeA]);
209
+ const nodeH = createNodeFPolynomialFromCoeffs([nodeM, nodeD]);
210
+ nodeF = frac(nodeH, nodeG);
211
+ }
212
+ return nodeF;
213
+ })();
214
+ return nodeF;
215
+ }
216
+ default:
217
+ throw new Error("Unsupported typeF: " + typeF);
218
+ }
219
+ };
220
+ const getPrettyNode = (node) => {
221
+ if (isFractionNode(node)) {
222
+ const nodeNumSimplified = tryToSimplify(node.leftChild, {
223
+ towardsDistribute: true,
224
+ forbidFactorize: true,
225
+ });
226
+ const nodeDenSimplified = node.rightChild.simplify();
227
+ return frac(nodeNumSimplified, nodeDenSimplified);
228
+ }
229
+ else {
230
+ return node;
231
+ }
232
+ };
233
+ const getInstruction = (identifiers) => {
234
+ const { nodeIdsF } = identifiers;
235
+ const [nodeF] = [nodeIdsF].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
236
+ const nodeFPretty = getPrettyNode(nodeF);
237
+ const arrNodeXForbidden = (() => {
238
+ if (isFractionNode(nodeF)) {
239
+ const nodeDenum = nodeF.rightChild;
240
+ const { arrNodeX } = getAnswerStuffSolveSecondDegreePolynomial(nodeDenum);
241
+ return arrNodeX;
242
+ }
243
+ else {
244
+ return [];
245
+ }
246
+ })();
247
+ return `Soit $f$ une fonction telle que, pour tout $x$ réel${(() => {
248
+ if (arrNodeXForbidden.length > 0) {
249
+ return `, différent de ${arrNodeXForbidden
250
+ .map((node) => `$${node.toTex()}$`)
251
+ .join(" et de ")}`;
252
+ }
253
+ else {
254
+ return "";
255
+ }
256
+ })()} :
257
+
258
+ $$
259
+ f(x) = ${nodeFPretty.toTex()}
260
+ $$
261
+
262
+ Déterminer les extremums locaux de $f$.`;
263
+ };
264
+ const getAnswerStuff = (identifiers) => {
265
+ const { nodeIdsF } = identifiers;
266
+ const nodeF = NodeConstructor.fromIdentifiers(nodeIdsF);
267
+ const nodeFPretty = getPrettyNode(nodeF);
268
+ const nodeDerivativeRaw = nodeFPretty.derivative().simplify();
269
+ const nodeDerivativePretty = getPrettyNode(nodeDerivativeRaw);
270
+ const nodePolynomial = (() => {
271
+ if (isFractionNode(nodeDerivativePretty)) {
272
+ return nodeDerivativePretty.leftChild;
273
+ }
274
+ else {
275
+ return nodeDerivativePretty;
276
+ }
277
+ })();
278
+ return getAnswerStuffSolveSecondDegreePolynomial(nodePolynomial);
279
+ };
280
+ const getAnswerNode = (identifiers) => {
281
+ const { nodeIdsF } = identifiers;
282
+ const nodeF = NodeConstructor.fromIdentifiers(nodeIdsF);
283
+ const nodeFPretty = getPrettyNode(nodeF);
284
+ const { arrNodeX } = getAnswerStuff(identifiers);
285
+ const arrNodeValueFunction = arrNodeX.map((nodeX) => nodeBySubstitutingVar(nodeFPretty, nodeX, "x".toTree()).simplify());
286
+ return new EquationSolutionNode(new DiscreteSetNode(arrNodeValueFunction));
287
+ };
288
+ const getAnswer = (identifiers) => {
289
+ return getAnswerNode(identifiers).toTex();
290
+ };
291
+ const getHint = (identifiers) => {
292
+ const { typeF } = identifiers;
293
+ const strHintDerivative = (() => {
294
+ switch (typeF) {
295
+ case "polynôme (degré $2$)":
296
+ 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$.`;
297
+ case "polynôme (degré $3$)":
298
+ 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$.`;
299
+ case "$\\frac{ax^2+bx+c}{dx+m}$":
300
+ return `Soient $a$, $b$, $c$, $d$ et $m$ cinq réels. La dérivée de $x \\mapsto \\frac{ax^2+bx+c}{dx+m}$ est $x \\mapsto \\frac{(2ax+b)(dx+m)-(ax^2+bx+c)d}{(dx+m)^2}$.`;
301
+ case "$\\frac{dx+m}{ax^2+bx+c}$":
302
+ return `Soient $a$, $b$, $c$, $d$ et $m$ cinq réels. La dérivée de $x \\mapsto \\frac{dx+m}{ax^2+bx+c}$ est $x \\mapsto \\frac{d(ax^2+bx+c)-(dx+m)(2ax+b)}{(ax^2+bx+c)^2}$.`;
303
+ default:
304
+ throw new Error("Unsupported typeF: " + typeF);
305
+ }
306
+ })();
307
+ return `${strHintDerivative}
308
+
309
+ Les extremums sont les images $f(x)$ des abscisses $x$ pour lesquelles $f'(x)=0$.
310
+ `;
311
+ };
312
+ const getCorrection = (identifiers) => {
313
+ const { nodeIdsF } = identifiers;
314
+ const [nodeF] = [nodeIdsF].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
315
+ const nodeFPretty = getPrettyNode(nodeF);
316
+ const nodeDerivativeRaw = nodeFPretty.derivative().simplify();
317
+ const nodeDerivativePretty = getPrettyNode(nodeDerivativeRaw);
318
+ const nodePolynomial = (() => {
319
+ if (isFractionNode(nodeDerivativePretty)) {
320
+ return nodeDerivativePretty.leftChild;
321
+ }
322
+ else {
323
+ return nodeDerivativePretty;
324
+ }
325
+ })();
326
+ const { arrNodeX } = getAnswerStuff(identifiers);
327
+ return `Les abscisses recherchées sont les abscisses $a$ telles que $f'(a)=0$.
328
+
329
+ Pour $x$ appartenant à l'ensemble de dérivation de $f$, on calcule :
330
+
331
+ ${alignTex([
332
+ ...[
333
+ ...new Set([
334
+ tryToSimplify(nodeFPretty.derivative(), {}).toTex(),
335
+ nodeDerivativePretty.toTex(),
336
+ ]),
337
+ ].map((tex) => [`f'(x)`, "=", tex]),
338
+ ])}
339
+
340
+ On résout $f'(x)=0$ :
341
+
342
+ ${getTexSolveSecondDegreeEquation(nodePolynomial)}
343
+
344
+ Les extremums sont donc :
345
+
346
+ ${alignTex([
347
+ ...arrNodeX.flatMap((nodeX) => {
348
+ const nodeExtremum = nodeBySubstitutingVar(nodeFPretty, nodeX, "x".toTree());
349
+ return [
350
+ [`f(${nodeX.toTex()})`, "=", nodeExtremum.toTex()],
351
+ [``, "=", nodeExtremum.simplify().toTex()],
352
+ ];
353
+ }),
354
+ ])}
355
+
356
+ `;
357
+ };
358
+ const getPropositions = (n, { answer, ...identifiers }) => {
359
+ const { typeF, typeRoots } = identifiers;
360
+ const propositions = [];
361
+ addValidProp(propositions, answer);
362
+ propWhile(propositions, n, () => {
363
+ const identifierWrong = createRandomIdentifiers(typeF, typeRoots);
364
+ if (isIdentifiersQCPassed(identifierWrong)) {
365
+ tryToAddWrongProp(propositions, getAnswer(identifierWrong));
366
+ }
367
+ });
368
+ return shuffle(propositions);
369
+ };
370
+ const getKeys = () => {
371
+ return ["S", "equal", "varnothing", "lbrace", "semicolon", "rbrace"];
372
+ };
373
+ const isAnswerValid = (ans, { answer, ...identifiers }, _optsIn) => {
374
+ const answerNode = getAnswerNode(identifiers);
375
+ const arrNodeAnswer = answerNode.solutionsSet.elements;
376
+ const parsed = discreteSetParser(ans);
377
+ if (!parsed) {
378
+ return false;
379
+ }
380
+ const arrAns = parsed.elements;
381
+ return SetVEA.isArrayOfNodesValid(arrAns, arrNodeAnswer);
382
+ };
383
+ const createRandomIdentifiers = (typeF, typeRoots) => {
384
+ const nodeF = getNodeFForTypeF(typeF, typeRoots);
385
+ const identifiers = {
386
+ nodeIdsF: nodeF.toIdentifiers(),
387
+ typeF,
388
+ typeRoots,
389
+ };
390
+ return identifiers;
391
+ };
392
+ const isIdentifiersQCPassed = (identifiers) => {
393
+ const isSolutionPrettyAndNotExploding = (identifiers) => {
394
+ try {
395
+ const arrNode = getAnswerNode(identifiers).solutionsSet.elements;
396
+ return arrNode.every((node) => NodeUtils.getDepth(node) < 2);
397
+ }
398
+ catch (_) {
399
+ return false;
400
+ }
401
+ };
402
+ return isSolutionPrettyAndNotExploding(identifiers);
403
+ };
404
+ const getFindExtremaFromFunctionExpressionQuestion = (optsIn) => {
405
+ const arrayedOptions = optsIn ?? arrayedOptsDefault;
406
+ const typeF = random(arrayedOptions.typeF);
407
+ const typeRoots = random(arrayedOptions.typeRoots);
408
+ let identifiers;
409
+ let isValid = false;
410
+ let counter = -1;
411
+ while (!isValid && counter < 100) {
412
+ counter++;
413
+ const identifiersCandidate = createRandomIdentifiers(typeF, typeRoots);
414
+ isValid = isIdentifiersQCPassed(identifiersCandidate);
415
+ if (isValid) {
416
+ identifiers = identifiersCandidate;
417
+ }
418
+ }
419
+ if (!isValid) {
420
+ // console.log("will use identifiersDefault");
421
+ const identifiersDefault = {
422
+ nodeIdsF: {
423
+ id: 3,
424
+ leftChild: {
425
+ id: 0,
426
+ leftChild: {
427
+ id: 2,
428
+ leftChild: {
429
+ id: 7,
430
+ value: 30,
431
+ },
432
+ rightChild: {
433
+ id: 10,
434
+ name: "x",
435
+ },
436
+ },
437
+ rightChild: {
438
+ id: 7,
439
+ value: 10,
440
+ },
441
+ },
442
+ rightChild: {
443
+ id: 0,
444
+ leftChild: {
445
+ id: 0,
446
+ leftChild: {
447
+ id: 2,
448
+ leftChild: {
449
+ id: 7,
450
+ value: 6,
451
+ },
452
+ rightChild: {
453
+ id: 5,
454
+ leftChild: {
455
+ id: 10,
456
+ name: "x",
457
+ },
458
+ rightChild: {
459
+ id: 7,
460
+ value: 2,
461
+ },
462
+ },
463
+ },
464
+ rightChild: {
465
+ id: 2,
466
+ leftChild: {
467
+ id: 7,
468
+ value: 3,
469
+ },
470
+ rightChild: {
471
+ id: 10,
472
+ name: "x",
473
+ },
474
+ },
475
+ },
476
+ rightChild: {
477
+ id: 7,
478
+ value: 1,
479
+ },
480
+ },
481
+ },
482
+ typeF: "$\\frac{dx+m}{ax^2+bx+c}$",
483
+ typeRoots: "entières",
484
+ };
485
+ identifiers = identifiersDefault;
486
+ }
487
+ return getQuestionFromIdentifiers(identifiers);
488
+ };
489
+ const getQuestionFromIdentifiers = (identifiers) => {
490
+ return {
491
+ answer: getAnswer(identifiers),
492
+ instruction: getInstruction(identifiers),
493
+ keys: getKeys(identifiers),
494
+ answerFormat: "tex",
495
+ identifiers,
496
+ hint: getHint(identifiers),
497
+ correction: getCorrection(identifiers),
498
+ };
499
+ };
500
+ const arrayedOptsDefault = {
501
+ typeF: [
502
+ "polynôme (degré $2$)",
503
+ "polynôme (degré $3$)",
504
+ "$\\frac{ax^2+bx+c}{dx+m}$",
505
+ "$\\frac{dx+m}{ax^2+bx+c}$",
506
+ ],
507
+ typeRoots: ["entières", "rationnelles"],
508
+ };
509
+ const options = [
510
+ {
511
+ id: "typeF",
512
+ label: "Type de fonction",
513
+ target: GeneratorOptionTarget.generation,
514
+ type: GeneratorOptionType.multiselect,
515
+ values: [
516
+ "polynôme (degré $2$)",
517
+ "polynôme (degré $3$)",
518
+ "$\\frac{ax^2+bx+c}{dx+m}$",
519
+ "$\\frac{dx+m}{ax^2+bx+c}$",
520
+ ],
521
+ defaultValue: arrayedOptsDefault.typeF,
522
+ },
523
+ {
524
+ id: "typeRoots",
525
+ label: "Type d'abscisses",
526
+ target: GeneratorOptionTarget.generation,
527
+ type: GeneratorOptionType.multiselect,
528
+ values: ["entières", "rationnelles"],
529
+ defaultValue: arrayedOptsDefault.typeRoots,
530
+ },
531
+ ];
532
+ export const findExtremaFromFunctionExpression = {
533
+ id: "findExtremaFromFunctionExpression",
534
+ connector: "=",
535
+ label: "Déterminer les abscisses des extremums locaux à partir de l'expression d'une fonction",
536
+ isSingleStep: true,
537
+ generator: (nb, opts) => getDistinctQuestions(() => getFindExtremaFromFunctionExpressionQuestion(opts), nb),
538
+ options,
539
+ subject: "Mathématiques",
540
+ getInstruction,
541
+ getHint,
542
+ getCorrection,
543
+ isAnswerValid,
544
+ getPropositions,
545
+ getQuestionFromIdentifiers,
546
+ hasHintAndCorrection: true,
547
+ };
@@ -0,0 +1,15 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { PointIdentifiers } from "../../../../math/geometry/point.js";
3
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
4
+ type Identifiers = {
5
+ nodeIdsF: NodeIdentifiers;
6
+ pointIds: PointIdentifiers[];
7
+ nodeIdsAbscissa: NodeIdentifiers[];
8
+ typeF: string;
9
+ };
10
+ type Options = {
11
+ typeF: string;
12
+ };
13
+ export declare const plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial: Exercise<Identifiers, Options>;
14
+ export {};
15
+ //# sourceMappingURL=plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/variations/plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAQtC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AA6J7C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,eAAe,EAAE,eAAe,EAAE,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAubF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAoCF,eAAO,MAAM,iEAAiE,EAAE,QAAQ,CACtF,WAAW,EACX,OAAO,CAuBR,CAAC"}