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,346 @@
1
+ import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { AffineConstructor } from "../../../../../math/polynomials/affine.js";
4
+ import { TrinomConstructor } from "../../../../../math/polynomials/trinom.js";
5
+ import { randint } from "../../../../../math/utils/random/randint.js";
6
+ import { exp, ExpNode } from "../../../../../tree/nodes/functions/expNode.js";
7
+ import { add, AddNode } from "../../../../../tree/nodes/operators/addNode.js";
8
+ import { isMultiplyNode, multiply, MultiplyNode, } from "../../../../../tree/nodes/operators/multiplyNode.js";
9
+ import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
10
+ import { parseAlgebraic } from "../../../../../tree/parsers/latexParser.js";
11
+ const simplifyMore = (node) => {
12
+ if (isMultiplyNode(node)) {
13
+ const nodeLeft = node.leftChild;
14
+ const nodeRight = node.rightChild;
15
+ try {
16
+ return multiply(nodeLeft.simplify({ forbidFactorize: true, towardsDistribute: true }), nodeRight.simplify({ forbidFactorize: true, towardsDistribute: true }));
17
+ }
18
+ catch (_) {
19
+ return node;
20
+ }
21
+ }
22
+ else {
23
+ return node;
24
+ }
25
+ };
26
+ const getInstructionNode = (a, b, c, d, e) => {
27
+ const nodeF = (() => {
28
+ if (a !== undefined) {
29
+ return TrinomConstructor.fromCoeffs([c, b, a]).toTree().simplify();
30
+ }
31
+ else if (b !== undefined) {
32
+ return AffineConstructor.fromCoeffs([c, b]).toTree().simplify();
33
+ }
34
+ else {
35
+ return c.toTree();
36
+ }
37
+ })();
38
+ const nodeG = (() => {
39
+ if (d !== undefined) {
40
+ return AffineConstructor.fromCoeffs([e, d]).toTree().simplify();
41
+ }
42
+ else {
43
+ return e.toTree();
44
+ }
45
+ })();
46
+ const nodeExpG = exp(nodeG);
47
+ return multiply(nodeF, nodeExpG);
48
+ };
49
+ const getInstruction = (identifiers) => {
50
+ const { coeffsF, coeffsG } = identifiers;
51
+ const [c, b, a] = coeffsF;
52
+ const [e, d] = coeffsG;
53
+ const nodeH = getInstructionNode(a, b, c, d, e);
54
+ return `Déterminer la dérivée de la fonction $h$ définie par :
55
+
56
+ $$
57
+ h(x) = ${nodeH.toTex()}
58
+ $$`;
59
+ };
60
+ const getAnswerNode = (identifiers) => {
61
+ const { coeffsF, coeffsG } = identifiers;
62
+ const [c, b, a] = coeffsF;
63
+ const [e, d] = coeffsG;
64
+ const nodeDerivative = getInstructionNode(a, b, c, d, e).derivative();
65
+ return nodeDerivative;
66
+ };
67
+ const getAnswer = (identifiers) => {
68
+ return simplifyMore(getAnswerNode(identifiers).simplify()).toTex();
69
+ };
70
+ const getHint = (_identifiers, optsIn) => {
71
+ const opts = optsIn ?? optsDefault;
72
+ const { typeExpG } = opts;
73
+ return `Si $u$ et $v$ sont deux fonctions dérivables alors, pour $x$ qui convient, on a :
74
+
75
+ $$
76
+ (uv)'(x) = u'(x)v(x)+u(x)v'(x)
77
+ $$
78
+
79
+ $$
80
+ ${(() => {
81
+ switch (typeExpG) {
82
+ case "exp(x)":
83
+ return `\\exp'(x) = \\exp(x)`;
84
+ case "exp(ax+b)":
85
+ return `(y \\mapsto \\exp(ay+b))'(x) = a \\times \\exp(ax+b)`;
86
+ default:
87
+ throw new Error("Unsupported typeExpG: " + typeExpG);
88
+ }
89
+ })()}
90
+ $$
91
+
92
+ `;
93
+ };
94
+ const getCorrection = (identifiers) => {
95
+ const { coeffsF, coeffsG } = identifiers;
96
+ const [c, b, a] = coeffsF;
97
+ const [e, d] = coeffsG;
98
+ const nodeInstruction = getInstructionNode(a, b, c, d, e);
99
+ const [nodeU, nodeV] = [
100
+ nodeInstruction.leftChild,
101
+ nodeInstruction.rightChild,
102
+ ];
103
+ const [nodeUPrime, nodeVPrime] = [nodeU, nodeV].map((node) => node.derivative().simplify());
104
+ return `On doit calculer la dérivée d'un produit.
105
+
106
+ Ici, on a :
107
+
108
+ $$
109
+ u(x) = ${nodeU.toTex()}
110
+ $$
111
+
112
+ $$
113
+ v(x) = ${nodeV.toTex()}
114
+ $$
115
+
116
+ On calcule :
117
+
118
+ $$
119
+ u'(x) = ${nodeUPrime.toTex()}
120
+ $$
121
+
122
+ $$
123
+ v'(x) = ${nodeVPrime.toTex()}
124
+ $$
125
+
126
+ Donc :
127
+
128
+ $$
129
+ (uv)'(x) = ${add(multiply(nodeUPrime, nodeV), multiply(nodeU, nodeVPrime)).toTex()}
130
+ $$
131
+
132
+ $$
133
+ h'(x) = ${getAnswer(identifiers)}
134
+ $$
135
+
136
+ `;
137
+ };
138
+ const getPropositions = (n, { answer, ...identifiers }) => {
139
+ const propositions = [];
140
+ addValidProp(propositions, answer);
141
+ const { coeffsF, coeffsG } = identifiers;
142
+ const [c, b, a] = coeffsF;
143
+ const [e, d] = coeffsG;
144
+ const nodeInstruction = getInstructionNode(a, b, c, d, e);
145
+ const [nodeU, nodeV] = [
146
+ nodeInstruction.leftChild,
147
+ nodeInstruction.rightChild,
148
+ ];
149
+ const [nodeUPrime, nodeVPrime] = [nodeU, nodeV].map((node) => node.derivative().simplify());
150
+ //student: no derivation
151
+ {
152
+ tryToAddWrongProp(propositions, nodeInstruction.simplify().toTex());
153
+ }
154
+ //student: u'v'
155
+ {
156
+ tryToAddWrongProp(propositions, simplifyMore(multiply(nodeUPrime, nodeVPrime).simplify()).toTex());
157
+ }
158
+ //student: u'v
159
+ {
160
+ tryToAddWrongProp(propositions, simplifyMore(multiply(nodeUPrime, nodeV).simplify()).toTex());
161
+ }
162
+ //student: u'v + uv
163
+ {
164
+ tryToAddWrongProp(propositions, simplifyMore(add(multiply(nodeUPrime, nodeV).simplify(), multiply(nodeU, nodeV).simplify()).simplify()).toTex());
165
+ }
166
+ //student: exp(x)' = x.exp(x)
167
+ {
168
+ class MyAddNode extends AddNode {
169
+ simplify(opts, log) {
170
+ if (this.leftChild.evaluate() === 0 ||
171
+ this.rightChild.evaluate() === 0) {
172
+ return (0).toTree();
173
+ }
174
+ else {
175
+ return super.simplify(opts, log);
176
+ }
177
+ }
178
+ }
179
+ class MyMultiplyNode extends MultiplyNode {
180
+ derivative(varName) {
181
+ return new MyAddNode(new MyMultiplyNode(this.leftChild.derivative(varName).simplify(), this.rightChild), new MyMultiplyNode(this.leftChild, this.rightChild.derivative(varName).simplify())).simplify();
182
+ }
183
+ simplify(opts, log) {
184
+ if (this.leftChild.evaluate() === 0 ||
185
+ this.rightChild.evaluate() === 0) {
186
+ return (0).toTree();
187
+ }
188
+ else {
189
+ return super.simplify(opts, log);
190
+ }
191
+ }
192
+ }
193
+ class WrongExpNode extends ExpNode {
194
+ derivative(varName = "x") {
195
+ const derivateSuper = new MyMultiplyNode(this.child.derivative(varName), exp(this.child));
196
+ return new MyMultiplyNode(varName.toTree(), derivateSuper);
197
+ }
198
+ }
199
+ const wrongInstructionNode = (() => {
200
+ const nodeF = (() => {
201
+ if (a !== undefined) {
202
+ return TrinomConstructor.fromCoeffs([c, b, a]).toTree().simplify();
203
+ }
204
+ else if (b !== undefined) {
205
+ return AffineConstructor.fromCoeffs([c, b]).toTree().simplify();
206
+ }
207
+ else {
208
+ return c.toTree();
209
+ }
210
+ })();
211
+ const nodeG = (() => {
212
+ if (d !== undefined) {
213
+ return AffineConstructor.fromCoeffs([e, d]).toTree().simplify();
214
+ }
215
+ else {
216
+ return e.toTree();
217
+ }
218
+ })();
219
+ return multiply(nodeF, new WrongExpNode(nodeG));
220
+ })();
221
+ const nodeDerivativeWrong = wrongInstructionNode.derivative();
222
+ tryToAddWrongProp(propositions, simplifyMore(nodeDerivativeWrong.simplify()).toTex());
223
+ }
224
+ return shuffleProps(propositions, n);
225
+ };
226
+ const isAnswerValid = (ans, { answer }, optsIn) => {
227
+ const opts = optsIn ?? optsDefault;
228
+ const { isRequireFactorizedAnswer } = opts;
229
+ const nodeAns = parseAlgebraic(ans);
230
+ if (isRequireFactorizedAnswer) {
231
+ const nodeAnsFactorized = simplifyMore(nodeAns.simplify());
232
+ if (nodeAns.toTex() !== nodeAnsFactorized.toTex()) {
233
+ return false;
234
+ }
235
+ }
236
+ const nodeAnswer = parseAlgebraic(answer);
237
+ return [0, 1, 2, 10].every((x) => {
238
+ return (substract(nodeAns.evaluate({ x }), nodeAnswer.evaluate({ x })).evaluate() === 0);
239
+ });
240
+ };
241
+ const getExpDerivativeProductFExpQuestion = (optsIn) => {
242
+ const opts = optsIn ?? optsDefault;
243
+ const { typeF, typeExpG } = opts;
244
+ const coeffsF = (() => {
245
+ switch (typeF) {
246
+ case "affine":
247
+ return AffineConstructor.random().coefficients;
248
+ case "second degré":
249
+ return TrinomConstructor.random().coefficients;
250
+ default:
251
+ throw new Error("Unsupported typeF: " + typeF);
252
+ }
253
+ })();
254
+ const coeffsG = (() => {
255
+ switch (typeExpG) {
256
+ case "exp(x)":
257
+ return [0, 1];
258
+ case "exp(ax+b)":
259
+ return [randint(-9, 10), randint(-9, 10, [0])];
260
+ default:
261
+ throw new Error("Unsupported typeF: " + typeF);
262
+ }
263
+ })();
264
+ const identifiers = {
265
+ coeffsF,
266
+ coeffsG,
267
+ };
268
+ return getQuestionFromIdentifiers(identifiers, opts);
269
+ };
270
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
271
+ const question = {
272
+ instruction: getInstruction(identifiers, opts),
273
+ startStatement: "h'(x)",
274
+ answer: getAnswer(identifiers, opts),
275
+ keys: ["x", "epower"],
276
+ answerFormat: "tex",
277
+ identifiers,
278
+ hint: getHint(identifiers, opts),
279
+ correction: getCorrection(identifiers, opts),
280
+ options: opts,
281
+ };
282
+ return question;
283
+ };
284
+ const optsDefault = {
285
+ typeF: "affine",
286
+ isRequireFactorizedAnswer: false,
287
+ //"internal" option
288
+ typeExpG: "exp(x)",
289
+ };
290
+ const options = [
291
+ {
292
+ id: "typeF",
293
+ label: "Fonction $f$",
294
+ type: GeneratorOptionType.select,
295
+ target: GeneratorOptionTarget.generation,
296
+ values: ["affine", "second degré"],
297
+ defaultValue: optsDefault.typeF,
298
+ },
299
+ {
300
+ id: "isRequireFactorizedAnswer",
301
+ label: "Réponse factorisée attendue ?",
302
+ type: GeneratorOptionType.checkbox,
303
+ target: GeneratorOptionTarget.generation,
304
+ defaultValue: optsDefault.isRequireFactorizedAnswer,
305
+ },
306
+ ];
307
+ export const expDerivativeProductFExp = {
308
+ id: "expDerivativeProductFExp",
309
+ connector: "=",
310
+ label: "Dérivée de $f(x)exp(x)$",
311
+ isSingleStep: false,
312
+ generator: (nb, opts) => getDistinctQuestions(() => getExpDerivativeProductFExpQuestion({
313
+ ...(opts ?? optsDefault),
314
+ typeExpG: "exp(x)",
315
+ }), nb),
316
+ options,
317
+ getPropositions,
318
+ qcmTimer: 60,
319
+ freeTimer: 60,
320
+ isAnswerValid,
321
+ subject: "Mathématiques",
322
+ getAnswer,
323
+ getInstruction,
324
+ getQuestionFromIdentifiers,
325
+ hasHintAndCorrection: true,
326
+ };
327
+ export const expDerivativeProductFExpAffine = {
328
+ id: "expDerivativeProductFExpAffine",
329
+ connector: "=",
330
+ label: "Dérivée de $f(x)exp(ax+b)$",
331
+ isSingleStep: false,
332
+ generator: (nb, opts) => getDistinctQuestions(() => getExpDerivativeProductFExpQuestion({
333
+ ...(opts ?? optsDefault),
334
+ typeExpG: "exp(ax+b)",
335
+ }), nb),
336
+ options,
337
+ getPropositions,
338
+ qcmTimer: 60,
339
+ freeTimer: 60,
340
+ isAnswerValid,
341
+ subject: "Mathématiques",
342
+ getAnswer,
343
+ getInstruction,
344
+ getQuestionFromIdentifiers,
345
+ hasHintAndCorrection: true,
346
+ };
@@ -0,0 +1,15 @@
1
+ import { Exercise } from "../../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ coeffsF: number[];
4
+ coeffsG: number[];
5
+ isFOverExpG: boolean;
6
+ };
7
+ type Options = {
8
+ typeF: string;
9
+ isRequireFactorizedAnswer: boolean;
10
+ typeExpG: string;
11
+ };
12
+ export declare const expDerivativeQuotientFExp: Exercise<Identifiers, Options>;
13
+ export declare const expDerivativeQuotientFExpAffine: Exercise<Identifiers, Options>;
14
+ export {};
15
+ //# sourceMappingURL=expDerivativeQuotientFExp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expDerivativeQuotientFExp.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/derivation/derivative/exp/expDerivativeQuotientFExp.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAqGrC,KAAK,WAAW,GAAG;IAEjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAGlB,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AA4XF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;IACd,yBAAyB,EAAE,OAAO,CAAC;IAGnC,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AA4BF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAwBpE,CAAC;AAEF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAyB1E,CAAC"}