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 +1 @@
1
- {"version":3,"file":"expOfTrinomEquals1Equation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/calculLitteral/equation/exp/expOfTrinomEquals1Equation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAoBT,MAAM,6BAA6B,CAAC;AAmCrC;;GAEG;AACH,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA0YF,KAAK,OAAO,GAAG;IACb,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAgBF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAoBrE,CAAC"}
1
+ {"version":3,"file":"expOfTrinomEquals1Equation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/calculLitteral/equation/exp/expOfTrinomEquals1Equation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAoBT,MAAM,6BAA6B,CAAC;AAmCrC;;GAEG;AACH,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA0YF,KAAK,OAAO,GAAG;IACb,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAgBF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAuBrE,CAAC"}
@@ -368,4 +368,7 @@ export const expOfTrinomEquals1Equation = {
368
368
  getStartStatement,
369
369
  getQuestionFromIdentifiers,
370
370
  options,
371
+ pdfOptions: {
372
+ shouldSpreadPropositions: true,
373
+ },
371
374
  };
@@ -1 +1 @@
1
- {"version":3,"file":"firstDegreeInequationsType3.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/inequations/firstDegreeInequationsType3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EACL,gBAAgB,EAGjB,MAAM,sCAAsC,CAAC;AAY9C,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA4LF,KAAK,OAAO,GAAG;IACb,wBAAwB,EAAE,MAAM,CAAC;CAClC,CAAC;AAGF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CActE,CAAC"}
1
+ {"version":3,"file":"firstDegreeInequationsType3.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/inequations/firstDegreeInequationsType3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EACL,gBAAgB,EAGjB,MAAM,sCAAsC,CAAC;AAe9C,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAkOF,KAAK,OAAO,GAAG;IACb,wBAAwB,EAAE,MAAM,CAAC;CAClC,CAAC;AAGF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAetE,CAAC"}
@@ -7,6 +7,9 @@ import { Affine } from "../../../../math/polynomials/affine.js";
7
7
  import { randint } from "../../../../math/utils/random/randint.js";
8
8
  import { InequationNode } from "../../../../tree/nodes/inequations/inequationNode.js";
9
9
  import { InequationSolutionNode } from "../../../../tree/nodes/inequations/inequationSolutionNode.js";
10
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
11
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
12
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
10
13
  import { inequationParser } from "../../../../tree/parsers/inequationParser.js";
11
14
  import { intervalParser } from "../../../../tree/parsers/intervalParser.js";
12
15
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
@@ -41,37 +44,59 @@ const getAnswerNode = (identifiers, opts) => {
41
44
  const getAnswer = (identifiers, opts) => {
42
45
  return getAnswerNode(identifiers, opts).toTex();
43
46
  };
44
- // const getHint: GetHint<Identifiers, Options> = (identifiers, opts) => {
45
- // return `Isole le terme $x$ dans le membre de gauche de l'inéquation. Attention : lorsqu'on multiplie (ou divise) les deux membres d'une inéquation par un nombre négatif, le sens de l'inéquation est inversé.`;
46
- // };
47
- // const getCorrection: GetHint<Identifiers, Options> = (identifiers, opts) => {
48
- // const { a, b, c, d,ineqType } = identifiers;
49
- // const isInterval =
50
- // opts?.inequationSolutionFormat === "Intervalle (S = [a;b])";
51
- // const answer = getAnswer(identifiers, opts);
52
- // return `On isole $x$ dans le membre de gauche de l'inéquation :
53
- // $$
54
- // ${firstDegreeInequationResolutionTex(new Affine(a, b), ineqType, new Affine(c,d))}
55
- // $$
56
- // ${
57
- // identifiers.a < 0
58
- // ? `On a changé le sens de l'inéquation, car $${a}$ est négatif.`
59
- // : ""
60
- // }
61
- // ${
62
- // isInterval
63
- // ? `On traduit ensuite cette inéquation en intervalle :
64
- // $$
65
- // ${answer}
66
- // $$
67
- // `
68
- // : ""
69
- // }
70
- // `;
71
- // };
47
+ const getHint = () => {
48
+ return `Commence par regrouper les termes en $x$ d'un même côté de l'inéquation. Puis isole $x$ en effectuant les bonnes opérations.
49
+
50
+ Attention, lorsqu'on divise ou multiplie les deux membres d'une inéquation par un nombre négatif, l'inéquation change de sens. `;
51
+ };
52
+ const getCorrection = (identifiers, opts) => {
53
+ const { a, b, c, d, ineqType } = identifiers;
54
+ const affine1 = new Affine(a, b);
55
+ const affine2 = new Affine(c, d);
56
+ const isInterval = opts?.inequationSolutionFormat === "Intervalle (S = [a;b])";
57
+ return `On doit résoudre l'inéquation :
58
+
59
+ $$
60
+ ${affine1.toTex()} ${ineqType} ${affine2.toTex()}
61
+ $$
62
+
63
+ On ${c < 0 ? "ajoute" : "enlève"} $${multiply(Math.abs(c), "x").toTex()}$ des deux côtés :
64
+
65
+ $$
66
+ ${add(multiply(substract(a, c).simplify(), "x"), b).toTex()} ${ineqType} ${d.frenchify()}
67
+ $$
68
+
69
+ On ${b < 0 ? "ajoute" : "enlève"} $${Math.abs(b).frenchify()}$ des deux côtés :
70
+
71
+ $$
72
+ ${multiply(substract(a, c).simplify(), "x").toTex()} ${ineqType} ${substract(d, b)
73
+ .simplify()
74
+ .toTex()}
75
+ $$
76
+
77
+ On divise ensuite par $${substract(a, c)
78
+ .simplify()
79
+ .toTex()}$. Puisque $${substract(a, c).simplify().toTex()}$ est ${a > c ? "positif" : "négatif"}, l'inéquation ${a > c ? "ne change pas" : "change"} de sens :
80
+
81
+ $$
82
+ ${getAnswer(identifiers, {
83
+ inequationSolutionFormat: "Inégalité (x>a)",
84
+ })}
85
+ $$
86
+
87
+ ${isInterval
88
+ ? `On traduit cette inégalité par un intervalle :
89
+
90
+ $$
91
+ ${getAnswer(identifiers, opts)}
92
+ $$`
93
+ : ""}
94
+ `;
95
+ };
72
96
  const getFirstDegreeInequationsQuestion = (opts) => {
73
- const affine1 = new Affine(randint(-10, 10, [0]), randint(-10, 10));
74
- const affine2 = new Affine(randint(-10, 10, [0, affine1.a]), randint(-10, 10));
97
+ // ax+b < cx+d
98
+ const affine1 = new Affine(randint(-10, 10, [0, 1]), randint(-10, 10, [0]));
99
+ const affine2 = new Affine(randint(-10, 10, [0, affine1.a, 1, affine1.a - 1]), randint(-10, 10, [0]));
75
100
  const coeff = affine1.a - affine2.a;
76
101
  const ineqType = InequationSymbolConstructor.random();
77
102
  const identifiers = {
@@ -91,6 +116,8 @@ const getQuestionFromIdentifiers = (identifiers, opts) => {
91
116
  keys: getKeys(identifiers, opts),
92
117
  answerFormat: "tex",
93
118
  identifiers,
119
+ hint: getHint(identifiers, opts),
120
+ correction: getCorrection(identifiers, opts),
94
121
  };
95
122
  return question;
96
123
  };
@@ -157,6 +184,7 @@ export const firstDegreeInequationsType3 = {
157
184
  subject: "Mathématiques",
158
185
  options,
159
186
  getQuestionFromIdentifiers,
187
+ hasHintAndCorrection: true,
160
188
  };
161
189
  // export const reuseFirstDegreeInequationsType3 = {
162
190
  // getAnswerNode,
@@ -1 +1 @@
1
- {"version":3,"file":"addComplex.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/complex/addComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAKrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AA4EF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAY5C,CAAC"}
1
+ {"version":3,"file":"addComplex.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/complex/addComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAwHF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAa5C,CAAC"}
@@ -1,7 +1,11 @@
1
1
  import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Complex, ComplexConstructor } from "../../../math/complex/complex.js";
4
+ import { add } from "../../../tree/nodes/operators/addNode.js";
5
+ import { multiply } from "../../../tree/nodes/operators/multiplyNode.js";
6
+ import { parseAlgebraic } from "../../../tree/parsers/latexParser.js";
4
7
  import { shuffle } from "../../../utils/alea/shuffle.js";
8
+ import { alignTex } from "../../../utils/latex/alignTex.js";
5
9
  const getInstruction = (identifiers) => {
6
10
  const z1 = new Complex(identifiers.z1Re, identifiers.z1Im);
7
11
  const z2 = new Complex(identifiers.z2Re, identifiers.z2Im);
@@ -15,14 +19,47 @@ const getAnswer = (identifiers) => {
15
19
  const answer = z1.add(z2).toTree().toTex();
16
20
  return answer;
17
21
  };
22
+ const getHint = () => {
23
+ return `Soient deux nombres complexes $z = a+ib$ et $z' = a'+ib'$. Alors :
24
+
25
+ $$
26
+ z+z' = (a+a') + i(b+b')
27
+ $$`;
28
+ };
29
+ const getCorrection = (identifiers) => {
30
+ const { z1Re, z1Im, z2Re, z2Im } = identifiers;
31
+ const z1 = add(z1Re, multiply(z1Im, "i")).simplify({
32
+ forbidFactorize: true,
33
+ noAddOrder: true,
34
+ });
35
+ const z2 = add(z2Re, multiply(z2Im, "i")).simplify({
36
+ forbidFactorize: true,
37
+ noAddOrder: true,
38
+ });
39
+ return `Soient deux nombres complexes $z = a+ib$ et $z' = a'+ib'$. Alors :
40
+
41
+ $$
42
+ z+z' = (a+a') + i(b+b')
43
+ $$
44
+
45
+ Ici, on a donc :
46
+
47
+ ${alignTex([
48
+ ["z+ z'", "=", add(z1, z2).toTex()],
49
+ ["", "=", add(add(z1Re, z2Re), multiply("i", add(z1Im, z2Im))).toTex()],
50
+ ["", "=", getAnswer(identifiers)],
51
+ ])}`;
52
+ };
18
53
  const getQuestionFromIdentifiers = (identifiers) => {
19
54
  const question = {
20
55
  answer: getAnswer(identifiers),
21
56
  instruction: getInstruction(identifiers),
22
- keys: ["i", "z", "quote"],
57
+ keys: ["i"],
23
58
  answerFormat: "tex",
24
59
  startStatement: "z+z'",
25
60
  identifiers,
61
+ hint: getHint(identifiers),
62
+ correction: getCorrection(identifiers),
26
63
  };
27
64
  return question;
28
65
  };
@@ -57,12 +94,20 @@ const getPropositions = (n, { answer, z1Re, z1Im, z2Re, z2Im }) => {
57
94
  });
58
95
  return shuffle(propositions);
59
96
  };
60
- const isAnswerValid = (ans, { z1Im, z1Re, z2Im, z2Re }) => {
61
- const z1 = new Complex(z1Re, z1Im);
62
- const z2 = new Complex(z2Re, z2Im);
63
- const answer = z1.add(z2).toTree();
64
- const texs = answer.toAllValidTexs();
65
- return texs.includes(ans);
97
+ const isAnswerValid = (ans, { answer }) => {
98
+ const parsed = parseAlgebraic(ans);
99
+ if (!parsed)
100
+ return false;
101
+ return (parsed
102
+ .simplify({
103
+ forbidFactorize: true,
104
+ })
105
+ .toTex() ===
106
+ parseAlgebraic(answer)
107
+ .simplify({
108
+ forbidFactorize: true,
109
+ })
110
+ .toTex());
66
111
  };
67
112
  export const addComplex = {
68
113
  id: "addComplex",
@@ -76,4 +121,5 @@ export const addComplex = {
76
121
  isAnswerValid,
77
122
  subject: "Mathématiques",
78
123
  getQuestionFromIdentifiers,
124
+ hasHintAndCorrection: true,
79
125
  };
@@ -1 +1 @@
1
- {"version":3,"file":"conjugateComplex.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/complex/conjugateComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAKrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA4DF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAalD,CAAC"}
1
+ {"version":3,"file":"conjugateComplex.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/complex/conjugateComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAqGF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAclD,CAAC"}
@@ -1,11 +1,16 @@
1
1
  import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Complex, ComplexConstructor } from "../../../math/complex/complex.js";
4
+ import { parseAlgebraic } from "../../../tree/parsers/latexParser.js";
4
5
  import { shuffle } from "../../../utils/alea/shuffle.js";
5
6
  const getInstruction = (identifiers) => {
6
7
  const { re, im } = identifiers;
7
8
  const complex = new Complex(re, im);
8
- return `Déterminer le conjugué de $z=${complex.toTree().toTex()}$.`;
9
+ return `Déterminer le conjugué $\\overline{z}$ de :
10
+
11
+ $$
12
+ z=${complex.toTree().toTex()}
13
+ $$`;
9
14
  };
10
15
  const getAnswer = (identifiers) => {
11
16
  const { re, im } = identifiers;
@@ -13,14 +18,40 @@ const getAnswer = (identifiers) => {
13
18
  const answer = complex.conjugate().toTree().toTex();
14
19
  return answer;
15
20
  };
21
+ const getHint = () => {
22
+ return `Soit $z = a+ib$ un nombre complexe.
23
+
24
+ Le conjugué $\\overline{z}$ de $z$ est le nombre :
25
+
26
+ $$
27
+ \\overline{z} = a-ib
28
+ $$`;
29
+ };
30
+ const getCorrection = (identifiers) => {
31
+ return `Soit $z = a+ib$ un nombre complexe.
32
+
33
+ Le conjugué $\\overline{z}$ de $z$ est le nombre :
34
+
35
+ $$
36
+ \\overline{z} = a-ib
37
+ $$
38
+
39
+ Ici, on a donc :
40
+
41
+ $$
42
+ \\overline{z} = ${getAnswer(identifiers)}
43
+ $$`;
44
+ };
16
45
  const getQuestionFromIdentifiers = (identifiers) => {
17
46
  const question = {
18
47
  answer: getAnswer(identifiers),
19
48
  instruction: getInstruction(identifiers),
20
- keys: ["i", "overline"],
49
+ keys: ["i"],
21
50
  answerFormat: "tex",
22
51
  startStatement: "\\overline z",
23
52
  identifiers,
53
+ hint: getHint(identifiers),
54
+ correction: getCorrection(identifiers),
24
55
  };
25
56
  return question;
26
57
  };
@@ -43,11 +74,20 @@ const getPropositions = (n, { answer, re, im }) => {
43
74
  });
44
75
  return shuffle(propositions);
45
76
  };
46
- const isAnswerValid = (ans, { im, re }) => {
47
- const complex = new Complex(re, im);
48
- const answer = complex.conjugate().toTree();
49
- const texs = answer.toAllValidTexs();
50
- return texs.includes(ans);
77
+ const isAnswerValid = (ans, { answer }) => {
78
+ const parsed = parseAlgebraic(ans);
79
+ if (!parsed)
80
+ return false;
81
+ return (parsed
82
+ .simplify({
83
+ forbidFactorize: true,
84
+ })
85
+ .toTex() ===
86
+ parseAlgebraic(answer)
87
+ .simplify({
88
+ forbidFactorize: true,
89
+ })
90
+ .toTex());
51
91
  };
52
92
  export const conjugateComplex = {
53
93
  id: "conjugateComplex",
@@ -61,4 +101,5 @@ export const conjugateComplex = {
61
101
  isAnswerValid,
62
102
  subject: "Mathématiques",
63
103
  getQuestionFromIdentifiers,
104
+ hasHintAndCorrection: true,
64
105
  };
@@ -1 +1 @@
1
- {"version":3,"file":"mutiplyComplex.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/complex/mutiplyComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAKrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,EAAE,CAAC;IACb,EAAE,EAAE,MAAM,EAAE,CAAC;CACd,CAAC;AAmEF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAahD,CAAC"}
1
+ {"version":3,"file":"mutiplyComplex.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/complex/mutiplyComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,EAAE,CAAC;IACb,EAAE,EAAE,MAAM,EAAE,CAAC;CACd,CAAC;AA2GF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAchD,CAAC"}
@@ -1,7 +1,12 @@
1
1
  import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Complex, ComplexConstructor } from "../../../math/complex/complex.js";
4
+ import { randTupleInt } from "../../../math/utils/random/randTupleInt.js";
5
+ import { add } from "../../../tree/nodes/operators/addNode.js";
6
+ import { multiply } from "../../../tree/nodes/operators/multiplyNode.js";
7
+ import { parseAlgebraic } from "../../../tree/parsers/latexParser.js";
4
8
  import { shuffle } from "../../../utils/alea/shuffle.js";
9
+ import { alignTex } from "../../../utils/latex/alignTex.js";
5
10
  const getInstruction = (identifiers) => {
6
11
  const z1 = new Complex(identifiers.z1[0], identifiers.z1[1]);
7
12
  const z2 = new Complex(identifiers.z2[0], identifiers.z2[1]);
@@ -15,29 +20,48 @@ const getAnswer = (identifiers) => {
15
20
  const answer = z1.multiply(z2).toTree().toTex();
16
21
  return answer;
17
22
  };
23
+ const getHint = () => {
24
+ return `Pour multiplier deux nombres complexes, on utilise la distributivité double, ainsi que le fait que $i^2 = -1$.`;
25
+ };
26
+ const getCorrection = (identifiers) => {
27
+ const { z1, z2 } = identifiers;
28
+ const [a, b] = z1;
29
+ const [c, d] = z2;
30
+ const zA = add(a, multiply(b, "i"));
31
+ const zB = add(c, multiply(d, "i"));
32
+ return `On distribue comme pour des nombres réels, puis on utilise le fait que $i^2=-1$ :
33
+
34
+ ${alignTex([
35
+ ["z\\times z'", "=", multiply(zA, zB).toTex()],
36
+ [
37
+ "",
38
+ "=",
39
+ add(add(multiply(a, c), multiply(a, multiply(d, "i"))), add(multiply(multiply(b, "i"), c), multiply(multiply(b, "i"), multiply(d, "i")))).toTex(),
40
+ ],
41
+ [
42
+ "",
43
+ "=",
44
+ add(add(multiply(a, c).simplify(), multiply(a * d + b * c, "i")), multiply(multiply(b, d).simplify(), -1)).toTex(),
45
+ ],
46
+ ["", "=", getAnswer(identifiers)],
47
+ ])}`;
48
+ };
18
49
  const getQuestionFromIdentifiers = (identifiers) => {
19
50
  const question = {
20
51
  answer: getAnswer(identifiers),
21
52
  instruction: getInstruction(identifiers),
22
- keys: ["i", "z", "quote"],
53
+ keys: ["i"],
23
54
  answerFormat: "tex",
24
55
  startStatement: "z\\times z'",
25
56
  identifiers,
57
+ hint: getHint(identifiers),
58
+ correction: getCorrection(identifiers),
26
59
  };
27
60
  return question;
28
61
  };
29
62
  const getMutiplyComplexQuestion = () => {
30
- const z1 = ComplexConstructor.random();
31
- let z2;
32
- let counter = 0;
33
- do {
34
- counter++;
35
- if (counter > 1000) {
36
- throw new Error("multiply complex too many iterations");
37
- }
38
- z2 = ComplexConstructor.random();
39
- } while (z1.im === 0 && z2.im === 0);
40
- const identifiers = { z1: [z1.re, z1.im], z2: [z2.re, z2.im] };
63
+ const [a, b, c, d] = randTupleInt(4, { from: -9, to: 10, elExcludes: [0] });
64
+ const identifiers = { z1: [a, b], z2: [c, d] };
41
65
  return getQuestionFromIdentifiers(identifiers);
42
66
  };
43
67
  const getPropositions = (n, { answer, z1, z2 }) => {
@@ -51,12 +75,20 @@ const getPropositions = (n, { answer, z1, z2 }) => {
51
75
  });
52
76
  return shuffle(propositions);
53
77
  };
54
- const isAnswerValid = (ans, { z1, z2 }) => {
55
- const complex1 = new Complex(z1[0], z1[1]);
56
- const complex2 = new Complex(z2[0], z2[1]);
57
- const answer = complex1.multiply(complex2).toTree();
58
- const texs = answer.toAllValidTexs();
59
- return texs.includes(ans);
78
+ const isAnswerValid = (ans, { answer }) => {
79
+ const parsed = parseAlgebraic(ans);
80
+ if (!parsed)
81
+ return false;
82
+ return (parsed
83
+ .simplify({
84
+ forbidFactorize: true,
85
+ })
86
+ .toTex() ===
87
+ parseAlgebraic(answer)
88
+ .simplify({
89
+ forbidFactorize: true,
90
+ })
91
+ .toTex());
60
92
  };
61
93
  export const mutiplyComplex = {
62
94
  id: "mutiplyComplex",
@@ -70,4 +102,5 @@ export const mutiplyComplex = {
70
102
  isAnswerValid,
71
103
  subject: "Mathématiques",
72
104
  getQuestionFromIdentifiers,
105
+ hasHintAndCorrection: true,
73
106
  };
@@ -1 +1 @@
1
- {"version":3,"file":"reAndIm.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/complex/reAndIm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AA6DF,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,WAAW,CAYzC,CAAC"}
1
+ {"version":3,"file":"reAndIm.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/complex/reAndIm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AA2FF,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,WAAW,CAazC,CAAC"}
@@ -1,13 +1,17 @@
1
1
  import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
+ import { numberVEA } from "../../../exercises/vea/numberVEA.js";
3
4
  import { Complex, ComplexConstructor } from "../../../math/complex/complex.js";
4
5
  import { randint } from "../../../math/utils/random/randint.js";
5
6
  import { coinFlip } from "../../../utils/alea/coinFlip.js";
6
7
  import { shuffle } from "../../../utils/alea/shuffle.js";
8
+ import { doWhile } from "../../../utils/doWhile.js";
7
9
  const getInstruction = (identifiers) => {
8
10
  const { re, im, isRe } = identifiers;
9
11
  const z1 = new Complex(re, im);
10
- return `Soit $z=${z1.toTree().toTex()}$. Quelle est la partie ${isRe ? "réelle" : "imaginaire"} de $z$ ?`;
12
+ return `Soit $z=${z1.toTree().toTex()}$.
13
+
14
+ Quelle est la partie ${isRe ? "réelle" : "imaginaire"} de $z$ ?`;
11
15
  };
12
16
  const getAnswer = (identifiers) => {
13
17
  const { re, im, isRe } = identifiers;
@@ -15,6 +19,30 @@ const getAnswer = (identifiers) => {
15
19
  const answer = (isRe ? z1.re : z1.im) + "";
16
20
  return answer;
17
21
  };
22
+ const getHint = () => {
23
+ return `Si $z$ est un nombre complexe tel que :
24
+
25
+ $$
26
+ z = a+ib
27
+ $$
28
+
29
+ alors $a$ est la partie réelle de $z$, et $b$ et sa partie imaginaire.`;
30
+ };
31
+ const getCorrection = (identifiers) => {
32
+ const { re, im } = identifiers;
33
+ const z1 = new Complex(re, im);
34
+ return `Si $z$ est un nombre complexe tel que :
35
+
36
+ $$
37
+ z = a+ib
38
+ $$
39
+
40
+ alors $a$ est la partie réelle de $z$, et $b$ et sa partie imaginaire.
41
+
42
+ Ici, on a $z = ${z1
43
+ .toTree()
44
+ .toTex()}$, donc la partie réelle de $z$ est $${re}$ et sa partie imaginaire est $${im}$. `;
45
+ };
18
46
  const getQuestionFromIdentifiers = (identifiers) => {
19
47
  const question = {
20
48
  answer: getAnswer(identifiers),
@@ -22,11 +50,13 @@ const getQuestionFromIdentifiers = (identifiers) => {
22
50
  keys: ["i", "z"],
23
51
  answerFormat: "tex",
24
52
  identifiers,
53
+ hint: getHint(identifiers),
54
+ correction: getCorrection(identifiers),
25
55
  };
26
56
  return question;
27
57
  };
28
58
  const getReAndImQuestion = () => {
29
- const z1 = ComplexConstructor.random();
59
+ const z1 = doWhile(() => ComplexConstructor.random(), (z) => z.re === z.im);
30
60
  const isRe = coinFlip();
31
61
  const identifiers = { re: z1.re, im: z1.im, isRe };
32
62
  return getQuestionFromIdentifiers(identifiers);
@@ -44,13 +74,13 @@ const getPropositions = (n, { answer, re, im, isRe }) => {
44
74
  return shuffle(propositions);
45
75
  };
46
76
  const isAnswerValid = (ans, { answer }) => {
47
- return ans === answer;
77
+ return numberVEA(ans, answer);
48
78
  };
49
79
  export const reAndIm = {
50
80
  id: "getReAndImQuestion",
51
81
  connector: "=",
52
82
  getPropositions,
53
- label: "Identifier partie réelle et partie imaginaire",
83
+ label: "Identifier partie réelle et partie imaginaire d'un nombre complexe",
54
84
  isSingleStep: true,
55
85
  generator: (nb) => getDistinctQuestions(getReAndImQuestion, nb),
56
86
  qcmTimer: 60,
@@ -58,4 +88,5 @@ export const reAndIm = {
58
88
  isAnswerValid,
59
89
  subject: "Mathématiques",
60
90
  getQuestionFromIdentifiers,
91
+ hasHintAndCorrection: true,
61
92
  };
@@ -1 +1 @@
1
- {"version":3,"file":"convexityQuadrinomials.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/convexity/convexityQuadrinomials.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAoBrC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAwIF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAcxD,CAAC"}
1
+ {"version":3,"file":"convexityQuadrinomials.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/convexity/convexityQuadrinomials.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAsBrC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAqLF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAexD,CAAC"}
@@ -1,7 +1,9 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { Affine } from "../../../../math/polynomials/affine.js";
3
4
  import { Polynomial, PolynomialConstructor, } from "../../../../math/polynomials/polynomial.js";
4
5
  import { randint } from "../../../../math/utils/random/randint.js";
6
+ import { firstDegreeInequationResolutionTex } from "../../../../tree/nodes/inequations/inequationNode.js";
5
7
  import { MinusInfinityNode, PlusInfinityNode, } from "../../../../tree/nodes/numbers/infiniteNode.js";
6
8
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
7
9
  import { FractionNode } from "../../../../tree/nodes/operators/fractionNode.js";
@@ -21,7 +23,7 @@ $$
21
23
  f(x) = ${quadrinomial.toTex()}
22
24
  $$
23
25
 
24
- Sur quelle intervalle $f$ est-elle ${questionType} ?`;
26
+ Sur quel intervalle $f$ est-elle ${questionType} ?`;
25
27
  };
26
28
  const getAnswer = (identifiers) => {
27
29
  const { askConvex, quadcoeffs } = identifiers;
@@ -45,6 +47,7 @@ const getAnswer = (identifiers) => {
45
47
  return interval;
46
48
  };
47
49
  const getConvexityQuadrinomialsQuestion = () => {
50
+ //b/3a nice
48
51
  const quadrinomial = PolynomialConstructor.randomWithOrder(3);
49
52
  const quadcoeffs = quadrinomial.coefficients;
50
53
  const askConvex = coinFlip();
@@ -58,6 +61,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
58
61
  keys: ["rbracket", "lbracket", "semicolon", "infty", "reals"],
59
62
  answerFormat: "tex",
60
63
  identifiers,
64
+ hint: getHint(identifiers),
65
+ correction: getCorrection(identifiers),
61
66
  };
62
67
  return question;
63
68
  };
@@ -71,16 +76,52 @@ const getPropositions = (n, { answer, quadcoeffs }) => {
71
76
  const wrongInterval1 = new IntervalNode(inflexionPoint, PlusInfinityNode, ClosureType.OO).toTex();
72
77
  const wrongInterval2 = new IntervalNode(MinusInfinityNode, inflexionPoint, ClosureType.OO).toTex();
73
78
  const wrongInterval3 = new IntervalNode(MinusInfinityNode, PlusInfinityNode, ClosureType.OO).toTex();
74
- const wrongInterval4 = new IntervalNode(new NumberNode(randint(-1, 2)), PlusInfinityNode, ClosureType.FO).toTex();
79
+ const wrongInterval4 = new IntervalNode(new NumberNode(randint(-10, 10)), PlusInfinityNode, ClosureType.OO).toTex();
75
80
  tryToAddWrongProp(propositions, wrongInterval1);
76
81
  tryToAddWrongProp(propositions, wrongInterval2);
77
82
  tryToAddWrongProp(propositions, wrongInterval3);
78
83
  tryToAddWrongProp(propositions, wrongInterval4);
79
84
  return shuffleProps(propositions, n);
80
85
  };
86
+ const getHint = () => `Soit $f$ une fonction deux fois dérivable et soit $f''$ sa dérivée seconde.
87
+
88
+ Alors :
89
+
90
+ - $f$ est convexe sur un intervalle $I$ si et seulement si $f''$ est positive sur $I$ ;
91
+ - $f$ est concave sur un intervalle $I$ si et seulement si $f''$ est négative sur $I$.
92
+
93
+ Ici, il faut donc calculer $f''$, puis étudier son signe.`;
94
+ const getCorrection = (identifiers) => {
95
+ const { quadcoeffs, askConvex } = identifiers;
96
+ const poly = new Polynomial(quadcoeffs);
97
+ const deriv = poly.derivate().toTree().simplify();
98
+ const second = poly.secondDerivate().toTree().simplify();
99
+ const secondAffine = new Affine(6 * quadcoeffs[3], 2 * quadcoeffs[2]); // 6a + 2b
100
+ const questionType = askConvex ? "convexe" : "concave";
101
+ return `On calcule la dérivée seconde $f''$ de $f$. On a, pour tout $x\\in \\mathbb{R}$ :
102
+
103
+ $$
104
+ f'(x) = ${deriv.toTex()}
105
+ $$
106
+
107
+ Donc :
108
+
109
+ $$
110
+ f''(x) = ${second.toTex()}
111
+ $$
112
+
113
+ On étudie le signe de $f''$ :
114
+
115
+ $$
116
+ ${firstDegreeInequationResolutionTex(secondAffine, "\\ge", (0).toTree())}
117
+ $$
118
+
119
+ On en conclut donc que $f$ est ${questionType} sur $${getAnswer(identifiers)}$.
120
+ `;
121
+ };
81
122
  const isAnswerValid = (ans, { answer }) => {
82
123
  try {
83
- const parsed = intervalParser(ans);
124
+ const parsed = intervalParser(ans, { expectedClosure: ClosureType.OO });
84
125
  if (!parsed)
85
126
  return false;
86
127
  return parsed.simplify().toTex() === answer;
@@ -91,7 +132,7 @@ const isAnswerValid = (ans, { answer }) => {
91
132
  };
92
133
  export const convexityQuadrinomials = {
93
134
  id: "convexityQuadrinomials",
94
- label: "Convexité des fonctions polynomiales de degré $3$",
135
+ label: "Déterminer la convexité d'une fonction polynôme de degré $3$",
95
136
  isSingleStep: true,
96
137
  generator: (nb) => getDistinctQuestions(getConvexityQuadrinomialsQuestion, nb),
97
138
  qcmTimer: 60,
@@ -102,4 +143,5 @@ export const convexityQuadrinomials = {
102
143
  getAnswer,
103
144
  getInstruction,
104
145
  getQuestionFromIdentifiers,
146
+ hasHintAndCorrection: true,
105
147
  };
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ askConvex: boolean;
4
+ quadcoeffs: number[];
5
+ inflexionPoint: number;
6
+ };
7
+ export declare const convexityQuadrinomialsGeo: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=convexityQuadrinomialsGeo.d.ts.map