math-exercises 3.0.208 → 3.0.211

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 (101) hide show
  1. package/lib/exercises/math/arithmetic/congruenceBasicComputation.d.ts +8 -0
  2. package/lib/exercises/math/arithmetic/congruenceBasicComputation.d.ts.map +1 -0
  3. package/lib/exercises/math/arithmetic/congruenceBasicComputation.js +93 -0
  4. package/lib/exercises/math/arithmetic/index.d.ts +2 -0
  5. package/lib/exercises/math/arithmetic/index.d.ts.map +1 -0
  6. package/lib/exercises/math/arithmetic/index.js +1 -0
  7. package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.d.ts.map +1 -1
  8. package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.js +15 -0
  9. package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.d.ts.map +1 -1
  10. package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.js +15 -0
  11. package/lib/exercises/math/functions/continuity/index.d.ts +2 -0
  12. package/lib/exercises/math/functions/continuity/index.d.ts.map +1 -1
  13. package/lib/exercises/math/functions/continuity/index.js +2 -0
  14. package/lib/exercises/math/functions/continuity/pyContinuityBalayageInstructionCompletion.d.ts +11 -0
  15. package/lib/exercises/math/functions/continuity/pyContinuityBalayageInstructionCompletion.d.ts.map +1 -0
  16. package/lib/exercises/math/functions/continuity/pyContinuityBalayageInstructionCompletion.js +276 -0
  17. package/lib/exercises/math/functions/continuity/pyContinuityDichotomyInstructionCompletion.d.ts +10 -0
  18. package/lib/exercises/math/functions/continuity/pyContinuityDichotomyInstructionCompletion.d.ts.map +1 -0
  19. package/lib/exercises/math/functions/continuity/pyContinuityDichotomyInstructionCompletion.js +265 -0
  20. package/lib/exercises/math/functions/logarithm/log10Simplifying.d.ts.map +1 -1
  21. package/lib/exercises/math/functions/logarithm/log10Simplifying.js +72 -33
  22. package/lib/exercises/math/functions/logarithm/logEquation.d.ts.map +1 -1
  23. package/lib/exercises/math/functions/logarithm/logEquation.js +40 -2
  24. package/lib/exercises/math/functions/logarithm/logPowerEquation.d.ts.map +1 -1
  25. package/lib/exercises/math/functions/logarithm/logPowerEquation.js +55 -6
  26. package/lib/exercises/math/functions/logarithm/logSimplifiying.d.ts.map +1 -1
  27. package/lib/exercises/math/functions/logarithm/logSimplifiying.js +45 -5
  28. package/lib/exercises/math/index.d.ts +1 -0
  29. package/lib/exercises/math/index.d.ts.map +1 -1
  30. package/lib/exercises/math/index.js +1 -0
  31. package/lib/exercises/math/integration/algorithms/index.d.ts +2 -0
  32. package/lib/exercises/math/integration/algorithms/index.d.ts.map +1 -0
  33. package/lib/exercises/math/integration/algorithms/index.js +1 -0
  34. package/lib/exercises/math/integration/algorithms/pyIntegrationInstructionCompletion.d.ts +10 -0
  35. package/lib/exercises/math/integration/algorithms/pyIntegrationInstructionCompletion.d.ts.map +1 -0
  36. package/lib/exercises/math/integration/algorithms/pyIntegrationInstructionCompletion.js +273 -0
  37. package/lib/exercises/math/integration/index.d.ts +1 -0
  38. package/lib/exercises/math/integration/index.d.ts.map +1 -1
  39. package/lib/exercises/math/integration/index.js +1 -0
  40. package/lib/exercises/math/limits/algorithms/index.d.ts +2 -0
  41. package/lib/exercises/math/limits/algorithms/index.d.ts.map +1 -0
  42. package/lib/exercises/math/limits/algorithms/index.js +1 -0
  43. package/lib/exercises/math/limits/algorithms/pyLimitProgramExecution.d.ts +17 -0
  44. package/lib/exercises/math/limits/algorithms/pyLimitProgramExecution.d.ts.map +1 -0
  45. package/lib/exercises/math/limits/algorithms/pyLimitProgramExecution.js +353 -0
  46. package/lib/exercises/math/limits/index.d.ts +1 -0
  47. package/lib/exercises/math/limits/index.d.ts.map +1 -1
  48. package/lib/exercises/math/limits/index.js +1 -0
  49. package/lib/exercises/math/probaStat/density/findParamToMakeDensity.d.ts +8 -0
  50. package/lib/exercises/math/probaStat/density/findParamToMakeDensity.d.ts.map +1 -0
  51. package/lib/exercises/math/probaStat/density/findParamToMakeDensity.js +127 -0
  52. package/lib/exercises/math/probaStat/density/index.d.ts +2 -0
  53. package/lib/exercises/math/probaStat/density/index.d.ts.map +1 -0
  54. package/lib/exercises/math/probaStat/density/index.js +1 -0
  55. package/lib/exercises/math/probaStat/exponential/exponentialLawAverage.d.ts +7 -0
  56. package/lib/exercises/math/probaStat/exponential/exponentialLawAverage.d.ts.map +1 -0
  57. package/lib/exercises/math/probaStat/exponential/exponentialLawAverage.js +95 -0
  58. package/lib/exercises/math/probaStat/exponential/exponentialLawComputeIntervalProba.d.ts +9 -0
  59. package/lib/exercises/math/probaStat/exponential/exponentialLawComputeIntervalProba.d.ts.map +1 -0
  60. package/lib/exercises/math/probaStat/exponential/exponentialLawComputeIntervalProba.js +115 -0
  61. package/lib/exercises/math/probaStat/exponential/exponentialLawComputeProba.d.ts +8 -0
  62. package/lib/exercises/math/probaStat/exponential/exponentialLawComputeProba.d.ts.map +1 -0
  63. package/lib/exercises/math/probaStat/exponential/exponentialLawComputeProba.js +110 -0
  64. package/lib/exercises/math/probaStat/exponential/index.d.ts +4 -0
  65. package/lib/exercises/math/probaStat/exponential/index.d.ts.map +1 -0
  66. package/lib/exercises/math/probaStat/exponential/index.js +3 -0
  67. package/lib/exercises/math/probaStat/geometric/geometricLawAverage.d.ts +8 -0
  68. package/lib/exercises/math/probaStat/geometric/geometricLawAverage.d.ts.map +1 -0
  69. package/lib/exercises/math/probaStat/geometric/geometricLawAverage.js +124 -0
  70. package/lib/exercises/math/probaStat/geometric/geometricLawComputeProba.d.ts +9 -0
  71. package/lib/exercises/math/probaStat/geometric/geometricLawComputeProba.d.ts.map +1 -0
  72. package/lib/exercises/math/probaStat/geometric/geometricLawComputeProba.js +121 -0
  73. package/lib/exercises/math/probaStat/geometric/index.d.ts +3 -0
  74. package/lib/exercises/math/probaStat/geometric/index.d.ts.map +1 -0
  75. package/lib/exercises/math/probaStat/geometric/index.js +2 -0
  76. package/lib/exercises/math/probaStat/index.d.ts +4 -0
  77. package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
  78. package/lib/exercises/math/probaStat/index.js +4 -0
  79. package/lib/exercises/math/probaStat/stats2var/fineAdjustementExercise.d.ts.map +1 -1
  80. package/lib/exercises/math/probaStat/stats2var/fineAdjustementExercise.js +15 -0
  81. package/lib/exercises/math/probaStat/uniform/index.d.ts +3 -0
  82. package/lib/exercises/math/probaStat/uniform/index.d.ts.map +1 -0
  83. package/lib/exercises/math/probaStat/uniform/index.js +2 -0
  84. package/lib/exercises/math/probaStat/uniform/uniformAverage.d.ts +8 -0
  85. package/lib/exercises/math/probaStat/uniform/uniformAverage.d.ts.map +1 -0
  86. package/lib/exercises/math/probaStat/uniform/uniformAverage.js +100 -0
  87. package/lib/exercises/math/probaStat/uniform/uniformLawComputeProba.d.ts +10 -0
  88. package/lib/exercises/math/probaStat/uniform/uniformLawComputeProba.d.ts.map +1 -0
  89. package/lib/exercises/math/probaStat/uniform/uniformLawComputeProba.js +105 -0
  90. package/lib/index.d.ts +52 -1
  91. package/lib/index.d.ts.map +1 -1
  92. package/lib/latexTester.js +1 -0
  93. package/lib/tests/pdfs/formatMdToLatex.js +1 -1
  94. package/lib/tests/singleExo.test.js +2 -2
  95. package/lib/tree/nodes/functions/log10Node.d.ts +1 -0
  96. package/lib/tree/nodes/functions/log10Node.d.ts.map +1 -1
  97. package/lib/tree/nodes/functions/log10Node.js +12 -1
  98. package/lib/tree/nodes/functions/logNode.d.ts +1 -0
  99. package/lib/tree/nodes/functions/logNode.d.ts.map +1 -1
  100. package/lib/tree/nodes/functions/logNode.js +12 -1
  101. package/package.json +1 -1
@@ -2,9 +2,11 @@ import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../../exercis
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Rational } from "../../../../math/numbers/rationals/rational.js";
4
4
  import { randint } from "../../../../math/utils/random/randint.js";
5
- import { LogNode } from "../../../../tree/nodes/functions/logNode.js";
5
+ import { logn, LogNode } from "../../../../tree/nodes/functions/logNode.js";
6
6
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
7
7
  import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
8
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
9
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
8
10
  import { SubstractNode } from "../../../../tree/nodes/operators/substractNode.js";
9
11
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
10
12
  import { shuffle } from "../../../../utils/alea/shuffle.js";
@@ -21,7 +23,7 @@ const getStatementNode = (identifiers) => {
21
23
  }
22
24
  };
23
25
  const getInstruction = (identifiers) => {
24
- return `Écrire le nombre suivant sous la forme $\\ln\\left(a\\right)$ :
26
+ return `Écrire le nombre suivant sous la forme $\\ln\\left(a\\right)$, avec $a\\in \\mathbb{R}$ :
25
27
 
26
28
  $$
27
29
  ${getStatementNode(identifiers).toTex()}
@@ -36,15 +38,50 @@ const getAnswer = (identifiers) => {
36
38
  return new LogNode(new Rational(a, b).simplify().toTree()).toTex();
37
39
  }
38
40
  };
41
+ const getHint = () => {
42
+ return `Pour tous nombres réels $a$ et $b$ strictement positifs, on a :
43
+
44
+ - $\\ln(a) + \\ln(b) = \\ln(a\\times b)$
45
+ - $\\ln(a) - \\ln(b) = \\ln(\\frac{a}{b})$`;
46
+ };
47
+ const getCorrection = (identifiers) => {
48
+ const { a, b, pm } = identifiers;
49
+ if (pm === 1) {
50
+ return `On sait que pour tous nombres réels $a$ et $b$ strictement positifs, on a :
51
+
52
+ $$
53
+ \\ln(a) + \\ln(b) = \\ln(a\\times b)
54
+ $$
55
+
56
+ Ici on a donc :
57
+
58
+ $$
59
+ \\ln(${a}) + \\ln(${b}) = ${logn(multiply(a, b)).toSimplificationTex()}
60
+ $$`;
61
+ }
62
+ else {
63
+ return `On sait que pour tous nombres réels $a$ et $b$ strictement positifs, on a :
64
+
65
+ $$
66
+ \\ln(a) - \\ln(b) = \\ln(\\frac{a}{b})
67
+ $$
68
+
69
+ Ici on a donc :
70
+
71
+ $$
72
+ \\ln(${a}) - \\ln(${b}) = ${logn(frac(a, b)).toSimplificationTex()}
73
+ $$`;
74
+ }
75
+ };
39
76
  const getKeys = () => {
40
77
  return ["lnBrackets"];
41
78
  };
42
79
  const getExpSimplifiying = () => {
43
80
  const pm = coinFlip() ? 1 : -1;
44
- const a = randint(1, 10);
81
+ const a = randint(2, 10);
45
82
  let b;
46
83
  do {
47
- b = randint(1, 10);
84
+ b = randint(2, 10);
48
85
  } while (pm === -1 && a === b);
49
86
  const identifiers = { pm, a, b };
50
87
  return getQuestionFromIdentifiers(identifiers);
@@ -56,6 +93,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
56
93
  keys: getKeys(identifiers),
57
94
  answerFormat: "tex",
58
95
  identifiers,
96
+ hint: getHint(identifiers),
97
+ correction: getCorrection(identifiers),
59
98
  };
60
99
  return question;
61
100
  };
@@ -85,7 +124,7 @@ const isAnswerValid = (ans, { a, b, pm }) => {
85
124
  export const logSimplifiying = {
86
125
  id: "logSimplifiying",
87
126
  connector: "\\iff",
88
- label: "Simplifier des expressions avec $\\ln$",
127
+ label: "Utiliser la propriété algébrique du logarithme népérien $\\ln(a) \\pm \\ln(b) = \\ln(ab)$",
89
128
  isSingleStep: false,
90
129
  generator: (nb) => getDistinctQuestions(getExpSimplifiying, nb),
91
130
  qcmTimer: 60,
@@ -94,4 +133,5 @@ export const logSimplifiying = {
94
133
  isAnswerValid,
95
134
  subject: "Mathématiques",
96
135
  getQuestionFromIdentifiers,
136
+ hasHintAndCorrection: true,
97
137
  };
@@ -26,4 +26,5 @@ export * from "./tests/index.js";
26
26
  export * from "./pcExosInMath.js";
27
27
  export * from "./scratch/index.js";
28
28
  export * from "./integration/index.js";
29
+ export * from "./arithmetic/index.js";
29
30
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exercises/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exercises/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,uBAAuB,CAAC"}
@@ -27,3 +27,4 @@ export * from "./pcExosInMath.js";
27
27
  export * from "./scratch/index.js";
28
28
  export * from "./integration/index.js";
29
29
  // export * from "./_debug/index.js";
30
+ export * from "./arithmetic/index.js";
@@ -0,0 +1,2 @@
1
+ export * from "./pyIntegrationInstructionCompletion.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/integration/algorithms/index.ts"],"names":[],"mappings":"AAAA,cAAc,yCAAyC,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./pyIntegrationInstructionCompletion.js";
@@ -0,0 +1,10 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ nodeIdsInterval: NodeIdentifiers;
5
+ nodeIdsDistanceMax: NodeIdentifiers;
6
+ keyIncomplete: string;
7
+ };
8
+ export declare const pyIntegrationInstructionCompletion: Exercise<Identifiers>;
9
+ export {};
10
+ //# sourceMappingURL=pyIntegrationInstructionCompletion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pyIntegrationInstructionCompletion.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/integration/algorithms/pyIntegrationInstructionCompletion.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAoB7C,KAAK,WAAW,GAAG;IACjB,eAAe,EAAE,eAAe,CAAC;IACjC,kBAAkB,EAAE,eAAe,CAAC;IACpC,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAsUF,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CAAC,WAAW,CAgBpE,CAAC"}
@@ -0,0 +1,273 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randint } from "../../../../math/utils/random/randint.js";
4
+ import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
5
+ import { power } from "../../../../tree/nodes/operators/powerNode.js";
6
+ import { ClosureType } from "../../../../tree/nodes/sets/closure.js";
7
+ import { IntervalNode } from "../../../../tree/nodes/sets/intervalNode.js";
8
+ import { random } from "../../../../utils/alea/random.js";
9
+ const codify = (strPython) => {
10
+ return `\`\`\`python
11
+ ${strPython}
12
+ \`\`\``;
13
+ };
14
+ const codifyChunk = (strPython) => {
15
+ return `\`${strPython}\``;
16
+ };
17
+ const createStrPythonForNode = (node) => {
18
+ return node.toMathString().replaceAll("^", "**");
19
+ };
20
+ const getHydrated = (identifiers) => {
21
+ const { nodeIdsInterval, nodeIdsDistanceMax } = identifiers;
22
+ const nodeInterval = NodeConstructor.fromIdentifiers(nodeIdsInterval);
23
+ const nodeDistanceMax = NodeConstructor.fromIdentifiers(nodeIdsDistanceMax);
24
+ return {
25
+ nodeInterval,
26
+ nodeDistanceMax,
27
+ };
28
+ };
29
+ const _getStrPythonProgram = (identifiers) => {
30
+ const { nodeInterval, nodeDistanceMax } = getHydrated(identifiers);
31
+ const [strIntervalBoundA, strIntervalBoundB] = [
32
+ nodeInterval.a,
33
+ nodeInterval.b,
34
+ ].map(createStrPythonForNode);
35
+ const strDistanceMax = createStrPythonForNode(nodeDistanceMax);
36
+ return `def integral(f,a,b, precision):
37
+ k = 1
38
+ while True:
39
+ sr,sR = rectangles(f,a,b,k)
40
+ if(sR-sr < precision): #
41
+ return sr,sR
42
+ else:
43
+ k = k + 1 #
44
+
45
+ def rectangles(f,a,b,n):
46
+ sr, sR = 0,0 #
47
+ l = (b-a)/n #
48
+ for i in range(n): #
49
+ sr = sr + f(a + l * i) * l #
50
+ sR = sR + f(a + l * (i+1)) * l #
51
+ return sr,sR
52
+
53
+ sr,sR = integral(f,${strIntervalBoundA}, ${strIntervalBoundB},${strDistanceMax}) #
54
+ print(sr, "<=", I, "<=", sR)`;
55
+ };
56
+ const getStrPythonProgramComplete = (identifiers) => {
57
+ const identifiersTweaked = {
58
+ ...identifiers,
59
+ keyIncomplete: "",
60
+ };
61
+ return getStrPythonProgramIncomplete(identifiersTweaked);
62
+ };
63
+ const getStrPythonProgramIncomplete = (identifiers) => {
64
+ const { keyIncomplete } = identifiers;
65
+ const { strIntegralCondition, strIntegralElse, strRectanglesInitialization, strRectanglesL, strRectanglesLoop, strRectanglesSMin, strRectanglesSMax, strCallIntegral, } = Object.fromEntries(Object.entries(getDictStrCompletion(identifiers)).map(([key, str]) => key === keyIncomplete ? [key, "..."] : [key, str]));
66
+ return `def integral(f,a,b, precision):
67
+ k = 1
68
+ while True:
69
+ sr,sR = rectangles(f,a,b,k)
70
+ ${strIntegralCondition}
71
+ return sr,sR
72
+ else:
73
+ ${strIntegralElse}
74
+
75
+ def rectangles(f,a,b,n):
76
+ ${strRectanglesInitialization}
77
+ ${strRectanglesL}
78
+ ${strRectanglesLoop}
79
+ ${strRectanglesSMin}
80
+ ${strRectanglesSMax}
81
+ return sr,sR
82
+
83
+ ${strCallIntegral}
84
+ print(sr, "<=", I, "<=", sR)`;
85
+ };
86
+ const getDictStrCompletion = (identifiers) => {
87
+ const { nodeInterval, nodeDistanceMax } = getHydrated(identifiers);
88
+ const [strIntervalBoundA, strIntervalBoundB] = [
89
+ nodeInterval.a,
90
+ nodeInterval.b,
91
+ ].map(createStrPythonForNode);
92
+ const strDistanceMax = createStrPythonForNode(nodeDistanceMax);
93
+ return {
94
+ strIntegralCondition: `if(sR-sr < precision):`,
95
+ strIntegralElse: `k = k + 1`,
96
+ strRectanglesInitialization: `sr, sR = 0,0`,
97
+ strRectanglesL: `l = (b-a)/n`,
98
+ strRectanglesLoop: `for i in range(n):`,
99
+ strRectanglesSMin: `sr = sr + f(a + l * i) * l`,
100
+ strRectanglesSMax: `sR = sR + f(a + l * (i+1)) * l`,
101
+ strCallIntegral: `sr,sR = integral(f,${strIntervalBoundA}, ${strIntervalBoundB},${strDistanceMax})`,
102
+ };
103
+ };
104
+ const getInstruction = (identifiers) => {
105
+ const { nodeInterval, nodeDistanceMax } = getHydrated(identifiers);
106
+ return `On considère une fonction $f$ positive et strictement croissante,
107
+ dont on veut calculer $I$, l'intégrale de $f$ sur l'intervalle $${nodeInterval.toTex()}$
108
+ en utilisant la méthode des rectangles, avec une précision de $${nodeDistanceMax.toTex()}$.
109
+
110
+ Dans le programme suivant,
111
+ on suppose que l'on dispose d'une fonction ${codifyChunk("f")}
112
+ telle que ${codifyChunk("f(x)")} retourne $f(x)$.
113
+
114
+ Par quoi faut-il remplacer les pointillés dans le programme suivant pour qu'il affiche l'encadrement par les deux sommes de $n$ rectangles,
115
+ $n$ étant le nombre de rectangles à partir duquel l'écart entre les deux sommes
116
+ est strictement inférieur à $${nodeDistanceMax.toTex()}$ ?
117
+
118
+ ${codify(getStrPythonProgramIncomplete(identifiers))}
119
+
120
+ `;
121
+ };
122
+ const getAnswer = (identifiers) => {
123
+ const { keyIncomplete } = identifiers;
124
+ const dictStrCompletion = getDictStrCompletion(identifiers);
125
+ return codifyChunk(dictStrCompletion[keyIncomplete]);
126
+ };
127
+ const getHint = (identifiers) => {
128
+ const { keyIncomplete } = identifiers;
129
+ switch (keyIncomplete) {
130
+ case "strIntegralCondition":
131
+ return `Écris en Python "Si la différence de la somme des rectangles au-dessus de la courbe de $f$ avec la somme des rectangles au-dessous de la courbe de $f$ est inférieure à $precision$ alors".`;
132
+ case "strIntegralElse":
133
+ return `Si la condition n'est pas remplie, on augmente le nombre de rectangles de $1$.`;
134
+ case "strRectanglesInitialization":
135
+ return `Les sommes doivent être initialisées.`;
136
+ case "strRectanglesL":
137
+ return `Quelle est la largeur d'un rectangle ?`;
138
+ case "strRectanglesLoop":
139
+ return `Pour calculer les sommes, on part de la borne inférieure d'intégration et on se décale petit à petit.`;
140
+ case "strRectanglesSMin":
141
+ return `Pour calculer la somme des aires des rectangles au-dessous de la courbe, à chaque itération, on ajoute l'aire du rectangle "à gauche".`;
142
+ case "strRectanglesSMax":
143
+ return `Pour calculer la somme des aires des rectangles au-dessus de la courbe, à chaque itération, on ajoute l'aire du rectangle "à droite".`;
144
+ default:
145
+ throw new Error("Unsupported keyIncomplete: " + keyIncomplete);
146
+ }
147
+ };
148
+ const getCorrection = (identifiers) => {
149
+ return `Voici le programme complet :
150
+
151
+ ${codify(getStrPythonProgramComplete(identifiers))}
152
+
153
+ `;
154
+ };
155
+ const getPropositions = (n, { answer, ...identifiers }) => {
156
+ const propositions = [];
157
+ addValidProp(propositions, answer, "raw");
158
+ const { keyIncomplete } = identifiers;
159
+ switch (keyIncomplete) {
160
+ case "strIntegralCondition":
161
+ {
162
+ [
163
+ "if(sr-sR < precision):",
164
+ "if(sR-sr > precision):",
165
+ "if(sr-sR > precision):",
166
+ ].forEach((str) => tryToAddWrongProp(propositions, codifyChunk(str), "raw"));
167
+ }
168
+ break;
169
+ case "strIntegralElse":
170
+ {
171
+ ["k + 1", "n = n + 1", "n + 1"].forEach((str) => tryToAddWrongProp(propositions, codifyChunk(str), "raw"));
172
+ }
173
+ break;
174
+ case "strRectanglesInitialization":
175
+ {
176
+ [
177
+ "sr, sR = 1,1",
178
+ "sr,sR = f(a), f(a + (b-a)/n)",
179
+ "sr,sR = a, a + (b-a)/n",
180
+ ].forEach((str) => tryToAddWrongProp(propositions, codifyChunk(str), "raw"));
181
+ }
182
+ break;
183
+ case "strRectanglesL":
184
+ {
185
+ ["l = b-a", "l = (b-a)*n", "l = b-a/n"].forEach((str) => tryToAddWrongProp(propositions, codifyChunk(str), "raw"));
186
+ }
187
+ break;
188
+ case "strRectanglesLoop":
189
+ {
190
+ [
191
+ "for i in range(l):",
192
+ "for i in range(n+1):",
193
+ "for i in range(n-1):",
194
+ ].forEach((str) => tryToAddWrongProp(propositions, codifyChunk(str), "raw"));
195
+ }
196
+ break;
197
+ case "strRectanglesSMin":
198
+ {
199
+ [
200
+ "sr = sr + f(a + i) * l",
201
+ "sr = sr + f(a + l * i)",
202
+ "sr = sr + f(a + l) * i",
203
+ ].forEach((str) => tryToAddWrongProp(propositions, codifyChunk(str), "raw"));
204
+ }
205
+ break;
206
+ case "strRectanglesSMax":
207
+ {
208
+ [
209
+ "sR = f(a + l * (i+1)) * l",
210
+ "sR = sR + f(a + l * (i+1))",
211
+ "sR = sR + f(a + (l+1) * i) * (l+1)",
212
+ ].forEach((str) => tryToAddWrongProp(propositions, codifyChunk(str), "raw"));
213
+ }
214
+ break;
215
+ default:
216
+ throw new Error("Unsupported keyIncomplete: " + keyIncomplete);
217
+ }
218
+ return shuffleProps(propositions, n);
219
+ };
220
+ const createRandomIdentifiers = () => {
221
+ const nodeDistanceMax = power(10, randint(-3, 0));
222
+ const keyIncomplete = random([
223
+ "strIntegralCondition",
224
+ "strIntegralElse",
225
+ "strRectanglesInitialization",
226
+ "strRectanglesL",
227
+ "strRectanglesLoop",
228
+ "strRectanglesSMin",
229
+ "strRectanglesSMax",
230
+ // "strCallIntegral",
231
+ ]);
232
+ const nodeInterval = (() => {
233
+ const a = randint(-5, 5);
234
+ const b = a + randint(1, 5);
235
+ return new IntervalNode(a.toTree(), b.toTree(), ClosureType.FF);
236
+ })();
237
+ const identifiers = {
238
+ nodeIdsInterval: nodeInterval.toIdentifiers(),
239
+ nodeIdsDistanceMax: nodeDistanceMax.toIdentifiers(),
240
+ keyIncomplete,
241
+ };
242
+ return identifiers;
243
+ };
244
+ const getPyIntegrationInstructionCompletionQuestion = () => {
245
+ const identifiers = createRandomIdentifiers();
246
+ return getQuestionFromIdentifiers(identifiers);
247
+ };
248
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
249
+ const question = {
250
+ answer: getAnswer(identifiers, opts),
251
+ instruction: getInstruction(identifiers, opts),
252
+ keys: [],
253
+ answerFormat: "tex",
254
+ identifiers,
255
+ hint: getHint(identifiers, opts),
256
+ correction: getCorrection(identifiers, opts),
257
+ options: opts,
258
+ };
259
+ return question;
260
+ };
261
+ export const pyIntegrationInstructionCompletion = {
262
+ id: "pyIntegrationInstructionCompletion",
263
+ label: "Compléter un algorithme pour obtenir un encadrement d'une intégrale",
264
+ isSingleStep: true,
265
+ generator: (nb, opts) => getDistinctQuestions(() => getPyIntegrationInstructionCompletionQuestion(opts), nb),
266
+ qcmTimer: 60,
267
+ freeTimer: 60,
268
+ getPropositions,
269
+ subject: "Mathématiques",
270
+ getQuestionFromIdentifiers,
271
+ hasHintAndCorrection: true,
272
+ answerType: "QCU",
273
+ };
@@ -1,4 +1,5 @@
1
1
  export * from "./fromGraph/index.js";
2
2
  export * from "./fromExpr/index.js";
3
3
  export * from "./integralOfPiecewiseFunctionByUsingComputedIntegrals.js";
4
+ export * from "./algorithms/index.js";
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/integration/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AAEpC,cAAc,0DAA0D,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/integration/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AAEpC,cAAc,0DAA0D,CAAC;AAEzE,cAAc,uBAAuB,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from "./fromGraph/index.js";
2
2
  export * from "./fromExpr/index.js";
3
3
  export * from "./integralOfPiecewiseFunctionByUsingComputedIntegrals.js";
4
+ export * from "./algorithms/index.js";
@@ -0,0 +1,2 @@
1
+ export * from "./pyLimitProgramExecution.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/limits/algorithms/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./pyLimitProgramExecution.js";
@@ -0,0 +1,17 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ abscissaType: string;
5
+ imageType: string;
6
+ nodeIdsF: NodeIdentifiers;
7
+ nodeIdsAbscissa: NodeIdentifiers;
8
+ nodeIdsImage: NodeIdentifiers;
9
+ nodeIdsPrecision?: NodeIdentifiers;
10
+ };
11
+ type Options = {
12
+ abscissaType: string;
13
+ imageType: string;
14
+ };
15
+ export declare const pyLimitProgramExecution: Exercise<Identifiers, Options>;
16
+ export {};
17
+ //# sourceMappingURL=pyLimitProgramExecution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pyLimitProgramExecution.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/limits/algorithms/pyLimitProgramExecution.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AA4B7C,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,eAAe,CAAC;IAC1B,eAAe,EAAE,eAAe,CAAC;IACjC,YAAY,EAAE,eAAe,CAAC;IAC9B,gBAAgB,CAAC,EAAE,eAAe,CAAC;CACpC,CAAC;AA8VF,KAAK,OAAO,GAAG;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA+BF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiBlE,CAAC"}