math-exercises 3.0.211 → 3.0.213

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 (103) hide show
  1. package/lib/exercises/math/arithmetic/congruenceBasicEquation.d.ts +9 -0
  2. package/lib/exercises/math/arithmetic/congruenceBasicEquation.d.ts.map +1 -0
  3. package/lib/exercises/math/arithmetic/congruenceBasicEquation.js +116 -0
  4. package/lib/exercises/math/arithmetic/diophantianEquationSimpleSolution.d.ts +9 -0
  5. package/lib/exercises/math/arithmetic/diophantianEquationSimpleSolution.d.ts.map +1 -0
  6. package/lib/exercises/math/arithmetic/diophantianEquationSimpleSolution.js +129 -0
  7. package/lib/exercises/math/arithmetic/fermatUsageOnBigPowers.d.ts +9 -0
  8. package/lib/exercises/math/arithmetic/fermatUsageOnBigPowers.d.ts.map +1 -0
  9. package/lib/exercises/math/arithmetic/fermatUsageOnBigPowers.js +140 -0
  10. package/lib/exercises/math/arithmetic/fillCongruenceTableFirstDegree.d.ts +9 -0
  11. package/lib/exercises/math/arithmetic/fillCongruenceTableFirstDegree.d.ts.map +1 -0
  12. package/lib/exercises/math/arithmetic/fillCongruenceTableFirstDegree.js +106 -0
  13. package/lib/exercises/math/arithmetic/findBezoutCoefficients.d.ts +8 -0
  14. package/lib/exercises/math/arithmetic/findBezoutCoefficients.d.ts.map +1 -0
  15. package/lib/exercises/math/arithmetic/findBezoutCoefficients.js +175 -0
  16. package/lib/exercises/math/arithmetic/hasDiophantianEquationSolution.d.ts +9 -0
  17. package/lib/exercises/math/arithmetic/hasDiophantianEquationSolution.d.ts.map +1 -0
  18. package/lib/exercises/math/arithmetic/hasDiophantianEquationSolution.js +105 -0
  19. package/lib/exercises/math/arithmetic/index.d.ts +8 -0
  20. package/lib/exercises/math/arithmetic/index.d.ts.map +1 -1
  21. package/lib/exercises/math/arithmetic/index.js +8 -0
  22. package/lib/exercises/math/arithmetic/pgcdFromPrimeDecomposition.d.ts +10 -0
  23. package/lib/exercises/math/arithmetic/pgcdFromPrimeDecomposition.d.ts.map +1 -0
  24. package/lib/exercises/math/arithmetic/pgcdFromPrimeDecomposition.js +136 -0
  25. package/lib/exercises/math/arithmetic/pgcdHomogenuity.d.ts +8 -0
  26. package/lib/exercises/math/arithmetic/pgcdHomogenuity.d.ts.map +1 -0
  27. package/lib/exercises/math/arithmetic/pgcdHomogenuity.js +124 -0
  28. package/lib/exercises/math/calcul/ordering/compareFracAndDec.js +2 -2
  29. package/lib/exercises/math/complex/argumentFromAlgebraicComplex.d.ts +3 -0
  30. package/lib/exercises/math/complex/argumentFromAlgebraicComplex.d.ts.map +1 -1
  31. package/lib/exercises/math/complex/argumentFromAlgebraicComplex.js +92 -3
  32. package/lib/exercises/math/complex/conjugateDivideComplex.d.ts.map +1 -1
  33. package/lib/exercises/math/complex/conjugateDivideComplex.js +67 -6
  34. package/lib/exercises/math/complex/conjugateMultiplyComplex.d.ts.map +1 -1
  35. package/lib/exercises/math/complex/conjugateMultiplyComplex.js +54 -15
  36. package/lib/exercises/math/complex/divideComplex.d.ts.map +1 -1
  37. package/lib/exercises/math/complex/divideComplex.js +60 -6
  38. package/lib/exercises/math/complex/exp/complexAlgebraicFromExpForm.d.ts +9 -0
  39. package/lib/exercises/math/complex/exp/complexAlgebraicFromExpForm.d.ts.map +1 -0
  40. package/lib/exercises/math/complex/exp/complexAlgebraicFromExpForm.js +178 -0
  41. package/lib/exercises/math/complex/exp/complexExpFormPowerSimplify.d.ts +10 -0
  42. package/lib/exercises/math/complex/exp/complexExpFormPowerSimplify.d.ts.map +1 -0
  43. package/lib/exercises/math/complex/exp/complexExpFormPowerSimplify.js +152 -0
  44. package/lib/exercises/math/complex/exp/complexExpFormProductSimplify.d.ts +11 -0
  45. package/lib/exercises/math/complex/exp/complexExpFormProductSimplify.d.ts.map +1 -0
  46. package/lib/exercises/math/complex/exp/complexExpFormProductSimplify.js +165 -0
  47. package/lib/exercises/math/complex/exp/complexExpFormQuotientSimplify.d.ts +11 -0
  48. package/lib/exercises/math/complex/exp/complexExpFormQuotientSimplify.d.ts.map +1 -0
  49. package/lib/exercises/math/complex/exp/complexExpFormQuotientSimplify.js +164 -0
  50. package/lib/exercises/math/complex/exp/complexExpFromAlgebraicForm.d.ts +9 -0
  51. package/lib/exercises/math/complex/exp/complexExpFromAlgebraicForm.d.ts.map +1 -0
  52. package/lib/exercises/math/complex/exp/complexExpFromAlgebraicForm.js +175 -0
  53. package/lib/exercises/math/complex/exp/index.d.ts +5 -0
  54. package/lib/exercises/math/complex/exp/index.d.ts.map +1 -0
  55. package/lib/exercises/math/complex/exp/index.js +5 -0
  56. package/lib/exercises/math/complex/index.d.ts +1 -0
  57. package/lib/exercises/math/complex/index.d.ts.map +1 -1
  58. package/lib/exercises/math/complex/index.js +1 -0
  59. package/lib/exercises/math/complex/inverseComplex.d.ts.map +1 -1
  60. package/lib/exercises/math/complex/inverseComplex.js +35 -2
  61. package/lib/exercises/math/complex/linearCombinaisonComplex.d.ts.map +1 -1
  62. package/lib/exercises/math/complex/linearCombinaisonComplex.js +36 -5
  63. package/lib/exercises/math/complex/moduloFromAlgebraicComplex.d.ts.map +1 -1
  64. package/lib/exercises/math/complex/moduloFromAlgebraicComplex.js +38 -9
  65. package/lib/exercises/math/derivation/problems/index.d.ts +0 -1
  66. package/lib/exercises/math/derivation/problems/index.d.ts.map +1 -1
  67. package/lib/exercises/math/derivation/problems/index.js +1 -1
  68. package/lib/exercises/math/trigonometry/formulas/index.d.ts +2 -0
  69. package/lib/exercises/math/trigonometry/formulas/index.d.ts.map +1 -0
  70. package/lib/exercises/math/trigonometry/formulas/index.js +1 -0
  71. package/lib/exercises/math/trigonometry/formulas/trigoAdditionFormulaUsage.d.ts +8 -0
  72. package/lib/exercises/math/trigonometry/formulas/trigoAdditionFormulaUsage.d.ts.map +1 -0
  73. package/lib/exercises/math/trigonometry/formulas/trigoAdditionFormulaUsage.js +217 -0
  74. package/lib/exercises/math/trigonometry/index.d.ts +1 -0
  75. package/lib/exercises/math/trigonometry/index.d.ts.map +1 -1
  76. package/lib/exercises/math/trigonometry/index.js +1 -0
  77. package/lib/index.d.ts +52 -7
  78. package/lib/index.d.ts.map +1 -1
  79. package/lib/math/utils/arithmetic/bezout.d.ts +2 -0
  80. package/lib/math/utils/arithmetic/bezout.d.ts.map +1 -0
  81. package/lib/math/utils/arithmetic/bezout.js +10 -0
  82. package/lib/playground.d.ts +0 -5
  83. package/lib/playground.d.ts.map +1 -1
  84. package/lib/playground.js +3 -9
  85. package/lib/tree/nodes/algebraicNode.d.ts +2 -0
  86. package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
  87. package/lib/tree/nodes/complex/complexNode.d.ts +3 -0
  88. package/lib/tree/nodes/complex/complexNode.d.ts.map +1 -1
  89. package/lib/tree/nodes/complex/complexNode.js +8 -0
  90. package/lib/tree/nodes/functions/absNode.d.ts.map +1 -1
  91. package/lib/tree/nodes/functions/absNode.js +6 -1
  92. package/lib/tree/nodes/functions/expNode.d.ts +2 -2
  93. package/lib/tree/nodes/functions/expNode.d.ts.map +1 -1
  94. package/lib/tree/nodes/functions/expNode.js +2 -2
  95. package/lib/tree/nodes/node.d.ts +2 -0
  96. package/lib/tree/nodes/node.d.ts.map +1 -1
  97. package/lib/tree/nodes/operators/addNode.js +6 -0
  98. package/lib/tree/nodes/operators/multiplyNode.d.ts +1 -1
  99. package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
  100. package/lib/tree/nodes/operators/multiplyNode.js +11 -6
  101. package/lib/tree/nodes/operators/powerNode.d.ts.map +1 -1
  102. package/lib/tree/nodes/operators/powerNode.js +2 -0
  103. package/package.json +1 -1
@@ -5,13 +5,22 @@ import { RationalConstructor } from "../../../math/numbers/rationals/rational.js
5
5
  import { mainTrigoValues } from "../../../math/trigonometry/remarkableValues.js";
6
6
  import { randint } from "../../../math/utils/random/randint.js";
7
7
  import { ComplexNode } from "../../../tree/nodes/complex/complexNode.js";
8
- import { SqrtNode } from "../../../tree/nodes/functions/sqrtNode.js";
8
+ import { sqrt, SqrtNode } from "../../../tree/nodes/functions/sqrtNode.js";
9
+ import { reifyAlgebraic, } from "../../../tree/nodes/nodeConstructor.js";
9
10
  import { NumberNode } from "../../../tree/nodes/numbers/numberNode.js";
11
+ import { add } from "../../../tree/nodes/operators/addNode.js";
12
+ import { frac } from "../../../tree/nodes/operators/fractionNode.js";
10
13
  import { MultiplyNode } from "../../../tree/nodes/operators/multiplyNode.js";
14
+ import { square } from "../../../tree/nodes/operators/powerNode.js";
11
15
  import { random } from "../../../utils/alea/random.js";
16
+ import { alignTex } from "../../../utils/latex/alignTex.js";
12
17
  const getInstruction = (identifiers) => {
13
18
  const zTex = identifiers.zTex;
14
- return `Soit $z=${zTex}$.
19
+ return `Soit le nombre complexe :
20
+
21
+ $$
22
+ z=${zTex}
23
+ $$
15
24
 
16
25
  Déterminer l'argument principal de $z$.`;
17
26
  };
@@ -20,6 +29,78 @@ const getAnswer = (identifiers) => {
20
29
  const answer = arg.angle.toTex();
21
30
  return answer;
22
31
  };
32
+ const getHint = () => {
33
+ return `Soit $z$ un nombre complexe non nul.
34
+
35
+ - Si la partie réelle de $z$ est nulle, alors tout argument de $z$ est congru à $0$ modulo $\\pi$.
36
+ - Si la partie imaginaire de $z$ est nulle, alors tout argument de $z$ est congru à $\\frac{\\pi}{2}$ modulo $\\pi$.
37
+ - Dans les autres cas, on peut déterminer un argument $\\theta$ de $z$ en calculant $|z|$, puis en résolvant le système :
38
+
39
+ $$
40
+ \\left\\{\\begin{matrix}
41
+ \\cos(\\theta) = \\frac{x}{|z|} \\\\
42
+ \\sin(\\theta) = \\frac{y}{|z|}
43
+ \\end{matrix}\\right.
44
+ $$
45
+ `;
46
+ };
47
+ const getCorrection = (identifiers) => {
48
+ const { reIds, imIds } = identifiers;
49
+ const re = reifyAlgebraic(reIds);
50
+ const im = reifyAlgebraic(imIds);
51
+ const answer = getAnswer(identifiers);
52
+ const module = sqrt(add(square(re), square(im))).simplify();
53
+ const arg = mainTrigoValues.find((point) => point.angle.evaluate({}) === identifiers.arg);
54
+ const argCos = arg.cos.toTex();
55
+ const argSin = arg.sin.toTex();
56
+ const cosinus = frac(re, module).simplify();
57
+ const sinus = frac(im, module).simplify();
58
+ const cosSimp = frac(re, module).toSimplificationTex();
59
+ const sinSimp = frac(im, module).toSimplificationTex();
60
+ if (re.evaluate() === 0) {
61
+ const sign = im.evaluate() > 0 ? "positive" : "négative";
62
+ return `$z$ est un imaginaire pur dont la partie imaginaire est strictement ${sign}, donc l'argument principal de $z$ est :
63
+
64
+ $$
65
+ ${answer}
66
+ $$`;
67
+ }
68
+ else if (im.evaluate() === 0) {
69
+ const sign = re.evaluate() > 0 ? "positive" : "négative";
70
+ return `$z$ est un réel strictement ${sign}, donc l'argument principal de $z$ est :
71
+
72
+ $$
73
+ ${answer}
74
+ $$`;
75
+ }
76
+ else {
77
+ return `On commence par calculer le module de $z$ :
78
+
79
+ ${alignTex([
80
+ ["|z|", "=", sqrt(add(square(re), square(im))).toTex()],
81
+ ["", "=", sqrt(add(square(re), square(im)).simplify()).toTex()],
82
+ ["", "=", module.toTex()],
83
+ ])}
84
+
85
+ Tout argument $\\theta$ de $z$ vérifie alors :
86
+
87
+ $$
88
+ \\cos(\\theta) = ${cosSimp} ${argCos !== cosinus.toTex() ? `= ${argCos}` : ""}
89
+ $$
90
+
91
+ et
92
+
93
+ $$
94
+ \\sin(\\theta) = ${sinSimp} ${argSin !== sinus.toTex() ? `= ${argSin}` : ""}
95
+ $$
96
+
97
+ On en déduit que l'argument principal de $z$ est :
98
+
99
+ $$
100
+ ${answer}
101
+ $$`;
102
+ }
103
+ };
23
104
  const getQuestionFromIdentifiers = (identifiers) => {
24
105
  const question = {
25
106
  answer: getAnswer(identifiers),
@@ -27,6 +108,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
27
108
  keys: ["pi"],
28
109
  answerFormat: "tex",
29
110
  identifiers,
111
+ hint: getHint(identifiers),
112
+ correction: getCorrection(identifiers),
30
113
  };
31
114
  return question;
32
115
  };
@@ -41,7 +124,12 @@ const getArgumentFromAlgebraicComplexQuestion = () => {
41
124
  const im = new MultiplyNode(factor, arg.sin).simplify();
42
125
  const z = new ComplexNode(re, im);
43
126
  const zTex = z.toTex();
44
- const identifiers = { arg: arg.angle.evaluate({}), zTex };
127
+ const identifiers = {
128
+ arg: arg.angle.evaluate({}),
129
+ zTex,
130
+ reIds: re.toIdentifiers(),
131
+ imIds: im.toIdentifiers(),
132
+ };
45
133
  return getQuestionFromIdentifiers(identifiers);
46
134
  };
47
135
  const getPropositions = (n, { answer }) => {
@@ -70,4 +158,5 @@ export const argumentFromAlgebraicComplex = {
70
158
  isAnswerValid,
71
159
  subject: "Mathématiques",
72
160
  getQuestionFromIdentifiers,
161
+ hasHintAndCorrection: true,
73
162
  };
@@ -1 +1 @@
1
- {"version":3,"file":"conjugateDivideComplex.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/complex/conjugateDivideComplex.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;AA6EF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAaxD,CAAC"}
1
+ {"version":3,"file":"conjugateDivideComplex.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/complex/conjugateDivideComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,EAAE,CAAC;IACb,EAAE,EAAE,MAAM,EAAE,CAAC;CACd,CAAC;AAyIF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAcxD,CAAC"}
@@ -1,7 +1,10 @@
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 { randint } from "../../../math/utils/random/randint.js";
5
+ import { frac } from "../../../tree/nodes/operators/fractionNode.js";
4
6
  import { shuffle } from "../../../utils/alea/shuffle.js";
7
+ import { alignTex } from "../../../utils/latex/alignTex.js";
5
8
  const getInstruction = (identifiers) => {
6
9
  const z1 = new Complex(identifiers.z1[0], identifiers.z1[1]);
7
10
  const z2 = new Complex(identifiers.z2[0], identifiers.z2[1]);
@@ -17,19 +20,75 @@ const getAnswer = (identifiers) => {
17
20
  const answerTex = conjz1.divideNode(conjz2).toTex();
18
21
  return answerTex;
19
22
  };
23
+ const getHint = () => {
24
+ return `Pour calculer un quotient dans $\\mathbb{C}$, on multiplie le numérateur et le dénominateur par le conjugué du dénominateur.
25
+
26
+ On rappelle que le conjugué d'un nombre complexe $z$ est le nombre complexe de même partie réelle et de partie imaginaire opposée.
27
+ `;
28
+ };
29
+ const getCorrection = (identifiers) => {
30
+ const z1 = new Complex(identifiers.z1[0], identifiers.z1[1]);
31
+ const z2 = new Complex(identifiers.z2[0], identifiers.z2[1]);
32
+ const z1Tree = z1.toTree();
33
+ const z2Tree = z2.toTree();
34
+ const conj = z2.conjugate().toTree();
35
+ const num = z1.multiply(z2.conjugate()).toTree();
36
+ const denum = z2.multiply(z2.conjugate()).toTree();
37
+ // const zTree = z.toTree();
38
+ // const conj = z.conjugate().toTree();
39
+ return `On a
40
+
41
+ $$
42
+ z = ${z1Tree.toTex()}
43
+ $$
44
+
45
+ $$
46
+ z' = ${z2Tree.toTex()}
47
+ $$
48
+
49
+ et on veut calculer le conjugué de $\\frac{z}{z'}$.
50
+
51
+ On commence par calculer $\\frac{z}{z'}$. Pour cela, on multiplie le numérateur et le dénominateur par le conjugué de $z'$, c'est à dire par :
52
+
53
+ $$
54
+ ${conj.toTex()}
55
+ $$
56
+
57
+ Cela donne :
58
+
59
+
60
+ ${alignTex([
61
+ ["", ` \\frac{${z1Tree.toTex()}}{${z2Tree.toTex()}} `],
62
+ [
63
+ "=",
64
+ `\\frac{(${z1Tree.toTex()})(${conj.toTex()})}{(${z2Tree.toTex()})(${conj.toTex()})}`,
65
+ ],
66
+ ["=", frac(num, denum).toTex()],
67
+ ["=", z1.divideNode(z2).toTex()],
68
+ ])}
69
+
70
+ Il suffit maintenant de prendre le conjugué de ce résultat : on obtient
71
+
72
+ $$
73
+ ${getAnswer(identifiers)}
74
+ $$
75
+ `;
76
+ };
20
77
  const getQuestionFromIdentifiers = (identifiers) => {
21
78
  const question = {
22
79
  answer: getAnswer(identifiers),
23
80
  instruction: getInstruction(identifiers),
24
- keys: ["i", "z", "overline", "quote"],
81
+ keys: ["i"],
25
82
  answerFormat: "tex",
26
83
  startStatement: "\\overline{\\frac{z}{z'}}",
27
84
  identifiers,
85
+ hint: getHint(identifiers),
86
+ correction: getCorrection(identifiers),
28
87
  };
29
88
  return question;
30
89
  };
31
90
  const getConjugateDivideComplexQuestion = () => {
32
- const z1 = ComplexConstructor.random();
91
+ let z1;
33
92
  let z2;
34
93
  let counter = 0;
35
94
  do {
@@ -37,11 +96,12 @@ const getConjugateDivideComplexQuestion = () => {
37
96
  if (counter > 1000) {
38
97
  throw new Error("conjugate divide complex too many iterations");
39
98
  }
40
- z2 = ComplexConstructor.random();
41
- } while (z1.im === 0 && z2.im === 0);
99
+ z1 = [randint(-10, 11, [0]), randint(-10, 11, [0])];
100
+ z2 = [randint(-10, 11, [0]), randint(-10, 11, [0])];
101
+ } while (z1[0] / z2[0] === z1[1] / z2[1]);
42
102
  const identifiers = {
43
- z1: [z1.re, z1.im],
44
- z2: [z2.re, z2.im],
103
+ z1,
104
+ z2,
45
105
  };
46
106
  return getQuestionFromIdentifiers(identifiers);
47
107
  };
@@ -73,4 +133,5 @@ export const conjugateDivideComplex = {
73
133
  isAnswerValid,
74
134
  subject: "Mathématiques",
75
135
  getQuestionFromIdentifiers,
136
+ hasHintAndCorrection: true,
76
137
  };
@@ -1 +1 @@
1
- {"version":3,"file":"conjugateMultiplyComplex.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/complex/conjugateMultiplyComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAIrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,EAAE,CAAC;IACb,EAAE,EAAE,MAAM,EAAE,CAAC;CACd,CAAC;AA4EF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAa1D,CAAC"}
1
+ {"version":3,"file":"conjugateMultiplyComplex.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/complex/conjugateMultiplyComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,EAAE,CAAC;IACb,EAAE,EAAE,MAAM,EAAE,CAAC;CACd,CAAC;AA4HF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAc1D,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
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";
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.z1[0], identifiers.z1[1]);
7
11
  const z2 = new Complex(identifiers.z2[0], identifiers.z2[1]);
8
- return `Soit $z=${z1.toTree().toTex()}$ et $z'=${z2
9
- .toTree()
10
- .toTex()}$. Calculer $\\overline{z\\times z'}$.`;
12
+ return `Soit $z=${z1.toTree().toTex()}$ et $z'=${z2.toTree().toTex()}$.
13
+
14
+ Calculer $\\overline{z\\times z'}$.`;
11
15
  };
12
16
  const getAnswer = (identifiers) => {
13
17
  const z1 = new Complex(identifiers.z1[0], identifiers.z1[1]);
@@ -17,29 +21,63 @@ const getAnswer = (identifiers) => {
17
21
  const answer = conj.toTree().toTex();
18
22
  return answer;
19
23
  };
24
+ const getHint = () => {
25
+ return `Pour multiplier deux nombres complexes, on utilise la distributivité double, ainsi que le fait que $i^2 = -1$.
26
+
27
+ On rappelle que le conjugué $\\overline{z}$ d'un nombre complexe $z$ est le nombre complexe de même partie réelle et de partie imaginaire opposée.`;
28
+ };
29
+ const getCorrection = (identifiers) => {
30
+ const { z1, z2 } = identifiers;
31
+ const [a, b] = z1;
32
+ const [c, d] = z2;
33
+ const zA = add(a, multiply(b, "i"));
34
+ const zB = add(c, multiply(d, "i"));
35
+ return `On distribue comme pour des nombres réels, puis on utilise le fait que $i^2=-1$ :
36
+
37
+ ${alignTex([
38
+ ["z\\times z'", "=", multiply(zA, zB).toTex()],
39
+ [
40
+ "",
41
+ "=",
42
+ add(add(multiply(a, c), multiply(a, multiply(d, "i"))), add(multiply(multiply(b, "i"), c), multiply(multiply(b, "i"), multiply(d, "i")))).toTex(),
43
+ ],
44
+ [
45
+ "",
46
+ "=",
47
+ add(add(multiply(a, c).simplify(), multiply(a * d + b * c, "i")), multiply(multiply(b, d).simplify(), -1)).toTex(),
48
+ ],
49
+ [
50
+ "",
51
+ "=",
52
+ add(add(multiply(a, c), multiply(a * d + b * c, "i")), multiply(multiply(b, d), -1))
53
+ .simplify({ noAddOrder: true })
54
+ .toTex(),
55
+ ],
56
+ ])}
57
+
58
+ Il suffit alors de prendre le conjugué de ce résultat, on obtient :
59
+
60
+ $$
61
+ ${getAnswer(identifiers)}
62
+ $$
63
+ `;
64
+ };
20
65
  const getQuestionFromIdentifiers = (identifiers) => {
21
66
  const question = {
22
67
  answer: getAnswer(identifiers),
23
68
  instruction: getInstruction(identifiers),
24
- keys: ["i", "z", "overline", "quote"],
69
+ keys: ["i"],
25
70
  answerFormat: "tex",
26
71
  startStatement: "\\overline{z\\times z'}",
27
72
  identifiers,
73
+ hint: getHint(identifiers),
74
+ correction: getCorrection(identifiers),
28
75
  };
29
76
  return question;
30
77
  };
31
78
  const getConjugateMultiplyComplexQuestion = () => {
32
- const z1 = ComplexConstructor.random();
33
- let z2;
34
- let counter = 0;
35
- do {
36
- counter++;
37
- if (counter > 1000) {
38
- throw new Error("conjugate multiply complex too many iterations");
39
- }
40
- z2 = ComplexConstructor.random();
41
- } while (z1.im === 0 && z2.im === 0);
42
- const identifiers = { z1: [z1.re, z1.im], z2: [z2.re, z2.im] };
79
+ const [a, b, c, d] = randTupleInt(4, { from: -9, to: 10, elExcludes: [0] });
80
+ const identifiers = { z1: [a, b], z2: [c, d] };
43
81
  return getQuestionFromIdentifiers(identifiers);
44
82
  };
45
83
  const getPropositions = (n, { answer, z1, z2 }) => {
@@ -74,4 +112,5 @@ export const conjugateMultiplyComplex = {
74
112
  isAnswerValid,
75
113
  subject: "Mathématiques",
76
114
  getQuestionFromIdentifiers,
115
+ hasHintAndCorrection: true,
77
116
  };
@@ -1 +1 @@
1
- {"version":3,"file":"divideComplex.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/complex/divideComplex.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;AAoEF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAY/C,CAAC"}
1
+ {"version":3,"file":"divideComplex.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/complex/divideComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,EAAE,CAAC;IACb,EAAE,EAAE,MAAM,EAAE,CAAC;CACd,CAAC;AAyHF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAa/C,CAAC"}
@@ -1,7 +1,10 @@
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 { randint } from "../../../math/utils/random/randint.js";
5
+ import { frac } from "../../../tree/nodes/operators/fractionNode.js";
4
6
  import { shuffle } from "../../../utils/alea/shuffle.js";
7
+ import { alignTex } from "../../../utils/latex/alignTex.js";
5
8
  const getInstruction = (identifiers) => {
6
9
  const z1 = new Complex(identifiers.z1[0], identifiers.z1[1]);
7
10
  const z2 = new Complex(identifiers.z2[0], identifiers.z2[1]);
@@ -15,19 +18,68 @@ const getAnswer = (identifiers) => {
15
18
  const answerTex = z1.divideNode(z2).toTex();
16
19
  return answerTex;
17
20
  };
21
+ const getHint = () => {
22
+ return `Pour calculer un quotient dans $\\mathbb{C}$, on multiplie le numérateur et le dénominateur par le conjugué du dénominateur.
23
+
24
+ On rappelle que le conjugué d'un nombre complexe $z$ est le nombre complexe de même partie réelle et de partie imaginaire opposée.
25
+ `;
26
+ };
27
+ const getCorrection = (identifiers) => {
28
+ const z1 = new Complex(identifiers.z1[0], identifiers.z1[1]);
29
+ const z2 = new Complex(identifiers.z2[0], identifiers.z2[1]);
30
+ const z1Tree = z1.toTree();
31
+ const z2Tree = z2.toTree();
32
+ const conj = z2.conjugate().toTree();
33
+ const num = z1.multiply(z2.conjugate()).toTree();
34
+ const denum = z2.multiply(z2.conjugate()).toTree();
35
+ // const zTree = z.toTree();
36
+ // const conj = z.conjugate().toTree();
37
+ return `On a
38
+
39
+ $$
40
+ z = ${z1Tree.toTex()}
41
+ $$
42
+
43
+ $$
44
+ z' = ${z2Tree.toTex()}
45
+ $$
46
+
47
+ et on veut calculer $\\frac{z}{z'}$.
48
+
49
+ Pour cela, on multiplie le numérateur et le dénominateur par le conjugué de $z'$, c'est à dire par :
50
+
51
+ $$
52
+ ${conj.toTex()}
53
+ $$
54
+
55
+ Cela donne :
56
+
57
+
58
+ ${alignTex([
59
+ ["", ` \\frac{${z1Tree.toTex()}}{${z2Tree.toTex()}} `],
60
+ [
61
+ "=",
62
+ `\\frac{(${z1Tree.toTex()})(${conj.toTex()})}{(${z2Tree.toTex()})(${conj.toTex()})}`,
63
+ ],
64
+ ["=", frac(num, denum).toTex()],
65
+ ["=", getAnswer(identifiers)],
66
+ ])}`;
67
+ };
18
68
  const getQuestionFromIdentifiers = (identifiers) => {
19
69
  const question = {
20
70
  answer: getAnswer(identifiers),
21
71
  instruction: getInstruction(identifiers),
22
- keys: ["i", "z", "quote"],
72
+ keys: ["i"],
23
73
  answerFormat: "tex",
24
74
  startStatement: "\\frac{z}{z'}",
25
75
  identifiers,
76
+ hint: getHint(identifiers),
77
+ correction: getCorrection(identifiers),
26
78
  };
27
79
  return question;
28
80
  };
29
81
  const getDivideComplexQuestion = () => {
30
- const z1 = ComplexConstructor.random();
82
+ let z1;
31
83
  let z2;
32
84
  let counter = 0;
33
85
  do {
@@ -35,11 +87,12 @@ const getDivideComplexQuestion = () => {
35
87
  if (counter > 1000) {
36
88
  throw new Error("divide complex too many iterations");
37
89
  }
38
- z2 = ComplexConstructor.random();
39
- } while (z1.im === 0 && z2.im === 0);
90
+ z1 = [randint(-10, 11, [0]), randint(-10, 11, [0])];
91
+ z2 = [randint(-10, 11, [0]), randint(-10, 11, [0])];
92
+ } while (z1[0] / z2[0] === z1[1] / z2[1]);
40
93
  const identifiers = {
41
- z1: [z1.re, z1.im],
42
- z2: [z2.re, z2.im],
94
+ z1,
95
+ z2,
43
96
  };
44
97
  return getQuestionFromIdentifiers(identifiers);
45
98
  };
@@ -71,4 +124,5 @@ export const divideComplex = {
71
124
  isAnswerValid,
72
125
  subject: "Mathématiques",
73
126
  getQuestionFromIdentifiers,
127
+ hasHintAndCorrection: true,
74
128
  };
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ rIds: NodeIdentifiers;
5
+ thetaIds: NodeIdentifiers;
6
+ };
7
+ export declare const complexAlgebraicFromExpForm: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=complexAlgebraicFromExpForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"complexAlgebraicFromExpForm.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/complex/exp/complexAlgebraicFromExpForm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAQ7C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,eAAe,CAAC;IACtB,QAAQ,EAAE,eAAe,CAAC;CAC3B,CAAC;AAiLF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAsB7D,CAAC"}
@@ -0,0 +1,178 @@
1
+ import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { mainTrigoValues } from "../../../../math/trigonometry/remarkableValues.js";
4
+ import { randint } from "../../../../math/utils/random/randint.js";
5
+ import { abs } from "../../../../tree/nodes/functions/absNode.js";
6
+ import { cos } from "../../../../tree/nodes/functions/cosNode.js";
7
+ import { sin } from "../../../../tree/nodes/functions/sinNode.js";
8
+ import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
9
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
10
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
11
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
12
+ import { random } from "../../../../utils/alea/random.js";
13
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
14
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
15
+ const getPropositions = (n, { answer, rIds, thetaIds }) => {
16
+ const propositions = [];
17
+ addValidProp(propositions, answer);
18
+ tryToAddWrongProp(propositions, getAnswer({
19
+ rIds: (1).toTree().toIdentifiers(),
20
+ thetaIds: thetaIds,
21
+ }));
22
+ propWhile(propositions, n, () => {
23
+ const fakeTheta = random(mainTrigoValues).angle;
24
+ tryToAddWrongProp(propositions, getAnswer({
25
+ rIds,
26
+ thetaIds: fakeTheta.toIdentifiers(),
27
+ }));
28
+ });
29
+ return shuffleProps(propositions, n);
30
+ };
31
+ const getRawAnswerNode = (identifiers) => {
32
+ const { rIds, thetaIds } = identifiers;
33
+ const r = reifyAlgebraic(rIds);
34
+ const theta = reifyAlgebraic(thetaIds);
35
+ const re = multiply(r, cos(theta)).simplify();
36
+ const im = multiply(r, sin(theta)).simplify();
37
+ return add(re, multiply(im, "i"));
38
+ };
39
+ const getAnswer = (identifiers) => {
40
+ return getRawAnswerNode(identifiers)
41
+ .simplify({
42
+ noAddOrder: true,
43
+ forceDistributeFractions: true,
44
+ towardsDistribute: true,
45
+ forbidFactorize: true,
46
+ })
47
+ .toTex();
48
+ };
49
+ const getInstruction = (identifiers) => {
50
+ const { rIds, thetaIds } = identifiers;
51
+ const r = reifyAlgebraic(rIds);
52
+ const theta = reifyAlgebraic(thetaIds);
53
+ const rawTheta = abs(theta).simplify();
54
+ return `Soit le nombre complexe :
55
+
56
+ $$
57
+ z = ${r.toTex()}e^{${theta.evaluate() < 0 ? "-" : ""}${multiply("i", rawTheta).toTex({
58
+ forceNoTimesSign: true,
59
+ })}}
60
+ $$
61
+
62
+ Écrire $z$ sous forme algébrique.`;
63
+ };
64
+ const getHint = () => {
65
+ return `Pour tout réel $\\theta$, on a :
66
+
67
+ $$
68
+ e^{i\\theta} = \\cos(\\theta)+i\\sin(\\theta)
69
+ $$`;
70
+ };
71
+ const getCorrection = (identifiers) => {
72
+ const { rIds, thetaIds } = identifiers;
73
+ const r = reifyAlgebraic(rIds);
74
+ const theta = reifyAlgebraic(thetaIds);
75
+ const rawTheta = abs(theta).simplify();
76
+ const rawRe = cos(theta).simplify().toTex();
77
+ const rawIm = multiply("i", sin(theta))
78
+ .simplify({
79
+ forceDistributeFractions: true,
80
+ })
81
+ .toTex();
82
+ return `Pour tout réel $\\theta$, on a :
83
+
84
+ $$
85
+ e^{i\\theta} = \\cos(\\theta)+i\\sin(\\theta)
86
+ $$
87
+
88
+ Ici, on a donc :
89
+
90
+ ${alignTex([
91
+ [
92
+ `e^{${theta.evaluate() < 0 ? "-" : ""}${multiply("i", rawTheta).toTex({
93
+ forceNoTimesSign: true,
94
+ })}}`,
95
+ "=",
96
+ cos(theta).toTex() + "+" + multiply("i", sin(theta)).toTex(),
97
+ ],
98
+ [
99
+ "",
100
+ "=",
101
+ add(rawRe, rawIm)
102
+ .simplify({
103
+ noAddOrder: true,
104
+ })
105
+ .toTex(),
106
+ ],
107
+ ])}
108
+
109
+ On multiplie alors par $${r.toTex()}$ :
110
+
111
+ $$
112
+ z = ${getAnswer(identifiers)}
113
+ $$
114
+ `;
115
+ };
116
+ const getKeys = () => {
117
+ return ["i"];
118
+ };
119
+ const isAnswerValid = (ans, { answer, ...identifiers }) => {
120
+ try {
121
+ const parsed = parseAlgebraic(ans);
122
+ return (parsed
123
+ .simplify({
124
+ towardsDistribute: true,
125
+ forbidFactorize: true,
126
+ forceDistributeFractions: true,
127
+ })
128
+ .toTex() ===
129
+ getRawAnswerNode(identifiers)
130
+ .simplify({
131
+ towardsDistribute: true,
132
+ forbidFactorize: true,
133
+ forceDistributeFractions: true,
134
+ })
135
+ .toTex());
136
+ }
137
+ catch (err) {
138
+ return handleVEAError(err);
139
+ }
140
+ };
141
+ const getComplexAlgebraicFromExpFormQuestion = () => {
142
+ const angle = random(mainTrigoValues).angle;
143
+ const r = randint(1, 10);
144
+ const identifiers = {
145
+ rIds: r.toTree().toIdentifiers(),
146
+ thetaIds: angle.toIdentifiers(),
147
+ };
148
+ return getQuestionFromIdentifiers(identifiers);
149
+ };
150
+ const getQuestionFromIdentifiers = (identifiers) => {
151
+ return {
152
+ answer: getAnswer(identifiers),
153
+ instruction: getInstruction(identifiers),
154
+ keys: getKeys(identifiers),
155
+ answerFormat: "tex",
156
+ identifiers,
157
+ hint: getHint(identifiers),
158
+ correction: getCorrection(identifiers),
159
+ };
160
+ };
161
+ export const complexAlgebraicFromExpForm = {
162
+ id: "complexAlgebraicFromExpForm",
163
+ connector: "=",
164
+ label: "Donner la forme algébrique d'un complexe écrit sous forme exponentielle",
165
+ isSingleStep: true,
166
+ generator: (nb, opts) => getDistinctQuestions(() => getComplexAlgebraicFromExpFormQuestion(opts), nb),
167
+ qcmTimer: 60,
168
+ freeTimer: 60,
169
+ getPropositions,
170
+ isAnswerValid,
171
+ subject: "Mathématiques",
172
+ getInstruction,
173
+ getHint,
174
+ getCorrection,
175
+ getAnswer,
176
+ getQuestionFromIdentifiers,
177
+ hasHintAndCorrection: true,
178
+ };
@@ -0,0 +1,10 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ z1ModuleIds: NodeIdentifiers;
5
+ z1ArgIds: NodeIdentifiers;
6
+ pow: number;
7
+ };
8
+ export declare const complexExpFormPowerSimplify: Exercise<Identifiers>;
9
+ export {};
10
+ //# sourceMappingURL=complexExpFormPowerSimplify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"complexExpFormPowerSimplify.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/complex/exp/complexExpFormPowerSimplify.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAY7C,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,eAAe,CAAC;IAC7B,QAAQ,EAAE,eAAe,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AA4JF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAsB7D,CAAC"}