math-exercises 3.0.164 → 3.0.165

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 (55) hide show
  1. package/lib/exercises/exercise.d.ts +1 -1
  2. package/lib/exercises/exercise.d.ts.map +1 -1
  3. package/lib/exercises/math/functions/basics/inverseImageFunctionGeogebra.d.ts.map +1 -1
  4. package/lib/exercises/math/functions/basics/inverseImageFunctionGeogebra.js +3 -1
  5. package/lib/exercises/math/functions/trinoms/devForm/variationsFromAlgebricForm.d.ts +6 -2
  6. package/lib/exercises/math/functions/trinoms/devForm/variationsFromAlgebricForm.d.ts.map +1 -1
  7. package/lib/exercises/math/functions/trinoms/devForm/variationsFromAlgebricForm.js +85 -13
  8. package/lib/exercises/math/functions/trinoms/equation/index.d.ts +2 -0
  9. package/lib/exercises/math/functions/trinoms/equation/index.d.ts.map +1 -1
  10. package/lib/exercises/math/functions/trinoms/equation/index.js +2 -0
  11. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationByFactorisation.d.ts +4 -1
  12. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationByFactorisation.d.ts.map +1 -1
  13. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationByFactorisation.js +169 -8
  14. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationEqualsC.d.ts +10 -0
  15. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationEqualsC.d.ts.map +1 -0
  16. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationEqualsC.js +146 -0
  17. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationFromCano.d.ts.map +1 -1
  18. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationFromCano.js +73 -3
  19. package/lib/exercises/math/functions/trinoms/equation/trinomSelectEquationWithoutDeltaNeeded.d.ts +13 -0
  20. package/lib/exercises/math/functions/trinoms/equation/trinomSelectEquationWithoutDeltaNeeded.d.ts.map +1 -0
  21. package/lib/exercises/math/functions/trinoms/equation/trinomSelectEquationWithoutDeltaNeeded.js +204 -0
  22. package/lib/exercises/math/functions/trinoms/sign/index.d.ts +2 -0
  23. package/lib/exercises/math/functions/trinoms/sign/index.d.ts.map +1 -1
  24. package/lib/exercises/math/functions/trinoms/sign/index.js +2 -0
  25. package/lib/exercises/math/functions/trinoms/sign/parabolaSignTable.d.ts +9 -0
  26. package/lib/exercises/math/functions/trinoms/sign/parabolaSignTable.d.ts.map +1 -0
  27. package/lib/exercises/math/functions/trinoms/sign/parabolaSignTable.js +123 -0
  28. package/lib/exercises/math/functions/trinoms/sign/trinomSignTableFromAlgebraicForm.d.ts +13 -0
  29. package/lib/exercises/math/functions/trinoms/sign/trinomSignTableFromAlgebraicForm.d.ts.map +1 -0
  30. package/lib/exercises/math/functions/trinoms/sign/trinomSignTableFromAlgebraicForm.js +209 -0
  31. package/lib/exercises/math/probaStat/index.js +1 -0
  32. package/lib/exercises/math/probaStat/trees/index.d.ts +2 -0
  33. package/lib/exercises/math/probaStat/trees/index.d.ts.map +1 -0
  34. package/lib/exercises/math/probaStat/trees/index.js +1 -0
  35. package/lib/exercises/math/probaStat/trees/treeInInstruction.d.ts +8 -0
  36. package/lib/exercises/math/probaStat/trees/treeInInstruction.d.ts.map +1 -0
  37. package/lib/exercises/math/probaStat/trees/treeInInstruction.js +110 -0
  38. package/lib/exercises/math/sequences/arithmetic/arithmeticVariations.d.ts +13 -0
  39. package/lib/exercises/math/sequences/arithmetic/arithmeticVariations.d.ts.map +1 -0
  40. package/lib/exercises/math/sequences/arithmetic/arithmeticVariations.js +163 -0
  41. package/lib/exercises/math/sequences/arithmetic/index.d.ts +1 -0
  42. package/lib/exercises/math/sequences/arithmetic/index.d.ts.map +1 -1
  43. package/lib/exercises/math/sequences/arithmetic/index.js +1 -0
  44. package/lib/index.d.ts +37 -3
  45. package/lib/index.d.ts.map +1 -1
  46. package/lib/math/polynomials/trinom.d.ts +1 -1
  47. package/lib/math/polynomials/trinom.d.ts.map +1 -1
  48. package/lib/math/polynomials/trinom.js +5 -2
  49. package/lib/tree/nodes/numbers/constantNode.d.ts +1 -0
  50. package/lib/tree/nodes/numbers/constantNode.d.ts.map +1 -1
  51. package/lib/tree/nodes/numbers/constantNode.js +7 -0
  52. package/lib/tree/nodes/numbers/numberNode.d.ts +1 -0
  53. package/lib/tree/nodes/numbers/numberNode.d.ts.map +1 -1
  54. package/lib/tree/nodes/numbers/numberNode.js +7 -0
  55. package/package.json +1 -1
@@ -0,0 +1,146 @@
1
+ import { addValidProp, shuffleProps, 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 { EquationSolutionNode } from "../../../../../tree/nodes/equations/equationSolutionNode.js";
5
+ import { opposite } from "../../../../../tree/nodes/functions/oppositeNode.js";
6
+ import { reifyAlgebraic, } from "../../../../../tree/nodes/nodeConstructor.js";
7
+ import { add } from "../../../../../tree/nodes/operators/addNode.js";
8
+ import { frac } from "../../../../../tree/nodes/operators/fractionNode.js";
9
+ import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
10
+ import { square } from "../../../../../tree/nodes/operators/powerNode.js";
11
+ import { DiscreteSetNode } from "../../../../../tree/nodes/sets/discreteSetNode.js";
12
+ import { discreteSetParser } from "../../../../../tree/parsers/discreteSetParser.js";
13
+ import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
14
+ import { alignTex } from "../../../../../utils/latex/alignTex.js";
15
+ const getPropositions = (n, { answer }) => {
16
+ const propositions = [];
17
+ addValidProp(propositions, answer);
18
+ propWhile(propositions, n, () => {
19
+ tryToAddWrongProp(propositions, new EquationSolutionNode(new DiscreteSetNode([randint(-9, 0), randint(1, 10)].map((e) => e.toTree()))).toTex());
20
+ });
21
+ return shuffleProps(propositions, n);
22
+ };
23
+ const getAnswer = (identifiers) => {
24
+ const { aIds, bIds } = identifiers;
25
+ const a = reifyAlgebraic(aIds);
26
+ const b = reifyAlgebraic(bIds);
27
+ const root = frac(opposite(b), a).simplify();
28
+ return new EquationSolutionNode(new DiscreteSetNode([(0).toTree(), root].sort((a, b) => a.evaluate() - b.evaluate()))).toTex();
29
+ };
30
+ const getInstruction = (identifiers) => {
31
+ const { aIds, bIds, cIds } = identifiers;
32
+ const a = reifyAlgebraic(aIds);
33
+ const b = reifyAlgebraic(bIds);
34
+ const c = reifyAlgebraic(cIds);
35
+ return `Résoudre :
36
+
37
+ $$
38
+ ${add(add(multiply(a, square("x")), multiply(b, "x")), c)
39
+ .simplify({ forbidFactorize: true })
40
+ .toTex()} = ${c.toTex()}
41
+ $$`;
42
+ };
43
+ const getHint = () => {
44
+ return `Fais en sorte que le membre de droite soit nul.
45
+
46
+ Puis, factorise le membre de gauche pour te ramener à une équation produit nul.`;
47
+ };
48
+ const getCorrection = (identifiers) => {
49
+ const { aIds, bIds, cIds } = identifiers;
50
+ const a = reifyAlgebraic(aIds);
51
+ const b = reifyAlgebraic(bIds);
52
+ const c = reifyAlgebraic(cIds);
53
+ return `On a :
54
+
55
+ ${alignTex([
56
+ [
57
+ add(add(multiply(a, square("x")), multiply(b, "x")), c)
58
+ .simplify({ forbidFactorize: true })
59
+ .toTex(),
60
+ "=",
61
+ c.toTex(),
62
+ ],
63
+ [
64
+ add(multiply(a, square("x")), multiply(b, "x"))
65
+ .simplify({ forbidFactorize: true })
66
+ .toTex(),
67
+ "=",
68
+ "0",
69
+ ],
70
+ [multiply("x", add(multiply(a, "x"), b)).toTex(), "=", "0"],
71
+ ])}
72
+
73
+ On résout alors cette équation produit nul. Cela donne :
74
+
75
+ $$
76
+ x = 0
77
+ $$
78
+
79
+ ou
80
+
81
+ $$
82
+ ${add(multiply(a, "x"), b).toTex()} = 0 \\iff x = ${frac(opposite(b), a)
83
+ .simplify()
84
+ .toTex()}
85
+ $$
86
+
87
+ Les solutions sont donc :
88
+
89
+ $$
90
+ ${getAnswer(identifiers)}
91
+ $$`;
92
+ };
93
+ const getKeys = () => {
94
+ return ["S", "equal", "lbrace", "semicolon", "rbrace", "varnothing"];
95
+ };
96
+ const isAnswerValid = (ans, { answer }) => {
97
+ try {
98
+ const parsed = discreteSetParser(ans);
99
+ if (!parsed)
100
+ return false;
101
+ return ("S=" + parsed.simplify({ decimalToFractions: true }).toTex() === answer);
102
+ }
103
+ catch (err) {
104
+ return handleVEAError(err);
105
+ }
106
+ };
107
+ const getSolveSecondDegreeEquationEqualsCQuestion = () => {
108
+ const a = randint(-9, 10, [0]);
109
+ const b = randint(-9, 10, [0]);
110
+ const c = randint(-9, 10, [0]);
111
+ const identifiers = {
112
+ aIds: a.toTree().toIdentifiers(),
113
+ bIds: b.toTree().toIdentifiers(),
114
+ cIds: c.toTree().toIdentifiers(),
115
+ };
116
+ return getQuestionFromIdentifiers(identifiers);
117
+ };
118
+ const getQuestionFromIdentifiers = (identifiers) => {
119
+ return {
120
+ answer: getAnswer(identifiers),
121
+ instruction: getInstruction(identifiers),
122
+ keys: getKeys(identifiers),
123
+ answerFormat: "tex",
124
+ identifiers,
125
+ hint: getHint(identifiers),
126
+ correction: getCorrection(identifiers),
127
+ };
128
+ };
129
+ export const solveSecondDegreeEquationEqualsC = {
130
+ id: "solveSecondDegreeEquationEqualsC",
131
+ connector: "\\iff",
132
+ label: "Résoudre par factorisation une équation du second degré du type $ax^2+bx+c=c$",
133
+ isSingleStep: true,
134
+ generator: (nb, opts) => getDistinctQuestions(() => getSolveSecondDegreeEquationEqualsCQuestion(opts), nb),
135
+ qcmTimer: 60,
136
+ freeTimer: 60,
137
+ getPropositions,
138
+ isAnswerValid,
139
+ subject: "Mathématiques",
140
+ getInstruction,
141
+ getHint,
142
+ getCorrection,
143
+ getAnswer,
144
+ getQuestionFromIdentifiers,
145
+ hasHintAndCorrection: true,
146
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"solveSecondDegreeEquationFromCano.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationFromCano.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAyEF,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,WAAW,CAanE,CAAC"}
1
+ {"version":3,"file":"solveSecondDegreeEquationFromCano.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationFromCano.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AA4IF,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,WAAW,CAcnE,CAAC"}
@@ -1,10 +1,16 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, propWhile, } from "../../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
- import { equationKeys } from "../../../../../exercises/utils/keys/equationKeys.js";
4
3
  import { TrinomConstructor } from "../../../../../math/polynomials/trinom.js";
5
4
  import { randint } from "../../../../../math/utils/random/randint.js";
6
5
  import { EquationSolutionNode } from "../../../../../tree/nodes/equations/equationSolutionNode.js";
6
+ import { opposite } from "../../../../../tree/nodes/functions/oppositeNode.js";
7
+ import { sqrt } from "../../../../../tree/nodes/functions/sqrtNode.js";
8
+ import { add } from "../../../../../tree/nodes/operators/addNode.js";
9
+ import { frac } from "../../../../../tree/nodes/operators/fractionNode.js";
10
+ import { square } from "../../../../../tree/nodes/operators/powerNode.js";
11
+ import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
7
12
  import { DiscreteSetNode } from "../../../../../tree/nodes/sets/discreteSetNode.js";
13
+ import { alignTex } from "../../../../../utils/latex/alignTex.js";
8
14
  const getInstruction = (identifiers) => {
9
15
  const { coeffs } = identifiers;
10
16
  const trinom = TrinomConstructor.fromCoeffs(coeffs);
@@ -25,17 +31,80 @@ const getAnswer = (identifiers) => {
25
31
  return answer;
26
32
  };
27
33
  const getSolveSecondDegreeEquationFromCanoQuestion = () => {
28
- const trinom = TrinomConstructor.randomNiceRootsAndSummit();
34
+ const trinom = TrinomConstructor.randomNiceRootsAndSummit(2);
29
35
  const identifiers = { coeffs: trinom.coefficients };
30
36
  return getQuestionFromIdentifiers(identifiers);
31
37
  };
38
+ const getHint = () => {
39
+ return `Ramène toi à une équation du type $X^2 = k$.
40
+
41
+ On sait alors que ce type d'équation :
42
+ - n'a pas de solution réelle si $k<0$;
43
+ - a pour unique solution réelle $0$ si $k=0$;
44
+ - a deux solutions $\\sqrt{k}$ et $-\\sqrt{k}$ si $k>0$.`;
45
+ };
46
+ const getCorrection = (identifiers) => {
47
+ const { coeffs } = identifiers;
48
+ const trinom = TrinomConstructor.fromCoeffs(coeffs);
49
+ const a = trinom.a;
50
+ const alpha = trinom.getAlphaNode();
51
+ const beta = trinom.getBetaNode();
52
+ const cano = trinom.getCanonicalForm();
53
+ const k = frac(opposite(beta), a).simplify();
54
+ const roots = trinom.getRootsNode();
55
+ return `On a :
56
+
57
+ ${alignTex([
58
+ [cano.toTex(), "=", "0"],
59
+ [
60
+ substract(cano, beta).simplify({ forbidFactorize: true }).toTex(),
61
+ "=",
62
+ opposite(beta).simplify().toTex(),
63
+ ],
64
+ [square(substract("x", alpha).simplify()).toTex(), "=", k.toTex()],
65
+ ])}
66
+
67
+ ${alpha.evaluate() === 0
68
+ ? `Cela donne donc deux solutions : $${roots[0].toTex()}$ et $${roots[1].toTex()}$.`
69
+ : `
70
+ On résout alors deux équations :
71
+
72
+ ${alignTex([
73
+ [substract("x", alpha).simplify().toTex(), "=", sqrt(k).simplify().toTex()],
74
+ ["x", "=", add(alpha, sqrt(k)).simplify().toTex()],
75
+ ])}
76
+
77
+ ou
78
+
79
+ ${alignTex([
80
+ [
81
+ substract("x", alpha).simplify().toTex(),
82
+ "=",
83
+ opposite(sqrt(k)).simplify().toTex(),
84
+ ],
85
+ ["x", "=", substract(alpha, sqrt(k)).simplify().toTex()],
86
+ ])}
87
+ `}
88
+
89
+ L'ensemble des solutions est donc :
90
+
91
+ $$
92
+ ${getAnswer(identifiers)}
93
+ $$
94
+ `;
95
+ };
96
+ const getKeys = () => {
97
+ return ["S", "equal", "lbrace", "semicolon", "rbrace", "varnothing"];
98
+ };
32
99
  const getQuestionFromIdentifiers = (identifiers) => {
33
100
  const question = {
34
101
  answer: getAnswer(identifiers),
35
102
  instruction: getInstruction(identifiers),
36
- keys: [...equationKeys],
103
+ keys: getKeys(identifiers),
37
104
  answerFormat: "tex",
38
105
  identifiers,
106
+ hint: getHint(identifiers),
107
+ correction: getCorrection(identifiers),
39
108
  };
40
109
  return question;
41
110
  };
@@ -68,4 +137,5 @@ export const solveSecondDegreeEquationFromCano = {
68
137
  isAnswerValid,
69
138
  subject: "Mathématiques",
70
139
  getQuestionFromIdentifiers,
140
+ hasHintAndCorrection: true,
71
141
  };
@@ -0,0 +1,13 @@
1
+ import { Exercise } from "../../../../../exercises/exercise.js";
2
+ type EquationIds = {
3
+ a: number;
4
+ b: number;
5
+ c: number;
6
+ form: "dev" | "cano" | "facto";
7
+ };
8
+ type Identifiers = {
9
+ equations: EquationIds[];
10
+ };
11
+ export declare const trinomSelectEquationWithoutDeltaNeeded: Exercise<Identifiers>;
12
+ export {};
13
+ //# sourceMappingURL=trinomSelectEquationWithoutDeltaNeeded.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trinomSelectEquationWithoutDeltaNeeded.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/equation/trinomSelectEquationWithoutDeltaNeeded.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;CAChC,CAAC;AACF,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,WAAW,EAAE,CAAC;CAC1B,CAAC;AA6MF,eAAO,MAAM,sCAAsC,EAAE,QAAQ,CAAC,WAAW,CAqBxE,CAAC"}
@@ -0,0 +1,204 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { Trinom, TrinomConstructor } from "../../../../../math/polynomials/trinom.js";
4
+ import { randint } from "../../../../../math/utils/random/randint.js";
5
+ import { opposite } from "../../../../../tree/nodes/functions/oppositeNode.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 { square } from "../../../../../tree/nodes/operators/powerNode.js";
10
+ import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
11
+ import { coinFlip } from "../../../../../utils/alea/coinFlip.js";
12
+ import { shuffle } from "../../../../../utils/alea/shuffle.js";
13
+ import { doWhile } from "../../../../../utils/doWhile.js";
14
+ const buildEquation = (equationIds) => {
15
+ const { a, b, c, form } = equationIds;
16
+ const trinom = new Trinom(a, b, c);
17
+ if (form === "dev")
18
+ return trinom.toTree();
19
+ if (form === "cano")
20
+ return trinom.getCanonicalForm();
21
+ return trinom.toFactorized();
22
+ };
23
+ const isEqWithoutDelta = (equationIds) => {
24
+ const { b, c, form } = equationIds;
25
+ return form === "cano" || form === "facto" || b === 0 || c === 0;
26
+ };
27
+ const getPropositions = (n, { answer: _answer, equations }) => {
28
+ const propositions = [];
29
+ equations.forEach((eq) => {
30
+ (isEqWithoutDelta(eq) ? addValidProp : tryToAddWrongProp)(propositions, buildEquation(eq).toTex() + "=0");
31
+ });
32
+ return shuffleProps(propositions, n);
33
+ };
34
+ const getInstruction = () => {
35
+ return `Parmi les équations suivantes, laquelle ou lesquelles sont plus rapides à résoudre sans utiliser le discriminant ?`;
36
+ };
37
+ const getHint = () => {
38
+ return `Il n'est pas toujours nécessaire de calculer $\\Delta$ pour résoudre une équation du second degré.
39
+
40
+ En particulier, on sait résoudre :
41
+
42
+ - une équation du type : $x^2 = k$. Les solutions sont $\\pm \\sqrt{k}$ si $k$ est positif.
43
+ - une équation produit nul :
44
+
45
+ $$
46
+ a(x-x_1)(x-x_2) = 0
47
+ $$
48
+
49
+ Les solutions sont $x_1$ et $x_2$ si $a$ est non nul.`;
50
+ };
51
+ const getCorrection = (identifiers) => {
52
+ const getCorrForEq = (eq) => {
53
+ const eqNode = buildEquation(eq);
54
+ const isNoDelta = isEqWithoutDelta(eq);
55
+ const trinom = new Trinom(eq.a, eq.b, eq.c);
56
+ if (isNoDelta) {
57
+ const roots = trinom.getRootsNode();
58
+ const rootsSolTex = !roots.length
59
+ ? `il n'y a pas de solution réelle`
60
+ : roots.length === 1
61
+ ? `la solution est $${roots[0].toTex()}$`
62
+ : `les solutions sont
63
+ $${roots[0].toTex()}$ et $${roots[1].toTex()}$`;
64
+ if (eq.form === "facto") {
65
+ return `- L'équation $${eqNode.toTex()}=0$ est une équation produit nul, car le membre de gauche est sous forme factorisée. On peut facilement la résoudre sans utiliser le discriminant : ${rootsSolTex}.`;
66
+ }
67
+ if (eq.c === 0) {
68
+ return `- L'équation $${eqNode.toTex()}=0$ peut se factoriser par $x$ :
69
+
70
+ $$
71
+ ${multiply("x", add(multiply(eq.a, "x"), eq.b)).toTex()} = 0
72
+ $$
73
+
74
+ On peut alors facilement la résoudre sans utiliser le discriminant : ${rootsSolTex}.
75
+ `;
76
+ }
77
+ if (eq.b === 0) {
78
+ return `- L'équation $${eqNode.toTex()}=0$ peut se réécrire :
79
+
80
+ $$
81
+ ${multiply(eq.a, square("x")).toTex()} = ${opposite(eq.c).simplify().toTex()}
82
+ $$
83
+
84
+ C'est donc une équation du type $x^2 = k$, on peut la résoudre sans discriminant : ${rootsSolTex}.
85
+ `;
86
+ }
87
+ if (eq.form === "cano") {
88
+ const alpha = trinom.getAlphaNode();
89
+ const beta = trinom.getBetaNode();
90
+ return `- L'équation $${eqNode.toTex()}$ peut se réécrire :
91
+
92
+ $$
93
+ ${square(substract("x", alpha).simplify()).toTex()} = ${frac(opposite(beta), eq.a).toTex()}
94
+ $$
95
+
96
+ C'est donc une équation du type $X^2 = k$, avec $X = ${substract("x", alpha)
97
+ .simplify()
98
+ .toTex()}$. On peut la résoudre sans utiliser le discriminant : ${rootsSolTex}.`;
99
+ }
100
+ }
101
+ return `- L'équation $${eqNode.toTex()}=0$ ne peut pas facilement se factoriser, et on ne peut pas la ramener à une équation du type $x^2 = k$. Pour cette équation, il est donc pertinent d'utiliser le discriminant.`;
102
+ };
103
+ return `Essayons de résoudre chacune des équations :
104
+
105
+ ${identifiers.equations.map((e) => getCorrForEq(e)).join("\n")}
106
+
107
+ `;
108
+ };
109
+ const getTrinomSelectEquationWithoutDeltaNeededQuestion = () => {
110
+ let equations = [];
111
+ const getEqNoDelta = () => {
112
+ const type = randint(0, 4);
113
+ const a = randint(-9, 10, [0]);
114
+ if (type === 0) {
115
+ const c = randint(-9, 10, [0]);
116
+ return {
117
+ a,
118
+ b: 0,
119
+ c,
120
+ form: "dev",
121
+ };
122
+ }
123
+ if (type === 1) {
124
+ const b = randint(-9, 10, [0]);
125
+ return {
126
+ a,
127
+ b,
128
+ c: 0,
129
+ form: "dev",
130
+ };
131
+ }
132
+ if (type === 2) {
133
+ const trinom = TrinomConstructor.randomNiceRoots();
134
+ return {
135
+ a: trinom.a,
136
+ b: trinom.b,
137
+ c: trinom.c,
138
+ form: "facto",
139
+ };
140
+ }
141
+ else {
142
+ const trinom = TrinomConstructor.randomCanonical();
143
+ return {
144
+ a: trinom.a,
145
+ b: trinom.b,
146
+ c: trinom.c,
147
+ form: "cano",
148
+ };
149
+ }
150
+ };
151
+ const getEqDelta = () => {
152
+ let a, b, c;
153
+ do {
154
+ a = randint(-9, 10, [0]);
155
+ b = randint(-9, 10, [0]);
156
+ c = randint(-9, 10, [0]);
157
+ //delta = 0 => factorisation par idRmq trop simple
158
+ //! il reste le cas "une racine est évidente" et je trouve facilement la deuxième grâce à c...
159
+ } while (b ** 2 - 4 * a * c === 0);
160
+ return {
161
+ a,
162
+ b,
163
+ c,
164
+ form: "dev",
165
+ };
166
+ };
167
+ equations = [getEqDelta(), getEqNoDelta()];
168
+ for (let i = 0; i < 2; i++) {
169
+ const eq = doWhile(() => (coinFlip() ? getEqDelta() : getEqNoDelta()), (eq) => equations.some((e) => e.a === eq.a && e.b === eq.b && e.c === eq.c && e.form === eq.form));
170
+ equations.push(eq);
171
+ }
172
+ const shuffled = shuffle(equations);
173
+ const identifiers = {
174
+ equations: shuffled,
175
+ };
176
+ return getQuestionFromIdentifiers(identifiers);
177
+ };
178
+ const getQuestionFromIdentifiers = (identifiers) => {
179
+ return {
180
+ instruction: getInstruction(identifiers),
181
+ keys: [],
182
+ answerFormat: "tex",
183
+ identifiers,
184
+ hint: getHint(identifiers),
185
+ correction: getCorrection(identifiers),
186
+ };
187
+ };
188
+ export const trinomSelectEquationWithoutDeltaNeeded = {
189
+ id: "trinomSelectEquationWithoutDeltaNeeded",
190
+ label: "Repérer les équations du second degré qui ne nécessitent pas le calcul du discriminant",
191
+ isSingleStep: true,
192
+ generator: (nb, opts) => getDistinctQuestions(() => getTrinomSelectEquationWithoutDeltaNeededQuestion(opts), nb),
193
+ qcmTimer: 60,
194
+ freeTimer: 60,
195
+ getPropositions,
196
+ subject: "Mathématiques",
197
+ getInstruction,
198
+ getHint,
199
+ getCorrection,
200
+ getQuestionFromIdentifiers,
201
+ hasHintAndCorrection: true,
202
+ isQCM: true,
203
+ answerType: "QCM",
204
+ };
@@ -1,3 +1,5 @@
1
1
  export * from "./trinomSignFromRoots.js";
2
2
  export * from "./trinomSignFromFacto.js";
3
+ export * from "./trinomSignTableFromAlgebraicForm.js";
4
+ export * from "./parabolaSignTable.js";
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/sign/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/sign/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uCAAuC,CAAC;AACtD,cAAc,wBAAwB,CAAC"}
@@ -1,2 +1,4 @@
1
1
  export * from "./trinomSignFromRoots.js";
2
2
  export * from "./trinomSignFromFacto.js";
3
+ export * from "./trinomSignTableFromAlgebraicForm.js";
4
+ export * from "./parabolaSignTable.js";
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ a: number;
4
+ b: number;
5
+ c: number;
6
+ };
7
+ export declare const parabolaSignTable: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=parabolaSignTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parabolaSignTable.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/sign/parabolaSignTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAuHF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAoBnD,CAAC"}
@@ -0,0 +1,123 @@
1
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
2
+ import { GeogebraConstructor } from "../../../../../geogebra/geogebraConstructor.js";
3
+ import { Trinom, TrinomConstructor } from "../../../../../math/polynomials/trinom.js";
4
+ import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
5
+ const getInstruction = () => {
6
+ return `Ci-dessous est tracée la parabole qui représente graphiquement une fonction polynôme du second degré $f$ définie sur $\\mathbb{R}$.
7
+
8
+ Dresser le tableau de signes de $f$.`;
9
+ };
10
+ const getHint = () => {
11
+ return `La fonction est définie sur $\\mathbb{R}$, donc les valeurs de $x$ vont de $-\\infty$ à $+\\infty$.
12
+
13
+ Repère ensuite les points de la courbe à l'intersection de l'axe des abscisses. Dans la première ligne du tableau, il faut mettre les abscisses de ces points, et dans la deuxième ligne, le signe de $f(x)$.`;
14
+ };
15
+ const getCorrection = (identifiers) => {
16
+ const { a, b, c } = identifiers;
17
+ const trinom = new Trinom(a, b, c);
18
+ const roots = trinom.getRootsNode();
19
+ const sign = a > 0 ? "positive" : "négative";
20
+ const oppSign = a > 0 ? "négative" : "positive";
21
+ return `On lit graphiquement que les racines de $f$ sont $${roots[0].toTex()}$ et $${roots[1].toTex()}$.
22
+
23
+ Entre ces racines, c'est à dire sur l'intervalle $\\left[${roots[0].toTex()};${roots[1].toTex()}\\right]$, $f(x)$ est ${oppSign}.
24
+
25
+ Pour les valeurs de l'intervalle $\\left]-\\infty;${roots[0].toTex()}\\right]$ et de l'intervalle $\\left[${roots[1].toTex()};+\\infty \\right[$, $f(x)$ est ${sign}.
26
+ `;
27
+ };
28
+ const getGGBOptions = (identifiers) => {
29
+ const { a, b, c } = identifiers;
30
+ const trinom = new Trinom(a, b, c);
31
+ const roots = trinom.getRoots();
32
+ const beta = trinom.getBeta();
33
+ const ggb = new GeogebraConstructor({
34
+ commands: [`f(x) = ${a}*x^2 + ${b}*x + ${c}`],
35
+ lockedAxesRatio: false,
36
+ gridDistance: false,
37
+ xAxis: {
38
+ steps: 1,
39
+ },
40
+ });
41
+ const xMin = roots[0] - 2;
42
+ const xMax = roots[1] + 2;
43
+ const yMin = a > 0 ? beta : -5;
44
+ const yMax = a < 0 ? beta : 5;
45
+ return ggb.getOptions({
46
+ coords: [xMin, xMax, yMin, yMax],
47
+ });
48
+ };
49
+ const getKeys = () => {
50
+ return ["infty"];
51
+ };
52
+ const getAnswerTable = (identifiers) => {
53
+ const { a, b, c } = identifiers;
54
+ const trinom = new Trinom(a, b, c);
55
+ const roots = trinom.getRootsNode();
56
+ const opp = a > 0 ? "-" : "+";
57
+ const sign = a > 0 ? "+" : "-";
58
+ return [
59
+ [
60
+ "$x$",
61
+ "-\\infty",
62
+ "\\ ",
63
+ roots[0].toTex(),
64
+ "\\ ",
65
+ roots[1].toTex(),
66
+ "\\ ",
67
+ "+\\infty",
68
+ ],
69
+ ["$f(x)$", "\\ ", sign, "0", opp, "0", sign, "\\ "],
70
+ ];
71
+ };
72
+ const isAnswerTableValid = (ans, { answerTable }) => {
73
+ try {
74
+ return ans.every((row, i) => row.every((cell, j) => cell === answerTable[i][j]));
75
+ }
76
+ catch (err) {
77
+ return handleVEAError(err);
78
+ }
79
+ };
80
+ const getSignTableFromGraphQuestion = () => {
81
+ const trinom = TrinomConstructor.randomNiceRoots(2);
82
+ const identifiers = {
83
+ a: trinom.a,
84
+ b: trinom.b,
85
+ c: trinom.c,
86
+ };
87
+ return getQuestionFromIdentifiers(identifiers);
88
+ };
89
+ const getQuestionFromIdentifiers = (identifiers) => {
90
+ return {
91
+ answerTable: getAnswerTable(identifiers),
92
+ instruction: getInstruction(identifiers),
93
+ keys: getKeys(identifiers),
94
+ answerFormat: "tex",
95
+ identifiers,
96
+ hint: getHint(identifiers),
97
+ correction: getCorrection(identifiers),
98
+ ggbOptions: getGGBOptions(identifiers),
99
+ initTable: [
100
+ ["$x$", "", "\\ ", "", "\\ ", "", "\\ ", ""],
101
+ ["$f(x)$", "\\ ", "", "", "", "", "", "\\ "],
102
+ ],
103
+ };
104
+ };
105
+ export const parabolaSignTable = {
106
+ id: "parabolaSignTable",
107
+ label: "Dresser le tableau de signes d'une parabole représentée graphiquement",
108
+ isSingleStep: true,
109
+ generator: (nb, opts) => getDistinctQuestions(() => getSignTableFromGraphQuestion(opts), nb),
110
+ qcmTimer: 60,
111
+ freeTimer: 60,
112
+ isAnswerTableValid,
113
+ subject: "Mathématiques",
114
+ getHint,
115
+ getCorrection,
116
+ getInstruction,
117
+ getAnswerTable,
118
+ getGGBOptions,
119
+ hasGeogebra: true,
120
+ getQuestionFromIdentifiers,
121
+ answerType: "signTable",
122
+ hasHintAndCorrection: true,
123
+ };
@@ -0,0 +1,13 @@
1
+ import { Exercise } from "../../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ a: number;
4
+ b: number;
5
+ c: number;
6
+ form: "dev" | "cano" | "facto";
7
+ };
8
+ type Options = {
9
+ givenForm: string;
10
+ };
11
+ export declare const trinomSignTableFromAlgebraicForm: Exercise<Identifiers, Options>;
12
+ export {};
13
+ //# sourceMappingURL=trinomSignTableFromAlgebraicForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trinomSignTableFromAlgebraicForm.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/sign/trinomSignTableFromAlgebraicForm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;CAChC,CAAC;AAwMF,KAAK,OAAO,GAAG;IACb,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAWF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAoBzE,CAAC"}