math-exercises 3.0.26 → 3.0.27

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 (54) 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/derivation/derivative/convexityQuadrinomials.d.ts.map +1 -1
  6. package/lib/exercises/math/derivation/derivative/convexityQuadrinomials.js +27 -10
  7. package/lib/exercises/math/derivation/derivative/convexityTrinomials.d.ts.map +1 -1
  8. package/lib/exercises/math/derivation/derivative/convexityTrinomials.js +21 -10
  9. package/lib/exercises/math/derivation/derivative/cosCompositionDerivation.d.ts.map +1 -1
  10. package/lib/exercises/math/derivation/derivative/cosCompositionDerivation.js +38 -11
  11. package/lib/exercises/math/derivation/derivative/cosSecondDegreeDerivative.d.ts.map +1 -1
  12. package/lib/exercises/math/derivation/derivative/cosSecondDegreeDerivative.js +40 -13
  13. package/lib/exercises/math/derivation/derivative/expDerivativeFour.d.ts.map +1 -1
  14. package/lib/exercises/math/derivation/derivative/expDerivativeFour.js +5 -1
  15. package/lib/exercises/math/derivation/derivative/expDerivativeOne.d.ts.map +1 -1
  16. package/lib/exercises/math/derivation/derivative/expDerivativeOne.js +46 -14
  17. package/lib/exercises/math/derivation/derivative/expDerivativeTwo.d.ts.map +1 -1
  18. package/lib/exercises/math/derivation/derivative/expDerivativeTwo.js +33 -12
  19. package/lib/exercises/math/derivation/derivative/firstDegreeDerivative.d.ts.map +1 -1
  20. package/lib/exercises/math/derivation/derivative/firstDegreeDerivative.js +5 -3
  21. package/lib/exercises/math/derivation/derivative/inverseFunctionDerivative.d.ts.map +1 -1
  22. package/lib/exercises/math/derivation/derivative/inverseFunctionDerivative.js +31 -14
  23. package/lib/exercises/math/derivation/derivative/lnDerivativeTwo.d.ts.map +1 -1
  24. package/lib/exercises/math/derivation/derivative/lnDerivativeTwo.js +31 -12
  25. package/lib/exercises/math/derivation/derivative/powerCompositionDerivation.d.ts.map +1 -1
  26. package/lib/exercises/math/derivation/derivative/powerCompositionDerivation.js +1 -0
  27. package/lib/exercises/math/derivation/derivative/powerFunctionDerivative.d.ts.map +1 -1
  28. package/lib/exercises/math/derivation/derivative/powerFunctionDerivative.js +35 -15
  29. package/lib/exercises/math/derivation/derivative/productDerivative.d.ts.map +1 -1
  30. package/lib/exercises/math/derivation/derivative/productDerivative.js +43 -16
  31. package/lib/exercises/math/derivation/derivative/quotientDerivative.d.ts.map +1 -1
  32. package/lib/exercises/math/derivation/derivative/quotientDerivative.js +0 -2
  33. package/lib/exercises/math/derivation/derivative/rootFunctionDerivative.d.ts.map +1 -1
  34. package/lib/exercises/math/derivation/derivative/rootFunctionDerivative.js +0 -2
  35. package/lib/exercises/math/derivation/derivative/secondDegreeDerivative.d.ts.map +1 -1
  36. package/lib/exercises/math/derivation/derivative/secondDegreeDerivative.js +16 -15
  37. package/lib/exercises/math/derivation/derivative/secondDerivativeOfExpoFunction.d.ts.map +1 -1
  38. package/lib/exercises/math/derivation/derivative/secondDerivativeOfExpoFunction.js +39 -11
  39. package/lib/exercises/math/derivation/derivative/secondDerivativeOfThirdDegreeFunction.d.ts.map +1 -1
  40. package/lib/exercises/math/derivation/derivative/secondDerivativeOfThirdDegreeFunction.js +35 -12
  41. package/lib/exercises/math/derivation/derivative/secondDerivativeOfTrinom.d.ts.map +1 -1
  42. package/lib/exercises/math/derivation/derivative/secondDerivativeOfTrinom.js +23 -9
  43. package/lib/exercises/math/derivation/derivative/sqrtCompositionDerivation.d.ts.map +1 -1
  44. package/lib/exercises/math/derivation/derivative/sqrtCompositionDerivation.js +23 -7
  45. package/lib/exercises/math/derivation/derivativeNumberCalcul.d.ts.map +1 -1
  46. package/lib/exercises/math/derivation/derivativeNumberCalcul.js +31 -11
  47. package/lib/exercises/math/powers/powersOfTenToDecimal.d.ts.map +1 -1
  48. package/lib/exercises/math/powers/powersOfTenToDecimal.js +30 -23
  49. package/lib/index.d.ts +0 -3
  50. package/lib/index.d.ts.map +1 -1
  51. package/lib/tree/nodes/functions/expNode.d.ts +2 -2
  52. package/lib/tree/nodes/functions/expNode.d.ts.map +1 -1
  53. package/lib/tree/nodes/functions/expNode.js +2 -2
  54. package/package.json +1 -1
@@ -1,20 +1,31 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { randint } from "../../../../math/utils/random/randint.js";
4
- import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
5
- import { FractionNode } from "../../../../tree/nodes/operators/fractionNode.js";
6
- import { SquareNode } from "../../../../tree/nodes/operators/powerNode.js";
7
- import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
4
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
5
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
6
+ const getInstruction = (identifiers) => {
7
+ const { a } = identifiers;
8
+ return `Déterminer la fonction dérivée $f'$ de la fonction $f$ définie par :
9
+
10
+ $$
11
+ f(x) = \\frac{${a}}{x}
12
+ $$`;
13
+ };
14
+ const getAnswer = (identifiers) => {
15
+ const { a } = identifiers;
16
+ const answer = `${a > 0 ? "-" : ""}\\frac{${Math.abs(a)}}{x^2}`;
17
+ return answer;
18
+ };
8
19
  const getInverseFunctionDerivative = () => {
9
20
  const a = randint(-19, 20, [0]);
10
- const answer = `${a > 0 ? "-" : ""}\\frac{${Math.abs(a)}}{x^2}`;
21
+ const identifiers = { a };
11
22
  const question = {
12
- instruction: `Déterminer la fonction dérivée $f'$ de la fonction $f$ définie par $f(x) =\\frac{${a}}{x}$.`,
23
+ instruction: getInstruction(identifiers),
13
24
  startStatement: `f'(x)`,
14
- answer,
25
+ answer: getAnswer(identifiers),
15
26
  keys: ["x"],
16
27
  answerFormat: "tex",
17
- identifiers: { a },
28
+ identifiers,
18
29
  };
19
30
  return question;
20
31
  };
@@ -31,17 +42,21 @@ const getPropositions = (n, { answer, a }) => {
31
42
  }
32
43
  return shuffleProps(propositions, n);
33
44
  };
34
- const isAnswerValid = (ans, { a }) => {
35
- const answerTree = new FractionNode(new NumberNode(-a), new SquareNode(new VariableNode("x")));
36
- const texs = answerTree.toAllValidTexs();
37
- return texs.includes(ans);
45
+ const isAnswerValid = (ans, { answer, a }) => {
46
+ try {
47
+ const parsed = parseAlgebraic(ans);
48
+ if (!parsed)
49
+ return false;
50
+ return parsed.simplify().toTex() === answer;
51
+ }
52
+ catch (err) {
53
+ return handleVEAError(err);
54
+ }
38
55
  };
39
56
  export const inverseFunctionDerivative = {
40
57
  id: "inverseFunctionDerivative",
41
58
  connector: "=",
42
59
  label: "Dérivée d'une fonction inverse",
43
- levels: ["1reESM", "1reSpé", "1reTech", "MathComp", "TermTech"],
44
- sections: ["Dérivation", "Fonction inverse"],
45
60
  isSingleStep: false,
46
61
  generator: (nb) => getDistinctQuestions(getInverseFunctionDerivative, nb),
47
62
  qcmTimer: 60,
@@ -49,4 +64,6 @@ export const inverseFunctionDerivative = {
49
64
  getPropositions,
50
65
  isAnswerValid,
51
66
  subject: "Mathématiques",
67
+ getAnswer,
68
+ getInstruction,
52
69
  };
@@ -1 +1 @@
1
- {"version":3,"file":"lnDerivativeTwo.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/lnDerivativeTwo.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA6DF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAajD,CAAC"}
1
+ {"version":3,"file":"lnDerivativeTwo.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/lnDerivativeTwo.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA+EF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAWjD,CAAC"}
@@ -8,20 +8,35 @@ import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
8
8
  import { FractionNode } from "../../../../tree/nodes/operators/fractionNode.js";
9
9
  import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
10
10
  import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
11
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
11
12
  import { shuffle } from "../../../../utils/alea/shuffle.js";
12
- const getLnDerivative = () => {
13
- const a = randint(-9, 10, [0]);
14
- const b = randint(-9, 10, [0]);
13
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
14
+ const getInstruction = (identifiers) => {
15
+ const { a, b } = identifiers;
15
16
  const myfunction = new AddNode(new MultiplyNode(new NumberNode(a), new LogNode(new VariableNode("x"))), new NumberNode(b));
17
+ return `Déterminer la dérivée de la fonction $f$ définie par :
18
+
19
+ $$
20
+ f(x) = ${myfunction.toTex()}
21
+ $$`;
22
+ };
23
+ const getAnswer = (identifiers) => {
24
+ const { a, b } = identifiers;
16
25
  const derivative = new FractionNode(new NumberNode(a), new VariableNode("x"));
17
26
  const answer = derivative.toTex();
27
+ return answer;
28
+ };
29
+ const getLnDerivative = () => {
30
+ const a = randint(-9, 10, [0]);
31
+ const b = randint(-9, 10, [0]);
32
+ const identifiers = { a, b };
18
33
  const question = {
19
- instruction: `Déterminer la dérivée de la fonction $f(x) = ${myfunction.toTex()}$.`,
34
+ instruction: getInstruction(identifiers),
20
35
  startStatement: "f'(x)",
21
- answer,
36
+ answer: getAnswer(identifiers),
22
37
  keys: ["x", "lnBrackets", "epower"],
23
38
  answerFormat: "tex",
24
- identifiers: { a, b },
39
+ identifiers,
25
40
  };
26
41
  return question;
27
42
  };
@@ -37,17 +52,21 @@ const getPropositions = (n, { answer, a, b }) => {
37
52
  }
38
53
  return shuffle(propositions);
39
54
  };
40
- const isAnswerValid = (ans, { a }) => {
41
- const derivative = new FractionNode(new NumberNode(a), new VariableNode("x"));
42
- const texs = derivative.toAllValidTexs();
43
- return texs.includes(ans);
55
+ const isAnswerValid = (ans, { answer, a }) => {
56
+ try {
57
+ const parsed = parseAlgebraic(ans);
58
+ if (!parsed)
59
+ return false;
60
+ return parsed.simplify().toTex() === answer;
61
+ }
62
+ catch (err) {
63
+ return handleVEAError(err);
64
+ }
44
65
  };
45
66
  export const lnDerivativeTwo = {
46
67
  id: "lnDerivativeTwo",
47
68
  connector: "=",
48
69
  label: "Dérivée de $a \\times \\ln(x) + b$",
49
- levels: ["1reESM", "1reSpé", "1reTech", "MathComp", "TermSpé"],
50
- sections: ["Dérivation", "Logarithme népérien"],
51
70
  isSingleStep: false,
52
71
  generator: (nb) => getDistinctQuestions(getLnDerivative, nb),
53
72
  getPropositions,
@@ -1 +1 @@
1
- {"version":3,"file":"powerCompositionDerivation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/powerCompositionDerivation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAoIF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAmB5D,CAAC"}
1
+ {"version":3,"file":"powerCompositionDerivation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/powerCompositionDerivation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAqIF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAmB5D,CAAC"}
@@ -15,6 +15,7 @@ const getInstruction = (identifiers) => {
15
15
  const affineTree = affine.toTree();
16
16
  const fct = new PowerNode(affineTree, powerTree);
17
17
  return `Déterminer la fonction dérivée de la fonction $f$ définie par :
18
+
18
19
  $$
19
20
  f(x) = ${fct.toTex()}
20
21
  $$`;
@@ -1 +1 @@
1
- {"version":3,"file":"powerFunctionDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/powerFunctionDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AA+GF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAezD,CAAC"}
1
+ {"version":3,"file":"powerFunctionDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/powerFunctionDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AA0HF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAczD,CAAC"}
@@ -5,21 +5,36 @@ 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 { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
8
- const getPowerFunctionDerivative = () => {
9
- const a = randint(-9, 10, [0]);
10
- const power = randint(2, 10);
8
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
9
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
10
+ const getInstruction = (identifiers) => {
11
+ const { a, power } = identifiers;
11
12
  const statement = new MultiplyNode(new NumberNode(a), new PowerNode(new VariableNode("x"), new NumberNode(power)));
13
+ return `Déterminer la fonction dérivée $f'$ de la fonction $f$ définie par :
14
+
15
+ $$
16
+ f(x)=${statement.toTex()}
17
+ $$`;
18
+ };
19
+ const getAnswer = (identifiers) => {
20
+ const { a, power } = identifiers;
12
21
  const answerStatement = power > 2
13
22
  ? new MultiplyNode(new NumberNode(a * power), new PowerNode(new VariableNode("x"), new NumberNode(power - 1)))
14
23
  : new MultiplyNode(new NumberNode(a * power), new VariableNode("x"));
15
24
  const answer = answerStatement.toTex();
25
+ return answer;
26
+ };
27
+ const getPowerFunctionDerivative = () => {
28
+ const a = randint(-9, 10, [0]);
29
+ const power = randint(2, 10);
30
+ const identifiers = { a, power };
16
31
  const question = {
17
- instruction: `Déterminer la fonction dérivée $f'$ de la fonction $f$ définie par $f(x) =${statement.toTex()}$.`,
32
+ instruction: getInstruction(identifiers),
18
33
  startStatement: `f'(x)`,
19
- answer,
34
+ answer: getAnswer(identifiers),
20
35
  keys: ["x"],
21
36
  answerFormat: "tex",
22
- identifiers: { a, power },
37
+ identifiers,
23
38
  };
24
39
  return question;
25
40
  };
@@ -44,20 +59,23 @@ const getPropositions = (n, { answer, a, power }) => {
44
59
  }
45
60
  return shuffleProps(propositions, n);
46
61
  };
47
- const isAnswerValid = (ans, { a, power }) => {
48
- const opts = { forbidPowerToProduct: true };
49
- const answerTree = power > 2
50
- ? new MultiplyNode(new NumberNode(a * power), new PowerNode(new VariableNode("x"), new NumberNode(power - 1), opts), opts)
51
- : new MultiplyNode(new NumberNode(a * power), new VariableNode("x"), opts);
52
- const texs = answerTree.toAllValidTexs();
53
- return texs.includes(ans);
62
+ const isAnswerValid = (ans, { answer, a, power }) => {
63
+ try {
64
+ const parsed = parseAlgebraic(ans);
65
+ if (!parsed)
66
+ return false;
67
+ return (parsed
68
+ .simplify({ towardsDistribute: true, forbidFactorize: true })
69
+ .toTex() === answer);
70
+ }
71
+ catch (err) {
72
+ return handleVEAError(err);
73
+ }
54
74
  };
55
75
  export const powerFunctionDerivative = {
56
76
  id: "powerFunctionDerivative",
57
77
  connector: "=",
58
78
  label: "Dérivée d'une fonction monôme",
59
- levels: ["1reESM", "1reSpé", "1reTech", "MathComp"],
60
- sections: ["Dérivation"],
61
79
  isSingleStep: false,
62
80
  generator: (nb) => getDistinctQuestions(getPowerFunctionDerivative, nb),
63
81
  getPropositions,
@@ -65,4 +83,6 @@ export const powerFunctionDerivative = {
65
83
  qcmTimer: 60,
66
84
  freeTimer: 60,
67
85
  subject: "Mathématiques",
86
+ getInstruction,
87
+ getAnswer,
68
88
  };
@@ -1 +1 @@
1
- {"version":3,"file":"productDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/productDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AA4DF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAcnD,CAAC"}
1
+ {"version":3,"file":"productDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/productDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAoFF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAgBnD,CAAC"}
@@ -2,19 +2,38 @@ import { shuffleProps, tryToAddWrongProp, addValidProp, } from "../../../../exer
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Polynomial, PolynomialConstructor, } from "../../../../math/polynomials/polynomial.js";
4
4
  import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
5
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
6
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
7
+ const getInstruction = (identifiers) => {
8
+ const { poly1Coeffs, poly2Coeffs } = identifiers;
9
+ const poly1 = new Polynomial(poly1Coeffs);
10
+ const poly2 = new Polynomial(poly2Coeffs);
11
+ return `Déterminer la dérivée de la fonction $f$ définie par :
12
+
13
+ $$
14
+ f(x) = ${new MultiplyNode(poly1.toTree(), poly2.toTree()).toTex()}
15
+ $$`;
16
+ };
17
+ const getAnswer = (identifiers) => {
18
+ const { poly1Coeffs, poly2Coeffs } = identifiers;
19
+ const poly1 = new Polynomial(poly1Coeffs);
20
+ const poly2 = new Polynomial(poly2Coeffs);
21
+ const answer = poly1.multiply(poly2).derivate().toTree().toTex();
22
+ return answer;
23
+ };
5
24
  const getProductDerivativeQuestion = () => {
6
25
  const poly1 = PolynomialConstructor.randomWithLength(3, 2);
7
26
  const poly2 = PolynomialConstructor.randomWithLength(3, 2);
8
- const answer = poly1.multiply(poly2).derivate().toTree().toTex();
27
+ const identifiers = {
28
+ poly1Coeffs: poly1.coefficients,
29
+ poly2Coeffs: poly2.coefficients,
30
+ };
9
31
  const question = {
10
- answer: answer,
11
- instruction: `Déterminer la dérivée de la fonction $f$ définie par $f(x) = ${new MultiplyNode(poly1.toTree(), poly2.toTree()).toTex()}$`,
32
+ answer: getAnswer(identifiers),
33
+ instruction: getInstruction(identifiers),
12
34
  keys: ["x", "xsquare", "xcube"],
13
35
  answerFormat: "tex",
14
- identifiers: {
15
- poly1Coeffs: poly1.coefficients,
16
- poly2Coeffs: poly2.coefficients,
17
- },
36
+ identifiers,
18
37
  };
19
38
  return question;
20
39
  };
@@ -31,15 +50,21 @@ const getPropositions = (n, { answer, poly1Coeffs, poly2Coeffs }) => {
31
50
  }
32
51
  return shuffleProps(propositions, n);
33
52
  };
34
- const isAnswerValid = (ans, { poly1Coeffs, poly2Coeffs }) => {
35
- const poly1 = new Polynomial(poly1Coeffs);
36
- const poly2 = new Polynomial(poly2Coeffs);
37
- const answer = poly1
38
- .multiply(poly2)
39
- .derivate()
40
- .toTree({ forbidPowerToProduct: true });
41
- const texs = answer.toAllValidTexs();
42
- return texs.includes(ans);
53
+ const isAnswerValid = (ans, { answer, poly1Coeffs, poly2Coeffs }) => {
54
+ try {
55
+ const parsed = parseAlgebraic(ans);
56
+ if (!parsed)
57
+ return false;
58
+ return (parsed
59
+ .simplify({
60
+ towardsDistribute: true,
61
+ forbidFactorize: true,
62
+ })
63
+ .toTex() === answer);
64
+ }
65
+ catch (err) {
66
+ return handleVEAError(err);
67
+ }
43
68
  };
44
69
  export const productDerivative = {
45
70
  id: "productDerivative",
@@ -54,4 +79,6 @@ export const productDerivative = {
54
79
  freeTimer: 60,
55
80
  isAnswerValid,
56
81
  subject: "Mathématiques",
82
+ getAnswer,
83
+ getInstruction,
57
84
  };
@@ -1 +1 @@
1
- {"version":3,"file":"quotientDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/quotientDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAuGF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAcpD,CAAC"}
1
+ {"version":3,"file":"quotientDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/quotientDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAuGF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAYpD,CAAC"}
@@ -88,9 +88,7 @@ export const quotientDerivative = {
88
88
  id: "quotientDerivative",
89
89
  connector: "=",
90
90
  label: "Dérivée d'un quotient de polynômes",
91
- levels: ["1reSpé", "MathComp"],
92
91
  isSingleStep: true,
93
- sections: ["Dérivation"],
94
92
  generator: (nb) => getDistinctQuestions(getProductDerivativeQuestion, nb),
95
93
  qcmTimer: 60,
96
94
  freeTimer: 60,
@@ -1 +1 @@
1
- {"version":3,"file":"rootFunctionDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/rootFunctionDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAoBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA+FF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAmBxD,CAAC"}
1
+ {"version":3,"file":"rootFunctionDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/rootFunctionDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAoBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA+FF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAiBxD,CAAC"}
@@ -100,8 +100,6 @@ export const rootFunctionDerivative = {
100
100
  id: "rootFunctionDerivative",
101
101
  connector: "=",
102
102
  label: "Dérivée d'une fonction racine carrée",
103
- levels: ["1reESM", "1reSpé", "1reTech", "MathComp"],
104
- sections: ["Dérivation", "Racines carrées"],
105
103
  isSingleStep: false,
106
104
  generator: (nb) => getDistinctQuestions(getRootFunctionDerivative, nb),
107
105
  qcmTimer: 60,
@@ -1 +1 @@
1
- {"version":3,"file":"secondDegreeDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/secondDegreeDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAMR,YAAY,EAEZ,iBAAiB,EACjB,GAAG,EAGJ,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AA8CF,eAAO,MAAM,yBAAyB,EAAE,iBAAiB,CAAC,WAAW,CAgBpE,CAAC;AAEF,eAAO,MAAM,qCAAqC,EAAE,YAAY,CAC9D,WAAW,CA+BZ,CAAC;AACF,eAAO,MAAM,mCAAmC,EAAE,GAAG,CAAC,WAAW,CAQhE,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAyBxD,CAAC"}
1
+ {"version":3,"file":"secondDegreeDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/secondDegreeDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAMR,YAAY,EAEZ,iBAAiB,EACjB,GAAG,EAGJ,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AA8CF,eAAO,MAAM,yBAAyB,EAAE,iBAAiB,CAAC,WAAW,CAgBpE,CAAC;AAEF,eAAO,MAAM,qCAAqC,EAAE,YAAY,CAC9D,WAAW,CA+BZ,CAAC;AACF,eAAO,MAAM,mCAAmC,EAAE,GAAG,CAAC,WAAW,CAehE,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAiBxD,CAAC"}
@@ -4,7 +4,9 @@ import { Polynomial } from "../../../../math/polynomials/polynomial.js";
4
4
  import { randint } from "../../../../math/utils/random/randint.js";
5
5
  import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
6
6
  import { power } from "../../../../tree/nodes/operators/powerNode.js";
7
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
7
8
  import { shuffle } from "../../../../utils/alea/shuffle.js";
9
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
8
10
  const getAnswer = (identifiers) => {
9
11
  const polynomial = new Polynomial(identifiers.coefficients);
10
12
  const derivative = polynomial.derivate();
@@ -81,26 +83,23 @@ export const getSecondDegreeDerivativePropositions = (n, { answer, coefficients
81
83
  }
82
84
  return shuffle(propositions);
83
85
  };
84
- export const isSecondDegreeDerivativeAnswerValid = (ans, { coefficients }) => {
85
- const polynomial = new Polynomial(coefficients);
86
- const derivative = polynomial.derivate().toTree();
87
- const texs = derivative.toAllValidTexs();
88
- return texs.includes(ans);
86
+ export const isSecondDegreeDerivativeAnswerValid = (ans, { answer, coefficients }) => {
87
+ try {
88
+ const parsed = parseAlgebraic(ans);
89
+ if (!parsed)
90
+ return false;
91
+ return (parsed
92
+ .simplify({ towardsDistribute: true, forbidFactorize: true })
93
+ .toTex() === answer);
94
+ }
95
+ catch (err) {
96
+ return handleVEAError(err);
97
+ }
89
98
  };
90
99
  export const secondDegreeDerivative = {
91
100
  id: "secondDegreeDerivative",
92
101
  connector: "=",
93
102
  label: "Dérivée d'un polynôme de degré $2$",
94
- levels: [
95
- "1reESM",
96
- "1reSpé",
97
- "1reTech",
98
- "MathComp",
99
- "1rePro",
100
- "TermPro",
101
- "TermTech",
102
- ],
103
- sections: ["Dérivation"],
104
103
  isSingleStep: false,
105
104
  generator: (nb) => getDistinctQuestions(getSecondDegreeDerivative, nb),
106
105
  qcmTimer: 60,
@@ -111,4 +110,6 @@ export const secondDegreeDerivative = {
111
110
  getHint,
112
111
  getCorrection,
113
112
  hasHintAndCorrection: true,
113
+ getInstruction,
114
+ getAnswer,
114
115
  };
@@ -1 +1 @@
1
- {"version":3,"file":"secondDerivativeOfExpoFunction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/secondDerivativeOfExpoFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAiDF,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,WAAW,CAahE,CAAC"}
1
+ {"version":3,"file":"secondDerivativeOfExpoFunction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/secondDerivativeOfExpoFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAgFF,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,WAAW,CAahE,CAAC"}
@@ -2,19 +2,40 @@ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exer
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Polynomial, PolynomialConstructor, } from "../../../../math/polynomials/polynomial.js";
4
4
  import { expUDerivate } from "../../../../math/utils/functions/expUDerivate.js";
5
- import { expuSecondDerivative } from "../../../../math/utils/functions/expUSecondDerivate.js";
6
5
  import { ExpNode } from "../../../../tree/nodes/functions/expNode.js";
6
+ import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
7
7
  import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
8
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
9
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
10
+ const getInstruction = (identifiers) => {
11
+ const { coeffs } = identifiers;
12
+ const polynom = new Polynomial(coeffs);
13
+ const funct = new ExpNode(polynom.toTree());
14
+ return `Déterminer la fonction dérivée seconde $f''$ de la fonction $f$ définie par :
15
+
16
+ $$
17
+ f(x)=${funct.toTex()}
18
+ $$`;
19
+ };
20
+ const getAnswer = (identifiers) => {
21
+ const { coeffs } = identifiers;
22
+ const polynom = new Polynomial(coeffs);
23
+ const funct = new ExpNode(polynom.toTree());
24
+ const uDerivated = polynom.derivate().toTree();
25
+ const uSecondDerivated = polynom.secondDerivate();
26
+ return new AddNode(new MultiplyNode(uSecondDerivated.toTree(), funct).simplify(), new MultiplyNode(uDerivated, expUDerivate(funct, polynom)).simplify())
27
+ .simplify({ towardsDistribute: true, forbidFactorize: true })
28
+ .toTex();
29
+ };
8
30
  const getSecondDerivativeOfExpoFunctionQuestion = () => {
9
31
  const polynom = PolynomialConstructor.randomWithOrder(1, "x");
10
- const funct = new ExpNode(polynom.toTree());
11
- const correctAnswer = expuSecondDerivative(funct, polynom);
32
+ const identifiers = { coeffs: polynom.coefficients };
12
33
  const question = {
13
- answer: correctAnswer.toTex(),
14
- instruction: `Déterminer la fonction dérivée seconde $f''$ de la fonction $f$ définie par $f(x)=${funct.toTex()}$`,
34
+ answer: getAnswer(identifiers),
35
+ instruction: getInstruction(identifiers),
15
36
  keys: ["epower", "x", "lnBrackets"],
16
37
  answerFormat: "tex",
17
- identifiers: { coeffs: polynom.coefficients },
38
+ identifiers,
18
39
  };
19
40
  return question;
20
41
  };
@@ -27,11 +48,18 @@ const getPropositions = (n, { answer, coeffs }) => {
27
48
  }
28
49
  return shuffleProps(propositions, n);
29
50
  };
30
- const isAnswerValid = (ans, { coeffs }) => {
31
- const polynom = new Polynomial(coeffs, "x");
32
- const e = new ExpNode(polynom.toTree());
33
- const correctAnswer = expuSecondDerivative(e, polynom);
34
- return correctAnswer.toAllValidTexs().includes(ans);
51
+ const isAnswerValid = (ans, { answer, coeffs }) => {
52
+ try {
53
+ const parsed = parseAlgebraic(ans);
54
+ if (!parsed)
55
+ return false;
56
+ return (parsed
57
+ .simplify({ towardsDistribute: true, forbidFactorize: true })
58
+ .toTex() === answer);
59
+ }
60
+ catch (err) {
61
+ return handleVEAError(err);
62
+ }
35
63
  };
36
64
  const generateProposition = (coeffs) => {
37
65
  const u = new Polynomial(coeffs, "x");
@@ -1 +1 @@
1
- {"version":3,"file":"secondDerivativeOfThirdDegreeFunction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/secondDerivativeOfThirdDegreeFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA+DF,eAAO,MAAM,qCAAqC,EAAE,QAAQ,CAAC,WAAW,CAavE,CAAC"}
1
+ {"version":3,"file":"secondDerivativeOfThirdDegreeFunction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/secondDerivativeOfThirdDegreeFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqFF,eAAO,MAAM,qCAAqC,EAAE,QAAQ,CAAC,WAAW,CAavE,CAAC"}
@@ -1,25 +1,39 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Polynomial, PolynomialConstructor, } from "../../../../math/polynomials/polynomial.js";
4
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
5
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
6
+ const getInstruction = (identifiers) => {
7
+ const { a, b, c, d } = identifiers;
8
+ const funct = new Polynomial([d, c, b, a]);
9
+ return `Déterminer la fonction dérivée seconde $f''$ de la fonction $f$ définie par :
10
+
11
+ $$
12
+ f(x)=${funct.toTree().toTex()}
13
+ $$`;
14
+ };
15
+ const getAnswer = (identifiers) => {
16
+ const { a, b, c, d } = identifiers;
17
+ const funct = new Polynomial([d, c, b, a]);
18
+ const correctAnswer = funct.secondDerivate().toTree();
19
+ return correctAnswer.toTex();
20
+ };
4
21
  const getSecondDerivativeOfThirdDegreeFunction = () => {
5
22
  const funct = PolynomialConstructor.randomWithOrder(3, "x");
6
23
  const coefficients = funct.coefficients;
7
- const correctAnswer = funct.secondDerivate().toTree();
8
- const instruction = `Déterminer la fonction dérivée seconde $f''$ de la fonction $f$ définie par $f(x)=${funct
9
- .toTree()
10
- .toTex()}$.`;
11
24
  const coeff = {
12
25
  a: coefficients[3],
13
26
  b: coefficients[2],
14
27
  c: coefficients[1],
15
28
  d: coefficients[0],
16
29
  };
30
+ const identifiers = { ...coeff };
17
31
  const question = {
18
- answer: correctAnswer.toTex(),
19
- instruction: instruction,
32
+ answer: getAnswer(identifiers),
33
+ instruction: getInstruction(identifiers),
20
34
  keys: ["x"],
21
35
  answerFormat: "tex",
22
- identifiers: { ...coeff },
36
+ identifiers,
23
37
  };
24
38
  return question;
25
39
  };
@@ -38,20 +52,29 @@ const generateProposition = (a, b, c, d) => {
38
52
  const thirdProposition = new Polynomial([c, 2 * b, 3 * 2 * a], "x").toTree();
39
53
  return [firstPropostion, secondProposition, thirdProposition];
40
54
  };
41
- const isAnswerValid = (ans, { a, b, c, d }) => {
42
- const result = new Polynomial([d, c, b, a], "x");
43
- return result.derivate().derivate().toTree().toAllValidTexs().includes(ans);
55
+ const isAnswerValid = (ans, { answer, a, b, c, d }) => {
56
+ try {
57
+ const parsed = parseAlgebraic(ans);
58
+ if (!parsed)
59
+ return false;
60
+ return (parsed
61
+ .simplify({ towardsDistribute: true, forbidFactorize: true })
62
+ .toTex() === answer);
63
+ }
64
+ catch (err) {
65
+ return handleVEAError(err);
66
+ }
44
67
  };
45
68
  export const secondDerivativeOfThridDegreeFunction = {
46
69
  id: "secondDerivativeOfThirdDegreeFunction",
47
70
  label: "Dérivée seconde d'un polynôme de degré $3$",
48
- levels: ["TermSpé"],
49
71
  isSingleStep: true,
50
- sections: ["Dérivation"],
51
72
  generator: (nb) => getDistinctQuestions(getSecondDerivativeOfThirdDegreeFunction, nb),
52
73
  qcmTimer: 60,
53
74
  freeTimer: 60,
54
75
  getPropositions,
55
76
  isAnswerValid,
56
77
  subject: "Mathématiques",
78
+ getInstruction,
79
+ getAnswer,
57
80
  };
@@ -1 +1 @@
1
- {"version":3,"file":"secondDerivativeOfTrinom.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/secondDerivativeOfTrinom.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAuDF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAa1D,CAAC"}
1
+ {"version":3,"file":"secondDerivativeOfTrinom.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/secondDerivativeOfTrinom.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;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAsEF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAa1D,CAAC"}