math-exercises 3.0.169 → 3.0.171

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 (177) hide show
  1. package/lib/exercises/math/derivation/derivativeNumber/averageRateOfChangeAlgebraicExpression.d.ts +4 -3
  2. package/lib/exercises/math/derivation/derivativeNumber/averageRateOfChangeAlgebraicExpression.d.ts.map +1 -1
  3. package/lib/exercises/math/derivation/derivativeNumber/averageRateOfChangeAlgebraicExpression.js +236 -52
  4. package/lib/exercises/math/derivation/derivativeNumber/expressFAPlusH.d.ts +13 -0
  5. package/lib/exercises/math/derivation/derivativeNumber/expressFAPlusH.d.ts.map +1 -0
  6. package/lib/exercises/math/derivation/derivativeNumber/expressFAPlusH.js +225 -0
  7. package/lib/exercises/math/derivation/derivativeNumber/findAverageRateLimit.d.ts +14 -0
  8. package/lib/exercises/math/derivation/derivativeNumber/findAverageRateLimit.d.ts.map +1 -0
  9. package/lib/exercises/math/derivation/derivativeNumber/findAverageRateLimit.js +162 -0
  10. package/lib/exercises/math/derivation/derivativeNumber/index.d.ts +3 -0
  11. package/lib/exercises/math/derivation/derivativeNumber/index.d.ts.map +1 -1
  12. package/lib/exercises/math/derivation/derivativeNumber/index.js +3 -1
  13. package/lib/exercises/math/derivation/tangent/derivativeNumberReading.d.ts +4 -1
  14. package/lib/exercises/math/derivation/tangent/derivativeNumberReading.d.ts.map +1 -1
  15. package/lib/exercises/math/derivation/tangent/derivativeNumberReading.js +50 -9
  16. package/lib/exercises/math/derivation/variations/signVarTableFromDerivativeGraph.js +1 -1
  17. package/lib/exercises/math/derivation/variations/signVarTableFromGraph.js +1 -1
  18. package/lib/exercises/math/functions/trinoms/equation/findTwoNumbersFromSumAndProduct.d.ts +8 -0
  19. package/lib/exercises/math/functions/trinoms/equation/findTwoNumbersFromSumAndProduct.d.ts.map +1 -0
  20. package/lib/exercises/math/functions/trinoms/equation/findTwoNumbersFromSumAndProduct.js +182 -0
  21. package/lib/exercises/math/functions/trinoms/equation/index.d.ts +1 -0
  22. package/lib/exercises/math/functions/trinoms/equation/index.d.ts.map +1 -1
  23. package/lib/exercises/math/functions/trinoms/equation/index.js +1 -0
  24. package/lib/exercises/math/functions/trinoms/index.d.ts +1 -0
  25. package/lib/exercises/math/functions/trinoms/index.d.ts.map +1 -1
  26. package/lib/exercises/math/functions/trinoms/index.js +1 -0
  27. package/lib/exercises/math/functions/trinoms/problems/index.d.ts +4 -0
  28. package/lib/exercises/math/functions/trinoms/problems/index.d.ts.map +1 -0
  29. package/lib/exercises/math/functions/trinoms/problems/index.js +3 -0
  30. package/lib/exercises/math/functions/trinoms/problems/maxSurfaceForGivenClosure.d.ts +11 -0
  31. package/lib/exercises/math/functions/trinoms/problems/maxSurfaceForGivenClosure.d.ts.map +1 -0
  32. package/lib/exercises/math/functions/trinoms/problems/maxSurfaceForGivenClosure.js +212 -0
  33. package/lib/exercises/math/functions/trinoms/problems/rectangleSizesFromPerimeterAndArea.d.ts +9 -0
  34. package/lib/exercises/math/functions/trinoms/problems/rectangleSizesFromPerimeterAndArea.d.ts.map +1 -0
  35. package/lib/exercises/math/functions/trinoms/problems/rectangleSizesFromPerimeterAndArea.js +202 -0
  36. package/lib/exercises/math/functions/trinoms/problems/swedishFlag.d.ts +8 -0
  37. package/lib/exercises/math/functions/trinoms/problems/swedishFlag.d.ts.map +1 -0
  38. package/lib/exercises/math/functions/trinoms/problems/swedishFlag.js +174 -0
  39. package/lib/exercises/math/functions/trinoms/summitAndCanonical/findTrinomCanonicalFormFromGraph.js +2 -2
  40. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitReading.d.ts.map +1 -1
  41. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitReading.js +22 -1
  42. package/lib/exercises/math/geometry/vectors/scalarProduct/alg/scalarProductIdentities.js +1 -1
  43. package/lib/exercises/math/probaStat/randomVariable/calculateProbaFromVATableLaw.d.ts +11 -0
  44. package/lib/exercises/math/probaStat/randomVariable/calculateProbaFromVATableLaw.d.ts.map +1 -0
  45. package/lib/exercises/math/probaStat/randomVariable/calculateProbaFromVATableLaw.js +232 -0
  46. package/lib/exercises/math/probaStat/randomVariable/index.d.ts +1 -0
  47. package/lib/exercises/math/probaStat/randomVariable/index.d.ts.map +1 -1
  48. package/lib/exercises/math/probaStat/randomVariable/index.js +1 -0
  49. package/lib/exercises/math/sequences/arithmetic/arithmeticVariations.js +1 -1
  50. package/lib/exercises/math/trigonometry/circle/findAssociateAnglePointOnTrigoCircle.js +1 -1
  51. package/lib/index.d.ts +43 -2
  52. package/lib/index.d.ts.map +1 -1
  53. package/lib/math/geometry/point.js +2 -2
  54. package/lib/math/geometry/segment.d.ts +1 -1
  55. package/lib/math/utils/random/randTupleInt.d.ts +1 -0
  56. package/lib/math/utils/random/randTupleInt.d.ts.map +1 -1
  57. package/lib/math/utils/random/randTupleInt.js +3 -0
  58. package/lib/playground.d.ts.map +1 -1
  59. package/lib/playground.js +1 -3
  60. package/lib/tree/nodes/algebraicNode.d.ts +2 -0
  61. package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
  62. package/lib/tree/nodes/complex/complexNode.d.ts +1 -0
  63. package/lib/tree/nodes/complex/complexNode.d.ts.map +1 -1
  64. package/lib/tree/nodes/complex/complexNode.js +3 -0
  65. package/lib/tree/nodes/equations/equalNode.d.ts +1 -0
  66. package/lib/tree/nodes/equations/equalNode.d.ts.map +1 -1
  67. package/lib/tree/nodes/equations/equalNode.js +3 -0
  68. package/lib/tree/nodes/equations/equationSolutionNode.d.ts +1 -0
  69. package/lib/tree/nodes/equations/equationSolutionNode.d.ts.map +1 -1
  70. package/lib/tree/nodes/equations/equationSolutionNode.js +3 -0
  71. package/lib/tree/nodes/equations/multiEqualNode.d.ts +1 -0
  72. package/lib/tree/nodes/equations/multiEqualNode.d.ts.map +1 -1
  73. package/lib/tree/nodes/equations/multiEqualNode.js +3 -0
  74. package/lib/tree/nodes/equations/notEqualNode.d.ts +1 -0
  75. package/lib/tree/nodes/equations/notEqualNode.d.ts.map +1 -1
  76. package/lib/tree/nodes/equations/notEqualNode.js +3 -0
  77. package/lib/tree/nodes/functions/absNode.d.ts +1 -0
  78. package/lib/tree/nodes/functions/absNode.d.ts.map +1 -1
  79. package/lib/tree/nodes/functions/absNode.js +3 -0
  80. package/lib/tree/nodes/functions/arcSinNode.d.ts +1 -0
  81. package/lib/tree/nodes/functions/arcSinNode.d.ts.map +1 -1
  82. package/lib/tree/nodes/functions/arcSinNode.js +3 -0
  83. package/lib/tree/nodes/functions/arccosNode.d.ts +1 -0
  84. package/lib/tree/nodes/functions/arccosNode.d.ts.map +1 -1
  85. package/lib/tree/nodes/functions/arccosNode.js +3 -0
  86. package/lib/tree/nodes/functions/arctanNode.d.ts +1 -0
  87. package/lib/tree/nodes/functions/arctanNode.d.ts.map +1 -1
  88. package/lib/tree/nodes/functions/arctanNode.js +3 -0
  89. package/lib/tree/nodes/functions/cosNode.d.ts +1 -0
  90. package/lib/tree/nodes/functions/cosNode.d.ts.map +1 -1
  91. package/lib/tree/nodes/functions/cosNode.js +3 -0
  92. package/lib/tree/nodes/functions/expNode.d.ts +1 -0
  93. package/lib/tree/nodes/functions/expNode.d.ts.map +1 -1
  94. package/lib/tree/nodes/functions/expNode.js +3 -0
  95. package/lib/tree/nodes/functions/integralNode.d.ts +1 -0
  96. package/lib/tree/nodes/functions/integralNode.d.ts.map +1 -1
  97. package/lib/tree/nodes/functions/integralNode.js +3 -0
  98. package/lib/tree/nodes/functions/log10Node.d.ts +1 -0
  99. package/lib/tree/nodes/functions/log10Node.d.ts.map +1 -1
  100. package/lib/tree/nodes/functions/log10Node.js +3 -0
  101. package/lib/tree/nodes/functions/logNode.d.ts +1 -0
  102. package/lib/tree/nodes/functions/logNode.d.ts.map +1 -1
  103. package/lib/tree/nodes/functions/logNode.js +3 -0
  104. package/lib/tree/nodes/functions/oppositeNode.d.ts +1 -0
  105. package/lib/tree/nodes/functions/oppositeNode.d.ts.map +1 -1
  106. package/lib/tree/nodes/functions/oppositeNode.js +6 -0
  107. package/lib/tree/nodes/functions/sinNode.d.ts +1 -0
  108. package/lib/tree/nodes/functions/sinNode.d.ts.map +1 -1
  109. package/lib/tree/nodes/functions/sinNode.js +3 -0
  110. package/lib/tree/nodes/functions/sqrtNode.d.ts +1 -2
  111. package/lib/tree/nodes/functions/sqrtNode.d.ts.map +1 -1
  112. package/lib/tree/nodes/functions/tanNode.d.ts +1 -0
  113. package/lib/tree/nodes/functions/tanNode.d.ts.map +1 -1
  114. package/lib/tree/nodes/functions/tanNode.js +3 -0
  115. package/lib/tree/nodes/geometry/degree.d.ts +1 -0
  116. package/lib/tree/nodes/geometry/degree.d.ts.map +1 -1
  117. package/lib/tree/nodes/geometry/degree.js +3 -0
  118. package/lib/tree/nodes/geometry/lengthNode.d.ts +1 -0
  119. package/lib/tree/nodes/geometry/lengthNode.d.ts.map +1 -1
  120. package/lib/tree/nodes/geometry/lengthNode.js +3 -0
  121. package/lib/tree/nodes/geometry/pointNode.d.ts +1 -0
  122. package/lib/tree/nodes/geometry/pointNode.d.ts.map +1 -1
  123. package/lib/tree/nodes/geometry/pointNode.js +3 -0
  124. package/lib/tree/nodes/geometry/vectorNode.d.ts +1 -0
  125. package/lib/tree/nodes/geometry/vectorNode.d.ts.map +1 -1
  126. package/lib/tree/nodes/geometry/vectorNode.js +3 -0
  127. package/lib/tree/nodes/inequations/inequationNode.d.ts +1 -0
  128. package/lib/tree/nodes/inequations/inequationNode.d.ts.map +1 -1
  129. package/lib/tree/nodes/inequations/inequationNode.js +3 -0
  130. package/lib/tree/nodes/inequations/inequationSolutionNode.d.ts +1 -0
  131. package/lib/tree/nodes/inequations/inequationSolutionNode.d.ts.map +1 -1
  132. package/lib/tree/nodes/inequations/inequationSolutionNode.js +3 -0
  133. package/lib/tree/nodes/numbers/constantNode.d.ts +3 -2
  134. package/lib/tree/nodes/numbers/constantNode.d.ts.map +1 -1
  135. package/lib/tree/nodes/numbers/constantNode.js +7 -1
  136. package/lib/tree/nodes/numbers/numberNode.d.ts +1 -0
  137. package/lib/tree/nodes/numbers/numberNode.d.ts.map +1 -1
  138. package/lib/tree/nodes/numbers/numberNode.js +6 -0
  139. package/lib/tree/nodes/numbers/percentNode.d.ts +1 -0
  140. package/lib/tree/nodes/numbers/percentNode.d.ts.map +1 -1
  141. package/lib/tree/nodes/numbers/percentNode.js +3 -0
  142. package/lib/tree/nodes/operators/addNode.js +17 -14
  143. package/lib/tree/nodes/operators/binomialCoefficientNode.d.ts +1 -0
  144. package/lib/tree/nodes/operators/binomialCoefficientNode.d.ts.map +1 -1
  145. package/lib/tree/nodes/operators/binomialCoefficientNode.js +3 -0
  146. package/lib/tree/nodes/operators/divideNode.d.ts +1 -0
  147. package/lib/tree/nodes/operators/divideNode.d.ts.map +1 -1
  148. package/lib/tree/nodes/operators/divideNode.js +3 -0
  149. package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
  150. package/lib/tree/nodes/operators/limitNode.d.ts +1 -0
  151. package/lib/tree/nodes/operators/limitNode.d.ts.map +1 -1
  152. package/lib/tree/nodes/operators/limitNode.js +3 -0
  153. package/lib/tree/nodes/operators/powerNode.d.ts +1 -0
  154. package/lib/tree/nodes/operators/powerNode.d.ts.map +1 -1
  155. package/lib/tree/nodes/operators/powerNode.js +6 -0
  156. package/lib/tree/nodes/polynomials/monomNode.d.ts +1 -0
  157. package/lib/tree/nodes/polynomials/monomNode.d.ts.map +1 -1
  158. package/lib/tree/nodes/polynomials/monomNode.js +3 -0
  159. package/lib/tree/nodes/polynomials/trinomNode.d.ts +1 -0
  160. package/lib/tree/nodes/polynomials/trinomNode.d.ts.map +1 -1
  161. package/lib/tree/nodes/polynomials/trinomNode.js +3 -0
  162. package/lib/tree/nodes/sets/belongsNode.d.ts +1 -0
  163. package/lib/tree/nodes/sets/belongsNode.d.ts.map +1 -1
  164. package/lib/tree/nodes/sets/belongsNode.js +3 -0
  165. package/lib/tree/nodes/sets/discreteSetNode.d.ts +1 -0
  166. package/lib/tree/nodes/sets/discreteSetNode.d.ts.map +1 -1
  167. package/lib/tree/nodes/sets/discreteSetNode.js +3 -0
  168. package/lib/tree/nodes/sets/intervalNode.d.ts +1 -0
  169. package/lib/tree/nodes/sets/intervalNode.d.ts.map +1 -1
  170. package/lib/tree/nodes/sets/intervalNode.js +3 -0
  171. package/lib/tree/nodes/sets/unionIntervalNode.d.ts +1 -0
  172. package/lib/tree/nodes/sets/unionIntervalNode.d.ts.map +1 -1
  173. package/lib/tree/nodes/sets/unionIntervalNode.js +3 -0
  174. package/lib/tree/nodes/variables/variableNode.d.ts +1 -0
  175. package/lib/tree/nodes/variables/variableNode.d.ts.map +1 -1
  176. package/lib/tree/nodes/variables/variableNode.js +3 -0
  177. package/package.json +1 -1
@@ -1,11 +1,12 @@
1
1
  import { Exercise } from "../../../../exercises/exercise.js";
2
2
  import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
3
  type Identifiers = {
4
- aIds: NodeIdentifiers;
5
- fxIds: NodeIdentifiers;
4
+ type: number;
5
+ functionIds: NodeIdentifiers;
6
+ a: number;
6
7
  };
7
8
  type Options = {
8
- functionType: string[];
9
+ functionTypes: string[];
9
10
  };
10
11
  export declare const averageRateOfChangeAlgebraicExpression: Exercise<Identifiers, Options>;
11
12
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"averageRateOfChangeAlgebraicExpression.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivativeNumber/averageRateOfChangeAlgebraicExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAO7C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,EAAE,eAAe,CAAC;CACxB,CAAC;AAyEF,KAAK,OAAO,GAAG;IACb,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAuCF,eAAO,MAAM,sCAAsC,EAAE,QAAQ,CAC3D,WAAW,EACX,OAAO,CAyBR,CAAC"}
1
+ {"version":3,"file":"averageRateOfChangeAlgebraicExpression.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivativeNumber/averageRateOfChangeAlgebraicExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAY7C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,eAAe,CAAC;IAC7B,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAkSF,KAAK,OAAO,GAAG;IACb,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AA8BF,eAAO,MAAM,sCAAsC,EAAE,QAAQ,CAC3D,WAAW,EACX,OAAO,CAwBR,CAAC"}
@@ -1,90 +1,285 @@
1
- import { addValidProp, shuffleProps, GeneratorOptionTarget, GeneratorOptionType, propWhile, } from "../../../../exercises/exercise.js";
1
+ import { addValidProp, shuffleProps, GeneratorOptionTarget, GeneratorOptionType, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
- import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
4
3
  import { AffineConstructor } from "../../../../math/polynomials/affine.js";
5
4
  import { TrinomConstructor } from "../../../../math/polynomials/trinom.js";
6
5
  import { randint } from "../../../../math/utils/random/randint.js";
6
+ import { round } from "../../../../math/utils/round.js";
7
7
  import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
8
8
  import { add } from "../../../../tree/nodes/operators/addNode.js";
9
9
  import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
10
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
11
+ import { square } from "../../../../tree/nodes/operators/powerNode.js";
10
12
  import { substract } from "../../../../tree/nodes/operators/substractNode.js";
13
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
11
14
  import { random } from "../../../../utils/alea/random.js";
15
+ import { doWhile } from "../../../../utils/doWhile.js";
12
16
  import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
13
- const getPropositions = (n, { answer }) => {
17
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
18
+ const getPropositions = (n, { answer, ...identifiers }) => {
14
19
  const propositions = [];
20
+ const { a, functionIds } = identifiers;
21
+ const fct = reifyAlgebraic(functionIds);
15
22
  addValidProp(propositions, answer);
16
- propWhile(propositions, n, () => {
17
- throw Error("QCM not implemented");
18
- });
23
+ tryToAddWrongProp(propositions, fct
24
+ .toDetailedEvaluation({ x: a.toTree() })
25
+ .simplify({
26
+ towardsDistribute: true,
27
+ forbidFactorize: true,
28
+ })
29
+ .toTex());
30
+ tryToAddWrongProp(propositions, fct
31
+ .toDetailedEvaluation({ x: "h".toTree() })
32
+ .simplify({
33
+ towardsDistribute: true,
34
+ forbidFactorize: true,
35
+ })
36
+ .toTex());
37
+ let safeA = randint(-10, 10, [0]);
38
+ let isSafe = false;
39
+ let counter = 0;
40
+ while (!isSafe && counter < 100) {
41
+ counter++;
42
+ if (counter > 100) {
43
+ throw new Error("Too many iterations in getPropositions expressFAPlusH");
44
+ }
45
+ try {
46
+ fct.toDetailedEvaluation({ x: safeA.toTree() }).simplify();
47
+ isSafe = true;
48
+ }
49
+ catch (_e) {
50
+ safeA = randint(-10, 10, [0]);
51
+ }
52
+ }
53
+ tryToAddWrongProp(propositions, fct
54
+ .toDetailedEvaluation({ x: add(safeA, "h") })
55
+ .simplify({
56
+ towardsDistribute: true,
57
+ forbidFactorize: true,
58
+ })
59
+ .toTex());
19
60
  return shuffleProps(propositions, n);
20
61
  };
21
- const getAnswer = (identifiers) => {
22
- const { fxIds, aIds } = identifiers;
23
- const fx = reifyAlgebraic(fxIds);
24
- const a = reifyAlgebraic(aIds);
25
- const fa = fx.toDetailedEvaluation({ x: a });
26
- const fah = fx.toDetailedEvaluation({ x: add(a, "h") }).simplify({
62
+ const getAnswerNode = (identifiers) => {
63
+ const { a, functionIds, type } = identifiers;
64
+ const fct = reifyAlgebraic(functionIds);
65
+ const faSimp = fct.toDetailedEvaluation({ x: a.toTree() }).simplify();
66
+ const fahSimp = fct.toDetailedEvaluation({ x: add(a, "h") }).simplify({
27
67
  towardsDistribute: true,
28
68
  forbidFactorize: true,
29
69
  });
30
- return frac(substract(fah, fa), "h").simplify().toTex();
70
+ const diff = substract(fahSimp, faSimp);
71
+ const diffSimp = diff.simplify({
72
+ towardsDistribute: true,
73
+ forbidFactorize: true,
74
+ forceAddFractions: true,
75
+ });
76
+ const taux = type === 0 || type === 1
77
+ ? frac(diffSimp, "h")
78
+ : multiply(diffSimp, frac(1, "h"));
79
+ //? terrible manipulation pour faire marcher le cas dans ce cas très chiant
80
+ const tauxSimp = type === 3
81
+ ? frac(frac(diffSimp.leftChild, "h").simplify({
82
+ forceDistributeFractions: true,
83
+ }), diffSimp.rightChild)
84
+ : taux.simplify({
85
+ forceDistributeFractions: type === 0 || type === 1,
86
+ });
87
+ return tauxSimp;
88
+ };
89
+ const getAnswer = (identifiers) => {
90
+ return getAnswerNode(identifiers).toTex();
31
91
  };
32
92
  const getInstruction = (identifiers) => {
33
- const { fxIds, aIds } = identifiers;
34
- const fx = reifyAlgebraic(fxIds);
35
- const a = reifyAlgebraic(aIds);
36
- return `Soit $f$ la fonction définie sur $\\mathbb{R}$ par :
93
+ const { a, functionIds } = identifiers;
94
+ const fct = reifyAlgebraic(functionIds);
95
+ return `On considère la fonction $f$ définie par :
37
96
 
38
97
  $$
39
- f(x) = ${fx.toTex()}
98
+ f(x) = ${fct.toTex()}
40
99
  $$
41
100
 
42
- Pour un nombre réel $h>0$, donner l'expression algébrique du taux d'accroissement entre $${a.toTex()}$ et $${a.toTex()}+h$.
43
- `;
101
+ Pour $h>0$, exprimer le taux d'accroissement de $f$ entre $${a}$ et $${a}+h$ en fonction de $h$.`;
44
102
  };
45
- const getHint = () => {
46
- return ``;
103
+ const getHint = (identifiers) => {
104
+ const { a } = identifiers;
105
+ return `Le taux d'accroissement d'une fonction $f$ entre deux nombres réels $a$ et $b$ est égal à :
106
+
107
+ $$
108
+ \\frac{f(b)-f(a)}{b-a}
109
+ $$
110
+
111
+ Ici, on pose $b=${a}+h$. Le taux d'accroissement vaut donc :
112
+
113
+ $$
114
+ \\frac{f(${a}+h)-f(${a})}{h}
115
+ $$
116
+ `;
47
117
  };
48
- const getCorrection = () => {
49
- return ``;
118
+ const getCorrection = (identifiers) => {
119
+ const { a, functionIds, type } = identifiers;
120
+ const fct = reifyAlgebraic(functionIds);
121
+ const fa = fct.toDetailedEvaluation({ x: a.toTree() });
122
+ const faSimp = fa.simplify();
123
+ const fah = fct.toDetailedEvaluation({ x: add(a, "h") });
124
+ const fahSimp = fct.toDetailedEvaluation({ x: add(a, "h") }).simplify({
125
+ towardsDistribute: true,
126
+ forbidFactorize: true,
127
+ });
128
+ const diff = substract(fahSimp, faSimp);
129
+ const diffPreSimp = diff.simplify({
130
+ // towardsDistribute: true,
131
+ forbidFactorize: true,
132
+ forceAddFractions: true,
133
+ });
134
+ const diffSimp = diff.simplify({
135
+ towardsDistribute: true,
136
+ forbidFactorize: true,
137
+ forceAddFractions: true,
138
+ });
139
+ const taux = type === 0 || type === 1
140
+ ? frac(diffSimp, "h")
141
+ : multiply(diffSimp, frac(1, "h"));
142
+ //? terrible manipulation pour faire marcher le cas dans ce cas très chiant
143
+ const tauxSimp = type === 3
144
+ ? frac(frac(diffSimp.leftChild, "h").simplify({
145
+ forceDistributeFractions: true,
146
+ }), diffSimp.rightChild)
147
+ : taux.simplify({
148
+ forceDistributeFractions: type === 0 || type === 1,
149
+ });
150
+ return `Le taux d'accroissement de $f$ entre $${a}$ et $${a}+h$ vaut :
151
+
152
+ $$
153
+ \\frac{f(${a}+h)-f(${a})}{h}
154
+ $$
155
+
156
+ On calcule donc $f(${a})$ :
157
+
158
+ ${alignTex([
159
+ [`f(${a})`, "=", type === 2 ? fa.toSimplificationTex() : fa.toTex()],
160
+ ...(type !== 2 ? [["", "=", faSimp.toTex()]] : []),
161
+ ])}
162
+
163
+ Puis $f(${a}+h)$ :
164
+
165
+ ${alignTex([
166
+ [`f(${a}+h)`, "=", fah.toTex()],
167
+ ["", "=", fahSimp.toTex()],
168
+ ])}
169
+
170
+ Puis $f(${a}+h)-f(${a})$ :
171
+
172
+ ${alignTex([
173
+ [`f(${a}+h)-f(${a})`, "=", diff.toTex()],
174
+ ["", "=", diffPreSimp.toTex()],
175
+ ...(type !== 0 && type !== 1 ? [["", "=", diffSimp.toTex()]] : []),
176
+ ])}
177
+
178
+ Enfin, on divise par $h$ pour obtenir le taux d'accroissement de $f$ entre $${a}$ et $${a}+h$ :
179
+
180
+ ${alignTex([
181
+ [`\\frac{f(${a}+h)-f(${a})}{h}`, "=", taux.toTex()],
182
+ ["", "=", tauxSimp.toTex()],
183
+ ])}
184
+ `;
50
185
  };
51
186
  const getKeys = () => {
52
187
  return ["h"];
53
188
  };
54
- const isAnswerValid = (ans, { answer }) => {
189
+ const isAnswerValid = (ans, { answer, ...identifiers }) => {
55
190
  try {
56
- return rationalVEA(ans, answer);
191
+ const parsed = parseAlgebraic(ans);
192
+ if (!parsed)
193
+ return false;
194
+ return (parsed
195
+ .simplify({ towardsDistribute: true, forbidFactorize: true })
196
+ .toTex() ===
197
+ getAnswerNode(identifiers)
198
+ .simplify({
199
+ towardsDistribute: true,
200
+ forbidFactorize: true,
201
+ })
202
+ .toTex());
57
203
  }
58
204
  catch (err) {
59
205
  return handleVEAError(err);
60
206
  }
61
207
  };
62
208
  const getAverageRateOfChangeAlgebraicExpressionQuestion = (opts) => {
63
- let a = randint(-10, 10);
64
- let b = randint(-10, 10, [a]);
65
- if (a > b)
66
- [a, b] = [b, a];
67
- const types = opts?.functionType ?? ["Affine", "Polynôme du second degré"];
68
- const type = random(types);
69
- const fx = type === "Affine" ? AffineConstructor.random() : TrinomConstructor.random();
209
+ const defaultTypes = [
210
+ "$ax+b$",
211
+ "$ax^2+bx+c$",
212
+ "$\\frac{k}{x}$",
213
+ "$\\frac{k}{x^2}$",
214
+ "$\\frac{ax+b}{cx+d}$",
215
+ ];
216
+ const frenchType = random(opts?.functionTypes ?? defaultTypes);
217
+ const type = defaultTypes.indexOf(frenchType);
218
+ let functionIds = undefined;
219
+ let a = 0;
220
+ switch (type) {
221
+ case 0:
222
+ functionIds = AffineConstructor.random().toTree().toIdentifiers();
223
+ a = randint(-5, 6, [0]);
224
+ break;
225
+ case 1:
226
+ functionIds = TrinomConstructor.random().toTree().toIdentifiers();
227
+ a = randint(-5, 6, [0]);
228
+ break;
229
+ case 2:
230
+ a = randint(-5, 6, [0]);
231
+ functionIds = frac(randint(-10, 10, [0]), "x").toIdentifiers();
232
+ break;
233
+ case 3:
234
+ a = randint(-5, 6, [0]);
235
+ functionIds = frac(randint(-10, 10, [0]), square("x")).toIdentifiers();
236
+ break;
237
+ case 4:
238
+ default: {
239
+ const denum = AffineConstructor.random();
240
+ const num = doWhile(() => AffineConstructor.random(), (aff) => (denum.b === 0 && aff.b === 0) ||
241
+ round(aff.a / denum.a, 5) === round(aff.b / denum.b, 5));
242
+ a = randint(-5, 6, [denum.getRoot().value]);
243
+ functionIds = frac(num.toTree(), denum.toTree()).toIdentifiers();
244
+ break;
245
+ }
246
+ }
70
247
  const identifiers = {
71
- aIds: a.toTree().toIdentifiers(),
72
- fxIds: fx.toTree().toIdentifiers(),
248
+ type,
249
+ functionIds,
250
+ a,
73
251
  };
74
252
  return getQuestionFromIdentifiers(identifiers);
75
253
  };
254
+ const getQuestionFromIdentifiers = (identifiers) => {
255
+ return {
256
+ answer: getAnswer(identifiers),
257
+ instruction: getInstruction(identifiers),
258
+ keys: getKeys(identifiers),
259
+ answerFormat: "tex",
260
+ identifiers,
261
+ hint: getHint(identifiers),
262
+ correction: getCorrection(identifiers),
263
+ };
264
+ };
76
265
  const options = [
77
266
  {
78
- id: "functionType",
79
- label: "Type de fonction",
267
+ id: "functionTypes",
268
+ label: "Types de fonction",
80
269
  target: GeneratorOptionTarget.generation,
81
270
  type: GeneratorOptionType.multiselect,
82
- values: ["Affine", "Polynôme du second degré"],
83
- defaultValue: ["Affine", "Polynôme du second degré"],
271
+ values: [
272
+ "$ax+b$",
273
+ "$ax^2+bx+c$",
274
+ "$\\frac{k}{x}$",
275
+ "$\\frac{k}{x^2}$",
276
+ "$\\frac{ax+b}{cx+d}$",
277
+ ],
278
+ defaultValue: ["$ax+b$", "$ax^2+bx+c$", "$\\frac{k}{x}$"],
84
279
  },
85
280
  ];
86
281
  const validateOptions = (opts) => {
87
- if (!opts.functionType?.length)
282
+ if (!opts.functionTypes?.length)
88
283
  return {
89
284
  valid: false,
90
285
  message: "Veuillez choisir au moins un type de fonction.",
@@ -94,21 +289,10 @@ const validateOptions = (opts) => {
94
289
  message: "",
95
290
  };
96
291
  };
97
- const getQuestionFromIdentifiers = (identifiers) => {
98
- return {
99
- answer: getAnswer(identifiers),
100
- instruction: getInstruction(identifiers),
101
- keys: getKeys(identifiers),
102
- answerFormat: "tex",
103
- identifiers,
104
- hint: getHint(identifiers),
105
- correction: getCorrection(identifiers),
106
- };
107
- };
108
292
  export const averageRateOfChangeAlgebraicExpression = {
109
293
  id: "averageRateOfChangeAlgebraicExpression",
110
294
  connector: "=",
111
- label: "Donner l'expression algébrique du taux d'accroissement d'une fonction en fonction de $h$",
295
+ label: "Exprimer en fonction de $h$ le taux d'accroissement d'une fonction",
112
296
  isSingleStep: true,
113
297
  generator: (nb, opts) => getDistinctQuestions(() => getAverageRateOfChangeAlgebraicExpressionQuestion(opts), nb),
114
298
  qcmTimer: 60,
@@ -0,0 +1,13 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ type: number;
5
+ functionIds: NodeIdentifiers;
6
+ a: number;
7
+ };
8
+ type Options = {
9
+ functionTypes: string[];
10
+ };
11
+ export declare const expressFAPlusH: Exercise<Identifiers, Options>;
12
+ export {};
13
+ //# sourceMappingURL=expressFAPlusH.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expressFAPlusH.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivativeNumber/expressFAPlusH.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAU7C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,eAAe,CAAC;IAC7B,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA+LF,KAAK,OAAO,GAAG;IACb,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAoCF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAoBzD,CAAC"}
@@ -0,0 +1,225 @@
1
+ import { addValidProp, shuffleProps, GeneratorOptionTarget, GeneratorOptionType, 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 { round } from "../../../../math/utils/round.js";
7
+ import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
8
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
9
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
10
+ import { square } from "../../../../tree/nodes/operators/powerNode.js";
11
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
12
+ import { random } from "../../../../utils/alea/random.js";
13
+ import { doWhile } from "../../../../utils/doWhile.js";
14
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
15
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
16
+ const getPropositions = (n, { answer, ...identifiers }) => {
17
+ const propositions = [];
18
+ const { a, functionIds } = identifiers;
19
+ const fct = reifyAlgebraic(functionIds);
20
+ addValidProp(propositions, answer);
21
+ tryToAddWrongProp(propositions, fct
22
+ .toDetailedEvaluation({ x: a.toTree() })
23
+ .simplify({
24
+ towardsDistribute: true,
25
+ forbidFactorize: true,
26
+ })
27
+ .toTex());
28
+ tryToAddWrongProp(propositions, fct
29
+ .toDetailedEvaluation({ x: "h".toTree() })
30
+ .simplify({
31
+ towardsDistribute: true,
32
+ forbidFactorize: true,
33
+ })
34
+ .toTex());
35
+ let safeA = randint(-10, 10, [0]);
36
+ let isSafe = false;
37
+ let counter = 0;
38
+ while (!isSafe && counter < 100) {
39
+ counter++;
40
+ if (counter > 100) {
41
+ throw new Error("Too many iterations in getPropositions expressFAPlusH");
42
+ }
43
+ try {
44
+ fct.toDetailedEvaluation({ x: safeA.toTree() }).simplify();
45
+ isSafe = true;
46
+ }
47
+ catch (_e) {
48
+ safeA = randint(-10, 10, [0]);
49
+ }
50
+ }
51
+ tryToAddWrongProp(propositions, fct
52
+ .toDetailedEvaluation({ x: add(safeA, "h") })
53
+ .simplify({
54
+ towardsDistribute: true,
55
+ forbidFactorize: true,
56
+ })
57
+ .toTex());
58
+ return shuffleProps(propositions, n);
59
+ };
60
+ const getAnswer = (identifiers) => {
61
+ const { a, functionIds } = identifiers;
62
+ const fct = reifyAlgebraic(functionIds);
63
+ return fct
64
+ .toDetailedEvaluation({ x: add(a, "h") })
65
+ .simplify({ towardsDistribute: true, forbidFactorize: true })
66
+ .toTex();
67
+ };
68
+ const getInstruction = (identifiers) => {
69
+ const { a, functionIds } = identifiers;
70
+ const fct = reifyAlgebraic(functionIds);
71
+ return `On considère la fonction $f$ définie par :
72
+
73
+ $$
74
+ f(x) = ${fct.toTex()}
75
+ $$
76
+
77
+ Pour $h>0$, exprimer $f(${a}+h)$ en fonction de $h$.`;
78
+ };
79
+ const getHint = (identifiers) => {
80
+ const { a } = identifiers;
81
+ return `Il suffit de remplacer $x$ par $${a}+h$ dans l'expression algébrique de $f$, puis de simplifier si nécessaire.`;
82
+ };
83
+ const getCorrection = (identifiers) => {
84
+ const { a, functionIds } = identifiers;
85
+ const fct = reifyAlgebraic(functionIds);
86
+ return `On remplace $x$ par $${a}+h$ dans l'expression algébrique de $f$ :
87
+
88
+ ${alignTex([
89
+ [`f(${a}+h)`, "=", fct.toDetailedEvaluation({ x: add(a, "h") }).toTex()],
90
+ [
91
+ "",
92
+ "=",
93
+ fct
94
+ .toDetailedEvaluation({ x: add(a, "h") })
95
+ .simplify({ towardsDistribute: true, forbidFactorize: true })
96
+ .toTex(),
97
+ ],
98
+ ])}`;
99
+ };
100
+ const getKeys = () => {
101
+ return ["h"];
102
+ };
103
+ const isAnswerValid = (ans, { answer }) => {
104
+ try {
105
+ const parsed = parseAlgebraic(ans);
106
+ if (!parsed)
107
+ return false;
108
+ return (parsed
109
+ .simplify({ towardsDistribute: true, forbidFactorize: true })
110
+ .toTex() === answer);
111
+ }
112
+ catch (err) {
113
+ return handleVEAError(err);
114
+ }
115
+ };
116
+ const getExpressFaPlusHQuestion = (opts) => {
117
+ const defaultTypes = [
118
+ "$ax+b$",
119
+ "$ax^2+bx+c$",
120
+ "$\\frac{k}{x}$",
121
+ "$\\frac{k}{x^2}$",
122
+ "$\\frac{ax+b}{cx+d}$",
123
+ ];
124
+ const frenchType = random(opts?.functionTypes ?? defaultTypes);
125
+ const type = defaultTypes.indexOf(frenchType);
126
+ let functionIds = undefined;
127
+ let a = 0;
128
+ switch (type) {
129
+ case 0:
130
+ functionIds = AffineConstructor.random().toTree().toIdentifiers();
131
+ a = randint(-10, 10, [0]);
132
+ break;
133
+ case 1:
134
+ functionIds = TrinomConstructor.random().toTree().toIdentifiers();
135
+ a = randint(-10, 10, [0]);
136
+ break;
137
+ case 2:
138
+ a = randint(-10, 10, [0]);
139
+ functionIds = frac(randint(-10, 10, [0]), "x").toIdentifiers();
140
+ break;
141
+ case 3:
142
+ a = randint(-10, 10, [0]);
143
+ functionIds = frac(randint(-10, 10, [0]), square("x")).toIdentifiers();
144
+ break;
145
+ case 4:
146
+ default: {
147
+ const denum = AffineConstructor.random();
148
+ const num = doWhile(() => AffineConstructor.random(), (aff) => (denum.b === 0 && aff.b === 0) ||
149
+ round(aff.a / denum.a, 5) === round(aff.b / denum.b, 5));
150
+ a = randint(-10, 10, [denum.getRoot().value]);
151
+ functionIds = frac(num.toTree(), denum.toTree()).toIdentifiers();
152
+ break;
153
+ }
154
+ }
155
+ const identifiers = {
156
+ type,
157
+ functionIds,
158
+ a,
159
+ };
160
+ return getQuestionFromIdentifiers(identifiers);
161
+ };
162
+ const getQuestionFromIdentifiers = (identifiers) => {
163
+ return {
164
+ answer: getAnswer(identifiers),
165
+ instruction: getInstruction(identifiers),
166
+ keys: getKeys(identifiers),
167
+ answerFormat: "tex",
168
+ identifiers,
169
+ hint: getHint(identifiers),
170
+ correction: getCorrection(identifiers),
171
+ };
172
+ };
173
+ const options = [
174
+ {
175
+ id: "functionTypes",
176
+ label: "Types de fonction",
177
+ target: GeneratorOptionTarget.generation,
178
+ type: GeneratorOptionType.multiselect,
179
+ values: [
180
+ "$ax+b$",
181
+ "$ax^2+bx+c$",
182
+ "$\\frac{k}{x}$",
183
+ "$\\frac{k}{x^2}$",
184
+ "$\\frac{ax+b}{cx+d}$",
185
+ ],
186
+ defaultValue: [
187
+ "$ax+b$",
188
+ "$ax^2+bx+c$",
189
+ "$\\frac{k}{x}$",
190
+ "$\\frac{k}{x^2}$",
191
+ "$\\frac{ax+b}{cx+d}$",
192
+ ],
193
+ },
194
+ ];
195
+ const validateOptions = (opts) => {
196
+ if (!opts.functionTypes?.length)
197
+ return {
198
+ valid: false,
199
+ message: "Veuillez choisir au moins un type de fonction.",
200
+ };
201
+ return {
202
+ valid: true,
203
+ message: "",
204
+ };
205
+ };
206
+ export const expressFAPlusH = {
207
+ id: "expressFAPlusH",
208
+ connector: "=",
209
+ label: "Exprimer $f(a+h)$ en fonction de $h$ pour $f$ et $a$ donnés",
210
+ isSingleStep: true,
211
+ generator: (nb, opts) => getDistinctQuestions(() => getExpressFaPlusHQuestion(opts), nb),
212
+ qcmTimer: 60,
213
+ freeTimer: 60,
214
+ getPropositions,
215
+ isAnswerValid,
216
+ subject: "Mathématiques",
217
+ getInstruction,
218
+ getHint,
219
+ getCorrection,
220
+ getAnswer,
221
+ getQuestionFromIdentifiers,
222
+ hasHintAndCorrection: true,
223
+ options,
224
+ validateOptions,
225
+ };
@@ -0,0 +1,14 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ type: number;
5
+ rateIds: NodeIdentifiers;
6
+ a: number;
7
+ };
8
+ type Options = {
9
+ functionTypes: string[];
10
+ questionType: string;
11
+ };
12
+ export declare const findAverageRateLimit: Exercise<Identifiers, Options>;
13
+ export {};
14
+ //# sourceMappingURL=findAverageRateLimit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findAverageRateLimit.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivativeNumber/findAverageRateLimit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAK7C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,eAAe,CAAC;IACzB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA+IF,KAAK,OAAO,GAAG;IACb,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAmBF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAoB/D,CAAC"}