math-exercises 1.3.50 → 1.3.52

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 (52) hide show
  1. package/lib/exercises/complex/addComplex.d.ts.map +1 -1
  2. package/lib/exercises/complex/addComplex.js +6 -2
  3. package/lib/exercises/complex/conjugateComplex.ts.d.ts +4 -0
  4. package/lib/exercises/complex/conjugateComplex.ts.d.ts.map +1 -0
  5. package/lib/exercises/complex/conjugateComplex.ts.js +73 -0
  6. package/lib/exercises/complex/conjugateDivideComplex.d.ts +4 -0
  7. package/lib/exercises/complex/conjugateDivideComplex.d.ts.map +1 -0
  8. package/lib/exercises/complex/conjugateDivideComplex.js +65 -0
  9. package/lib/exercises/complex/conjugateMultiplyComplex.d.ts +4 -0
  10. package/lib/exercises/complex/conjugateMultiplyComplex.d.ts.map +1 -0
  11. package/lib/exercises/complex/conjugateMultiplyComplex.js +69 -0
  12. package/lib/exercises/complex/divideComplex.d.ts +4 -0
  13. package/lib/exercises/complex/divideComplex.d.ts.map +1 -0
  14. package/lib/exercises/complex/divideComplex.js +61 -0
  15. package/lib/exercises/complex/inverseComplex.d.ts +4 -0
  16. package/lib/exercises/complex/inverseComplex.d.ts.map +1 -0
  17. package/lib/exercises/complex/inverseComplex.js +73 -0
  18. package/lib/exercises/complex/linearCombinaisonComplex.d.ts +4 -0
  19. package/lib/exercises/complex/linearCombinaisonComplex.d.ts.map +1 -0
  20. package/lib/exercises/complex/linearCombinaisonComplex.js +67 -0
  21. package/lib/exercises/complex/mutiplyComplex.d.ts.map +1 -1
  22. package/lib/exercises/complex/mutiplyComplex.js +6 -4
  23. package/lib/exercises/exercises.d.ts.map +1 -1
  24. package/lib/exercises/exercises.js +19 -8
  25. package/lib/exercises/probaStat/averageWithTable.d.ts +4 -0
  26. package/lib/exercises/probaStat/averageWithTable.d.ts.map +1 -0
  27. package/lib/exercises/probaStat/averageWithTable.js +76 -0
  28. package/lib/exercises/probaStat/median.d.ts +2 -2
  29. package/lib/exercises/probaStat/median.d.ts.map +1 -1
  30. package/lib/exercises/probaStat/median.js +7 -7
  31. package/lib/exercises/probaStat/medianList.d.ts +2 -2
  32. package/lib/exercises/probaStat/medianList.d.ts.map +1 -1
  33. package/lib/exercises/probaStat/medianList.js +6 -6
  34. package/lib/exercises/probaStat/quartiles.js +1 -1
  35. package/lib/exercises/sequences/arithmetic/arithmeticSum.d.ts +1 -0
  36. package/lib/exercises/sequences/arithmetic/arithmeticSum.d.ts.map +1 -0
  37. package/lib/exercises/sequences/arithmetic/arithmeticSum.js +1 -0
  38. package/lib/math/complex/complex.d.ts +7 -0
  39. package/lib/math/complex/complex.d.ts.map +1 -1
  40. package/lib/math/complex/complex.js +40 -1
  41. package/lib/tree/nodes/expression/expressionNode.d.ts +1 -0
  42. package/lib/tree/nodes/expression/expressionNode.d.ts.map +1 -0
  43. package/lib/tree/nodes/expression/expressionNode.js +1 -0
  44. package/lib/tree/nodes/numbers/numberNode.d.ts +1 -1
  45. package/lib/tree/nodes/numbers/numberNode.js +1 -2
  46. package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
  47. package/lib/tree/nodes/operators/multiplyNode.js +5 -0
  48. package/lib/tree/nodes/variables/variableNode.d.ts +1 -1
  49. package/lib/tree/nodes/variables/variableNode.d.ts.map +1 -1
  50. package/lib/tree/nodes/variables/variableNode.js +1 -4
  51. package/lib/tree/parsers/simplify.js +1 -0
  52. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"addComplex.d.ts","sourceRoot":"","sources":["../../../src/exercises/complex/addComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAU3E,eAAO,MAAM,UAAU,EAAE,QASxB,CAAC;AAEF,wBAAgB,qBAAqB,IAAI,QAAQ,CAqDhD"}
1
+ {"version":3,"file":"addComplex.d.ts","sourceRoot":"","sources":["../../../src/exercises/complex/addComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAU3E,eAAO,MAAM,UAAU,EAAE,QASxB,CAAC;AAEF,wBAAgB,qBAAqB,IAAI,QAAQ,CAyDhD"}
@@ -12,7 +12,7 @@ exports.addComplex = {
12
12
  id: 'addComplex',
13
13
  connector: '=',
14
14
  instruction: '',
15
- label: 'Ajouter deux nombres complexes',
15
+ label: 'Additionner deux nombres complexes',
16
16
  levels: ['MathExp'],
17
17
  isSingleStep: true,
18
18
  sections: ['Nombres complexes'],
@@ -20,7 +20,10 @@ exports.addComplex = {
20
20
  };
21
21
  function getAddComplexQuestion() {
22
22
  const z1 = complex_1.ComplexConstructor.random();
23
- const z2 = complex_1.ComplexConstructor.random();
23
+ let z2;
24
+ do {
25
+ z2 = complex_1.ComplexConstructor.random();
26
+ } while (z1.im === 0 && z2.im === 0);
24
27
  const answer = (0, simplify_1.simplifyComplex)(new addNode_1.AddNode(z1.toTree(), z2.toTree()));
25
28
  const getPropositions = (n) => {
26
29
  const res = [];
@@ -60,6 +63,7 @@ function getAddComplexQuestion() {
60
63
  keys: ['i', 'z', 'quote'],
61
64
  getPropositions,
62
65
  answerFormat: 'tex',
66
+ startStatement: "z+z'",
63
67
  };
64
68
  return question;
65
69
  }
@@ -0,0 +1,4 @@
1
+ import { Exercise, Question } from '../../exercises/exercise';
2
+ export declare const conjugateComplex: Exercise;
3
+ export declare function getConjugateComplexQuestion(): Question;
4
+ //# sourceMappingURL=conjugateComplex.ts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conjugateComplex.ts.d.ts","sourceRoot":"","sources":["../../../src/exercises/complex/conjugateComplex.ts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAM3E,eAAO,MAAM,gBAAgB,EAAE,QAS9B,CAAC;AAEF,wBAAgB,2BAA2B,IAAI,QAAQ,CA6DtD"}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getConjugateComplexQuestion = exports.conjugateComplex = void 0;
4
+ const getDistinctQuestions_1 = require("../../exercises/utils/getDistinctQuestions");
5
+ const complex_1 = require("../../math/complex/complex");
6
+ const shuffle_1 = require("../../utils/shuffle");
7
+ const uuid_1 = require("uuid");
8
+ exports.conjugateComplex = {
9
+ id: 'conjugateComplex',
10
+ connector: '=',
11
+ instruction: '',
12
+ label: "Conjugué d'un nombre complexe",
13
+ levels: ['MathExp'],
14
+ isSingleStep: true,
15
+ sections: ['Nombres complexes'],
16
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getConjugateComplexQuestion, nb),
17
+ };
18
+ function getConjugateComplexQuestion() {
19
+ const complex = complex_1.ComplexConstructor.random();
20
+ const answer = complex.conjugate().toTree().toTex();
21
+ const getPropositions = (n) => {
22
+ const res = [];
23
+ res.push({
24
+ id: (0, uuid_1.v4)(),
25
+ statement: answer,
26
+ isRightAnswer: true,
27
+ format: 'tex',
28
+ });
29
+ const opposite = complex.opposite().toTree().toTex();
30
+ if (opposite !== answer)
31
+ res.push({
32
+ id: (0, uuid_1.v4)(),
33
+ statement: opposite,
34
+ isRightAnswer: false,
35
+ format: 'tex',
36
+ });
37
+ const conjOpposite = complex.conjugate().opposite().toTree().toTex();
38
+ if (!res.some((prop) => prop.statement === conjOpposite))
39
+ res.push({
40
+ id: (0, uuid_1.v4)(),
41
+ statement: conjOpposite,
42
+ isRightAnswer: false,
43
+ format: 'tex',
44
+ });
45
+ const missing = n - res.length;
46
+ for (let i = 0; i < missing; i++) {
47
+ let isDuplicate;
48
+ let proposition;
49
+ do {
50
+ const wrongAnswer = complex_1.ComplexConstructor.random();
51
+ proposition = {
52
+ id: (0, uuid_1.v4)() + ``,
53
+ statement: wrongAnswer.toTree().toTex(),
54
+ isRightAnswer: false,
55
+ format: 'tex',
56
+ };
57
+ isDuplicate = res.some((p) => p.statement === proposition.statement);
58
+ } while (isDuplicate);
59
+ res.push(proposition);
60
+ }
61
+ return (0, shuffle_1.shuffle)(res);
62
+ };
63
+ const question = {
64
+ answer,
65
+ instruction: `Déterminer le conjugué de $z=${complex.toTree().toTex()}$.`,
66
+ keys: ['i'],
67
+ getPropositions,
68
+ answerFormat: 'tex',
69
+ startStatement: '\\overline z',
70
+ };
71
+ return question;
72
+ }
73
+ exports.getConjugateComplexQuestion = getConjugateComplexQuestion;
@@ -0,0 +1,4 @@
1
+ import { Exercise, Question } from '../../exercises/exercise';
2
+ export declare const conjugateDivideComplex: Exercise;
3
+ export declare function getConjugateDivideComplexQuestion(): Question;
4
+ //# sourceMappingURL=conjugateDivideComplex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conjugateDivideComplex.d.ts","sourceRoot":"","sources":["../../../src/exercises/complex/conjugateDivideComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAM3E,eAAO,MAAM,sBAAsB,EAAE,QASpC,CAAC;AAEF,wBAAgB,iCAAiC,IAAI,QAAQ,CAwD5D"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getConjugateDivideComplexQuestion = exports.conjugateDivideComplex = void 0;
4
+ const getDistinctQuestions_1 = require("../../exercises/utils/getDistinctQuestions");
5
+ const complex_1 = require("../../math/complex/complex");
6
+ const shuffle_1 = require("../../utils/shuffle");
7
+ const uuid_1 = require("uuid");
8
+ exports.conjugateDivideComplex = {
9
+ id: 'conjugateDivideComplex',
10
+ connector: '=',
11
+ instruction: '',
12
+ label: "Conjugué d'une fraction de nombres complexes",
13
+ levels: ['MathExp'],
14
+ isSingleStep: true,
15
+ sections: ['Nombres complexes'],
16
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getConjugateDivideComplexQuestion, nb),
17
+ };
18
+ function getConjugateDivideComplexQuestion() {
19
+ const z1 = complex_1.ComplexConstructor.random();
20
+ let z2;
21
+ do {
22
+ z2 = complex_1.ComplexConstructor.random();
23
+ } while (z1.im === 0 && z2.im === 0);
24
+ const conjz1 = z1.conjugate();
25
+ const conjz2 = z2.conjugate();
26
+ const answerTex = conjz1.divideNode(conjz2).toTex();
27
+ const getPropositions = (n) => {
28
+ const res = [];
29
+ res.push({
30
+ id: (0, uuid_1.v4)(),
31
+ statement: answerTex,
32
+ isRightAnswer: true,
33
+ format: 'tex',
34
+ });
35
+ const missing = n - res.length;
36
+ for (let i = 0; i < missing; i++) {
37
+ let isDuplicate;
38
+ let proposition;
39
+ do {
40
+ const wrongAnswer = complex_1.ComplexConstructor.random();
41
+ proposition = {
42
+ id: (0, uuid_1.v4)() + '',
43
+ statement: wrongAnswer.toTree().toTex(),
44
+ isRightAnswer: false,
45
+ format: 'tex',
46
+ };
47
+ isDuplicate = res.some((p) => p.statement === proposition.statement);
48
+ } while (isDuplicate);
49
+ res.push(proposition);
50
+ }
51
+ return (0, shuffle_1.shuffle)(res);
52
+ };
53
+ const question = {
54
+ answer: answerTex,
55
+ instruction: `Soit $z=${z1.toTree().toTex()}$ et $z'=${z2
56
+ .toTree()
57
+ .toTex()}$. Calculer le conjugué de $\\frac{z}{z'}$.`,
58
+ keys: ['i', 'z', 'quote'],
59
+ getPropositions,
60
+ answerFormat: 'tex',
61
+ startStatement: "\\overline{\\frac{z}{z'}}",
62
+ };
63
+ return question;
64
+ }
65
+ exports.getConjugateDivideComplexQuestion = getConjugateDivideComplexQuestion;
@@ -0,0 +1,4 @@
1
+ import { Exercise, Question } from '../../exercises/exercise';
2
+ export declare const conjugateMultiplyComplex: Exercise;
3
+ export declare function getConjugateMultiplyComplexQuestion(): Question;
4
+ //# sourceMappingURL=conjugateMultiplyComplex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conjugateMultiplyComplex.d.ts","sourceRoot":"","sources":["../../../src/exercises/complex/conjugateMultiplyComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAM3E,eAAO,MAAM,wBAAwB,EAAE,QAStC,CAAC;AAEF,wBAAgB,mCAAmC,IAAI,QAAQ,CA4D9D"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getConjugateMultiplyComplexQuestion = exports.conjugateMultiplyComplex = void 0;
4
+ const getDistinctQuestions_1 = require("../../exercises/utils/getDistinctQuestions");
5
+ const complex_1 = require("../../math/complex/complex");
6
+ const shuffle_1 = require("../../utils/shuffle");
7
+ const uuid_1 = require("uuid");
8
+ exports.conjugateMultiplyComplex = {
9
+ id: 'conjugateMultiplyComplex',
10
+ connector: '=',
11
+ instruction: '',
12
+ label: "Conjugué d'un produit de nombres complexes",
13
+ levels: ['MathExp'],
14
+ isSingleStep: true,
15
+ sections: ['Nombres complexes'],
16
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getConjugateMultiplyComplexQuestion, nb),
17
+ };
18
+ function getConjugateMultiplyComplexQuestion() {
19
+ const z1 = complex_1.ComplexConstructor.random();
20
+ let z2;
21
+ do {
22
+ z2 = complex_1.ComplexConstructor.random();
23
+ } while (z1.im === 0 && z2.im === 0);
24
+ const prod = z1.multiply(z2);
25
+ const conj = prod.conjugate();
26
+ const answer = conj.toTree();
27
+ const getPropositions = (n) => {
28
+ const res = [];
29
+ res.push({
30
+ id: (0, uuid_1.v4)(),
31
+ statement: answer.toTex(),
32
+ isRightAnswer: true,
33
+ format: 'tex',
34
+ });
35
+ res.push({
36
+ id: (0, uuid_1.v4)(),
37
+ statement: prod.toTree().toTex(),
38
+ isRightAnswer: true,
39
+ format: 'tex',
40
+ });
41
+ const missing = n - res.length;
42
+ for (let i = 0; i < missing; i++) {
43
+ let isDuplicate;
44
+ let proposition;
45
+ do {
46
+ const wrongAnswer = complex_1.ComplexConstructor.random();
47
+ proposition = {
48
+ id: (0, uuid_1.v4)(),
49
+ statement: wrongAnswer.toTree().toTex(),
50
+ isRightAnswer: false,
51
+ format: 'tex',
52
+ };
53
+ isDuplicate = res.some((p) => p.statement === proposition.statement);
54
+ } while (isDuplicate);
55
+ res.push(proposition);
56
+ }
57
+ return (0, shuffle_1.shuffle)(res);
58
+ };
59
+ const question = {
60
+ answer: answer.toTex(),
61
+ instruction: `Soit $z=${z1.toTree().toTex()}$ et $z'=${z2.toTree().toTex()}$. Calculer $\\overline{z\\times z'}$.`,
62
+ keys: ['i', 'z', 'quote'],
63
+ getPropositions,
64
+ answerFormat: 'tex',
65
+ startStatement: "\\overline{z\\times z'}",
66
+ };
67
+ return question;
68
+ }
69
+ exports.getConjugateMultiplyComplexQuestion = getConjugateMultiplyComplexQuestion;
@@ -0,0 +1,4 @@
1
+ import { Exercise, Question } from '../../exercises/exercise';
2
+ export declare const divideComplex: Exercise;
3
+ export declare function getDivideComplexQuestion(): Question;
4
+ //# sourceMappingURL=divideComplex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"divideComplex.d.ts","sourceRoot":"","sources":["../../../src/exercises/complex/divideComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAM3E,eAAO,MAAM,aAAa,EAAE,QAS3B,CAAC;AAEF,wBAAgB,wBAAwB,IAAI,QAAQ,CAmDnD"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDivideComplexQuestion = exports.divideComplex = void 0;
4
+ const getDistinctQuestions_1 = require("../../exercises/utils/getDistinctQuestions");
5
+ const complex_1 = require("../../math/complex/complex");
6
+ const shuffle_1 = require("../../utils/shuffle");
7
+ const uuid_1 = require("uuid");
8
+ exports.divideComplex = {
9
+ id: 'divideComplex',
10
+ connector: '=',
11
+ instruction: '',
12
+ label: 'Diviser deux nombres complexes',
13
+ levels: ['MathExp'],
14
+ isSingleStep: true,
15
+ sections: ['Nombres complexes'],
16
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getDivideComplexQuestion, nb),
17
+ };
18
+ function getDivideComplexQuestion() {
19
+ const z1 = complex_1.ComplexConstructor.random();
20
+ let z2;
21
+ do {
22
+ z2 = complex_1.ComplexConstructor.random();
23
+ } while (z1.im === 0 && z2.im === 0);
24
+ const answerTex = z1.divideNode(z2).toTex();
25
+ const getPropositions = (n) => {
26
+ const res = [];
27
+ res.push({
28
+ id: (0, uuid_1.v4)(),
29
+ statement: answerTex,
30
+ isRightAnswer: true,
31
+ format: 'tex',
32
+ });
33
+ const missing = n - res.length;
34
+ for (let i = 0; i < missing; i++) {
35
+ let isDuplicate;
36
+ let proposition;
37
+ do {
38
+ const wrongAnswer = complex_1.ComplexConstructor.random();
39
+ proposition = {
40
+ id: (0, uuid_1.v4)() + '',
41
+ statement: wrongAnswer.toTree().toTex(),
42
+ isRightAnswer: false,
43
+ format: 'tex',
44
+ };
45
+ isDuplicate = res.some((p) => p.statement === proposition.statement);
46
+ } while (isDuplicate);
47
+ res.push(proposition);
48
+ }
49
+ return (0, shuffle_1.shuffle)(res);
50
+ };
51
+ const question = {
52
+ answer: answerTex,
53
+ instruction: `Soit $z=${z1.toTree().toTex()}$ et $z'=${z2.toTree().toTex()}$. Calculer $\\frac{z}{z'}$.`,
54
+ keys: ['i', 'z', 'quote'],
55
+ getPropositions,
56
+ answerFormat: 'tex',
57
+ startStatement: "\\frac{z}{z'}",
58
+ };
59
+ return question;
60
+ }
61
+ exports.getDivideComplexQuestion = getDivideComplexQuestion;
@@ -0,0 +1,4 @@
1
+ import { Exercise, Question } from '../../exercises/exercise';
2
+ export declare const inverseComplex: Exercise;
3
+ export declare function getInverseComplexQuestion(): Question;
4
+ //# sourceMappingURL=inverseComplex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inverseComplex.d.ts","sourceRoot":"","sources":["../../../src/exercises/complex/inverseComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAM3E,eAAO,MAAM,cAAc,EAAE,QAS5B,CAAC;AAEF,wBAAgB,yBAAyB,IAAI,QAAQ,CA6DpD"}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getInverseComplexQuestion = exports.inverseComplex = void 0;
4
+ const getDistinctQuestions_1 = require("../../exercises/utils/getDistinctQuestions");
5
+ const complex_1 = require("../../math/complex/complex");
6
+ const shuffle_1 = require("../../utils/shuffle");
7
+ const uuid_1 = require("uuid");
8
+ exports.inverseComplex = {
9
+ id: 'inverseComplex',
10
+ connector: '=',
11
+ instruction: '',
12
+ label: "Inverse d'un nombre complexe",
13
+ levels: ['MathExp'],
14
+ isSingleStep: true,
15
+ sections: ['Nombres complexes'],
16
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getInverseComplexQuestion, nb),
17
+ };
18
+ function getInverseComplexQuestion() {
19
+ const complex = complex_1.ComplexConstructor.randomNotReal();
20
+ const answer = complex.inverseNode().toTex();
21
+ const getPropositions = (n) => {
22
+ const res = [];
23
+ res.push({
24
+ id: (0, uuid_1.v4)(),
25
+ statement: answer,
26
+ isRightAnswer: true,
27
+ format: 'tex',
28
+ });
29
+ const opposite = complex.opposite().toTree().toTex();
30
+ if (opposite !== answer)
31
+ res.push({
32
+ id: (0, uuid_1.v4)(),
33
+ statement: opposite,
34
+ isRightAnswer: false,
35
+ format: 'tex',
36
+ });
37
+ const conj = complex.conjugate().toTree().toTex();
38
+ if (!res.some((prop) => prop.statement === conj))
39
+ res.push({
40
+ id: (0, uuid_1.v4)(),
41
+ statement: conj,
42
+ isRightAnswer: false,
43
+ format: 'tex',
44
+ });
45
+ const missing = n - res.length;
46
+ for (let i = 0; i < missing; i++) {
47
+ let isDuplicate;
48
+ let proposition;
49
+ do {
50
+ const wrongAnswer = complex_1.ComplexConstructor.random();
51
+ proposition = {
52
+ id: (0, uuid_1.v4)() + ``,
53
+ statement: wrongAnswer.toTree().toTex(),
54
+ isRightAnswer: false,
55
+ format: 'tex',
56
+ };
57
+ isDuplicate = res.some((p) => p.statement === proposition.statement);
58
+ } while (isDuplicate);
59
+ res.push(proposition);
60
+ }
61
+ return (0, shuffle_1.shuffle)(res);
62
+ };
63
+ const question = {
64
+ answer,
65
+ instruction: `Déterminer l'inverse de $z=${complex.toTree().toTex()}$.`,
66
+ keys: ['i'],
67
+ getPropositions,
68
+ answerFormat: 'tex',
69
+ startStatement: '\\frac{1}{z}',
70
+ };
71
+ return question;
72
+ }
73
+ exports.getInverseComplexQuestion = getInverseComplexQuestion;
@@ -0,0 +1,4 @@
1
+ import { Exercise, Question } from '../../exercises/exercise';
2
+ export declare const linearCombinaisonComplex: Exercise;
3
+ export declare function getLinearCombinaisonComplexQuestion(): Question;
4
+ //# sourceMappingURL=linearCombinaisonComplex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linearCombinaisonComplex.d.ts","sourceRoot":"","sources":["../../../src/exercises/complex/linearCombinaisonComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAc3E,eAAO,MAAM,wBAAwB,EAAE,QAStC,CAAC;AAEF,wBAAgB,mCAAmC,IAAI,QAAQ,CA0D9D"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLinearCombinaisonComplexQuestion = exports.linearCombinaisonComplex = void 0;
4
+ const getDistinctQuestions_1 = require("../../exercises/utils/getDistinctQuestions");
5
+ const complex_1 = require("../../math/complex/complex");
6
+ const randint_1 = require("../../math/utils/random/randint");
7
+ const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
8
+ const addNode_1 = require("../../tree/nodes/operators/addNode");
9
+ const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
10
+ const variableNode_1 = require("../../tree/nodes/variables/variableNode");
11
+ const simplify_1 = require("../../tree/parsers/simplify");
12
+ const shuffle_1 = require("../../utils/shuffle");
13
+ const uuid_1 = require("uuid");
14
+ exports.linearCombinaisonComplex = {
15
+ id: 'linearCombinaisonComplex',
16
+ connector: '=',
17
+ instruction: '',
18
+ label: 'Combinaison linéaire de deux nombres complexes',
19
+ levels: ['MathExp'],
20
+ isSingleStep: true,
21
+ sections: ['Nombres complexes'],
22
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getLinearCombinaisonComplexQuestion, nb),
23
+ };
24
+ function getLinearCombinaisonComplexQuestion() {
25
+ const z1 = complex_1.ComplexConstructor.random();
26
+ const z2 = complex_1.ComplexConstructor.random();
27
+ const a = (0, randint_1.randint)(-10, 11, [0]);
28
+ const b = (0, randint_1.randint)(-10, 11, [0]);
29
+ const statement = (0, simplify_1.simplifyNode)(new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(a), new variableNode_1.VariableNode('z_1')), new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(b), new variableNode_1.VariableNode('z_2'))));
30
+ // const statement = simplify(`${a}z+${b}z'`);
31
+ const answer = (0, simplify_1.simplifyComplex)(new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(a), z1.toTree()), new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(b), z2.toTree())));
32
+ const getPropositions = (n) => {
33
+ const res = [];
34
+ res.push({
35
+ id: (0, uuid_1.v4)(),
36
+ statement: answer.toTex(),
37
+ isRightAnswer: true,
38
+ format: 'tex',
39
+ });
40
+ const missing = n - res.length;
41
+ for (let i = 0; i < missing; i++) {
42
+ let isDuplicate;
43
+ let proposition;
44
+ do {
45
+ const wrongAnswer = complex_1.ComplexConstructor.random();
46
+ proposition = {
47
+ id: (0, uuid_1.v4)() + '',
48
+ statement: wrongAnswer.toTree().toTex(),
49
+ isRightAnswer: false,
50
+ format: 'tex',
51
+ };
52
+ isDuplicate = res.some((p) => p.statement === proposition.statement);
53
+ } while (isDuplicate);
54
+ res.push(proposition);
55
+ }
56
+ return (0, shuffle_1.shuffle)(res);
57
+ };
58
+ const question = {
59
+ answer: answer.toTex(),
60
+ instruction: `Soit $z_1=${z1.toTree().toTex()}$ et $z_2=${z2.toTree().toTex()}$. Calculer $${statement.toTex()}$.`,
61
+ keys: ['i', 'z', 'quote'],
62
+ getPropositions,
63
+ answerFormat: 'tex',
64
+ };
65
+ return question;
66
+ }
67
+ exports.getLinearCombinaisonComplexQuestion = getLinearCombinaisonComplexQuestion;
@@ -1 +1 @@
1
- {"version":3,"file":"mutiplyComplex.d.ts","sourceRoot":"","sources":["../../../src/exercises/complex/mutiplyComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAW3E,eAAO,MAAM,cAAc,EAAE,QAS5B,CAAC;AAEF,wBAAgB,yBAAyB,IAAI,QAAQ,CAsDpD"}
1
+ {"version":3,"file":"mutiplyComplex.d.ts","sourceRoot":"","sources":["../../../src/exercises/complex/mutiplyComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAM3E,eAAO,MAAM,cAAc,EAAE,QAS5B,CAAC;AAEF,wBAAgB,yBAAyB,IAAI,QAAQ,CA0DpD"}
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getMutiplyComplexQuestion = exports.mutiplyComplex = void 0;
4
4
  const getDistinctQuestions_1 = require("../../exercises/utils/getDistinctQuestions");
5
5
  const complex_1 = require("../../math/complex/complex");
6
- const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
7
- const simplify_1 = require("../../tree/parsers/simplify");
8
6
  const shuffle_1 = require("../../utils/shuffle");
9
7
  const uuid_1 = require("uuid");
10
8
  exports.mutiplyComplex = {
@@ -19,8 +17,11 @@ exports.mutiplyComplex = {
19
17
  };
20
18
  function getMutiplyComplexQuestion() {
21
19
  const z1 = complex_1.ComplexConstructor.random();
22
- const z2 = complex_1.ComplexConstructor.random();
23
- const answer = (0, simplify_1.simplifyComplex)(new multiplyNode_1.MultiplyNode(z1.toTree(), z2.toTree()));
20
+ let z2;
21
+ do {
22
+ z2 = complex_1.ComplexConstructor.random();
23
+ } while (z1.im === 0 && z2.im === 0);
24
+ const answer = z1.multiply(z2).toTree();
24
25
  const getPropositions = (n) => {
25
26
  const res = [];
26
27
  res.push({
@@ -59,6 +60,7 @@ function getMutiplyComplexQuestion() {
59
60
  keys: ['i', 'z', 'quote'],
60
61
  getPropositions,
61
62
  answerFormat: 'tex',
63
+ startStatement: "z\\times z'",
62
64
  };
63
65
  return question;
64
66
  }
@@ -1 +1 @@
1
- {"version":3,"file":"exercises.d.ts","sourceRoot":"","sources":["../../src/exercises/exercises.ts"],"names":[],"mappings":"AAyJA,eAAO,MAAM,SAAS,iCA2MrB,CAAC"}
1
+ {"version":3,"file":"exercises.d.ts","sourceRoot":"","sources":["../../src/exercises/exercises.ts"],"names":[],"mappings":"AA8JA,eAAO,MAAM,SAAS,iCAmNrB,CAAC"}
@@ -111,10 +111,7 @@ const logEquation_1 = require("./calculLitteral/equation/logEquation");
111
111
  const expEquation_1 = require("./calculLitteral/equation/expEquation");
112
112
  const expSimplifiying_1 = require("./calculLitteral/simplifying/expSimplifiying");
113
113
  const logSimplifiying_1 = require("./calculLitteral/simplifying/logSimplifiying");
114
- const frequencyTable_1 = require("../exercises/probaStat/frequencyTable");
115
- const median_1 = require("../exercises/probaStat/median");
116
114
  const quartiles_1 = require("../exercises/probaStat/quartiles");
117
- const medianList_1 = require("../exercises/probaStat/medianList");
118
115
  const quartilesList_1 = require("../exercises/probaStat/quartilesList");
119
116
  const euclideanDivision_1 = require("../exercises/calcul/arithmetics/euclideanDivision");
120
117
  const thirdDegreeFunctionVariation_1 = require("../exercises/derivation/derivative/thirdDegreeFunctionVariation");
@@ -144,6 +141,14 @@ const variationsFromAlgebricForm_1 = require("./functions/trinoms/variationsFrom
144
141
  const mutiplyComplex_1 = require("./complex/mutiplyComplex");
145
142
  const reAndIm_1 = require("./complex/reAndIm");
146
143
  const addComplex_1 = require("./complex/addComplex");
144
+ const averageWithTable_1 = require("./probaStat/averageWithTable");
145
+ const medianList_1 = require("./probaStat/medianList");
146
+ const median_1 = require("./probaStat/median");
147
+ const conjugateComplex_ts_1 = require("./complex/conjugateComplex.ts");
148
+ const conjugateMultiplyComplex_1 = require("./complex/conjugateMultiplyComplex");
149
+ const inverseComplex_1 = require("./complex/inverseComplex");
150
+ const divideComplex_1 = require("./complex/divideComplex");
151
+ const conjugateDivideComplex_1 = require("./complex/conjugateDivideComplex");
147
152
  exports.exercises = [
148
153
  /**
149
154
  * calcul litteral
@@ -305,11 +310,6 @@ exports.exercises = [
305
310
  logSimplifiying_1.logSimplifiying,
306
311
  imageFunctionGeogebra_1.imageFunctionGeogebra,
307
312
  inverseImageFunctionGeogebra_1.inverseImageFunctionGeogebra,
308
- frequencyTable_1.frequencyTable,
309
- median_1.median,
310
- quartiles_1.quartiles,
311
- medianList_1.medianList,
312
- quartilesList_1.quartilesList,
313
313
  euclideanDivision_1.euclideanDivision,
314
314
  signFunction_1.signFunction,
315
315
  thirdDegreeFunctionVariation_1.thirdDegreeFunctionVariation,
@@ -322,6 +322,12 @@ exports.exercises = [
322
322
  usualPrimitives_1.usualPrimitives,
323
323
  equaDiffGeneralForme_1.exponentialDifferentialEquation,
324
324
  equaDiffGeneralFormeWithIC_1.exponentialDifferentialEquationWithIC,
325
+ /**Stats */
326
+ averageWithTable_1.averageWithTable,
327
+ medianList_1.medianWithList,
328
+ quartiles_1.quartiles,
329
+ median_1.medianWithTable,
330
+ quartilesList_1.quartilesList,
325
331
  /**Trinomes */
326
332
  alphaBetaInCanonicalForm_1.alphaBetaInCanonicalForm,
327
333
  canonicalFromDevForm_1.canonicalFromDevForm,
@@ -333,4 +339,9 @@ exports.exercises = [
333
339
  mutiplyComplex_1.mutiplyComplex,
334
340
  reAndIm_1.reAndIm,
335
341
  addComplex_1.addComplex,
342
+ conjugateComplex_ts_1.conjugateComplex,
343
+ conjugateMultiplyComplex_1.conjugateMultiplyComplex,
344
+ inverseComplex_1.inverseComplex,
345
+ divideComplex_1.divideComplex,
346
+ conjugateDivideComplex_1.conjugateDivideComplex,
336
347
  ];
@@ -0,0 +1,4 @@
1
+ import { Exercise, Question } from '../exercise';
2
+ export declare const averageWithTable: Exercise;
3
+ export declare function getAverageWithTableQuestion(): Question;
4
+ //# sourceMappingURL=averageWithTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"averageWithTable.d.ts","sourceRoot":"","sources":["../../../src/exercises/probaStat/averageWithTable.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI9D,eAAO,MAAM,gBAAgB,EAAE,QAU9B,CAAC;AAEF,wBAAgB,2BAA2B,IAAI,QAAQ,CAsEtD"}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAverageWithTableQuestion = exports.averageWithTable = void 0;
4
+ const randint_1 = require("../../math/utils/random/randint");
5
+ const round_1 = require("../../math/utils/round");
6
+ const shuffle_1 = require("../../utils/shuffle");
7
+ const getDistinctQuestions_1 = require("../utils/getDistinctQuestions");
8
+ const uuid_1 = require("uuid");
9
+ exports.averageWithTable = {
10
+ id: 'averageWithTable',
11
+ connector: '=',
12
+ instruction: '',
13
+ label: "Calcul de la moyenne d'un tableau d'effectifs",
14
+ levels: ['3ème', '2nde'],
15
+ isSingleStep: false,
16
+ sections: ['Statistiques'],
17
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getAverageWithTableQuestion, nb),
18
+ keys: [],
19
+ };
20
+ function getAverageWithTableQuestion() {
21
+ const getRandomUniqueValues = (count, min, max) => {
22
+ const uniqueValues = new Set();
23
+ while (uniqueValues.size < count) {
24
+ uniqueValues.add((0, randint_1.randint)(min, max));
25
+ }
26
+ return Array.from(uniqueValues).sort((a, b) => a - b);
27
+ };
28
+ const randomValeurs = getRandomUniqueValues(5, 1, 20);
29
+ const randomEffectives = [1, 2, 3, 4, 5].map((el) => (0, randint_1.randint)(1, 6));
30
+ const sumEffectives = randomEffectives.reduce((sum, value) => sum + value, 0);
31
+ let average = 0;
32
+ for (let i = 0; i < randomValeurs.length; i++)
33
+ average += randomValeurs[i] * randomEffectives[i];
34
+ average /= sumEffectives;
35
+ average = (0, round_1.round)(average, 2);
36
+ const getPropositions = (n) => {
37
+ const res = [];
38
+ res.push({
39
+ id: (0, uuid_1.v4)() + '',
40
+ statement: average + '',
41
+ isRightAnswer: true,
42
+ format: 'tex',
43
+ });
44
+ for (let i = 0; i < n - 1; i++) {
45
+ let isDuplicate;
46
+ let proposition;
47
+ do {
48
+ proposition = {
49
+ id: (0, uuid_1.v4)() + '',
50
+ statement: (0, round_1.round)(average + (0, randint_1.randint)(-average, 20 - average, [0]) + (0, randint_1.randint)(1, 100) / 100, 2) + '',
51
+ isRightAnswer: false,
52
+ format: 'tex',
53
+ };
54
+ isDuplicate = res.some((p) => p.statement === proposition.statement);
55
+ } while (isDuplicate);
56
+ res.push(proposition);
57
+ }
58
+ return (0, shuffle_1.shuffle)(res);
59
+ };
60
+ const question = {
61
+ instruction: `On considère le tableau d'effectifs suivant :
62
+
63
+ | | | | | | |
64
+ |-|-|-|-|-|-|
65
+ |Valeur|${randomValeurs[0]}|${randomValeurs[1]}|${randomValeurs[2]}|${randomValeurs[3]}|${randomValeurs[4]}|
66
+ |Effectif|${randomEffectives[0]}|${randomEffectives[1]}|${randomEffectives[2]}|${randomEffectives[3]}|${randomEffectives[4]}|
67
+
68
+ Calculer la moyenne de cette série de valeurs.`,
69
+ answer: average + '',
70
+ keys: [],
71
+ getPropositions,
72
+ answerFormat: 'tex',
73
+ };
74
+ return question;
75
+ }
76
+ exports.getAverageWithTableQuestion = getAverageWithTableQuestion;
@@ -1,4 +1,4 @@
1
1
  import { Exercise, Question } from '../exercise';
2
- export declare const median: Exercise;
3
- export declare function getMedian(): Question;
2
+ export declare const medianWithTable: Exercise;
3
+ export declare function getMedianWithTable(): Question;
4
4
  //# sourceMappingURL=median.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"median.d.ts","sourceRoot":"","sources":["../../../src/exercises/probaStat/median.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI9D,eAAO,MAAM,MAAM,EAAE,QAUpB,CAAC;AAEF,wBAAgB,SAAS,IAAI,QAAQ,CA8EpC"}
1
+ {"version":3,"file":"median.d.ts","sourceRoot":"","sources":["../../../src/exercises/probaStat/median.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI9D,eAAO,MAAM,eAAe,EAAE,QAU7B,CAAC;AAEF,wBAAgB,kBAAkB,IAAI,QAAQ,CA8E7C"}
@@ -1,22 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMedian = exports.median = void 0;
3
+ exports.getMedianWithTable = exports.medianWithTable = void 0;
4
4
  const randint_1 = require("../../math/utils/random/randint");
5
5
  const shuffle_1 = require("../../utils/shuffle");
6
6
  const getDistinctQuestions_1 = require("../utils/getDistinctQuestions");
7
7
  const uuid_1 = require("uuid");
8
- exports.median = {
9
- id: 'median',
8
+ exports.medianWithTable = {
9
+ id: 'medianWithTable',
10
10
  connector: '=',
11
11
  instruction: '',
12
- label: "Calcul de la moyenne d'une série de valeurs",
12
+ label: "Calcul de la médiane d'un tableau d'effectifs",
13
13
  levels: ['3ème', '2nde'],
14
14
  isSingleStep: false,
15
15
  sections: ['Statistiques'],
16
- generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getMedian, nb),
16
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getMedianWithTable, nb),
17
17
  keys: [],
18
18
  };
19
- function getMedian() {
19
+ function getMedianWithTable() {
20
20
  const getRandomUniqueValues = (count, min, max) => {
21
21
  const uniqueValues = new Set();
22
22
  while (uniqueValues.size < count) {
@@ -79,4 +79,4 @@ Calculer la médiane de cette série de valeurs.`,
79
79
  };
80
80
  return question;
81
81
  }
82
- exports.getMedian = getMedian;
82
+ exports.getMedianWithTable = getMedianWithTable;
@@ -1,4 +1,4 @@
1
1
  import { Exercise, Question } from '../exercise';
2
- export declare const medianList: Exercise;
3
- export declare function getMedian(): Question;
2
+ export declare const medianWithList: Exercise;
3
+ export declare function getMedianList(): Question;
4
4
  //# sourceMappingURL=medianList.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"medianList.d.ts","sourceRoot":"","sources":["../../../src/exercises/probaStat/medianList.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI9D,eAAO,MAAM,UAAU,EAAE,QAUxB,CAAC;AAEF,wBAAgB,SAAS,IAAI,QAAQ,CA4DpC"}
1
+ {"version":3,"file":"medianList.d.ts","sourceRoot":"","sources":["../../../src/exercises/probaStat/medianList.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI9D,eAAO,MAAM,cAAc,EAAE,QAU5B,CAAC;AAEF,wBAAgB,aAAa,IAAI,QAAQ,CA4DxC"}
@@ -1,22 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMedian = exports.medianList = void 0;
3
+ exports.getMedianList = exports.medianWithList = void 0;
4
4
  const randint_1 = require("../../math/utils/random/randint");
5
5
  const shuffle_1 = require("../../utils/shuffle");
6
6
  const getDistinctQuestions_1 = require("../utils/getDistinctQuestions");
7
7
  const uuid_1 = require("uuid");
8
- exports.medianList = {
9
- id: 'medianList',
8
+ exports.medianWithList = {
9
+ id: 'medianWithList',
10
10
  connector: '=',
11
11
  instruction: '',
12
12
  label: "Calcul de la médiane d'une liste de valeurs",
13
13
  levels: ['3ème', '2nde'],
14
14
  isSingleStep: false,
15
15
  sections: ['Statistiques'],
16
- generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getMedian, nb),
16
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getMedianList, nb),
17
17
  keys: ['f', 'cap', 'underscore'],
18
18
  };
19
- function getMedian() {
19
+ function getMedianList() {
20
20
  let randomValeurs = [];
21
21
  const length = (0, randint_1.randint)(6, 10);
22
22
  for (let i = 0; i < length; i++)
@@ -64,4 +64,4 @@ function getMedian() {
64
64
  };
65
65
  return question;
66
66
  }
67
- exports.getMedian = getMedian;
67
+ exports.getMedianList = getMedianList;
@@ -9,7 +9,7 @@ exports.quartiles = {
9
9
  id: 'quartiles',
10
10
  connector: '=',
11
11
  instruction: '',
12
- label: "Calcul des quartiles d'une série de valeurs",
12
+ label: "Calcul des quartiles d'un tableau d'effectifs",
13
13
  levels: ['3ème', '2nde'],
14
14
  isSingleStep: false,
15
15
  sections: ['Statistiques'],
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=arithmeticSum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arithmeticSum.d.ts","sourceRoot":"","sources":["../../../../src/exercises/sequences/arithmetic/arithmeticSum.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ "use strict";
@@ -1,11 +1,18 @@
1
1
  import { ComplexNode } from '../../tree/nodes/complex/complexNode';
2
+ import { AddNode } from '../../tree/nodes/operators/addNode';
2
3
  export declare abstract class ComplexConstructor {
3
4
  static random(): Complex;
5
+ static randomNotReal(): Complex;
4
6
  }
5
7
  export declare class Complex {
6
8
  re: number;
7
9
  im: number;
8
10
  constructor(re: number, im: number);
11
+ moduleSquared(): number;
12
+ inverseNode(): AddNode;
13
+ divideNode(z: Complex): AddNode;
14
+ multiply(z: Complex): Complex;
15
+ opposite(): Complex;
9
16
  conjugate(): Complex;
10
17
  toTree(): ComplexNode;
11
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"complex.d.ts","sourceRoot":"","sources":["../../../src/math/complex/complex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAGnE,8BAAsB,kBAAkB;IACtC,MAAM,CAAC,MAAM;CAGd;AACD,qBAAa,OAAO;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;gBACC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IAIlC,SAAS;IAGT,MAAM;CAGP"}
1
+ {"version":3,"file":"complex.d.ts","sourceRoot":"","sources":["../../../src/math/complex/complex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAO7D,8BAAsB,kBAAkB;IACtC,MAAM,CAAC,MAAM;IAQb,MAAM,CAAC,aAAa;CAQrB;AACD,qBAAa,OAAO;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;gBACC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IAIlC,aAAa;IAIb,WAAW;IAQX,UAAU,CAAC,CAAC,EAAE,OAAO;IAOrB,QAAQ,CAAC,CAAC,EAAE,OAAO;IAGnB,QAAQ;IAGR,SAAS;IAGT,MAAM;CAGP"}
@@ -2,10 +2,27 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Complex = exports.ComplexConstructor = void 0;
4
4
  const complexNode_1 = require("../../tree/nodes/complex/complexNode");
5
+ const addNode_1 = require("../../tree/nodes/operators/addNode");
6
+ const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
7
+ const variableNode_1 = require("../../tree/nodes/variables/variableNode");
8
+ const rational_1 = require("../numbers/rationals/rational");
5
9
  const randint_1 = require("../utils/random/randint");
6
10
  class ComplexConstructor {
7
11
  static random() {
8
- return new Complex((0, randint_1.randint)(-10, 11), (0, randint_1.randint)(-10, 11));
12
+ const re = (0, randint_1.randint)(-10, 11);
13
+ let im = 0;
14
+ do {
15
+ im = (0, randint_1.randint)(-10, 11);
16
+ } while (re === 0 && im === 0);
17
+ return new Complex(re, im);
18
+ }
19
+ static randomNotReal() {
20
+ const re = (0, randint_1.randint)(-10, 11);
21
+ let im = 0;
22
+ do {
23
+ im = (0, randint_1.randint)(-10, 11, [0]);
24
+ } while (re === 0 && im === 0);
25
+ return new Complex(re, im);
9
26
  }
10
27
  }
11
28
  exports.ComplexConstructor = ComplexConstructor;
@@ -14,6 +31,28 @@ class Complex {
14
31
  this.re = re;
15
32
  this.im = im;
16
33
  }
34
+ moduleSquared() {
35
+ return this.re ** 2 + this.im ** 2;
36
+ }
37
+ inverseNode() {
38
+ const moduleSq = this.moduleSquared();
39
+ const conj = this.conjugate();
40
+ const invRe = new rational_1.Rational(conj.re, moduleSq).simplify().toTree();
41
+ const invIm = new rational_1.Rational(conj.im, moduleSq).simplify().toTree();
42
+ return new addNode_1.AddNode(invRe, new multiplyNode_1.MultiplyNode(invIm, new variableNode_1.VariableNode('i')));
43
+ }
44
+ divideNode(z) {
45
+ const moduleSq = z.moduleSquared();
46
+ const newRe = new rational_1.Rational(this.re * z.re + this.im * z.im, moduleSq).simplify().toTree();
47
+ const newIm = new rational_1.Rational(this.im * z.re - z.im * this.re, moduleSq).simplify().toTree();
48
+ return new addNode_1.AddNode(newRe, new multiplyNode_1.MultiplyNode(newIm, new variableNode_1.VariableNode('i')));
49
+ }
50
+ multiply(z) {
51
+ return new Complex(this.re * z.re - this.im * z.im, this.re * z.im + this.im * z.re);
52
+ }
53
+ opposite() {
54
+ return new Complex(-this.re, -this.im);
55
+ }
17
56
  conjugate() {
18
57
  return new Complex(this.re, -this.im);
19
58
  }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=expressionNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expressionNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/expression/expressionNode.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ "use strict";
@@ -7,6 +7,6 @@ export declare class NumberNode implements Node {
7
7
  constructor(value: number, tex?: string, mathString?: string);
8
8
  toMathString(): string;
9
9
  toTex(): string;
10
- toMathjs(): import("mathjs").MathNode;
10
+ toMathjs(): string;
11
11
  }
12
12
  //# sourceMappingURL=numberNode.d.ts.map
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NumberNode = void 0;
4
- const mathjs_1 = require("mathjs");
5
4
  const node_1 = require("../node");
6
5
  class NumberNode {
7
6
  constructor(value, tex, mathString) {
@@ -17,7 +16,7 @@ class NumberNode {
17
16
  return `${this.tex}`;
18
17
  }
19
18
  toMathjs() {
20
- return (0, mathjs_1.parse)(this.toMathString());
19
+ return this.toMathString();
21
20
  }
22
21
  }
23
22
  exports.NumberNode = NumberNode;
@@ -1 +1 @@
1
- {"version":3,"file":"multiplyNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/multiplyNode.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAY,MAAM,SAAS,CAAC;AACzC,OAAO,EAAe,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE3D,qBAAa,YAAa,SAAQ,YAAa,YAAW,IAAI;gBAChD,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI;IAY7C,YAAY,IAAI,MAAM;IAItB,KAAK,IAAI,MAAM;IA8Bf,QAAQ;CAGT"}
1
+ {"version":3,"file":"multiplyNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/multiplyNode.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAY,MAAM,SAAS,CAAC;AACzC,OAAO,EAAe,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE3D,qBAAa,YAAa,SAAQ,YAAa,YAAW,IAAI;gBAChD,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI;IAY7C,YAAY,IAAI,MAAM;IAItB,KAAK,IAAI,MAAM;IAoCf,QAAQ;CAGT"}
@@ -21,6 +21,11 @@ class MultiplyNode extends operatorNode_1.OperatorNode {
21
21
  toTex() {
22
22
  let leftTex = this.leftChild.toTex();
23
23
  let rightTex = this.rightChild.toTex();
24
+ if (this.rightChild.type === node_1.NodeType.variable) {
25
+ if (leftTex === '1') {
26
+ return rightTex;
27
+ }
28
+ }
24
29
  if (this.leftChild.type === node_1.NodeType.operator) {
25
30
  if ([operatorNode_1.OperatorIds.add, operatorNode_1.OperatorIds.substract, operatorNode_1.OperatorIds.divide].includes(this.leftChild.id))
26
31
  leftTex = `(${leftTex})`;
@@ -5,6 +5,6 @@ export declare class VariableNode implements Node {
5
5
  constructor(name: string);
6
6
  toTex(): string;
7
7
  toMathString(): string;
8
- toMathjs(): import("mathjs").MathNode;
8
+ toMathjs(): string;
9
9
  }
10
10
  //# sourceMappingURL=variableNode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"variableNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/variables/variableNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEzC,qBAAa,YAAa,YAAW,IAAI;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,WAAqB;gBAEb,IAAI,EAAE,MAAM;IAKxB,KAAK,IAAI,MAAM;IAGf,YAAY,IAAI,MAAM;IAGtB,QAAQ;CAMT"}
1
+ {"version":3,"file":"variableNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/variables/variableNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEzC,qBAAa,YAAa,YAAW,IAAI;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,WAAqB;gBAEb,IAAI,EAAE,MAAM;IAIxB,KAAK,IAAI,MAAM;IAGf,YAAY,IAAI,MAAM;IAGtB,QAAQ;CAMT"}
@@ -1,13 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VariableNode = void 0;
4
- const mathjs_1 = require("mathjs");
5
4
  const node_1 = require("../node");
6
5
  class VariableNode {
7
6
  constructor(name) {
8
7
  this.type = node_1.NodeType.variable;
9
- if (name.length !== 1 || !name.match('[a-zA-Z]'))
10
- throw Error('variable must be a letter');
11
8
  this.name = name;
12
9
  }
13
10
  toTex() {
@@ -17,7 +14,7 @@ class VariableNode {
17
14
  return `${this.name}`;
18
15
  }
19
16
  toMathjs() {
20
- return (0, mathjs_1.parse)(this.name);
17
+ return this.name;
21
18
  }
22
19
  }
23
20
  exports.VariableNode = VariableNode;
@@ -68,5 +68,6 @@ const mathjsNodeToNode = (mathjsNode) => {
68
68
  return new sinNode_1.SinNode(mathjsNodeToNode(mathjsNode.args[0]));
69
69
  }
70
70
  }
71
+ console.log(mathjsNode);
71
72
  throw Error('unrecognized mathjs node');
72
73
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "math-exercises",
3
- "version": "1.3.50",
3
+ "version": "1.3.52",
4
4
  "description": "Math exercises generator for middle school and high school",
5
5
  "main": "lib/index.js",
6
6
  "files": [