math-exercises 3.0.56 → 3.0.57

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 (97) hide show
  1. package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.d.ts.map +1 -1
  2. package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.js +65 -13
  3. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.d.ts.map +1 -1
  4. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.js +43 -0
  5. package/lib/exercises/math/calculLitteral/systems/basicNiceValuesSystemResolution.d.ts.map +1 -1
  6. package/lib/exercises/math/calculLitteral/systems/basicNiceValuesSystemResolution.js +23 -0
  7. package/lib/exercises/math/calculLitteral/systems/basicSystemResolution.d.ts.map +1 -1
  8. package/lib/exercises/math/calculLitteral/systems/basicSystemResolution.js +23 -0
  9. package/lib/exercises/math/calculLitteral/systems/verifySystemSolution.d.ts.map +1 -1
  10. package/lib/exercises/math/calculLitteral/systems/verifySystemSolution.js +49 -0
  11. package/lib/exercises/math/conversion/capacityConversion.d.ts.map +1 -1
  12. package/lib/exercises/math/conversion/capacityConversion.js +68 -12
  13. package/lib/exercises/math/conversion/hoursToDecimal.d.ts.map +1 -1
  14. package/lib/exercises/math/conversion/hoursToDecimal.js +73 -15
  15. package/lib/exercises/math/conversion/lengthConversion.d.ts.map +1 -1
  16. package/lib/exercises/math/conversion/lengthConversion.js +55 -6
  17. package/lib/exercises/math/conversion/massConversion.d.ts.map +1 -1
  18. package/lib/exercises/math/conversion/massConversion.js +72 -16
  19. package/lib/exercises/math/conversion/volumeConversion.d.ts.map +1 -1
  20. package/lib/exercises/math/conversion/volumeConversion.js +72 -12
  21. package/lib/exercises/math/functions/affines/signFunction.d.ts.map +1 -1
  22. package/lib/exercises/math/functions/affines/signFunction.js +23 -11
  23. package/lib/exercises/math/geometry/cartesian/cartesianEquationOfLine.d.ts.map +1 -1
  24. package/lib/exercises/math/geometry/cartesian/cartesianEquationOfLine.js +12 -5
  25. package/lib/exercises/math/geometry/lines/cartesianEquationToReduced.d.ts.map +1 -1
  26. package/lib/exercises/math/geometry/lines/cartesianEquationToReduced.js +68 -29
  27. package/lib/exercises/math/geometry/lines/cartesianEquationsIntersection.d.ts.map +1 -1
  28. package/lib/exercises/math/geometry/lines/cartesianEquationsIntersection.js +56 -4
  29. package/lib/exercises/math/geometry/lines/drawLineFromCartesianEquation.d.ts.map +1 -1
  30. package/lib/exercises/math/geometry/lines/drawLineFromCartesianEquation.js +71 -25
  31. package/lib/exercises/math/limits/polynomLimit.d.ts +1 -1
  32. package/lib/exercises/math/limits/polynomLimit.d.ts.map +1 -1
  33. package/lib/exercises/math/limits/polynomLimit.js +28 -9
  34. package/lib/exercises/math/limits/polynomLimitNoFI.d.ts +1 -1
  35. package/lib/exercises/math/limits/polynomLimitNoFI.d.ts.map +1 -1
  36. package/lib/exercises/math/limits/polynomLimitNoFI.js +29 -10
  37. package/lib/exercises/math/powers/calculateNegativePower.d.ts.map +1 -1
  38. package/lib/exercises/math/powers/calculateNegativePower.js +59 -16
  39. package/lib/exercises/math/powers/decimalToScientific.d.ts.map +1 -1
  40. package/lib/exercises/math/powers/decimalToScientific.js +55 -11
  41. package/lib/exercises/math/powers/index.d.ts +1 -0
  42. package/lib/exercises/math/powers/index.d.ts.map +1 -1
  43. package/lib/exercises/math/powers/index.js +1 -0
  44. package/lib/exercises/math/powers/powersDivision.d.ts +5 -2
  45. package/lib/exercises/math/powers/powersDivision.d.ts.map +1 -1
  46. package/lib/exercises/math/powers/powersDivision.js +68 -53
  47. package/lib/exercises/math/powers/powersMixOperations.d.ts +1 -0
  48. package/lib/exercises/math/powers/powersMixOperations.d.ts.map +1 -1
  49. package/lib/exercises/math/powers/powersMixOperations.js +88 -17
  50. package/lib/exercises/math/powers/powersOfTenMixOperations.d.ts +10 -0
  51. package/lib/exercises/math/powers/powersOfTenMixOperations.d.ts.map +1 -0
  52. package/lib/exercises/math/powers/powersOfTenMixOperations.js +129 -0
  53. package/lib/exercises/math/powers/powersOfTenToDecimal.d.ts.map +1 -1
  54. package/lib/exercises/math/powers/powersOfTenToDecimal.js +32 -3
  55. package/lib/exercises/math/powers/powersProduct.d.ts.map +1 -1
  56. package/lib/exercises/math/powers/powersProduct.js +1 -0
  57. package/lib/exercises/math/powers/scientificToDecimal.d.ts.map +1 -1
  58. package/lib/exercises/math/powers/scientificToDecimal.js +50 -10
  59. package/lib/exercises/math/primitive/polynomialPrimitive.d.ts.map +1 -1
  60. package/lib/exercises/math/primitive/polynomialPrimitive.js +1 -0
  61. package/lib/exercises/math/sequences/geometric/geometricFirstTermsGeneralSum.d.ts.map +1 -1
  62. package/lib/exercises/math/sequences/geometric/geometricFirstTermsGeneralSum.js +40 -2
  63. package/lib/exercises/math/sequences/geometric/geometricFirstTermsSum.d.ts.map +1 -1
  64. package/lib/exercises/math/sequences/geometric/geometricFirstTermsSum.js +32 -0
  65. package/lib/exercises/math/trigonometry/trigonometry.d.ts.map +1 -1
  66. package/lib/exercises/math/trigonometry/trigonometry.js +67 -1
  67. package/lib/exercises/math/trigonometry/trigonometryAngleCalcul.d.ts.map +1 -1
  68. package/lib/exercises/math/trigonometry/trigonometryAngleCalcul.js +89 -0
  69. package/lib/index.d.ts +14 -4
  70. package/lib/index.d.ts.map +1 -1
  71. package/lib/math/geometry/angle.d.ts.map +1 -1
  72. package/lib/math/geometry/angle.js +0 -5
  73. package/lib/math/geometry/vector.d.ts +1 -0
  74. package/lib/math/geometry/vector.d.ts.map +1 -1
  75. package/lib/math/geometry/vector.js +19 -0
  76. package/lib/math/numbers/decimals/decimal.d.ts +1 -0
  77. package/lib/math/numbers/decimals/decimal.d.ts.map +1 -1
  78. package/lib/math/numbers/decimals/decimal.js +2 -0
  79. package/lib/math/systems/generalSystem.d.ts +6 -1
  80. package/lib/math/systems/generalSystem.d.ts.map +1 -1
  81. package/lib/math/systems/generalSystem.js +137 -0
  82. package/lib/math/utils/arithmetic/lcm.js +1 -1
  83. package/lib/playground.d.ts.map +1 -1
  84. package/lib/playground.js +1 -36
  85. package/lib/tree/nodes/algebraicNode.d.ts +1 -0
  86. package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
  87. package/lib/tree/nodes/equations/equalNode.d.ts +7 -1
  88. package/lib/tree/nodes/equations/equalNode.d.ts.map +1 -1
  89. package/lib/tree/nodes/equations/equalNode.js +17 -9
  90. package/lib/tree/nodes/operators/addNode.js +1 -1
  91. package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
  92. package/lib/tree/nodes/operators/fractionNode.js +31 -11
  93. package/lib/tree/nodes/operators/powerNode.d.ts.map +1 -1
  94. package/lib/tree/nodes/operators/powerNode.js +5 -0
  95. package/lib/tree/nodes/sets/intervalNode.d.ts.map +1 -1
  96. package/lib/tree/nodes/sets/intervalNode.js +3 -1
  97. package/package.json +1 -1
@@ -56,8 +56,59 @@ $$
56
56
 
57
57
  Déterminer les coordonnées du point d'intersection de $d_1$ et $d_2$.`;
58
58
  };
59
- // const getHint: GetHint<Identifiers> = (identifiers) => {};
60
- // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
59
+ const getHint = (identifiers) => {
60
+ const { cartesianCoeffs1, cartesianCoeffs2 } = identifiers;
61
+ const coeffs1 = cartesianCoeffs1.map((c) => reifyAlgebraic(c));
62
+ const coeffs2 = cartesianCoeffs2.map((c) => reifyAlgebraic(c));
63
+ const equa1 = getEquation(coeffs1).toTex();
64
+ const equa2 = getEquation(coeffs2).toTex();
65
+ return `Le point d'intersection de $d_1$ et $d_2$, s'il existe, est le point dont les coordonnées $(x;y)$ est une solution du système :
66
+
67
+ $$
68
+ \\left\\{\\begin{matrix}
69
+ ${equa1} \\\\
70
+ ${equa2}
71
+ \\end{matrix}\\right.
72
+ $$`;
73
+ };
74
+ const getCorrection = (identifiers) => {
75
+ const { cartesianCoeffs1, cartesianCoeffs2 } = identifiers;
76
+ const coeffs1 = cartesianCoeffs1.map((c) => reifyAlgebraic(c));
77
+ const coeffs2 = cartesianCoeffs2.map((c) => reifyAlgebraic(c));
78
+ let equa1 = getEquation(coeffs1);
79
+ let equa2 = getEquation(coeffs2);
80
+ let corr = `On doit résoudre le système :
81
+
82
+ $$
83
+ \\left\\{\\begin{matrix}
84
+ ${equa1.toTex()} \\\\
85
+ ${equa2.toTex()}
86
+ \\end{matrix}\\right.
87
+ $$`;
88
+ coeffs1[2] = opposite(coeffs1[2].simplify());
89
+ coeffs2[2] = opposite(coeffs2[2].simplify());
90
+ const sys = new GeneralSystem([coeffs1, coeffs2]);
91
+ [equa1, equa2] = sys.getEqualNodes();
92
+ corr += `
93
+
94
+ c'est à dire :
95
+
96
+ $$
97
+ ${sys.toTex()}
98
+ $$
99
+
100
+ `;
101
+ corr += sys.toCorrectionTex();
102
+ corr += `
103
+
104
+ Le point d'intersection de $d_1$ et $d_2$ a donc pour coordonnées :
105
+
106
+ $$
107
+ ${getAnswer(identifiers)}
108
+ $$
109
+ `;
110
+ return corr;
111
+ };
61
112
  const getKeys = (identifiers) => {
62
113
  return ["semicolon"];
63
114
  };
@@ -93,8 +144,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
93
144
  keys: getKeys(identifiers),
94
145
  answerFormat: "tex",
95
146
  identifiers,
96
- // hint: getHint(identifiers),
97
- // correction: getCorrection(identifiers),
147
+ hint: getHint(identifiers),
148
+ correction: getCorrection(identifiers),
98
149
  };
99
150
  };
100
151
  export const cartesianEquationsIntersection = {
@@ -112,4 +163,5 @@ export const cartesianEquationsIntersection = {
112
163
  // getCorrection,
113
164
  getAnswer,
114
165
  getQuestionFromIdentifiers,
166
+ hasHintAndCorrection: true,
115
167
  };
@@ -1 +1 @@
1
- {"version":3,"file":"drawLineFromCartesianEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/lines/drawLineFromCartesianEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAGL,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AAQvC,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,SAAS,EAAE,iBAAiB,CAAC;CAC9B,CAAC;AA+HF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAmB/D,CAAC"}
1
+ {"version":3,"file":"drawLineFromCartesianEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/lines/drawLineFromCartesianEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAGL,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AAMvC,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,SAAS,EAAE,iBAAiB,CAAC;CAC9B,CAAC;AA4KF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAoB/D,CAAC"}
@@ -5,7 +5,10 @@ import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js
5
5
  import { Line, LineConstructor } from "../../../../math/geometry/line.js";
6
6
  import { Point, PointConstructor, } from "../../../../math/geometry/point.js";
7
7
  import { Vector, VectorConstructor, } from "../../../../math/geometry/vector.js";
8
+ import { gcd } from "../../../../math/utils/arithmetic/gcd.js";
8
9
  import { randint } from "../../../../math/utils/random/randint.js";
10
+ import { opposite } from "../../../../tree/nodes/functions/oppositeNode.js";
11
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
9
12
  const getCartesianEquation = (identifiers) => {
10
13
  const { pointIds, vectorIds } = identifiers;
11
14
  const point = PointConstructor.fromIdentifiers(pointIds);
@@ -20,11 +23,61 @@ $$
20
23
  ${getCartesianEquation(identifiers).toTex()}
21
24
  $$`;
22
25
  };
23
- // const getHint: GetHint<Identifiers> = (identifiers) => {};
24
- // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
26
+ const getHint = (identifiers) => {
27
+ const u = new Vector("u", opposite("b"), "a".toTree());
28
+ return `On peut commencer par chercher les coordonnées d'un point appartenant à la droite. Pour cela, on peut remplacer par exemple $x$ par $0$ et en déduire l'ordonnée $y$ du point d'abscisse $0$ de la droite.
29
+
30
+ Ensuite, on détermine les coordonnées d'un vecteur directeur de la droite. Une droite admettant une équation cartésienne de la forme :
31
+
32
+ $$
33
+ ax+by+c=0
34
+ $$
35
+
36
+ admet le vecteur $${u.toTexWithCoords()}$ comme vecteur directeur.
37
+ `;
38
+ };
39
+ const getCorrection = (identifiers) => {
40
+ const equa = getCartesianEquation(identifiers);
41
+ const detailed = equa.toDetailedEvaluation({ x: (0).toTree() });
42
+ const detailedSimp = detailed.simplify({
43
+ towardsDistribute: true,
44
+ forbidFactorize: true,
45
+ });
46
+ const y = detailedSimp.isolate("y");
47
+ const { pointIds, vectorIds } = identifiers;
48
+ const point = PointConstructor.fromIdentifiers(pointIds);
49
+ const u = new Vector("u", opposite("b"), "a".toTree());
50
+ const vector = VectorConstructor.fromIdentifiers(vectorIds);
51
+ return `On remplace $x$ par $0$ dans l'équation de la droite pour déterminer l'ordonnée $y$ du point d'abscisse $0$ de la droite :
52
+
53
+ ${alignTex([[detailed.toTex()], [detailedSimp.toTex()], [y.toTex()]])}
54
+
55
+ Le point $${point.toTexWithCoords()}$ appartient donc à la droite $d$ : on peut le placer sur le graphique.
56
+
57
+ Puis, on détermine les coordonnées d'un vecteur directeur de $d$. On sait qu'une droite admettant une équation cartésienne de la forme :
58
+
59
+ $$
60
+ ax+by+c=0
61
+ $$
62
+
63
+ admet le vecteur $${u.toTexWithCoords()}$ comme vecteur directeur.
64
+
65
+ Ici, un vecteur directeur de $d$ est donc $${vector.toTexWithCoords()}$.
66
+
67
+ Pour tracer la droite $d$, on peut donc partir du point $A$, puis tracer le vecteur $${vector.toTex()}$. Cela nous donne un deuxième point $B$. On relie alors les points $A$ et $B$ pour obtenir la droite $d$.`;
68
+ };
25
69
  const getGGBAnswer = (identifiers) => {
70
+ const { pointIds, vectorIds } = identifiers;
71
+ const point = PointConstructor.fromIdentifiers(pointIds);
72
+ const vector = VectorConstructor.fromIdentifiers(vectorIds);
73
+ const B = vector.getEndPoint(point, "B");
26
74
  const equa = getCartesianEquation(identifiers).toMathString();
27
- return [`d: ${equa}`, `SetFixed(d, true)`];
75
+ return [
76
+ ...point.toGGBCommand(),
77
+ ...B.toGGBCommand(),
78
+ `d = Line(A,B)`,
79
+ `SetFixed(d, true)`,
80
+ ];
28
81
  };
29
82
  const getStudentGGBOptions = (identifiers) => {
30
83
  // throw new Error("vea devrait accepter arrondis");
@@ -72,24 +125,16 @@ const isGGBAnswerValid = (ans, { ggbAnswer, ...identifiers }) => {
72
125
  return line.includes(point, 0.5) && line.includes(B, 0.5);
73
126
  };
74
127
  const getDrawLineFromCartesianEquationQuestion = () => {
75
- const A = new Point("A", (0).toTree(), randint(-6, 7).toTree());
76
- // let B: Point;
77
- // const isVertical = probaFlip(0.1);
78
- // const isHorizontal = probaFlip(0.1);
79
- // if (isVertical) {
80
- // B = new Point("B", A.x, add(A.y, 2));
81
- // } else if (isHorizontal) {
82
- // B = new Point("B", add(A.x, 2), A.y);
83
- // } else {
84
- // B = new Point(
85
- // "B",
86
- // add(A.x, randint(-3, 4, [0])),
87
- // add(A.y, randint(-3, 4, [0])),
88
- // );
89
- // }
90
- const x = randint(-3, 4);
91
- const y = randint(-3, 4, x === 0 ? [0] : undefined);
92
- const vec = new Vector("u", x.toTree(), y.toTree());
128
+ let a;
129
+ let b;
130
+ let c;
131
+ do {
132
+ a = randint(-9, 10, [0]);
133
+ b = randint(-9, 10, [0]);
134
+ c = randint(-4, 5, [0]) * b; //pour que (0;y)=> y entier
135
+ } while (gcd(a, b, c) !== 1 || (a <= 0 && b <= 0 && c <= 0));
136
+ const A = new Point("A", (0).toTree(), -c / b);
137
+ const vec = new Vector("u", (-b).toTree(), a.toTree());
93
138
  const identifiers = {
94
139
  pointIds: A.toIdentifiers(),
95
140
  vectorIds: vec.toIdentifiers(),
@@ -102,8 +147,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
102
147
  instruction: getInstruction(identifiers),
103
148
  studentGgbOptions: getStudentGGBOptions(identifiers),
104
149
  identifiers,
105
- // hint: getHint(identifiers),
106
- // correction: getCorrection(identifiers),
150
+ hint: getHint(identifiers),
151
+ correction: getCorrection(identifiers),
107
152
  };
108
153
  };
109
154
  export const drawLineFromCartesianEquation = {
@@ -114,11 +159,12 @@ export const drawLineFromCartesianEquation = {
114
159
  ggbTimer: 60,
115
160
  isGGBAnswerValid,
116
161
  subject: "Mathématiques",
117
- // getHint,
162
+ getHint,
118
163
  getInstruction,
119
- // getCorrection,
164
+ getCorrection,
120
165
  getGGBAnswer,
121
166
  getStudentGGBOptions,
122
167
  answerType: "GGB",
123
168
  getQuestionFromIdentifiers,
169
+ hasHintAndCorrection: true,
124
170
  };
@@ -1,7 +1,7 @@
1
1
  import { Exercise } from "../../../exercises/exercise.js";
2
2
  type Identifiers = {
3
3
  coeffs: number[];
4
- to: string;
4
+ to: "+\\infty" | "-\\infty";
5
5
  };
6
6
  export declare const polynomLimit: Exercise<Identifiers>;
7
7
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"polynomLimit.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/limits/polynomLimit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAwCF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAa9C,CAAC"}
1
+ {"version":3,"file":"polynomLimit.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/limits/polynomLimit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,EAAE,EAAE,UAAU,GAAG,UAAU,CAAC;CAC7B,CAAC;AA6DF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAc9C,CAAC"}
@@ -1,24 +1,42 @@
1
1
  import { addValidProp, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
- import { PolynomialConstructor, } from "../../../math/polynomials/polynomial.js";
3
+ import { Polynomial, PolynomialConstructor, } from "../../../math/polynomials/polynomial.js";
4
4
  import { randint } from "../../../math/utils/random/randint.js";
5
5
  import { coinFlip } from "../../../utils/alea/coinFlip.js";
6
6
  import { shuffle } from "../../../utils/alea/shuffle.js";
7
- const getPolynomLimitQuestion = () => {
8
- const poly = PolynomialConstructor.random(4);
9
- const to = coinFlip() ? "+\\infty" : "-\\infty";
7
+ const getInstruction = (identifiers) => {
8
+ const { coeffs, to } = identifiers;
9
+ const poly = new Polynomial(coeffs);
10
+ return `Déterminer la limite en $${to}$ de la fonction $f$ définie par :
11
+
12
+ $$
13
+ f(x) = ${poly.toTree().toTex()}
14
+ $$`;
15
+ };
16
+ const getAnswer = (identifiers) => {
17
+ const { coeffs, to } = identifiers;
18
+ const poly = new Polynomial(coeffs);
10
19
  const answer = poly.getLimit(to);
20
+ return answer;
21
+ };
22
+ // const getHint: GetHint<Identifiers> = (identifiers) => {};
23
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
24
+ const getQuestionFromIdentifiers = (identifiers) => {
11
25
  const question = {
12
- answer: answer,
13
- instruction: `Déterminer la limite en $${to}$ de la fonction $f$ définie par : $f(x) = ${poly
14
- .toTree()
15
- .toTex()}$.`,
26
+ answer: getAnswer(identifiers),
27
+ instruction: getInstruction(identifiers),
16
28
  keys: ["infty"],
17
29
  answerFormat: "tex",
18
- identifiers: { coeffs: poly.coefficients, to },
30
+ identifiers,
19
31
  };
20
32
  return question;
21
33
  };
34
+ const getPolynomLimitQuestion = () => {
35
+ const poly = PolynomialConstructor.random(4);
36
+ const to = coinFlip() ? "+\\infty" : "-\\infty";
37
+ const identifiers = { coeffs: poly.coefficients, to };
38
+ return getQuestionFromIdentifiers(identifiers);
39
+ };
22
40
  const getPropositions = (n, { answer, coeffs }) => {
23
41
  const propositions = [];
24
42
  addValidProp(propositions, answer);
@@ -48,4 +66,5 @@ export const polynomLimit = {
48
66
  getPropositions,
49
67
  isAnswerValid,
50
68
  subject: "Mathématiques",
69
+ getQuestionFromIdentifiers,
51
70
  };
@@ -1,7 +1,7 @@
1
1
  import { Exercise } from "../../../exercises/exercise.js";
2
2
  type Identifiers = {
3
3
  coeffs: number[];
4
- to: string;
4
+ to: "+\\infty" | "-\\infty";
5
5
  };
6
6
  export declare const polynomLimitNoFI: Exercise<Identifiers>;
7
7
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"polynomLimitNoFI.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/limits/polynomLimitNoFI.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA4CF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAclD,CAAC"}
1
+ {"version":3,"file":"polynomLimitNoFI.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/limits/polynomLimitNoFI.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,EAAE,EAAE,UAAU,GAAG,UAAU,CAAC;CAC7B,CAAC;AAgEF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAelD,CAAC"}
@@ -1,25 +1,43 @@
1
1
  import { addValidProp, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
- import { PolynomialConstructor } from "../../../math/polynomials/polynomial.js";
3
+ import { Polynomial, PolynomialConstructor, } from "../../../math/polynomials/polynomial.js";
4
4
  import { randint } from "../../../math/utils/random/randint.js";
5
5
  import { coinFlip } from "../../../utils/alea/coinFlip.js";
6
6
  import { shuffle } from "../../../utils/alea/shuffle.js";
7
- const getSequencePolynomNoFILimitQuestion = () => {
8
- const length = randint(2, 5);
9
- const to = coinFlip() ? "+\\infty" : "-\\infty";
10
- const poly = PolynomialConstructor.randomNoFI(4, to, length);
7
+ const getInstruction = (identifiers) => {
8
+ const { coeffs, to } = identifiers;
9
+ const poly = new Polynomial(coeffs);
10
+ return `Déterminer la limite en $${to}$ de la fonction $f$ définie par :
11
+
12
+ $$
13
+ f(x) = ${poly.toTree().toTex()}
14
+ $$`;
15
+ };
16
+ const getAnswer = (identifiers) => {
17
+ const { coeffs, to } = identifiers;
18
+ const poly = new Polynomial(coeffs);
11
19
  const answer = poly.getLimit(to);
20
+ return answer;
21
+ };
22
+ // const getHint: GetHint<Identifiers> = (identifiers) => {};
23
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
24
+ const getQuestionFromIdentifiers = (identifiers) => {
12
25
  const question = {
13
- answer: answer,
14
- instruction: `Déterminer la limite en $${to}$ de la fonction $f$ définie par : $f(x) = ${poly
15
- .toTree()
16
- .toTex()}$.`,
26
+ answer: getAnswer(identifiers),
27
+ instruction: getInstruction(identifiers),
17
28
  keys: ["infty"],
18
29
  answerFormat: "tex",
19
- identifiers: { coeffs: poly.coefficients, to },
30
+ identifiers,
20
31
  };
21
32
  return question;
22
33
  };
34
+ const getSequencePolynomNoFILimitQuestion = () => {
35
+ const length = randint(2, 5);
36
+ const to = coinFlip() ? "+\\infty" : "-\\infty";
37
+ const poly = PolynomialConstructor.randomNoFI(4, to, length);
38
+ const identifiers = { coeffs: poly.coefficients, to };
39
+ return getQuestionFromIdentifiers(identifiers);
40
+ };
23
41
  const getPropositions = (n, { answer, coeffs }) => {
24
42
  const propositions = [];
25
43
  addValidProp(propositions, answer);
@@ -48,4 +66,5 @@ export const polynomLimitNoFI = {
48
66
  getPropositions,
49
67
  isAnswerValid,
50
68
  subject: "Mathématiques",
69
+ getQuestionFromIdentifiers,
51
70
  };
@@ -1 +1 @@
1
- {"version":3,"file":"calculateNegativePower.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/calculateNegativePower.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAmEF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAYxD,CAAC"}
1
+ {"version":3,"file":"calculateNegativePower.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/calculateNegativePower.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAmBrC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAmHF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAcxD,CAAC"}
@@ -1,28 +1,65 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
- import { Power } from "../../../math/numbers/integer/power.js";
4
3
  import { Rational } from "../../../math/numbers/rationals/rational.js";
5
4
  import { randint } from "../../../math/utils/random/randint.js";
6
- import { NumberNode } from "../../../tree/nodes/numbers/numberNode.js";
7
- import { FractionNode } from "../../../tree/nodes/operators/fractionNode.js";
5
+ import { isNumberNode, NumberNode, } from "../../../tree/nodes/numbers/numberNode.js";
6
+ import { frac, isFractionNode, } from "../../../tree/nodes/operators/fractionNode.js";
8
7
  import { PowerNode } from "../../../tree/nodes/operators/powerNode.js";
9
- const getCalculatePowerQuestion = () => {
10
- const int = randint(1, 11);
11
- const power = randint(-5, 0);
8
+ import { parseAlgebraic } from "../../../tree/parsers/latexParser.js";
9
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
10
+ const getInstruction = (identifiers) => {
11
+ const { int, power } = identifiers;
12
12
  const statement = new PowerNode(new NumberNode(int), new NumberNode(power)).toTex();
13
+ return `Calculer et donner le résultat sous la forme d'une fraction ou d'un entier :
14
+
15
+ $$
16
+ ${statement}
17
+ $$`;
18
+ };
19
+ const getAnswer = (identifiers) => {
20
+ const { int, power } = identifiers;
13
21
  const answer = new Rational(1, int ** Math.abs(power))
14
22
  .simplify()
15
23
  .toTree()
16
24
  .toTex();
25
+ return answer;
26
+ };
27
+ const getHint = (identifiers) => {
28
+ const { int, power } = identifiers;
29
+ return `Pour tous nombre $a$ et tout nombre $x$ positif, on a :
30
+
31
+ $$
32
+ a^{-x} = \\frac{1}{a^x}
33
+ $$`;
34
+ };
35
+ const getCorrection = (identifiers) => {
36
+ const { int, power } = identifiers;
37
+ const statement = new PowerNode(new NumberNode(int), new NumberNode(power)).toTex();
38
+ const fraction = frac(1, new PowerNode(int.toTree(), Math.abs(power).toTree()));
39
+ return `Puisque $a^{-x} = \\frac{1}{a^x}$, on a :
40
+
41
+ $$
42
+ ${statement} = ${fraction.toSimplificationTex()}
43
+ $$`;
44
+ };
45
+ const getQuestionFromIdentifiers = (identifiers) => {
17
46
  const question = {
18
- answer,
19
- instruction: `Calculer : $${statement}$`,
47
+ answer: getAnswer(identifiers),
48
+ instruction: getInstruction(identifiers),
20
49
  keys: [],
21
50
  answerFormat: "tex",
22
- identifiers: { int, power },
51
+ identifiers,
52
+ hint: getHint(identifiers),
53
+ correction: getCorrection(identifiers),
23
54
  };
24
55
  return question;
25
56
  };
57
+ const getCalculatePowerQuestion = () => {
58
+ const int = randint(1, 11);
59
+ const power = randint(-5, 0);
60
+ const identifiers = { int, power };
61
+ return getQuestionFromIdentifiers(identifiers);
62
+ };
26
63
  const getPropositions = (n, { answer, int, power }) => {
27
64
  const propositions = [];
28
65
  addValidProp(propositions, answer);
@@ -46,13 +83,17 @@ const getPropositions = (n, { answer, int, power }) => {
46
83
  }
47
84
  return shuffleProps(propositions, n);
48
85
  };
49
- const isAnswerValid = (ans, { int, power }) => {
50
- const answerTree = new Rational(1, int ** Math.abs(power))
51
- .simplify()
52
- .toTree({ allowFractionToDecimal: true });
53
- const secondTree = new FractionNode(new NumberNode(1), new Power(int, -power).simplify());
54
- const texs = [...answerTree.toAllValidTexs(), ...secondTree.toAllValidTexs()];
55
- return texs.includes(ans);
86
+ const isAnswerValid = (ans, { answer, int, power }) => {
87
+ try {
88
+ const parsed = parseAlgebraic(ans);
89
+ if (!isNumberNode(parsed) && !isFractionNode(parsed)) {
90
+ return false;
91
+ }
92
+ return parsed.simplify({ calculatePowers: true }).toTex() === answer;
93
+ }
94
+ catch (err) {
95
+ return handleVEAError(err);
96
+ }
56
97
  };
57
98
  export const calculateNegativePower = {
58
99
  id: "calculateNegativePower",
@@ -65,4 +106,6 @@ export const calculateNegativePower = {
65
106
  getPropositions,
66
107
  isAnswerValid,
67
108
  subject: "Mathématiques",
109
+ getQuestionFromIdentifiers,
110
+ hasHintAndCorrection: true,
68
111
  };
@@ -1 +1 @@
1
- {"version":3,"file":"decimalToScientific.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/decimalToScientific.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,QAAQ,EAST,MAAM,mBAAmB,CAAC;AAG3B,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAoDF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAYrD,CAAC"}
1
+ {"version":3,"file":"decimalToScientific.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/decimalToScientific.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,QAAQ,EAeT,MAAM,mBAAmB,CAAC;AAG3B,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAqGF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAcrD,CAAC"}
@@ -5,8 +5,59 @@ import { NumberNode } from "../../../tree/nodes/numbers/numberNode.js";
5
5
  import { MultiplyNode } from "../../../tree/nodes/operators/multiplyNode.js";
6
6
  import { PowerNode } from "../../../tree/nodes/operators/powerNode.js";
7
7
  import { probaFlip } from "../../../utils/alea/probaFlip.js";
8
+ import { pluralize } from "../../../utils/strings/pluralize.js";
8
9
  import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../exercise.js";
9
10
  import { getDistinctQuestions } from "../../utils/getDistinctQuestions.js";
11
+ const getInstruction = (identifiers) => {
12
+ const { decimal } = identifiers;
13
+ return `Donner l'écriture scientifique du nombre suivant :
14
+
15
+ $$
16
+ ${decimal.frenchify()}
17
+ $$`;
18
+ };
19
+ const getAnswer = (identifiers) => {
20
+ const { decimal } = identifiers;
21
+ const dec = new Decimal(decimal);
22
+ const answer = dec.toScientificNotation().toTex();
23
+ return answer;
24
+ };
25
+ const getHint = (identifiers) => {
26
+ return `Pour écrire un nombre en notation scientifique, il faut qu'il soit sous la forme :
27
+
28
+ $$
29
+ a\\times 10^n
30
+ $$
31
+
32
+ où $a$ est un nombre compris entre $1$ et $10$ (exclus). Repère où placer la virgule pour que $a$ soit correct, puis compte combien de fois il faut déplacer la virgule.`;
33
+ };
34
+ const getCorrection = (identifiers) => {
35
+ const { decimal } = identifiers;
36
+ const isZero = decimal < 1;
37
+ const order = isZero ? "droite" : "gauche";
38
+ const dec = new Decimal(decimal);
39
+ const absExp = Math.abs(dec.tenthExponentBelow);
40
+ return `On déplace la virgule après le premier chiffre non nul :
41
+
42
+ $$
43
+ ${decimal.frenchify()} = ${getAnswer(identifiers)}
44
+ $$
45
+
46
+ On a déplacé la virgule de $${absExp}$ ${pluralize("rang", absExp)} vers la ${order}, donc l'exposant est $${dec.tenthExponentBelow}$.`;
47
+ };
48
+ const getQuestionFromIdentifiers = (identifiers) => {
49
+ const question = {
50
+ instruction: getInstruction(identifiers),
51
+ startStatement: identifiers.decimal.frenchify(),
52
+ answer: getAnswer(identifiers),
53
+ keys: [],
54
+ answerFormat: "tex",
55
+ identifiers,
56
+ hint: getHint(identifiers),
57
+ correction: getCorrection(identifiers),
58
+ };
59
+ return question;
60
+ };
10
61
  const getDecimalToScientificQuestion = () => {
11
62
  const isZero = probaFlip(0.2);
12
63
  let intPart, dec;
@@ -17,17 +68,8 @@ const getDecimalToScientificQuestion = () => {
17
68
  intPart = IntegerConstructor.random(randint(2, 5));
18
69
  dec = DecimalConstructor.fromParts(intPart.toString(), DecimalConstructor.randomFracPart(randint(1, 3)));
19
70
  }
20
- const decTex = dec.toTree().toTex().replace(".", ",");
21
- const answer = dec.toScientificNotation().toTex();
22
- const question = {
23
- instruction: `Donner l'écriture scientifique de : $${decTex}$`,
24
- startStatement: decTex,
25
- answer: answer,
26
- keys: [],
27
- answerFormat: "tex",
28
- identifiers: { decimal: dec.value },
29
- };
30
- return question;
71
+ const identifiers = { decimal: dec.value };
72
+ return getQuestionFromIdentifiers(identifiers);
31
73
  };
32
74
  const getPropositions = (n, { answer, decimal }) => {
33
75
  const propositions = [];
@@ -55,4 +97,6 @@ export const decimalToScientific = {
55
97
  getPropositions,
56
98
  isAnswerValid,
57
99
  subject: "Mathématiques",
100
+ hasHintAndCorrection: true,
101
+ getQuestionFromIdentifiers,
58
102
  };
@@ -8,4 +8,5 @@ export * from "./powersPower.js";
8
8
  export * from "./powersProduct.js";
9
9
  export * from "./scientificToDecimal.js";
10
10
  export * from "./powersMixOperations.js";
11
+ export * from "./powersOfTenMixOperations.js";
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC"}
@@ -8,3 +8,4 @@ export * from "./powersPower.js";
8
8
  export * from "./powersProduct.js";
9
9
  export * from "./scientificToDecimal.js";
10
10
  export * from "./powersMixOperations.js";
11
+ export * from "./powersOfTenMixOperations.js";
@@ -7,7 +7,10 @@ type Identifiers = {
7
7
  b: number;
8
8
  c: number;
9
9
  };
10
- export declare const powersDivision: Exercise<Identifiers>;
11
- export declare const powersOfTenDivision: Exercise<Identifiers>;
10
+ type Options = {
11
+ useOnlyPowersOfTen: boolean;
12
+ };
13
+ export declare const powersDivision: Exercise<Identifiers, Options>;
14
+ export declare const powersOfTenDivision: Exercise<Identifiers, Options>;
12
15
  export {};
13
16
  //# sourceMappingURL=powersDivision.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"powersDivision.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/powersDivision.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,OAAO,EACL,QAAQ,EAQT,MAAM,mBAAmB,CAAC;AAK3B,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA8FF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CA6BhD,CAAC;AACF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAkBrD,CAAC"}
1
+ {"version":3,"file":"powersDivision.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/powersDivision.ts"],"names":[],"mappings":"AAAA;;GAEG;AAaH,OAAO,EACL,QAAQ,EAcT,MAAM,mBAAmB,CAAC;AAK3B,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,kBAAkB,EAAE,OAAO,CAAC;CAC7B,CAAC;AA6HF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiBzD,CAAC;AACF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiB9D,CAAC"}