math-exercises 3.0.38 → 3.0.39
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/fractionsSumsMultiplesDenominators.js +1 -1
- package/lib/exercises/math/calcul/fractions/simplifyFraction.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/simplifyFraction.js +37 -0
- package/lib/exercises/math/calcul/rounding/rounding.d.ts +8 -5
- package/lib/exercises/math/calcul/rounding/rounding.d.ts.map +1 -1
- package/lib/exercises/math/calcul/rounding/rounding.js +63 -31
- package/lib/exercises/math/calculLitteral/simplifying/reduceExpression.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/simplifying/reduceExpression.js +60 -7
- package/lib/exercises/math/functions/affines/leadingCoefficient.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/leadingCoefficient.js +42 -4
- package/lib/exercises/math/functions/trinoms/factoForm/factorizedFormFromRoots.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/factoForm/factorizedFormFromRoots.js +49 -0
- package/lib/exercises/math/functions/trinoms/parabole/trinomSymetryAxisFromFacto.js +1 -1
- package/lib/exercises/math/functions/trinoms/roots/findSecondRoot.js +1 -1
- package/lib/exercises/math/functions/trinoms/roots/rootsProduct.js +1 -1
- package/lib/exercises/math/functions/trinoms/roots/rootsSum.js +1 -1
- package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLine.js +1 -1
- package/lib/exercises/math/geometry/perimeters/rectanglePerimeter.d.ts.map +1 -1
- package/lib/exercises/math/geometry/perimeters/rectanglePerimeter.js +0 -2
- package/lib/exercises/math/geometry/vectors/chasles.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/chasles.js +0 -2
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductViaCos.d.ts +1 -0
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductViaCos.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductViaCos.js +32 -14
- package/lib/exercises/math/probaStat/diceBasicProbas.js +1 -1
- package/lib/exercises/math/sequences/arithmetic/arithmeticFindReason.d.ts.map +1 -1
- package/lib/exercises/math/sequences/arithmetic/arithmeticFindReason.js +43 -8
- package/lib/exercises/math/sequences/arithmetic/arithmeticFindReasonRandomRange.d.ts.map +1 -1
- package/lib/exercises/math/sequences/arithmetic/arithmeticFindReasonRandomRange.js +0 -2
- package/lib/exercises/math/sequences/arithmetic/arithmeticReasonUsage.d.ts.map +1 -1
- package/lib/exercises/math/sequences/arithmetic/arithmeticReasonUsage.js +51 -8
- package/lib/geogebra/geogebraConstructor.d.ts +3 -1
- package/lib/geogebra/geogebraConstructor.d.ts.map +1 -1
- package/lib/geogebra/geogebraConstructor.js +5 -2
- package/lib/index.d.ts +5 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/latexTester.js +1 -0
- package/lib/math/numbers/integer/integer.d.ts +1 -1
- package/lib/math/numbers/rationals/rational.d.ts +1 -0
- package/lib/math/numbers/rationals/rational.d.ts.map +1 -1
- package/lib/math/numbers/rationals/rational.js +3 -0
- package/lib/math/utils/stats/generateAffineCloud.js +1 -1
- package/lib/playground.d.ts.map +1 -1
- package/lib/playground.js +5 -3
- package/lib/tests/pdfExo.test.d.ts.map +1 -1
- package/lib/tests/pdfExo.test.js +2 -2
- package/lib/tree/nodes/functions/oppositeNode.d.ts +1 -2
- package/lib/tree/nodes/functions/oppositeNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/sqrtNode.d.ts +2 -1
- package/lib/tree/nodes/functions/sqrtNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/sqrtNode.js +47 -2
- package/lib/tree/nodes/node.d.ts +1 -0
- package/lib/tree/nodes/node.d.ts.map +1 -1
- package/lib/tree/nodes/numbers/numberNode.d.ts +1 -1
- package/lib/tree/nodes/numbers/numberNode.d.ts.map +1 -1
- package/lib/tree/nodes/numbers/numberNode.js +1 -1
- package/lib/tree/nodes/operators/addNode.d.ts +1 -0
- package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.js +6 -0
- package/lib/tree/nodes/operators/fractionNode.d.ts +1 -1
- package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/fractionNode.js +1 -1
- package/lib/tree/nodes/operators/multiplyNode.d.ts +1 -0
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +7 -0
- package/lib/utils/iterators/dualReturn.d.ts +2 -0
- package/lib/utils/iterators/dualReturn.d.ts.map +1 -0
- package/lib/utils/iterators/dualReturn.js +19 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scalarProductViaCos.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/geometry/vectors/scalarProduct/scalarProductViaCos.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"scalarProductViaCos.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/geometry/vectors/scalarProduct/scalarProductViaCos.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAgBrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AA4EF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAcrD,CAAC"}
|
|
@@ -7,26 +7,41 @@ import { MultiplyNode } from "../../../../../tree/nodes/operators/multiplyNode.j
|
|
|
7
7
|
import { randomLetter } from "../../../../../utils/strings/randomLetter.js";
|
|
8
8
|
import { shuffle } from "../../../../../utils/alea/shuffle.js";
|
|
9
9
|
import { random } from "../../../../../utils/alea/random.js";
|
|
10
|
+
import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
|
|
11
|
+
import { parseAlgebraic } from "../../../../../tree/parsers/latexParser.js";
|
|
10
12
|
//|u| |v| cos(u,v)
|
|
13
|
+
const getInstruction = (identifiers) => {
|
|
14
|
+
const { AB, AC, trigoPoint, letters } = identifiers;
|
|
15
|
+
const [letterA, letterB, letterC] = letters;
|
|
16
|
+
const trigo = mainTrigoValues.find((v) => v.point === trigoPoint);
|
|
17
|
+
return `Soient trois points $${letterA}$, $${letterB}$ et $${letterC}$ tels que $${letterA}${letterB} = ${AB}$, $${letterA}${letterC}= ${AC}$, et $\\widehat{${letterB}${letterA}${letterC}} = ${trigo.angle.toTex()}$.
|
|
18
|
+
|
|
19
|
+
Calculer le produit scalaire $\\overrightarrow{${letterA}${letterB}}\\cdot \\overrightarrow{${letterA}${letterC}}$.`;
|
|
20
|
+
};
|
|
21
|
+
const getAnswer = (identifiers) => {
|
|
22
|
+
const { AB, AC, trigoPoint } = identifiers;
|
|
23
|
+
const trigo = mainTrigoValues.find((v) => v.point === trigoPoint);
|
|
24
|
+
const answer = new MultiplyNode(new NumberNode(AB * AC), trigo.cos)
|
|
25
|
+
.simplify()
|
|
26
|
+
.toTex();
|
|
27
|
+
return answer;
|
|
28
|
+
};
|
|
11
29
|
const getScalarProductViaCosQuestion = () => {
|
|
12
30
|
const AB = randint(1, 10);
|
|
13
31
|
const AC = randint(1, 10);
|
|
14
32
|
const trigo = random(mainTrigoValues);
|
|
15
|
-
const answer = new MultiplyNode(new NumberNode(AB * AC), trigo.cos)
|
|
16
|
-
.simplify()
|
|
17
|
-
.toTex();
|
|
18
33
|
const letters = [];
|
|
19
34
|
for (let i = 0; i < 3; i++) {
|
|
20
35
|
letters.push(randomLetter(true, letters));
|
|
21
36
|
}
|
|
22
37
|
letters.sort((a, b) => a.localeCompare(b));
|
|
23
|
-
const
|
|
38
|
+
const identifiers = { AB, AC, trigoPoint: trigo.point, letters };
|
|
24
39
|
const question = {
|
|
25
|
-
answer,
|
|
26
|
-
instruction:
|
|
40
|
+
answer: getAnswer(identifiers),
|
|
41
|
+
instruction: getInstruction(identifiers),
|
|
27
42
|
keys: ["pi"],
|
|
28
43
|
answerFormat: "tex",
|
|
29
|
-
identifiers
|
|
44
|
+
identifiers,
|
|
30
45
|
};
|
|
31
46
|
return question;
|
|
32
47
|
};
|
|
@@ -42,23 +57,26 @@ const getPropositions = (n, { answer, AB, AC, trigoPoint }) => {
|
|
|
42
57
|
}
|
|
43
58
|
return shuffle(propositions);
|
|
44
59
|
};
|
|
45
|
-
const isAnswerValid = (ans, { AB, AC, trigoPoint }) => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
60
|
+
const isAnswerValid = (ans, { answer, AB, AC, trigoPoint }) => {
|
|
61
|
+
try {
|
|
62
|
+
const parsed = parseAlgebraic(ans);
|
|
63
|
+
return parsed.simplify().toTex() === answer;
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
return handleVEAError(err);
|
|
67
|
+
}
|
|
50
68
|
};
|
|
51
69
|
export const scalarProductViaCos = {
|
|
52
70
|
id: "scalarProductViaCos",
|
|
53
71
|
connector: "=",
|
|
54
72
|
label: "Calculer un produit scalaire (formule avec $cos$)",
|
|
55
|
-
levels: ["1reSpé"],
|
|
56
73
|
isSingleStep: true,
|
|
57
|
-
sections: ["Vecteurs", "Produit scalaire"],
|
|
58
74
|
generator: (nb) => getDistinctQuestions(getScalarProductViaCosQuestion, nb),
|
|
59
75
|
qcmTimer: 60,
|
|
60
76
|
freeTimer: 60,
|
|
61
77
|
getPropositions,
|
|
62
78
|
isAnswerValid,
|
|
63
79
|
subject: "Mathématiques",
|
|
80
|
+
getInstruction,
|
|
81
|
+
getAnswer,
|
|
64
82
|
};
|
|
@@ -36,7 +36,7 @@ Puisque le dé est équilibré, chaque face du dé a autant de chances d'appara
|
|
|
36
36
|
Ainsi, la probabilité d'obtenir une face ${parity} est :
|
|
37
37
|
|
|
38
38
|
$$
|
|
39
|
-
${frac(count, nbFaces).
|
|
39
|
+
${frac(count, nbFaces).toSimplificationTex()}
|
|
40
40
|
$$`;
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arithmeticFindReason.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/arithmetic/arithmeticFindReason.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"arithmeticFindReason.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/arithmetic/arithmeticFindReason.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAoEF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAgBtD,CAAC"}
|
|
@@ -1,21 +1,53 @@
|
|
|
1
1
|
import { addValidProp, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
2
|
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
3
|
import { randint } from "../../../../math/utils/random/randint.js";
|
|
4
|
+
import { substract } from "../../../../tree/nodes/operators/substractNode.js";
|
|
4
5
|
import { shuffle } from "../../../../utils/alea/shuffle.js";
|
|
6
|
+
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
7
|
+
const getInstruction = (identifiers) => {
|
|
8
|
+
const { rank1, value1, reason } = identifiers;
|
|
9
|
+
const rank2 = rank1 + 1;
|
|
10
|
+
const value2 = reason + value1;
|
|
11
|
+
return `Soit $u$ une suite arithmétique telle que $u_{${rank1}} = ${value1}$ et $u_{${rank2}} = ${value2}$.
|
|
12
|
+
|
|
13
|
+
Quelle est la raison de la suite $(u_n)$ ?`;
|
|
14
|
+
};
|
|
15
|
+
const getAnswer = (identifiers) => {
|
|
16
|
+
const { rank1, value1, reason } = identifiers;
|
|
17
|
+
const answer = reason + "";
|
|
18
|
+
return answer;
|
|
19
|
+
};
|
|
20
|
+
const getHint = (identifiers) => {
|
|
21
|
+
return `La raison d'une suite arithmétique est le nombre par lequel on additionne un terme pour obtenir le suivant.`;
|
|
22
|
+
};
|
|
23
|
+
const getCorrection = (identifiers) => {
|
|
24
|
+
const { rank1, value1, reason } = identifiers;
|
|
25
|
+
const rank2 = rank1 + 1;
|
|
26
|
+
const value2 = reason + value1;
|
|
27
|
+
return `La raison de $u$ est le nombre par lequel on a additionné $u_{${rank1}}$ pour obtenir $u_{${rank2}}$.
|
|
28
|
+
|
|
29
|
+
Ainsi, la raison $r$ de la suite $u$ est :
|
|
30
|
+
|
|
31
|
+
${alignTex([
|
|
32
|
+
["r", "=", `u_{${rank2}} - u_{${rank1}}`],
|
|
33
|
+
["", "=", substract(value2, value1).toTex()],
|
|
34
|
+
["", "=", getAnswer(identifiers)],
|
|
35
|
+
])}`;
|
|
36
|
+
};
|
|
5
37
|
const getArithmeticFindReason = () => {
|
|
6
38
|
const rank1 = randint(0, 10);
|
|
7
|
-
const rank2 = rank1 + 1;
|
|
8
39
|
const reason = randint(-10, 10, [0]);
|
|
9
40
|
const value1 = randint(-10, 10);
|
|
10
|
-
const
|
|
11
|
-
const answer = reason + "";
|
|
41
|
+
const identifiers = { rank1, reason, value1 };
|
|
12
42
|
const question = {
|
|
13
|
-
instruction:
|
|
43
|
+
instruction: getInstruction(identifiers),
|
|
14
44
|
startStatement: "r",
|
|
15
|
-
answer,
|
|
45
|
+
answer: getAnswer(identifiers),
|
|
16
46
|
keys: [],
|
|
17
47
|
answerFormat: "tex",
|
|
18
|
-
identifiers
|
|
48
|
+
identifiers,
|
|
49
|
+
hint: getHint(identifiers),
|
|
50
|
+
correction: getCorrection(identifiers),
|
|
19
51
|
};
|
|
20
52
|
return question;
|
|
21
53
|
};
|
|
@@ -34,8 +66,6 @@ export const arithmeticFindReason = {
|
|
|
34
66
|
id: "arithmeticFindReason",
|
|
35
67
|
connector: "=",
|
|
36
68
|
label: "Déterminer la raison d'une suite arithmétique",
|
|
37
|
-
levels: ["1reESM", "1reSpé", "1reTech", "1rePro", "TermTech", "TermPro"],
|
|
38
|
-
sections: ["Suites"],
|
|
39
69
|
isSingleStep: false,
|
|
40
70
|
getPropositions,
|
|
41
71
|
isAnswerValid,
|
|
@@ -43,4 +73,9 @@ export const arithmeticFindReason = {
|
|
|
43
73
|
freeTimer: 60,
|
|
44
74
|
generator: (nb) => getDistinctQuestions(getArithmeticFindReason, nb),
|
|
45
75
|
subject: "Mathématiques",
|
|
76
|
+
getAnswer,
|
|
77
|
+
getInstruction,
|
|
78
|
+
getHint,
|
|
79
|
+
getCorrection,
|
|
80
|
+
hasHintAndCorrection: true,
|
|
46
81
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arithmeticFindReasonRandomRange.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/arithmetic/arithmeticFindReasonRandomRange.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAKrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAmCF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"arithmeticFindReasonRandomRange.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/arithmetic/arithmeticFindReasonRandomRange.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAKrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAmCF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,CAYjE,CAAC"}
|
|
@@ -34,8 +34,6 @@ export const arithmeticFindReasonRandomRange = {
|
|
|
34
34
|
id: "arithmeticFindReasonRandomRange",
|
|
35
35
|
connector: "=",
|
|
36
36
|
label: "Déterminer la raison d'une suite arithmétique (écart aléatoire)",
|
|
37
|
-
levels: ["1reESM", "1reSpé", "1reTech", "1rePro", "TermTech", "TermPro"],
|
|
38
|
-
sections: ["Suites"],
|
|
39
37
|
isSingleStep: false,
|
|
40
38
|
getPropositions,
|
|
41
39
|
isAnswerValid,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arithmeticReasonUsage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/arithmetic/arithmeticReasonUsage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"arithmeticReasonUsage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/arithmetic/arithmeticReasonUsage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AA2EF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAgBvD,CAAC"}
|
|
@@ -1,20 +1,60 @@
|
|
|
1
1
|
import { addValidProp, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
2
|
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
3
|
import { randint } from "../../../../math/utils/random/randint.js";
|
|
4
|
+
import { add } from "../../../../tree/nodes/operators/addNode.js";
|
|
4
5
|
import { shuffle } from "../../../../utils/alea/shuffle.js";
|
|
6
|
+
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
7
|
+
const getStartStatement = (identifiers) => {
|
|
8
|
+
const { reason, startRank, startValue } = identifiers;
|
|
9
|
+
const askedRank = startRank + 1;
|
|
10
|
+
return `u_{${askedRank}}`;
|
|
11
|
+
};
|
|
12
|
+
const getInstruction = (identifiers) => {
|
|
13
|
+
const { reason, startRank, startValue } = identifiers;
|
|
14
|
+
const askedRank = startRank + 1;
|
|
15
|
+
return `Soit $u$ une suite arithmétique de raison $r = ${reason}$ et telle que $u_{${startRank}} = ${startValue}$.
|
|
16
|
+
|
|
17
|
+
Calculer $u_{${askedRank}}$.`;
|
|
18
|
+
};
|
|
19
|
+
const getAnswer = (identifiers) => {
|
|
20
|
+
const { reason, startRank, startValue } = identifiers;
|
|
21
|
+
const answer = (startValue + reason).toString();
|
|
22
|
+
return answer;
|
|
23
|
+
};
|
|
24
|
+
const getHint = (identifiers) => {
|
|
25
|
+
const { reason, startRank, startValue } = identifiers;
|
|
26
|
+
return `Une suite arithmétique est une suite telle que, pour passer d'un terme de la suite au suivant, on additionne toujours par la raison de la suite.
|
|
27
|
+
|
|
28
|
+
En d'autres termes, si $u$ est une suite arithmétique de raison $r$, alors pour tout entier $n$, on a :
|
|
29
|
+
|
|
30
|
+
$$
|
|
31
|
+
u_{n+1} = u_n + r
|
|
32
|
+
$$`;
|
|
33
|
+
};
|
|
34
|
+
const getCorrection = (identifiers) => {
|
|
35
|
+
const { reason, startRank, startValue } = identifiers;
|
|
36
|
+
return `Puisque $u$ est une suite arithmétique, on a :
|
|
37
|
+
|
|
38
|
+
${alignTex([
|
|
39
|
+
[getStartStatement(identifiers), "=", add(`u_{${startRank}}`, "r").toTex()],
|
|
40
|
+
["", "=", add(startValue, reason).toTex()],
|
|
41
|
+
["", "=", getAnswer(identifiers)],
|
|
42
|
+
])}`;
|
|
43
|
+
};
|
|
5
44
|
const getArithmeticReasonUsage = () => {
|
|
6
45
|
const reason = randint(-10, 10, [0]);
|
|
7
46
|
const startRank = randint(0, 20);
|
|
8
|
-
const askedRank = startRank + 1;
|
|
9
47
|
const startValue = randint(-10, 10);
|
|
10
|
-
const
|
|
48
|
+
const identifiers = { reason, startRank, startValue };
|
|
11
49
|
const question = {
|
|
12
|
-
instruction:
|
|
13
|
-
startStatement:
|
|
14
|
-
answer,
|
|
50
|
+
instruction: getInstruction(identifiers),
|
|
51
|
+
startStatement: getStartStatement(identifiers),
|
|
52
|
+
answer: getAnswer(identifiers),
|
|
15
53
|
keys: ["u", "underscore", "equal"],
|
|
16
54
|
answerFormat: "tex",
|
|
17
|
-
identifiers
|
|
55
|
+
identifiers,
|
|
56
|
+
hint: getHint(identifiers),
|
|
57
|
+
correction: getCorrection(identifiers),
|
|
18
58
|
};
|
|
19
59
|
return question;
|
|
20
60
|
};
|
|
@@ -38,8 +78,6 @@ export const arithmeticReasonUsage = {
|
|
|
38
78
|
id: "arithmeticReasonUsage",
|
|
39
79
|
connector: "=",
|
|
40
80
|
label: "Utiliser la raison d'une suite arithmétique",
|
|
41
|
-
levels: ["1reESM", "1reSpé", "1reTech", "1rePro", "TermTech", "TermPro"],
|
|
42
|
-
sections: ["Suites"],
|
|
43
81
|
isSingleStep: false,
|
|
44
82
|
generator: (nb) => getDistinctQuestions(getArithmeticReasonUsage, nb),
|
|
45
83
|
qcmTimer: 60,
|
|
@@ -47,4 +85,9 @@ export const arithmeticReasonUsage = {
|
|
|
47
85
|
getPropositions,
|
|
48
86
|
isAnswerValid,
|
|
49
87
|
subject: "Mathématiques",
|
|
88
|
+
getAnswer,
|
|
89
|
+
getInstruction,
|
|
90
|
+
getHint,
|
|
91
|
+
getCorrection,
|
|
92
|
+
hasHintAndCorrection: true,
|
|
50
93
|
};
|
|
@@ -8,6 +8,8 @@ type GetAdaptedCoords = {
|
|
|
8
8
|
zMin?: number;
|
|
9
9
|
zMax?: number;
|
|
10
10
|
forceShowAxes?: boolean;
|
|
11
|
+
minCoords?: number[];
|
|
12
|
+
ratio?: number;
|
|
11
13
|
};
|
|
12
14
|
type GetOptionsProps = {
|
|
13
15
|
coords: number[];
|
|
@@ -33,7 +35,7 @@ export declare class GeogebraConstructor {
|
|
|
33
35
|
hideFullScreenButton?: boolean;
|
|
34
36
|
constructor(options: Omit<GeogebraOptions, "coords">);
|
|
35
37
|
getCoordsForPoints(points: Point[]): number[];
|
|
36
|
-
getAdaptedCoords({ xMin, xMax, yMin, yMax, zMin, zMax, forceShowAxes, }: GetAdaptedCoords): number[];
|
|
38
|
+
getAdaptedCoords({ xMin, xMax, yMin, yMax, zMin, zMax, forceShowAxes, minCoords, ratio, }: GetAdaptedCoords): number[];
|
|
37
39
|
getOptions({ coords }: GetOptionsProps): GeogebraOptions;
|
|
38
40
|
}
|
|
39
41
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geogebraConstructor.d.ts","sourceRoot":"","sources":["../../src/geogebra/geogebraConstructor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,eAAe,EAChB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAErD,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"geogebraConstructor.d.ts","sourceRoot":"","sources":["../../src/geogebra/geogebraConstructor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,eAAe,EAChB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAErD,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC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AC,EACf,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,aAAa,EACb,SAAS,EACT,KAAK,GACN,EAAE,gBAAgB;IAsDnB,UAAU,CAAC,EAAE,MAAM,EAAE,EAAE,eAAe,GAAG,eAAe;CAuBzD"}
|
|
@@ -45,11 +45,11 @@ export class GeogebraConstructor {
|
|
|
45
45
|
const yMax = Math.max(...points.map((p) => p.y.evaluate()));
|
|
46
46
|
return this.getAdaptedCoords({ xMin, xMax, yMin, yMax });
|
|
47
47
|
}
|
|
48
|
-
getAdaptedCoords({ xMin, xMax, yMin, yMax, zMin, zMax, forceShowAxes, }) {
|
|
48
|
+
getAdaptedCoords({ xMin, xMax, yMin, yMax, zMin, zMax, forceShowAxes, minCoords, ratio, }) {
|
|
49
49
|
const showAxes = forceShowAxes ?? (this.hideAxes ? false : true);
|
|
50
50
|
const xDelta = xMax - xMin;
|
|
51
51
|
const yDelta = yMax - yMin;
|
|
52
|
-
const coeff = 0.1;
|
|
52
|
+
const coeff = ratio ?? 0.1;
|
|
53
53
|
if (this.is3D && zMin !== undefined && zMax !== undefined) {
|
|
54
54
|
const zDelta = zMax - zMin;
|
|
55
55
|
const coords = [
|
|
@@ -91,6 +91,9 @@ export class GeogebraConstructor {
|
|
|
91
91
|
coords[2] = Math.min(-1, coords[2]);
|
|
92
92
|
coords[3] = Math.max(1, coords[3]);
|
|
93
93
|
}
|
|
94
|
+
if (minCoords) {
|
|
95
|
+
return coords.map((coord, index) => (index % 2 === 0 ? Math.min : Math.max)(minCoords[index], coord));
|
|
96
|
+
}
|
|
94
97
|
return coords;
|
|
95
98
|
}
|
|
96
99
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -178,7 +178,9 @@ declare const mathExercises: (Exercise<{
|
|
|
178
178
|
precisionAsked: number;
|
|
179
179
|
decimal: number;
|
|
180
180
|
precision: number;
|
|
181
|
-
}, {
|
|
181
|
+
}, {
|
|
182
|
+
precisionAsked: number;
|
|
183
|
+
}> | Exercise<{
|
|
182
184
|
nb: number;
|
|
183
185
|
rankAsked: number;
|
|
184
186
|
}, {}> | Exercise<{
|
|
@@ -1192,6 +1194,7 @@ declare const mathExercises: (Exercise<{
|
|
|
1192
1194
|
AB: number;
|
|
1193
1195
|
AC: number;
|
|
1194
1196
|
trigoPoint: string;
|
|
1197
|
+
letters: string[];
|
|
1195
1198
|
}, {}> | Exercise<{
|
|
1196
1199
|
c: number;
|
|
1197
1200
|
vec1Name: string;
|
|
@@ -2023,6 +2026,7 @@ declare const pcExercises: (Exercise<{
|
|
|
2023
2026
|
AB: number;
|
|
2024
2027
|
AC: number;
|
|
2025
2028
|
trigoPoint: string;
|
|
2029
|
+
letters: string[];
|
|
2026
2030
|
}, {}> | Exercise<{
|
|
2027
2031
|
total: number;
|
|
2028
2032
|
lefties: number;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,QAAA,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
|
package/lib/latexTester.js
CHANGED
|
@@ -15,7 +15,7 @@ export declare class Integer implements Nombre {
|
|
|
15
15
|
constructor(value: number, tex?: string);
|
|
16
16
|
equals(n: Nombre): boolean;
|
|
17
17
|
toTree(): NumberNode;
|
|
18
|
-
times(n: number | Nombre):
|
|
18
|
+
times(n: number | Nombre): Integer | Decimal;
|
|
19
19
|
round(precision: number): Integer;
|
|
20
20
|
divide(nb: Nombre): Nombre;
|
|
21
21
|
multiply(nb: Nombre): Rational | Integer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rational.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/rationals/rational.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE,OAAO,EAAQ,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAQ7D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAElD,8BAAsB,mBAAmB;IACvC;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,MAAM,GAAE,MAAW;IAW7C,MAAM,CAAC,kBAAkB,CACvB,GAAG,GAAE,MAAW,EAChB,EAAE,UAAkB,EAAE,GAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAO;IASvD,MAAM,CAAC,uBAAuB,CAAC,QA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MAAW,EAChB,EAAE,UAAkB,EAAE,GAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAO;IASvD,MAAM,CAAC,uBAAuB,CAAC,QAAQ,GAAE,MAAW;IAKpD,MAAM,CAAC,0BAA0B,CAAC,GAAG,GAAE,MAAW;IAQlD,MAAM,CAAC,kBAAkB,CAAC,GAAG,GAAE,MAAW;CAO3C;AAED,qBAAa,QAAS,YAAW,MAAM;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,OAAO,CAAC;IACtB,IAAI,EAAE,UAAU,CAAC;gBAEL,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IAYlD,OAAO;IAGP,MAAM,CAAC,CAAC,EAAE,MAAM;IAGhB,KAAK;IAML,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAkBvB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO;IAgBxC,OAAO,CAAC,cAAc,EAAE,OAAO,GAAG,MAAM;IAIxC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAgB1B,QAAQ,IAAI,QAAQ;IAIpB,MAAM,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,aAAa;IAgBzC,cAAc;IAId,QAAQ,IAAI,OAAO,GAAG,QAAQ;CAqB/B"}
|
|
@@ -74,6 +74,9 @@ export class Rational {
|
|
|
74
74
|
this.tex = `${this.num < 0 ? "-" : ""}\\frac{${this.num < 0 ? -this.num : this.num}}{${this.denum}}`;
|
|
75
75
|
this.type = NumberType.Rational;
|
|
76
76
|
}
|
|
77
|
+
toArray() {
|
|
78
|
+
return [this.num, this.denum];
|
|
79
|
+
}
|
|
77
80
|
equals(n) {
|
|
78
81
|
return this.value === n.value;
|
|
79
82
|
}
|
package/lib/playground.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAuBA,eAAO,MAAM,UAAU,YAMtB,CAAC"}
|
package/lib/playground.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { multiply } from "./tree/nodes/operators/multiplyNode.js";
|
|
2
|
+
import { substract } from "./tree/nodes/operators/substractNode.js";
|
|
2
3
|
export const playground = () => {
|
|
3
4
|
// const tex = "3\\%";
|
|
4
5
|
// console.log(parseAlgebraic(tex).simplify({}).toTex());
|
|
5
|
-
const
|
|
6
|
-
console.log(
|
|
6
|
+
const x = multiply(3, substract("x", 9));
|
|
7
|
+
console.log(x.simplify().toTex());
|
|
8
|
+
console.log(x.equals(x.simplify()));
|
|
7
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdfExo.test.d.ts","sourceRoot":"","sources":["../../src/tests/pdfExo.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pdfExo.test.d.ts","sourceRoot":"","sources":["../../src/tests/pdfExo.test.ts"],"names":[],"mappings":"AAgBA,OAAO,6BAA6B,CAAC"}
|
package/lib/tests/pdfExo.test.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { factorizedFormFromRoots, } from "../exercises/math/index.js";
|
|
2
2
|
import { buildPdfForExercise } from "./pdfs/buildPDFForExercise.js";
|
|
3
3
|
import "../prototypesEnhancement.js";
|
|
4
4
|
try {
|
|
5
|
-
buildPdfForExercise(
|
|
5
|
+
buildPdfForExercise(factorizedFormFromRoots);
|
|
6
6
|
}
|
|
7
7
|
catch (err) {
|
|
8
8
|
console.log(err);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Node, NodeIds, NodeOptions, NodeType } from "../node.js";
|
|
2
2
|
import { FunctionNode, FunctionsIds } from "./functionNode.js";
|
|
3
|
-
import { NumberNode } from "../numbers/numberNode.js";
|
|
4
3
|
import { AlgebraicNode, SimplifyOptions } from "../algebraicNode.js";
|
|
5
4
|
export declare function isOppositeNode(a: Node): a is OppositeNode;
|
|
6
5
|
export declare const opposite: <T extends AlgebraicNode = AlgebraicNode>(a: T | number | string) => OppositeNode<T>;
|
|
@@ -27,7 +26,7 @@ export declare class OppositeNode<T extends AlgebraicNode = AlgebraicNode> imple
|
|
|
27
26
|
*/
|
|
28
27
|
toAllValidTexs(opts?: NodeOptions): string[];
|
|
29
28
|
evaluate(vars?: Record<string, number>): number;
|
|
30
|
-
simplify(opts?: SimplifyOptions): AlgebraicNode
|
|
29
|
+
simplify(opts?: SimplifyOptions): AlgebraicNode;
|
|
31
30
|
equals(node: AlgebraicNode): boolean;
|
|
32
31
|
toDetailedEvaluation(vars: Record<string, AlgebraicNode>): OppositeNode<AlgebraicNode>;
|
|
33
32
|
derivative(varName?: string | undefined): AlgebraicNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oppositeNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/oppositeNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAMlE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"oppositeNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/oppositeNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAMlE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;AAE/E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAIrE,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AAED,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,aAAa,qBAC3C,CAAC,GAAG,MAAM,GAAG,MAAM,oBAKvB,CAAC;AAEF,qBAAa,YAAY,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,CAC/D,YAAW,YAAY,CAAC,CAAC,CAAC;IAE1B,EAAE,EAAE,YAAY,CAAC;IACjB,KAAK,EAAE,CAAC,CAAC;IACT,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;gBACP,KAAK,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,WAAW;IAQxC,aAAa;;;;;;IAMb,YAAY,IAAI,MAAM;IAGtB,KAAK,IAAI,MAAM;IAef,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,aAAa,EAAE;IAgCtD;;;;OAIG;IACH,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAQ5C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAGtC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe;IAK/B,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAGpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAGxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;CAGxD"}
|
|
@@ -21,9 +21,10 @@ export declare class SqrtNode implements FunctionNode {
|
|
|
21
21
|
toEquivalentNodes(opts?: NodeOptions): AlgebraicNode[];
|
|
22
22
|
toAllValidTexs(opts?: NodeOptions): string[];
|
|
23
23
|
evaluate(vars?: Record<string, number>): number;
|
|
24
|
-
simplify(opts?: SimplifyOptions): AlgebraicNode;
|
|
24
|
+
simplify(opts?: SimplifyOptions, steps?: AlgebraicNode[]): AlgebraicNode;
|
|
25
25
|
equals(node: AlgebraicNode): boolean;
|
|
26
26
|
toDetailedEvaluation(vars: Record<string, AlgebraicNode>): SqrtNode;
|
|
27
27
|
derivative(varName?: string | undefined): AlgebraicNode;
|
|
28
|
+
toSimplificationTex(opts?: SimplifyOptions): void;
|
|
28
29
|
}
|
|
29
30
|
//# sourceMappingURL=sqrtNode.d.ts.map
|
|
@@ -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,YAAY,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;AAK/E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
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,YAAY,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;AAK/E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAMrE,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,EAAE,KAAK,CAAC,EAAE,aAAa,EAAE;IA2CxD,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAGpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAGxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;IAGvD,mBAAmB,CAAC,IAAI,CAAC,EAAE,eAAe;CAI3C"}
|
|
@@ -69,12 +69,13 @@ export class SqrtNode {
|
|
|
69
69
|
evaluate(vars) {
|
|
70
70
|
return Math.sqrt(this.child.evaluate(vars));
|
|
71
71
|
}
|
|
72
|
-
simplify(opts) {
|
|
72
|
+
simplify(opts, steps) {
|
|
73
73
|
const simplifiedChild = this.child.simplify(opts);
|
|
74
74
|
const copy = new SqrtNode(simplifiedChild, this.opts);
|
|
75
|
+
if (steps && !this.child.equals(simplifiedChild))
|
|
76
|
+
steps.push(copy);
|
|
75
77
|
const externals = [];
|
|
76
78
|
//ex [3, x^2] pour sqrt(3x^2)
|
|
77
|
-
//TODO fractions
|
|
78
79
|
const recursive = (node) => {
|
|
79
80
|
if (isMultiplyNode(node)) {
|
|
80
81
|
recursive(node.leftChild);
|
|
@@ -120,4 +121,48 @@ export class SqrtNode {
|
|
|
120
121
|
derivative(varName) {
|
|
121
122
|
throw new Error("unimplemented derivative");
|
|
122
123
|
}
|
|
124
|
+
toSimplificationTex(opts) {
|
|
125
|
+
const nodes = [this];
|
|
126
|
+
const simp = this.simplify(opts, nodes);
|
|
127
|
+
}
|
|
123
128
|
}
|
|
129
|
+
// const simplifyInteger = (a: number)=>{
|
|
130
|
+
// if (a === 0) return 0..toTree()
|
|
131
|
+
// if (a === 1) return 1..toTree();
|
|
132
|
+
// const [outsideSqrt, insideSqrt] = this.getSimplifiedCoeffs();
|
|
133
|
+
// const simplified =
|
|
134
|
+
// insideSqrt !== 1
|
|
135
|
+
// ? new Real(
|
|
136
|
+
// outsideSqrt * Math.sqrt(insideSqrt),
|
|
137
|
+
// `${outsideSqrt === 1 ? "" : `${outsideSqrt}`}\\sqrt{${insideSqrt}}`,
|
|
138
|
+
// )
|
|
139
|
+
// : new Real(outsideSqrt, outsideSqrt + "");
|
|
140
|
+
// simplified.toTree = (): AlgebraicNode => {
|
|
141
|
+
// return insideSqrt !== 1
|
|
142
|
+
// ? outsideSqrt === 1
|
|
143
|
+
// ? new SqrtNode(new NumberNode(insideSqrt))
|
|
144
|
+
// : new MultiplyNode(
|
|
145
|
+
// new NumberNode(outsideSqrt),
|
|
146
|
+
// new SqrtNode(new NumberNode(insideSqrt)),
|
|
147
|
+
// )
|
|
148
|
+
// : new NumberNode(outsideSqrt);
|
|
149
|
+
// };
|
|
150
|
+
// return simplified;
|
|
151
|
+
// }
|
|
152
|
+
// const getMaxSquareAndRest = (a: number)=> {
|
|
153
|
+
// if (a === 0) return [1, 0];
|
|
154
|
+
// const factors = primeFactors( a);
|
|
155
|
+
// // finds primes with even exponents
|
|
156
|
+
// const multiples = [1];
|
|
157
|
+
// for (let i = 0; i < factors.length - 1; i++) {
|
|
158
|
+
// if (factors[i] === factors[i + 1]) {
|
|
159
|
+
// multiples.push(factors[i]);
|
|
160
|
+
// factors.splice(i, 2);
|
|
161
|
+
// i--;
|
|
162
|
+
// }
|
|
163
|
+
// }
|
|
164
|
+
// const maxSquare = multiples.reduce((x, y) => x * y);
|
|
165
|
+
// const insideSqrt =
|
|
166
|
+
// factors.length === 0 ? 1 : factors.reduce((x, y) => x * y);
|
|
167
|
+
// return [maxSquare, insideSqrt];
|
|
168
|
+
// }
|
package/lib/tree/nodes/node.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/tree/nodes/node.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAClB,MAAM,IAAA;IACN,QAAQ,IAAA;IACR,QAAQ,IAAA;IACR,QAAQ,IAAA;IACR,QAAQ,IAAA;IACR,UAAU,IAAA;IACV,KAAK,IAAA;IACL,MAAM,IAAA;IACN,QAAQ,IAAA;IACR,OAAO,IAAA;IACP,MAAM,KAAA;IACN,GAAG,KAAA;IACH,MAAM,KAAA;IACN,KAAK,KAAA;IACL,OAAO,KAAA;CACR;AACD,MAAM,MAAM,WAAW,GAAG;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cA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IAAI;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,iBAAiB,EAAE,CAAC,IAAI,CAAC,EAAE,WAAW,KAAK,IAAI,EAAE,CAAC;IAClD,cAAc,EAAE,CAAC,IAAI,CAAC,EAAE,WAAW,KAAK,MAAM,EAAE,CAAC;IACjD,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,YAAY,KAAK,MAAM,CAAC;IAEvC,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,aAAa,EAAE,MAAM;QAAE,EAAE,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5D"}
|
|
@@ -24,7 +24,7 @@ export declare class NumberNode implements AlgebraicNode {
|
|
|
24
24
|
toAllValidTexs(): string[];
|
|
25
25
|
toEquivalentNodes(): this[];
|
|
26
26
|
evaluate(vars?: Record<string, number>): number;
|
|
27
|
-
simplify(opts?: SimplifyOptions): AlgebraicNode
|
|
27
|
+
simplify(opts?: SimplifyOptions): AlgebraicNode;
|
|
28
28
|
equals(node: AlgebraicNode): boolean;
|
|
29
29
|
toDetailedEvaluation(vars: Record<string, AlgebraicNode>): this;
|
|
30
30
|
derivative(varName?: string | undefined): AlgebraicNode;
|