math-exercises 3.0.212 → 3.0.214
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/arithmetic/hasDiophantianEquationSolution.js +4 -4
- package/lib/exercises/math/arithmetic/pgcdFromPrimeDecomposition.d.ts.map +1 -1
- package/lib/exercises/math/arithmetic/pgcdFromPrimeDecomposition.js +11 -9
- package/lib/exercises/math/complex/argumentFromAlgebraicComplex.d.ts +3 -0
- package/lib/exercises/math/complex/argumentFromAlgebraicComplex.d.ts.map +1 -1
- package/lib/exercises/math/complex/argumentFromAlgebraicComplex.js +92 -3
- package/lib/exercises/math/complex/conjugateDivideComplex.d.ts.map +1 -1
- package/lib/exercises/math/complex/conjugateDivideComplex.js +67 -6
- package/lib/exercises/math/complex/conjugateMultiplyComplex.d.ts.map +1 -1
- package/lib/exercises/math/complex/conjugateMultiplyComplex.js +54 -15
- package/lib/exercises/math/complex/divideComplex.d.ts.map +1 -1
- package/lib/exercises/math/complex/divideComplex.js +60 -6
- package/lib/exercises/math/complex/exp/complexAlgebraicFromExpForm.d.ts +9 -0
- package/lib/exercises/math/complex/exp/complexAlgebraicFromExpForm.d.ts.map +1 -0
- package/lib/exercises/math/complex/exp/complexAlgebraicFromExpForm.js +178 -0
- package/lib/exercises/math/complex/exp/complexExpFormPowerSimplify.d.ts +10 -0
- package/lib/exercises/math/complex/exp/complexExpFormPowerSimplify.d.ts.map +1 -0
- package/lib/exercises/math/complex/exp/complexExpFormPowerSimplify.js +152 -0
- package/lib/exercises/math/complex/exp/complexExpFormProductSimplify.d.ts +11 -0
- package/lib/exercises/math/complex/exp/complexExpFormProductSimplify.d.ts.map +1 -0
- package/lib/exercises/math/complex/exp/complexExpFormProductSimplify.js +165 -0
- package/lib/exercises/math/complex/exp/complexExpFormQuotientSimplify.d.ts +11 -0
- package/lib/exercises/math/complex/exp/complexExpFormQuotientSimplify.d.ts.map +1 -0
- package/lib/exercises/math/complex/exp/complexExpFormQuotientSimplify.js +164 -0
- package/lib/exercises/math/complex/exp/complexExpFromAlgebraicForm.d.ts +9 -0
- package/lib/exercises/math/complex/exp/complexExpFromAlgebraicForm.d.ts.map +1 -0
- package/lib/exercises/math/complex/exp/complexExpFromAlgebraicForm.js +175 -0
- package/lib/exercises/math/complex/exp/index.d.ts +5 -0
- package/lib/exercises/math/complex/exp/index.d.ts.map +1 -0
- package/lib/exercises/math/complex/exp/index.js +5 -0
- package/lib/exercises/math/complex/index.d.ts +1 -0
- package/lib/exercises/math/complex/index.d.ts.map +1 -1
- package/lib/exercises/math/complex/index.js +1 -0
- package/lib/exercises/math/complex/inverseComplex.d.ts.map +1 -1
- package/lib/exercises/math/complex/inverseComplex.js +35 -2
- package/lib/exercises/math/complex/linearCombinaisonComplex.d.ts.map +1 -1
- package/lib/exercises/math/complex/linearCombinaisonComplex.js +36 -5
- package/lib/exercises/math/complex/moduloFromAlgebraicComplex.d.ts.map +1 -1
- package/lib/exercises/math/complex/moduloFromAlgebraicComplex.js +38 -9
- package/lib/exercises/math/derivation/problems/index.d.ts +0 -1
- package/lib/exercises/math/derivation/problems/index.d.ts.map +1 -1
- package/lib/exercises/math/derivation/problems/index.js +1 -1
- package/lib/exercises/math/trigonometry/formulas/index.d.ts +2 -0
- package/lib/exercises/math/trigonometry/formulas/index.d.ts.map +1 -0
- package/lib/exercises/math/trigonometry/formulas/index.js +1 -0
- package/lib/exercises/math/trigonometry/formulas/trigoAdditionFormulaUsage.d.ts +8 -0
- package/lib/exercises/math/trigonometry/formulas/trigoAdditionFormulaUsage.d.ts.map +1 -0
- package/lib/exercises/math/trigonometry/formulas/trigoAdditionFormulaUsage.js +217 -0
- package/lib/exercises/math/trigonometry/index.d.ts +1 -0
- package/lib/exercises/math/trigonometry/index.d.ts.map +1 -1
- package/lib/exercises/math/trigonometry/index.js +1 -0
- package/lib/index.d.ts +21 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/playground.d.ts +0 -5
- package/lib/playground.d.ts.map +1 -1
- package/lib/playground.js +3 -9
- package/lib/tree/nodes/algebraicNode.d.ts +2 -0
- package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
- package/lib/tree/nodes/complex/complexNode.d.ts +3 -0
- package/lib/tree/nodes/complex/complexNode.d.ts.map +1 -1
- package/lib/tree/nodes/complex/complexNode.js +8 -0
- package/lib/tree/nodes/functions/absNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/absNode.js +6 -1
- package/lib/tree/nodes/functions/expNode.d.ts +2 -2
- package/lib/tree/nodes/functions/expNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/expNode.js +2 -2
- package/lib/tree/nodes/node.d.ts +1 -0
- package/lib/tree/nodes/node.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.js +6 -0
- 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 +11 -6
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trigoAdditionFormulaUsage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/trigonometry/formulas/trigoAdditionFormulaUsage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAmBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AA2NF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAwB3D,CAAC"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { equal } from "../../../../tree/nodes/equations/equalNode.js";
|
|
4
|
+
import { abs } from "../../../../tree/nodes/functions/absNode.js";
|
|
5
|
+
import { cos } from "../../../../tree/nodes/functions/cosNode.js";
|
|
6
|
+
import { opposite } from "../../../../tree/nodes/functions/oppositeNode.js";
|
|
7
|
+
import { sin } from "../../../../tree/nodes/functions/sinNode.js";
|
|
8
|
+
import { PiNode } from "../../../../tree/nodes/numbers/piNode.js";
|
|
9
|
+
import { add } from "../../../../tree/nodes/operators/addNode.js";
|
|
10
|
+
import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
11
|
+
import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
12
|
+
import { substract } from "../../../../tree/nodes/operators/substractNode.js";
|
|
13
|
+
import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
|
|
14
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
15
|
+
import { random } from "../../../../utils/alea/random.js";
|
|
16
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
17
|
+
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
18
|
+
const getPropositions = (n, { answer }) => {
|
|
19
|
+
const propositions = [];
|
|
20
|
+
addValidProp(propositions, answer);
|
|
21
|
+
propWhile(propositions, n, () => {
|
|
22
|
+
tryToAddWrongProp(propositions, getAnswer({ k: random([1, 5, 7, 11]), isCos: coinFlip() }));
|
|
23
|
+
});
|
|
24
|
+
return shuffleProps(propositions, n);
|
|
25
|
+
};
|
|
26
|
+
const getAnswerNode = (identifiers) => {
|
|
27
|
+
const { isCos } = identifiers;
|
|
28
|
+
const [a, b] = getDecompCoeffs(identifiers);
|
|
29
|
+
const formula = getFormula(isCos, b.evaluate() > 0);
|
|
30
|
+
return formula.rightChild
|
|
31
|
+
.toDetailedEvaluation({
|
|
32
|
+
a: a,
|
|
33
|
+
b: abs(b),
|
|
34
|
+
})
|
|
35
|
+
.simplify();
|
|
36
|
+
};
|
|
37
|
+
const getAnswer = (identifiers) => {
|
|
38
|
+
return getAnswerNode(identifiers).toTex();
|
|
39
|
+
};
|
|
40
|
+
const getDecompCoeffs = (identifiers) => {
|
|
41
|
+
const { k } = identifiers;
|
|
42
|
+
//pi/12 = pi/3 - pi/4
|
|
43
|
+
//5pi/12 = 2pi/3-pi/4
|
|
44
|
+
//7pi/12 = pi/4+ pi/3
|
|
45
|
+
//11 pi/12= 2pi/3+pi/4
|
|
46
|
+
if (k === 1)
|
|
47
|
+
return [frac(PiNode, 3), opposite(frac(PiNode, 4))];
|
|
48
|
+
if (k === 5)
|
|
49
|
+
return [frac(multiply(2, PiNode), 3), opposite(frac(PiNode, 4))];
|
|
50
|
+
if (k === 7)
|
|
51
|
+
return [frac(PiNode, 4), frac(PiNode, 3)];
|
|
52
|
+
return [frac(multiply(2, PiNode), 3), frac(PiNode, 4)];
|
|
53
|
+
};
|
|
54
|
+
const getInstruction = (identifiers) => {
|
|
55
|
+
const { isCos, k } = identifiers;
|
|
56
|
+
const fct = isCos ? cos : sin;
|
|
57
|
+
const angle = frac(multiply(k, PiNode), 12);
|
|
58
|
+
const [a, b] = getDecompCoeffs(identifiers);
|
|
59
|
+
return `En remarquant que $${angle.toTex()} = ${add(a, b).toTex()}$, déterminer la valeur exacte de :
|
|
60
|
+
|
|
61
|
+
$$
|
|
62
|
+
${fct(angle).toTex()}
|
|
63
|
+
$$`;
|
|
64
|
+
};
|
|
65
|
+
const getFormula = (isCos, isPlus) => {
|
|
66
|
+
const formulas = [
|
|
67
|
+
equal(cos(add("a", "b")), substract(multiply(cos("a"), cos("b")), multiply(sin("a"), sin("b")))),
|
|
68
|
+
equal(sin(add("a", "b")), add(multiply(sin("a"), cos("b")), multiply(cos("a"), sin("b")))),
|
|
69
|
+
equal(cos(substract("a", "b")), add(multiply(cos("a"), cos("b")), multiply(sin("a"), sin("b")))),
|
|
70
|
+
equal(sin(substract("a", "b")), substract(multiply(sin("a"), cos("b")), multiply(cos("a"), sin("b")))),
|
|
71
|
+
];
|
|
72
|
+
return isPlus
|
|
73
|
+
? isCos
|
|
74
|
+
? formulas[0]
|
|
75
|
+
: formulas[1]
|
|
76
|
+
: isCos
|
|
77
|
+
? formulas[2]
|
|
78
|
+
: formulas[3];
|
|
79
|
+
};
|
|
80
|
+
const getHint = () => {
|
|
81
|
+
return `On rappelle les formules d'addition suivantes : pour tous $a$ et $b$ réels,
|
|
82
|
+
|
|
83
|
+
- $\\cos(a+b) = \\cos(a)\\cos(b)-\\sin(a)\\sin(b)$
|
|
84
|
+
- $\\sin(a+b) = \\sin(a)\\cos(b)+\\cos(a)\\sin(b)$
|
|
85
|
+
- $\\cos(a-b) = \\cos(a)\\cos(b)+\\sin(a)\\sin(b)$
|
|
86
|
+
- $\\sin(a-b) = \\sin(a)\\cos(b)-\\cos(a)\\sin(b)$
|
|
87
|
+
`;
|
|
88
|
+
};
|
|
89
|
+
const getCorrection = (identifiers) => {
|
|
90
|
+
const { isCos, k } = identifiers;
|
|
91
|
+
const fct = isCos ? cos : sin;
|
|
92
|
+
const angle = frac(multiply(k, PiNode), 12);
|
|
93
|
+
const [a, b] = getDecompCoeffs(identifiers);
|
|
94
|
+
const absB = b.evaluate() > 0 ? b : opposite(b).simplify();
|
|
95
|
+
const formula = getFormula(isCos, b.evaluate() > 0).rightChild;
|
|
96
|
+
const start = fct(angle).toTex();
|
|
97
|
+
return `On remarque que :
|
|
98
|
+
|
|
99
|
+
$$
|
|
100
|
+
${angle.toTex()} = ${add(a, b).toTex()}
|
|
101
|
+
$$
|
|
102
|
+
|
|
103
|
+
On peut alors utiliser la formule d'addition suivante :
|
|
104
|
+
|
|
105
|
+
$$
|
|
106
|
+
${formula.toTex()}
|
|
107
|
+
$$
|
|
108
|
+
|
|
109
|
+
On obtient :
|
|
110
|
+
|
|
111
|
+
${alignTex([
|
|
112
|
+
[start, "=", fct(add(a, b)).toTex()],
|
|
113
|
+
[
|
|
114
|
+
"",
|
|
115
|
+
"=",
|
|
116
|
+
formula
|
|
117
|
+
.toDetailedEvaluation({
|
|
118
|
+
a: a,
|
|
119
|
+
b: absB,
|
|
120
|
+
})
|
|
121
|
+
.toTex(),
|
|
122
|
+
],
|
|
123
|
+
[
|
|
124
|
+
"",
|
|
125
|
+
"=",
|
|
126
|
+
formula
|
|
127
|
+
.toDetailedEvaluation({
|
|
128
|
+
a: a,
|
|
129
|
+
b: abs(b),
|
|
130
|
+
})
|
|
131
|
+
.simplify({
|
|
132
|
+
forbidAdditions: true,
|
|
133
|
+
forbidMultiplications: true,
|
|
134
|
+
})
|
|
135
|
+
.toTex(),
|
|
136
|
+
],
|
|
137
|
+
[
|
|
138
|
+
"",
|
|
139
|
+
"=",
|
|
140
|
+
formula
|
|
141
|
+
.toDetailedEvaluation({
|
|
142
|
+
a: a,
|
|
143
|
+
b: abs(b),
|
|
144
|
+
})
|
|
145
|
+
.simplify({
|
|
146
|
+
forbidAdditions: true,
|
|
147
|
+
})
|
|
148
|
+
.toTex(),
|
|
149
|
+
],
|
|
150
|
+
[
|
|
151
|
+
"",
|
|
152
|
+
"=",
|
|
153
|
+
formula
|
|
154
|
+
.toDetailedEvaluation({
|
|
155
|
+
a: a,
|
|
156
|
+
b: absB,
|
|
157
|
+
})
|
|
158
|
+
.simplify()
|
|
159
|
+
.toTex(),
|
|
160
|
+
],
|
|
161
|
+
])}`;
|
|
162
|
+
};
|
|
163
|
+
//kpi/12 = aPI/4 + bPI/3
|
|
164
|
+
//= 3aPI/12 + 4bPI/12
|
|
165
|
+
//k = 3a + 4b
|
|
166
|
+
const getKeys = () => {
|
|
167
|
+
return ["pi"];
|
|
168
|
+
};
|
|
169
|
+
const isAnswerValid = (ans, { answer, ...identifiers }) => {
|
|
170
|
+
try {
|
|
171
|
+
const parsed = parseAlgebraic(ans);
|
|
172
|
+
//petit hack, l'évaluation marche ici si on refuse les décimaux
|
|
173
|
+
return (!parsed.toTex().includes(",") &&
|
|
174
|
+
!parsed.toTex().includes(".") &&
|
|
175
|
+
Math.abs(parsed.evaluate() - getAnswerNode(identifiers).evaluate()) < 0.01);
|
|
176
|
+
}
|
|
177
|
+
catch (err) {
|
|
178
|
+
return handleVEAError(err);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
const getTrigoAdditionFormulaUsageQuestion = () => {
|
|
182
|
+
const identifiers = {
|
|
183
|
+
isCos: coinFlip(),
|
|
184
|
+
k: random([1, 5, 7, 11]),
|
|
185
|
+
};
|
|
186
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
187
|
+
};
|
|
188
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
189
|
+
return {
|
|
190
|
+
answer: getAnswer(identifiers),
|
|
191
|
+
instruction: getInstruction(identifiers),
|
|
192
|
+
keys: getKeys(identifiers),
|
|
193
|
+
answerFormat: "tex",
|
|
194
|
+
identifiers,
|
|
195
|
+
hint: getHint(identifiers),
|
|
196
|
+
correction: getCorrection(identifiers),
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
export const trigoAdditionFormulaUsage = {
|
|
200
|
+
id: "trigoAdditionFormulaUsage",
|
|
201
|
+
connector: "=",
|
|
202
|
+
label: "Utiliser les formules d'addition trigonométrique pour calculer $\\cos(k\\frac{\\pi}{12})$ ou $\\sin(k\\frac{\\pi}{12})$",
|
|
203
|
+
isSingleStep: true,
|
|
204
|
+
generator: (nb, opts) => getDistinctQuestions(() => getTrigoAdditionFormulaUsageQuestion(opts), nb, 8),
|
|
205
|
+
qcmTimer: 60,
|
|
206
|
+
freeTimer: 60,
|
|
207
|
+
getPropositions,
|
|
208
|
+
isAnswerValid,
|
|
209
|
+
subject: "Mathématiques",
|
|
210
|
+
getInstruction,
|
|
211
|
+
getHint,
|
|
212
|
+
getCorrection,
|
|
213
|
+
getAnswer,
|
|
214
|
+
getQuestionFromIdentifiers,
|
|
215
|
+
hasHintAndCorrection: true,
|
|
216
|
+
maxAllowedQuestions: 8,
|
|
217
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/trigonometry/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/trigonometry/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -856,6 +856,24 @@ declare const mathExercises: (Exercise<{
|
|
|
856
856
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
857
857
|
arg: number;
|
|
858
858
|
zTex: string;
|
|
859
|
+
reIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
860
|
+
imIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
861
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
862
|
+
rIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
863
|
+
thetaIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
864
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
865
|
+
reIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
866
|
+
imIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
867
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
868
|
+
z1ModuleIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
869
|
+
z1ArgIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
870
|
+
z2ModuleIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
871
|
+
z2ArgIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
872
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
873
|
+
z1ModuleIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
874
|
+
z1ArgIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
875
|
+
z2ModuleIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
876
|
+
z2ArgIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
859
877
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
860
878
|
randomUnitIndex: number;
|
|
861
879
|
randomUnitInstructionIndex: number;
|
|
@@ -1275,13 +1293,6 @@ declare const mathExercises: (Exercise<{
|
|
|
1275
1293
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1276
1294
|
nodeIdsF: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
1277
1295
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1278
|
-
nodeIdsF: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
1279
|
-
pofIds: import("./math/utils/polynomial/polynomialInterpolationUtils.js").PointOfFunctionIdentifiers[];
|
|
1280
|
-
boundPHigh: number;
|
|
1281
|
-
typeF: string;
|
|
1282
|
-
}, {
|
|
1283
|
-
typeF: string;
|
|
1284
|
-
}> | Exercise<{
|
|
1285
1296
|
nodeIdsF: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
1286
1297
|
nodeIdsValueFunction: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
1287
1298
|
typeF: string;
|
|
@@ -4724,6 +4735,9 @@ declare const mathExercises: (Exercise<{
|
|
|
4724
4735
|
questionType: "frac" | "func";
|
|
4725
4736
|
targetTypes: string[];
|
|
4726
4737
|
}> | Exercise<{
|
|
4738
|
+
k: number;
|
|
4739
|
+
isCos: boolean;
|
|
4740
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
4727
4741
|
initialValue: number;
|
|
4728
4742
|
step: number;
|
|
4729
4743
|
iterations: 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;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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Node(-3) ne passent pas tjrs "equals", j'ai du mal à comprendre pourquoi alors que opposite(3) se simplifie bien en numberNode
|
|
6
|
-
*/
|
|
7
2
|
//# sourceMappingURL=playground.d.ts.map
|
package/lib/playground.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,YAGtB,CAAC"}
|
package/lib/playground.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parseAlgebraic } from "./tree/parsers/latexParser.js";
|
|
2
2
|
export const playground = () => {
|
|
3
|
-
const a =
|
|
4
|
-
|
|
5
|
-
console.log(gcd(a, b));
|
|
3
|
+
const a = "8^9\\cos^3";
|
|
4
|
+
console.log(parseAlgebraic(a).toTex());
|
|
6
5
|
};
|
|
7
|
-
/***
|
|
8
|
-
*
|
|
9
|
-
* !!TODO
|
|
10
|
-
* - j'ai l'impression que opposite(3).simplify() et numberNode(-3) ne passent pas tjrs "equals", j'ai du mal à comprendre pourquoi alors que opposite(3) se simplifie bien en numberNode
|
|
11
|
-
*/
|
|
@@ -9,6 +9,7 @@ export type SimplifyOptions = {
|
|
|
9
9
|
fractionsToDecimal?: boolean;
|
|
10
10
|
decimalToFractionsPrecisionAllowed?: boolean;
|
|
11
11
|
forbidAdditions?: boolean;
|
|
12
|
+
forbidMultiplications?: boolean;
|
|
12
13
|
forbidTrigo?: boolean;
|
|
13
14
|
calculatePowers?: boolean;
|
|
14
15
|
distributePowersOnFrac?: boolean;
|
|
@@ -16,6 +17,7 @@ export type SimplifyOptions = {
|
|
|
16
17
|
forceSeparateSqrts?: boolean;
|
|
17
18
|
forceAddFractions?: boolean;
|
|
18
19
|
noAddOrder?: boolean;
|
|
20
|
+
noMultiplyOrder?: boolean;
|
|
19
21
|
forbidPowerMultiply?: boolean;
|
|
20
22
|
forbidPowerDivision?: boolean;
|
|
21
23
|
forbidPowerPower?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"algebraicNode.d.ts","sourceRoot":"","sources":["../../../src/tree/nodes/algebraicNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,kCAAkC,CAAC,EAAE,OAAO,CAAC;IAC7C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAG5B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AACF,MAAM,WAAW,aAAc,SAAQ,IAAI;IACzC,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM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,EAAE,eAAe,KAAK,MAAM,CAAC;IACxD,mBAAmB,EAAE,MAAM,MAAM,CAAC;CACnC;AACD,8BAAsB,cAAc;;IAElC,OAAO,CAAC,MAAM,CAAC,QAAQ;CAGxB;AACD,eAAO,MAAM,eAAe,GAAI,MAAM,IAAI,KAAG,IAAI,IAAI,aACI,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { NodeIds, NodeOptions, NodeType } from "../node.js";
|
|
2
|
+
import { MultiplyNode } from "../operators/multiplyNode.js";
|
|
3
|
+
import { AddNode } from "../operators/addNode.js";
|
|
2
4
|
import { AlgebraicNode } from "../algebraicNode.js";
|
|
3
5
|
export declare const isComplexNode: (n: AlgebraicNode) => n is ComplexNode;
|
|
4
6
|
export declare class ComplexNode implements AlgebraicNode {
|
|
@@ -28,5 +30,6 @@ export declare class ComplexNode implements AlgebraicNode {
|
|
|
28
30
|
toDetailedEvaluation(vars: Record<string, AlgebraicNode>): ComplexNode;
|
|
29
31
|
toSimplificationTex(): string;
|
|
30
32
|
toSignInequationTex(): string;
|
|
33
|
+
toRawTree(): AlgebraicNode | AddNode | MultiplyNode;
|
|
31
34
|
}
|
|
32
35
|
//# sourceMappingURL=complexNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"complexNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/complex/complexNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"complexNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/complex/complexNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,eAAO,MAAM,aAAa,GAAI,GAAG,aAAa,KAAG,CAAC,IAAI,WAErD,CAAC;AACF,qBAAa,WAAY,YAAW,aAAa;IAC/C,EAAE,EAAE,aAAa,CAAC;IAClB,EAAE,EAAE,aAAa,CAAC;IAClB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAoB;IAClC,SAAS,EAAE,OAAO,CAAC;gBACP,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;IAMpE,aAAa;;;;;;;;;IAOb,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,aAAa,EAAE;IAiBtD,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAI5C,YAAY,IAAI,MAAM;IAGtB,KAAK,IAAI,MAAM;IAUf,QAAQ;IAGR,UAAU,IAAI,aAAa;IAG3B,MAAM,CAAC,IAAI,EAAE,aAAa;IAK1B,QAAQ;IAGR,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAMxD,mBAAmB,IAAI,MAAM;IAG7B,mBAAmB,IAAI,MAAM;IAG7B,SAAS;CAgBV"}
|
|
@@ -71,4 +71,12 @@ export class ComplexNode {
|
|
|
71
71
|
toSignInequationTex() {
|
|
72
72
|
throw new Error("unimplemented");
|
|
73
73
|
}
|
|
74
|
+
toRawTree() {
|
|
75
|
+
if (this.im.toTex() === "0")
|
|
76
|
+
return this.re;
|
|
77
|
+
if (this.re.toTex() === "0") {
|
|
78
|
+
return new MultiplyNode(this.im, new VariableNode("i"));
|
|
79
|
+
}
|
|
80
|
+
return new AddNode(this.re, new MultiplyNode(this.im, new VariableNode("i")));
|
|
81
|
+
}
|
|
74
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"absNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/absNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAKrE,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,OAAO,CAE/C;AACD,eAAO,MAAM,GAAG,GAAI,GAAG,aAAa,GAAG,MAAM,GAAG,MAAM,YAIrD,CAAC;AACF,qBAAa,OAAQ,YAAW,YAAY;IAC1C,EAAE,EAAE,YAAY,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBACP,KAAK,EAAE,aAAa;IAMhC,aAAa;;;;;;IAMb,YAAY,IAAI,MAAM;IAGtB,mBAAmB,IAAI,MAAM;IAG7B,KAAK,CAAC,IAAI,CAAC,EAAE,YAAY,GAAG,MAAM;IAGlC,mBAAmB;IAWnB,iBAAiB,IAAI,aAAa,EAAE;IASpC,cAAc,IAAI,MAAM,EAAE;IAG1B,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe;
|
|
1
|
+
{"version":3,"file":"absNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/absNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAKrE,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,OAAO,CAE/C;AACD,eAAO,MAAM,GAAG,GAAI,GAAG,aAAa,GAAG,MAAM,GAAG,MAAM,YAIrD,CAAC;AACF,qBAAa,OAAQ,YAAW,YAAY;IAC1C,EAAE,EAAE,YAAY,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBACP,KAAK,EAAE,aAAa;IAMhC,aAAa;;;;;;IAMb,YAAY,IAAI,MAAM;IAGtB,mBAAmB,IAAI,MAAM;IAG7B,KAAK,CAAC,IAAI,CAAC,EAAE,YAAY,GAAG,MAAM;IAGlC,mBAAmB;IAWnB,iBAAiB,IAAI,aAAa,EAAE;IASpC,cAAc,IAAI,MAAM,EAAE;IAG1B,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe;IAwB/B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAGtC,MAAM,CAAC,IAAI,EAAE,aAAa;IAI1B,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAKxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS;CAIxC"}
|
|
@@ -4,7 +4,7 @@ import { FunctionsIds, isFunctionNode } from "./functionNode.js";
|
|
|
4
4
|
import { isNumberNode } from "../numbers/numberNode.js";
|
|
5
5
|
import { isOppositeNode } from "./oppositeNode.js";
|
|
6
6
|
import { frac, isFractionNode } from "../operators/fractionNode.js";
|
|
7
|
-
import { multiply } from "../operators/multiplyNode.js";
|
|
7
|
+
import { isMultiplyNode, multiply } from "../operators/multiplyNode.js";
|
|
8
8
|
export function isAbsNode(a) {
|
|
9
9
|
return isFunctionNode(a) && a.id === FunctionsIds.abs;
|
|
10
10
|
}
|
|
@@ -61,6 +61,8 @@ export class AbsNode {
|
|
|
61
61
|
}
|
|
62
62
|
simplify(opts) {
|
|
63
63
|
const childSimplified = this.child.simplify();
|
|
64
|
+
if (childSimplified.evaluate() >= 0)
|
|
65
|
+
return childSimplified;
|
|
64
66
|
if (isNumberNode(childSimplified))
|
|
65
67
|
return Math.abs(childSimplified.value).toTree();
|
|
66
68
|
if (isOppositeNode(childSimplified)) {
|
|
@@ -69,6 +71,9 @@ export class AbsNode {
|
|
|
69
71
|
if (isFractionNode(childSimplified)) {
|
|
70
72
|
return frac(abs(childSimplified.leftChild), abs(childSimplified.rightChild)).simplify(opts);
|
|
71
73
|
}
|
|
74
|
+
if (isMultiplyNode(childSimplified)) {
|
|
75
|
+
return multiply(abs(childSimplified.leftChild), abs(childSimplified.rightChild)).simplify(opts);
|
|
76
|
+
}
|
|
72
77
|
return new AbsNode(childSimplified);
|
|
73
78
|
}
|
|
74
79
|
evaluate(vars) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Node, NodeIds, NodeOptions, NodeType } from "../node.js";
|
|
1
|
+
import { Node, NodeIds, NodeOptions, NodeType, ToTexOptions } from "../node.js";
|
|
2
2
|
import { FunctionNode, FunctionsIds } from "./functionNode.js";
|
|
3
3
|
import { AlgebraicNode, SimplifyOptions } from "../algebraicNode.js";
|
|
4
4
|
export declare const exp: (a: AlgebraicNode | number | string, opts?: NodeOptions) => ExpNode;
|
|
@@ -19,7 +19,7 @@ export declare class ExpNode implements FunctionNode {
|
|
|
19
19
|
toSignInequationTex(): string;
|
|
20
20
|
toMathString(): string;
|
|
21
21
|
toSimplificationTex(): string;
|
|
22
|
-
toTex(): string;
|
|
22
|
+
toTex(options?: ToTexOptions): string;
|
|
23
23
|
toEquivalentNodes(): AlgebraicNode[];
|
|
24
24
|
toAllValidTexs(): string[];
|
|
25
25
|
simplify(opts?: SimplifyOptions, _log?: boolean): AlgebraicNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/expNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,E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AAE,aAAa,CAAC;IAGxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;CAGxD"}
|
|
@@ -43,8 +43,8 @@ export class ExpNode {
|
|
|
43
43
|
toSimplificationTex() {
|
|
44
44
|
throw new Error("unimplemented");
|
|
45
45
|
}
|
|
46
|
-
toTex() {
|
|
47
|
-
const tex = this.child.toTex();
|
|
46
|
+
toTex(options) {
|
|
47
|
+
const tex = this.child.toTex(options);
|
|
48
48
|
if (!this.opts?.allowPowerOne && tex === "1") {
|
|
49
49
|
return "e";
|
|
50
50
|
}
|
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":"AAGA,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;IACP,WAAW,KAAA;IACX,SAAS,KAAA;CACV;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;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,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"}
|
|
@@ -120,6 +120,8 @@ export class AddNode {
|
|
|
120
120
|
const leftSimplified = this.leftChild.simplify(opts);
|
|
121
121
|
const rightSimplified = this.rightChild.simplify(opts);
|
|
122
122
|
const copy = new AddNode(leftSimplified, rightSimplified, this.opts);
|
|
123
|
+
if (opts?.forbidAdditions)
|
|
124
|
+
return copy;
|
|
123
125
|
/**get externals nodes
|
|
124
126
|
*/
|
|
125
127
|
let externals = [];
|
|
@@ -333,6 +335,8 @@ const addSimplifyFrac = (a, b, opts) => {
|
|
|
333
335
|
const d = a.child.rightChild;
|
|
334
336
|
const e = b.leftChild;
|
|
335
337
|
const f = b.rightChild;
|
|
338
|
+
if (d.evaluate() === f.evaluate())
|
|
339
|
+
return new FractionNode(new AddNode(new OppositeNode(c), e), d).simplify(opts);
|
|
336
340
|
return new FractionNode(new AddNode(new MultiplyNode(new OppositeNode(c), f), new MultiplyNode(e, d)), new MultiplyNode(d, f)).simplify(opts);
|
|
337
341
|
}
|
|
338
342
|
if (isOppositeNode(b) &&
|
|
@@ -344,6 +348,8 @@ const addSimplifyFrac = (a, b, opts) => {
|
|
|
344
348
|
const d = a.rightChild;
|
|
345
349
|
const e = b.child.leftChild;
|
|
346
350
|
const f = b.child.rightChild;
|
|
351
|
+
if (d.evaluate() === f.evaluate())
|
|
352
|
+
return new FractionNode(new AddNode(c, new OppositeNode(e)), d).simplify(opts);
|
|
347
353
|
return new FractionNode(new AddNode(new MultiplyNode(c, f), new MultiplyNode(new OppositeNode(e), d)), new MultiplyNode(d, f)).simplify(opts);
|
|
348
354
|
}
|
|
349
355
|
if (isOppositeNode(b) &&
|
|
@@ -3,7 +3,7 @@ import { CommutativeOperatorNode, OperatorIds } from "./operatorNode.js";
|
|
|
3
3
|
import { AlgebraicNode, SimplifyOptions } from "../algebraicNode.js";
|
|
4
4
|
export declare function isMultiplyNode(a: Node): a is MultiplyNode;
|
|
5
5
|
export declare const multiply: (a: AlgebraicNode | number | string, b: AlgebraicNode | number | string, opts?: NodeOptions) => MultiplyNode;
|
|
6
|
-
export declare const sortMultiplyNodes: (arr: AlgebraicNode[]) =>
|
|
6
|
+
export declare const sortMultiplyNodes: (arr: AlgebraicNode[], opts?: SimplifyOptions) => 0 | undefined;
|
|
7
7
|
export declare class MultiplyNode implements CommutativeOperatorNode {
|
|
8
8
|
opts?: NodeOptions;
|
|
9
9
|
id: OperatorIds;
|
|
@@ -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,WAAW,EAEZ,MAAM,mBAAmB,CAAC;AAgB3B,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAYrE,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AAED,eAAO,MAAM,QAAQ,GACnB,GAAG,aAAa,GAAG,MAAM,GAAG,MAAM,EAClC,GAAG,aAAa,GAAG,MAAM,GAAG,MAAM,EAClC,OAAO,WAAW,iBAOnB,CAAC;AACF,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"multiplyNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/multiplyNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAA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Ae,EAAE,GAAG,UAAQ,GAAG,aAAa;IAkK5D,mBAAmB,CAAC,IAAI,CAAC,EAAE,eAAe;IAM1C,mBAAmB;IAOnB,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"}
|
|
@@ -27,7 +27,9 @@ export const multiply = (a, b, opts) => {
|
|
|
27
27
|
const nodeB = typeof b === "number" ? b.toTree() : typeof b === "string" ? b.toTree() : b;
|
|
28
28
|
return new MultiplyNode(nodeA, nodeB, opts);
|
|
29
29
|
};
|
|
30
|
-
export const sortMultiplyNodes = (arr) => {
|
|
30
|
+
export const sortMultiplyNodes = (arr, opts) => {
|
|
31
|
+
if (opts?.noMultiplyOrder)
|
|
32
|
+
return 0;
|
|
31
33
|
arr.sort((a, b) => {
|
|
32
34
|
return (Number(b.isNumeric) - Number(a.isNumeric) ||
|
|
33
35
|
Number(isNumberNode(b) && b.value === -1) -
|
|
@@ -102,7 +104,8 @@ export class MultiplyNode {
|
|
|
102
104
|
// }
|
|
103
105
|
}
|
|
104
106
|
//!this is atrocious
|
|
105
|
-
let showTimesSign = !opts?.
|
|
107
|
+
let showTimesSign = !opts?.forceNoTimesSign &&
|
|
108
|
+
!opts?.forceDotSign &&
|
|
106
109
|
(opts?.forceTimesSign ||
|
|
107
110
|
!isNaN(+rightTex[0]) ||
|
|
108
111
|
(this.rightChild.isNumeric &&
|
|
@@ -114,7 +117,7 @@ export class MultiplyNode {
|
|
|
114
117
|
isVariableNode(this.rightChild) &&
|
|
115
118
|
this.leftChild.name === this.rightChild.name) ||
|
|
116
119
|
(isSqrtNode(this.leftChild) && isSqrtNode(this.rightChild)));
|
|
117
|
-
if (isOperatorNode(this.rightChild)) {
|
|
120
|
+
if (!opts?.forceNoTimesSign && isOperatorNode(this.rightChild)) {
|
|
118
121
|
showTimesSign ||= [OperatorIds.fraction].includes(this.rightChild.id);
|
|
119
122
|
if (isFractionNode(this.rightChild.leftChild)) {
|
|
120
123
|
showTimesSign = true;
|
|
@@ -261,6 +264,8 @@ export class MultiplyNode {
|
|
|
261
264
|
const leftSimplified = this.leftChild.simplify(opts, log);
|
|
262
265
|
const rightSimplified = this.rightChild.simplify(opts, log);
|
|
263
266
|
const copy = new MultiplyNode(leftSimplified, rightSimplified, this.opts);
|
|
267
|
+
if (opts?.forbidMultiplications)
|
|
268
|
+
return copy;
|
|
264
269
|
/**get externals nodes (= extremités du sous arbre non multiplicatif)
|
|
265
270
|
* les opposites sont supprimés et on ajoute *-1 à la fin si leur nb est impair
|
|
266
271
|
*/
|
|
@@ -319,8 +324,8 @@ export class MultiplyNode {
|
|
|
319
324
|
if (nums.some((node) => isNumberNode(node) && node.value === 0)) {
|
|
320
325
|
return new NumberNode(0);
|
|
321
326
|
}
|
|
322
|
-
sortMultiplyNodes(nums);
|
|
323
|
-
sortMultiplyNodes(denums);
|
|
327
|
+
sortMultiplyNodes(nums, opts);
|
|
328
|
+
sortMultiplyNodes(denums, opts);
|
|
324
329
|
const numNode = operatorComposition(MultiplyNode, nums);
|
|
325
330
|
const denumNode = denums.length === 1
|
|
326
331
|
? denums[0]
|
|
@@ -403,7 +408,7 @@ export class MultiplyNode {
|
|
|
403
408
|
return new NumberNode(1);
|
|
404
409
|
if (externals.length === 1)
|
|
405
410
|
return externals[0];
|
|
406
|
-
sortMultiplyNodes(externals);
|
|
411
|
+
sortMultiplyNodes(externals, opts);
|
|
407
412
|
return operatorComposition(MultiplyNode, externals);
|
|
408
413
|
}
|
|
409
414
|
toSimplificationTex(opts) {
|