math-exercises 3.0.172 → 3.0.173

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 (172) hide show
  1. package/lib/exercises/math/functions/trinoms/devForm/variationsFromAlgebricForm.d.ts.map +1 -1
  2. package/lib/exercises/math/functions/trinoms/devForm/variationsFromAlgebricForm.js +12 -0
  3. package/lib/exercises/math/functions/trinoms/parabole/index.d.ts +2 -0
  4. package/lib/exercises/math/functions/trinoms/parabole/index.d.ts.map +1 -1
  5. package/lib/exercises/math/functions/trinoms/parabole/index.js +2 -0
  6. package/lib/exercises/math/functions/trinoms/parabole/parabolaVarTable.d.ts +8 -0
  7. package/lib/exercises/math/functions/trinoms/parabole/parabolaVarTable.d.ts.map +1 -0
  8. package/lib/exercises/math/functions/trinoms/parabole/parabolaVarTable.js +106 -0
  9. package/lib/exercises/math/functions/trinoms/parabole/paraboleSolveGraphEquation.d.ts +14 -0
  10. package/lib/exercises/math/functions/trinoms/parabole/paraboleSolveGraphEquation.d.ts.map +1 -0
  11. package/lib/exercises/math/functions/trinoms/parabole/paraboleSolveGraphEquation.js +186 -0
  12. package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumTypeFromAlgebricForm.d.ts +6 -2
  13. package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumTypeFromAlgebricForm.d.ts.map +1 -1
  14. package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumTypeFromAlgebricForm.js +98 -13
  15. package/lib/exercises/math/geometry/lines/index.d.ts +1 -0
  16. package/lib/exercises/math/geometry/lines/index.d.ts.map +1 -1
  17. package/lib/exercises/math/geometry/lines/index.js +1 -0
  18. package/lib/exercises/math/geometry/lines/readLineNormalVectorOnGraph.d.ts +13 -0
  19. package/lib/exercises/math/geometry/lines/readLineNormalVectorOnGraph.d.ts.map +1 -0
  20. package/lib/exercises/math/geometry/lines/readLineNormalVectorOnGraph.js +195 -0
  21. package/lib/exercises/math/probaStat/randomVariable/index.d.ts +1 -0
  22. package/lib/exercises/math/probaStat/randomVariable/index.d.ts.map +1 -1
  23. package/lib/exercises/math/probaStat/randomVariable/index.js +1 -0
  24. package/lib/exercises/math/probaStat/randomVariable/missingValueInRandomVariableProbabilityLaw.d.ts +9 -0
  25. package/lib/exercises/math/probaStat/randomVariable/missingValueInRandomVariableProbabilityLaw.d.ts.map +1 -0
  26. package/lib/exercises/math/probaStat/randomVariable/missingValueInRandomVariableProbabilityLaw.js +119 -0
  27. package/lib/exercises/math/python/sequences/index.d.ts +8 -0
  28. package/lib/exercises/math/python/sequences/index.d.ts.map +1 -0
  29. package/lib/exercises/math/python/sequences/index.js +7 -0
  30. package/lib/exercises/math/python/sequences/pySequenceFactorialInstructionFalseOneOut.d.ts +11 -0
  31. package/lib/exercises/math/python/sequences/pySequenceFactorialInstructionFalseOneOut.d.ts.map +1 -0
  32. package/lib/exercises/math/python/sequences/pySequenceFactorialInstructionFalseOneOut.js +274 -0
  33. package/lib/exercises/math/python/sequences/pySequenceFirstTermsListInstructionCompletion.d.ts +12 -0
  34. package/lib/exercises/math/python/sequences/pySequenceFirstTermsListInstructionCompletion.d.ts.map +1 -0
  35. package/lib/exercises/math/python/sequences/pySequenceFirstTermsListInstructionCompletion.js +368 -0
  36. package/lib/exercises/math/python/sequences/pySequenceFirstTermsSumInstructionCompletion.d.ts +13 -0
  37. package/lib/exercises/math/python/sequences/pySequenceFirstTermsSumInstructionCompletion.d.ts.map +1 -0
  38. package/lib/exercises/math/python/sequences/pySequenceFirstTermsSumInstructionCompletion.js +254 -0
  39. package/lib/exercises/math/python/sequences/pySequenceProgramReading.d.ts +14 -0
  40. package/lib/exercises/math/python/sequences/pySequenceProgramReading.d.ts.map +1 -0
  41. package/lib/exercises/math/python/sequences/pySequenceProgramReading.js +365 -0
  42. package/lib/exercises/math/python/sequences/pySequenceTermForLoopInstructionCompletion.d.ts +11 -0
  43. package/lib/exercises/math/python/sequences/pySequenceTermForLoopInstructionCompletion.d.ts.map +1 -0
  44. package/lib/exercises/math/python/sequences/pySequenceTermForLoopInstructionCompletion.js +298 -0
  45. package/lib/exercises/math/python/sequences/pySequenceTermFromFunctionCallInstructionCompletion.d.ts +12 -0
  46. package/lib/exercises/math/python/sequences/pySequenceTermFromFunctionCallInstructionCompletion.d.ts.map +1 -0
  47. package/lib/exercises/math/python/sequences/pySequenceTermFromFunctionCallInstructionCompletion.js +408 -0
  48. package/lib/exercises/math/python/sequences/pySequenceThresholdInstructionCompletion.d.ts +17 -0
  49. package/lib/exercises/math/python/sequences/pySequenceThresholdInstructionCompletion.d.ts.map +1 -0
  50. package/lib/exercises/math/python/sequences/pySequenceThresholdInstructionCompletion.js +498 -0
  51. package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormulaFromTwoTerms.d.ts +12 -0
  52. package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormulaFromTwoTerms.d.ts.map +1 -0
  53. package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormulaFromTwoTerms.js +191 -0
  54. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindExplicitFormulaFromSituation.d.ts +14 -0
  55. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindExplicitFormulaFromSituation.d.ts.map +1 -0
  56. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindExplicitFormulaFromSituation.js +153 -0
  57. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.d.ts +15 -0
  58. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.d.ts.map +1 -0
  59. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.js +184 -0
  60. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRecurrenceFormulaFromSituation.d.ts +14 -0
  61. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRecurrenceFormulaFromSituation.d.ts.map +1 -0
  62. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRecurrenceFormulaFromSituation.js +210 -0
  63. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindTermFromSituation.d.ts +15 -0
  64. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindTermFromSituation.d.ts.map +1 -0
  65. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindTermFromSituation.js +161 -0
  66. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.d.ts +17 -0
  67. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.d.ts.map +1 -0
  68. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.js +188 -0
  69. package/lib/exercises/math/sequences/arithmetic/situations/index.d.ts +6 -0
  70. package/lib/exercises/math/sequences/arithmetic/situations/index.d.ts.map +1 -0
  71. package/lib/exercises/math/sequences/arithmetic/situations/index.js +5 -0
  72. package/lib/exercises/math/sequences/arithmetic/sum/arithmeticComputeSumWithDots.d.ts +15 -0
  73. package/lib/exercises/math/sequences/arithmetic/sum/arithmeticComputeSumWithDots.d.ts.map +1 -0
  74. package/lib/exercises/math/sequences/arithmetic/sum/arithmeticComputeSumWithDots.js +233 -0
  75. package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSum.d.ts +13 -0
  76. package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSum.d.ts.map +1 -0
  77. package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSum.js +111 -0
  78. package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSumThreshold.d.ts +13 -0
  79. package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSumThreshold.d.ts.map +1 -0
  80. package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSumThreshold.js +216 -0
  81. package/lib/exercises/math/sequences/arithmetic/sum/firstIntegersSum.d.ts +7 -0
  82. package/lib/exercises/math/sequences/arithmetic/sum/firstIntegersSum.d.ts.map +1 -0
  83. package/lib/exercises/math/sequences/arithmetic/sum/firstIntegersSum.js +94 -0
  84. package/lib/exercises/math/sequences/arithmetic/sum/index.d.ts +5 -0
  85. package/lib/exercises/math/sequences/arithmetic/sum/index.d.ts.map +1 -0
  86. package/lib/exercises/math/sequences/arithmetic/sum/index.js +4 -0
  87. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.d.ts +14 -0
  88. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.d.ts.map +1 -0
  89. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.js +301 -0
  90. package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoTerms.d.ts +15 -0
  91. package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoTerms.d.ts.map +1 -0
  92. package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoTerms.js +260 -0
  93. package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.d.ts +14 -0
  94. package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.d.ts.map +1 -0
  95. package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.js +186 -0
  96. package/lib/exercises/math/sequences/geometric/situations/geometricFindRankFromSituation.d.ts +15 -0
  97. package/lib/exercises/math/sequences/geometric/situations/geometricFindRankFromSituation.d.ts.map +1 -0
  98. package/lib/exercises/math/sequences/geometric/situations/geometricFindRankFromSituation.js +142 -0
  99. package/lib/exercises/math/sequences/geometric/situations/geometricFindRecurrenceFormulaFromSituation.d.ts +14 -0
  100. package/lib/exercises/math/sequences/geometric/situations/geometricFindRecurrenceFormulaFromSituation.d.ts.map +1 -0
  101. package/lib/exercises/math/sequences/geometric/situations/geometricFindRecurrenceFormulaFromSituation.js +205 -0
  102. package/lib/exercises/math/sequences/geometric/situations/geometricFindTermFromSituation.d.ts +15 -0
  103. package/lib/exercises/math/sequences/geometric/situations/geometricFindTermFromSituation.d.ts.map +1 -0
  104. package/lib/exercises/math/sequences/geometric/situations/geometricFindTermFromSituation.js +208 -0
  105. package/lib/exercises/math/sequences/geometric/situations/geometricFindThresholdFromSituation.d.ts +17 -0
  106. package/lib/exercises/math/sequences/geometric/situations/geometricFindThresholdFromSituation.d.ts.map +1 -0
  107. package/lib/exercises/math/sequences/geometric/situations/geometricFindThresholdFromSituation.js +152 -0
  108. package/lib/exercises/math/sequences/geometric/situations/index.d.ts +4 -0
  109. package/lib/exercises/math/sequences/geometric/situations/index.d.ts.map +1 -0
  110. package/lib/exercises/math/sequences/geometric/situations/index.js +5 -0
  111. package/lib/exercises/math/sequences/geometric/sum/geometricComputeSumWithDots.d.ts +15 -0
  112. package/lib/exercises/math/sequences/geometric/sum/geometricComputeSumWithDots.d.ts.map +1 -0
  113. package/lib/exercises/math/sequences/geometric/sum/geometricComputeSumWithDots.js +248 -0
  114. package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsGeneralSum.d.ts +14 -0
  115. package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsGeneralSum.d.ts.map +1 -0
  116. package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsGeneralSum.js +126 -0
  117. package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsSum.d.ts +8 -0
  118. package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsSum.d.ts.map +1 -0
  119. package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsSum.js +91 -0
  120. package/lib/exercises/math/sequences/geometric/sum/index.d.ts +4 -0
  121. package/lib/exercises/math/sequences/geometric/sum/index.d.ts.map +1 -0
  122. package/lib/exercises/math/sequences/geometric/sum/index.js +3 -0
  123. package/lib/exercises/math/sequences/seqArithmGeom/index.d.ts +2 -0
  124. package/lib/exercises/math/sequences/seqArithmGeom/index.d.ts.map +1 -0
  125. package/lib/exercises/math/sequences/seqArithmGeom/index.js +1 -0
  126. package/lib/exercises/math/sequences/seqArithmGeom/seqArithmGeomRecurrenceFormulaUsage.d.ts +14 -0
  127. package/lib/exercises/math/sequences/seqArithmGeom/seqArithmGeomRecurrenceFormulaUsage.d.ts.map +1 -0
  128. package/lib/exercises/math/sequences/seqArithmGeom/seqArithmGeomRecurrenceFormulaUsage.js +202 -0
  129. package/lib/exercises/options/optionFirstTermRankOne.d.ts +16 -0
  130. package/lib/exercises/options/optionFirstTermRankOne.d.ts.map +1 -0
  131. package/lib/exercises/options/optionFirstTermRankOne.js +17 -0
  132. package/lib/exercises/options/optionIsUsePythonDef.d.ts +16 -0
  133. package/lib/exercises/options/optionIsUsePythonDef.d.ts.map +1 -0
  134. package/lib/exercises/options/optionIsUsePythonDef.js +17 -0
  135. package/lib/exercises/options/optionIsWithSuperfluousData.d.ts +16 -0
  136. package/lib/exercises/options/optionIsWithSuperfluousData.d.ts.map +1 -0
  137. package/lib/exercises/options/optionIsWithSuperfluousData.js +17 -0
  138. package/lib/exercises/utils/geogebra/toGGBCommandsProps.d.ts +1 -0
  139. package/lib/exercises/utils/geogebra/toGGBCommandsProps.d.ts.map +1 -1
  140. package/lib/exercises/vea/colinearVectorVEA.d.ts +2 -0
  141. package/lib/exercises/vea/colinearVectorVEA.d.ts.map +1 -0
  142. package/lib/exercises/vea/colinearVectorVEA.js +11 -0
  143. package/lib/exercises/vea/varLineVEA.d.ts.map +1 -1
  144. package/lib/exercises/vea/varLineVEA.js +5 -2
  145. package/lib/index.d.ts +25 -2
  146. package/lib/index.d.ts.map +1 -1
  147. package/lib/math/geometry/line.d.ts +1 -1
  148. package/lib/math/geometry/line.d.ts.map +1 -1
  149. package/lib/math/geometry/line.js +3 -3
  150. package/lib/math/geometry/point.d.ts +1 -1
  151. package/lib/math/geometry/point.d.ts.map +1 -1
  152. package/lib/math/geometry/point.js +4 -1
  153. package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts +53 -0
  154. package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts.map +1 -0
  155. package/lib/math/utils/sequences/situations/seqArithmeticSituations.js +1928 -0
  156. package/lib/math/utils/sequences/situations/seqArithmeticUtils.d.ts +15 -0
  157. package/lib/math/utils/sequences/situations/seqArithmeticUtils.d.ts.map +1 -0
  158. package/lib/math/utils/sequences/situations/seqArithmeticUtils.js +136 -0
  159. package/lib/math/utils/sequences/situations/seqGeometricSituations.d.ts +42 -0
  160. package/lib/math/utils/sequences/situations/seqGeometricSituations.d.ts.map +1 -0
  161. package/lib/math/utils/sequences/situations/seqGeometricSituations.js +932 -0
  162. package/lib/math/utils/sequences/situations/seqGeometricUtils.d.ts +12 -0
  163. package/lib/math/utils/sequences/situations/seqGeometricUtils.d.ts.map +1 -0
  164. package/lib/math/utils/sequences/situations/seqGeometricUtils.js +90 -0
  165. package/lib/tests/exosTest.d.ts.map +1 -1
  166. package/lib/tests/exosTest.js +0 -2
  167. package/lib/tree/nodes/operators/binomialCoefficientNode.d.ts +3 -3
  168. package/lib/tree/nodes/operators/binomialCoefficientNode.d.ts.map +1 -1
  169. package/lib/tree/nodes/operators/binomialCoefficientNode.js +6 -3
  170. package/lib/tree/parsers/vectorParser.d.ts.map +1 -1
  171. package/lib/tree/parsers/vectorParser.js +8 -0
  172. package/package.json +1 -1
@@ -0,0 +1,248 @@
1
+ import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
+ import { getOptionFirstTermRankOneStuff, } from "../../../../../exercises/options/optionFirstTermRankOne.js";
3
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
4
+ import { numberVEA } from "../../../../../exercises/vea/numberVEA.js";
5
+ import { randint } from "../../../../../math/utils/random/randint.js";
6
+ import { frac } from "../../../../../tree/nodes/operators/fractionNode.js";
7
+ import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
8
+ import { power } from "../../../../../tree/nodes/operators/powerNode.js";
9
+ import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
10
+ import { coinFlip } from "../../../../../utils/alea/coinFlip.js";
11
+ import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
12
+ import { alignTex } from "../../../../../utils/latex/alignTex.js";
13
+ const strForValue = (v) => {
14
+ return v < 0 ? `(${v.frenchify()})` : `${v.frenchify()}`;
15
+ };
16
+ const valueForRank = (initial, reason, rank) => {
17
+ return initial * Math.pow(reason, rank);
18
+ };
19
+ const strSumWithDots = (initial, reason, firstRank, lowRankDots, highRankDots, lastRank) => {
20
+ const arrRankStart = [...Array(lowRankDots - firstRank).keys()].map((i) => i + firstRank);
21
+ const arrRankEnd = [...Array(lastRank - highRankDots).keys()].map((i) => i + highRankDots + 1);
22
+ const [arrValueStart, arrValueEnd] = [arrRankStart, arrRankEnd].map((arrRank) => arrRank.map((rank) => strForValue(valueForRank(initial, reason, rank))));
23
+ const [strStart, strEnd] = [arrValueStart, arrValueEnd].map((arrValue) => arrValue.join(" + "));
24
+ const strFlat = [strStart, strEnd].join(` + \\ldots + `);
25
+ const maxStrLength = 35;
26
+ if (strFlat.length < maxStrLength) {
27
+ return `
28
+
29
+ $$
30
+ ${strFlat}
31
+ $$
32
+
33
+ `;
34
+ }
35
+ else {
36
+ return `
37
+
38
+ $$
39
+ ${strStart}
40
+ $$
41
+
42
+ $$
43
+ + \\ldots
44
+ $$
45
+
46
+ $$
47
+ + \\ ${strEnd}
48
+ $$
49
+
50
+ `;
51
+ }
52
+ };
53
+ const getInstruction = (identifiers, optsIn) => {
54
+ const opts = optsIn ?? optsDefault;
55
+ const { isGiveCount } = opts;
56
+ const firstRank = opts.firstTermRankOne ? 1 : 0;
57
+ const { initial, reason, nbTerms, lowRankDots, highRankDots } = identifiers;
58
+ const lastRank = firstRank + nbTerms - 1;
59
+ return `Soit $u$ une suite géométrique.
60
+
61
+ Calculer la somme des premiers termes de $u$ ${isGiveCount
62
+ ? `(la somme contient en tout $${nbTerms.frenchify()}$ termes)`
63
+ : ""}:
64
+
65
+ ${strSumWithDots(initial, reason, firstRank, lowRankDots, highRankDots, lastRank)}
66
+
67
+ `;
68
+ };
69
+ const getAnswerNode = (identifiers, opts) => {
70
+ const firstRank = opts.firstTermRankOne ? 1 : 0;
71
+ const { initial, reason, nbTerms } = identifiers;
72
+ const firstValue = valueForRank(initial, reason, firstRank);
73
+ const nodeAnswer = multiply(firstValue, frac(substract(1, power(reason, nbTerms)), substract(1, reason)));
74
+ return nodeAnswer;
75
+ };
76
+ const getAnswer = (identifiers, optsIn) => {
77
+ const opts = optsIn ?? optsDefault;
78
+ return getAnswerNode(identifiers, opts).evaluate().frenchify();
79
+ };
80
+ const getHint = (_, optsIn) => {
81
+ const opts = optsIn ?? optsDefault;
82
+ const { isGiveCount } = opts;
83
+ return `La somme $S$ des $n$ premiers termes d'une suite géométrique s'obtient par la formule :
84
+
85
+ $$
86
+ S = {1^{\\text{er}}\\text{terme}} \\times \\frac{1 - q^n}{1 - q}
87
+ $$
88
+
89
+ ${!isGiveCount
90
+ ? "Il te faut donc déterminer combien il y a de termes dans la somme donnée."
91
+ : ""}`;
92
+ };
93
+ const getCorrection = (identifiers, optsIn) => {
94
+ const opts = optsIn ?? optsDefault;
95
+ const { isGiveCount } = opts;
96
+ const firstRank = opts.firstTermRankOne ? 1 : 0;
97
+ const { initial, nbTerms, reason } = identifiers;
98
+ const firstValue = valueForRank(initial, reason, firstRank);
99
+ const lastRank = firstRank + nbTerms - 1;
100
+ const lastValue = valueForRank(initial, reason, lastRank);
101
+ const answerNode = getAnswerNode(identifiers, opts);
102
+ return `La somme $S$ des $n$ premiers termes d'une suite géométrique s'obtient par la formule :
103
+
104
+ $$
105
+ S = {1^{\\text{er}}\\text{terme}} \\times \\frac{1 - q^n}{1 - q}
106
+ $$
107
+
108
+ On calcule la raison de la suite :
109
+
110
+ ${alignTex([
111
+ [
112
+ "q",
113
+ "=",
114
+ `\\frac{u_{${(firstRank + 1).frenchify()}}}{u_{${firstRank.frenchify()}}}`,
115
+ ],
116
+ [
117
+ "q",
118
+ "=",
119
+ `\\frac{${strForValue(valueForRank(initial, reason, firstRank + 1))}}{${strForValue(valueForRank(initial, reason, firstRank))}}`,
120
+ ],
121
+ ["q", "=", `${reason.frenchify()}`],
122
+ ])}
123
+
124
+ ${(() => {
125
+ if (isGiveCount) {
126
+ return "";
127
+ }
128
+ else {
129
+ return `Il faut maintenant déterminer combien il y a de termes en tout.
130
+
131
+ ${alignTex([
132
+ [
133
+ "\\text{dernier terme}",
134
+ "=",
135
+ `{1^{\\text{er}}\\text{terme}} \\times q^{n-1}`,
136
+ ],
137
+ [
138
+ "\\lvert \\text{dernier terme} \\rvert",
139
+ "=",
140
+ `\\lvert {1^{\\text{er}}\\text{terme}} \\rvert \\times {\\lvert q \\rvert}^{n-1}`,
141
+ ],
142
+ ])}
143
+
144
+ ${alignTex([
145
+ [
146
+ "n",
147
+ "=",
148
+ `\\frac{\\ln{\\lvert${strForValue(lastValue)}\\rvert} - \\ln{\\lvert${strForValue(firstValue)}\\rvert}}{\\ln{\\lvert${reason.frenchify()}\\rvert}} + 1`,
149
+ ],
150
+ ["n", "=", `${nbTerms.frenchify()}`],
151
+ ])}
152
+
153
+ `;
154
+ }
155
+ })()}
156
+
157
+ La somme des $${nbTerms}$ premiers termes de $u$ vaut donc :
158
+
159
+ $$
160
+ ${answerNode.toTex({ forceParenthesis: true })} = ${answerNode
161
+ .evaluate()
162
+ .frenchify()}
163
+ $$`;
164
+ };
165
+ const getPropositions = (n, { answer }, optsIn) => {
166
+ const opts = optsIn ?? optsDefault;
167
+ const propositions = [];
168
+ addValidProp(propositions, answer);
169
+ propWhile(propositions, n, () => {
170
+ const identifiersWrong = createRandomIdentifiers(opts);
171
+ tryToAddWrongProp(propositions, getAnswer(identifiersWrong, opts));
172
+ });
173
+ return shuffleProps(propositions, n);
174
+ };
175
+ const isAnswerValid = (studentAns, { answer }) => {
176
+ try {
177
+ return numberVEA(studentAns, answer);
178
+ }
179
+ catch (err) {
180
+ return handleVEAError(err);
181
+ }
182
+ };
183
+ const createRandomIdentifiers = (opts) => {
184
+ const firstRank = opts.firstTermRankOne ? 1 : 0;
185
+ const initial = randint(-9, 10, [0]);
186
+ const signReason = coinFlip() ? 1 : -1;
187
+ const reason = signReason * randint(2, 6);
188
+ const nbTerms = randint(7, 15);
189
+ const minRankDots = firstRank + 2;
190
+ const lastRank = firstRank + nbTerms - 1;
191
+ const lowRankDots = randint(minRankDots, Math.min(minRankDots + randint(1, 3), lastRank));
192
+ const highRankDots = randint(Math.max(lastRank - randint(1, 3), lowRankDots), lastRank);
193
+ const identifiers = {
194
+ initial,
195
+ reason,
196
+ nbTerms,
197
+ lowRankDots,
198
+ highRankDots,
199
+ };
200
+ return identifiers;
201
+ };
202
+ const getGeometricComputeSumWithDotsQuestion = (optsIn) => {
203
+ const opts = optsIn ?? optsDefault;
204
+ const identifiers = createRandomIdentifiers(opts);
205
+ return getQuestionFromIdentifiers(identifiers, opts);
206
+ };
207
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
208
+ const question = {
209
+ answer: getAnswer(identifiers, opts),
210
+ instruction: getInstruction(identifiers, opts),
211
+ keys: [],
212
+ answerFormat: "tex",
213
+ identifiers,
214
+ hint: getHint(identifiers, opts),
215
+ correction: getCorrection(identifiers, opts),
216
+ options: opts,
217
+ };
218
+ return question;
219
+ };
220
+ const { optsDefaultFirstTermRankOne, generatorOptionFirstTermRankOne } = getOptionFirstTermRankOneStuff(false);
221
+ const optsDefault = Object.assign({}, optsDefaultFirstTermRankOne, {
222
+ isGiveCount: true,
223
+ });
224
+ const options = [
225
+ generatorOptionFirstTermRankOne,
226
+ {
227
+ id: "isGiveCount",
228
+ label: "Donner $n$",
229
+ target: GeneratorOptionTarget.generation,
230
+ type: GeneratorOptionType.checkbox,
231
+ defaultValue: optsDefault.isGiveCount,
232
+ },
233
+ ];
234
+ export const geometricComputeSumWithDots = {
235
+ id: "geometricComputeSumWithDots",
236
+ connector: "=",
237
+ label: "Calculer une somme donnée avec $\\ldots$ (suite géométrique)",
238
+ isSingleStep: true,
239
+ generator: (nb, opts) => getDistinctQuestions(() => getGeometricComputeSumWithDotsQuestion(opts), nb),
240
+ qcmTimer: 60,
241
+ freeTimer: 60,
242
+ getPropositions,
243
+ isAnswerValid,
244
+ subject: "Mathématiques",
245
+ hasHintAndCorrection: true,
246
+ getQuestionFromIdentifiers,
247
+ options,
248
+ };
@@ -0,0 +1,14 @@
1
+ import { Exercise } from "../../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ firstRank: number;
4
+ firstValue: number;
5
+ reason: number;
6
+ nbTerms: number;
7
+ };
8
+ type Options = {
9
+ positiveReason: boolean;
10
+ firstRankOne: boolean;
11
+ };
12
+ export declare const geometricFirstTermsGeneralSum: Exercise<Identifiers, Options>;
13
+ export {};
14
+ //# sourceMappingURL=geometricFirstTermsGeneralSum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometricFirstTermsGeneralSum.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/geometric/sum/geometricFirstTermsGeneralSum.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAkHF,KAAK,OAAO,GAAG;IACb,cAAc,EAAE,OAAO,CAAC;IACxB,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAkBF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkBxE,CAAC"}
@@ -0,0 +1,126 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, propWhile, GeneratorOptionTarget, GeneratorOptionType, } from "../../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randint } from "../../../../../math/utils/random/randint.js";
4
+ import { frac } from "../../../../../tree/nodes/operators/fractionNode.js";
5
+ import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
6
+ import { power } from "../../../../../tree/nodes/operators/powerNode.js";
7
+ import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
8
+ import { random } from "../../../../../utils/alea/random.js";
9
+ import { alignTex } from "../../../../../utils/latex/alignTex.js";
10
+ const getHint = () => {
11
+ return `On utilise la formule :
12
+
13
+ $$
14
+ S = \\text{premier terme} \\times \\frac{1-\\text{raison}^{\\text{nombre de termes}}}{1-\\text{raison}}
15
+ $$`;
16
+ };
17
+ const getCorrection = (identifiers) => {
18
+ const { firstValue, nbTerms, reason } = identifiers;
19
+ return `On utilise la formule :
20
+
21
+ $$
22
+ S = \\text{premier terme} \\times \\frac{1-\\text{raison}^{\\text{nombre de termes}}}{1-\\text{raison}}
23
+ $$
24
+
25
+ Ici, la raison est $${reason}$, le premier terme est $${firstValue}$ et le nombre de termes est $${nbTerms}$.
26
+
27
+ On a donc :
28
+
29
+ ${alignTex([
30
+ [
31
+ "S",
32
+ "=",
33
+ multiply(firstValue, frac(substract(1, power(reason, nbTerms)), substract(1, reason))).toTex(),
34
+ ],
35
+ [
36
+ "",
37
+ "=",
38
+ multiply(firstValue, frac(substract(1, power(reason, nbTerms)).simplify({
39
+ calculatePowers: true,
40
+ }), substract(1, reason).simplify())).toTex(),
41
+ ],
42
+ ["", "=", getAnswer(identifiers)],
43
+ ])}`;
44
+ };
45
+ const getInstruction = (identifiers) => {
46
+ const { firstRank, firstValue, reason, nbTerms } = identifiers;
47
+ return `Soit $u$ une suite géométrique de premier terme $u_${firstRank} = ${firstValue}$ et de raison $${reason}$.
48
+
49
+ Calculer la somme des $${nbTerms}$ premiers termes de $u$.`;
50
+ };
51
+ const getAnswer = (identifiers) => {
52
+ const { firstValue, reason, nbTerms } = identifiers;
53
+ const answer = (firstValue * (1 - Math.pow(reason, nbTerms))) / (1 - reason);
54
+ return answer.frenchify();
55
+ };
56
+ const getGeometricFirstTermsGeneralSumQuestion = (opts) => {
57
+ const firstRank = opts?.firstRankOne ? 1 : random([0, 1]);
58
+ const firstValue = randint(-9, 10, [0]);
59
+ const reason = opts?.positiveReason ? randint(2, 5) : randint(-5, 5, [0, 1]);
60
+ const nbTerms = randint(4, 9);
61
+ const identifiers = {
62
+ firstRank,
63
+ firstValue,
64
+ reason,
65
+ nbTerms,
66
+ };
67
+ return getQuestionFromIdentifiers(identifiers, opts);
68
+ };
69
+ const getQuestionFromIdentifiers = (identifiers) => {
70
+ const question = {
71
+ answer: getAnswer(identifiers),
72
+ instruction: getInstruction(identifiers),
73
+ keys: [],
74
+ answerFormat: "tex",
75
+ identifiers,
76
+ hint: getHint(identifiers),
77
+ correction: getCorrection(identifiers),
78
+ };
79
+ return question;
80
+ };
81
+ const getPropositions = (n, { answer, firstValue, reason }) => {
82
+ const propositions = [];
83
+ addValidProp(propositions, answer);
84
+ propWhile(propositions, n, () => {
85
+ const fake = (firstValue *
86
+ (1 -
87
+ Math.pow(reason === -1 ? randint(2, 5) : reason, randint(3, 10)))) /
88
+ (1 - reason);
89
+ tryToAddWrongProp(propositions, fake.frenchify());
90
+ });
91
+ return shuffleProps(propositions, n);
92
+ };
93
+ const isAnswerValid = (ans, { answer }) => {
94
+ return ans === answer;
95
+ };
96
+ const options = [
97
+ {
98
+ id: "positiveReason",
99
+ label: "Utiliser des raisons positives",
100
+ target: GeneratorOptionTarget.generation,
101
+ type: GeneratorOptionType.checkbox,
102
+ defaultValue: false,
103
+ },
104
+ {
105
+ id: "firstRankOne",
106
+ label: "Toujours utiliser $u_1$ comme premier terme",
107
+ target: GeneratorOptionTarget.generation,
108
+ type: GeneratorOptionType.checkbox,
109
+ defaultValue: false,
110
+ },
111
+ ];
112
+ export const geometricFirstTermsGeneralSum = {
113
+ id: "geometricFirstTermsGeneralSum",
114
+ connector: "=",
115
+ label: "Somme des termes d'une suite géométrique (cas général)",
116
+ isSingleStep: true,
117
+ generator: (nb, opts) => getDistinctQuestions(() => getGeometricFirstTermsGeneralSumQuestion(opts), nb),
118
+ qcmTimer: 60,
119
+ freeTimer: 60,
120
+ options,
121
+ getPropositions,
122
+ isAnswerValid,
123
+ subject: "Mathématiques",
124
+ getQuestionFromIdentifiers,
125
+ hasHintAndCorrection: true,
126
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ raison: number;
4
+ final: number;
5
+ };
6
+ export declare const geometricFirstTermsSum: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=geometricFirstTermsSum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometricFirstTermsSum.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/geometric/sum/geometricFirstTermsSum.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AA2FF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAgBxD,CAAC"}
@@ -0,0 +1,91 @@
1
+ import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randint } from "../../../../../math/utils/random/randint.js";
4
+ import { shuffle } from "../../../../../utils/alea/shuffle.js";
5
+ import { alignTex } from "../../../../../utils/latex/alignTex.js";
6
+ const getInstruction = (identifiers) => {
7
+ const { raison, final } = identifiers;
8
+ return `Calculer la somme suivante :
9
+
10
+ $$
11
+ 1 + ${raison} + ${raison}^2 + \\ldots + ${raison}^{${final}}
12
+ $$`;
13
+ };
14
+ const getHint = () => {
15
+ return `On utilise la formule :
16
+
17
+ $$
18
+ 1 + q + q^2 + \\ldots + q^n = \\frac{1-q^{n+1}}{1-q}
19
+ $$`;
20
+ };
21
+ const getCorrection = (identifiers) => {
22
+ const { raison, final } = identifiers;
23
+ return `On utilise la formule :
24
+
25
+ $$
26
+ 1 + q + q^2 + \\ldots + q^n = \\frac{1-q^{n+1}}{1-q}
27
+ $$
28
+
29
+ Ici, $q = ${raison}$ et $n = ${final}$.
30
+
31
+ On a donc :
32
+
33
+ ${alignTex([
34
+ ["S", "=", `\\frac{1-${raison}^{${final}+1}}{1-${raison}}`],
35
+ ["", "=", `\\frac{${1 - raison ** (final + 1)}}{${1 - raison}}`],
36
+ ["", "=", getAnswer(identifiers)],
37
+ ])}`;
38
+ };
39
+ const getAnswer = (identifiers) => {
40
+ const { raison, final } = identifiers;
41
+ const answer = (raison ** (final + 1) - 1) / (raison - 1) + "";
42
+ return answer;
43
+ };
44
+ const getGeometricFirstTermsSumQuestion = () => {
45
+ const raison = randint(2, 8);
46
+ const final = randint(5, 10);
47
+ const identifiers = { raison, final };
48
+ return getQuestionFromIdentifiers(identifiers);
49
+ };
50
+ const getQuestionFromIdentifiers = (identifiers) => {
51
+ const question = {
52
+ answer: getAnswer(identifiers),
53
+ instruction: getInstruction(identifiers),
54
+ keys: [],
55
+ answerFormat: "tex",
56
+ identifiers,
57
+ hint: getHint(identifiers),
58
+ correction: getCorrection(identifiers),
59
+ };
60
+ return question;
61
+ };
62
+ const getPropositions = (n, { answer, raison, final }) => {
63
+ const propositions = [];
64
+ addValidProp(propositions, answer);
65
+ tryToAddWrongProp(propositions, (raison ** (final + 1) - 1).toString());
66
+ tryToAddWrongProp(propositions, ((raison ** final - 1) / (raison - 1)).toString());
67
+ propWhile(propositions, n, () => {
68
+ const wrongAnswer = randint(1000, 10000) + "";
69
+ tryToAddWrongProp(propositions, wrongAnswer);
70
+ });
71
+ return shuffle(propositions);
72
+ };
73
+ const isAnswerValid = (ans, { answer }) => {
74
+ return ans === answer;
75
+ };
76
+ export const geometricFirstTermsSum = {
77
+ id: "geometricFirstTermsSum",
78
+ connector: "=",
79
+ label: "Somme des termes d'une suite géométrique",
80
+ isSingleStep: true,
81
+ generator: (nb) => getDistinctQuestions(getGeometricFirstTermsSumQuestion, nb),
82
+ qcmTimer: 60,
83
+ freeTimer: 60,
84
+ getPropositions,
85
+ isAnswerValid,
86
+ subject: "Mathématiques",
87
+ getAnswer,
88
+ getInstruction,
89
+ hasHintAndCorrection: true,
90
+ getQuestionFromIdentifiers,
91
+ };
@@ -0,0 +1,4 @@
1
+ export * from "./geometricFirstTermsSum.js";
2
+ export * from "./geometricFirstTermsGeneralSum.js";
3
+ export * from "./geometricComputeSumWithDots.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/geometric/sum/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./geometricFirstTermsSum.js";
2
+ export * from "./geometricFirstTermsGeneralSum.js";
3
+ export * from "./geometricComputeSumWithDots.js";
@@ -0,0 +1,2 @@
1
+ export * from "./seqArithmGeomRecurrenceFormulaUsage.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/seqArithmGeom/index.ts"],"names":[],"mappings":"AAAA,cAAc,0CAA0C,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./seqArithmGeomRecurrenceFormulaUsage.js";
@@ -0,0 +1,14 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { OptionFirstTermRankOne } from "../../../../exercises/options/optionFirstTermRankOne.js";
3
+ type Identifiers = {
4
+ rank1: number;
5
+ value1: number;
6
+ coeffs: number[];
7
+ rankAsked: number;
8
+ };
9
+ type Options = OptionFirstTermRankOne & {
10
+ distanceOfRankAsked: string;
11
+ };
12
+ export declare const seqArithmGeomRecurrenceFormulaUsage: Exercise<Identifiers, Options>;
13
+ export {};
14
+ //# sourceMappingURL=seqArithmGeomRecurrenceFormulaUsage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seqArithmGeomRecurrenceFormulaUsage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/seqArithmGeom/seqArithmGeomRecurrenceFormulaUsage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,sBAAsB,EACvB,MAAM,mDAAmD,CAAC;AA8C3D,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAoMF,KAAK,OAAO,GAAG,sBAAsB,GAAG;IAAE,mBAAmB,EAAE,MAAM,CAAA;CAAE,CAAC;AAkBxE,eAAO,MAAM,mCAAmC,EAAE,QAAQ,CACxD,WAAW,EACX,OAAO,CAoBR,CAAC"}