math-exercises 2.2.59 → 2.2.60

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 (64) hide show
  1. package/lib/exercises/exercise.d.ts +2 -0
  2. package/lib/exercises/exercise.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/fractions/fractionAndIntegerDivision.d.ts +1 -1
  4. package/lib/exercises/math/calcul/fractions/fractionAndIntegerDivision.d.ts.map +1 -1
  5. package/lib/exercises/math/calcul/fractions/fractionAndIntegerDivision.js +75 -37
  6. package/lib/exercises/math/calcul/fractions/fractionAndIntegerProduct.d.ts +6 -2
  7. package/lib/exercises/math/calcul/fractions/fractionAndIntegerProduct.d.ts.map +1 -1
  8. package/lib/exercises/math/calcul/fractions/fractionAndIntegerProduct.js +88 -40
  9. package/lib/exercises/math/calcul/fractions/fractionAndIntegerSum.d.ts +4 -1
  10. package/lib/exercises/math/calcul/fractions/fractionAndIntegerSum.d.ts.map +1 -1
  11. package/lib/exercises/math/calcul/fractions/fractionAndIntegerSum.js +23 -5
  12. package/lib/exercises/math/calcul/fractions/fractionsDivision.d.ts.map +1 -1
  13. package/lib/exercises/math/calcul/fractions/fractionsDivision.js +24 -6
  14. package/lib/exercises/math/calcul/fractions/fractionsProduct.d.ts +4 -1
  15. package/lib/exercises/math/calcul/fractions/fractionsProduct.d.ts.map +1 -1
  16. package/lib/exercises/math/calcul/fractions/fractionsProduct.js +24 -6
  17. package/lib/exercises/math/calcul/fractions/fractionsSum.d.ts +2 -2
  18. package/lib/exercises/math/calcul/fractions/fractionsSum.d.ts.map +1 -1
  19. package/lib/exercises/math/calcul/fractions/fractionsSum.js +20 -11
  20. package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.js +1 -1
  21. package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.js +1 -1
  22. package/lib/exercises/math/calcul/fractions/fractionsSumsSameDenominators.js +2 -2
  23. package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.d.ts +7 -2
  24. package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.d.ts.map +1 -1
  25. package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.js +52 -44
  26. package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.d.ts +7 -2
  27. package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.d.ts.map +1 -1
  28. package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.js +48 -40
  29. package/lib/exercises/math/functions/affines/signFunction.js +1 -1
  30. package/lib/exercises/math/functions/trinoms/factorizedFormFromRoots.d.ts.map +1 -1
  31. package/lib/exercises/math/functions/trinoms/factorizedFormFromRoots.js +1 -0
  32. package/lib/exercises/math/spaceGeometry/lineAndPlaneRelativePosition.d.ts +1 -0
  33. package/lib/exercises/math/spaceGeometry/lineAndPlaneRelativePosition.d.ts.map +1 -0
  34. package/lib/exercises/math/spaceGeometry/lineAndPlaneRelativePosition.js +84 -0
  35. package/lib/exercises/math/squareRoots/index.d.ts +2 -0
  36. package/lib/exercises/math/squareRoots/index.d.ts.map +1 -1
  37. package/lib/exercises/math/squareRoots/index.js +2 -0
  38. package/lib/exercises/math/squareRoots/squareRootsFractions.d.ts +10 -0
  39. package/lib/exercises/math/squareRoots/squareRootsFractions.d.ts.map +1 -0
  40. package/lib/exercises/math/squareRoots/squareRootsFractions.js +93 -0
  41. package/lib/exercises/math/squareRoots/squareRootsToSquare.d.ts +10 -0
  42. package/lib/exercises/math/squareRoots/squareRootsToSquare.d.ts.map +1 -0
  43. package/lib/exercises/math/squareRoots/squareRootsToSquare.js +116 -0
  44. package/lib/exercises/math/trigonometry/mainAngleMeasure.js +13 -13
  45. package/lib/index.d.ts +35 -11
  46. package/lib/index.d.ts.map +1 -1
  47. package/lib/math/numbers/reals/extendedRingElement.d.ts +1 -1
  48. package/lib/playground.d.ts.map +1 -1
  49. package/lib/playground.js +8 -1
  50. package/lib/tree/nodes/functions/absNode.d.ts +1 -1
  51. package/lib/tree/nodes/functions/absNode.d.ts.map +1 -1
  52. package/lib/tree/nodes/functions/absNode.js +9 -1
  53. package/lib/tree/nodes/functions/sqrtNode.d.ts.map +1 -1
  54. package/lib/tree/nodes/functions/sqrtNode.js +9 -0
  55. package/lib/tree/nodes/operators/operatorNode.d.ts +2 -1
  56. package/lib/tree/nodes/operators/operatorNode.d.ts.map +1 -1
  57. package/lib/tree/nodes/operators/operatorNode.js +1 -0
  58. package/lib/tree/nodes/operators/powerNode.d.ts +1 -0
  59. package/lib/tree/nodes/operators/powerNode.d.ts.map +1 -1
  60. package/lib/tree/nodes/operators/powerNode.js +12 -83
  61. package/lib/tree/parsers/rationalParser.d.ts +1 -1
  62. package/lib/tree/parsers/rationalParser.d.ts.map +1 -1
  63. package/lib/tree/parsers/rationalParser.js +13 -8
  64. package/package.json +1 -1
@@ -0,0 +1,10 @@
1
+ import { Exercise } from "../../../exercises/exercise";
2
+ type Identifiers = {
3
+ a: number;
4
+ b: number;
5
+ c: number;
6
+ d: number;
7
+ };
8
+ export declare const squareRootsFractions: Exercise<Identifiers>;
9
+ export {};
10
+ //# sourceMappingURL=squareRootsFractions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"squareRootsFractions.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/squareRoots/squareRootsFractions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AAUlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA8EF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAetD,CAAC"}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.squareRootsFractions = void 0;
4
+ const exercise_1 = require("../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
6
+ const rational_1 = require("../../../math/numbers/rationals/rational");
7
+ const randint_1 = require("../../../math/utils/random/randint");
8
+ const sqrtNode_1 = require("../../../tree/nodes/functions/sqrtNode");
9
+ const fractionNode_1 = require("../../../tree/nodes/operators/fractionNode");
10
+ const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
11
+ const rationalParser_1 = require("../../../tree/parsers/rationalParser");
12
+ const coinFlip_1 = require("../../../utils/alea/coinFlip");
13
+ const getPropositions = (n, { answer }) => {
14
+ const propositions = [];
15
+ (0, exercise_1.addValidProp)(propositions, answer);
16
+ while (propositions.length < n) {
17
+ (0, exercise_1.tryToAddWrongProp)(propositions, rational_1.RationalConstructor.randomIrreductible().toTree().toTex());
18
+ }
19
+ return (0, exercise_1.shuffleProps)(propositions, n);
20
+ };
21
+ const getAnswer = (identifiers) => {
22
+ const { a, b, c, d } = identifiers;
23
+ return (0, fractionNode_1.frac)((0, multiplyNode_1.multiply)(a, (0, sqrtNode_1.sqrt)(b)), (0, multiplyNode_1.multiply)(c, (0, sqrtNode_1.sqrt)(d)))
24
+ .simplify()
25
+ .toTex();
26
+ };
27
+ const getInstruction = (identifiers) => {
28
+ const { a, b, c, d } = identifiers;
29
+ return `Simplifier au maximum :
30
+
31
+ $$
32
+ ${(0, fractionNode_1.frac)((0, multiplyNode_1.multiply)(a, (0, sqrtNode_1.sqrt)(b)), (0, multiplyNode_1.multiply)(c, (0, sqrtNode_1.sqrt)(d))).toTex()}
33
+ $$`;
34
+ };
35
+ // const getHint: GetHint<Identifiers> = (identifiers) => {};
36
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
37
+ const getKeys = (identifiers) => {
38
+ return [];
39
+ };
40
+ const isAnswerValid = (ans, { answer }) => {
41
+ const parsed = (0, rationalParser_1.rationalParser)(ans);
42
+ if (!parsed)
43
+ return false;
44
+ return parsed.simplify().toTex() === answer;
45
+ };
46
+ // a/√b + c/√d
47
+ // avec b/d = q^2 ou b/d = 1/q^2
48
+ const getSquareRootsFractionsQuestion = () => {
49
+ const a = (0, randint_1.randint)(-10, 10, [0]);
50
+ const c = (0, randint_1.randint)(-10, 10, [0]);
51
+ const q = (0, randint_1.randint)(2, 10);
52
+ let b;
53
+ let d;
54
+ if ((0, coinFlip_1.coinFlip)()) {
55
+ d = (0, randint_1.randint)(2, 10);
56
+ b = d * q ** 2;
57
+ }
58
+ else {
59
+ b = (0, randint_1.randint)(2, 10);
60
+ d = b * q ** 2;
61
+ }
62
+ const identifiers = {
63
+ a,
64
+ b,
65
+ c,
66
+ d,
67
+ };
68
+ const question = {
69
+ answer: getAnswer(identifiers),
70
+ instruction: getInstruction(identifiers),
71
+ keys: getKeys(identifiers),
72
+ answerFormat: "tex",
73
+ identifiers,
74
+ // hint: getHint(identifiers),
75
+ // correction: getCorrection(identifiers),
76
+ };
77
+ return question;
78
+ };
79
+ exports.squareRootsFractions = {
80
+ id: "squareRootsFractions",
81
+ connector: "=",
82
+ label: "Fractions de racines carrées",
83
+ isSingleStep: true,
84
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getSquareRootsFractionsQuestion, nb),
85
+ qcmTimer: 60,
86
+ freeTimer: 60,
87
+ getPropositions,
88
+ isAnswerValid,
89
+ subject: "Mathématiques",
90
+ // getHint,
91
+ // getCorrection,
92
+ getAnswer,
93
+ };
@@ -0,0 +1,10 @@
1
+ import { Exercise } from "../../../exercises/exercise";
2
+ import { NodeIdentifiers } from "../../../tree/nodes/nodeConstructor";
3
+ type Identifiers = {
4
+ a: number;
5
+ k: NodeIdentifiers;
6
+ isSquareInside: boolean;
7
+ };
8
+ export declare const squareRootsToSquare: Exercise<Identifiers>;
9
+ export {};
10
+ //# sourceMappingURL=squareRootsToSquare.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"squareRootsToSquare.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/squareRoots/squareRootsToSquare.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAEL,eAAe,EAChB,MAAM,kCAAkC,CAAC;AAO1C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,eAAe,CAAC;IACnB,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAmHF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAgBrD,CAAC"}
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.squareRootsToSquare = void 0;
4
+ const exercise_1 = require("../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
6
+ const rational_1 = require("../../../math/numbers/rationals/rational");
7
+ const randint_1 = require("../../../math/utils/random/randint");
8
+ const oppositeNode_1 = require("../../../tree/nodes/functions/oppositeNode");
9
+ const sqrtNode_1 = require("../../../tree/nodes/functions/sqrtNode");
10
+ const nodeConstructor_1 = require("../../../tree/nodes/nodeConstructor");
11
+ const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
12
+ const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
13
+ const powerNode_1 = require("../../../tree/nodes/operators/powerNode");
14
+ const rationalParser_1 = require("../../../tree/parsers/rationalParser");
15
+ const coinFlip_1 = require("../../../utils/alea/coinFlip");
16
+ const getPropositions = (n, { answer, a, isSquareInside, k }) => {
17
+ const propositions = [];
18
+ (0, exercise_1.addValidProp)(propositions, answer);
19
+ const kNode = nodeConstructor_1.NodeConstructor.fromIdentifiers(k);
20
+ if (kNode.evaluate() < 0) {
21
+ (0, exercise_1.tryToAddWrongProp)(propositions, (0, oppositeNode_1.opposite)(getAnswerNode({ a, k, isSquareInside })).toTex());
22
+ }
23
+ if (isSquareInside) {
24
+ }
25
+ else {
26
+ (0, exercise_1.tryToAddWrongProp)(propositions, (0, multiplyNode_1.multiply)(a ** 2, (0, sqrtNode_1.sqrt)(kNode))
27
+ .simplify()
28
+ .toTex());
29
+ (0, exercise_1.tryToAddWrongProp)(propositions, (0, multiplyNode_1.multiply)(a, kNode).simplify().toTex());
30
+ }
31
+ while (propositions.length < n) {
32
+ (0, exercise_1.tryToAddWrongProp)(propositions, (0, numberNode_1.isNumberNode)(kNode)
33
+ ? (0, randint_1.randint)(2, 100).frenchify()
34
+ : rational_1.RationalConstructor.randomIrreductible().toTree().toTex());
35
+ }
36
+ return (0, exercise_1.shuffleProps)(propositions, n);
37
+ };
38
+ const getAnswerNode = (identifiers) => {
39
+ const { a, k, isSquareInside } = identifiers;
40
+ const kNode = nodeConstructor_1.NodeConstructor.fromIdentifiers(k);
41
+ const ansNode = (isSquareInside
42
+ ? (0, multiplyNode_1.multiply)(a, (0, sqrtNode_1.sqrt)((0, powerNode_1.square)(kNode)))
43
+ : (0, powerNode_1.square)((0, multiplyNode_1.multiply)(a, (0, sqrtNode_1.sqrt)(kNode)))).simplify();
44
+ return ansNode;
45
+ };
46
+ const getAnswer = (identifiers) => {
47
+ return `${getAnswerNode(identifiers).toTex()}`;
48
+ };
49
+ const getInstruction = (identifiers) => {
50
+ const { a, k, isSquareInside } = identifiers;
51
+ const kNode = nodeConstructor_1.NodeConstructor.fromIdentifiers(k);
52
+ return `Simplifier au maximum :
53
+
54
+ $$
55
+ ${(isSquareInside
56
+ ? (0, multiplyNode_1.multiply)(a, (0, sqrtNode_1.sqrt)((0, powerNode_1.square)(kNode)))
57
+ : (0, powerNode_1.square)((0, multiplyNode_1.multiply)(a, (0, sqrtNode_1.sqrt)(kNode)))).toTex()}
58
+ $$`;
59
+ };
60
+ // const getHint: GetHint<Identifiers> = (identifiers) => {};
61
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
62
+ const getKeys = (identifiers) => {
63
+ return [];
64
+ };
65
+ const isAnswerValid = (ans, { answer, a, isSquareInside, k }) => {
66
+ const answerNode = getAnswerNode({ a, isSquareInside, k });
67
+ const parsed = (0, rationalParser_1.rationalParser)(ans);
68
+ if (!parsed)
69
+ return false;
70
+ const simpTex = parsed.simplify().toTex();
71
+ return (simpTex === answerNode.toTex() ||
72
+ simpTex === answerNode.evaluate().frenchify());
73
+ };
74
+ //a √(k^2) ou (a√k)^2
75
+ //avec k=b ou b/c
76
+ const getSquareRootsToSquareQuestion = () => {
77
+ const a = (0, randint_1.randint)(2, 10);
78
+ const isSquareInside = (0, coinFlip_1.coinFlip)();
79
+ const isInt = (0, coinFlip_1.coinFlip)();
80
+ const k = isInt
81
+ ? (0, randint_1.randint)(isSquareInside ? -10 : 2, 11, [0, 1]).toTree()
82
+ : isSquareInside
83
+ ? rational_1.RationalConstructor.randomIrreductibleWithSign().toTree()
84
+ : rational_1.RationalConstructor.randomIrreductible().toTree();
85
+ const identifiers = {
86
+ a,
87
+ k: k.toIdentifiers(),
88
+ isSquareInside,
89
+ };
90
+ const question = {
91
+ answer: getAnswer(identifiers),
92
+ instruction: getInstruction(identifiers),
93
+ keys: getKeys(identifiers),
94
+ answerFormat: "tex",
95
+ identifiers,
96
+ // hint: getHint(identifiers),
97
+ // correction: getCorrection(identifiers),
98
+ };
99
+ return question;
100
+ };
101
+ exports.squareRootsToSquare = {
102
+ id: "squareRootsToSquare",
103
+ connector: "=",
104
+ label: "Passer une racine carrée au carré",
105
+ isSingleStep: true,
106
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getSquareRootsToSquareQuestion, nb),
107
+ qcmTimer: 60,
108
+ freeTimer: 60,
109
+ getPropositions,
110
+ isAnswerValid,
111
+ subject: "Mathématiques",
112
+ // getHint,
113
+ // getCorrection,
114
+ getAnswer,
115
+ getInstruction,
116
+ };
@@ -43,13 +43,13 @@ ${angle.toTex()}
43
43
  $$
44
44
  `;
45
45
  };
46
- const getHint = (identifiers) => {
47
- const angle = nodeConstructor_1.NodeConstructor.fromIdentifiers(identifiers.nodeIds);
48
- return `La mesure principale d'un angle en radian est sa valeur appartenant à l'intervalle $]-\\pi; \\pi]$. Il faut donc ajouter (ou retirer) $2\\pi$ à $${angle.toTex()}$ jusqu'à ce que le résultat soit dans cet intervalle.`;
49
- };
50
- const getCorrection = (identifiers) => {
51
- return `a`;
52
- };
46
+ // const getHint: GetHint<Identifiers> = (identifiers) => {
47
+ // const angle = NodeConstructor.fromIdentifiers(identifiers.nodeIds);
48
+ // return `La mesure principale d'un angle en radian est sa valeur appartenant à l'intervalle $]-\\pi; \\pi]$. Il faut donc ajouter (ou retirer) $2\\pi$ à $${angle.toTex()}$ jusqu'à ce que le résultat soit dans cet intervalle.`;
49
+ // };
50
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {
51
+ // return `a`;
52
+ // };
53
53
  const getKeys = (identifiers) => {
54
54
  return ["pi"];
55
55
  };
@@ -67,7 +67,7 @@ const isAnswerValid = (ans, { answer, degree }) => {
67
67
  };
68
68
  const getMainAngleMeasureQuestion = () => {
69
69
  const value = (0, random_1.random)(remarkableValues_1.mainTrigoValues);
70
- const multipleOf2PiToAdd = (0, randint_1.randint)(-3, 4, [0]);
70
+ const multipleOf2PiToAdd = (0, randint_1.randint)(-100, 100, [0]);
71
71
  const node = new addNode_1.AddNode(value.angle, new multiplyNode_1.MultiplyNode((2 * multipleOf2PiToAdd).toTree(), piNode_1.PiNode)).simplify();
72
72
  const identifiers = {
73
73
  degree: value.degree,
@@ -80,8 +80,8 @@ const getMainAngleMeasureQuestion = () => {
80
80
  keys: getKeys(identifiers),
81
81
  answerFormat: "tex",
82
82
  identifiers,
83
- hint: getHint(identifiers),
84
- correction: getCorrection(identifiers),
83
+ // hint: getHint(identifiers),
84
+ // correction: getCorrection(identifiers),
85
85
  };
86
86
  return question;
87
87
  };
@@ -97,8 +97,8 @@ exports.mainAngleMeasure = {
97
97
  getPropositions,
98
98
  isAnswerValid,
99
99
  subject: "Mathématiques",
100
- getHint,
101
- getCorrection,
100
+ // getHint,
101
+ // getCorrection,
102
102
  getAnswer,
103
- hasHintAndCorrection: true,
103
+ // hasHintAndCorrection: false,
104
104
  };
package/lib/index.d.ts CHANGED
@@ -26,14 +26,19 @@ declare const mathExercises: (import("./exercises/exercise").Exercise<{
26
26
  }, {}> | import("./exercises/exercise").Exercise<{
27
27
  integerFirst: boolean;
28
28
  integer: number;
29
- rational: [number, number];
29
+ rational: number[];
30
30
  }, {}> | import("./exercises/exercise").Exercise<{
31
31
  integer: number;
32
- rational: [number, number];
33
- }, {}> | import("./exercises/exercise").Exercise<{
32
+ rational: number[];
33
+ integerFirst: boolean;
34
+ }, {
35
+ allowNonIrreductible?: boolean | undefined;
36
+ }> | import("./exercises/exercise").Exercise<{
34
37
  integer: number;
35
38
  rational: [number, number];
36
- }, {}> | import("./exercises/exercise").Exercise<{
39
+ }, {
40
+ allowNonIrreductible?: boolean | undefined;
41
+ }> | import("./exercises/exercise").Exercise<{
37
42
  rand: number;
38
43
  numerator: number;
39
44
  denominator: number;
@@ -43,9 +48,11 @@ declare const mathExercises: (import("./exercises/exercise").Exercise<{
43
48
  }, {}> | import("./exercises/exercise").Exercise<{
44
49
  rationalNum: [number, number];
45
50
  rationalDenum: [number, number];
46
- }, {}> | import("./exercises/exercise").Exercise<{
47
- rational: [number, number];
48
- rational2: [number, number];
51
+ }, {
52
+ allowNonIrreductible?: boolean | undefined;
53
+ }> | import("./exercises/exercise").Exercise<{
54
+ rational: number[];
55
+ rational2: number[];
49
56
  }, {
50
57
  allowNonIrreductible?: boolean | undefined;
51
58
  }> | import("./exercises/exercise").Exercise<{
@@ -131,13 +138,21 @@ declare const mathExercises: (import("./exercises/exercise").Exercise<{
131
138
  xValues: any[];
132
139
  yValues: any[];
133
140
  isProportionnal: boolean;
134
- type: number;
135
- }, {}> | import("./exercises/exercise").Exercise<{
141
+ coeffType: string;
142
+ valuesType: string;
143
+ }, {
144
+ coeffNumberTypes: string[];
145
+ valuesNumberTypes: string[];
146
+ }> | import("./exercises/exercise").Exercise<{
136
147
  coeffIds: any;
137
148
  xValues: any[];
138
149
  yValues: any[];
139
- type: number;
140
- }, {}> | import("./exercises/exercise").Exercise<{
150
+ coeffType: string;
151
+ valuesType: string;
152
+ }, {
153
+ coeffNumberTypes: string[];
154
+ valuesNumberTypes: string[];
155
+ }> | import("./exercises/exercise").Exercise<{
141
156
  xValues: number[];
142
157
  yValues: number[];
143
158
  }, {}> | import("./exercises/exercise").Exercise<{
@@ -1553,6 +1568,15 @@ declare const mathExercises: (import("./exercises/exercise").Exercise<{
1553
1568
  b: number;
1554
1569
  c: number;
1555
1570
  d: number;
1571
+ }, {}> | import("./exercises/exercise").Exercise<{
1572
+ a: number;
1573
+ b: number;
1574
+ c: number;
1575
+ d: number;
1576
+ }, {}> | import("./exercises/exercise").Exercise<{
1577
+ a: number;
1578
+ k: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
1579
+ isSquareInside: boolean;
1556
1580
  }, {}> | import("./exercises/exercise").Exercise<{
1557
1581
  valueIndex: number;
1558
1582
  isCos: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,yBAAyB,CAAC;AAEjC,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ement {
13
13
  b: number;
14
14
  algebraicElement: Nombre;
15
15
  constructor(a: number, b: number, algebraicElement: Nombre);
16
- toTree(): import("../../../tree/nodes/algebraicNode").AlgebraicNode | NumberNode | MultiplyNode | OppositeNode | AddNode | SubstractNode;
16
+ toTree(): import("../../../tree/nodes/algebraicNode").AlgebraicNode | NumberNode | OppositeNode | MultiplyNode | AddNode | SubstractNode;
17
17
  }
18
18
  //# sourceMappingURL=extendedRingElement.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAoCA,eAAO,MAAM,UAAU,YAAW,CAAC"}
1
+ {"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAqCA,eAAO,MAAM,UAAU,YAMtB,CAAC"}
package/lib/playground.js CHANGED
@@ -1,5 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.playground = void 0;
4
- const playground = () => { };
4
+ const sqrtNode_1 = require("./tree/nodes/functions/sqrtNode");
5
+ const fractionNode_1 = require("./tree/nodes/operators/fractionNode");
6
+ const powerNode_1 = require("./tree/nodes/operators/powerNode");
7
+ const playground = () => {
8
+ console.log((0, sqrtNode_1.sqrt)((0, powerNode_1.square)((0, fractionNode_1.frac)(2, 3)))
9
+ .simplify()
10
+ .toTex());
11
+ };
5
12
  exports.playground = playground;
@@ -18,7 +18,7 @@ export declare class AbsNode implements FunctionNode {
18
18
  toTex(): string;
19
19
  toEquivalentNodes(): AlgebraicNode[];
20
20
  toAllValidTexs(): string[];
21
- simplify(): AbsNode;
21
+ simplify(): AlgebraicNode | AbsNode;
22
22
  evaluate(vars?: Record<string, number>): number;
23
23
  equals(node: AlgebraicNode): boolean;
24
24
  toDetailedEvaluation(vars: Record<string, AlgebraicNode>): AbsNode;
@@ -1 +1 @@
1
- {"version":3,"file":"absNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nod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E,aAAa,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBACP,KAAK,EAAE,aAAa;IAMhC,aAAa;;;;;;IAMb,YAAY,IAAI,MAAM;IAItB,KAAK,IAAI,MAAM;IAOf,iBAAiB,IAAI,aAAa,EAAE;IASpC,cAAc,IAAI,MAAM,EAAE;IAG1B,QAAQ;IAUR,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAGtC,MAAM,CAAC,IAAI,EAAE,aAAa;IAI1B,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;CAGzD"}
@@ -4,6 +4,8 @@ exports.AbsNode = exports.isAbsNode = void 0;
4
4
  // import { abs } from "mathjs";
5
5
  const node_1 = require("../node");
6
6
  const functionNode_1 = require("./functionNode");
7
+ const numberNode_1 = require("../numbers/numberNode");
8
+ const oppositeNode_1 = require("./oppositeNode");
7
9
  function isAbsNode(a) {
8
10
  return (0, functionNode_1.isFunctionNode)(a) && a.id === functionNode_1.FunctionsIds.abs;
9
11
  }
@@ -42,7 +44,13 @@ class AbsNode {
42
44
  return this.toEquivalentNodes().map((node) => node.toTex());
43
45
  }
44
46
  simplify() {
45
- return new AbsNode(this.child.simplify());
47
+ const childSimplified = this.child.simplify();
48
+ if ((0, numberNode_1.isNumberNode)(childSimplified))
49
+ return Math.abs(childSimplified.value).toTree();
50
+ if ((0, oppositeNode_1.isOppositeNode)(childSimplified)) {
51
+ return childSimplified.child;
52
+ }
53
+ return new AbsNode(childSimplified);
46
54
  }
47
55
  evaluate(vars) {
48
56
  return Math.abs(this.child.evaluate(vars));
@@ -1 +1 @@
1
- {"version":3,"file":"sqrtNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/sqrtNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,S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E,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAMlE,wBAAgB,UAAU,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,QAAQ,CAEjD;AAED,eAAO,MAAM,IAAI,MAAO,aAAa,GAAG,MAAM,GAAG,MAAM,aAItD,CAAC;AAEF,qBAAa,QAAS,YAAW,YAAY;IAC3C,EAAE,EAAE,YAAY,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;gBACP,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;IAOpD,aAAa;;;;;;IAMb,YAAY,IAAI,MAAM;IAMtB,KAAK,IAAI,MAAM;IAIf,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,aAAa,EAAE;IAwBtD,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAG5C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAGtC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe;IAyC/B,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAGpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;CAGzD"}
@@ -9,6 +9,9 @@ const numberNode_1 = require("../numbers/numberNode");
9
9
  const multiplyNode_1 = require("../operators/multiplyNode");
10
10
  const isInt_1 = require("../../../utils/isInt");
11
11
  const operatorComposition_1 = require("../../../tree/utilities/operatorComposition");
12
+ const fractionNode_1 = require("../operators/fractionNode");
13
+ const powerNode_1 = require("../operators/powerNode");
14
+ const absNode_1 = require("./absNode");
12
15
  function isSqrtNode(a) {
13
16
  return (0, functionNode_1.isFunctionNode)(a) && a.id === functionNode_1.FunctionsIds.sqrt;
14
17
  }
@@ -88,6 +91,12 @@ class SqrtNode {
88
91
  return sqrt.simplify().toTree();
89
92
  }
90
93
  //TODO diviser par 2 les puissances (dont exp)
94
+ if ((0, powerNode_1.isSquareNode)(a)) {
95
+ return new absNode_1.AbsNode(a.leftChild).simplify();
96
+ }
97
+ if ((0, fractionNode_1.isFractionNode)(a)) {
98
+ return (0, fractionNode_1.frac)((0, exports.sqrt)(a.leftChild), (0, exports.sqrt)(a.rightChild)).simplify(opts);
99
+ }
91
100
  return new SqrtNode(a);
92
101
  };
93
102
  const simplifyIteration = () => {
@@ -9,7 +9,8 @@ export declare enum OperatorIds {
9
9
  power = 5,
10
10
  limit = 6,
11
11
  integral = 7,
12
- binomialCoefficient = 8
12
+ binomialCoefficient = 8,
13
+ square = 9
13
14
  }
14
15
  export interface OperatorNode extends AlgebraicNode {
15
16
  id: OperatorIds;
@@ -1 +1 @@
1
- {"version":3,"file":"operatorNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/operatorNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAY,MAAM,SAAS,CAAC;AAEzC,oBAAY,WAAW;IACrB,GAAG,IAAA;IACH,SAAS,IAAA;IACT,QAAQ,IAAA;IACR,QAAQ,IAAA;IACR,MAAM,IAAA;IACN,KAAK,IAAA;IACL,KAAK,IAAA;IACL,QAAQ,IAAA;IACR,mBAAmB,IAAA;CACpB;AAED,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;CAC3B;AACD,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AAED,MAAM,WAAW,uBAAwB,SAAQ,YAAY;IAC3D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,MAAM,EAAE,CAAC;CAC3B"}
1
+ {"version":3,"file":"operatorNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/operatorNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAY,MAAM,SAAS,CAAC;AAEzC,oBAAY,WAAW;IACrB,GAAG,IAAA;IACH,SAAS,IAAA;IACT,QAAQ,IAAA;IACR,QAAQ,IAAA;IACR,MAAM,IAAA;IACN,KAAK,IAAA;IACL,KAAK,IAAA;IACL,QAAQ,IAAA;IACR,mBAAmB,IAAA;IACnB,MAAM,IAAA;CACP;AAED,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;CAC3B;AACD,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AAED,MAAM,WAAW,uBAAwB,SAAQ,YAAY;IAC3D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,MAAM,EAAE,CAAC;CAC3B"}
@@ -13,6 +13,7 @@ var OperatorIds;
13
13
  OperatorIds[OperatorIds["limit"] = 6] = "limit";
14
14
  OperatorIds[OperatorIds["integral"] = 7] = "integral";
15
15
  OperatorIds[OperatorIds["binomialCoefficient"] = 8] = "binomialCoefficient";
16
+ OperatorIds[OperatorIds["square"] = 9] = "square";
16
17
  })(OperatorIds || (exports.OperatorIds = OperatorIds = {}));
17
18
  function isOperatorNode(a) {
18
19
  return a.type === node_1.NodeType.operator;
@@ -2,6 +2,7 @@ import { Node, NodeIds, NodeOptions, NodeType } from "../node";
2
2
  import { OperatorIds, OperatorNode } from "./operatorNode";
3
3
  import { AlgebraicNode, SimplifyOptions } from "../algebraicNode";
4
4
  export declare function isPowerNode(a: Node): a is PowerNode;
5
+ export declare function isSquareNode(a: Node): a is SquareNode;
5
6
  export declare const square: (a: AlgebraicNode | number | string) => SquareNode;
6
7
  export declare class PowerNode implements OperatorNode {
7
8
  opts?: NodeOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"powerNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/powerNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAG3E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAElE,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,SAAS,CAEnD;AAED,eAAO,MAAM,MAAM,MAAO,aAAa,GAAG,MAAM,GAAG,MAAM,eAKxD,CAAC;AAEF,qBAAa,SAAU,YAAW,YAAY;IAC5C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IAUpB,YAAY,IAAI,MAAM;IAGtB,aAAa;;;;;;;;;IAOb,iBAAiB;IAqBjB,cAAc,IAAI,MAAM,EAAE;IAI1B,KAAK,IAAI,MAAM;IAuBf,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMtC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IA8FxD,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAqC/C,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;CAO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