math-exercises 3.0.10 → 3.0.11

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 (128) hide show
  1. package/lib/exercises/math/calcul/fractions/fractionsOperations.d.ts.map +1 -1
  2. package/lib/exercises/math/calcul/fractions/fractionsOperations.js +0 -1
  3. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType1.js +1 -1
  4. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.d.ts.map +1 -1
  5. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.js +6 -2
  6. package/lib/exercises/math/functions/trinoms/devForm/coefficientsIdentification.d.ts +11 -0
  7. package/lib/exercises/math/functions/trinoms/devForm/coefficientsIdentification.d.ts.map +1 -0
  8. package/lib/exercises/math/functions/trinoms/devForm/coefficientsIdentification.js +134 -0
  9. package/lib/exercises/math/functions/trinoms/devForm/index.d.ts +3 -0
  10. package/lib/exercises/math/functions/trinoms/devForm/index.d.ts.map +1 -0
  11. package/lib/exercises/math/functions/trinoms/devForm/index.js +2 -0
  12. package/lib/exercises/math/functions/trinoms/devForm/variationsFromAlgebricForm.d.ts +9 -0
  13. package/lib/exercises/math/functions/trinoms/devForm/variationsFromAlgebricForm.d.ts.map +1 -0
  14. package/lib/exercises/math/functions/trinoms/devForm/variationsFromAlgebricForm.js +42 -0
  15. package/lib/exercises/math/functions/trinoms/equation/deltaTrinom.d.ts +9 -0
  16. package/lib/exercises/math/functions/trinoms/equation/deltaTrinom.d.ts.map +1 -0
  17. package/lib/exercises/math/functions/trinoms/equation/deltaTrinom.js +50 -0
  18. package/lib/exercises/math/functions/trinoms/equation/index.d.ts +5 -0
  19. package/lib/exercises/math/functions/trinoms/equation/index.d.ts.map +1 -0
  20. package/lib/exercises/math/functions/trinoms/equation/index.js +4 -0
  21. package/lib/exercises/math/functions/trinoms/equation/secondDegreeInequation.d.ts +11 -0
  22. package/lib/exercises/math/functions/trinoms/equation/secondDegreeInequation.d.ts.map +1 -0
  23. package/lib/exercises/math/functions/trinoms/equation/secondDegreeInequation.js +102 -0
  24. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationByFactorisation.d.ts +9 -0
  25. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationByFactorisation.d.ts.map +1 -0
  26. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationByFactorisation.js +131 -0
  27. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationFromCano.d.ts +7 -0
  28. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationFromCano.d.ts.map +1 -0
  29. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationFromCano.js +69 -0
  30. package/lib/exercises/math/functions/trinoms/factoForm/factorizedFormFromRoots.d.ts +8 -0
  31. package/lib/exercises/math/functions/trinoms/factoForm/factorizedFormFromRoots.d.ts.map +1 -0
  32. package/lib/exercises/math/functions/trinoms/factoForm/factorizedFormFromRoots.js +72 -0
  33. package/lib/exercises/math/functions/trinoms/factoForm/index.d.ts +2 -0
  34. package/lib/exercises/math/functions/trinoms/factoForm/index.d.ts.map +1 -0
  35. package/lib/exercises/math/functions/trinoms/factoForm/index.js +1 -0
  36. package/lib/exercises/math/functions/trinoms/index.d.ts +7 -23
  37. package/lib/exercises/math/functions/trinoms/index.d.ts.map +1 -1
  38. package/lib/exercises/math/functions/trinoms/index.js +7 -23
  39. package/lib/exercises/math/functions/trinoms/parabole/index.d.ts +3 -0
  40. package/lib/exercises/math/functions/trinoms/parabole/index.d.ts.map +1 -0
  41. package/lib/exercises/math/functions/trinoms/parabole/index.js +2 -0
  42. package/lib/exercises/math/functions/trinoms/parabole/paraboleExpressionReading.d.ts +8 -0
  43. package/lib/exercises/math/functions/trinoms/parabole/paraboleExpressionReading.d.ts.map +1 -0
  44. package/lib/exercises/math/functions/trinoms/parabole/paraboleExpressionReading.js +285 -0
  45. package/lib/exercises/math/functions/trinoms/parabole/trinomSymetryAxisFromFacto.d.ts +9 -0
  46. package/lib/exercises/math/functions/trinoms/parabole/trinomSymetryAxisFromFacto.d.ts.map +1 -0
  47. package/lib/exercises/math/functions/trinoms/parabole/trinomSymetryAxisFromFacto.js +112 -0
  48. package/lib/exercises/math/functions/trinoms/roots/findSecondRoot.d.ts +10 -0
  49. package/lib/exercises/math/functions/trinoms/roots/findSecondRoot.d.ts.map +1 -0
  50. package/lib/exercises/math/functions/trinoms/roots/findSecondRoot.js +124 -0
  51. package/lib/exercises/math/functions/trinoms/roots/index.d.ts +8 -0
  52. package/lib/exercises/math/functions/trinoms/roots/index.d.ts.map +1 -0
  53. package/lib/exercises/math/functions/trinoms/roots/index.js +7 -0
  54. package/lib/exercises/math/functions/trinoms/roots/niceRootsFromDevForm.d.ts +9 -0
  55. package/lib/exercises/math/functions/trinoms/roots/niceRootsFromDevForm.d.ts.map +1 -0
  56. package/lib/exercises/math/functions/trinoms/roots/niceRootsFromDevForm.js +54 -0
  57. package/lib/exercises/math/functions/trinoms/roots/rootsFromDevForm.d.ts +9 -0
  58. package/lib/exercises/math/functions/trinoms/roots/rootsFromDevForm.d.ts.map +1 -0
  59. package/lib/exercises/math/functions/trinoms/roots/rootsFromDevForm.js +55 -0
  60. package/lib/exercises/math/functions/trinoms/roots/rootsFromFactorizedForm.d.ts +9 -0
  61. package/lib/exercises/math/functions/trinoms/roots/rootsFromFactorizedForm.d.ts.map +1 -0
  62. package/lib/exercises/math/functions/trinoms/roots/rootsFromFactorizedForm.js +67 -0
  63. package/lib/exercises/math/functions/trinoms/roots/rootsProduct.d.ts +8 -0
  64. package/lib/exercises/math/functions/trinoms/roots/rootsProduct.d.ts.map +1 -0
  65. package/lib/exercises/math/functions/trinoms/roots/rootsProduct.js +109 -0
  66. package/lib/exercises/math/functions/trinoms/roots/rootsReading.d.ts +9 -0
  67. package/lib/exercises/math/functions/trinoms/roots/rootsReading.d.ts.map +1 -0
  68. package/lib/exercises/math/functions/trinoms/roots/rootsReading.js +63 -0
  69. package/lib/exercises/math/functions/trinoms/roots/rootsSum.d.ts +8 -0
  70. package/lib/exercises/math/functions/trinoms/roots/rootsSum.d.ts.map +1 -0
  71. package/lib/exercises/math/functions/trinoms/roots/rootsSum.js +109 -0
  72. package/lib/exercises/math/functions/trinoms/sign/index.d.ts +3 -0
  73. package/lib/exercises/math/functions/trinoms/sign/index.d.ts.map +1 -0
  74. package/lib/exercises/math/functions/trinoms/sign/index.js +2 -0
  75. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromFacto.d.ts +8 -0
  76. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromFacto.d.ts.map +1 -0
  77. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromFacto.js +120 -0
  78. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromRoots.d.ts +8 -0
  79. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromRoots.d.ts.map +1 -0
  80. package/lib/exercises/math/functions/trinoms/sign/trinomSignFromRoots.js +119 -0
  81. package/lib/exercises/math/functions/trinoms/summitAndCanonical/alphaBetaFromDevForm.d.ts +8 -0
  82. package/lib/exercises/math/functions/trinoms/summitAndCanonical/alphaBetaFromDevForm.d.ts.map +1 -0
  83. package/lib/exercises/math/functions/trinoms/summitAndCanonical/alphaBetaFromDevForm.js +49 -0
  84. package/lib/exercises/math/functions/trinoms/summitAndCanonical/alphaBetaInCanonicalForm.d.ts +10 -0
  85. package/lib/exercises/math/functions/trinoms/summitAndCanonical/alphaBetaInCanonicalForm.d.ts.map +1 -0
  86. package/lib/exercises/math/functions/trinoms/summitAndCanonical/alphaBetaInCanonicalForm.js +64 -0
  87. package/lib/exercises/math/functions/trinoms/summitAndCanonical/canonicalFromDevForm.d.ts +9 -0
  88. package/lib/exercises/math/functions/trinoms/summitAndCanonical/canonicalFromDevForm.d.ts.map +1 -0
  89. package/lib/exercises/math/functions/trinoms/summitAndCanonical/canonicalFromDevForm.js +48 -0
  90. package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumFromCanonicalForm.d.ts +9 -0
  91. package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumFromCanonicalForm.d.ts.map +1 -0
  92. package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumFromCanonicalForm.js +55 -0
  93. package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumTypeFromAlgebricForm.d.ts +9 -0
  94. package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumTypeFromAlgebricForm.d.ts.map +1 -0
  95. package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumTypeFromAlgebricForm.js +42 -0
  96. package/lib/exercises/math/functions/trinoms/summitAndCanonical/index.d.ts +9 -0
  97. package/lib/exercises/math/functions/trinoms/summitAndCanonical/index.d.ts.map +1 -0
  98. package/lib/exercises/math/functions/trinoms/summitAndCanonical/index.js +8 -0
  99. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitAbscissFromDevForm.d.ts +9 -0
  100. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitAbscissFromDevForm.d.ts.map +1 -0
  101. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitAbscissFromDevForm.js +90 -0
  102. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitAbscissFromRoots.d.ts +9 -0
  103. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitAbscissFromRoots.d.ts.map +1 -0
  104. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitAbscissFromRoots.js +55 -0
  105. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitReading.d.ts +9 -0
  106. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitReading.d.ts.map +1 -0
  107. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitReading.js +59 -0
  108. package/lib/exercises/math/geometry/areas/triangleArea.d.ts +2 -0
  109. package/lib/exercises/math/geometry/areas/triangleArea.d.ts.map +1 -1
  110. package/lib/exercises/math/geometry/areas/triangleArea.js +56 -31
  111. package/lib/exercises/math/geometry/cartesian/drawAlineInGGB.d.ts.map +1 -1
  112. package/lib/exercises/math/geometry/cartesian/drawAlineInGGB.js +34 -14
  113. package/lib/index.d.ts +42 -31
  114. package/lib/index.d.ts.map +1 -1
  115. package/lib/math/geometry/triangle.d.ts +1 -0
  116. package/lib/math/geometry/triangle.d.ts.map +1 -1
  117. package/lib/math/geometry/triangle.js +10 -2
  118. package/lib/math/systems/generalSystem.d.ts.map +1 -1
  119. package/lib/tests/questionTest.d.ts.map +1 -1
  120. package/lib/tests/questionTest.js +1 -1
  121. package/lib/tree/nodes/algebraicNode.d.ts +1 -0
  122. package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
  123. package/lib/tree/nodes/polynomials/trinomNode.d.ts +1 -0
  124. package/lib/tree/nodes/polynomials/trinomNode.d.ts.map +1 -1
  125. package/lib/tree/nodes/polynomials/trinomNode.js +9 -0
  126. package/lib/tree/nodes/variables/variableNode.d.ts.map +1 -1
  127. package/lib/tree/nodes/variables/variableNode.js +1 -3
  128. package/package.json +1 -1
@@ -0,0 +1,112 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { rationalVEA } from "../../../../../exercises/vea/rationalVEA.js";
4
+ import { RationalConstructor } from "../../../../../math/numbers/rationals/rational.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 { substract } from "../../../../../tree/nodes/operators/substractNode.js";
10
+ import { equationSolutionParser } from "../../../../../tree/parsers/equationSolutionParser.js";
11
+ import { coinFlip } from "../../../../../utils/alea/coinFlip.js";
12
+ import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
13
+ const getPropositions = (n, { answer }) => {
14
+ const propositions = [];
15
+ addValidProp(propositions, answer);
16
+ while (propositions.length < n) {
17
+ const wrong = coinFlip()
18
+ ? randint(-10, 10) + ""
19
+ : RationalConstructor.randomIrreductible().toTree().toTex();
20
+ tryToAddWrongProp(propositions, `x=${wrong}`);
21
+ }
22
+ return shuffleProps(propositions, n);
23
+ };
24
+ const getAnswer = (identifiers) => {
25
+ const { a, x1, x2 } = identifiers;
26
+ const alpha = frac(add(x1, x2), 2).simplify().toTex();
27
+ return `x=${alpha}`;
28
+ };
29
+ const getInstruction = (identifiers) => {
30
+ const { a, x1, x2 } = identifiers;
31
+ const node = multiply(a, multiply(substract("x", x1), substract("x", x2))).simplify({ forbidFactorize: true });
32
+ return `Soit $f$ la fonction polynôme du second degré définie sur $\\mathbb{R}$ par :
33
+
34
+ $$
35
+ f(x) = ${node.toTex()}
36
+ $$
37
+
38
+ Déterminer l'équation de l'axe de symétrie de la parabole représentant $f$.
39
+ `;
40
+ };
41
+ const getHint = (identifiers) => {
42
+ return `Si $x_1$ et $x_2$ sont deux racines distinctes de $f$, alors l'axe de symétrie de la parabole représentant $f$ a pour équation :
43
+
44
+ $$
45
+ x=\\frac{x_1+x_2}{2}
46
+ $$`;
47
+ };
48
+ const getCorrection = (identifiers) => {
49
+ const { a, x1, x2 } = identifiers;
50
+ const fraction = frac(add(x1, x2), 2);
51
+ return `$f$ admet deux racines distinctes : $${x1}$ et $${x2}$.
52
+
53
+ L'axe de symétrie de la parabole représentant $f$ a donc pour équation :
54
+
55
+ $$
56
+ x=${fraction.toTex()}=${frac(x1 + x2, 2).toSimplificationString()}
57
+ $$`;
58
+ };
59
+ const getKeys = (identifiers) => {
60
+ return ["x", "equal"];
61
+ };
62
+ const isAnswerValid = (ans, { answer, a, x1, x2 }) => {
63
+ try {
64
+ const solutionTex = frac(add(x1, x2), 2).simplify().toTex();
65
+ let parsed = equationSolutionParser(ans);
66
+ if (!parsed)
67
+ return false;
68
+ return rationalVEA(parsed.toTex(), solutionTex);
69
+ }
70
+ catch (err) {
71
+ return handleVEAError(err);
72
+ }
73
+ };
74
+ const getTrinomSymetryAxisFromFactoQuestion = (ops) => {
75
+ const a = randint(-10, 11, [0]);
76
+ let x1 = randint(-10, 11);
77
+ let x2 = randint(-10, 11, [x1]);
78
+ if (x1 > x2)
79
+ [x1, x2] = [x2, x1];
80
+ const identifiers = {
81
+ a,
82
+ x1,
83
+ x2,
84
+ };
85
+ const question = {
86
+ answer: getAnswer(identifiers),
87
+ instruction: getInstruction(identifiers),
88
+ keys: getKeys(identifiers),
89
+ answerFormat: "tex",
90
+ identifiers,
91
+ hint: getHint(identifiers),
92
+ correction: getCorrection(identifiers),
93
+ };
94
+ return question;
95
+ };
96
+ export const trinomSymetryAxisFromFacto = {
97
+ id: "trinomSymetryAxisFromFacto",
98
+ connector: "\\iff",
99
+ label: "Déterminer l'axe de symétrie d'une parabole en connaissant la forme factorisée",
100
+ isSingleStep: true,
101
+ generator: (nb, opts) => getDistinctQuestions(() => getTrinomSymetryAxisFromFactoQuestion(opts), nb),
102
+ qcmTimer: 60,
103
+ freeTimer: 60,
104
+ getPropositions,
105
+ isAnswerValid,
106
+ subject: "Mathématiques",
107
+ getInstruction,
108
+ getHint,
109
+ getCorrection,
110
+ getAnswer,
111
+ hasHintAndCorrection: true,
112
+ };
@@ -0,0 +1,10 @@
1
+ import { Exercise } from "../../../../../exercises/exercise.js";
2
+ import { TrinomNodeIdentifiers } from "../../../../../tree/nodes/polynomials/trinomNode.js";
3
+ import { NodeIdentifiers } from "../../../../../tree/nodes/nodeConstructor.js";
4
+ type Identifiers = {
5
+ trinomIdentifiers: TrinomNodeIdentifiers;
6
+ firstRootIdentifiers: NodeIdentifiers;
7
+ };
8
+ export declare const findSecondRoot: Exercise<Identifiers>;
9
+ export {};
10
+ //# sourceMappingURL=findSecondRoot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findSecondRoot.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/roots/findSecondRoot.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAGL,qBAAqB,EACtB,MAAM,4CAA4C,CAAC;AAIpD,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAO7C,KAAK,WAAW,GAAG;IACjB,iBAAiB,EAAE,qBAAqB,CAAC;IACzC,oBAAoB,EAAE,eAAe,CAAC;CACvC,CAAC;AAiHF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAiBhD,CAAC"}
@@ -0,0 +1,124 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { rationalVEA } from "../../../../../exercises/vea/rationalVEA.js";
4
+ import { TrinomNode, TrinomNodeConstructor, } from "../../../../../tree/nodes/polynomials/trinomNode.js";
5
+ import { randint } from "../../../../../math/utils/random/randint.js";
6
+ import { opposite } from "../../../../../tree/nodes/functions/oppositeNode.js";
7
+ import { NodeConstructor, } from "../../../../../tree/nodes/nodeConstructor.js";
8
+ import { add } from "../../../../../tree/nodes/operators/addNode.js";
9
+ import { frac } from "../../../../../tree/nodes/operators/fractionNode.js";
10
+ import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
11
+ const getPropositions = (n, { answer }) => {
12
+ const propositions = [];
13
+ addValidProp(propositions, answer);
14
+ while (propositions.length < n) {
15
+ tryToAddWrongProp(propositions, randint(-10, 10).frenchify());
16
+ }
17
+ return shuffleProps(propositions, n);
18
+ };
19
+ const getAnswer = (identifiers) => {
20
+ const { trinomIdentifiers, firstRootIdentifiers } = identifiers;
21
+ const trinom = TrinomNodeConstructor.fromIdentifiers(trinomIdentifiers);
22
+ const firstRoot = NodeConstructor.fromIdentifiers(firstRootIdentifiers);
23
+ const firstRootTex = firstRoot.toTex();
24
+ const roots = trinom.getRoots().map((e) => e.toTex());
25
+ return roots.find((r) => r !== firstRootTex);
26
+ };
27
+ const getInstruction = (identifiers) => {
28
+ const { trinomIdentifiers, firstRootIdentifiers } = identifiers;
29
+ const trinom = TrinomNodeConstructor.fromIdentifiers(trinomIdentifiers);
30
+ const firstRoot = NodeConstructor.fromIdentifiers(firstRootIdentifiers);
31
+ const firstRootTex = firstRoot.toTex();
32
+ return `Soit $f$ la fonction polynôme du second degré définie sur $\\mathbb{R}$ par :
33
+
34
+ $$
35
+ f(x) = ${trinom.toTree().toTex()}
36
+ $$
37
+
38
+ On admet que $f$ admet deux racines, dont une vaut $${firstRootTex}$.
39
+
40
+ Sans calculer $\\Delta$, déterminer la deuxième racine de $f$.`;
41
+ };
42
+ const getHint = (identifiers) => {
43
+ return `Si $f(x) = ax^2 + bx + c$ admet deux racines $x_1$ et $x_2$, alors leur produit vaut :
44
+
45
+ $$
46
+ x_1\\times x_2 = \\frac{c}{a}
47
+ $$
48
+
49
+ En remplaçant les valeurs par celles données dans l'énoncé, on peut déterminer la deuxième racine de $f$.
50
+ `;
51
+ };
52
+ const getCorrection = (identifiers) => {
53
+ const { trinomIdentifiers, firstRootIdentifiers } = identifiers;
54
+ const trinom = TrinomNodeConstructor.fromIdentifiers(trinomIdentifiers);
55
+ const firstRoot = NodeConstructor.fromIdentifiers(firstRootIdentifiers);
56
+ const cOverA = frac(trinom.c, trinom.a).simplify();
57
+ return `On sait que le produit des racines $x_1$ et $x_2$ de $f$ vaut :
58
+
59
+ $$
60
+ x_1\\times x_2 = \\frac{c}{a} = ${cOverA.toTex()}
61
+ $$
62
+
63
+ Or on sait que $x_1 = ${firstRoot.toTex()}$. On a donc :
64
+
65
+ $$
66
+ x_2 = ${frac(cOverA, firstRoot).toSimplificationString()}
67
+ $$
68
+ `;
69
+ };
70
+ const getKeys = (identifiers) => {
71
+ return [];
72
+ };
73
+ const isAnswerValid = (ans, { answer }) => {
74
+ return rationalVEA(ans, answer);
75
+ };
76
+ const getFindSecondRootQuestion = (ops) => {
77
+ // const firstRoot = coinFlip()
78
+ // ? randint(-10, 10).toTree()
79
+ // : RationalConstructor.randomIrreductibleWithSign(5).toTree();
80
+ const firstRoot = randint(-10, 10, [0]);
81
+ // const secondRoot = doWhile(
82
+ // () =>
83
+ // coinFlip()
84
+ // ? randint(-10, 10).toTree()
85
+ // : RationalConstructor.randomIrreductibleWithSign(5).toTree(),
86
+ // (x) => x.equals(firstRoot),
87
+ // );
88
+ const secondRoot = randint(-10, 10, [firstRoot]);
89
+ const a = randint(-10, 10, [0]);
90
+ const b = opposite(multiply(a, add(firstRoot, secondRoot))).simplify();
91
+ const c = multiply(a, multiply(firstRoot, secondRoot)).simplify();
92
+ //first*second = c/a
93
+ const identifiers = {
94
+ firstRootIdentifiers: firstRoot.toTree().toIdentifiers(),
95
+ trinomIdentifiers: new TrinomNode(a, b, c).toIdentifiers(),
96
+ };
97
+ const question = {
98
+ answer: getAnswer(identifiers),
99
+ instruction: getInstruction(identifiers),
100
+ keys: getKeys(identifiers),
101
+ answerFormat: "tex",
102
+ identifiers,
103
+ hint: getHint(identifiers),
104
+ correction: getCorrection(identifiers),
105
+ };
106
+ return question;
107
+ };
108
+ export const findSecondRoot = {
109
+ id: "findSecondRoot",
110
+ connector: "=",
111
+ label: "Déterminer la deuxième racine d'un trinôme sans utiliser $\\Delta$",
112
+ isSingleStep: true,
113
+ generator: (nb, opts) => getDistinctQuestions(() => getFindSecondRootQuestion(opts), nb),
114
+ qcmTimer: 60,
115
+ freeTimer: 60,
116
+ getPropositions,
117
+ isAnswerValid,
118
+ subject: "Mathématiques",
119
+ getInstruction,
120
+ getHint,
121
+ getCorrection,
122
+ getAnswer,
123
+ hasHintAndCorrection: true,
124
+ };
@@ -0,0 +1,8 @@
1
+ export * from "./findSecondRoot.js";
2
+ export * from "./niceRootsFromDevForm.js";
3
+ export * from "./rootsFromDevForm.js";
4
+ export * from "./rootsFromFactorizedForm.js";
5
+ export * from "./rootsProduct.js";
6
+ export * from "./rootsReading.js";
7
+ export * from "./rootsSum.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/roots/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from "./findSecondRoot.js";
2
+ export * from "./niceRootsFromDevForm.js";
3
+ export * from "./rootsFromDevForm.js";
4
+ export * from "./rootsFromFactorizedForm.js";
5
+ export * from "./rootsProduct.js";
6
+ export * from "./rootsReading.js";
7
+ export * from "./rootsSum.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 niceRootsFromDevForm: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=niceRootsFromDevForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"niceRootsFromDevForm.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/roots/niceRootsFromDevForm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA0CF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CActD,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { addValidProp, 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 { EquationSolutionNode } from "../../../../../tree/nodes/equations/equationSolutionNode.js";
6
+ import { DiscreteSetNode } from "../../../../../tree/nodes/sets/discreteSetNode.js";
7
+ import { shuffle } from "../../../../../utils/alea/shuffle.js";
8
+ const getRootsFromDevFormQuestion = () => {
9
+ const trinom = TrinomConstructor.randomFactorized();
10
+ const answer = trinom.getRootsEquationSolutionTex();
11
+ const question = {
12
+ answer: answer,
13
+ instruction: `Soit $f(x) = ${trinom
14
+ .toTree()
15
+ .toTex()}$. Résoudre l'équation $f(x) = 0$.`,
16
+ keys: ["S", "equal", "lbrace", "semicolon", "rbrace", "varnothing"],
17
+ identifiers: { a: trinom.a, b: trinom.b, c: trinom.c },
18
+ answerFormat: "tex",
19
+ };
20
+ return question;
21
+ };
22
+ const getPropositions = (n, { answer }) => {
23
+ const propositions = [];
24
+ addValidProp(propositions, answer);
25
+ tryToAddWrongProp(propositions, "S=\\varnothing");
26
+ while (propositions.length < n) {
27
+ let wrongX1 = randint(-19, 0);
28
+ let wrongX2 = randint(0, 20);
29
+ const wrongAnswer = `S=\\left\\{${wrongX1};${wrongX2}\\right\\}`;
30
+ tryToAddWrongProp(propositions, wrongAnswer);
31
+ }
32
+ return shuffle(propositions);
33
+ };
34
+ const isAnswerValid = (ans, { a, b, c }) => {
35
+ const trinom = new Trinom(a, b, c);
36
+ const roots = trinom.getRootsNode();
37
+ const answer = new EquationSolutionNode(new DiscreteSetNode(roots));
38
+ const texs = answer.toAllValidTexs();
39
+ return texs.includes(ans);
40
+ };
41
+ export const niceRootsFromDevForm = {
42
+ id: "niceRootsFromDevForm",
43
+ connector: "\\iff",
44
+ getPropositions,
45
+ isAnswerValid,
46
+ label: "Résoudre une équation du second degré (solutions entières)",
47
+ levels: ["1reSpé", "TermSpé", "MathComp"],
48
+ isSingleStep: true,
49
+ sections: ["Second degré"],
50
+ generator: (nb) => getDistinctQuestions(getRootsFromDevFormQuestion, nb),
51
+ qcmTimer: 60,
52
+ freeTimer: 60,
53
+ subject: "Mathématiques",
54
+ };
@@ -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 rootsFromDevForm: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=rootsFromDevForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rootsFromDevForm.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/roots/rootsFromDevForm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA2CF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAgBlD,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { addValidProp, 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 { EquationSolutionNode } from "../../../../../tree/nodes/equations/equationSolutionNode.js";
6
+ import { DiscreteSetNode } from "../../../../../tree/nodes/sets/discreteSetNode.js";
7
+ import { shuffle } from "../../../../../utils/alea/shuffle.js";
8
+ const getRootsFromDevFormQuestion = () => {
9
+ const trinom = TrinomConstructor.random();
10
+ const answer = trinom.getRootsEquationSolutionTex();
11
+ const question = {
12
+ answer: answer,
13
+ instruction: `Soit $f(x) = ${trinom
14
+ .toTree()
15
+ .toTex()}$. Résoudre l'équation $f(x) = 0$.`,
16
+ keys: ["S", "equal", "lbrace", "semicolon", "rbrace", "varnothing"],
17
+ answerFormat: "tex",
18
+ identifiers: { a: trinom.a, b: trinom.b, c: trinom.c },
19
+ };
20
+ return question;
21
+ };
22
+ const getPropositions = (n, { answer }) => {
23
+ const propositions = [];
24
+ addValidProp(propositions, answer);
25
+ tryToAddWrongProp(propositions, "S=\\varnothing");
26
+ while (propositions.length < n) {
27
+ let wrongX1 = randint(-19, 0);
28
+ let wrongX2 = randint(0, 20);
29
+ const wrongAnswer = `S=\\left\\{${wrongX1};${wrongX2}\\right\\}`;
30
+ tryToAddWrongProp(propositions, wrongAnswer);
31
+ }
32
+ return shuffle(propositions);
33
+ };
34
+ const isAnswerValid = (ans, { a, b, c }) => {
35
+ const trinom = new Trinom(a, b, c);
36
+ const roots = trinom.getRootsNode();
37
+ const answer = new EquationSolutionNode(new DiscreteSetNode(roots));
38
+ const texs = answer.toAllValidTexs();
39
+ return texs.includes(ans);
40
+ };
41
+ export const rootsFromDevForm = {
42
+ id: "rootsFromDevForm",
43
+ connector: "\\iff",
44
+ getPropositions,
45
+ label: "Résoudre une équation du second degré",
46
+ levels: ["1reSpé", "TermSpé", "MathComp"],
47
+ isSingleStep: true,
48
+ sections: ["Second degré"],
49
+ generator: (nb) => getDistinctQuestions(getRootsFromDevFormQuestion, nb),
50
+ qcmTimer: 60,
51
+ freeTimer: 60,
52
+ isAnswerValid,
53
+ subject: "Mathématiques",
54
+ pdfOptions: { shouldSpreadPropositions: true },
55
+ };
@@ -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 rootsFromFactorizedForm: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=rootsFromFactorizedForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rootsFromFactorizedForm.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/roots/rootsFromFactorizedForm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA+EF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAczD,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { addValidProp, 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 { EquationSolutionNode } from "../../../../../tree/nodes/equations/equationSolutionNode.js";
6
+ import { OppositeNode } from "../../../../../tree/nodes/functions/oppositeNode.js";
7
+ import { NumberNode } from "../../../../../tree/nodes/numbers/numberNode.js";
8
+ import { DiscreteSetNode } from "../../../../../tree/nodes/sets/discreteSetNode.js";
9
+ import { shuffle } from "../../../../../utils/alea/shuffle.js";
10
+ const getRootsFromFactorizedFormQuestion = () => {
11
+ const trinom = TrinomConstructor.randomFactorized();
12
+ const answer = trinom.getRootsEquationSolutionTex();
13
+ const question = {
14
+ answer: answer,
15
+ instruction: `Soit $f(x) = ${trinom
16
+ .getFactorizedForm()
17
+ .toTex()}$. Résoudre l'équation $f(x) = 0$.`,
18
+ keys: ["S", "equal", "lbrace", "semicolon", "rbrace", "varnothing"],
19
+ answerFormat: "tex",
20
+ identifiers: { a: trinom.a, b: trinom.b, c: trinom.c },
21
+ };
22
+ return question;
23
+ };
24
+ const getPropositions = (n, { answer, a, b, c }) => {
25
+ const propositions = [];
26
+ addValidProp(propositions, answer);
27
+ const trinom = new Trinom(a, b, c);
28
+ const roots = trinom.getRoots();
29
+ if (roots.length === 1 && roots[0] !== 0) {
30
+ tryToAddWrongProp(propositions, `S=\\left\\{${new OppositeNode(new NumberNode(roots[0])).toTex()}\\right\\}`);
31
+ }
32
+ if (roots.length === 2 && roots[0] !== 0) {
33
+ tryToAddWrongProp(propositions, `S=\\left\\{${new OppositeNode(new NumberNode(roots[0])).toTex()};${roots[1]}\\right\\}`);
34
+ }
35
+ if (roots.length === 2 && roots[1] !== 0) {
36
+ tryToAddWrongProp(propositions, `S=\\left\\{${roots[0]};${new OppositeNode(new NumberNode(roots[1])).toTex()}\\right\\}`);
37
+ }
38
+ if (roots.length === 2 && roots[0] !== 0 && roots[1] !== 0) {
39
+ tryToAddWrongProp(propositions, `S=\\left\\{${new OppositeNode(new NumberNode(roots[0])).toTex()};${new OppositeNode(new NumberNode(roots[1])).toTex()}\\right\\}`);
40
+ }
41
+ while (propositions.length < n) {
42
+ const wrongAnswer = `S=\\left\\{${randint(-10, 11)};${randint(-10, 11)}\\right\\}`;
43
+ tryToAddWrongProp(propositions, wrongAnswer);
44
+ }
45
+ return shuffle(propositions);
46
+ };
47
+ const isAnswerValid = (ans, { a, b, c }) => {
48
+ const trinom = new Trinom(a, b, c);
49
+ const roots = trinom.getRootsNode();
50
+ const answer = new EquationSolutionNode(new DiscreteSetNode(roots));
51
+ const texs = answer.toAllValidTexs();
52
+ return texs.includes(ans);
53
+ };
54
+ export const rootsFromFactorizedForm = {
55
+ id: "rootsFromFactorizedForm",
56
+ connector: "=",
57
+ label: "Déterminer les racines d'un trinôme à partir de sa forme factorisée",
58
+ levels: ["1reSpé", "TermSpé", "MathComp"],
59
+ isSingleStep: true,
60
+ sections: ["Second degré"],
61
+ generator: (nb) => getDistinctQuestions(getRootsFromFactorizedFormQuestion, nb),
62
+ qcmTimer: 60,
63
+ freeTimer: 60,
64
+ getPropositions,
65
+ isAnswerValid,
66
+ subject: "Mathématiques",
67
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../../exercises/exercise.js";
2
+ import { TrinomNodeIdentifiers } from "../../../../../tree/nodes/polynomials/trinomNode.js";
3
+ type Identifiers = {
4
+ trinomIdentifiers: TrinomNodeIdentifiers;
5
+ };
6
+ export declare const rootsProduct: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=rootsProduct.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rootsProduct.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/roots/rootsProduct.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAGL,qBAAqB,EACtB,MAAM,4CAA4C,CAAC;AAOpD,KAAK,WAAW,GAAG;IACjB,iBAAiB,EAAE,qBAAqB,CAAC;CAC1C,CAAC;AA0GF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAiB9C,CAAC"}
@@ -0,0 +1,109 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { rationalVEA } from "../../../../../exercises/vea/rationalVEA.js";
4
+ import { TrinomNode, TrinomNodeConstructor, } from "../../../../../tree/nodes/polynomials/trinomNode.js";
5
+ import { randint } from "../../../../../math/utils/random/randint.js";
6
+ import { opposite } from "../../../../../tree/nodes/functions/oppositeNode.js";
7
+ import { frac } from "../../../../../tree/nodes/operators/fractionNode.js";
8
+ import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
9
+ const getPropositions = (n, { answer, trinomIdentifiers }) => {
10
+ const propositions = [];
11
+ addValidProp(propositions, answer);
12
+ const trinom = TrinomNodeConstructor.fromIdentifiers(trinomIdentifiers);
13
+ tryToAddWrongProp(propositions, frac(opposite(trinom.b), trinom.a).simplify().toTex());
14
+ tryToAddWrongProp(propositions, frac(opposite(trinom.c), trinom.a).simplify().toTex());
15
+ tryToAddWrongProp(propositions, frac(opposite(trinom.b), multiply(2, trinom.a)).simplify().toTex());
16
+ while (propositions.length < n) {
17
+ tryToAddWrongProp(propositions, randint(-10, 10).frenchify());
18
+ }
19
+ return shuffleProps(propositions, n);
20
+ };
21
+ const getAnswer = (identifiers) => {
22
+ const { trinomIdentifiers } = identifiers;
23
+ const trinom = TrinomNodeConstructor.fromIdentifiers(trinomIdentifiers);
24
+ const ans = frac(trinom.c, trinom.a).simplify().toTex();
25
+ return ans;
26
+ };
27
+ const getInstruction = (identifiers) => {
28
+ const { trinomIdentifiers } = identifiers;
29
+ const trinom = TrinomNodeConstructor.fromIdentifiers(trinomIdentifiers);
30
+ return `Soit $f$ la fonction définie sur $\\mathbb{R}$ par :
31
+
32
+ $$
33
+ f(x) = ${trinom.toTree().toTex()}
34
+ $$
35
+
36
+ On admet que $f$ possède deux racines.
37
+
38
+ Que vaut le produit des racines de $f$ ?`;
39
+ };
40
+ const getHint = (identifiers) => {
41
+ return `Si $f(x) = ax^2 + bx + c$ admet deux racines, alors leur produit $P$ vaut :
42
+
43
+ $$
44
+ P = \\frac{c}{a}
45
+ $$`;
46
+ };
47
+ const getCorrection = (identifiers) => {
48
+ const { trinomIdentifiers } = identifiers;
49
+ const trinom = TrinomNodeConstructor.fromIdentifiers(trinomIdentifiers);
50
+ const aTex = trinom.a.toTex();
51
+ const cTex = trinom.c.toTex();
52
+ const ans = frac(trinom.c, trinom.a);
53
+ return `Si $f(x) = ax^2 + bx + c$ admet deux racines, alors leur produit $P$ vaut :
54
+
55
+ $$
56
+ P = \\frac{c}{a}
57
+ $$
58
+
59
+ Ici, on a $a = ${aTex}$ et $c = ${cTex}$, donc :
60
+
61
+ $$
62
+ P = ${ans.toSimplificationString()}
63
+ $$
64
+ `;
65
+ };
66
+ const getKeys = (identifiers) => {
67
+ return [];
68
+ };
69
+ const isAnswerValid = (ans, { answer }) => {
70
+ return rationalVEA(ans, answer);
71
+ };
72
+ const getRootsProductQuestion = (ops) => {
73
+ //(b,c) != 0
74
+ //ac <= 0
75
+ const a = randint(-10, 10, [0]);
76
+ const b = randint(-10, 10);
77
+ const c = (a / Math.abs(a)) * randint(-10, 0, !b ? [0] : []);
78
+ const trinom = new TrinomNode(a, b, c);
79
+ const identifiers = {
80
+ trinomIdentifiers: trinom.toIdentifiers(),
81
+ };
82
+ const question = {
83
+ answer: getAnswer(identifiers),
84
+ instruction: getInstruction(identifiers),
85
+ keys: getKeys(identifiers),
86
+ answerFormat: "tex",
87
+ identifiers,
88
+ hint: getHint(identifiers),
89
+ correction: getCorrection(identifiers),
90
+ };
91
+ return question;
92
+ };
93
+ export const rootsProduct = {
94
+ id: "rootsProduct",
95
+ connector: "=",
96
+ label: "Produit des racines d'un trinôme",
97
+ isSingleStep: true,
98
+ generator: (nb, opts) => getDistinctQuestions(() => getRootsProductQuestion(opts), nb),
99
+ qcmTimer: 60,
100
+ freeTimer: 60,
101
+ getPropositions,
102
+ isAnswerValid,
103
+ subject: "Mathématiques",
104
+ getInstruction,
105
+ getHint,
106
+ getCorrection,
107
+ getAnswer,
108
+ hasHintAndCorrection: true,
109
+ };
@@ -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 rootsReading: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=rootsReading.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rootsReading.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/roots/rootsReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqDF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAa9C,CAAC"}