math-exercises 3.0.134 → 3.0.135
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/arithmetics/coprime.d.ts +8 -0
- package/lib/exercises/math/calcul/arithmetics/coprime.d.ts.map +1 -0
- package/lib/exercises/math/calcul/arithmetics/coprime.js +113 -0
- package/lib/exercises/math/calcul/arithmetics/index.d.ts +1 -0
- package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/index.js +1 -0
- package/lib/exercises/math/calcul/decimals/decimalFractionToDecimal.d.ts +11 -0
- package/lib/exercises/math/calcul/decimals/decimalFractionToDecimal.d.ts.map +1 -0
- package/lib/exercises/math/calcul/decimals/decimalFractionToDecimal.js +243 -0
- package/lib/exercises/math/calcul/decimals/index.d.ts +1 -0
- package/lib/exercises/math/calcul/decimals/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/decimals/index.js +1 -0
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityAdd.d.ts +12 -0
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityAdd.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityAdd.js +173 -0
- package/lib/exercises/math/calculLitteral/distributivity/index.d.ts +1 -0
- package/lib/exercises/math/calculLitteral/distributivity/index.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/index.js +1 -0
- package/lib/exercises/math/calculLitteral/equation/equationSecondDegreeWithNoB.d.ts +7 -0
- package/lib/exercises/math/calculLitteral/equation/equationSecondDegreeWithNoB.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/equation/equationSecondDegreeWithNoB.js +160 -0
- package/lib/exercises/math/calculLitteral/simplifying/compareMinusA.js +1 -1
- package/lib/exercises/math/dataRepresentations/barChartInterpreting.d.ts.map +1 -1
- package/lib/exercises/math/dataRepresentations/barChartInterpreting.js +0 -1
- package/lib/exercises/math/derivation/derivative/composition/functionCompositionDerivative.d.ts +11 -0
- package/lib/exercises/math/derivation/derivative/composition/functionCompositionDerivative.d.ts.map +1 -0
- package/lib/exercises/math/derivation/derivative/composition/functionCompositionDerivative.js +372 -0
- package/lib/exercises/math/derivation/derivative/composition/index.d.ts +2 -0
- package/lib/exercises/math/derivation/derivative/composition/index.d.ts.map +1 -0
- package/lib/exercises/math/derivation/derivative/composition/index.js +1 -0
- package/lib/exercises/math/derivation/derivative/index.d.ts +1 -0
- package/lib/exercises/math/derivation/derivative/index.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/index.js +1 -0
- package/lib/exercises/math/functions/affines/recognizeAffineGraph.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/recognizeAffineGraph.js +3 -3
- package/lib/exercises/math/functions/affines/recognizeExprAffine.js +2 -2
- package/lib/exercises/math/functions/composition/functionComposition.js +1 -1
- package/lib/exercises/math/functions/composition/functionDecompositionFindPossibleUVs.d.ts +13 -0
- package/lib/exercises/math/functions/composition/functionDecompositionFindPossibleUVs.d.ts.map +1 -0
- package/lib/exercises/math/functions/composition/functionDecompositionFindPossibleUVs.js +223 -0
- package/lib/exercises/math/functions/composition/functionDecompositionFindUOrV.d.ts +9 -0
- package/lib/exercises/math/functions/composition/functionDecompositionFindUOrV.d.ts.map +1 -0
- package/lib/exercises/math/functions/composition/functionDecompositionFindUOrV.js +252 -0
- package/lib/exercises/math/functions/composition/index.d.ts +2 -0
- package/lib/exercises/math/functions/composition/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/composition/index.js +2 -0
- package/lib/exercises/math/geometry/vectors/constructions/index.d.ts +1 -0
- package/lib/exercises/math/geometry/vectors/constructions/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/constructions/index.js +1 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorCL.d.ts +13 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorCL.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorCL.js +178 -0
- package/lib/exercises/math/percent/evolutions/findEndValueAfterEvolution.d.ts.map +1 -1
- package/lib/exercises/math/percent/evolutions/findEndValueAfterEvolution.js +1 -1
- package/lib/exercises/math/powers/powersMixOperations.d.ts +4 -1
- package/lib/exercises/math/powers/powersMixOperations.d.ts.map +1 -1
- package/lib/exercises/math/powers/powersMixOperations.js +17 -7
- package/lib/exercises/math/probaStat/stats1var/plausibilityOfAverage.js +1 -1
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormula.d.ts.map +1 -1
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormula.js +2 -1
- package/lib/exercises/math/sequences/geometric/geometricFirstTermsGeneralSum.d.ts +5 -1
- package/lib/exercises/math/sequences/geometric/geometricFirstTermsGeneralSum.d.ts.map +1 -1
- package/lib/exercises/math/sequences/geometric/geometricFirstTermsGeneralSum.js +23 -6
- package/lib/exercises/math/sequences/recurrenceFormulaUsage.js +1 -1
- package/lib/index.d.ts +42 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/math/utils/arithmetic/isCoprime.d.ts +2 -0
- package/lib/math/utils/arithmetic/isCoprime.d.ts.map +1 -0
- package/lib/math/utils/arithmetic/isCoprime.js +10 -0
- package/lib/math/utils/arithmetic/primeDecompNode.d.ts +3 -0
- package/lib/math/utils/arithmetic/primeDecompNode.d.ts.map +1 -0
- package/lib/math/utils/arithmetic/primeDecompNode.js +24 -0
- package/lib/math/utils/functions/functionComparison.d.ts +3 -0
- package/lib/math/utils/functions/functionComparison.d.ts.map +1 -0
- package/lib/math/utils/functions/functionComparison.js +58 -0
- package/lib/math/utils/functions/functionComposition.d.ts +13 -0
- package/lib/math/utils/functions/functionComposition.d.ts.map +1 -0
- package/lib/math/utils/functions/functionComposition.js +117 -0
- package/lib/math/utils/functions/functionDecomposition.d.ts +10 -0
- package/lib/math/utils/functions/functionDecomposition.d.ts.map +1 -0
- package/lib/math/utils/functions/functionDecomposition.js +256 -0
- package/lib/server.js +25 -29
- package/lib/tree/nodes/operators/powerNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/powerNode.js +4 -0
- package/lib/utils/strings/joinanded.d.ts +2 -0
- package/lib/utils/strings/joinanded.d.ts.map +1 -0
- package/lib/utils/strings/joinanded.js +11 -0
- package/package.json +1 -1
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { toolBarConstructor } from "../../../../../exercises/utils/geogebra/toolBarConstructor.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { purpleDark, red } from "../../../../../geogebra/colors.js";
|
|
4
|
+
import { GeogebraConstructor } from "../../../../../geogebra/geogebraConstructor.js";
|
|
5
|
+
import { ggbPointToCoords } from "../../../../../geogebra/parsers/ggbPointToCoords.js";
|
|
6
|
+
import { parseGGBPoints } from "../../../../../geogebra/parsers/parseGGBPoints.js";
|
|
7
|
+
import { Point, PointConstructor, } from "../../../../../math/geometry/point.js";
|
|
8
|
+
import { VectorConstructor } from "../../../../../math/geometry/vector.js";
|
|
9
|
+
import { randint } from "../../../../../math/utils/random/randint.js";
|
|
10
|
+
import { randomMany } from "../../../../../utils/alea/random.js";
|
|
11
|
+
import { doWhile } from "../../../../../utils/doWhile.js";
|
|
12
|
+
const getMultiplyVectorTex = (v, a, shouldShowPlusSign) => {
|
|
13
|
+
if (a === 1)
|
|
14
|
+
return `${shouldShowPlusSign ? "+" : ""}\\overrightarrow{${v}}`;
|
|
15
|
+
if (a === -1)
|
|
16
|
+
return `-\\overrightarrow{${v}}`;
|
|
17
|
+
if (a < 0)
|
|
18
|
+
return `${a}\\overrightarrow{${v}}`;
|
|
19
|
+
return `${shouldShowPlusSign ? "+" : ""}${a}\\overrightarrow{${v}}`;
|
|
20
|
+
};
|
|
21
|
+
const getSolutionPoint = (identifiers) => {
|
|
22
|
+
const { a, b, firstVectorPointsIndexes, secondVectorPointsIndexes, startPointIndex, } = identifiers;
|
|
23
|
+
const points = identifiers.points.map(PointConstructor.fromIdentifiers);
|
|
24
|
+
const origin = points[startPointIndex];
|
|
25
|
+
const vecs = [
|
|
26
|
+
VectorConstructor.fromPoints(points[firstVectorPointsIndexes[0]], points[firstVectorPointsIndexes[1]]),
|
|
27
|
+
VectorConstructor.fromPoints(points[secondVectorPointsIndexes[0]], points[secondVectorPointsIndexes[1]]),
|
|
28
|
+
];
|
|
29
|
+
return vecs[0]
|
|
30
|
+
.times(a.toTree())
|
|
31
|
+
.add(vecs[1].times(b.toTree()))
|
|
32
|
+
.getEndPoint(origin, "K");
|
|
33
|
+
};
|
|
34
|
+
const getInstruction = (identifiers) => {
|
|
35
|
+
const { startPointIndex, firstVectorPointsIndexes, secondVectorPointsIndexes, a, b, } = identifiers;
|
|
36
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
37
|
+
const firstVec = `${identifiers.points[firstVectorPointsIndexes[0]].name}${identifiers.points[firstVectorPointsIndexes[1]].name}`;
|
|
38
|
+
const secondVec = `${identifiers.points[secondVectorPointsIndexes[0]].name}${identifiers.points[secondVectorPointsIndexes[1]].name}`;
|
|
39
|
+
return `Placer le point $K$ tel que :
|
|
40
|
+
|
|
41
|
+
$$
|
|
42
|
+
\\overrightarrow{${origin}K} = ${getMultiplyVectorTex(firstVec, a, false)} ${getMultiplyVectorTex(secondVec, b, true)}
|
|
43
|
+
$$
|
|
44
|
+
|
|
45
|
+
Penser à effacer les points de construction pour que la réponse soit comptée juste.`;
|
|
46
|
+
};
|
|
47
|
+
const getHint = (identifiers) => {
|
|
48
|
+
const { startPointIndex, firstVectorPointsIndexes, secondVectorPointsIndexes, a, b, } = identifiers;
|
|
49
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
50
|
+
const firstVec = `${identifiers.points[firstVectorPointsIndexes[0]].name}${identifiers.points[firstVectorPointsIndexes[1]].name}`;
|
|
51
|
+
const secondVec = `${identifiers.points[secondVectorPointsIndexes[0]].name}${identifiers.points[secondVectorPointsIndexes[1]].name}`;
|
|
52
|
+
return `À partir du point $${origin}$, trace à la suite les vecteurs $${getMultiplyVectorTex(firstVec, a, false)}$ et $${getMultiplyVectorTex(secondVec, b, false)}$.`;
|
|
53
|
+
};
|
|
54
|
+
const getCorrection = (identifiers) => {
|
|
55
|
+
const { startPointIndex, firstVectorPointsIndexes, secondVectorPointsIndexes, a, b, } = identifiers;
|
|
56
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
57
|
+
const firstVec = `${identifiers.points[firstVectorPointsIndexes[0]].name}${identifiers.points[firstVectorPointsIndexes[1]].name}`;
|
|
58
|
+
const secondVec = `${identifiers.points[secondVectorPointsIndexes[0]].name}${identifiers.points[secondVectorPointsIndexes[1]].name}`;
|
|
59
|
+
return `On se place au point $${origin}$. On trace à partir de ce point le vecteur $${getMultiplyVectorTex(firstVec, a, false)}$. Puis, à la suite, on trace le vecteur $${getMultiplyVectorTex(secondVec, b, false)}$. Le point d'arrivée est le point $K$ recherché.`;
|
|
60
|
+
};
|
|
61
|
+
const getGGBAnswer = (identifiers) => {
|
|
62
|
+
const { startPointIndex, firstVectorPointsIndexes, a } = identifiers;
|
|
63
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
64
|
+
const firstVec = [
|
|
65
|
+
identifiers.points[firstVectorPointsIndexes[0]].name,
|
|
66
|
+
identifiers.points[firstVectorPointsIndexes[1]].name,
|
|
67
|
+
];
|
|
68
|
+
const midPoint = `${origin}+(${a})*Vector(${firstVec[0]}, ${firstVec[1]})`;
|
|
69
|
+
const endPoint = getSolutionPoint(identifiers);
|
|
70
|
+
return [
|
|
71
|
+
...endPoint.toGGBCommand(),
|
|
72
|
+
`a = Vector(${origin}, ${midPoint})`,
|
|
73
|
+
`SetColor(a, "${red}")`,
|
|
74
|
+
`b = Vector(${midPoint}, K)`,
|
|
75
|
+
`SetColor(b, "${purpleDark}")`,
|
|
76
|
+
];
|
|
77
|
+
};
|
|
78
|
+
const getStudentGGBOptions = (identifiers) => {
|
|
79
|
+
const { firstVectorPointsIndexes, startPointIndex, a } = identifiers;
|
|
80
|
+
const commands = identifiers.points.flatMap((p) => PointConstructor.fromIdentifiers(p).toGGBCommand({ size: 4 }));
|
|
81
|
+
const ggb = new GeogebraConstructor({
|
|
82
|
+
commands,
|
|
83
|
+
customToolBar: toolBarConstructor({
|
|
84
|
+
point: true,
|
|
85
|
+
}),
|
|
86
|
+
hideAxes: true,
|
|
87
|
+
fontSize: 16,
|
|
88
|
+
});
|
|
89
|
+
const points = identifiers.points.map((p) => PointConstructor.fromIdentifiers(p));
|
|
90
|
+
const firstVec = VectorConstructor.fromPoints(points[firstVectorPointsIndexes[0]], points[firstVectorPointsIndexes[1]]);
|
|
91
|
+
const origin = points[startPointIndex];
|
|
92
|
+
const midPoint = firstVec.times(a.toTree()).getEndPoint(origin);
|
|
93
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
94
|
+
return ggb.getOptions({
|
|
95
|
+
coords: ggb.getCoordsForPoints([...points, solutionPoint, midPoint]),
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
const isGGBAnswerValid = (ans, { ggbAnswer, ...identifiers }) => {
|
|
99
|
+
const studentAns = ans.filter((c) => !["A", "B", "C", "D"].includes(c[0]));
|
|
100
|
+
if (studentAns.length !== 1)
|
|
101
|
+
return false;
|
|
102
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
103
|
+
const pointCoords = parseGGBPoints(studentAns).map((p) => ggbPointToCoords(p));
|
|
104
|
+
if (pointCoords.length !== 1)
|
|
105
|
+
return false;
|
|
106
|
+
return (new Point("K", pointCoords[0].x, pointCoords[0].y).distanceTo(solutionPoint) < 1);
|
|
107
|
+
};
|
|
108
|
+
const getTraceVectorSumQuestion = () => {
|
|
109
|
+
const names = ["A", "B", "C", "D"];
|
|
110
|
+
let points = [];
|
|
111
|
+
let startPointIndex;
|
|
112
|
+
let firstVectorPointsIndexes;
|
|
113
|
+
let secondVectorPointsIndexes;
|
|
114
|
+
const a = randint(-3, 4, [0]);
|
|
115
|
+
const b = randint(-3, 4, Math.abs(a) === 1 ? [0, 1, -1] : [0]);
|
|
116
|
+
let counter = 0;
|
|
117
|
+
while (true) {
|
|
118
|
+
counter++;
|
|
119
|
+
if (counter > 1000)
|
|
120
|
+
throw new Error("Too many iterations in traceVectorCL");
|
|
121
|
+
points = [];
|
|
122
|
+
points.push(...PointConstructor.randomDifferent(4, {
|
|
123
|
+
minDistance: 1,
|
|
124
|
+
names,
|
|
125
|
+
minDistanceToOrigin: 2,
|
|
126
|
+
}));
|
|
127
|
+
startPointIndex = randint(0, names.length);
|
|
128
|
+
firstVectorPointsIndexes = randomMany([0, 1, 2, 3], 2);
|
|
129
|
+
secondVectorPointsIndexes = doWhile(() => randomMany([0, 1, 2, 3], 2), (arr) => arr[0] === firstVectorPointsIndexes[0] &&
|
|
130
|
+
arr[1] === firstVectorPointsIndexes[1]);
|
|
131
|
+
//AC = AB+BC
|
|
132
|
+
const firstVec = VectorConstructor.fromPoints(points[firstVectorPointsIndexes[0]], points[firstVectorPointsIndexes[1]]);
|
|
133
|
+
const second = VectorConstructor.fromPoints(points[secondVectorPointsIndexes[0]], points[secondVectorPointsIndexes[1]]);
|
|
134
|
+
const endPoint = firstVec
|
|
135
|
+
.times(a.toTree())
|
|
136
|
+
.add(second.times(b.toTree()))
|
|
137
|
+
.getEndPoint(points[startPointIndex], "K");
|
|
138
|
+
if (endPoint.distanceTo(new Point("O", 0, 0)) > 10 ||
|
|
139
|
+
points.some((p) => p.equals(endPoint)))
|
|
140
|
+
continue;
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
const identifiers = {
|
|
144
|
+
firstVectorPointsIndexes,
|
|
145
|
+
points: points.map((p) => p.toIdentifiers()),
|
|
146
|
+
secondVectorPointsIndexes,
|
|
147
|
+
startPointIndex,
|
|
148
|
+
a,
|
|
149
|
+
b,
|
|
150
|
+
};
|
|
151
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
152
|
+
};
|
|
153
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
154
|
+
const question = {
|
|
155
|
+
ggbAnswer: getGGBAnswer(identifiers),
|
|
156
|
+
instruction: getInstruction(identifiers),
|
|
157
|
+
studentGgbOptions: getStudentGGBOptions(identifiers),
|
|
158
|
+
identifiers,
|
|
159
|
+
hint: getHint(identifiers),
|
|
160
|
+
correction: getCorrection(identifiers),
|
|
161
|
+
};
|
|
162
|
+
return question;
|
|
163
|
+
};
|
|
164
|
+
export const traceVectorCL = {
|
|
165
|
+
id: "traceVectorCL",
|
|
166
|
+
label: "Placer un point défini par une combinaison linéaire de deux vecteurs",
|
|
167
|
+
isSingleStep: true,
|
|
168
|
+
generator: (nb, opts) => getDistinctQuestions(() => getTraceVectorSumQuestion(opts), nb),
|
|
169
|
+
ggbTimer: 60,
|
|
170
|
+
isGGBAnswerValid,
|
|
171
|
+
subject: "Mathématiques",
|
|
172
|
+
getInstruction,
|
|
173
|
+
getGGBAnswer,
|
|
174
|
+
getStudentGGBOptions,
|
|
175
|
+
answerType: "GGB",
|
|
176
|
+
getQuestionFromIdentifiers,
|
|
177
|
+
hasHintAndCorrection: true,
|
|
178
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findEndValueAfterEvolution.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/percent/evolutions/findEndValueAfterEvolution.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;
|
|
1
|
+
{"version":3,"file":"findEndValueAfterEvolution.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/percent/evolutions/findEndValueAfterEvolution.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAkGF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAiB5D,CAAC"}
|
|
@@ -24,7 +24,7 @@ const getAnswer = (identifiers) => {
|
|
|
24
24
|
};
|
|
25
25
|
const getInstruction = (identifiers) => {
|
|
26
26
|
const evolution = identifiers.percentRate < 0 ? "baisse" : "hausse";
|
|
27
|
-
return `Le prix initial d'un objet est $${identifiers.vd.frenchify()}€$. Quel sera son prix après une ${evolution} de $${identifiers.percentRate.frenchify()}\\%$ ? Arrondir au centième.`;
|
|
27
|
+
return `Le prix initial d'un objet est $${identifiers.vd.frenchify()}€$. Quel sera son prix après une ${evolution} de $${Math.abs(identifiers.percentRate).frenchify()}\\%$ ? Arrondir au centième.`;
|
|
28
28
|
};
|
|
29
29
|
const getHint = () => {
|
|
30
30
|
return `Transforme le taux d'évolution en coefficient multiplicateur. Puis multiplie le prix initial par ce coefficient multiplicateur.`;
|
|
@@ -7,6 +7,9 @@ type Identifiers = {
|
|
|
7
7
|
m: number;
|
|
8
8
|
n: number | undefined;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
type Options = {
|
|
11
|
+
useSameInteger: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare const powersMixOperations: Exercise<Identifiers, Options>;
|
|
11
14
|
export {};
|
|
12
15
|
//# sourceMappingURL=powersMixOperations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"powersMixOperations.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/powersMixOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"powersMixOperations.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/powersMixOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAmBT,MAAM,6BAA6B,CAAC;AAwBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACvB,CAAC;AA4JF,KAAK,OAAO,GAAG;IACb,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AA0BF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgB9D,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addValidProp, shuffleProps, tryToAddWrongProp, propWhile, } from "../../../exercises/exercise.js";
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, propWhile, GeneratorOptionTarget, GeneratorOptionType, } from "../../../exercises/exercise.js";
|
|
2
2
|
import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
|
|
3
3
|
import { randint } from "../../../math/utils/random/randint.js";
|
|
4
4
|
import { frac, isFractionNode, } from "../../../tree/nodes/operators/fractionNode.js";
|
|
@@ -108,10 +108,10 @@ const isAnswerValid = (ans, { answer }) => {
|
|
|
108
108
|
return handleVEAError(err);
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
|
-
const getPowersMixOperationsQuestion = () => {
|
|
111
|
+
const getPowersMixOperationsQuestion = (opts) => {
|
|
112
112
|
const finalPower = randint(2, 10);
|
|
113
113
|
const a = randint(2, 10);
|
|
114
|
-
const bEqualsA = coinFlip();
|
|
114
|
+
const bEqualsA = opts?.useSameInteger || coinFlip();
|
|
115
115
|
const b = bEqualsA ? a : randint(2, 10, [a]);
|
|
116
116
|
let l, m, k, n;
|
|
117
117
|
if (!bEqualsA) {
|
|
@@ -135,15 +135,24 @@ const getPowersMixOperationsQuestion = () => {
|
|
|
135
135
|
};
|
|
136
136
|
return getQuestionFromIdentifiers(identifiers);
|
|
137
137
|
};
|
|
138
|
-
const
|
|
138
|
+
const options = [
|
|
139
|
+
{
|
|
140
|
+
id: "useSameInteger",
|
|
141
|
+
label: "Utiliser des puissances du même entier",
|
|
142
|
+
target: GeneratorOptionTarget.generation,
|
|
143
|
+
type: GeneratorOptionType.checkbox,
|
|
144
|
+
defaultValue: false,
|
|
145
|
+
},
|
|
146
|
+
];
|
|
147
|
+
const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
139
148
|
const question = {
|
|
140
149
|
answer: getAnswer(identifiers),
|
|
141
|
-
instruction: getInstruction(identifiers),
|
|
150
|
+
instruction: getInstruction(identifiers, opts),
|
|
142
151
|
keys: getKeys(identifiers),
|
|
143
152
|
answerFormat: "tex",
|
|
144
153
|
identifiers,
|
|
145
|
-
hint: getHint(identifiers),
|
|
146
|
-
correction: getCorrection(identifiers),
|
|
154
|
+
hint: getHint(identifiers, opts),
|
|
155
|
+
correction: getCorrection(identifiers, opts),
|
|
147
156
|
};
|
|
148
157
|
return question;
|
|
149
158
|
};
|
|
@@ -159,6 +168,7 @@ export const powersMixOperations = {
|
|
|
159
168
|
isAnswerValid,
|
|
160
169
|
subject: "Mathématiques",
|
|
161
170
|
hasHintAndCorrection: true,
|
|
171
|
+
options,
|
|
162
172
|
getQuestionFromIdentifiers,
|
|
163
173
|
shouldHaveCalculator: false,
|
|
164
174
|
};
|
|
@@ -182,7 +182,7 @@ const getQuestionFromIdentifiers = (identifiers) => {
|
|
|
182
182
|
};
|
|
183
183
|
export const plausibilityOfAverage = {
|
|
184
184
|
id: "plausibilityOfAverage",
|
|
185
|
-
label: "S
|
|
185
|
+
label: "S'assurer de la vraisemblance, de la cohérence d'un résultat (moyenne d'une série)",
|
|
186
186
|
isSingleStep: true,
|
|
187
187
|
generator: (nb, opts) => getDistinctQuestions(() => getPlausibilityOfAverageQuestion(opts), nb),
|
|
188
188
|
qcmTimer: 60,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometricFindExplicitFormula.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricFindExplicitFormula.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;
|
|
1
|
+
{"version":3,"file":"geometricFindExplicitFormula.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricFindExplicitFormula.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AA+HF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAe9D,CAAC"}
|
|
@@ -85,7 +85,8 @@ const isAnswerValid = (ans, { reason, firstValue }) => {
|
|
|
85
85
|
const texs = equal.toAllValidTexs();
|
|
86
86
|
return (texs.includes(ans) ||
|
|
87
87
|
(() => {
|
|
88
|
-
|
|
88
|
+
const refinedAns = ans.replace("u_n", "").replace("=", "");
|
|
89
|
+
let nodeAns = parseLatex(refinedAns);
|
|
89
90
|
if (isEqualNode(nodeAns)) {
|
|
90
91
|
nodeAns = nodeAns.rightChild;
|
|
91
92
|
}
|
|
@@ -5,6 +5,10 @@ type Identifiers = {
|
|
|
5
5
|
reason: number;
|
|
6
6
|
nbTerms: number;
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
type Options = {
|
|
9
|
+
positiveReason: boolean;
|
|
10
|
+
firstRankOne: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare const geometricFirstTermsGeneralSum: Exercise<Identifiers, Options>;
|
|
9
13
|
export {};
|
|
10
14
|
//# sourceMappingURL=geometricFirstTermsGeneralSum.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometricFirstTermsGeneralSum.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricFirstTermsGeneralSum.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"geometricFirstTermsGeneralSum.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricFirstTermsGeneralSum.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAkHF,KAAK,OAAO,GAAG;IACb,cAAc,EAAE,OAAO,CAAC;IACxB,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAkBF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkBxE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addValidProp, shuffleProps, tryToAddWrongProp, propWhile, } from "../../../../exercises/exercise.js";
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, propWhile, GeneratorOptionTarget, GeneratorOptionType, } from "../../../../exercises/exercise.js";
|
|
2
2
|
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
3
|
import { randint } from "../../../../math/utils/random/randint.js";
|
|
4
4
|
import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
@@ -53,10 +53,10 @@ const getAnswer = (identifiers) => {
|
|
|
53
53
|
const answer = (firstValue * (1 - Math.pow(reason, nbTerms))) / (1 - reason);
|
|
54
54
|
return answer.frenchify();
|
|
55
55
|
};
|
|
56
|
-
const getGeometricFirstTermsGeneralSumQuestion = () => {
|
|
57
|
-
const firstRank = random([0, 1]);
|
|
56
|
+
const getGeometricFirstTermsGeneralSumQuestion = (opts) => {
|
|
57
|
+
const firstRank = opts?.firstRankOne ? 1 : random([0, 1]);
|
|
58
58
|
const firstValue = randint(-9, 10, [0]);
|
|
59
|
-
const reason = randint(-5, 5, [0, 1]);
|
|
59
|
+
const reason = opts?.positiveReason ? randint(2, 5) : randint(-5, 5, [0, 1]);
|
|
60
60
|
const nbTerms = randint(4, 9);
|
|
61
61
|
const identifiers = {
|
|
62
62
|
firstRank,
|
|
@@ -64,7 +64,7 @@ const getGeometricFirstTermsGeneralSumQuestion = () => {
|
|
|
64
64
|
reason,
|
|
65
65
|
nbTerms,
|
|
66
66
|
};
|
|
67
|
-
return getQuestionFromIdentifiers(identifiers);
|
|
67
|
+
return getQuestionFromIdentifiers(identifiers, opts);
|
|
68
68
|
};
|
|
69
69
|
const getQuestionFromIdentifiers = (identifiers) => {
|
|
70
70
|
const question = {
|
|
@@ -93,14 +93,31 @@ const getPropositions = (n, { answer, firstValue, reason }) => {
|
|
|
93
93
|
const isAnswerValid = (ans, { answer }) => {
|
|
94
94
|
return ans === answer;
|
|
95
95
|
};
|
|
96
|
+
const options = [
|
|
97
|
+
{
|
|
98
|
+
id: "positiveReason",
|
|
99
|
+
label: "Utiliser des raisons positives",
|
|
100
|
+
target: GeneratorOptionTarget.generation,
|
|
101
|
+
type: GeneratorOptionType.checkbox,
|
|
102
|
+
defaultValue: false,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: "firstRankOne",
|
|
106
|
+
label: "Toujours utiliser $u_1$ comme premier terme",
|
|
107
|
+
target: GeneratorOptionTarget.generation,
|
|
108
|
+
type: GeneratorOptionType.checkbox,
|
|
109
|
+
defaultValue: false,
|
|
110
|
+
},
|
|
111
|
+
];
|
|
96
112
|
export const geometricFirstTermsGeneralSum = {
|
|
97
113
|
id: "geometricFirstTermsGeneralSum",
|
|
98
114
|
connector: "=",
|
|
99
115
|
label: "Somme des termes d'une suite géométrique (cas général)",
|
|
100
116
|
isSingleStep: true,
|
|
101
|
-
generator: (nb) => getDistinctQuestions(getGeometricFirstTermsGeneralSumQuestion, nb),
|
|
117
|
+
generator: (nb, opts) => getDistinctQuestions(() => getGeometricFirstTermsGeneralSumQuestion(opts), nb),
|
|
102
118
|
qcmTimer: 60,
|
|
103
119
|
freeTimer: 60,
|
|
120
|
+
options,
|
|
104
121
|
getPropositions,
|
|
105
122
|
isAnswerValid,
|
|
106
123
|
subject: "Mathématiques",
|
package/lib/index.d.ts
CHANGED
|
@@ -46,6 +46,9 @@ declare const mathExercises: (Exercise<{
|
|
|
46
46
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
47
47
|
a: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
48
48
|
b: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
49
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
50
|
+
a: number;
|
|
51
|
+
b: number;
|
|
49
52
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
50
53
|
integerFirst: boolean;
|
|
51
54
|
integer: number;
|
|
@@ -330,6 +333,11 @@ declare const mathExercises: (Exercise<{
|
|
|
330
333
|
point: import("./math/geometry/point.js").PointIdentifiers;
|
|
331
334
|
bounding: number;
|
|
332
335
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
336
|
+
isFractionToDigital: boolean;
|
|
337
|
+
nb: number;
|
|
338
|
+
}, {
|
|
339
|
+
conversionType: string;
|
|
340
|
+
}> | Exercise<{
|
|
333
341
|
choices: {
|
|
334
342
|
node: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
335
343
|
irrationalUsed: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers | null;
|
|
@@ -388,6 +396,12 @@ declare const mathExercises: (Exercise<{
|
|
|
388
396
|
a: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
389
397
|
b: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
390
398
|
isAdd: boolean;
|
|
399
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
400
|
+
type: number;
|
|
401
|
+
affine1: import("./math/polynomials/generalAffine.js").GeneralAffineIdentifiers;
|
|
402
|
+
affine2: import("./math/polynomials/generalAffine.js").GeneralAffineIdentifiers;
|
|
403
|
+
affine3: import("./math/polynomials/generalAffine.js").GeneralAffineIdentifiers;
|
|
404
|
+
affine4?: import("./math/polynomials/generalAffine.js").GeneralAffineIdentifiers;
|
|
391
405
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
392
406
|
randNbr: number;
|
|
393
407
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
@@ -825,6 +839,11 @@ declare const mathExercises: (Exercise<{
|
|
|
825
839
|
affineB: number;
|
|
826
840
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
827
841
|
a: number;
|
|
842
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
843
|
+
nodeUIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
844
|
+
nodeVIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
845
|
+
nodeUPrimeIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
846
|
+
nodeVPrimeIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
828
847
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
829
848
|
coeffs: number[];
|
|
830
849
|
x: number;
|
|
@@ -1471,6 +1490,15 @@ declare const mathExercises: (Exercise<{
|
|
|
1471
1490
|
k: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
1472
1491
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1473
1492
|
nodeIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers[];
|
|
1493
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1494
|
+
isFindU: boolean;
|
|
1495
|
+
nodeIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers[];
|
|
1496
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1497
|
+
uov: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
1498
|
+
items: {
|
|
1499
|
+
tex: string;
|
|
1500
|
+
isValid: boolean;
|
|
1501
|
+
}[];
|
|
1474
1502
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1475
1503
|
coin: boolean;
|
|
1476
1504
|
radius: number;
|
|
@@ -1784,6 +1812,13 @@ declare const mathExercises: (Exercise<{
|
|
|
1784
1812
|
vCoords: number[];
|
|
1785
1813
|
wCoords: number[];
|
|
1786
1814
|
uCoords: number[];
|
|
1815
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1816
|
+
points: import("./math/geometry/point.js").PointIdentifiers[];
|
|
1817
|
+
startPointIndex: number;
|
|
1818
|
+
firstVectorPointsIndexes: number[];
|
|
1819
|
+
secondVectorPointsIndexes: number[];
|
|
1820
|
+
a: number;
|
|
1821
|
+
b: number;
|
|
1787
1822
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1788
1823
|
points: string[][];
|
|
1789
1824
|
pointAskedIndex: number[];
|
|
@@ -2172,7 +2207,9 @@ declare const mathExercises: (Exercise<{
|
|
|
2172
2207
|
l: number;
|
|
2173
2208
|
m: number;
|
|
2174
2209
|
n: number | undefined;
|
|
2175
|
-
},
|
|
2210
|
+
}, {
|
|
2211
|
+
useSameInteger: boolean;
|
|
2212
|
+
}> | Exercise<{
|
|
2176
2213
|
a: number;
|
|
2177
2214
|
b: number;
|
|
2178
2215
|
c: number;
|
|
@@ -2607,7 +2644,10 @@ declare const mathExercises: (Exercise<{
|
|
|
2607
2644
|
firstValue: number;
|
|
2608
2645
|
reason: number;
|
|
2609
2646
|
nbTerms: number;
|
|
2610
|
-
},
|
|
2647
|
+
}, {
|
|
2648
|
+
positiveReason: boolean;
|
|
2649
|
+
firstRankOne: boolean;
|
|
2650
|
+
}> | Exercise<{
|
|
2611
2651
|
q: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
2612
2652
|
a: number;
|
|
2613
2653
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
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;AAC7D,OAAO,KAAK,aAAa,MAAM,2BAA2B,CAAC;AAE3D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/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;AAC7D,OAAO,KAAK,aAAa,MAAM,2BAA2B,CAAC;AAE3D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kDAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isCoprime.d.ts","sourceRoot":"","sources":["../../../../src/math/utils/arithmetic/isCoprime.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,YAY7C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { primeDecomposition } from "./primeDecomposition.js";
|
|
2
|
+
export const isCoprime = (a, b) => {
|
|
3
|
+
const [dictDecompA, dictDecompB] = [a, b].map((n) => {
|
|
4
|
+
const arrDecomp = primeDecomposition(n);
|
|
5
|
+
const dictDecomp = Object.fromEntries(arrDecomp.map(({ value, power }) => [value, power]));
|
|
6
|
+
return dictDecomp;
|
|
7
|
+
});
|
|
8
|
+
const isCoprime = Object.keys(dictDecompA).every((value) => dictDecompB[value] === undefined);
|
|
9
|
+
return isCoprime;
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primeDecompNode.d.ts","sourceRoot":"","sources":["../../../../src/math/utils/arithmetic/primeDecompNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAMlE,eAAO,MAAM,eAAe,GAAI,IAAI,MAAM,EAAE,WAAU,OAAc,KAef,aACpD,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { MultiplyNode } from "../../../tree/nodes/operators/multiplyNode.js";
|
|
2
|
+
import { power } from "../../../tree/nodes/operators/powerNode.js";
|
|
3
|
+
import { operatorComposition } from "../../../tree/utilities/operatorComposition.js";
|
|
4
|
+
import { primeDecomposition } from "./primeDecomposition.js";
|
|
5
|
+
export const primeDecompNode = (nb, asPowers = true) => {
|
|
6
|
+
const decomp = primeDecomposition(nb);
|
|
7
|
+
const nodes = [];
|
|
8
|
+
if (asPowers) {
|
|
9
|
+
for (const d of decomp) {
|
|
10
|
+
if (d.power === 1)
|
|
11
|
+
nodes.push(d.value.toTree());
|
|
12
|
+
else
|
|
13
|
+
nodes.push(power(d.value, d.power));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
for (const d of decomp) {
|
|
18
|
+
for (let i = 0; i < d.power; i++) {
|
|
19
|
+
nodes.push(d.value.toTree());
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return operatorComposition(MultiplyNode, nodes);
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functionComparison.d.ts","sourceRoot":"","sources":["../../../../src/math/utils/functions/functionComparison.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAsElE,eAAO,MAAM,iBAAiB,GAC5B,OAAO,aAAa,EACpB,OAAO,aAAa,YAarB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { isInfiniteNode } from "../../../tree/nodes/numbers/constantNode.js";
|
|
2
|
+
import { substract } from "../../../tree/nodes/operators/substractNode.js";
|
|
3
|
+
import { randfloat } from "../random/randfloat.js";
|
|
4
|
+
const getSafeEvaluationDictForEqualityCheck = (node1, node2, nbSafeX = 4) => {
|
|
5
|
+
const dict = {};
|
|
6
|
+
let counter = -1;
|
|
7
|
+
while (Object.keys(dict).length < nbSafeX && counter < 1000) {
|
|
8
|
+
counter++;
|
|
9
|
+
const x = randfloat(-20, 100, 3);
|
|
10
|
+
let value1;
|
|
11
|
+
let value2;
|
|
12
|
+
try {
|
|
13
|
+
value1 = node1.evaluate({ x });
|
|
14
|
+
}
|
|
15
|
+
catch (_) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
value2 = node2.evaluate({ x });
|
|
20
|
+
}
|
|
21
|
+
catch (_) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const [isValidValue1, isValidValue2] = [value1, value2].map((value) => value !== undefined && !isNaN(value) && !isInfiniteNode(value.toTree()));
|
|
25
|
+
if (isValidValue1 && isValidValue2) {
|
|
26
|
+
dict[x] = [value1, value2].map((value) => {
|
|
27
|
+
return {
|
|
28
|
+
x,
|
|
29
|
+
value,
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return dict;
|
|
35
|
+
};
|
|
36
|
+
const isEqualFromRandomEvaluations = (node1, node2) => {
|
|
37
|
+
return Object.values(getSafeEvaluationDictForEqualityCheck(node1, node2)).every((arrSafeEval) => {
|
|
38
|
+
// console.log(
|
|
39
|
+
// "arrSafeEval",
|
|
40
|
+
// arrSafeEval.map((safeEval) => safeEval.value),
|
|
41
|
+
// );
|
|
42
|
+
return arrSafeEval
|
|
43
|
+
.slice(1)
|
|
44
|
+
.every((safeEval) => substract(arrSafeEval[0].value, safeEval.value).evaluate() === 0);
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
export const isEquivalentNodes = (node1, node2) => {
|
|
48
|
+
let isEqualFromAlgebraicSimplification = false;
|
|
49
|
+
try {
|
|
50
|
+
isEqualFromAlgebraicSimplification =
|
|
51
|
+
substract(node1, node2).simplify().evaluate() === 0;
|
|
52
|
+
}
|
|
53
|
+
catch (_) {
|
|
54
|
+
(() => { })();
|
|
55
|
+
}
|
|
56
|
+
return (isEqualFromAlgebraicSimplification ||
|
|
57
|
+
isEqualFromRandomEvaluations(node1, node2));
|
|
58
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AlgebraicNode, SimplifyOptions } from "../../../tree/nodes/algebraicNode.js";
|
|
2
|
+
import { VariableNode } from "../../../tree/nodes/variables/variableNode.js";
|
|
3
|
+
export declare const nodeBySubstitutingVar: (nodeCarrier: AlgebraicNode, nodeInjected: AlgebraicNode, variableNode?: VariableNode) => AlgebraicNode;
|
|
4
|
+
export type NodePathWithNodes = {
|
|
5
|
+
arrNode: AlgebraicNode[];
|
|
6
|
+
nodePath: NodePath;
|
|
7
|
+
};
|
|
8
|
+
export declare const getAllNodePaths: (node: AlgebraicNode) => NodePathWithNodes[];
|
|
9
|
+
export type NodePath = {
|
|
10
|
+
keys: ("leftChild" | "rightChild" | "child")[];
|
|
11
|
+
};
|
|
12
|
+
export declare function nodeByReplacingNodeAtPath(nodeCarrier: AlgebraicNode, path: NodePath, nodeInjected: AlgebraicNode, simplifyUpToLevel?: number, simplifyOptions?: SimplifyOptions): AlgebraicNode;
|
|
13
|
+
//# sourceMappingURL=functionComposition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functionComposition.d.ts","sourceRoot":"","sources":["../../../../src/math/utils/functions/functionComposition.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,eAAe,EAChB,MAAM,mCAAmC,CAAC;AAU3C,OAAO,EAEL,YAAY,EACb,MAAM,4CAA4C,CAAC;AAEpD,eAAO,MAAM,qBAAqB,GAChC,aAAa,aAAa,EAC1B,cAAc,aAAa,EAC3B,eAAc,YAA2C,kBAiB1D,CAAC;AAMF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,MAAM,aAAa,wBA4ClD,CAAC;AAMF,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,CAAC,WAAW,GAAG,YAAY,GAAG,OAAO,CAAC,EAAE,CAAC;CAChD,CAAC;AA6BF,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,aAAa,EAC1B,IAAI,EAAE,QAAQ,EACd,YAAY,EAAE,aAAa,EAC3B,iBAAiB,GAAE,MAAW,EAC9B,eAAe,GAAE,eAAoB,iBAiEtC"}
|