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.
- package/lib/exercises/math/functions/trinoms/devForm/variationsFromAlgebricForm.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/devForm/variationsFromAlgebricForm.js +12 -0
- package/lib/exercises/math/functions/trinoms/parabole/index.d.ts +2 -0
- package/lib/exercises/math/functions/trinoms/parabole/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/parabole/index.js +2 -0
- package/lib/exercises/math/functions/trinoms/parabole/parabolaVarTable.d.ts +8 -0
- package/lib/exercises/math/functions/trinoms/parabole/parabolaVarTable.d.ts.map +1 -0
- package/lib/exercises/math/functions/trinoms/parabole/parabolaVarTable.js +106 -0
- package/lib/exercises/math/functions/trinoms/parabole/paraboleSolveGraphEquation.d.ts +14 -0
- package/lib/exercises/math/functions/trinoms/parabole/paraboleSolveGraphEquation.d.ts.map +1 -0
- package/lib/exercises/math/functions/trinoms/parabole/paraboleSolveGraphEquation.js +186 -0
- package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumTypeFromAlgebricForm.d.ts +6 -2
- package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumTypeFromAlgebricForm.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumTypeFromAlgebricForm.js +98 -13
- package/lib/exercises/math/geometry/lines/index.d.ts +1 -0
- package/lib/exercises/math/geometry/lines/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/lines/index.js +1 -0
- package/lib/exercises/math/geometry/lines/readLineNormalVectorOnGraph.d.ts +13 -0
- package/lib/exercises/math/geometry/lines/readLineNormalVectorOnGraph.d.ts.map +1 -0
- package/lib/exercises/math/geometry/lines/readLineNormalVectorOnGraph.js +195 -0
- package/lib/exercises/math/probaStat/randomVariable/index.d.ts +1 -0
- package/lib/exercises/math/probaStat/randomVariable/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/randomVariable/index.js +1 -0
- package/lib/exercises/math/probaStat/randomVariable/missingValueInRandomVariableProbabilityLaw.d.ts +9 -0
- package/lib/exercises/math/probaStat/randomVariable/missingValueInRandomVariableProbabilityLaw.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/missingValueInRandomVariableProbabilityLaw.js +119 -0
- package/lib/exercises/math/python/sequences/index.d.ts +8 -0
- package/lib/exercises/math/python/sequences/index.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/index.js +7 -0
- package/lib/exercises/math/python/sequences/pySequenceFactorialInstructionFalseOneOut.d.ts +11 -0
- package/lib/exercises/math/python/sequences/pySequenceFactorialInstructionFalseOneOut.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceFactorialInstructionFalseOneOut.js +274 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsListInstructionCompletion.d.ts +12 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsListInstructionCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsListInstructionCompletion.js +368 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsSumInstructionCompletion.d.ts +13 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsSumInstructionCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsSumInstructionCompletion.js +254 -0
- package/lib/exercises/math/python/sequences/pySequenceProgramReading.d.ts +14 -0
- package/lib/exercises/math/python/sequences/pySequenceProgramReading.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceProgramReading.js +365 -0
- package/lib/exercises/math/python/sequences/pySequenceTermForLoopInstructionCompletion.d.ts +11 -0
- package/lib/exercises/math/python/sequences/pySequenceTermForLoopInstructionCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceTermForLoopInstructionCompletion.js +298 -0
- package/lib/exercises/math/python/sequences/pySequenceTermFromFunctionCallInstructionCompletion.d.ts +12 -0
- package/lib/exercises/math/python/sequences/pySequenceTermFromFunctionCallInstructionCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceTermFromFunctionCallInstructionCompletion.js +408 -0
- package/lib/exercises/math/python/sequences/pySequenceThresholdInstructionCompletion.d.ts +17 -0
- package/lib/exercises/math/python/sequences/pySequenceThresholdInstructionCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceThresholdInstructionCompletion.js +498 -0
- package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormulaFromTwoTerms.d.ts +12 -0
- package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormulaFromTwoTerms.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormulaFromTwoTerms.js +191 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindExplicitFormulaFromSituation.d.ts +14 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindExplicitFormulaFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindExplicitFormulaFromSituation.js +153 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.d.ts +15 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.js +184 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRecurrenceFormulaFromSituation.d.ts +14 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRecurrenceFormulaFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRecurrenceFormulaFromSituation.js +210 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindTermFromSituation.d.ts +15 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindTermFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindTermFromSituation.js +161 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.d.ts +17 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.js +188 -0
- package/lib/exercises/math/sequences/arithmetic/situations/index.d.ts +6 -0
- package/lib/exercises/math/sequences/arithmetic/situations/index.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/index.js +5 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticComputeSumWithDots.d.ts +15 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticComputeSumWithDots.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticComputeSumWithDots.js +233 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSum.d.ts +13 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSum.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSum.js +111 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSumThreshold.d.ts +13 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSumThreshold.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSumThreshold.js +216 -0
- package/lib/exercises/math/sequences/arithmetic/sum/firstIntegersSum.d.ts +7 -0
- package/lib/exercises/math/sequences/arithmetic/sum/firstIntegersSum.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/sum/firstIntegersSum.js +94 -0
- package/lib/exercises/math/sequences/arithmetic/sum/index.d.ts +5 -0
- package/lib/exercises/math/sequences/arithmetic/sum/index.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/sum/index.js +4 -0
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.d.ts +14 -0
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.js +301 -0
- package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoTerms.d.ts +15 -0
- package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoTerms.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoTerms.js +260 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.d.ts +14 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.js +186 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRankFromSituation.d.ts +15 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRankFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRankFromSituation.js +142 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRecurrenceFormulaFromSituation.d.ts +14 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRecurrenceFormulaFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRecurrenceFormulaFromSituation.js +205 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindTermFromSituation.d.ts +15 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindTermFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindTermFromSituation.js +208 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindThresholdFromSituation.d.ts +17 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindThresholdFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindThresholdFromSituation.js +152 -0
- package/lib/exercises/math/sequences/geometric/situations/index.d.ts +4 -0
- package/lib/exercises/math/sequences/geometric/situations/index.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/index.js +5 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricComputeSumWithDots.d.ts +15 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricComputeSumWithDots.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricComputeSumWithDots.js +248 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsGeneralSum.d.ts +14 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsGeneralSum.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsGeneralSum.js +126 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsSum.d.ts +8 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsSum.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsSum.js +91 -0
- package/lib/exercises/math/sequences/geometric/sum/index.d.ts +4 -0
- package/lib/exercises/math/sequences/geometric/sum/index.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/sum/index.js +3 -0
- package/lib/exercises/math/sequences/seqArithmGeom/index.d.ts +2 -0
- package/lib/exercises/math/sequences/seqArithmGeom/index.d.ts.map +1 -0
- package/lib/exercises/math/sequences/seqArithmGeom/index.js +1 -0
- package/lib/exercises/math/sequences/seqArithmGeom/seqArithmGeomRecurrenceFormulaUsage.d.ts +14 -0
- package/lib/exercises/math/sequences/seqArithmGeom/seqArithmGeomRecurrenceFormulaUsage.d.ts.map +1 -0
- package/lib/exercises/math/sequences/seqArithmGeom/seqArithmGeomRecurrenceFormulaUsage.js +202 -0
- package/lib/exercises/options/optionFirstTermRankOne.d.ts +16 -0
- package/lib/exercises/options/optionFirstTermRankOne.d.ts.map +1 -0
- package/lib/exercises/options/optionFirstTermRankOne.js +17 -0
- package/lib/exercises/options/optionIsUsePythonDef.d.ts +16 -0
- package/lib/exercises/options/optionIsUsePythonDef.d.ts.map +1 -0
- package/lib/exercises/options/optionIsUsePythonDef.js +17 -0
- package/lib/exercises/options/optionIsWithSuperfluousData.d.ts +16 -0
- package/lib/exercises/options/optionIsWithSuperfluousData.d.ts.map +1 -0
- package/lib/exercises/options/optionIsWithSuperfluousData.js +17 -0
- package/lib/exercises/utils/geogebra/toGGBCommandsProps.d.ts +1 -0
- package/lib/exercises/utils/geogebra/toGGBCommandsProps.d.ts.map +1 -1
- package/lib/exercises/vea/colinearVectorVEA.d.ts +2 -0
- package/lib/exercises/vea/colinearVectorVEA.d.ts.map +1 -0
- package/lib/exercises/vea/colinearVectorVEA.js +11 -0
- package/lib/exercises/vea/varLineVEA.d.ts.map +1 -1
- package/lib/exercises/vea/varLineVEA.js +5 -2
- package/lib/index.d.ts +25 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/line.d.ts +1 -1
- package/lib/math/geometry/line.d.ts.map +1 -1
- package/lib/math/geometry/line.js +3 -3
- package/lib/math/geometry/point.d.ts +1 -1
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/point.js +4 -1
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts +53 -0
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts.map +1 -0
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.js +1928 -0
- package/lib/math/utils/sequences/situations/seqArithmeticUtils.d.ts +15 -0
- package/lib/math/utils/sequences/situations/seqArithmeticUtils.d.ts.map +1 -0
- package/lib/math/utils/sequences/situations/seqArithmeticUtils.js +136 -0
- package/lib/math/utils/sequences/situations/seqGeometricSituations.d.ts +42 -0
- package/lib/math/utils/sequences/situations/seqGeometricSituations.d.ts.map +1 -0
- package/lib/math/utils/sequences/situations/seqGeometricSituations.js +932 -0
- package/lib/math/utils/sequences/situations/seqGeometricUtils.d.ts +12 -0
- package/lib/math/utils/sequences/situations/seqGeometricUtils.d.ts.map +1 -0
- package/lib/math/utils/sequences/situations/seqGeometricUtils.js +90 -0
- package/lib/tests/exosTest.d.ts.map +1 -1
- package/lib/tests/exosTest.js +0 -2
- package/lib/tree/nodes/operators/binomialCoefficientNode.d.ts +3 -3
- package/lib/tree/nodes/operators/binomialCoefficientNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/binomialCoefficientNode.js +6 -3
- package/lib/tree/parsers/vectorParser.d.ts.map +1 -1
- package/lib/tree/parsers/vectorParser.js +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,233 @@
|
|
|
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 { add } from "../../../../../tree/nodes/operators/addNode.js";
|
|
7
|
+
import { frac } from "../../../../../tree/nodes/operators/fractionNode.js";
|
|
8
|
+
import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
|
|
9
|
+
import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
|
|
10
|
+
import { alignTex } from "../../../../../utils/latex/alignTex.js";
|
|
11
|
+
const strForValue = (v) => {
|
|
12
|
+
return v < 0 ? `(${v.frenchify()})` : `${v.frenchify()}`;
|
|
13
|
+
};
|
|
14
|
+
const valueForRank = (initial, reason, rank) => {
|
|
15
|
+
return initial + reason * rank;
|
|
16
|
+
};
|
|
17
|
+
const strSumWithDots = (initial, reason, firstRank, lowRankDots, highRankDots, lastRank) => {
|
|
18
|
+
const arrRankStart = [...Array(lowRankDots - firstRank).keys()].map((i) => i + firstRank);
|
|
19
|
+
const arrRankEnd = [...Array(lastRank - highRankDots).keys()].map((i) => i + highRankDots + 1);
|
|
20
|
+
const [arrValueStart, arrValueEnd] = [arrRankStart, arrRankEnd].map((arrRank) => arrRank.map((rank) => strForValue(valueForRank(initial, reason, rank))));
|
|
21
|
+
const [strStart, strEnd] = [arrValueStart, arrValueEnd].map((arrValue) => arrValue.join(" + "));
|
|
22
|
+
const strFlat = [strStart, strEnd].join(` + \\ldots + `);
|
|
23
|
+
const maxStrLength = 40;
|
|
24
|
+
if (strFlat.length < maxStrLength) {
|
|
25
|
+
return `
|
|
26
|
+
|
|
27
|
+
$$
|
|
28
|
+
${strFlat}
|
|
29
|
+
$$
|
|
30
|
+
|
|
31
|
+
`;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return `
|
|
35
|
+
|
|
36
|
+
$$
|
|
37
|
+
${strStart}
|
|
38
|
+
$$
|
|
39
|
+
|
|
40
|
+
$$
|
|
41
|
+
+ \\ldots
|
|
42
|
+
$$
|
|
43
|
+
|
|
44
|
+
$$
|
|
45
|
+
+ \\ ${strEnd}
|
|
46
|
+
$$
|
|
47
|
+
|
|
48
|
+
`;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const getInstruction = (identifiers, optsIn) => {
|
|
52
|
+
const opts = optsIn ?? optsDefault;
|
|
53
|
+
const { isGiveCount } = opts;
|
|
54
|
+
const firstRank = opts.firstTermRankOne ? 1 : 0;
|
|
55
|
+
const { initial, reason, nbTerms, lowRankDots, highRankDots } = identifiers;
|
|
56
|
+
const lastRank = firstRank + nbTerms - 1;
|
|
57
|
+
return `Soit $u$ une suite arithmétique.
|
|
58
|
+
|
|
59
|
+
Calculer la somme des premiers termes de $u$ ${isGiveCount
|
|
60
|
+
? `(la somme contient en tout $${nbTerms.frenchify()}$ termes)`
|
|
61
|
+
: ""}:
|
|
62
|
+
|
|
63
|
+
${strSumWithDots(initial, reason, firstRank, lowRankDots, highRankDots, lastRank)}
|
|
64
|
+
|
|
65
|
+
`;
|
|
66
|
+
};
|
|
67
|
+
const getAnswerNode = (identifiers, opts) => {
|
|
68
|
+
const firstRank = opts.firstTermRankOne ? 1 : 0;
|
|
69
|
+
const { initial, reason, nbTerms } = identifiers;
|
|
70
|
+
const lastRank = firstRank + nbTerms - 1;
|
|
71
|
+
const nodeAnswer = multiply(nbTerms, frac(add(valueForRank(initial, reason, firstRank), valueForRank(initial, reason, lastRank)), 2));
|
|
72
|
+
return nodeAnswer;
|
|
73
|
+
};
|
|
74
|
+
const getAnswer = (identifiers, optsIn) => {
|
|
75
|
+
const opts = optsIn ?? optsDefault;
|
|
76
|
+
return getAnswerNode(identifiers, opts).simplify().toTex();
|
|
77
|
+
};
|
|
78
|
+
const getHint = (_, optsIn) => {
|
|
79
|
+
const opts = optsIn ?? optsDefault;
|
|
80
|
+
const { isGiveCount } = opts;
|
|
81
|
+
return `La somme $S$ des $n$ premiers termes d'une suite arithmétique s'obtient par la formule :
|
|
82
|
+
|
|
83
|
+
$$
|
|
84
|
+
S = n \\times \\frac{1^{\\text{er}}\\text{terme} + \\text{dernier terme}}{2}
|
|
85
|
+
$$
|
|
86
|
+
|
|
87
|
+
${!isGiveCount
|
|
88
|
+
? "Il te faut donc déterminer combien il y a de termes dans la somme donnée."
|
|
89
|
+
: ""}`;
|
|
90
|
+
};
|
|
91
|
+
const getCorrection = (identifiers, optsIn) => {
|
|
92
|
+
const opts = optsIn ?? optsDefault;
|
|
93
|
+
const { isGiveCount } = opts;
|
|
94
|
+
const firstRank = opts.firstTermRankOne ? 1 : 0;
|
|
95
|
+
const { initial, nbTerms, reason } = identifiers;
|
|
96
|
+
const firstValue = valueForRank(initial, reason, firstRank);
|
|
97
|
+
const lastRank = firstRank + nbTerms - 1;
|
|
98
|
+
const lastValue = valueForRank(initial, reason, lastRank);
|
|
99
|
+
const answerNode = getAnswerNode(identifiers, opts);
|
|
100
|
+
return `La somme $S$ des $n$ premiers termes d'une suite arithmétique s'obtient par la formule :
|
|
101
|
+
|
|
102
|
+
$$
|
|
103
|
+
S = n \\times \\frac{1^{\\text{er}}\\text{terme} + \\text{dernier terme}}{2}
|
|
104
|
+
$$
|
|
105
|
+
|
|
106
|
+
${(() => {
|
|
107
|
+
if (isGiveCount) {
|
|
108
|
+
return "";
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
return `On a le premier et le dernier terme mais il faut déterminer combien il y a de termes en tout.
|
|
112
|
+
|
|
113
|
+
On calcule la raison de la suite :
|
|
114
|
+
|
|
115
|
+
${alignTex([
|
|
116
|
+
[
|
|
117
|
+
"r",
|
|
118
|
+
"=",
|
|
119
|
+
`u_{${(firstRank + 1).frenchify()}} - u_{${firstRank.frenchify()}}`,
|
|
120
|
+
],
|
|
121
|
+
[
|
|
122
|
+
"r",
|
|
123
|
+
"=",
|
|
124
|
+
`${strForValue(valueForRank(initial, reason, firstRank + 1))} - ${strForValue(valueForRank(initial, reason, firstRank))}`,
|
|
125
|
+
],
|
|
126
|
+
["r", "=", `${reason.frenchify()}`],
|
|
127
|
+
])}
|
|
128
|
+
|
|
129
|
+
On calcule le nombre de termes :
|
|
130
|
+
|
|
131
|
+
$$
|
|
132
|
+
\\text{dernier terme} = {1^{\\text{er}}\\text{terme}} + r \\times (n-1)
|
|
133
|
+
$$
|
|
134
|
+
|
|
135
|
+
${alignTex([
|
|
136
|
+
[
|
|
137
|
+
"n",
|
|
138
|
+
"=",
|
|
139
|
+
`\\frac{${strForValue(lastValue)} - ${strForValue(firstValue)}}{${reason.frenchify()}} + 1`,
|
|
140
|
+
],
|
|
141
|
+
["n", "=", `${nbTerms.frenchify()}`],
|
|
142
|
+
])}
|
|
143
|
+
|
|
144
|
+
`;
|
|
145
|
+
}
|
|
146
|
+
})()}
|
|
147
|
+
|
|
148
|
+
La somme des $${nbTerms}$ premiers termes de $u$ vaut donc :
|
|
149
|
+
|
|
150
|
+
$$
|
|
151
|
+
${answerNode.toTex({ forceParenthesis: true })} = ${answerNode
|
|
152
|
+
.simplify()
|
|
153
|
+
.toTex()}
|
|
154
|
+
$$`;
|
|
155
|
+
};
|
|
156
|
+
const getPropositions = (n, { answer }) => {
|
|
157
|
+
const propositions = [];
|
|
158
|
+
addValidProp(propositions, answer);
|
|
159
|
+
propWhile(propositions, n, () => {
|
|
160
|
+
tryToAddWrongProp(propositions, randint(-100, 100) + "");
|
|
161
|
+
});
|
|
162
|
+
return shuffleProps(propositions, n);
|
|
163
|
+
};
|
|
164
|
+
const isAnswerValid = (studentAns, { answer }) => {
|
|
165
|
+
try {
|
|
166
|
+
return numberVEA(studentAns, answer);
|
|
167
|
+
}
|
|
168
|
+
catch (err) {
|
|
169
|
+
return handleVEAError(err);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
const getArithmeticComputeSumWithDotsQuestion = (optsIn) => {
|
|
173
|
+
const opts = optsIn ?? optsDefault;
|
|
174
|
+
const { isGiveCount } = opts;
|
|
175
|
+
const firstRank = opts.firstTermRankOne ? 1 : 0;
|
|
176
|
+
const initial = randint(-9, 10);
|
|
177
|
+
const reason = randint(-5, 5, [0]);
|
|
178
|
+
const nbTerms = randint(7, 15);
|
|
179
|
+
const minRankDots = isGiveCount ? firstRank + 1 : firstRank + 2;
|
|
180
|
+
const lastRank = firstRank + nbTerms - 1;
|
|
181
|
+
const lowRankDots = randint(minRankDots, Math.min(minRankDots + randint(1, 4), lastRank));
|
|
182
|
+
const highRankDots = randint(Math.max(lastRank - randint(1, 4), lowRankDots), lastRank);
|
|
183
|
+
const identifiers = {
|
|
184
|
+
initial,
|
|
185
|
+
reason,
|
|
186
|
+
nbTerms,
|
|
187
|
+
lowRankDots,
|
|
188
|
+
highRankDots,
|
|
189
|
+
};
|
|
190
|
+
return getQuestionFromIdentifiers(identifiers, opts);
|
|
191
|
+
};
|
|
192
|
+
const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
193
|
+
const question = {
|
|
194
|
+
answer: getAnswer(identifiers, opts),
|
|
195
|
+
instruction: getInstruction(identifiers, opts),
|
|
196
|
+
keys: [],
|
|
197
|
+
answerFormat: "tex",
|
|
198
|
+
identifiers,
|
|
199
|
+
hint: getHint(identifiers, opts),
|
|
200
|
+
correction: getCorrection(identifiers, opts),
|
|
201
|
+
options: opts,
|
|
202
|
+
};
|
|
203
|
+
return question;
|
|
204
|
+
};
|
|
205
|
+
const { optsDefaultFirstTermRankOne, generatorOptionFirstTermRankOne } = getOptionFirstTermRankOneStuff(false);
|
|
206
|
+
const optsDefault = Object.assign({}, optsDefaultFirstTermRankOne, {
|
|
207
|
+
isGiveCount: true,
|
|
208
|
+
});
|
|
209
|
+
const options = [
|
|
210
|
+
generatorOptionFirstTermRankOne,
|
|
211
|
+
{
|
|
212
|
+
id: "isGiveCount",
|
|
213
|
+
label: "Donner $n$",
|
|
214
|
+
target: GeneratorOptionTarget.generation,
|
|
215
|
+
type: GeneratorOptionType.checkbox,
|
|
216
|
+
defaultValue: optsDefault.isGiveCount,
|
|
217
|
+
},
|
|
218
|
+
];
|
|
219
|
+
export const arithmeticComputeSumWithDots = {
|
|
220
|
+
id: "arithmeticComputeSumWithDots",
|
|
221
|
+
connector: "=",
|
|
222
|
+
label: "Calculer une somme donnée avec $\\ldots$ (suite arithmétique)",
|
|
223
|
+
isSingleStep: true,
|
|
224
|
+
generator: (nb, opts) => getDistinctQuestions(() => getArithmeticComputeSumWithDotsQuestion(opts), nb),
|
|
225
|
+
qcmTimer: 60,
|
|
226
|
+
freeTimer: 60,
|
|
227
|
+
getPropositions,
|
|
228
|
+
isAnswerValid,
|
|
229
|
+
subject: "Mathématiques",
|
|
230
|
+
hasHintAndCorrection: true,
|
|
231
|
+
getQuestionFromIdentifiers,
|
|
232
|
+
options,
|
|
233
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
firstTermRank: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const arithmeticFirstTermsSum: Exercise<Identifiers, Options>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=arithmeticFirstTermsSum.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arithmeticFirstTermsSum.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSum.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAQrC,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;AAqGF,KAAK,OAAO,GAAG;IACb,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAeF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAelE,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, propWhile, 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 { add } from "../../../../../tree/nodes/operators/addNode.js";
|
|
5
|
+
import { frac } from "../../../../../tree/nodes/operators/fractionNode.js";
|
|
6
|
+
import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
|
|
7
|
+
import { random } from "../../../../../utils/alea/random.js";
|
|
8
|
+
const getHint = () => {
|
|
9
|
+
return `La somme $S$ des $n$ premiers termes d'une suite arithmétique s'obtient par la formule :
|
|
10
|
+
|
|
11
|
+
$$
|
|
12
|
+
S = n \\times \\frac{1^{\\text{er}}\\text{terme} + \\text{dernier terme}}{2}
|
|
13
|
+
$$`;
|
|
14
|
+
};
|
|
15
|
+
const getCorrection = (identifiers) => {
|
|
16
|
+
const { firstRank, firstValue, nbTerms, reason } = identifiers;
|
|
17
|
+
const lastRank = firstRank + nbTerms - 1;
|
|
18
|
+
const lastValue = firstValue + reason * (nbTerms - 1);
|
|
19
|
+
return `La somme $S$ des $n$ premiers termes d'une suite arithmétique s'obtient par la formule :
|
|
20
|
+
|
|
21
|
+
$$
|
|
22
|
+
S = n \\times \\frac{1^{\\text{er}}\\text{terme} + \\text{dernier terme}}{2}
|
|
23
|
+
$$
|
|
24
|
+
|
|
25
|
+
On calcule le dernier terme de la somme :
|
|
26
|
+
|
|
27
|
+
$$
|
|
28
|
+
u_{${lastRank}} = ${add(firstValue, multiply(nbTerms - 1, reason)).toTex()} = ${lastValue}
|
|
29
|
+
$$
|
|
30
|
+
|
|
31
|
+
La somme des $${nbTerms}$ premiers termes de $u$ vaut donc :
|
|
32
|
+
|
|
33
|
+
$$
|
|
34
|
+
${multiply(nbTerms, frac(add(firstValue, lastValue), 2)).toTex()} = ${getAnswer(identifiers)}
|
|
35
|
+
$$`;
|
|
36
|
+
};
|
|
37
|
+
const getInstruction = (identifiers) => {
|
|
38
|
+
const { firstRank, firstValue, reason, nbTerms } = identifiers;
|
|
39
|
+
return `Soit $u$ une suite arithmétique de premier terme $u_${firstRank} = ${firstValue}$ et de raison $${reason}$.
|
|
40
|
+
|
|
41
|
+
Calculer la somme des $${nbTerms}$ premiers termes de $u$.`;
|
|
42
|
+
};
|
|
43
|
+
const getAnswer = (identifiers) => {
|
|
44
|
+
const { firstRank, firstValue, reason, nbTerms } = identifiers;
|
|
45
|
+
const lastRank = firstRank + nbTerms - 1;
|
|
46
|
+
const answer = (lastRank - firstRank + 1) *
|
|
47
|
+
(firstRank === 0 ? firstValue : firstValue - reason) +
|
|
48
|
+
(reason * (lastRank * (lastRank + 1))) / 2;
|
|
49
|
+
const answerTex = answer + "";
|
|
50
|
+
return answerTex;
|
|
51
|
+
};
|
|
52
|
+
const getArithmeticFirstTermsSumQuestion = (opts) => {
|
|
53
|
+
const firstRank = opts?.firstTermRank === "$u_{0}$"
|
|
54
|
+
? 0
|
|
55
|
+
: opts?.firstTermRank === "$u_{1}$"
|
|
56
|
+
? 1
|
|
57
|
+
: random([0, 1]);
|
|
58
|
+
const firstValue = randint(-9, 10);
|
|
59
|
+
const reason = randint(-5, 5, [0]);
|
|
60
|
+
const nbTerms = randint(4, 9);
|
|
61
|
+
const identifiers = { firstRank, firstValue, reason, nbTerms };
|
|
62
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
63
|
+
};
|
|
64
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
65
|
+
const question = {
|
|
66
|
+
answer: getAnswer(identifiers),
|
|
67
|
+
instruction: getInstruction(identifiers),
|
|
68
|
+
keys: [],
|
|
69
|
+
answerFormat: "tex",
|
|
70
|
+
identifiers,
|
|
71
|
+
hint: getHint(identifiers),
|
|
72
|
+
correction: getCorrection(identifiers),
|
|
73
|
+
};
|
|
74
|
+
return question;
|
|
75
|
+
};
|
|
76
|
+
const getPropositions = (n, { answer }) => {
|
|
77
|
+
const propositions = [];
|
|
78
|
+
addValidProp(propositions, answer);
|
|
79
|
+
propWhile(propositions, n, () => {
|
|
80
|
+
tryToAddWrongProp(propositions, randint(-100, 100) + "");
|
|
81
|
+
});
|
|
82
|
+
return shuffleProps(propositions, n);
|
|
83
|
+
};
|
|
84
|
+
const options = [
|
|
85
|
+
{
|
|
86
|
+
id: "firstTermRank",
|
|
87
|
+
label: "Rang du premier terme",
|
|
88
|
+
target: GeneratorOptionTarget.generation,
|
|
89
|
+
type: GeneratorOptionType.select,
|
|
90
|
+
values: ["$u_{0}$", "$u_{1}$", "L'un ou l'autre"],
|
|
91
|
+
defaultValue: "L'un ou l'autre",
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
95
|
+
return ans === answer;
|
|
96
|
+
};
|
|
97
|
+
export const arithmeticFirstTermsSum = {
|
|
98
|
+
id: "arithmeticFirstTermsSum",
|
|
99
|
+
connector: "=",
|
|
100
|
+
label: "Calculer la somme des premiers termes d'une suite arithmétique",
|
|
101
|
+
isSingleStep: true,
|
|
102
|
+
generator: (nb, opts) => getDistinctQuestions(() => getArithmeticFirstTermsSumQuestion(opts), nb),
|
|
103
|
+
qcmTimer: 60,
|
|
104
|
+
freeTimer: 60,
|
|
105
|
+
getPropositions,
|
|
106
|
+
isAnswerValid,
|
|
107
|
+
subject: "Mathématiques",
|
|
108
|
+
hasHintAndCorrection: true,
|
|
109
|
+
getQuestionFromIdentifiers,
|
|
110
|
+
options,
|
|
111
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Exercise } from "../../../../../exercises/exercise.js";
|
|
2
|
+
import { OptionFirstTermRankOne } from "../../../../../exercises/options/optionFirstTermRankOne.js";
|
|
3
|
+
import { InegalitySymbols } from "../../../../../math/inequations/inequation.js";
|
|
4
|
+
type Identifiers = {
|
|
5
|
+
initial: number;
|
|
6
|
+
reason: number;
|
|
7
|
+
valueThreshold: number;
|
|
8
|
+
inegSymbol: InegalitySymbols;
|
|
9
|
+
};
|
|
10
|
+
type Options = OptionFirstTermRankOne;
|
|
11
|
+
export declare const arithmeticFirstTermsSumThreshold: Exercise<Identifiers, Options>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=arithmeticFirstTermsSumThreshold.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arithmeticFirstTermsSumThreshold.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSumThreshold.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,sBAAsB,EACvB,MAAM,mDAAmD,CAAC;AAG3D,OAAO,EACL,gBAAgB,EAEjB,MAAM,sCAAsC,CAAC;AAY9C,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,gBAAgB,CAAC;CAC9B,CAAC;AA6PF,KAAK,OAAO,GAAG,sBAAsB,CAAC;AAMtC,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAoBzE,CAAC"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { 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 { InequationSymbol, } from "../../../../../math/inequations/inequation.js";
|
|
6
|
+
import { Trinom } from "../../../../../math/polynomials/trinom.js";
|
|
7
|
+
import { randint } from "../../../../../math/utils/random/randint.js";
|
|
8
|
+
import { round } from "../../../../../math/utils/round.js";
|
|
9
|
+
import { seqArithmeticUtils } from "../../../../../math/utils/sequences/situations/seqArithmeticUtils.js";
|
|
10
|
+
import { random } from "../../../../../utils/alea/random.js";
|
|
11
|
+
import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
|
|
12
|
+
const strForValue = (v) => {
|
|
13
|
+
return v < 0 ? `(${v.frenchify()})` : `${v.frenchify()}`;
|
|
14
|
+
};
|
|
15
|
+
const getInstruction = (identifiers, optsIn) => {
|
|
16
|
+
const opts = optsIn ?? optsDefault;
|
|
17
|
+
const firstRank = opts.firstTermRankOne ? 1 : 0;
|
|
18
|
+
const { initial, reason, valueThreshold, inegSymbol } = identifiers;
|
|
19
|
+
const inequationSymbol = new InequationSymbol(inegSymbol);
|
|
20
|
+
const firstValue = seqArithmeticUtils.valueForRank(initial, reason, firstRank);
|
|
21
|
+
return `Soit $u$ une suite arithmétique de raison $${reason.frenchify()}$ et de premier terme $${firstValue.frenchify()}$.
|
|
22
|
+
|
|
23
|
+
Pour $k$ entier supérieur ou égal à $${firstRank + 1}$, on note $S_{k}$ la somme des $k$ premiers termes de $u$ :
|
|
24
|
+
|
|
25
|
+
$$
|
|
26
|
+
S_{k} = u_{${firstRank}} + ... + u_{${firstRank === 0 ? "k-1" : "k"}}
|
|
27
|
+
$$
|
|
28
|
+
|
|
29
|
+
À partir de quel rang $k$, la somme est-elle ${inequationSymbol.toWord(false, true)} à $${valueThreshold}$ ?
|
|
30
|
+
|
|
31
|
+
`;
|
|
32
|
+
};
|
|
33
|
+
const getAnswerNode = (identifiers, opts) => {
|
|
34
|
+
const firstRank = opts.firstTermRankOne ? 1 : 0;
|
|
35
|
+
const { initial, reason, valueThreshold, inegSymbol } = identifiers;
|
|
36
|
+
const inequationSymbol = new InequationSymbol(inegSymbol);
|
|
37
|
+
return seqArithmeticUtils.getAnswerNodeSumThresholdRank(initial, reason, firstRank, valueThreshold, inequationSymbol);
|
|
38
|
+
};
|
|
39
|
+
const getAnswer = (identifiers, optsIn) => {
|
|
40
|
+
const opts = optsIn ?? optsDefault;
|
|
41
|
+
return getAnswerNode(identifiers, opts).simplify().toTex();
|
|
42
|
+
};
|
|
43
|
+
const getHint = (identifiers, optsIn) => {
|
|
44
|
+
const opts = optsIn ?? optsDefault;
|
|
45
|
+
const firstRank = opts.firstTermRankOne ? 1 : 0;
|
|
46
|
+
const { valueThreshold, inegSymbol } = identifiers;
|
|
47
|
+
if (firstRank === 0) {
|
|
48
|
+
return `Pour $k$ entier supérieur ou égal à $${firstRank + 1}$, la somme $S$ des $k$ premiers termes d'une suite arithmétique s'obtient par la formule :
|
|
49
|
+
|
|
50
|
+
$$
|
|
51
|
+
S_k = k \\times \\frac{u_0 + u_{k-1}}{2}
|
|
52
|
+
$$
|
|
53
|
+
|
|
54
|
+
Utilise la formule explicite :
|
|
55
|
+
|
|
56
|
+
$$
|
|
57
|
+
u_{k-1} = u_0 + (k-1)r
|
|
58
|
+
$$
|
|
59
|
+
|
|
60
|
+
pour réécrire $S_k$ uniquement en fonction de $k$.
|
|
61
|
+
|
|
62
|
+
Tu devras ensuite résoudre l'inéquation :
|
|
63
|
+
|
|
64
|
+
$$
|
|
65
|
+
S_k ${inegSymbol} ${valueThreshold.frenchify()}
|
|
66
|
+
$$
|
|
67
|
+
|
|
68
|
+
`;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
return `Pour $k$ entier supérieur ou égal à $${firstRank + 1}$, la somme $S$ des $k$ premiers termes d'une suite arithmétique s'obtient par la formule :
|
|
72
|
+
|
|
73
|
+
$$
|
|
74
|
+
S_k = k \\times \\frac{u_1 + u_{k}}{2}
|
|
75
|
+
$$
|
|
76
|
+
|
|
77
|
+
Utilise la formule explicite :
|
|
78
|
+
|
|
79
|
+
$$
|
|
80
|
+
u_{k} = u_0 + kr
|
|
81
|
+
$$
|
|
82
|
+
|
|
83
|
+
pour réécrire $S_k$ uniquement en fonction de $k$.
|
|
84
|
+
|
|
85
|
+
Tu devras ensuite résoudre l'inéquation $S_k ${inegSymbol} ${valueThreshold.frenchify()}$.`;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const getCorrection = (identifiers, optsIn) => {
|
|
89
|
+
const opts = optsIn ?? optsDefault;
|
|
90
|
+
const firstRank = opts.firstTermRankOne ? 1 : 0;
|
|
91
|
+
const { initial, reason, valueThreshold, inegSymbol } = identifiers;
|
|
92
|
+
const firstValue = seqArithmeticUtils.valueForRank(initial, reason, firstRank);
|
|
93
|
+
const root = (() => {
|
|
94
|
+
const a = reason / 2;
|
|
95
|
+
const b = firstValue - a;
|
|
96
|
+
const c = -valueThreshold;
|
|
97
|
+
const trinom = new Trinom(a, b, c);
|
|
98
|
+
const [_nodeKLow, nodeKHigh] = trinom
|
|
99
|
+
.getRootsNode()
|
|
100
|
+
.toSorted((v1, v2) => v1.evaluate() - v2.evaluate());
|
|
101
|
+
const kHigh = nodeKHigh.evaluate();
|
|
102
|
+
return kHigh;
|
|
103
|
+
})();
|
|
104
|
+
const isIntegerRoot = round(root, 0) === root;
|
|
105
|
+
return `${(() => {
|
|
106
|
+
if (firstRank === 0) {
|
|
107
|
+
return `Pour $k$ entier supérieur ou égal à $${firstRank + 1}$, la somme $S$ des $k$ premiers termes d'une suite arithmétique s'obtient par la formule :
|
|
108
|
+
|
|
109
|
+
$$
|
|
110
|
+
S_k = k \\times \\frac{u_0 + u_{k-1}}{2}
|
|
111
|
+
$$
|
|
112
|
+
|
|
113
|
+
On utilise la formule explicite :
|
|
114
|
+
|
|
115
|
+
$$
|
|
116
|
+
u_{k-1} = u_0 + (k-1)r
|
|
117
|
+
$$
|
|
118
|
+
|
|
119
|
+
pour réécrire $S_k$ uniquement en fonction de $k$ :
|
|
120
|
+
|
|
121
|
+
$$
|
|
122
|
+
S_k = (\\frac{r}{2})k^2 + (u_0-\\frac{r}{2})k
|
|
123
|
+
$$
|
|
124
|
+
|
|
125
|
+
`;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
return `Pour $k$ entier supérieur ou égal à $${firstRank + 1}$, la somme $S$ des $k$ premiers termes d'une suite arithmétique s'obtient par la formule :
|
|
129
|
+
|
|
130
|
+
$$
|
|
131
|
+
S_k = k \\times \\frac{u_1 + u_{k}}{2}
|
|
132
|
+
$$
|
|
133
|
+
|
|
134
|
+
Utilise la formule explicite :
|
|
135
|
+
|
|
136
|
+
$$
|
|
137
|
+
u_{k} = u_1 + (k-1)r
|
|
138
|
+
$$
|
|
139
|
+
|
|
140
|
+
pour réécrire $S_k$ uniquement en fonction de $k$ :
|
|
141
|
+
|
|
142
|
+
$$
|
|
143
|
+
S_k = (\\frac{r}{2})k^2 + (u_1-\\frac{r}{2})k
|
|
144
|
+
$$`;
|
|
145
|
+
}
|
|
146
|
+
})()}
|
|
147
|
+
|
|
148
|
+
On doit donc résoudre l'inéquation $S_k ${inegSymbol} ${valueThreshold.frenchify()}$.
|
|
149
|
+
|
|
150
|
+
L'équation $S_k - ${strForValue(valueThreshold)} = 0$ a deux racines.
|
|
151
|
+
On ne garde que la racine positive qui vaut ${isIntegerRoot ? "" : "environ"} $${round(root, 2).frenchify()}$.
|
|
152
|
+
|
|
153
|
+
Le rang recherché est donc $${getAnswer(identifiers, opts)}$.`;
|
|
154
|
+
};
|
|
155
|
+
const getPropositions = (n, { answer }) => {
|
|
156
|
+
const propositions = [];
|
|
157
|
+
addValidProp(propositions, answer);
|
|
158
|
+
propWhile(propositions, n, () => {
|
|
159
|
+
tryToAddWrongProp(propositions, randint(-100, 100) + "");
|
|
160
|
+
});
|
|
161
|
+
return shuffleProps(propositions, n);
|
|
162
|
+
};
|
|
163
|
+
const isAnswerValid = (studentAns, { answer }) => {
|
|
164
|
+
try {
|
|
165
|
+
return numberVEA(studentAns, answer);
|
|
166
|
+
}
|
|
167
|
+
catch (err) {
|
|
168
|
+
return handleVEAError(err);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
const getArithmeticFirstTermsSumThresholdQuestion = (optsIn) => {
|
|
172
|
+
const opts = optsIn ?? optsDefault;
|
|
173
|
+
const firstRank = opts.firstTermRankOne ? 1 : 0;
|
|
174
|
+
const initial = randint(-9, 10);
|
|
175
|
+
const reason = randint(-5, 5, [0]);
|
|
176
|
+
const valueThreshold = seqArithmeticUtils.randThreshold(initial, reason, firstRank, 0);
|
|
177
|
+
const inegSymbol = reason > 0 ? random([">", "\\ge"]) : random(["<", "\\le"]);
|
|
178
|
+
const identifiers = {
|
|
179
|
+
initial,
|
|
180
|
+
reason,
|
|
181
|
+
valueThreshold,
|
|
182
|
+
inegSymbol,
|
|
183
|
+
};
|
|
184
|
+
return getQuestionFromIdentifiers(identifiers, opts);
|
|
185
|
+
};
|
|
186
|
+
const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
187
|
+
const question = {
|
|
188
|
+
answer: getAnswer(identifiers, opts),
|
|
189
|
+
instruction: getInstruction(identifiers, opts),
|
|
190
|
+
keys: [],
|
|
191
|
+
answerFormat: "tex",
|
|
192
|
+
identifiers,
|
|
193
|
+
hint: getHint(identifiers, opts),
|
|
194
|
+
correction: getCorrection(identifiers, opts),
|
|
195
|
+
options: opts,
|
|
196
|
+
};
|
|
197
|
+
return question;
|
|
198
|
+
};
|
|
199
|
+
const { optsDefaultFirstTermRankOne, generatorOptionFirstTermRankOne } = getOptionFirstTermRankOneStuff(false);
|
|
200
|
+
const optsDefault = Object.assign({}, optsDefaultFirstTermRankOne);
|
|
201
|
+
const options = [generatorOptionFirstTermRankOne];
|
|
202
|
+
export const arithmeticFirstTermsSumThreshold = {
|
|
203
|
+
id: "arithmeticFirstTermsSumThreshold",
|
|
204
|
+
connector: "=",
|
|
205
|
+
label: "Déterminer le rang à partir duquel une somme franchit un seuil donné (suite arithmétique)",
|
|
206
|
+
isSingleStep: true,
|
|
207
|
+
generator: (nb, opts) => getDistinctQuestions(() => getArithmeticFirstTermsSumThresholdQuestion(opts), nb),
|
|
208
|
+
qcmTimer: 60,
|
|
209
|
+
freeTimer: 60,
|
|
210
|
+
getPropositions,
|
|
211
|
+
isAnswerValid,
|
|
212
|
+
subject: "Mathématiques",
|
|
213
|
+
hasHintAndCorrection: true,
|
|
214
|
+
getQuestionFromIdentifiers,
|
|
215
|
+
options,
|
|
216
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firstIntegersSum.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/arithmetic/sum/firstIntegersSum.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAoFF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAkBlD,CAAC"}
|