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,435 @@
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 { PiNode } from "../../../../../tree/nodes/numbers/piNode.js";
8
+ import { add, AddNode } from "../../../../../tree/nodes/operators/addNode.js";
9
+ import { frac, FractionNode, isFractionNode, } from "../../../../../tree/nodes/operators/fractionNode.js";
10
+ import { isMultiplyNode, multiply, MultiplyNode, } from "../../../../../tree/nodes/operators/multiplyNode.js";
11
+ import { power } from "../../../../../tree/nodes/operators/powerNode.js";
12
+ import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
13
+ import { parseAlgebraic } from "../../../../../tree/parsers/latexParser.js";
14
+ import { coinFlip } from "../../../../../utils/alea/coinFlip.js";
15
+ const simplifyMoreProduct = (node) => {
16
+ if (isMultiplyNode(node)) {
17
+ const nodeLeft = node.leftChild;
18
+ const nodeRight = node.rightChild;
19
+ try {
20
+ return multiply(nodeLeft.simplify({ forbidFactorize: true, towardsDistribute: true }), nodeRight.simplify({ forbidFactorize: true, towardsDistribute: true }));
21
+ }
22
+ catch (_) {
23
+ return node;
24
+ }
25
+ }
26
+ else {
27
+ return node;
28
+ }
29
+ };
30
+ const simplifyMore = (node) => {
31
+ if (isFractionNode(node)) {
32
+ const nodeLeft = node.leftChild;
33
+ const nodeRight = node.rightChild;
34
+ try {
35
+ return frac(simplifyMoreProduct(nodeLeft), nodeRight.simplify());
36
+ }
37
+ catch (_) {
38
+ return node;
39
+ }
40
+ }
41
+ else if (isMultiplyNode(node)) {
42
+ return simplifyMoreProduct(node);
43
+ }
44
+ else {
45
+ return node;
46
+ }
47
+ };
48
+ const getPrettyFractionNode = (nodeFraction) => {
49
+ try {
50
+ const nodeNum = nodeFraction.leftChild.simplify({
51
+ towardsDistribute: true,
52
+ });
53
+ const nodeDen = nodeFraction.rightChild;
54
+ return frac(nodeNum, nodeDen);
55
+ }
56
+ catch (_e) {
57
+ return nodeFraction;
58
+ }
59
+ };
60
+ const getInstructionNode = (a, b, c, d, e, isFOverExpG) => {
61
+ const nodeF = (() => {
62
+ if (a !== undefined) {
63
+ return TrinomConstructor.fromCoeffs([c, b, a]).toTree().simplify();
64
+ }
65
+ else if (b !== undefined) {
66
+ return AffineConstructor.fromCoeffs([c, b]).toTree().simplify();
67
+ }
68
+ else {
69
+ return c.toTree();
70
+ }
71
+ })();
72
+ const nodeG = (() => {
73
+ if (d !== undefined) {
74
+ return AffineConstructor.fromCoeffs([e, d]).toTree().simplify();
75
+ }
76
+ else {
77
+ return e.toTree();
78
+ }
79
+ })();
80
+ const nodeExpG = exp(nodeG);
81
+ return isFOverExpG ? frac(nodeF, nodeExpG) : frac(nodeExpG, nodeF);
82
+ };
83
+ const getInstruction = (identifiers) => {
84
+ const { coeffsF, coeffsG, isFOverExpG } = identifiers;
85
+ const [c, b, a] = coeffsF;
86
+ const [e, d] = coeffsG;
87
+ const nodeH = getInstructionNode(a, b, c, d, e, isFOverExpG);
88
+ return `Déterminer la dérivée de la fonction $h$ définie par :
89
+
90
+ $$
91
+ h(x) = ${nodeH.toTex()}
92
+ $$`;
93
+ };
94
+ const getAnswerNode = (identifiers) => {
95
+ const { coeffsF, coeffsG, isFOverExpG } = identifiers;
96
+ const [c, b, a] = coeffsF;
97
+ const [e, d] = coeffsG;
98
+ const nodeDerivative = getInstructionNode(a, b, c, d, e, isFOverExpG).derivative();
99
+ return nodeDerivative;
100
+ };
101
+ const getAnswer = (identifiers) => {
102
+ return simplifyMore(getAnswerNode(identifiers).simplify()).toTex();
103
+ };
104
+ const getHint = (_identifiers, optsIn) => {
105
+ const opts = optsIn ?? optsDefault;
106
+ const { typeExpG } = opts;
107
+ return `Si $u$ et $v$ sont deux fonctions dérivables alors, pour $x$ tel que $v(x)\\neq0$, on a :
108
+
109
+ $$
110
+ (\\frac{u}{v})'(x) = \\frac{u'(x)v(x)-u(x)v'(x)}{{v(x)}^2}
111
+ $$
112
+
113
+ $$
114
+ ${(() => {
115
+ switch (typeExpG) {
116
+ case "exp(x)":
117
+ return `\\exp'(x) = \\exp(x)`;
118
+ case "exp(ax+b)":
119
+ return `(y \\mapsto \\exp(ay+b))'(x) = a \\times \\exp(ax+b)`;
120
+ default:
121
+ throw new Error("Unsupported typeExpG: " + typeExpG);
122
+ }
123
+ })()}
124
+ $$
125
+
126
+ `;
127
+ };
128
+ const getCorrection = (identifiers) => {
129
+ const { coeffsF, coeffsG, isFOverExpG } = identifiers;
130
+ const [c, b, a] = coeffsF;
131
+ const [e, d] = coeffsG;
132
+ const nodeInstruction = getInstructionNode(a, b, c, d, e, isFOverExpG);
133
+ const [nodeU, nodeV] = [
134
+ nodeInstruction.leftChild,
135
+ nodeInstruction.rightChild,
136
+ ];
137
+ const [nodeUPrime, nodeVPrime] = [nodeU, nodeV].map((node) => node.derivative().simplify());
138
+ return `On doit calculer la dérivée d'un quotient.
139
+
140
+ Ici, on a :
141
+
142
+ $$
143
+ u(x) = ${nodeU.toTex()}
144
+ $$
145
+
146
+ $$
147
+ v(x) = ${nodeV.toTex()}
148
+ $$
149
+
150
+ On calcule :
151
+
152
+ $$
153
+ u'(x) = ${nodeUPrime.toTex()}
154
+ $$
155
+
156
+ $$
157
+ v'(x) = ${nodeVPrime.toTex()}
158
+ $$
159
+
160
+ Donc :
161
+
162
+ $$
163
+ (\\frac{u}{v})'(x) = ${frac(substract(multiply(nodeUPrime, nodeV), multiply(nodeU, nodeVPrime)), power(nodeV, 2)).toTex()}
164
+ $$
165
+
166
+ ${(() => {
167
+ try {
168
+ return `$$
169
+ (\\frac{u}{v})'(x) = ${frac(substract(multiply(nodeUPrime, nodeV).simplify({ towardsDistribute: true }), multiply(nodeU, nodeVPrime).simplify({ towardsDistribute: true })), power(nodeV, 2)).toTex()}
170
+ $$`;
171
+ }
172
+ catch (_e) {
173
+ return "";
174
+ }
175
+ })()}
176
+
177
+ $$
178
+ h'(x) = ${getAnswer(identifiers)}
179
+ $$
180
+
181
+ `;
182
+ };
183
+ const getPropositions = (n, { answer, ...identifiers }) => {
184
+ const propositions = [];
185
+ addValidProp(propositions, answer);
186
+ const { coeffsF, coeffsG, isFOverExpG } = identifiers;
187
+ const [c, b, a] = coeffsF;
188
+ const [e, d] = coeffsG;
189
+ const nodeInstruction = getInstructionNode(a, b, c, d, e, isFOverExpG);
190
+ const [nodeU, nodeV] = [
191
+ nodeInstruction.leftChild,
192
+ nodeInstruction.rightChild,
193
+ ];
194
+ const [nodeUPrime, nodeVPrime] = [nodeU, nodeV].map((node) => node.derivative().simplify());
195
+ //student: no derivation
196
+ {
197
+ tryToAddWrongProp(propositions, nodeInstruction.simplify().toTex());
198
+ }
199
+ //student: (u/v)' = u'/v'
200
+ {
201
+ tryToAddWrongProp(propositions, simplifyMore(frac(nodeUPrime, nodeVPrime).simplify()).toTex());
202
+ }
203
+ //student: (u/v)' = (u'v+uv')/v²
204
+ {
205
+ class WrongFractionNode extends FractionNode {
206
+ derivative(varName) {
207
+ const numNode = add(multiply(this.leftChild.derivative(varName), this.rightChild), multiply(this.leftChild, this.rightChild.derivative(varName)));
208
+ const denNode = power(this.rightChild, 2);
209
+ return frac(numNode, denNode);
210
+ }
211
+ }
212
+ const wrongInstructionNode = (() => {
213
+ return new WrongFractionNode(nodeU, nodeV);
214
+ })();
215
+ const nodeRaw = wrongInstructionNode.derivative();
216
+ let nodeWrong;
217
+ if (isFractionNode(nodeRaw)) {
218
+ nodeWrong = getPrettyFractionNode(nodeRaw);
219
+ }
220
+ else {
221
+ nodeWrong = nodeRaw;
222
+ }
223
+ tryToAddWrongProp(propositions, nodeWrong.toTex());
224
+ }
225
+ //student: (u/v)' = -u'/v²
226
+ {
227
+ class WrongFractionNode extends FractionNode {
228
+ derivative(varName) {
229
+ const numNode = multiply(-1, this.leftChild).derivative(varName);
230
+ const denNode = power(this.rightChild, 2);
231
+ return frac(numNode, denNode);
232
+ }
233
+ }
234
+ const wrongInstructionNode = (() => {
235
+ return new WrongFractionNode(nodeU, nodeV);
236
+ })();
237
+ const nodeRaw = wrongInstructionNode.derivative();
238
+ let nodeWrong;
239
+ if (isFractionNode(nodeRaw)) {
240
+ nodeWrong = getPrettyFractionNode(nodeRaw);
241
+ }
242
+ else {
243
+ nodeWrong = nodeRaw;
244
+ }
245
+ tryToAddWrongProp(propositions, nodeWrong.toTex());
246
+ }
247
+ //student: exp(x)' = x.exp(x)
248
+ {
249
+ class MyAddNode extends AddNode {
250
+ simplify(opts, log) {
251
+ if (this.leftChild.evaluate() === 0 ||
252
+ this.rightChild.evaluate() === 0) {
253
+ return (0).toTree();
254
+ }
255
+ else {
256
+ return super.simplify(opts, log);
257
+ }
258
+ }
259
+ }
260
+ class MyMultiplyNode extends MultiplyNode {
261
+ derivative(varName) {
262
+ return new MyAddNode(new MyMultiplyNode(this.leftChild.derivative(varName).simplify(), this.rightChild), new MyMultiplyNode(this.leftChild, this.rightChild.derivative(varName).simplify())).simplify();
263
+ }
264
+ simplify(opts, log) {
265
+ if (this.leftChild.evaluate() === 0 ||
266
+ this.rightChild.evaluate() === 0) {
267
+ return (0).toTree();
268
+ }
269
+ else {
270
+ return super.simplify(opts, log);
271
+ }
272
+ }
273
+ }
274
+ class WrongExpNode extends ExpNode {
275
+ derivative(varName = "x") {
276
+ const derivateSuper = new MyMultiplyNode(this.child.derivative(varName), exp(this.child));
277
+ return new MyMultiplyNode(varName.toTree(), derivateSuper);
278
+ }
279
+ }
280
+ const wrongInstructionNode = (() => {
281
+ const nodeF = (() => {
282
+ if (a !== undefined) {
283
+ return TrinomConstructor.fromCoeffs([c, b, a]).toTree().simplify();
284
+ }
285
+ else if (b !== undefined) {
286
+ return AffineConstructor.fromCoeffs([c, b]).toTree().simplify();
287
+ }
288
+ else {
289
+ return c.toTree();
290
+ }
291
+ })();
292
+ const nodeG = (() => {
293
+ if (d !== undefined) {
294
+ return AffineConstructor.fromCoeffs([e, d]).toTree().simplify();
295
+ }
296
+ else {
297
+ return e.toTree();
298
+ }
299
+ })();
300
+ return isFOverExpG
301
+ ? frac(nodeF, new WrongExpNode(nodeG))
302
+ : frac(new WrongExpNode(nodeG), nodeF);
303
+ })();
304
+ const nodeDerivativeWrong = wrongInstructionNode.derivative();
305
+ tryToAddWrongProp(propositions, simplifyMore(nodeDerivativeWrong.simplify()).toTex());
306
+ }
307
+ return shuffleProps(propositions, n);
308
+ };
309
+ const isAnswerValid = (ans, { answer }, optsIn) => {
310
+ const opts = optsIn ?? optsDefault;
311
+ const { isRequireFactorizedAnswer } = opts;
312
+ const nodeAns = parseAlgebraic(ans);
313
+ if (isRequireFactorizedAnswer) {
314
+ const nodeAnsFactorized = simplifyMore(nodeAns.simplify());
315
+ if (nodeAns.toTex() !== nodeAnsFactorized.toTex()) {
316
+ return false;
317
+ }
318
+ }
319
+ const nodeAnswer = parseAlgebraic(answer);
320
+ return [
321
+ PiNode.evaluate(),
322
+ 2 * PiNode.evaluate(),
323
+ 3 * PiNode.evaluate(),
324
+ ].every((x) => {
325
+ return (substract(nodeAns.evaluate({ x }), nodeAnswer.evaluate({ x })).evaluate() === 0);
326
+ });
327
+ };
328
+ const getExpDerivativeQuotientFExpQuestion = (optsIn) => {
329
+ const opts = optsIn ?? optsDefault;
330
+ const { typeF, typeExpG } = opts;
331
+ const coeffsF = (() => {
332
+ switch (typeF) {
333
+ case "affine":
334
+ return AffineConstructor.random().coefficients;
335
+ case "second degré":
336
+ return TrinomConstructor.random().coefficients;
337
+ default:
338
+ throw new Error("Unsupported typeF: " + typeF);
339
+ }
340
+ })();
341
+ const coeffsG = (() => {
342
+ switch (typeExpG) {
343
+ case "exp(x)":
344
+ return [0, 1];
345
+ case "exp(ax+b)":
346
+ return [randint(-9, 10), randint(-9, 10, [0])];
347
+ default:
348
+ throw new Error("Unsupported typeF: " + typeF);
349
+ }
350
+ })();
351
+ const isFOverExpG = coinFlip();
352
+ const identifiers = {
353
+ coeffsF,
354
+ coeffsG,
355
+ isFOverExpG,
356
+ };
357
+ return getQuestionFromIdentifiers(identifiers, opts);
358
+ };
359
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
360
+ const question = {
361
+ instruction: getInstruction(identifiers, opts),
362
+ startStatement: "h'(x)",
363
+ answer: getAnswer(identifiers, opts),
364
+ keys: ["x", "epower"],
365
+ answerFormat: "tex",
366
+ identifiers,
367
+ hint: getHint(identifiers, opts),
368
+ correction: getCorrection(identifiers, opts),
369
+ options: opts,
370
+ };
371
+ return question;
372
+ };
373
+ const optsDefault = {
374
+ typeF: "affine",
375
+ isRequireFactorizedAnswer: false,
376
+ //"internal" option
377
+ typeExpG: "exp(x)",
378
+ };
379
+ const options = [
380
+ {
381
+ id: "typeF",
382
+ label: "Fonction $f$",
383
+ type: GeneratorOptionType.select,
384
+ target: GeneratorOptionTarget.generation,
385
+ values: ["affine", "second degré"],
386
+ defaultValue: optsDefault.typeF,
387
+ },
388
+ {
389
+ id: "isRequireFactorizedAnswer",
390
+ label: "Réponse factorisée attendue ?",
391
+ type: GeneratorOptionType.checkbox,
392
+ target: GeneratorOptionTarget.generation,
393
+ defaultValue: optsDefault.isRequireFactorizedAnswer,
394
+ },
395
+ ];
396
+ export const expDerivativeQuotientFExp = {
397
+ id: "expDerivativeQuotientFExp",
398
+ connector: "=",
399
+ label: "Dérivée de $\\frac{f(x)}{\\exp(x)}$ ou de $\\frac{\\exp(x)}{f(x)}$",
400
+ isSingleStep: false,
401
+ generator: (nb, opts) => getDistinctQuestions(() => getExpDerivativeQuotientFExpQuestion({
402
+ ...(opts ?? optsDefault),
403
+ typeExpG: "exp(x)",
404
+ }), nb),
405
+ options,
406
+ getPropositions,
407
+ qcmTimer: 60,
408
+ freeTimer: 60,
409
+ isAnswerValid,
410
+ subject: "Mathématiques",
411
+ getAnswer,
412
+ getInstruction,
413
+ getQuestionFromIdentifiers,
414
+ hasHintAndCorrection: true,
415
+ };
416
+ export const expDerivativeQuotientFExpAffine = {
417
+ id: "expDerivativeQuotientFExpAffine",
418
+ connector: "=",
419
+ label: "Dérivée de $\\frac{f(x)}{\\exp(ax+b)}$ ou de $\\frac{\\exp(ax+b)}{f(x)}$",
420
+ isSingleStep: false,
421
+ generator: (nb, opts) => getDistinctQuestions(() => getExpDerivativeQuotientFExpQuestion({
422
+ ...(opts ?? optsDefault),
423
+ typeExpG: "exp(ax+b)",
424
+ }), nb),
425
+ options,
426
+ getPropositions,
427
+ qcmTimer: 60,
428
+ freeTimer: 60,
429
+ isAnswerValid,
430
+ subject: "Mathématiques",
431
+ getAnswer,
432
+ getInstruction,
433
+ getQuestionFromIdentifiers,
434
+ hasHintAndCorrection: true,
435
+ };
@@ -0,0 +1,13 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ nodeIdsXAsked: NodeIdentifiers;
5
+ nodeIdsF: NodeIdentifiers;
6
+ typeF: string;
7
+ };
8
+ type Options = {
9
+ typeF: string;
10
+ };
11
+ export declare const valueDerivativeFromFunctionExpression: Exercise<Identifiers, Options>;
12
+ export {};
13
+ //# sourceMappingURL=valueDerivativeFromFunctionExpression.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"valueDerivativeFromFunctionExpression.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AASrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAgF7C,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,eAAe,CAAC;IAC/B,QAAQ,EAAE,eAAe,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AA0QF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAgDF,eAAO,MAAM,qCAAqC,EAAE,QAAQ,CAC1D,WAAW,EACX,OAAO,CAoBR,CAAC"}