math-exercises 3.0.26 → 3.0.28

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 (56) hide show
  1. package/lib/exercises/math/dataRepresentations/functionGraphReading.js +1 -1
  2. package/lib/exercises/math/dataRepresentations/index.d.ts +0 -1
  3. package/lib/exercises/math/dataRepresentations/index.d.ts.map +1 -1
  4. package/lib/exercises/math/dataRepresentations/index.js +1 -1
  5. package/lib/exercises/math/dataRepresentations/pieChartReading.d.ts.map +1 -1
  6. package/lib/exercises/math/dataRepresentations/pieChartReading.js +2 -4
  7. package/lib/exercises/math/derivation/derivative/convexityQuadrinomials.d.ts.map +1 -1
  8. package/lib/exercises/math/derivation/derivative/convexityQuadrinomials.js +27 -10
  9. package/lib/exercises/math/derivation/derivative/convexityTrinomials.d.ts.map +1 -1
  10. package/lib/exercises/math/derivation/derivative/convexityTrinomials.js +21 -10
  11. package/lib/exercises/math/derivation/derivative/cosCompositionDerivation.d.ts.map +1 -1
  12. package/lib/exercises/math/derivation/derivative/cosCompositionDerivation.js +38 -11
  13. package/lib/exercises/math/derivation/derivative/cosSecondDegreeDerivative.d.ts.map +1 -1
  14. package/lib/exercises/math/derivation/derivative/cosSecondDegreeDerivative.js +40 -13
  15. package/lib/exercises/math/derivation/derivative/expDerivativeFour.d.ts.map +1 -1
  16. package/lib/exercises/math/derivation/derivative/expDerivativeFour.js +5 -1
  17. package/lib/exercises/math/derivation/derivative/expDerivativeOne.d.ts.map +1 -1
  18. package/lib/exercises/math/derivation/derivative/expDerivativeOne.js +46 -14
  19. package/lib/exercises/math/derivation/derivative/expDerivativeTwo.d.ts.map +1 -1
  20. package/lib/exercises/math/derivation/derivative/expDerivativeTwo.js +33 -12
  21. package/lib/exercises/math/derivation/derivative/firstDegreeDerivative.d.ts.map +1 -1
  22. package/lib/exercises/math/derivation/derivative/firstDegreeDerivative.js +5 -3
  23. package/lib/exercises/math/derivation/derivative/inverseFunctionDerivative.d.ts.map +1 -1
  24. package/lib/exercises/math/derivation/derivative/inverseFunctionDerivative.js +31 -14
  25. package/lib/exercises/math/derivation/derivative/lnDerivativeTwo.d.ts.map +1 -1
  26. package/lib/exercises/math/derivation/derivative/lnDerivativeTwo.js +31 -12
  27. package/lib/exercises/math/derivation/derivative/powerCompositionDerivation.d.ts.map +1 -1
  28. package/lib/exercises/math/derivation/derivative/powerCompositionDerivation.js +1 -0
  29. package/lib/exercises/math/derivation/derivative/powerFunctionDerivative.d.ts.map +1 -1
  30. package/lib/exercises/math/derivation/derivative/powerFunctionDerivative.js +35 -15
  31. package/lib/exercises/math/derivation/derivative/productDerivative.d.ts.map +1 -1
  32. package/lib/exercises/math/derivation/derivative/productDerivative.js +43 -16
  33. package/lib/exercises/math/derivation/derivative/quotientDerivative.d.ts.map +1 -1
  34. package/lib/exercises/math/derivation/derivative/quotientDerivative.js +0 -2
  35. package/lib/exercises/math/derivation/derivative/rootFunctionDerivative.d.ts.map +1 -1
  36. package/lib/exercises/math/derivation/derivative/rootFunctionDerivative.js +0 -2
  37. package/lib/exercises/math/derivation/derivative/secondDegreeDerivative.d.ts.map +1 -1
  38. package/lib/exercises/math/derivation/derivative/secondDegreeDerivative.js +16 -15
  39. package/lib/exercises/math/derivation/derivative/secondDerivativeOfExpoFunction.d.ts.map +1 -1
  40. package/lib/exercises/math/derivation/derivative/secondDerivativeOfExpoFunction.js +39 -11
  41. package/lib/exercises/math/derivation/derivative/secondDerivativeOfThirdDegreeFunction.d.ts.map +1 -1
  42. package/lib/exercises/math/derivation/derivative/secondDerivativeOfThirdDegreeFunction.js +35 -12
  43. package/lib/exercises/math/derivation/derivative/secondDerivativeOfTrinom.d.ts.map +1 -1
  44. package/lib/exercises/math/derivation/derivative/secondDerivativeOfTrinom.js +23 -9
  45. package/lib/exercises/math/derivation/derivative/sqrtCompositionDerivation.d.ts.map +1 -1
  46. package/lib/exercises/math/derivation/derivative/sqrtCompositionDerivation.js +23 -7
  47. package/lib/exercises/math/derivation/derivativeNumberCalcul.d.ts.map +1 -1
  48. package/lib/exercises/math/derivation/derivativeNumberCalcul.js +31 -11
  49. package/lib/exercises/math/powers/powersOfTenToDecimal.d.ts.map +1 -1
  50. package/lib/exercises/math/powers/powersOfTenToDecimal.js +30 -23
  51. package/lib/index.d.ts +0 -3
  52. package/lib/index.d.ts.map +1 -1
  53. package/lib/tree/nodes/functions/expNode.d.ts +2 -2
  54. package/lib/tree/nodes/functions/expNode.d.ts.map +1 -1
  55. package/lib/tree/nodes/functions/expNode.js +2 -2
  56. package/package.json +1 -1
@@ -123,7 +123,7 @@ const getFunctionGraphReadingQuestion = (opts) => {
123
123
  };
124
124
  export const functionGraphReading = {
125
125
  id: "functionGraphReading",
126
- label: "Lire le graphique d'une fonction",
126
+ label: "Lire et interpréter la courbe d'une fonction",
127
127
  isSingleStep: true,
128
128
  generator: (nb, opts) => getDistinctQuestions(() => getFunctionGraphReadingQuestion(opts), nb),
129
129
  qcmTimer: 60,
@@ -1,5 +1,4 @@
1
1
  export * from "./tableReading.js";
2
2
  export * from "./functionGraphReading.js";
3
3
  export * from "./pieChartReading.js";
4
- export * from "./testGen.js";
5
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/dataRepresentations/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAElC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/dataRepresentations/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAElC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC"}
@@ -2,4 +2,4 @@ export * from "./tableReading.js";
2
2
  // export * from "./barChartReading.js";
3
3
  export * from "./functionGraphReading.js";
4
4
  export * from "./pieChartReading.js";
5
- export * from "./testGen.js";
5
+ // export * from "./testGen.js";
@@ -1 +1 @@
1
- {"version":3,"file":"pieChartReading.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/dataRepresentations/pieChartReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAuBrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAoLF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAiBjD,CAAC"}
1
+ {"version":3,"file":"pieChartReading.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/dataRepresentations/pieChartReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAuBrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAkLF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAiBjD,CAAC"}
@@ -56,18 +56,16 @@ const getGGBOptions = (identifiers) => {
56
56
  const angleM = angleA +
57
57
  Math.atan2(Math.sin(angleB - angleA), Math.cos(angleB - angleA)) / 2;
58
58
  return [1.2 * Math.cos(angleM), 1.2 * Math.sin(angleM)];
59
- return [
60
- (1.2 * (xA + xB)) / Math.sqrt((xA + xB) ** 2 + (yA + yB) ** 2 + 0.1),
61
- (1.2 * (yA + yB)) / Math.sqrt((xA + xB) ** 2 + (yA + yB) ** 2 + 0.1),
62
- ];
63
59
  };
64
60
  const ggb = new GeogebraConstructor({
65
61
  commands: [
66
62
  `C = Circle((0,0), 1)`,
63
+ `SetFixed(C, true)`,
67
64
  `SetLineThickness(C, 1)`,
68
65
  // ...pointsObj.flatMap((p) => p.toGGBCommand()),
69
66
  ...pointsObj.flatMap((p, i) => [
70
67
  `C_${i} = CircularSector((0,0), ${pointsObj[(i + 1 + pointsObj.length) % pointsObj.length].toMathString()}, ${p.toMathString()})`,
68
+ `SetFixed(C_${i}, true)`,
71
69
  `SetColor(C_${i}, "${colorWithOpacity(colors[i], 80)}")`,
72
70
  `SetLineThickness(C_${i}, 0)`,
73
71
  // `SetCaption(C_${i}, "$\\tiny \\text{${labels[i]}}$")`,
@@ -1 +1 @@
1
- {"version":3,"file":"convexityQuadrinomials.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/convexityQuadrinomials.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAoBrC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAqHF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAcxD,CAAC"}
1
+ {"version":3,"file":"convexityQuadrinomials.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/convexityQuadrinomials.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAoBrC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAqIF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAcxD,CAAC"}
@@ -11,13 +11,24 @@ import { IntervalNode } from "../../../../tree/nodes/sets/intervalNode.js";
11
11
  import { intervalParser } from "../../../../tree/parsers/intervalParser.js";
12
12
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
13
13
  import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
14
- const getConvexityQuadrinomialsQuestion = () => {
15
- const quadrinomial = PolynomialConstructor.randomWithOrder(3);
16
- const quadcoeffs = quadrinomial.coefficients;
14
+ const getInstruction = (identifiers) => {
15
+ const { askConvex, quadcoeffs } = identifiers;
16
+ const quadrinomial = new Polynomial(quadcoeffs);
17
+ const questionType = askConvex ? "convexe" : "concave";
18
+ return `Soit la fonction $f$ définie par :
19
+
20
+ $$
21
+ f(x) = ${quadrinomial.toTex()}
22
+ $$
23
+
24
+ Sur quelle intervalle $f$ est-elle ${questionType} ?`;
25
+ };
26
+ const getAnswer = (identifiers) => {
27
+ const { askConvex, quadcoeffs } = identifiers;
28
+ const quadrinomial = new Polynomial(quadcoeffs);
17
29
  const secondderivative = quadrinomial.derivate().derivate();
18
30
  const seconddcoeffs = secondderivative.coefficients;
19
31
  const inflexionPoint = new FractionNode(new MultiplyNode(seconddcoeffs[0].toTree(), new NumberNode(-1)), seconddcoeffs[1].toTree()).simplify();
20
- const askConvex = coinFlip();
21
32
  let interval;
22
33
  if (askConvex) {
23
34
  interval =
@@ -31,13 +42,19 @@ const getConvexityQuadrinomialsQuestion = () => {
31
42
  ? new IntervalNode(inflexionPoint, PlusInfinityNode, ClosureType.OO).toTex()
32
43
  : new IntervalNode(MinusInfinityNode, inflexionPoint, ClosureType.OO).toTex();
33
44
  }
34
- const questionType = askConvex ? "convexe" : "concave";
45
+ return interval;
46
+ };
47
+ const getConvexityQuadrinomialsQuestion = () => {
48
+ const quadrinomial = PolynomialConstructor.randomWithOrder(3);
49
+ const quadcoeffs = quadrinomial.coefficients;
50
+ const askConvex = coinFlip();
51
+ const identifiers = { askConvex, quadcoeffs };
35
52
  const question = {
36
- answer: interval,
37
- instruction: `Soit la fonction $f(x) = ${quadrinomial.toTex()}$. Sur quelle intervalle est-elle ${questionType} ?`,
53
+ answer: getAnswer(identifiers),
54
+ instruction: getInstruction(identifiers),
38
55
  keys: ["rbracket", "lbracket", "semicolon", "infty", "reals"],
39
56
  answerFormat: "tex",
40
- identifiers: { askConvex, quadcoeffs },
57
+ identifiers,
41
58
  };
42
59
  return question;
43
60
  };
@@ -72,9 +89,7 @@ const isAnswerValid = (ans, { answer, askConvex, quadcoeffs }) => {
72
89
  export const convexityQuadrinomials = {
73
90
  id: "convexityQuadrinomials",
74
91
  label: "Convexité des fonctions polynomiales de degré $3$",
75
- levels: ["TermSpé"],
76
92
  isSingleStep: true,
77
- sections: ["Dérivation"],
78
93
  generator: (nb) => getDistinctQuestions(getConvexityQuadrinomialsQuestion, nb),
79
94
  qcmTimer: 60,
80
95
  freeTimer: 60,
@@ -82,4 +97,6 @@ export const convexityQuadrinomials = {
82
97
  getPropositions,
83
98
  isAnswerValid,
84
99
  subject: "Mathématiques",
100
+ getAnswer,
101
+ getInstruction,
85
102
  };
@@ -1 +1 @@
1
- {"version":3,"file":"convexityTrinomials.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/convexityTrinomials.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAIrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAgCF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAcrD,CAAC"}
1
+ {"version":3,"file":"convexityTrinomials.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/convexityTrinomials.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAIrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AA0CF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAarD,CAAC"}
@@ -1,15 +1,30 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { TrinomConstructor } from "../../../../math/polynomials/trinom.js";
4
+ const getInstruction = (identifiers) => {
5
+ const trinom = TrinomConstructor.fromCoeffs(identifiers.coeffs);
6
+ return `Soit la fonction $f$ définie par :
7
+
8
+ $$
9
+ f(x) = ${trinom.toTex()}
10
+ $$
11
+
12
+ Sur $\\mathbb{R}$, $f$ est :`;
13
+ };
14
+ const getAnswer = (identifiers) => {
15
+ const trinom = TrinomConstructor.fromCoeffs(identifiers.coeffs);
16
+ const isConvex = trinom.a > 0 ? "Convexe" : "Concave";
17
+ return isConvex;
18
+ };
4
19
  const getConvexityTrinomialsQuestion = () => {
5
20
  const trinom = TrinomConstructor.random();
6
- const isConvex = trinom.a > 0 ? "Convexe" : "Concave";
21
+ const identifiers = { coeffs: trinom.coefficients };
7
22
  const question = {
8
- answer: isConvex,
9
- instruction: `Soit la fonction $f(x) = ${trinom.toTex()}$. Sur $\\mathbb{R}$, $f$ est :`,
23
+ answer: getAnswer(identifiers),
24
+ instruction: getInstruction(identifiers),
10
25
  keys: [],
11
26
  answerFormat: "raw",
12
- identifiers: { coeffs: trinom.coefficients },
27
+ identifiers,
13
28
  };
14
29
  return question;
15
30
  };
@@ -22,20 +37,16 @@ const getPropositions = (n, { answer }) => {
22
37
  tryToAddWrongProp(propositions, "On ne peut pas savoir", "raw");
23
38
  return shuffleProps(propositions, n);
24
39
  };
25
- const isAnswerValid = (ans, { answer }) => {
26
- throw Error("VEA not implemented");
27
- };
28
40
  export const convexityTrinomials = {
29
41
  id: "convexityTrinomials",
30
42
  label: "Déterminer la convexité d'un trinôme",
31
- levels: ["TermSpé"],
32
43
  isSingleStep: true,
33
- sections: ["Dérivation"],
34
44
  generator: (nb) => getDistinctQuestions(getConvexityTrinomialsQuestion, nb),
35
45
  qcmTimer: 60,
36
46
  freeTimer: 60,
37
47
  answerType: "QCU",
38
48
  getPropositions,
39
- isAnswerValid,
40
49
  subject: "Mathématiques",
50
+ getAnswer,
51
+ getInstruction,
41
52
  };
@@ -1 +1 @@
1
- {"version":3,"file":"cosCompositionDerivation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/cosCompositionDerivation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AA+DF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAc1D,CAAC"}
1
+ {"version":3,"file":"cosCompositionDerivation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/cosCompositionDerivation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAmFF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAc1D,CAAC"}
@@ -5,16 +5,33 @@ import { CosNode } from "../../../../tree/nodes/functions/cosNode.js";
5
5
  import { OppositeNode } from "../../../../tree/nodes/functions/oppositeNode.js";
6
6
  import { SinNode } from "../../../../tree/nodes/functions/sinNode.js";
7
7
  import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
8
- const getCosCompositionDerivationQuestion = () => {
9
- const affine = AffineConstructor.random(undefined, { excludes: [0] });
8
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
9
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
10
+ const getInstruction = (identifiers) => {
11
+ const { affineA, affineB } = identifiers;
12
+ const affine = new Affine(affineA, affineB);
10
13
  const fct = new CosNode(affine.toTree());
14
+ return `Déterminer la dérivée de la fonction $f$ définie par :
15
+
16
+ $$
17
+ f(x) = ${fct.toTex()}
18
+ $$`;
19
+ };
20
+ const getAnswer = (identifiers) => {
21
+ const { affineA, affineB } = identifiers;
22
+ const affine = new Affine(affineA, affineB);
11
23
  const deriv = new MultiplyNode((-affine.a).toTree(), new SinNode(affine.toTree()));
24
+ return deriv.toTex();
25
+ };
26
+ const getCosCompositionDerivationQuestion = () => {
27
+ const affine = AffineConstructor.random(undefined, { excludes: [0] });
28
+ const identifiers = { affineA: affine.a, affineB: affine.b };
12
29
  const question = {
13
- answer: deriv.toTex(),
14
- instruction: `Déterminer la dérivée de la fonction $f(x) = ${fct.toTex()}$`,
30
+ answer: getAnswer(identifiers),
31
+ instruction: getInstruction(identifiers),
15
32
  keys: ["x", "sin", "cos", "tan"],
16
33
  answerFormat: "tex",
17
- identifiers: { affineA: affine.a, affineB: affine.b },
34
+ identifiers,
18
35
  };
19
36
  return question;
20
37
  };
@@ -33,22 +50,32 @@ const getPropositions = (n, { answer, affineA, affineB }) => {
33
50
  return shuffleProps(propositions, n);
34
51
  };
35
52
  const isAnswerValid = (ans, { answer, affineA, affineB }) => {
36
- const affine = new Affine(affineA, affineB);
37
- const deriv = new MultiplyNode((-affineA).toTree(), new SinNode(affine.toTree()));
38
- const texs = deriv.toAllValidTexs();
39
- return texs.includes(ans);
53
+ try {
54
+ const parsed = parseAlgebraic(ans);
55
+ if (!parsed)
56
+ return false;
57
+ return (parsed
58
+ .simplify({
59
+ towardsDistribute: true,
60
+ forbidFactorize: true,
61
+ })
62
+ .toTex() === answer);
63
+ }
64
+ catch (err) {
65
+ return handleVEAError(err);
66
+ }
40
67
  };
41
68
  export const cosCompositionDerivation = {
42
69
  id: "cosCompositionDerivation",
43
70
  connector: "=",
44
71
  label: "Dérivée de $\\cos(ax+b)$",
45
- levels: ["1reSpé"],
46
72
  isSingleStep: true,
47
- sections: ["Dérivation"],
48
73
  generator: (nb) => getDistinctQuestions(getCosCompositionDerivationQuestion, nb),
49
74
  qcmTimer: 60,
50
75
  freeTimer: 60,
51
76
  getPropositions,
52
77
  isAnswerValid,
53
78
  subject: "Mathématiques",
79
+ getAnswer,
80
+ getInstruction,
54
81
  };
@@ -1 +1 @@
1
- {"version":3,"file":"cosSecondDegreeDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/cosSecondDegreeDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAoHF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAa3D,CAAC"}
1
+ {"version":3,"file":"cosSecondDegreeDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/cosSecondDegreeDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AA+HF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAa3D,CAAC"}
@@ -8,19 +8,36 @@ import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
8
8
  import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
9
9
  import { PowerNode } from "../../../../tree/nodes/operators/powerNode.js";
10
10
  import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
11
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
12
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
13
+ const getInstruction = (identifiers) => {
14
+ const { affinecoeffs } = identifiers;
15
+ const affine = AffineConstructor.fromCoeffs(affinecoeffs);
16
+ const func = new CosNode(affine.toTree().simplify({ forbidFactorize: true })).toTex();
17
+ return `Calculez la dérivée seconde de la fonction $f$ définie par :
18
+
19
+ $$
20
+ f(x) = ${func}
21
+ $$`;
22
+ };
23
+ const getAnswer = (identifiers) => {
24
+ const { affinecoeffs } = identifiers;
25
+ const affine = AffineConstructor.fromCoeffs(affinecoeffs);
26
+ const ans = new MultiplyNode(new MultiplyNode(new PowerNode(affinecoeffs[1].toTree(), new NumberNode(2)), new NumberNode(-1)), new CosNode(affine.toTree().simplify({ forbidFactorize: true })))
27
+ .simplify({ forbidFactorize: true })
28
+ .toTex();
29
+ return ans;
30
+ };
11
31
  const getCosSecondDegreeDerivativeQuestion = () => {
12
32
  const affine = AffineConstructor.random();
13
33
  const affinecoeffs = affine.coefficients;
14
- const ans = new MultiplyNode(new MultiplyNode(new PowerNode(affinecoeffs[1].toTree(), new NumberNode(2)), new NumberNode(-1)), new CosNode(affine.toTree().simplify({ forbidFactorize: true })))
15
- .simplify()
16
- .toTex();
17
- const func = new CosNode(affine.toTree().simplify({ forbidFactorize: true })).toTex();
34
+ const identifiers = { affinecoeffs };
18
35
  const question = {
19
- answer: ans,
20
- instruction: `Calculez la dérivée seconde de la fonction $f(x) = ${func}$.`,
36
+ answer: getAnswer(identifiers),
37
+ instruction: getInstruction(identifiers),
21
38
  keys: ["x", "sin", "cos", "tan"],
22
39
  answerFormat: "tex",
23
- identifiers: { affinecoeffs },
40
+ identifiers,
24
41
  };
25
42
  return question;
26
43
  };
@@ -56,21 +73,31 @@ const getPropositions = (n, { answer, affinecoeffs }) => {
56
73
  return shuffleProps(propositions, n);
57
74
  };
58
75
  const isAnswerValid = (ans, { answer, affinecoeffs }) => {
59
- const affine = new AddNode(new MultiplyNode(new NumberNode(affinecoeffs[1]), new VariableNode("x")), new NumberNode(affinecoeffs[0])).simplify({ forbidFactorize: true });
60
- const validanswer = new MultiplyNode(new MultiplyNode(new PowerNode(new NumberNode(affinecoeffs[1]), new NumberNode(2)), new NumberNode(-1)), new CosNode(affine)).simplify();
61
- const latexs = validanswer.toAllValidTexs();
62
- return latexs.includes(ans);
76
+ try {
77
+ const parsed = parseAlgebraic(ans);
78
+ if (!parsed)
79
+ return false;
80
+ return (parsed
81
+ .simplify({
82
+ towardsDistribute: true,
83
+ forbidFactorize: true,
84
+ })
85
+ .toTex() === answer);
86
+ }
87
+ catch (err) {
88
+ return handleVEAError(err);
89
+ }
63
90
  };
64
91
  export const cosSecondDegreeDerivative = {
65
92
  id: "cosSecondDegreeDerivative",
66
93
  label: "Dérivée seconde de $\\cos(u)$",
67
- levels: ["TermSpé"],
68
94
  isSingleStep: true,
69
- sections: ["Dérivation"],
70
95
  generator: (nb) => getDistinctQuestions(getCosSecondDegreeDerivativeQuestion, nb),
71
96
  qcmTimer: 60,
72
97
  freeTimer: 60,
73
98
  getPropositions,
74
99
  isAnswerValid,
75
100
  subject: "Mathématiques",
101
+ getAnswer,
102
+ getInstruction,
76
103
  };
@@ -1 +1 @@
1
- {"version":3,"file":"expDerivativeFour.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/expDerivativeFour.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AA4EF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAgBnD,CAAC"}
1
+ {"version":3,"file":"expDerivativeFour.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/expDerivativeFour.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAgFF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAgBnD,CAAC"}
@@ -11,7 +11,11 @@ const getInstruction = (identifiers) => {
11
11
  const affine2 = new Affine(affine2Coeffs[1], affine2Coeffs[0]);
12
12
  const exp = new ExpNode(affine2.toTree());
13
13
  const fct = new MultiplyNode(affine1.toTree(), exp);
14
- return `Déterminer la dérivée de la fonction $f(x) = ${fct.toTex()}$`;
14
+ return `Déterminer la dérivée de la fonction $f$ définie par :
15
+
16
+ $$
17
+ f(x) = ${fct.toTex()}
18
+ $$`;
15
19
  };
16
20
  const getAnswer = (identifiers) => {
17
21
  const { affine1Coeffs, affine2Coeffs } = identifiers;
@@ -1 +1 @@
1
- {"version":3,"file":"expDerivativeOne.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/expDerivativeOne.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqDF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAalD,CAAC"}
1
+ {"version":3,"file":"expDerivativeOne.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/expDerivativeOne.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAsFF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAalD,CAAC"}
@@ -6,20 +6,37 @@ import { randint } from "../../../../math/utils/random/randint.js";
6
6
  import { ExpNode } from "../../../../tree/nodes/functions/expNode.js";
7
7
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
8
8
  import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
9
- const getExpDerivative = () => {
10
- const a = randint(-9, 10, [0]);
11
- const b = randint(-9, 10);
9
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
10
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
11
+ const getInstruction = (identifiers) => {
12
+ const { a, b } = identifiers;
13
+ const affine = new Polynomial([b, a]);
14
+ const myfunction = new ExpNode(affine.toTree());
15
+ return `Déterminer la dérivée de la fonction $f$ définie par :
16
+
17
+ $$
18
+ f(x) = ${myfunction.toTex()}
19
+ $$`;
20
+ };
21
+ const getAnswer = (identifiers) => {
22
+ const { a, b } = identifiers;
12
23
  const affine = new Polynomial([b, a]);
13
24
  const myfunction = new ExpNode(affine.toTree());
14
25
  const derivative = new MultiplyNode(new NumberNode(a), myfunction);
15
26
  const answer = derivative.toTex();
27
+ return answer;
28
+ };
29
+ const getExpDerivative = () => {
30
+ const a = randint(-9, 10, [0]);
31
+ const b = randint(-9, 10);
32
+ const identifiers = { a, b };
16
33
  const question = {
17
- instruction: `Déterminer la dérivée de la fonction $f(x) = ${myfunction.toTex()}$.`,
34
+ instruction: getInstruction(identifiers),
18
35
  startStatement: "f'(x)",
19
- answer,
36
+ answer: getAnswer(identifiers),
20
37
  keys: ["x", "epower", "exp"],
21
38
  answerFormat: "tex",
22
- identifiers: { a, b },
39
+ identifiers,
23
40
  };
24
41
  return question;
25
42
  };
@@ -36,19 +53,32 @@ const getPropositions = (n, { answer, a, b }) => {
36
53
  tryToAddWrongProp(propositions, new MultiplyNode(new NumberNode(randint(-9, 10)), myfunction).toTex());
37
54
  return shuffleProps(propositions, n);
38
55
  };
39
- const isAnswerValid = (ans, { a, b }) => {
40
- const affine = new Polynomial([b, a]);
41
- const myfunction = new ExpNode(affine.toTree());
42
- const derivative = new MultiplyNode(new NumberNode(a), myfunction);
43
- const texs = derivative.toAllValidTexs();
44
- return texs.includes(ans);
56
+ const isAnswerValid = (ans, { answer, a, b }) => {
57
+ try {
58
+ const parsed = parseAlgebraic(ans);
59
+ if (!parsed)
60
+ return false;
61
+ console.log(parsed
62
+ .simplify({
63
+ towardsDistribute: true,
64
+ forbidFactorize: true,
65
+ })
66
+ .toTex());
67
+ return (parsed
68
+ .simplify({
69
+ towardsDistribute: true,
70
+ forbidFactorize: true,
71
+ })
72
+ .toTex() === answer);
73
+ }
74
+ catch (err) {
75
+ return handleVEAError(err);
76
+ }
45
77
  };
46
78
  export const expDerivativeOne = {
47
79
  id: "expDerivativeOne",
48
80
  connector: "=",
49
81
  label: "Dérivée de $\\exp(ax + b)$",
50
- levels: ["1reESM", "1reSpé", "1reTech", "MathComp", "TermSpé"],
51
- sections: ["Dérivation", "Exponentielle"],
52
82
  isSingleStep: false,
53
83
  generator: (nb) => getDistinctQuestions(getExpDerivative, nb),
54
84
  qcmTimer: 60,
@@ -56,4 +86,6 @@ export const expDerivativeOne = {
56
86
  getPropositions,
57
87
  isAnswerValid,
58
88
  subject: "Mathématiques",
89
+ getAnswer,
90
+ getInstruction,
59
91
  };
@@ -1 +1 @@
1
- {"version":3,"file":"expDerivativeTwo.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/expDerivativeTwo.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA4DF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAalD,CAAC"}
1
+ {"version":3,"file":"expDerivativeTwo.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/expDerivativeTwo.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA4EF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAalD,CAAC"}
@@ -6,19 +6,34 @@ import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
6
6
  import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
7
7
  import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
8
8
  import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
9
- const getExpDerivative = () => {
10
- const a = randint(-9, 10, [0]);
11
- const b = randint(-9, 10);
9
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
10
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
11
+ const getInstruction = (identifiers) => {
12
+ const { a, b } = identifiers;
12
13
  const myfunction = new AddNode(new MultiplyNode(new NumberNode(a), new ExpNode(new VariableNode("x"))), new NumberNode(b));
14
+ return `Déterminer la dérivée de la fonction $f$ définie par :
15
+
16
+ $$
17
+ f(x) = ${myfunction.toTex()}
18
+ $$`;
19
+ };
20
+ const getAnswer = (identifiers) => {
21
+ const { a, b } = identifiers;
13
22
  const derivative = new MultiplyNode(new NumberNode(a), new ExpNode(new VariableNode("x")));
14
23
  const answer = derivative.toTex();
24
+ return answer;
25
+ };
26
+ const getExpDerivative = () => {
27
+ const a = randint(-9, 10, [0]);
28
+ const b = randint(-9, 10);
29
+ const identifiers = { a, b };
15
30
  const question = {
16
- instruction: `Déterminer la dérivée de la fonction $f(x) = ${myfunction.toTex()}$.`,
31
+ instruction: getInstruction(identifiers),
17
32
  startStatement: "f'(x)",
18
- answer,
33
+ answer: getAnswer(identifiers),
19
34
  keys: ["x", "epower", "exp"],
20
35
  answerFormat: "tex",
21
- identifiers: { a, b },
36
+ identifiers,
22
37
  };
23
38
  return question;
24
39
  };
@@ -34,17 +49,21 @@ const getPropositions = (n, { answer, a, b }) => {
34
49
  }
35
50
  return shuffleProps(propositions, n);
36
51
  };
37
- const isAnswerValid = (ans, { a }) => {
38
- const derivative = new MultiplyNode(new NumberNode(a), new ExpNode(new VariableNode("x")));
39
- const texs = derivative.toAllValidTexs();
40
- return texs.includes(ans);
52
+ const isAnswerValid = (ans, { a, answer }) => {
53
+ try {
54
+ const parsed = parseAlgebraic(ans);
55
+ if (!parsed)
56
+ return false;
57
+ return parsed.simplify().toTex() === answer;
58
+ }
59
+ catch (err) {
60
+ return handleVEAError(err);
61
+ }
41
62
  };
42
63
  export const expDerivativeTwo = {
43
64
  id: "expDerivativeTwo",
44
65
  connector: "=",
45
66
  label: "Dérivée de $a \\times \\exp(x) + b$",
46
- levels: ["1reESM", "1reSpé", "1reTech", "MathComp"],
47
- sections: ["Dérivation", "Exponentielle"],
48
67
  isSingleStep: false,
49
68
  generator: (nb) => getDistinctQuestions(getExpDerivative, nb),
50
69
  getPropositions,
@@ -52,4 +71,6 @@ export const expDerivativeTwo = {
52
71
  freeTimer: 60,
53
72
  isAnswerValid,
54
73
  subject: "Mathématiques",
74
+ getAnswer,
75
+ getInstruction,
55
76
  };
@@ -1 +1 @@
1
- {"version":3,"file":"firstDegreeDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/firstDegreeDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAKR,YAAY,EAEZ,iBAAiB,EACjB,GAAG,EAIJ,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAyCF,eAAO,MAAM,wBAAwB,EAAE,iBAAiB,CAAC,WAAW,CAenE,CAAC;AAEF,eAAO,MAAM,oCAAoC,EAAE,YAAY,CAAC,WAAW,CAkB1E,CAAC;AACF,eAAO,MAAM,kCAAkC,EAAE,GAAG,CAAC,WAAW,CAK/D,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAgBvD,CAAC"}
1
+ {"version":3,"file":"firstDegreeDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/firstDegreeDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAKR,YAAY,EAEZ,iBAAiB,EACjB,GAAG,EAIJ,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA6CF,eAAO,MAAM,wBAAwB,EAAE,iBAAiB,CAAC,WAAW,CAenE,CAAC;AAEF,eAAO,MAAM,oCAAoC,EAAE,YAAY,CAAC,WAAW,CAkB1E,CAAC;AACF,eAAO,MAAM,kCAAkC,EAAE,GAAG,CAAC,WAAW,CAK/D,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAcvD,CAAC"}
@@ -35,7 +35,11 @@ $$`;
35
35
  const getInstruction = (identifiers) => {
36
36
  const { a, b } = identifiers;
37
37
  const polynomial = new Polynomial([b, a]);
38
- return `Déterminer la fonction dérivée $f'$ de la fonction $f$ définie par $f(x) = ${polynomial.toTex()}$.`;
38
+ return `Déterminer la fonction dérivée $f'$ de la fonction $f$ définie par :
39
+
40
+ $$
41
+ f(x) = ${polynomial.toTex()}
42
+ $$`;
39
43
  };
40
44
  export const getFirstDegreeDerivative = () => {
41
45
  const [a, b] = [randint(-9, 10, [0]), randint(-9, 10)];
@@ -71,8 +75,6 @@ export const firstDegreeDerivative = {
71
75
  id: "firstDegreeDerivative",
72
76
  connector: "=",
73
77
  label: "Dérivée d'une fonction affine",
74
- levels: ["1reESM", "1reSpé", "1reTech", "MathComp", "1rePro", "TermPro"],
75
- sections: ["Dérivation"],
76
78
  isSingleStep: false,
77
79
  generator: (nb) => getDistinctQuestions(getFirstDegreeDerivative, nb),
78
80
  qcmTimer: 60,
@@ -1 +1 @@
1
- {"version":3,"file":"inverseFunctionDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/inverseFunctionDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA0CF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAc3D,CAAC"}
1
+ {"version":3,"file":"inverseFunctionDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/inverseFunctionDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAyDF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAa3D,CAAC"}