math-exercises 3.0.50 → 3.0.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.
- package/lib/exercises/math/calcul/fractions/fractionsOperations.js +2 -2
- package/lib/exercises/math/calcul/mentalCaluls/mentalAddAndSub.js +1 -1
- package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplications.js +1 -1
- package/lib/exercises/math/calcul/operations/expressionNature.js +6 -12
- package/lib/exercises/math/calcul/operations/operationsPriorities.d.ts.map +1 -1
- package/lib/exercises/math/calcul/operations/operationsPriorities.js +5 -6
- package/lib/exercises/math/calcul/operations/operationsPrioritiesParenthesis.js +1 -2
- package/lib/exercises/math/calcul/operations/operationsPrioritiesParenthesisNoRelatives.d.ts.map +1 -1
- package/lib/exercises/math/calcul/operations/operationsPrioritiesParenthesisNoRelatives.js +1 -2
- package/lib/exercises/math/calcul/operations/operationsPrioritiesWithoutRelative.d.ts.map +1 -1
- package/lib/exercises/math/calcul/operations/operationsPrioritiesWithoutRelative.js +1 -2
- package/lib/exercises/math/calcul/proportionality/proportionalityTableCoefficient.d.ts.map +1 -1
- package/lib/exercises/math/calcul/proportionality/proportionalityTableCoefficient.js +5 -1
- package/lib/exercises/math/calculLitteral/isolate/isolateVariable.js +100 -36
- package/lib/exercises/math/functions/exponential/expSimplifiying.d.ts.map +1 -1
- package/lib/exercises/math/functions/exponential/expSimplifiying.js +1 -2
- package/lib/exercises/math/geometry/cartesian/cartesianEquationOfLine.d.ts.map +1 -1
- package/lib/exercises/math/geometry/cartesian/cartesianEquationOfLine.js +62 -97
- package/lib/exercises/math/probaStat/basicStats/calculateFrequency.d.ts +4 -1
- package/lib/exercises/math/probaStat/basicStats/calculateFrequency.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/basicStats/calculateFrequency.js +43 -18
- package/lib/index.d.ts +3 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/line.d.ts.map +1 -1
- package/lib/math/geometry/line.js +9 -9
- package/lib/playground.d.ts.map +1 -1
- package/lib/playground.js +6 -3
- package/lib/tree/nodes/equations/equalNode.d.ts.map +1 -1
- package/lib/tree/nodes/equations/equalNode.js +21 -16
- package/lib/tree/nodes/hasVariableNode.d.ts +1 -1
- package/lib/tree/nodes/hasVariableNode.d.ts.map +1 -1
- package/lib/tree/nodes/hasVariableNode.js +4 -4
- package/lib/tree/nodes/operators/addNode.d.ts +1 -1
- package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.js +2 -1
- package/lib/tree/nodes/operators/divideNode.d.ts +1 -1
- package/lib/tree/nodes/operators/divideNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/divideNode.js +1 -2
- package/lib/tree/nodes/operators/multiplyNode.d.ts +1 -1
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +2 -1
- package/lib/tree/nodes/operators/operatorNode.d.ts +1 -1
- package/lib/tree/nodes/operators/operatorNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/substractNode.d.ts +2 -1
- package/lib/tree/nodes/operators/substractNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/substractNode.js +4 -3
- package/package.json +1 -1
|
@@ -47,12 +47,12 @@ const getFractionsOperationsQuestion = (ops) => {
|
|
|
47
47
|
RationalConstructor.randomIrreductible().toTree(),
|
|
48
48
|
RationalConstructor.randomIrreductible().toTree(),
|
|
49
49
|
];
|
|
50
|
-
|
|
50
|
+
let statement = firstOp(secondOp(rationals[0], rationals[1]), rationals[2]);
|
|
51
51
|
//éviter division par une soustraction qui donne 0
|
|
52
52
|
if (firstOpIndex !== 3 ||
|
|
53
53
|
secondOpIndex !== 1 ||
|
|
54
54
|
rationals[0].evaluate() - rationals[1].evaluate() !== 0) {
|
|
55
|
-
statement.shuffle();
|
|
55
|
+
statement = statement.shuffle();
|
|
56
56
|
}
|
|
57
57
|
const ids = statement.toIdentifiers();
|
|
58
58
|
const identifiers = {
|
|
@@ -27,7 +27,7 @@ const getMentalAddAndSub = () => {
|
|
|
27
27
|
let statementTree = new AddNode(allNumbersNodes[0], allNumbersNodes[1]);
|
|
28
28
|
for (let i = 2; i < nbrOperations; i++)
|
|
29
29
|
statementTree = new AddNode(statementTree, allNumbersNodes[i]);
|
|
30
|
-
statementTree.shuffle();
|
|
30
|
+
statementTree = statementTree.shuffle();
|
|
31
31
|
const statement = statementTree.toTex();
|
|
32
32
|
const answer = (round(sum, 2) + "").replace(".", ",");
|
|
33
33
|
const question = {
|
|
@@ -36,7 +36,7 @@ const getMentalMultiplications = () => {
|
|
|
36
36
|
statementTree = new MultiplyNode(allNumbersNodes[0], new MultiplyNode(allNumbersNodes[1], allNumbersNodes[2]));
|
|
37
37
|
answer = numbers[0] * numbers[1] * numbers[2];
|
|
38
38
|
}
|
|
39
|
-
statementTree.shuffle();
|
|
39
|
+
statementTree = statementTree.shuffle();
|
|
40
40
|
const statementTex = statementTree.toTex();
|
|
41
41
|
const answerTex = round(answer, 2).frenchify();
|
|
42
42
|
const question = {
|
|
@@ -24,8 +24,7 @@ const getExpressionNatureQuestion = () => {
|
|
|
24
24
|
switch (subType) {
|
|
25
25
|
case 1:
|
|
26
26
|
//ab+c
|
|
27
|
-
node = new AddNode(new MultiplyNode(a, b), c);
|
|
28
|
-
node.shuffle();
|
|
27
|
+
node = new AddNode(new MultiplyNode(a, b), c).shuffle();
|
|
29
28
|
break;
|
|
30
29
|
case 2:
|
|
31
30
|
//ab + cd
|
|
@@ -33,13 +32,11 @@ const getExpressionNatureQuestion = () => {
|
|
|
33
32
|
break;
|
|
34
33
|
case 3:
|
|
35
34
|
//a/b + c
|
|
36
|
-
node = new AddNode(new DivideNode(a, b), c);
|
|
37
|
-
node.shuffle();
|
|
35
|
+
node = new AddNode(new DivideNode(a, b), c).shuffle();
|
|
38
36
|
break;
|
|
39
37
|
case 4:
|
|
40
38
|
//ab + c/d
|
|
41
|
-
node = new AddNode(new MultiplyNode(a, b), new DivideNode(c, d));
|
|
42
|
-
node.shuffle();
|
|
39
|
+
node = new AddNode(new MultiplyNode(a, b), new DivideNode(c, d)).shuffle();
|
|
43
40
|
break;
|
|
44
41
|
case 5:
|
|
45
42
|
//a/b + c/d
|
|
@@ -84,13 +81,11 @@ const getExpressionNatureQuestion = () => {
|
|
|
84
81
|
switch (subType) {
|
|
85
82
|
case 1:
|
|
86
83
|
//(a+b)*c
|
|
87
|
-
node = new MultiplyNode(new AddNode(a, b), c);
|
|
88
|
-
node.shuffle();
|
|
84
|
+
node = new MultiplyNode(new AddNode(a, b), c).shuffle();
|
|
89
85
|
break;
|
|
90
86
|
case 2:
|
|
91
87
|
//(a-b)*c
|
|
92
|
-
node = new MultiplyNode(new SubstractNode(a, b), c);
|
|
93
|
-
node.shuffle();
|
|
88
|
+
node = new MultiplyNode(new SubstractNode(a, b), c).shuffle();
|
|
94
89
|
break;
|
|
95
90
|
case 3:
|
|
96
91
|
//(a+b)(c+d)
|
|
@@ -98,8 +93,7 @@ const getExpressionNatureQuestion = () => {
|
|
|
98
93
|
break;
|
|
99
94
|
case 4:
|
|
100
95
|
//(a+b)(c-d)
|
|
101
|
-
node = new MultiplyNode(new AddNode(a, b), new SubstractNode(c, d));
|
|
102
|
-
node.shuffle();
|
|
96
|
+
node = new MultiplyNode(new AddNode(a, b), new SubstractNode(c, d)).shuffle();
|
|
103
97
|
break;
|
|
104
98
|
case 5:
|
|
105
99
|
//(a-b)(c-d)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operationsPriorities.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/operations/operationsPriorities.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACvB,CAAC;
|
|
1
|
+
{"version":3,"file":"operationsPriorities.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/operations/operationsPriorities.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACvB,CAAC;AAkJF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAatD,CAAC"}
|
|
@@ -29,7 +29,7 @@ const getPriorityQuestions = () => {
|
|
|
29
29
|
new AddNode(new MultiplyNode(new NumberNode(a), new NumberNode(b)), new AddNode(new NumberNode(c), new NumberNode(d)))
|
|
30
30
|
: //a*b middle
|
|
31
31
|
new AddNode(new AddNode(new NumberNode(c), new MultiplyNode(new NumberNode(a), new NumberNode(b))), new NumberNode(d));
|
|
32
|
-
statement.shuffle();
|
|
32
|
+
statement = statement.shuffle();
|
|
33
33
|
startStatement = statement.toTex();
|
|
34
34
|
answer = (a * b + c + d).toString();
|
|
35
35
|
break;
|
|
@@ -41,7 +41,7 @@ const getPriorityQuestions = () => {
|
|
|
41
41
|
new AddNode(new DivideNode(new NumberNode(a), new NumberNode(b)), new AddNode(new NumberNode(c), new NumberNode(d)))
|
|
42
42
|
: //a/b middle
|
|
43
43
|
new AddNode(new AddNode(new NumberNode(c), new DivideNode(new NumberNode(a), new NumberNode(b))), new NumberNode(d));
|
|
44
|
-
statement.shuffle();
|
|
44
|
+
statement = statement.shuffle();
|
|
45
45
|
startStatement = statement.toTex();
|
|
46
46
|
answer = (a / b + c + d).toString();
|
|
47
47
|
break;
|
|
@@ -56,7 +56,7 @@ const getPriorityQuestions = () => {
|
|
|
56
56
|
d = randint(-10, 11, [0]);
|
|
57
57
|
c = d * randint(0, 11);
|
|
58
58
|
statement = new AddNode(new MultiplyNode(new NumberNode(a), new NumberNode(b)), new DivideNode(new NumberNode(c), new NumberNode(d)));
|
|
59
|
-
statement.shuffle();
|
|
59
|
+
statement = statement.shuffle();
|
|
60
60
|
startStatement = statement.toTex();
|
|
61
61
|
answer = (a * b + c / d).toString();
|
|
62
62
|
break;
|
|
@@ -71,7 +71,7 @@ const getPriorityQuestions = () => {
|
|
|
71
71
|
case 6: // a*b*c ± d
|
|
72
72
|
[a, b, c, d] = [1, 2, 3, 4].map((el) => randint(-10, 11, [0]));
|
|
73
73
|
statement = new AddNode(new MultiplyNode(new MultiplyNode(new NumberNode(a), new NumberNode(b)), new NumberNode(c)), new NumberNode(d));
|
|
74
|
-
statement.shuffle();
|
|
74
|
+
statement = statement.shuffle();
|
|
75
75
|
startStatement = statement.toTex();
|
|
76
76
|
answer = (a * b * c + d).toString();
|
|
77
77
|
break;
|
|
@@ -79,8 +79,7 @@ const getPriorityQuestions = () => {
|
|
|
79
79
|
b = randint(2, 10);
|
|
80
80
|
a = b * randint(2, 10);
|
|
81
81
|
c = randint(2, 10);
|
|
82
|
-
statement = new MultiplyNode(new DivideNode(a.toTree(), b.toTree()), c.toTree());
|
|
83
|
-
statement.shuffle();
|
|
82
|
+
statement = new MultiplyNode(new DivideNode(a.toTree(), b.toTree()), c.toTree()).shuffle();
|
|
84
83
|
answer = ((a / b) * c).frenchify();
|
|
85
84
|
startStatement = statement.toTex();
|
|
86
85
|
break;
|
|
@@ -15,8 +15,7 @@ const getOperationsPrioritiesParenthesisQuestion = () => {
|
|
|
15
15
|
case 1: //a*(b+-c)
|
|
16
16
|
a = randint(-10, 11, [0, 1, -1]);
|
|
17
17
|
[b, c] = [1, 2].map((el) => randint(-10, 11, [0]));
|
|
18
|
-
statement = new MultiplyNode(a.toTree(), new AddNode(b.toTree(), c.toTree()), { forceTimesSign: true });
|
|
19
|
-
statement.shuffle();
|
|
18
|
+
statement = new MultiplyNode(a.toTree(), new AddNode(b.toTree(), c.toTree()), { forceTimesSign: true }).shuffle();
|
|
20
19
|
answer = (a * (b + c)).frenchify();
|
|
21
20
|
break;
|
|
22
21
|
case 2: //a/(b+-c) ou (b+-c)/a
|
package/lib/exercises/math/calcul/operations/operationsPrioritiesParenthesisNoRelatives.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operationsPrioritiesParenthesisNoRelatives.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/operations/operationsPrioritiesParenthesisNoRelatives.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,GAAG,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;
|
|
1
|
+
{"version":3,"file":"operationsPrioritiesParenthesisNoRelatives.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/operations/operationsPrioritiesParenthesisNoRelatives.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,GAAG,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAmIF,eAAO,MAAM,0CAA0C,EAAE,QAAQ,CAAC,WAAW,CAkB1E,CAAC"}
|
|
@@ -16,8 +16,7 @@ const getOperationsPrioritiesParenthesisNoRelativesQuestion = () => {
|
|
|
16
16
|
a = randint(2, 11);
|
|
17
17
|
b = randint(1, 11);
|
|
18
18
|
c = randint(-b, 11, [0]);
|
|
19
|
-
statement = new MultiplyNode(a.toTree(), new AddNode(b.toTree(), c.toTree()));
|
|
20
|
-
statement.shuffle();
|
|
19
|
+
statement = new MultiplyNode(a.toTree(), new AddNode(b.toTree(), c.toTree())).shuffle();
|
|
21
20
|
answer = (a * (b + c)).frenchify();
|
|
22
21
|
break;
|
|
23
22
|
case 2: //a/(b+-c) ou (b+-c)/a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operationsPrioritiesWithoutRelative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/operations/operationsPrioritiesWithoutRelative.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;
|
|
1
|
+
{"version":3,"file":"operationsPrioritiesWithoutRelative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/operations/operationsPrioritiesWithoutRelative.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAgSF,eAAO,MAAM,mCAAmC,EAAE,QAAQ,CAAC,WAAW,CAcrE,CAAC"}
|
|
@@ -162,8 +162,7 @@ const getOperationsPrioritiesWithoutRelative = () => {
|
|
|
162
162
|
b = randint(2, 10);
|
|
163
163
|
a = b * randint(2, 10);
|
|
164
164
|
c = randint(2, 10);
|
|
165
|
-
statement = new MultiplyNode(new DivideNode(a.toTree(), b.toTree()), c.toTree());
|
|
166
|
-
statement.shuffle();
|
|
165
|
+
statement = new MultiplyNode(new DivideNode(a.toTree(), b.toTree()), c.toTree()).shuffle();
|
|
167
166
|
answer = ((a / b) * c).frenchify();
|
|
168
167
|
startStatement = statement.toTex();
|
|
169
168
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proportionalityTableCoefficient.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/proportionality/proportionalityTableCoefficient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"proportionalityTableCoefficient.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/proportionality/proportionalityTableCoefficient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAsFF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,CAiBjE,CAAC"}
|
|
@@ -35,7 +35,7 @@ const getCorrection = (identifiers) => {
|
|
|
35
35
|
Pour l'obtenir, on divise une valeur de la deuxième ligne par la valeur correspondante dans la première ligne, par exemple :
|
|
36
36
|
|
|
37
37
|
$$
|
|
38
|
-
${frac(
|
|
38
|
+
${frac(yValues[0], xValues[0]).toSimplificationTex()}
|
|
39
39
|
$$`;
|
|
40
40
|
};
|
|
41
41
|
const getProportionalityTableCoefficient = () => {
|
|
@@ -43,6 +43,9 @@ const getProportionalityTableCoefficient = () => {
|
|
|
43
43
|
const xValues = IntegerConstructor.randomDifferents(1, 100 / factor, 3).sort((a, b) => a - b);
|
|
44
44
|
const yValues = xValues.map((x) => x * factor);
|
|
45
45
|
const identifiers = { xValues, yValues };
|
|
46
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
47
|
+
};
|
|
48
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
46
49
|
const question = {
|
|
47
50
|
instruction: getInstruction(identifiers),
|
|
48
51
|
answer: getAnswer(identifiers),
|
|
@@ -87,4 +90,5 @@ export const proportionalityTableCoefficient = {
|
|
|
87
90
|
subject: "Mathématiques",
|
|
88
91
|
getInstruction,
|
|
89
92
|
hasHintAndCorrection: true,
|
|
93
|
+
getQuestionFromIdentifiers,
|
|
90
94
|
};
|
|
@@ -13,71 +13,135 @@
|
|
|
13
13
|
// GetInstruction,
|
|
14
14
|
// GetKeys,
|
|
15
15
|
// GetQuestionFromIdentifiers,
|
|
16
|
-
// } from
|
|
17
|
-
// import { getDistinctQuestions } from
|
|
16
|
+
// } from "../../../../exercises/exercise.js";
|
|
17
|
+
// import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
18
|
+
// import { GeneralAffine } from "../../../../math/polynomials/generalAffine.js";
|
|
19
|
+
// import { randint } from "../../../../math/utils/random/randint.js";
|
|
20
|
+
// import { AlgebraicNode } from "../../../../tree/nodes/algebraicNode.js";
|
|
21
|
+
// import {
|
|
22
|
+
// EqualNode,
|
|
23
|
+
// EqualNodeConstructor,
|
|
24
|
+
// EqualNodeIdentifiers,
|
|
25
|
+
// } from "../../../../tree/nodes/equations/equalNode.js";
|
|
26
|
+
// import { opposite } from "../../../../tree/nodes/functions/oppositeNode.js";
|
|
27
|
+
// import { reifyAlgebraic } from "../../../../tree/nodes/nodeConstructor.js";
|
|
28
|
+
// import { add } from "../../../../tree/nodes/operators/addNode.js";
|
|
29
|
+
// import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
30
|
+
// import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
18
31
|
// import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
19
32
|
export {};
|
|
20
33
|
// type Identifiers = {
|
|
34
|
+
// eqNodeIds: EqualNodeIdentifiers;
|
|
35
|
+
// type: number;
|
|
21
36
|
// };
|
|
22
37
|
// //1. x+a = b (plus ou moins, droite ou gauche)
|
|
23
38
|
// //2. ax + b = c (plus ou moins, droite ou gauche)
|
|
24
|
-
// //3. a/x = b
|
|
39
|
+
// //3. a/x = b , a +b/x =c, x num ou denum
|
|
25
40
|
// //4. ax / b = c
|
|
41
|
+
// //5. x(a+b)=c
|
|
42
|
+
// //6. x*a*b = c ou xa = bc
|
|
43
|
+
// //7. x+a / b =c/ d (x+a) place aléatire , pm
|
|
44
|
+
// //8. (x+a)/b = c
|
|
26
45
|
// const getPropositions: QCMGenerator<Identifiers> = (n, { answer }) => {
|
|
27
46
|
// const propositions: Proposition[] = [];
|
|
28
47
|
// addValidProp(propositions, answer);
|
|
29
48
|
// while (propositions.length < n) {
|
|
30
|
-
// throw Error("QCM not implemented")
|
|
49
|
+
// throw Error("QCM not implemented");
|
|
31
50
|
// }
|
|
32
51
|
// return shuffleProps(propositions, n);
|
|
33
52
|
// };
|
|
34
|
-
// const getAnswer
|
|
35
|
-
// }
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
// }
|
|
40
|
-
// const
|
|
41
|
-
// }
|
|
42
|
-
//
|
|
43
|
-
// return
|
|
44
|
-
//
|
|
45
|
-
//
|
|
53
|
+
// const getAnswer: GetAnswer<Identifiers> = (identifiers) => {
|
|
54
|
+
// const { type, eqNodeIds } = identifiers;
|
|
55
|
+
// const eq = EqualNodeConstructor.fromIdentifiers(eqNodeIds);
|
|
56
|
+
// // return "";
|
|
57
|
+
// return eq.isolate("x").toTex();
|
|
58
|
+
// };
|
|
59
|
+
// const getInstruction: GetInstruction<Identifiers> = (identifiers) => {
|
|
60
|
+
// const { type, eqNodeIds } = identifiers;
|
|
61
|
+
// const eq = reifyAlgebraic(eqNodeIds);
|
|
62
|
+
// return `Isoler $x$ dans l'égalité suivante :
|
|
63
|
+
// $$
|
|
64
|
+
// ${eq.toTex()}
|
|
65
|
+
// $$`;
|
|
66
|
+
// };
|
|
67
|
+
// // const getHint : GetHint<Identifiers> = (identifiers)=>{
|
|
68
|
+
// // }
|
|
69
|
+
// // const getCorrection : GetCorrection<Identifiers> = (identifiers)=>{
|
|
70
|
+
// // }
|
|
71
|
+
// const getKeys: GetKeys<Identifiers> = (identifiers) => {
|
|
72
|
+
// return ["x", "a", "b", "c", "d"];
|
|
73
|
+
// };
|
|
74
|
+
// const isAnswerValid: VEA<Identifiers> = (ans, { answer }) => {
|
|
46
75
|
// try {
|
|
47
|
-
// throw Error("VEA not implemented")
|
|
48
|
-
// } catch(err){
|
|
49
|
-
// return handleVEAError(err)
|
|
76
|
+
// throw Error("VEA not implemented");
|
|
77
|
+
// } catch (err) {
|
|
78
|
+
// return handleVEAError(err);
|
|
50
79
|
// }
|
|
51
|
-
// }
|
|
52
|
-
// const getIsolateVariableQuestion: QuestionGenerator<Identifiers>
|
|
53
|
-
//
|
|
80
|
+
// };
|
|
81
|
+
// const getIsolateVariableQuestion: QuestionGenerator<Identifiers> = (ops) => {
|
|
82
|
+
// //1. x+a = b (plus ou moins, droite ou gauche)
|
|
83
|
+
// //2. ax + b = c (plus ou moins, droite ou gauche)
|
|
84
|
+
// //3. a/x = b , a +b/x =c, x num ou denum
|
|
85
|
+
// //4. ax / b = c
|
|
86
|
+
// //5. x(a+b)=c
|
|
87
|
+
// //6. x*a*b = c ou xa = bc
|
|
88
|
+
// //7. x+a / b =c/ d (x+a) place aléatire , pm
|
|
89
|
+
// //8. (x+a)/b = c
|
|
90
|
+
// const type = randint(0, 8);
|
|
91
|
+
// const x = "x".toTree();
|
|
92
|
+
// const a = "a".toTree();
|
|
93
|
+
// const b = "b".toTree();
|
|
94
|
+
// const c = "c".toTree();
|
|
95
|
+
// const d = "d".toTree();
|
|
96
|
+
// const signify = (x: AlgebraicNode) => (coinFlip() ? x : opposite(x));
|
|
97
|
+
// let eqNode: EqualNode;
|
|
98
|
+
// switch (type) {
|
|
99
|
+
// case 1:
|
|
100
|
+
// let n = add(signify(x), signify(a)).shuffle();
|
|
101
|
+
// eqNode = new EqualNode(n, b).shuffle();
|
|
102
|
+
// break;
|
|
103
|
+
// case 2:
|
|
104
|
+
// default:
|
|
105
|
+
// eqNode = new EqualNode(
|
|
106
|
+
// add(multiply(signify(a), x), signify(b)).shuffle(),
|
|
107
|
+
// signify(c),
|
|
108
|
+
// ).shuffle();
|
|
109
|
+
// break;
|
|
110
|
+
// }
|
|
111
|
+
// const identifiers: Identifiers = {
|
|
112
|
+
// type,
|
|
113
|
+
// eqNodeIds: eqNode.toIdentifiers(),
|
|
114
|
+
// };
|
|
54
115
|
// return getQuestionFromIdentifiers(identifiers);
|
|
55
|
-
// }
|
|
56
|
-
// const getQuestionFromIdentifiers: GetQuestionFromIdentifiers<Identifiers> = (
|
|
116
|
+
// };
|
|
117
|
+
// const getQuestionFromIdentifiers: GetQuestionFromIdentifiers<Identifiers> = (
|
|
118
|
+
// identifiers,
|
|
119
|
+
// ) => {
|
|
57
120
|
// return {
|
|
58
121
|
// answer: getAnswer(identifiers),
|
|
59
122
|
// instruction: getInstruction(identifiers),
|
|
60
123
|
// keys: getKeys(identifiers),
|
|
61
|
-
// answerFormat:
|
|
124
|
+
// answerFormat: "tex",
|
|
62
125
|
// identifiers,
|
|
63
|
-
// hint: getHint(identifiers),
|
|
64
|
-
// correction: getCorrection(identifiers)
|
|
65
|
-
// }
|
|
66
|
-
// }
|
|
126
|
+
// // hint: getHint(identifiers),
|
|
127
|
+
// // correction: getCorrection(identifiers)
|
|
128
|
+
// };
|
|
129
|
+
// };
|
|
67
130
|
// export const isolateVariable: Exercise<Identifiers> = {
|
|
68
|
-
// id:
|
|
69
|
-
// connector: "",
|
|
70
|
-
// label:
|
|
131
|
+
// id: "isolateVariable",
|
|
132
|
+
// connector: "\\iff",
|
|
133
|
+
// label: "Isoler une variable",
|
|
71
134
|
// isSingleStep: true,
|
|
72
|
-
// generator: (nb, opts) =>
|
|
135
|
+
// generator: (nb, opts) =>
|
|
136
|
+
// getDistinctQuestions(() => getIsolateVariableQuestion(opts), nb),
|
|
73
137
|
// qcmTimer: 60,
|
|
74
138
|
// freeTimer: 60,
|
|
75
139
|
// getPropositions,
|
|
76
140
|
// isAnswerValid,
|
|
77
141
|
// subject: "Mathématiques",
|
|
78
142
|
// getInstruction,
|
|
79
|
-
// getHint,
|
|
80
|
-
// getCorrection,
|
|
143
|
+
// // getHint,
|
|
144
|
+
// // getCorrection,
|
|
81
145
|
// getAnswer,
|
|
82
|
-
// getQuestionFromIdentifiers
|
|
146
|
+
// getQuestionFromIdentifiers,
|
|
83
147
|
// };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expSimplifiying.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/exponential/expSimplifiying.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;
|
|
1
|
+
{"version":3,"file":"expSimplifiying.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/exponential/expSimplifiying.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAkIF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAajD,CAAC"}
|
|
@@ -26,8 +26,7 @@ const getExpSimplifiying = () => {
|
|
|
26
26
|
//e^u * e^v
|
|
27
27
|
u = new Polynomial([randint(-9, 10), randint(-9, 10, [0])]);
|
|
28
28
|
v = new Polynomial([randint(-9, 10), randint(-9, 10, [0])]);
|
|
29
|
-
expression = new MultiplyNode(new ExpNode(u.toTree()), new ExpNode(v.toTree()));
|
|
30
|
-
expression.shuffle();
|
|
29
|
+
expression = new MultiplyNode(new ExpNode(u.toTree()), new ExpNode(v.toTree())).shuffle();
|
|
31
30
|
answer = new ExpNode(u.add(v).toTree()).toTex();
|
|
32
31
|
break;
|
|
33
32
|
case 3:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cartesianEquationOfLine.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/cartesianEquationOfLine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"cartesianEquationOfLine.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/cartesianEquationOfLine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAqBrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA0KF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAazD,CAAC"}
|
|
@@ -8,43 +8,79 @@ import { randint } from "../../../../math/utils/random/randint.js";
|
|
|
8
8
|
import { EqualNode } from "../../../../tree/nodes/equations/equalNode.js";
|
|
9
9
|
import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
|
|
10
10
|
import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
|
|
11
|
-
import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
11
|
+
import { MultiplyNode, } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
12
12
|
import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
13
|
+
import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
|
|
14
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
15
|
+
const getInstruction = (identifiers) => {
|
|
16
|
+
const instruction = `Déterminer une équation cartésienne de la droite $d$ représentée ci-dessous :`;
|
|
17
|
+
return instruction;
|
|
18
|
+
};
|
|
19
|
+
const getAnswer = (identifiers) => {
|
|
20
|
+
const { aX, aY, bX, bY } = identifiers;
|
|
21
|
+
const a = new Point("a", aX, aY);
|
|
22
|
+
const b = new Point("b", bX, bY);
|
|
17
23
|
const line = new Line(a, b);
|
|
24
|
+
const correctAnswer = line.getCartesianEquation();
|
|
25
|
+
return correctAnswer.toTex();
|
|
26
|
+
};
|
|
27
|
+
const getGGBOptions = (identifiers) => {
|
|
28
|
+
const { aX, aY, bX, bY } = identifiers;
|
|
29
|
+
const a = new Point("a", aX, aY);
|
|
30
|
+
const b = new Point("b", bX, bY);
|
|
18
31
|
const commands = [
|
|
19
|
-
`d = Line((${
|
|
32
|
+
`d = Line((${aX},${aY}),(${bX},${bY}))`,
|
|
20
33
|
`SetCaption(d, "$d$")`,
|
|
21
34
|
`ShowLabel(d,true)`,
|
|
22
35
|
`SetFixed(d,true)`,
|
|
23
36
|
];
|
|
24
37
|
const ggb = new GeogebraConstructor({ commands });
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
38
|
+
return ggb.getOptions({
|
|
39
|
+
coords: ggb.getCoordsForPoints([a, b]),
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
const getCartesianEquationOfLineQuestion = () => {
|
|
43
|
+
const aX = randint(-5, 6);
|
|
44
|
+
const aY = randint(-5, 6);
|
|
45
|
+
const bX = randint(-5, 6, [aX]);
|
|
46
|
+
const bY = randint(-5, 6, [aY]);
|
|
47
|
+
const identifiers = { aX, aY, bX, bY };
|
|
48
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
49
|
+
};
|
|
50
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
31
51
|
const question = {
|
|
32
|
-
answer:
|
|
33
|
-
ggbOptions:
|
|
34
|
-
|
|
35
|
-
xMin: Math.min(aX, bX) - 5,
|
|
36
|
-
xMax: Math.max(bX, aX) + 5,
|
|
37
|
-
yMin: Math.min(aY, bY) - 5,
|
|
38
|
-
yMax: Math.max(bY, aY) + 5,
|
|
39
|
-
}),
|
|
40
|
-
}),
|
|
41
|
-
instruction: instruction,
|
|
52
|
+
answer: getAnswer(identifiers),
|
|
53
|
+
ggbOptions: getGGBOptions(identifiers),
|
|
54
|
+
instruction: getInstruction(identifiers),
|
|
42
55
|
keys: ["x", "y", "equal"],
|
|
43
56
|
answerFormat: "tex",
|
|
44
|
-
identifiers
|
|
57
|
+
identifiers,
|
|
45
58
|
};
|
|
46
59
|
return question;
|
|
47
60
|
};
|
|
61
|
+
const isAnswerValid = (ans, { aX, aY, bX, bY }) => {
|
|
62
|
+
try {
|
|
63
|
+
const splitted = ans.split("=");
|
|
64
|
+
if (splitted[1] !== "0" || splitted.length !== 2)
|
|
65
|
+
return false;
|
|
66
|
+
const parsed = parseAlgebraic(splitted[0]);
|
|
67
|
+
const validpoints = [
|
|
68
|
+
[aX.toTree(), aY.toTree()],
|
|
69
|
+
[bX.toTree(), bY.toTree()],
|
|
70
|
+
];
|
|
71
|
+
return (parsed
|
|
72
|
+
.toDetailedEvaluation({ x: validpoints[0][0], y: validpoints[0][1] })
|
|
73
|
+
.simplify()
|
|
74
|
+
.toTex() === "0" &&
|
|
75
|
+
parsed
|
|
76
|
+
.toDetailedEvaluation({ x: validpoints[1][0], y: validpoints[1][1] })
|
|
77
|
+
.simplify()
|
|
78
|
+
.toTex() === "0");
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
return handleVEAError(err);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
48
84
|
const getPropositions = (n, { answer, aX, aY, bX, bY }) => {
|
|
49
85
|
const propositions = [];
|
|
50
86
|
addValidProp(propositions, answer);
|
|
@@ -69,7 +105,7 @@ const generateRandomWrongProp = (aX, aY, bX, bY, x, y) => {
|
|
|
69
105
|
b = randint(-10, 11, [0]);
|
|
70
106
|
c = randint(-10, 11);
|
|
71
107
|
} while (a * aX + b * aY + c === 0 && a * bX + b * bY + c === 0);
|
|
72
|
-
return new EqualNode(new AddNode(new AddNode(new MultiplyNode(a.toTree(), x).simplify(), new MultiplyNode(b.toTree(), y).simplify()), c.toTree()),
|
|
108
|
+
return new EqualNode(new AddNode(new AddNode(new MultiplyNode(a.toTree(), x).simplify(), new MultiplyNode(b.toTree(), y).simplify()), c.toTree()), (0).toTree());
|
|
73
109
|
};
|
|
74
110
|
const generateProposition = (aX, aY, bX, bY) => {
|
|
75
111
|
const x = new VariableNode("x");
|
|
@@ -86,84 +122,12 @@ const getFirstProposition = (x, y, aX, aY, bX, bY) => {
|
|
|
86
122
|
const b = -u.getXAsNumber();
|
|
87
123
|
const a = u.getYAsNumber();
|
|
88
124
|
const c = a * aX + b * aY;
|
|
89
|
-
return new EqualNode(new AddNode(new AddNode(new MultiplyNode(new NumberNode(b), x).simplify(), new MultiplyNode(new NumberNode(a), y).simplify()), new NumberNode(c)),
|
|
90
|
-
};
|
|
91
|
-
const isAnswerValid = (ans, { aX, aY, bX, bY }) => {
|
|
92
|
-
let userAns = getEquationNodeFromString(ans);
|
|
93
|
-
if (userAns === undefined)
|
|
94
|
-
return false;
|
|
95
|
-
userAns = userAns;
|
|
96
|
-
if (userAns.evaluate({ x: aX, y: aY }) !== 0)
|
|
97
|
-
return false;
|
|
98
|
-
if (userAns.evaluate({ x: bX, y: bY }) !== 0)
|
|
99
|
-
return false;
|
|
100
|
-
return true;
|
|
101
|
-
};
|
|
102
|
-
const getEquationNodeFromString = (ans) => {
|
|
103
|
-
if (!isValidFormat(ans))
|
|
104
|
-
return undefined;
|
|
105
|
-
const leftSide = ans.split("=")[0];
|
|
106
|
-
let op = leftSide.charAt(0) === "-" ? leftSide.replace("-", "minus") : leftSide;
|
|
107
|
-
op = op.includes("+") ? op : op.replaceAll("-", "+minus");
|
|
108
|
-
return getNodeFromString(op.split("+"));
|
|
109
|
-
};
|
|
110
|
-
const isValidFormat = (ans) => {
|
|
111
|
-
if (!ans.includes("="))
|
|
112
|
-
return false;
|
|
113
|
-
const splitted = ans.split("=");
|
|
114
|
-
if (splitted.length !== 2 ||
|
|
115
|
-
splitted[1] !== "0" ||
|
|
116
|
-
(!splitted[0].includes("x") && !splitted[0].includes("y")))
|
|
117
|
-
return false;
|
|
118
|
-
return true;
|
|
119
|
-
};
|
|
120
|
-
const getNodeFromString = (tab) => {
|
|
121
|
-
if (tab.length === 1) {
|
|
122
|
-
let varStr = tab[0];
|
|
123
|
-
const operator = findOpInSimpleOpString(varStr);
|
|
124
|
-
if (operator !== undefined) {
|
|
125
|
-
const modified = operator === "-" ? varStr.replaceAll("-", "+minus") : varStr;
|
|
126
|
-
const separated = modified.split("+");
|
|
127
|
-
return getNodeFromString(separated).simplify();
|
|
128
|
-
}
|
|
129
|
-
varStr = varStr.replace("minus", "-");
|
|
130
|
-
if (varStr.includes("x")) {
|
|
131
|
-
return getNodeFromVariableString(varStr, "x");
|
|
132
|
-
}
|
|
133
|
-
if (varStr.includes("y")) {
|
|
134
|
-
return getNodeFromVariableString(varStr, "y");
|
|
135
|
-
}
|
|
136
|
-
return isNaN(+varStr) ? new NumberNode(0) : new NumberNode(+varStr);
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
const middle = Math.floor(tab.length / 2);
|
|
140
|
-
const leftSide = tab.slice(0, middle);
|
|
141
|
-
const rightSide = tab.slice(middle);
|
|
142
|
-
return new AddNode(getNodeFromString(leftSide).simplify(), getNodeFromString(rightSide).simplify()).simplify();
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
const findOpInSimpleOpString = (str) => {
|
|
146
|
-
if (str.includes("+"))
|
|
147
|
-
return "+";
|
|
148
|
-
if (str.includes("-"))
|
|
149
|
-
return "-";
|
|
150
|
-
return undefined;
|
|
151
|
-
};
|
|
152
|
-
const getNodeFromVariableString = (str, splitter) => {
|
|
153
|
-
if (str === splitter)
|
|
154
|
-
return new VariableNode(splitter);
|
|
155
|
-
const splitted = str.split(splitter);
|
|
156
|
-
if (splitted[0] === "-") {
|
|
157
|
-
return new MultiplyNode(new NumberNode(-1), new VariableNode(splitter)).simplify();
|
|
158
|
-
}
|
|
159
|
-
return new MultiplyNode(new NumberNode(+splitted[0]), new VariableNode(splitter)).simplify();
|
|
125
|
+
return new EqualNode(new AddNode(new AddNode(new MultiplyNode(new NumberNode(b), x).simplify(), new MultiplyNode(new NumberNode(a), y).simplify()), new NumberNode(c)), (0).toTree());
|
|
160
126
|
};
|
|
161
127
|
export const cartesianEquationOfLine = {
|
|
162
128
|
id: "cartesianEquationOfLine",
|
|
163
129
|
label: "Déterminer une équation cartesienne de droite par lecture graphique",
|
|
164
|
-
levels: ["2nde"],
|
|
165
130
|
isSingleStep: true,
|
|
166
|
-
sections: ["Droites"],
|
|
167
131
|
generator: (nb) => getDistinctQuestions(getCartesianEquationOfLineQuestion, nb),
|
|
168
132
|
qcmTimer: 60,
|
|
169
133
|
freeTimer: 60,
|
|
@@ -171,4 +135,5 @@ export const cartesianEquationOfLine = {
|
|
|
171
135
|
isAnswerValid,
|
|
172
136
|
hasGeogebra: true,
|
|
173
137
|
subject: "Mathématiques",
|
|
138
|
+
getQuestionFromIdentifiers,
|
|
174
139
|
};
|
|
@@ -5,6 +5,9 @@ type Identifiers = {
|
|
|
5
5
|
k: number;
|
|
6
6
|
nbEssais: number;
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
type Options = {
|
|
9
|
+
useFractions?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare const calculateFrequency: Exercise<Identifiers, Options>;
|
|
9
12
|
export {};
|
|
10
13
|
//# sourceMappingURL=calculateFrequency.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculateFrequency.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/basicStats/calculateFrequency.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"calculateFrequency.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/basicStats/calculateFrequency.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AA2IF,KAAK,OAAO,GAAG;IACb,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAUF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkB7D,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, GeneratorOptionType, GeneratorOptionTarget, } from "../../../../exercises/exercise.js";
|
|
2
2
|
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
3
|
import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
|
|
4
4
|
import { RationalConstructor } from "../../../../math/numbers/rationals/rational.js";
|
|
@@ -8,22 +8,33 @@ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
|
8
8
|
import { random } from "../../../../utils/alea/random.js";
|
|
9
9
|
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
10
10
|
import { approxOrEqual } from "../../../../utils/latex/approxOrEqual.js";
|
|
11
|
-
const getPropositions = (n, { answer, ...identifiers }) => {
|
|
11
|
+
const getPropositions = (n, { answer, ...identifiers }, opts) => {
|
|
12
12
|
const propositions = [];
|
|
13
13
|
const { k, nbEssais } = identifiers;
|
|
14
|
+
const useFrac = opts?.useFractions;
|
|
14
15
|
addValidProp(propositions, answer);
|
|
15
16
|
tryToAddWrongProp(propositions, k + "");
|
|
16
|
-
|
|
17
|
+
if (useFrac)
|
|
18
|
+
tryToAddWrongProp(propositions, frac(k, 100).toTex());
|
|
19
|
+
else
|
|
20
|
+
tryToAddWrongProp(propositions, round(k / 100, 2).frenchify());
|
|
17
21
|
while (propositions.length < n) {
|
|
18
|
-
|
|
22
|
+
if (useFrac)
|
|
23
|
+
tryToAddWrongProp(propositions, frac(randint(5, 100), randint(5, 100)).toTex());
|
|
24
|
+
else
|
|
25
|
+
tryToAddWrongProp(propositions, round(RationalConstructor.randomIrreductible().toTree().evaluate(), 2).frenchify());
|
|
19
26
|
}
|
|
20
27
|
return shuffleProps(propositions, n);
|
|
21
28
|
};
|
|
22
|
-
const getAnswer = (identifiers) => {
|
|
29
|
+
const getAnswer = (identifiers, opts) => {
|
|
30
|
+
const useFrac = opts?.useFractions;
|
|
23
31
|
const { k, nbEssais } = identifiers;
|
|
24
|
-
|
|
32
|
+
if (useFrac)
|
|
33
|
+
return frac(k, nbEssais).toTex();
|
|
34
|
+
else
|
|
35
|
+
return round(k / nbEssais, 2).frenchify();
|
|
25
36
|
};
|
|
26
|
-
const getInstruction = (identifiers) => {
|
|
37
|
+
const getInstruction = (identifiers, opts) => {
|
|
27
38
|
const { type, k, nbEssais, caracType } = identifiers;
|
|
28
39
|
let instruction = ";";
|
|
29
40
|
switch (type) {
|
|
@@ -42,22 +53,23 @@ const getInstruction = (identifiers) => {
|
|
|
42
53
|
Quelle est la fréquence d'apparition de ${caracType} ? Arrondir au centième près.`;
|
|
43
54
|
return instruction;
|
|
44
55
|
};
|
|
45
|
-
const getHint = (identifiers) => {
|
|
56
|
+
const getHint = (identifiers, opts) => {
|
|
46
57
|
const { type, k, nbEssais, caracType } = identifiers;
|
|
47
58
|
return `La fréquence est le nombre de fois qu'on a obtenu ${caracType} divisé par le nombre total d'essais.`;
|
|
48
59
|
};
|
|
49
|
-
const getCorrection = (identifiers) => {
|
|
60
|
+
const getCorrection = (identifiers, opts) => {
|
|
50
61
|
const { type, k, nbEssais, caracType } = identifiers;
|
|
62
|
+
const useFrac = opts?.useFractions;
|
|
51
63
|
return `On a obtenu $${k}$ fois ${caracType} sur les $${nbEssais}$ lancers. La fréquence d'apparition de ${caracType} est donc :
|
|
52
64
|
|
|
53
65
|
$$
|
|
54
|
-
${frac(k, nbEssais).toTex()} ${approxOrEqual(k / nbEssais, 2).join("")}
|
|
66
|
+
${frac(k, nbEssais).toTex()} ${useFrac ? "" : approxOrEqual(k / nbEssais, 2).join("")}
|
|
55
67
|
$$`;
|
|
56
68
|
};
|
|
57
|
-
const getKeys = (identifiers) => {
|
|
69
|
+
const getKeys = (identifiers, opts) => {
|
|
58
70
|
return [];
|
|
59
71
|
};
|
|
60
|
-
const isAnswerValid = (ans, { answer, k, nbEssais }) => {
|
|
72
|
+
const isAnswerValid = (ans, { answer, k, nbEssais }, opts) => {
|
|
61
73
|
try {
|
|
62
74
|
return rationalVEA(ans, frac(k, nbEssais).simplify().toTex(), {
|
|
63
75
|
decimalPrecision: 2,
|
|
@@ -67,7 +79,7 @@ const isAnswerValid = (ans, { answer, k, nbEssais }) => {
|
|
|
67
79
|
return handleVEAError(err);
|
|
68
80
|
}
|
|
69
81
|
};
|
|
70
|
-
const getCalculateFrequencyQuestion = (
|
|
82
|
+
const getCalculateFrequencyQuestion = (opts) => {
|
|
71
83
|
const type = randint(0, 4);
|
|
72
84
|
const nbEssais = 5 * randint(10, 100);
|
|
73
85
|
const k = randint(1, nbEssais);
|
|
@@ -79,17 +91,29 @@ const getCalculateFrequencyQuestion = (ops) => {
|
|
|
79
91
|
? `la face $${randint(1, 13)}$`
|
|
80
92
|
: `la somme $${randint(1, 13)}$`;
|
|
81
93
|
const identifiers = { type, k, nbEssais, caracType };
|
|
94
|
+
return getQuestionFromIdentifiers(identifiers, opts);
|
|
95
|
+
};
|
|
96
|
+
const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
82
97
|
const question = {
|
|
83
|
-
answer: getAnswer(identifiers),
|
|
84
|
-
instruction: getInstruction(identifiers),
|
|
85
|
-
keys: getKeys(identifiers),
|
|
98
|
+
answer: getAnswer(identifiers, opts),
|
|
99
|
+
instruction: getInstruction(identifiers, opts),
|
|
100
|
+
keys: getKeys(identifiers, opts),
|
|
86
101
|
answerFormat: "tex",
|
|
87
102
|
identifiers,
|
|
88
|
-
hint: getHint(identifiers),
|
|
89
|
-
correction: getCorrection(identifiers),
|
|
103
|
+
hint: getHint(identifiers, opts),
|
|
104
|
+
correction: getCorrection(identifiers, opts),
|
|
90
105
|
};
|
|
91
106
|
return question;
|
|
92
107
|
};
|
|
108
|
+
const options = [
|
|
109
|
+
{
|
|
110
|
+
id: "useFractions",
|
|
111
|
+
label: "Réponse sous forme de fraction",
|
|
112
|
+
target: GeneratorOptionTarget.answer,
|
|
113
|
+
type: GeneratorOptionType.checkbox,
|
|
114
|
+
defaultValue: false,
|
|
115
|
+
},
|
|
116
|
+
];
|
|
93
117
|
export const calculateFrequency = {
|
|
94
118
|
id: "calculateFrequency",
|
|
95
119
|
connector: "=",
|
|
@@ -106,4 +130,5 @@ export const calculateFrequency = {
|
|
|
106
130
|
getCorrection,
|
|
107
131
|
getAnswer,
|
|
108
132
|
hasHintAndCorrection: true,
|
|
133
|
+
options,
|
|
109
134
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1659,7 +1659,9 @@ declare const mathExercises: (Exercise<{
|
|
|
1659
1659
|
caracType: string;
|
|
1660
1660
|
k: number;
|
|
1661
1661
|
nbEssais: number;
|
|
1662
|
-
}, {
|
|
1662
|
+
}, {
|
|
1663
|
+
useFractions?: boolean;
|
|
1664
|
+
}> | Exercise<{
|
|
1663
1665
|
firstValue: number;
|
|
1664
1666
|
askedRank: number;
|
|
1665
1667
|
reason: number;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","source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;;;;;IAOb,WAAW,CAAC,IAAI,EAAE,IAAI;IAYtB,iBAAiB;IAIjB,YAAY,CAAC,KAAK,EAAE,KAAK;IAYzB,gBAAgB,CAAC,KAAK,EAAE,KAAK;IAW7B,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,WAAW,GAAE,OAAe;IAgBnD,aAAa,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM;IAK7C,aAAa,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM;IAW7C,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM;IAa5B,WAAW,MAAO,MAAM,KAAK,KAAK,KAAG,SAAS,CAmB5C;IAEF,oBAAoB,IAAI,SAAS;IAgBjC,WAAW;IAMX,iBAAiB;;;;;IAcjB,KAAK;IAGL,gBAAgB;IAIhB,aAAa,CACX,iBAAiB,EAAE,OAAO,EAC1B,EACE,OAAc,EACd,SAAiB,EACjB,yBAAgC,EAChC,oBAA2B,EAC3B,KAAiB,EACjB,KAAiB,GAClB,GAAE,kBAAuB;IA2C5B,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,EAAE,MAAM;CAW7C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { randomSegmentName } from "../../exercises/utils/geometry/randomSegmentName.js";
|
|
2
2
|
import { randomColor } from "../../geogebra/colors.js";
|
|
3
|
-
import { EqualNode } from "../../tree/nodes/equations/equalNode.js";
|
|
3
|
+
import { equal, EqualNode } from "../../tree/nodes/equations/equalNode.js";
|
|
4
4
|
import { opposite } from "../../tree/nodes/functions/oppositeNode.js";
|
|
5
5
|
import { NumberNode } from "../../tree/nodes/numbers/numberNode.js";
|
|
6
6
|
import { AddNode, add } from "../../tree/nodes/operators/addNode.js";
|
|
@@ -11,7 +11,7 @@ import { VariableNode } from "../../tree/nodes/variables/variableNode.js";
|
|
|
11
11
|
import { GeneralSystem } from "../systems/generalSystem.js";
|
|
12
12
|
import { randint } from "../utils/random/randint.js";
|
|
13
13
|
import { Point, PointConstructor } from "./point.js";
|
|
14
|
-
import {
|
|
14
|
+
import { VectorConstructor } from "./vector.js";
|
|
15
15
|
export class LineConstructor {
|
|
16
16
|
static random(name) {
|
|
17
17
|
const names = randomSegmentName();
|
|
@@ -148,13 +148,13 @@ export class Line {
|
|
|
148
148
|
return equation;
|
|
149
149
|
};
|
|
150
150
|
getCartesianEquation() {
|
|
151
|
-
const u =
|
|
152
|
-
const b =
|
|
153
|
-
const a = u.
|
|
154
|
-
const c =
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
151
|
+
const u = VectorConstructor.fromPoints(this.pointA, this.pointB);
|
|
152
|
+
const b = opposite(u.x);
|
|
153
|
+
const a = u.y;
|
|
154
|
+
const c = add(opposite(multiply(a, this.pointA.x)), opposite(multiply(b, this.pointA.y)));
|
|
155
|
+
return equal(add(add(multiply(a, "x"), multiply(b, "y")), c).simplify({
|
|
156
|
+
forbidFactorize: true,
|
|
157
|
+
}), 0);
|
|
158
158
|
}
|
|
159
159
|
toCartesian() {
|
|
160
160
|
const { a, b, c } = this.toCartesianCoeffs();
|
package/lib/playground.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AA2BA,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AA2BA,eAAO,MAAM,UAAU,YAStB,CAAC"}
|
package/lib/playground.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { EqualNode } from "./tree/nodes/equations/equalNode.js";
|
|
2
|
-
import { parseAlgebraic } from "./tree/parsers/latexParser.js";
|
|
3
1
|
export const playground = () => {
|
|
4
2
|
// console.log(x.equals(x.simplify()));
|
|
5
|
-
const eq = new EqualNode(
|
|
3
|
+
// const eq = new EqualNode(
|
|
4
|
+
// parseAlgebraic("\\frac{3x+2}{4}"),
|
|
5
|
+
// parseAlgebraic("3x"),
|
|
6
|
+
// );
|
|
7
|
+
// console.log(eq.isolate("x").toTex());
|
|
6
8
|
// console.log(parseAlgebraic("\\left|x^2\\right|").toTex());
|
|
9
|
+
// console.log(add(multiply(3, "x"), multiply(4, "x")).simplify().toTex());
|
|
7
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equalNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/equations/equalNode.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,aAAa,EACb,eAAe,EAEhB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAEL,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAQ/B,eAAO,MAAM,KAAK,MACb,aAAa,GAAG,MAAM,GAAG,MAAM,KAC/B,aAAa,GAAG,MAAM,GAAG,MAAM,cAOnC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC;IAClB,SAAS,EAAE,eAAe,CAAC;IAC3B,UAAU,EAAE,eAAe,CAAC;IAC5B,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB,CAAC;AAEF,8BAAsB,oBAAoB;IACxC,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,oBAAoB,GAAG,SAAS;CAOrE;AAED,eAAO,MAAM,WAAW,SAAU,aAAa,KAAG,IAAI,IAAI,SACzB,CAAC;AAElC,qBAAa,SAAU,YAAW,aAAa;IAC7C,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAA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AS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IASpB,aAAa,IAAI,oBAAoB;IAQrC,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IAmBpC,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAM5C,YAAY,IAAI,MAAM;IAGtB,KAAK,IAAI,MAAM;IAIf,QAAQ;IAIR,OAAO;IAIP,OAAO;IAIP,OAAO,CAAC,OAAO,EAAE,MAAM;IAiGvB,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,aAAa;IAG3C,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAGpC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,eAAe,GAAG,MAAM;IAGvE,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,aAAa;CAGzE;AAED,eAAO,MAAM,qBAAqB,MAC7B,aAAa,KACb,aAAa,KACb,aAAa,KACb,aAAa,sBA2DjB,CAAC"}
|
|
@@ -95,17 +95,22 @@ export class EqualNode {
|
|
|
95
95
|
const simpOpts = {
|
|
96
96
|
towardsDistribute: true,
|
|
97
97
|
forbidFactorize: true,
|
|
98
|
+
forceDistributeFractions: false,
|
|
98
99
|
};
|
|
99
100
|
let left = substract(this.leftChild, this.rightChild).simplify(simpOpts);
|
|
100
101
|
// let simp = new EqualNode(left, right);
|
|
102
|
+
let i = 0;
|
|
101
103
|
const recur = () => {
|
|
104
|
+
i++;
|
|
105
|
+
if (i > 100)
|
|
106
|
+
throw new Error("too many iterations in isolate");
|
|
102
107
|
if (isVariableNode(left) && left.name === varName) {
|
|
103
108
|
return;
|
|
104
109
|
}
|
|
105
110
|
else if (isAddNode(left)) {
|
|
106
111
|
// const xIsLeft = ??
|
|
107
112
|
// if xIsLeft, right = right-node.right, left = left-node.right
|
|
108
|
-
const xIsLeft = hasVariableNode(left.leftChild);
|
|
113
|
+
const xIsLeft = hasVariableNode(left.leftChild, varName);
|
|
109
114
|
if (xIsLeft) {
|
|
110
115
|
right = substract(right, left.rightChild).simplify(simpOpts);
|
|
111
116
|
left = substract(left, left.rightChild).simplify(simpOpts);
|
|
@@ -116,7 +121,7 @@ export class EqualNode {
|
|
|
116
121
|
}
|
|
117
122
|
}
|
|
118
123
|
else if (isSubstractNode(left)) {
|
|
119
|
-
const xIsLeft = hasVariableNode(left.leftChild);
|
|
124
|
+
const xIsLeft = hasVariableNode(left.leftChild, varName);
|
|
120
125
|
if (xIsLeft) {
|
|
121
126
|
right = add(right, left.rightChild).simplify(simpOpts);
|
|
122
127
|
left = add(left, left.rightChild).simplify(simpOpts);
|
|
@@ -127,37 +132,37 @@ export class EqualNode {
|
|
|
127
132
|
}
|
|
128
133
|
}
|
|
129
134
|
else if (isMultiplyNode(left)) {
|
|
130
|
-
const xIsLeft = hasVariableNode(left.leftChild);
|
|
135
|
+
const xIsLeft = hasVariableNode(left.leftChild, varName);
|
|
131
136
|
if (xIsLeft) {
|
|
132
|
-
right = frac(right, left.rightChild).simplify(
|
|
133
|
-
left = frac(left, left.rightChild).simplify(
|
|
137
|
+
right = frac(right, left.rightChild).simplify();
|
|
138
|
+
left = frac(left, left.rightChild).simplify();
|
|
134
139
|
}
|
|
135
140
|
else {
|
|
136
|
-
right = frac(right, left.leftChild).simplify(
|
|
137
|
-
left = frac(left, left.leftChild).simplify(
|
|
141
|
+
right = frac(right, left.leftChild).simplify();
|
|
142
|
+
left = frac(left, left.leftChild).simplify();
|
|
138
143
|
}
|
|
139
144
|
}
|
|
140
145
|
else if (isFractionNode(left)) {
|
|
141
|
-
console.log(left.leftChild);
|
|
142
|
-
const xIsLeft = hasVariableNode(left.leftChild);
|
|
146
|
+
// console.log(left.leftChild);
|
|
147
|
+
const xIsLeft = hasVariableNode(left.leftChild, varName);
|
|
143
148
|
if (xIsLeft) {
|
|
144
|
-
right = multiply(right, left.rightChild).simplify(
|
|
145
|
-
left = multiply(left, left.rightChild).simplify(
|
|
149
|
+
right = multiply(right, left.rightChild).simplify();
|
|
150
|
+
left = multiply(left, left.rightChild).simplify();
|
|
146
151
|
}
|
|
147
152
|
else {
|
|
148
153
|
if (right.equals((0).toTree())) {
|
|
149
154
|
//A/f(x) = 0 --> f(x) = 0
|
|
150
|
-
left = left.rightChild.simplify(
|
|
155
|
+
left = left.rightChild.simplify();
|
|
151
156
|
}
|
|
152
157
|
else {
|
|
153
|
-
right = frac(1, right).simplify(
|
|
154
|
-
left = frac(1, left).simplify(
|
|
158
|
+
right = frac(1, right).simplify();
|
|
159
|
+
left = frac(1, left).simplify();
|
|
155
160
|
}
|
|
156
161
|
}
|
|
157
162
|
}
|
|
158
163
|
else if (isOppositeNode(left)) {
|
|
159
|
-
left = opposite(left).simplify(
|
|
160
|
-
right = opposite(right).simplify(
|
|
164
|
+
left = opposite(left).simplify();
|
|
165
|
+
right = opposite(right).simplify();
|
|
161
166
|
}
|
|
162
167
|
else {
|
|
163
168
|
throw new Error("Isolation only implemented for basic operations yet");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasVariableNode.d.ts","sourceRoot":"","sources":["../../../src/tree/nodes/hasVariableNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,eAAO,MAAM,eAAe,MAAO,IAAI,KAAG,
|
|
1
|
+
{"version":3,"file":"hasVariableNode.d.ts","sourceRoot":"","sources":["../../../src/tree/nodes/hasVariableNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,eAAO,MAAM,eAAe,MAAO,IAAI,SAAS,MAAM,KAAG,OAQxD,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { isFunctionNode } from "./functions/functionNode.js";
|
|
2
2
|
import { isOperatorNode } from "./operators/operatorNode.js";
|
|
3
3
|
import { isVariableNode } from "./variables/variableNode.js";
|
|
4
|
-
export const hasVariableNode = (n) => {
|
|
5
|
-
if (isVariableNode(n))
|
|
4
|
+
export const hasVariableNode = (n, name) => {
|
|
5
|
+
if (isVariableNode(n) && (!name || n.name === name))
|
|
6
6
|
return true;
|
|
7
7
|
if (isOperatorNode(n))
|
|
8
|
-
return hasVariableNode(n.leftChild) || hasVariableNode(n.rightChild);
|
|
8
|
+
return (hasVariableNode(n.leftChild, name) || hasVariableNode(n.rightChild, name));
|
|
9
9
|
if (isFunctionNode(n))
|
|
10
|
-
return hasVariableNode(n.child);
|
|
10
|
+
return hasVariableNode(n.child, name);
|
|
11
11
|
return false;
|
|
12
12
|
};
|
|
@@ -11,7 +11,7 @@ export declare class AddNode implements CommutativeOperatorNode {
|
|
|
11
11
|
opts?: NodeOptions;
|
|
12
12
|
isNumeric: boolean;
|
|
13
13
|
constructor(leftChild: AlgebraicNode, rightChild: AlgebraicNode, opts?: NodeOptions);
|
|
14
|
-
shuffle: () =>
|
|
14
|
+
shuffle: () => AddNode;
|
|
15
15
|
deepShuffle: (opts?: DeepShuffleOpts) => AddNode;
|
|
16
16
|
toMathString(): string;
|
|
17
17
|
toEquivalentNodes(opts?: NodeOptions): AlgebraicNode[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/addNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,WAAW,EAIZ,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAcrE,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,OAAO,CAE/C;AAED,eAA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W;IAUpB,OAAO,gBAGL;IACF,WAAW,UAAW,eAAe,aAUnC;IAEF,YAAY,IAAI,MAAM;IAItB,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,aAAa,EAAE;IAoCtD,SAAS,IAAI,MAAM,EAAE;IAIrB,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAK5C,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM;IAerC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMtC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAsJ/C,aAAa;;;;;;;;;IAOb,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAUpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAMxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;IAMvD,mBAAmB,CAAC,IAAI,CAAC,EAAE,eAAe;CAK3C"}
|
|
@@ -38,7 +38,8 @@ export class AddNode {
|
|
|
38
38
|
}
|
|
39
39
|
shuffle = () => {
|
|
40
40
|
if (coinFlip())
|
|
41
|
-
|
|
41
|
+
return this;
|
|
42
|
+
return new AddNode(this.rightChild, this.leftChild, this.opts);
|
|
42
43
|
};
|
|
43
44
|
deepShuffle = (opts) => {
|
|
44
45
|
const left = isCommutativeOperatorNode(this.leftChild)
|
|
@@ -33,6 +33,6 @@ export declare class DivideNode implements OperatorNode {
|
|
|
33
33
|
equals(node: AlgebraicNode): boolean;
|
|
34
34
|
toDetailedEvaluation(vars: Record<string, AlgebraicNode>): DivideNode;
|
|
35
35
|
derivative(varName?: string | undefined): AlgebraicNode;
|
|
36
|
-
shuffle: () =>
|
|
36
|
+
shuffle: () => this;
|
|
37
37
|
}
|
|
38
38
|
//# sourceMappingURL=divideNode.d.ts.map
|
|
@@ -1 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oot":"","sources":["../../../../src/tree/nodes/operators/divideNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,wBAAgB,YAAY,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,UAAU,CAErD;AAED,eAAO,MAAM,MAAM,MACd,aAAa,GAAG,MAAM,GAAG,MAAM,KAC/B,aAAa,GAAG,MAAM,GAAG,MAAM,SAC3B,WAAW,eAOnB,CAAC;AA4BF,qBAAa,UAAW,YAAW,YAAY;IAC7C,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB;;;OAGG;gBAES,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa;IAQ/D,YAAY,IAAI,MAAM;IAGtB,kBAAkB;IAIlB,aAAa;;;;;;;;;IAQb,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IAYpC,cAAc,IAAI,MAAM,EAAE;IAI1B,KAAK,IAAI,MAAM;IAGf,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMtC,QAAQ;IAGR,MAAM,CAAC,IAAI,EAAE,aAAa;IAO1B,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAMxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;IAGvD,OAAO,aAEL;CACH"}
|
|
@@ -12,7 +12,7 @@ export declare class MultiplyNode implements CommutativeOperatorNode {
|
|
|
12
12
|
type: NodeType;
|
|
13
13
|
isNumeric: boolean;
|
|
14
14
|
constructor(leftChild: AlgebraicNode, rightChild: AlgebraicNode, opts?: NodeOptions);
|
|
15
|
-
shuffle: () =>
|
|
15
|
+
shuffle: () => MultiplyNode;
|
|
16
16
|
deepShuffle: (opts?: DeepShuffleOpts) => MultiplyNode;
|
|
17
17
|
toReversed: () => MultiplyNode;
|
|
18
18
|
toMathString(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiplyNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/multiplyNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,WAAW,EAGZ,MAAM,mBAAmB,CAAC;AAY3B,OAAO,EACL,aAAa,EACb,eAAe,EAEhB,MAAM,qBAAqB,CAAC;AAU7B,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AAED,eAAO,MAAM,QAAQ,MAChB,aAAa,GAAG,MAAM,GAAG,MAAM,KAC/B,aAAa,GAAG,MAAM,GAAG,MAAM,SAC3B,WAAW,iBAOnB,CAAC;AACF,eAAO,MAAM,iBAAiB,QAAS,aAAa,EAAE,SAYrD,CAAC;AACF,qBAAa,YAAa,YAAW,uBAAuB;IAC1D,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,OAAO,
|
|
1
|
+
{"version":3,"file":"multiplyNode.d.ts","sourceRoot":"","s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ItC,IAAI;IAGJ,cAAc;IACd,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAsL/C,mBAAmB,CAAC,IAAI,CAAC,EAAE,eAAe;IAM1C,MAAM,CAAC,IAAI,EAAE,aAAa;IAU1B,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAQxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;CAMxD"}
|
|
@@ -54,7 +54,8 @@ export class MultiplyNode {
|
|
|
54
54
|
}
|
|
55
55
|
shuffle = () => {
|
|
56
56
|
if (coinFlip())
|
|
57
|
-
|
|
57
|
+
return this;
|
|
58
|
+
return new MultiplyNode(this.rightChild, this.leftChild, this.opts);
|
|
58
59
|
};
|
|
59
60
|
deepShuffle = (opts) => {
|
|
60
61
|
const left = isCommutativeOperatorNode(this.leftChild)
|
|
@@ -23,7 +23,7 @@ export type DeepShuffleOpts = {
|
|
|
23
23
|
nodeIdsToShuffle: OperatorIds[];
|
|
24
24
|
};
|
|
25
25
|
export interface CommutativeOperatorNode extends OperatorNode {
|
|
26
|
-
shuffle: () =>
|
|
26
|
+
shuffle: () => CommutativeOperatorNode;
|
|
27
27
|
deepShuffle: (opts?: DeepShuffleOpts) => CommutativeOperatorNode;
|
|
28
28
|
toAllTexs: () => string[];
|
|
29
29
|
}
|
|
@@ -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,qBAAqB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAqB,MAAM,YAAY,CAAC;AAErD,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,wBAAgB,yBAAyB,CACvC,CAAC,EAAE,IAAI,GACN,CAAC,IAAI,uBAAuB,CAI9B;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,gBAAgB,EAAE,WAAW,EAAE,CAAC;CACjC,CAAC;AACF,MAAM,WAAW,uBAAwB,SAAQ,YAAY;IAC3D,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"operatorNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/operatorNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAqB,MAAM,YAAY,CAAC;AAErD,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,wBAAgB,yBAAyB,CACvC,CAAC,EAAE,IAAI,GACN,CAAC,IAAI,uBAAuB,CAI9B;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,gBAAgB,EAAE,WAAW,EAAE,CAAC;CACjC,CAAC;AACF,MAAM,WAAW,uBAAwB,SAAQ,YAAY;IAC3D,OAAO,EAAE,MAAM,uBAAuB,CAAC;IACvC,WAAW,EAAE,CAAC,IAAI,CAAC,EAAE,eAAe,KAAK,uBAAuB,CAAC;IACjE,SAAS,EAAE,MAAM,MAAM,EAAE,CAAC;CAC3B"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Node, NodeIds, NodeOptions, NodeType, ToTexOptions } from "../node.js";
|
|
2
2
|
import { OperatorIds, OperatorNode } from "./operatorNode.js";
|
|
3
|
+
import { AddNode } from "./addNode.js";
|
|
3
4
|
import { AlgebraicNode, SimplifyOptions } from "../algebraicNode.js";
|
|
4
5
|
export declare function isSubstractNode(a: Node): a is SubstractNode;
|
|
5
6
|
export declare const substract: (a: AlgebraicNode | number | string, b: AlgebraicNode | number | string) => SubstractNode;
|
|
@@ -30,6 +31,6 @@ export declare class SubstractNode implements OperatorNode {
|
|
|
30
31
|
equals(node: AlgebraicNode): boolean;
|
|
31
32
|
toDetailedEvaluation(vars: Record<string, AlgebraicNode>): SubstractNode;
|
|
32
33
|
derivative(varName?: string | undefined): AlgebraicNode;
|
|
33
|
-
shuffle: () =>
|
|
34
|
+
shuffle: () => this | AddNode;
|
|
34
35
|
}
|
|
35
36
|
//# sourceMappingURL=substractNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"substractNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/substractNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"substractNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/substractNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EA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AO,uBAGL;CACH"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// import { subtract } from "mathjs";
|
|
2
2
|
import { NodeIds, NodeType } from "../node.js";
|
|
3
3
|
import { OperatorIds, isOperatorNode } from "./operatorNode.js";
|
|
4
|
-
import { OppositeNode } from "../functions/oppositeNode.js";
|
|
5
|
-
import { AddNode } from "./addNode.js";
|
|
4
|
+
import { opposite, OppositeNode } from "../functions/oppositeNode.js";
|
|
5
|
+
import { add, AddNode } from "./addNode.js";
|
|
6
6
|
import { coinFlip } from "../../../utils/alea/coinFlip.js";
|
|
7
7
|
import { colorize } from "../../../utils/latex/colorize.js";
|
|
8
8
|
export function isSubstractNode(a) {
|
|
@@ -94,6 +94,7 @@ export class SubstractNode {
|
|
|
94
94
|
}
|
|
95
95
|
shuffle = () => {
|
|
96
96
|
if (coinFlip())
|
|
97
|
-
|
|
97
|
+
return this;
|
|
98
|
+
return add(opposite(this.rightChild), this.leftChild);
|
|
98
99
|
};
|
|
99
100
|
}
|