math-exercises 3.0.197 → 3.0.199

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 (78) hide show
  1. package/lib/exercises/math/calculLitteral/equation/exp/expOfTrinomEquals1Equation.d.ts.map +1 -1
  2. package/lib/exercises/math/calculLitteral/equation/exp/expOfTrinomEquals1Equation.js +3 -0
  3. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType3.d.ts.map +1 -1
  4. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType3.js +58 -30
  5. package/lib/exercises/math/complex/addComplex.d.ts.map +1 -1
  6. package/lib/exercises/math/complex/addComplex.js +53 -7
  7. package/lib/exercises/math/complex/conjugateComplex.d.ts.map +1 -1
  8. package/lib/exercises/math/complex/conjugateComplex.js +48 -7
  9. package/lib/exercises/math/complex/mutiplyComplex.d.ts.map +1 -1
  10. package/lib/exercises/math/complex/mutiplyComplex.js +51 -18
  11. package/lib/exercises/math/complex/reAndIm.d.ts.map +1 -1
  12. package/lib/exercises/math/complex/reAndIm.js +35 -4
  13. package/lib/exercises/math/derivation/convexity/convexityQuadrinomials.d.ts.map +1 -1
  14. package/lib/exercises/math/derivation/convexity/convexityQuadrinomials.js +46 -4
  15. package/lib/exercises/math/derivation/convexity/convexityQuadrinomialsGeo.d.ts +9 -0
  16. package/lib/exercises/math/derivation/convexity/convexityQuadrinomialsGeo.d.ts.map +1 -0
  17. package/lib/exercises/math/derivation/convexity/convexityQuadrinomialsGeo.js +160 -0
  18. package/lib/exercises/math/derivation/convexity/convexityTrinomials.d.ts.map +1 -1
  19. package/lib/exercises/math/derivation/convexity/convexityTrinomials.js +33 -2
  20. package/lib/exercises/math/derivation/convexity/convexityTrinomialsGeo.d.ts +7 -0
  21. package/lib/exercises/math/derivation/convexity/convexityTrinomialsGeo.d.ts.map +1 -0
  22. package/lib/exercises/math/derivation/convexity/convexityTrinomialsGeo.js +80 -0
  23. package/lib/exercises/math/derivation/convexity/index.d.ts +2 -0
  24. package/lib/exercises/math/derivation/convexity/index.d.ts.map +1 -1
  25. package/lib/exercises/math/derivation/convexity/index.js +2 -0
  26. package/lib/exercises/math/derivation/convexity/inflexionPointQuadrinomials.js +2 -2
  27. package/lib/exercises/math/derivation/derivative/exp/expDerivativeFour.d.ts.map +1 -1
  28. package/lib/exercises/math/derivation/derivative/exp/expDerivativeFour.js +39 -33
  29. package/lib/exercises/math/derivation/derivative/exp/secondDerivativeOfExpoFunction.d.ts.map +1 -1
  30. package/lib/exercises/math/derivation/derivative/exp/secondDerivativeOfExpoFunction.js +45 -3
  31. package/lib/exercises/math/derivation/derivative/ln/lnDerivativeOne.d.ts.map +1 -1
  32. package/lib/exercises/math/derivation/derivative/ln/lnDerivativeOne.js +53 -11
  33. package/lib/exercises/math/derivation/derivative/ln/lnDerivativeThree.d.ts.map +1 -1
  34. package/lib/exercises/math/derivation/derivative/ln/lnDerivativeThree.js +54 -3
  35. package/lib/exercises/math/derivation/derivative/ln/lnDerivativeTwo.d.ts.map +1 -1
  36. package/lib/exercises/math/derivation/derivative/ln/lnDerivativeTwo.js +23 -0
  37. package/lib/exercises/math/derivation/derivative/polynomial/secondDerivativeOfThirdDegreeFunction.d.ts.map +1 -1
  38. package/lib/exercises/math/derivation/derivative/polynomial/secondDerivativeOfThirdDegreeFunction.js +30 -0
  39. package/lib/exercises/math/derivation/derivative/polynomial/secondDerivativeOfTrinom.d.ts.map +1 -1
  40. package/lib/exercises/math/derivation/derivative/polynomial/secondDerivativeOfTrinom.js +25 -1
  41. package/lib/exercises/math/derivation/derivative/trigo/cosCompositionDerivation.d.ts.map +1 -1
  42. package/lib/exercises/math/derivation/derivative/trigo/cosCompositionDerivation.js +27 -0
  43. package/lib/exercises/math/derivation/derivative/trigo/cosSecondDegreeDerivative.d.ts.map +1 -1
  44. package/lib/exercises/math/derivation/derivative/trigo/cosSecondDegreeDerivative.js +47 -3
  45. package/lib/exercises/math/derivation/derivative/trigo/sinCompositionDerivation.d.ts.map +1 -1
  46. package/lib/exercises/math/derivation/derivative/trigo/sinCompositionDerivation.js +44 -5
  47. package/lib/exercises/math/derivation/derivative/trigo/sinSecondDegreeDerivative.d.ts.map +1 -1
  48. package/lib/exercises/math/derivation/derivative/trigo/sinSecondDegreeDerivative.js +65 -9
  49. package/lib/exercises/math/functions/exponential/sign/expFunctionBasicSign.d.ts.map +1 -1
  50. package/lib/exercises/math/functions/exponential/sign/expFunctionBasicSign.js +3 -0
  51. package/lib/exercises/math/functions/exponential/variations/varSignTableOfAffineTimesExp.js +1 -1
  52. package/lib/exercises/math/functions/exponential/variations/varSignTableOfExpMinusX.js +1 -1
  53. package/lib/exercises/math/functions/sign/affineProductSign.d.ts.map +1 -1
  54. package/lib/exercises/math/functions/sign/affineProductSign.js +0 -4
  55. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitReading.d.ts.map +1 -1
  56. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitReading.js +1 -0
  57. package/lib/exercises/math/geometry/index.d.ts +0 -1
  58. package/lib/exercises/math/geometry/index.d.ts.map +1 -1
  59. package/lib/exercises/math/geometry/index.js +0 -1
  60. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorLinearCombinationCoords.d.ts.map +1 -1
  61. package/lib/index.d.ts +6 -6
  62. package/lib/math/utils/arithmetic/gcd.d.ts +5 -0
  63. package/lib/math/utils/arithmetic/gcd.d.ts.map +1 -1
  64. package/lib/math/utils/arithmetic/gcd.js +5 -0
  65. package/lib/playground.d.ts.map +1 -1
  66. package/lib/playground.js +6 -1
  67. package/lib/server.js +3 -2
  68. package/lib/tests/pdfExo.test.js +2 -2
  69. package/lib/tests/pdfs/buildPDFForExercise.d.ts.map +1 -1
  70. package/lib/tests/pdfs/buildPDFForExercise.js +6 -0
  71. package/lib/tests/pdfs/quizPdfPreambule.d.ts.map +1 -1
  72. package/lib/tests/pdfs/quizPdfPreambule.js +1 -0
  73. package/lib/tests/pdfs/treeDiagramToLatex.d.ts +15 -0
  74. package/lib/tests/pdfs/treeDiagramToLatex.d.ts.map +1 -0
  75. package/lib/tests/pdfs/treeDiagramToLatex.js +49 -0
  76. package/lib/tests/questionTest.d.ts.map +1 -1
  77. package/lib/tests/questionTest.js +19 -0
  78. package/package.json +1 -1
@@ -1,16 +1,18 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Polynomial } from "../../../../../math/polynomials/polynomial.js";
4
- import { RationalFrac } from "../../../../../math/polynomials/rationalFrac.js";
4
+ import { gcd } from "../../../../../math/utils/arithmetic/gcd.js";
5
5
  import { randint } from "../../../../../math/utils/random/randint.js";
6
6
  import { ExpNode } from "../../../../../tree/nodes/functions/expNode.js";
7
7
  import { LogNode } from "../../../../../tree/nodes/functions/logNode.js";
8
+ import { opposite } from "../../../../../tree/nodes/functions/oppositeNode.js";
8
9
  import { NumberNode } from "../../../../../tree/nodes/numbers/numberNode.js";
9
10
  import { add } from "../../../../../tree/nodes/operators/addNode.js";
10
11
  import { frac } from "../../../../../tree/nodes/operators/fractionNode.js";
11
12
  import { multiply, MultiplyNode, } from "../../../../../tree/nodes/operators/multiplyNode.js";
12
13
  import { parseAlgebraic } from "../../../../../tree/parsers/latexParser.js";
13
14
  import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
15
+ import { alignTex } from "../../../../../utils/latex/alignTex.js";
14
16
  const getInstruction = (identifiers) => {
15
17
  const { a, b } = identifiers;
16
18
  const polynom = new Polynomial([b, a]);
@@ -23,25 +25,60 @@ $$`;
23
25
  };
24
26
  const getAnswer = (identifiers) => {
25
27
  const { a, b } = identifiers;
26
- const polynom = new Polynomial([b, a]);
27
- const answer = new RationalFrac(new Polynomial([a]), polynom)
28
+ const pgcd = gcd(a, b);
29
+ const aSimp = frac(Math.abs(a), pgcd).simplify();
30
+ const bSimp = frac(Math.abs(b), pgcd).simplify();
31
+ const aPos = a > 0;
32
+ const bPos = b > 0;
33
+ if (!aPos) {
34
+ if (!bPos) {
35
+ return frac(aSimp, add(multiply(aSimp, "x"), bSimp))
36
+ .simplify()
37
+ .toTex();
38
+ }
39
+ return frac(aSimp, add(multiply(aSimp, "x"), opposite(bSimp)))
40
+ .simplify()
41
+ .toTex();
42
+ }
43
+ return frac(aSimp, add(multiply(aSimp, "x"), bPos ? bSimp : opposite(bSimp)))
28
44
  .simplify()
29
- .toTree()
30
45
  .toTex();
31
- return answer;
32
46
  };
33
- // const getHint: GetHint<Identifiers> = (identifiers) => {
34
- // return ``;
35
- // };
36
- // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {
37
- // return ``;
38
- // };
39
47
  const getLnDerivative = () => {
40
48
  const a = randint(-9, 10, [0]);
41
49
  const b = randint(-9, 10);
42
50
  const identifiers = { a, b };
43
51
  return getQuestionFromIdentifiers(identifiers);
44
52
  };
53
+ const getHint = () => {
54
+ return `Pour toute fonction dérivable $u$, on a :
55
+
56
+ $$
57
+ \\left(\\ln(u)\\right)' = \\frac{u'}{u}
58
+ $$`;
59
+ };
60
+ const getCorrection = (identifiers) => {
61
+ const { a, b } = identifiers;
62
+ const raw = frac(a, add(multiply(a, "x"), b));
63
+ const answer = getAnswer(identifiers);
64
+ const isSimp = raw.toTex() === answer;
65
+ return `Pour toute fonction dérivable $u$, on a :
66
+
67
+ $$
68
+ \\left(\\ln(u)\\right)' = \\frac{u'}{u}
69
+ $$
70
+
71
+ Ici, on a donc :
72
+
73
+ ${isSimp
74
+ ? `$$
75
+ f'(x) = ${answer}
76
+ $$`
77
+ : alignTex([
78
+ ["f'(x)", "=", raw.toTex()],
79
+ ["", "=", answer],
80
+ ])}`;
81
+ };
45
82
  const getQuestionFromIdentifiers = (identifiers) => {
46
83
  const question = {
47
84
  instruction: getInstruction(identifiers),
@@ -50,6 +87,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
50
87
  keys: ["x", "lnBrackets", "epower"],
51
88
  answerFormat: "tex",
52
89
  identifiers,
90
+ hint: getHint(identifiers),
91
+ correction: getCorrection(identifiers),
53
92
  };
54
93
  return question;
55
94
  };
@@ -69,6 +108,8 @@ const getPropositions = (n, { answer, a, b }) => {
69
108
  const isAnswerValid = (ans, { answer, a, b }) => {
70
109
  try {
71
110
  const parsed = parseAlgebraic(ans);
111
+ if (!parsed)
112
+ return false;
72
113
  const simp = parsed.simplify().toTex();
73
114
  const nonSimp = frac(a, add(multiply(a, "x"), b))
74
115
  .simplify()
@@ -91,4 +132,5 @@ export const lnDerivativeOne = {
91
132
  isAnswerValid,
92
133
  subject: "Mathématiques",
93
134
  getQuestionFromIdentifiers,
135
+ hasHintAndCorrection: true,
94
136
  };
@@ -1 +1 @@
1
- {"version":3,"file":"lnDerivativeThree.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/derivation/derivative/ln/lnDerivativeThree.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAoHF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAYnD,CAAC"}
1
+ {"version":3,"file":"lnDerivativeThree.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/derivation/derivative/ln/lnDerivativeThree.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAkBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqKF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAanD,CAAC"}
@@ -5,12 +5,13 @@ import { Polynomial } from "../../../../../math/polynomials/polynomial.js";
5
5
  import { randint } from "../../../../../math/utils/random/randint.js";
6
6
  import { LogNode } from "../../../../../tree/nodes/functions/logNode.js";
7
7
  import { NumberNode } from "../../../../../tree/nodes/numbers/numberNode.js";
8
- import { AddNode } from "../../../../../tree/nodes/operators/addNode.js";
9
- import { FractionNode } from "../../../../../tree/nodes/operators/fractionNode.js";
10
- import { MultiplyNode } from "../../../../../tree/nodes/operators/multiplyNode.js";
8
+ import { add, AddNode } from "../../../../../tree/nodes/operators/addNode.js";
9
+ import { frac, FractionNode } from "../../../../../tree/nodes/operators/fractionNode.js";
10
+ import { multiply, MultiplyNode, } from "../../../../../tree/nodes/operators/multiplyNode.js";
11
11
  import { VariableNode } from "../../../../../tree/nodes/variables/variableNode.js";
12
12
  import { parseAlgebraic } from "../../../../../tree/parsers/latexParser.js";
13
13
  import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
14
+ import { alignTex } from "../../../../../utils/latex/alignTex.js";
14
15
  const getInstruction = (identifiers) => {
15
16
  const { a, b } = identifiers;
16
17
  const affine = new Polynomial([b, a]).toTree();
@@ -42,6 +43,53 @@ const getLnDerivative = () => {
42
43
  const identifiers = { a, b };
43
44
  return getQuestionFromIdentifiers(identifiers);
44
45
  };
46
+ const getHint = () => {
47
+ return `Pour tout $x>0$, on a :
48
+
49
+ $$
50
+ \\ln(x)' = \\frac{1}{x}
51
+ $$
52
+
53
+ D'autre part, la dérivée d'un produit de fonctions s'obtient par la formule :
54
+
55
+ $$
56
+ (uv)' = u'v + uv'
57
+ $$`;
58
+ };
59
+ const getCorrection = (identifiers) => {
60
+ const { a, b } = identifiers;
61
+ const u = new Affine(a, b).toTree();
62
+ const v = new LogNode(new VariableNode("x"));
63
+ const uPrime = a.toTree();
64
+ const vPrime = frac(1, "x");
65
+ return `On note :
66
+
67
+ $$
68
+ u(x) = ${u.toTex()}
69
+ $$
70
+
71
+ $$
72
+ v(x) = \\ln(x)
73
+ $$
74
+
75
+ On a alors :
76
+
77
+ $$
78
+ u'(x) = ${a.frenchify()}
79
+ $$
80
+
81
+ $$
82
+ v'(x) = \\frac{1}{x}
83
+ $$
84
+
85
+ Alors :
86
+
87
+ ${alignTex([
88
+ ["f'(x)", "=", add(multiply(uPrime, v), multiply(u, vPrime)).toTex()],
89
+ ["", "=", getAnswer(identifiers)],
90
+ ])}
91
+ `;
92
+ };
45
93
  const getQuestionFromIdentifiers = (identifiers) => {
46
94
  const question = {
47
95
  instruction: getInstruction(identifiers),
@@ -50,6 +98,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
50
98
  keys: getKeys(identifiers),
51
99
  answerFormat: "tex",
52
100
  identifiers,
101
+ hint: getHint(identifiers),
102
+ correction: getCorrection(identifiers),
53
103
  };
54
104
  return question;
55
105
  };
@@ -99,4 +149,5 @@ export const lnDerivativeThree = {
99
149
  isAnswerValid,
100
150
  subject: "Mathématiques",
101
151
  getQuestionFromIdentifiers,
152
+ hasHintAndCorrection: true,
102
153
  };
@@ -1 +1 @@
1
- {"version":3,"file":"lnDerivativeTwo.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/derivation/derivative/ln/lnDerivativeTwo.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqFF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAYjD,CAAC"}
1
+ {"version":3,"file":"lnDerivativeTwo.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/derivation/derivative/ln/lnDerivativeTwo.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA4GF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAajD,CAAC"}
@@ -32,6 +32,26 @@ const getLnDerivative = () => {
32
32
  const identifiers = { a, b };
33
33
  return getQuestionFromIdentifiers(identifiers);
34
34
  };
35
+ const getHint = () => {
36
+ return `Pour tout $x>0$, on a :
37
+
38
+ $$
39
+ \\ln(x)' = \\frac{1}{x}
40
+ $$`;
41
+ };
42
+ const getCorrection = (identifiers) => {
43
+ return `Pour tout $x>0$, on a :
44
+
45
+ $$
46
+ \\ln(x)' = \\frac{1}{x}
47
+ $$
48
+
49
+ Ici, on a donc :
50
+
51
+ $$
52
+ f'(x) = ${getAnswer(identifiers)}
53
+ $$`;
54
+ };
35
55
  const getQuestionFromIdentifiers = (identifiers) => {
36
56
  const question = {
37
57
  instruction: getInstruction(identifiers),
@@ -40,6 +60,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
40
60
  keys: ["x", "lnBrackets", "epower"],
41
61
  answerFormat: "tex",
42
62
  identifiers,
63
+ hint: getHint(identifiers),
64
+ correction: getCorrection(identifiers),
43
65
  };
44
66
  return question;
45
67
  };
@@ -78,4 +100,5 @@ export const lnDerivativeTwo = {
78
100
  freeTimer: 60,
79
101
  subject: "Mathématiques",
80
102
  getQuestionFromIdentifiers,
103
+ hasHintAndCorrection: true,
81
104
  };
@@ -1 +1 @@
1
- {"version":3,"file":"secondDerivativeOfThirdDegreeFunction.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/derivation/derivative/polynomial/secondDerivativeOfThirdDegreeFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,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;AA0FF,eAAO,MAAM,qCAAqC,EAAE,QAAQ,CAAC,WAAW,CAcvE,CAAC"}
1
+ {"version":3,"file":"secondDerivativeOfThirdDegreeFunction.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/derivation/derivative/polynomial/secondDerivativeOfThirdDegreeFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAcrC,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;AAyHF,eAAO,MAAM,qCAAqC,EAAE,QAAQ,CAAC,WAAW,CAevE,CAAC"}
@@ -1,8 +1,12 @@
1
1
  import { addValidProp, propWhile, 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 { add } from "../../../../../tree/nodes/operators/addNode.js";
5
+ import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
6
+ import { square } from "../../../../../tree/nodes/operators/powerNode.js";
4
7
  import { parseAlgebraic } from "../../../../../tree/parsers/latexParser.js";
5
8
  import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
9
+ import { alignTex } from "../../../../../utils/latex/alignTex.js";
6
10
  const getInstruction = (identifiers) => {
7
11
  const { a, b, c, d } = identifiers;
8
12
  const funct = new Polynomial([d, c, b, a]);
@@ -30,6 +34,29 @@ const getSecondDerivativeOfThirdDegreeFunction = () => {
30
34
  const identifiers = { ...coeff };
31
35
  return getQuestionFromIdentifiers(identifiers);
32
36
  };
37
+ const getHint = () => {
38
+ return `Commence par calculer $f'(x)$.
39
+
40
+ Puis, calcule la dérivée de $f'(x)$ : tu obtiendras alors la dérivée seconde $f''$ de $f$.`;
41
+ };
42
+ const getCorrection = (identifiers) => {
43
+ const { a, b, c } = identifiers;
44
+ const rawDeriv = add(add(multiply(3, multiply(a, square("x"))), multiply(2, multiply(b, "x"))), c);
45
+ const rawSecond = add(multiply(2, multiply(3 * a, "x")), 2 * b);
46
+ return `On commence par calculer $f'(x)$ :
47
+
48
+ ${alignTex([
49
+ ["f'(x)", "=", rawDeriv.toTex()],
50
+ ["", "=", rawDeriv.simplify().toTex()],
51
+ ])}
52
+
53
+ On dérive de nouveau pour obtenir $f''$ :
54
+
55
+ ${alignTex([
56
+ ["f''(x)", "=", rawSecond.toTex()],
57
+ ["", "=", rawSecond.simplify().toTex()],
58
+ ])}`;
59
+ };
33
60
  const getQuestionFromIdentifiers = (identifiers) => {
34
61
  const question = {
35
62
  answer: getAnswer(identifiers),
@@ -37,6 +64,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
37
64
  keys: ["x"],
38
65
  answerFormat: "tex",
39
66
  identifiers,
67
+ hint: getHint(identifiers),
68
+ correction: getCorrection(identifiers),
40
69
  };
41
70
  return question;
42
71
  };
@@ -81,4 +110,5 @@ export const secondDerivativeOfThridDegreeFunction = {
81
110
  getInstruction,
82
111
  getAnswer,
83
112
  getQuestionFromIdentifiers,
113
+ hasHintAndCorrection: true,
84
114
  };
@@ -1 +1 @@
1
- {"version":3,"file":"secondDerivativeOfTrinom.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/derivation/derivative/polynomial/secondDerivativeOfTrinom.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA4EF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAc1D,CAAC"}
1
+ {"version":3,"file":"secondDerivativeOfTrinom.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/derivation/derivative/polynomial/secondDerivativeOfTrinom.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAkGF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAe1D,CAAC"}
@@ -4,6 +4,8 @@ import { Polynomial } from "../../../../../math/polynomials/polynomial.js";
4
4
  import { Trinom, TrinomConstructor } from "../../../../../math/polynomials/trinom.js";
5
5
  import { randint } from "../../../../../math/utils/random/randint.js";
6
6
  import { NumberNode } from "../../../../../tree/nodes/numbers/numberNode.js";
7
+ import { add } from "../../../../../tree/nodes/operators/addNode.js";
8
+ import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
7
9
  const getInstruction = (identifiers) => {
8
10
  const { a, b, c } = identifiers;
9
11
  const trinom = new Trinom(a, b, c);
@@ -25,6 +27,25 @@ const getSecondDerivativeOfTrinomQuestion = () => {
25
27
  const identifiers = { a: trinom.a, b: trinom.b, c: trinom.c };
26
28
  return getQuestionFromIdentifiers(identifiers);
27
29
  };
30
+ const getHint = () => {
31
+ return `Commence par calculer $f'(x)$.
32
+
33
+ Puis, calcule la dérivée de $f'(x)$ : tu obtiendras alors la dérivée seconde $f''$ de $f$.`;
34
+ };
35
+ const getCorrection = (identifiers) => {
36
+ const { a, b } = identifiers;
37
+ return `On commence par calculer $f'(x)$ :
38
+
39
+ $$
40
+ f'(x) = ${add(multiply(2, multiply(a, "x")), b).toSimplificationTex()}
41
+ $$
42
+
43
+ On dérive de nouveau pour obtenir $f''$ :
44
+
45
+ $$
46
+ f''(x) = ${getAnswer(identifiers)}
47
+ $$`;
48
+ };
28
49
  const getQuestionFromIdentifiers = (identifiers) => {
29
50
  const question = {
30
51
  answer: getAnswer(identifiers),
@@ -32,6 +53,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
32
53
  keys: ["x"],
33
54
  answerFormat: "tex",
34
55
  identifiers,
56
+ hint: getHint(identifiers),
57
+ correction: getCorrection(identifiers),
35
58
  };
36
59
  return question;
37
60
  };
@@ -57,7 +80,7 @@ const generateProposition = (a, b, c) => {
57
80
  };
58
81
  export const secondDerivativeOfTrinom = {
59
82
  id: "secondDerivativeOfTrinom",
60
- label: "Dérivée seconde d'un trinôme",
83
+ label: "Dérivée seconde d'un polynôme du second degré",
61
84
  isSingleStep: true,
62
85
  generator: (nb) => getDistinctQuestions(getSecondDerivativeOfTrinomQuestion, nb),
63
86
  qcmTimer: 60,
@@ -68,4 +91,5 @@ export const secondDerivativeOfTrinom = {
68
91
  getInstruction,
69
92
  getAnswer,
70
93
  getQuestionFromIdentifiers,
94
+ hasHintAndCorrection: true,
71
95
  };
@@ -1 +1 @@
1
- {"version":3,"file":"cosCompositionDerivation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/derivation/derivative/trigo/cosCompositionDerivation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAwFF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAe1D,CAAC"}
1
+ {"version":3,"file":"cosCompositionDerivation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/derivation/derivative/trigo/cosCompositionDerivation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAoHF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAgB1D,CAAC"}
@@ -23,6 +23,30 @@ const getAnswer = (identifiers) => {
23
23
  const deriv = new MultiplyNode((-affine.a).toTree(), new SinNode(affine.toTree()));
24
24
  return deriv.toTex();
25
25
  };
26
+ const getHint = () => {
27
+ return `Pour toute fonction dérivable $u$, on a :
28
+
29
+ $$
30
+ \\cos(u)' = -u'\\times \\sin(u)
31
+ $$`;
32
+ };
33
+ const getCorrection = (identifiers) => {
34
+ const { affineA, affineB } = identifiers;
35
+ const aff = new Affine(affineA, affineB).toTree();
36
+ return `Pour toute fonction dérivable $u$, on a :
37
+
38
+ $$
39
+ \\cos(u)' = -u'\\times \\sin(u)
40
+ $$
41
+
42
+ Ici, on a $u(x) = ${aff.toTex()}$, donc $u'(x) = ${affineA.frenchify()}$.
43
+
44
+ Ainsi :
45
+
46
+ $$
47
+ f'(x) = ${getAnswer(identifiers)}
48
+ $$`;
49
+ };
26
50
  const getCosCompositionDerivationQuestion = () => {
27
51
  const affine = AffineConstructor.random(undefined, { excludes: [0] });
28
52
  const identifiers = { affineA: affine.a, affineB: affine.b };
@@ -35,6 +59,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
35
59
  keys: ["x", "sin", "cos", "tan"],
36
60
  answerFormat: "tex",
37
61
  identifiers,
62
+ hint: getHint(identifiers),
63
+ correction: getCorrection(identifiers),
38
64
  };
39
65
  return question;
40
66
  };
@@ -82,4 +108,5 @@ export const cosCompositionDerivation = {
82
108
  getAnswer,
83
109
  getInstruction,
84
110
  getQuestionFromIdentifiers,
111
+ hasHintAndCorrection: true,
85
112
  };
@@ -1 +1 @@
1
- {"version":3,"file":"cosSecondDegreeDerivative.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/derivation/derivative/trigo/cosSecondDegreeDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAqIF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAc3D,CAAC"}
1
+ {"version":3,"file":"cosSecondDegreeDerivative.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/derivation/derivative/trigo/cosSecondDegreeDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAiBrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAmLF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAe3D,CAAC"}
@@ -1,11 +1,11 @@
1
1
  import { addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { AffineConstructor } from "../../../../../math/polynomials/affine.js";
4
- import { CosNode } from "../../../../../tree/nodes/functions/cosNode.js";
5
- import { SinNode } from "../../../../../tree/nodes/functions/sinNode.js";
4
+ import { cos, CosNode } from "../../../../../tree/nodes/functions/cosNode.js";
5
+ import { sin, SinNode } from "../../../../../tree/nodes/functions/sinNode.js";
6
6
  import { NumberNode } from "../../../../../tree/nodes/numbers/numberNode.js";
7
7
  import { AddNode } from "../../../../../tree/nodes/operators/addNode.js";
8
- import { MultiplyNode } from "../../../../../tree/nodes/operators/multiplyNode.js";
8
+ import { multiply, 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
11
  import { parseAlgebraic } from "../../../../../tree/parsers/latexParser.js";
@@ -28,6 +28,47 @@ const getAnswer = (identifiers) => {
28
28
  .toTex();
29
29
  return ans;
30
30
  };
31
+ const getHint = () => {
32
+ return `Pour toute fonction dérivable $u$, on a :
33
+
34
+ $$
35
+ \\left(\\cos(u)\\right)' = -u'\\times \\sin(u)
36
+ $$
37
+
38
+ et
39
+
40
+ $$
41
+ \\left(\\sin(u)\\right)' = u'\\times \\cos(u)
42
+ $$`;
43
+ };
44
+ const getCorrection = (identifiers) => {
45
+ const { affinecoeffs } = identifiers;
46
+ const affTree = AffineConstructor.fromCoeffs(affinecoeffs).toTree();
47
+ const a = affinecoeffs[1];
48
+ return `On utilise la propriété suivante : pour toute fonction dérivable $u$,
49
+
50
+ $$
51
+ \\left(\\cos(u)\\right)' = -u'\\times \\sin(u)
52
+ $$
53
+
54
+ et
55
+
56
+ $$
57
+ \\left(\\sin(u)\\right)' = u'\\times \\cos(u)
58
+ $$
59
+
60
+ Ici, on dérive la fonction $f$ deux fois. On a, pour tout $x\\in \\mathbb{R}$ :
61
+
62
+ $$
63
+ f'(x) = ${multiply(-a, sin(affTree)).toTex()}
64
+ $$
65
+
66
+ Donc
67
+
68
+ $$
69
+ f''(x)= ${multiply(multiply(-a, a).simplify(), cos(affTree)).toTex()}
70
+ $$`;
71
+ };
31
72
  const getCosSecondDegreeDerivativeQuestion = () => {
32
73
  const affine = AffineConstructor.random();
33
74
  const affinecoeffs = affine.coefficients;
@@ -41,6 +82,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
41
82
  keys: ["x", "sin", "cos", "tan"],
42
83
  answerFormat: "tex",
43
84
  identifiers,
85
+ hint: getHint(identifiers),
86
+ correction: getCorrection(identifiers),
44
87
  };
45
88
  return question;
46
89
  };
@@ -104,4 +147,5 @@ export const cosSecondDegreeDerivative = {
104
147
  getAnswer,
105
148
  getInstruction,
106
149
  getQuestionFromIdentifiers,
150
+ hasHintAndCorrection: true,
107
151
  };
@@ -1 +1 @@
1
- {"version":3,"file":"sinCompositionDerivation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/derivation/derivative/trigo/sinCompositionDerivation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAwFF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAe1D,CAAC"}
1
+ {"version":3,"file":"sinCompositionDerivation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/derivation/derivative/trigo/sinCompositionDerivation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAyHF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAgB1D,CAAC"}
@@ -5,6 +5,8 @@ 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
+ import { parseAlgebraic } from "../../../../../tree/parsers/latexParser.js";
9
+ import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
8
10
  const getInstruction = (identifiers) => {
9
11
  const { affineA, affineB } = identifiers;
10
12
  const affine = new Affine(affineA, affineB);
@@ -26,6 +28,30 @@ const getSinCompositionDerivationQuestion = () => {
26
28
  const identifiers = { affineA: affine.a, affineB: affine.b };
27
29
  return getQuestionFromIdentifiers(identifiers);
28
30
  };
31
+ const getHint = () => {
32
+ return `Pour toute fonction dérivable $u$, on a :
33
+
34
+ $$
35
+ \\sin(u)' = u'\\times \\cos(u)
36
+ $$`;
37
+ };
38
+ const getCorrection = (identifiers) => {
39
+ const { affineA, affineB } = identifiers;
40
+ const aff = new Affine(affineA, affineB).toTree();
41
+ return `Pour toute fonction dérivable $u$, on a :
42
+
43
+ $$
44
+ \\sin(u)' = u'\\times \\cos(u)
45
+ $$
46
+
47
+ Ici, on a $u(x) = ${aff.toTex()}$, donc $u'(x) = ${affineA.frenchify()}$.
48
+
49
+ Ainsi :
50
+
51
+ $$
52
+ f'(x) = ${getAnswer(identifiers)}
53
+ $$`;
54
+ };
29
55
  const getQuestionFromIdentifiers = (identifiers) => {
30
56
  const question = {
31
57
  answer: getAnswer(identifiers),
@@ -33,6 +59,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
33
59
  keys: ["x", "sin", "cos", "tan"],
34
60
  answerFormat: "tex",
35
61
  identifiers,
62
+ hint: getHint(identifiers),
63
+ correction: getCorrection(identifiers),
36
64
  };
37
65
  return question;
38
66
  };
@@ -51,11 +79,21 @@ const getPropositions = (n, { answer, affineA, affineB }) => {
51
79
  tryToAddWrongProp(propositions, new CosNode(affineA.toTree()).simplify().toTex());
52
80
  return shuffleProps(propositions, n);
53
81
  };
54
- const isAnswerValid = (ans, { affineA, affineB }) => {
55
- const affine = new Affine(affineA, affineB);
56
- const deriv = new MultiplyNode(affineA.toTree(), new CosNode(affine.toTree()));
57
- const texs = deriv.toAllValidTexs();
58
- return texs.includes(ans);
82
+ const isAnswerValid = (ans, { answer }) => {
83
+ try {
84
+ const parsed = parseAlgebraic(ans);
85
+ if (!parsed)
86
+ return false;
87
+ return (parsed
88
+ .simplify({
89
+ towardsDistribute: true,
90
+ forbidFactorize: true,
91
+ })
92
+ .toTex() === answer);
93
+ }
94
+ catch (err) {
95
+ return handleVEAError(err);
96
+ }
59
97
  };
60
98
  export const sinCompositionDerivation = {
61
99
  id: "sinCompositionDerivation",
@@ -71,4 +109,5 @@ export const sinCompositionDerivation = {
71
109
  getInstruction,
72
110
  getAnswer,
73
111
  getQuestionFromIdentifiers,
112
+ hasHintAndCorrection: true,
74
113
  };
@@ -1 +1 @@
1
- {"version":3,"file":"sinSecondDegreeDerivative.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/derivation/derivative/trigo/sinSecondDegreeDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAwIF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAc3D,CAAC"}
1
+ {"version":3,"file":"sinSecondDegreeDerivative.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/derivation/derivative/trigo/sinSecondDegreeDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAgBrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAkLF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAe3D,CAAC"}