math-exercises 2.2.59 → 2.2.61
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/exercise.d.ts +6 -0
- package/lib/exercises/exercise.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionAndIntegerDivision.d.ts +1 -1
- package/lib/exercises/math/calcul/fractions/fractionAndIntegerDivision.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionAndIntegerDivision.js +75 -37
- package/lib/exercises/math/calcul/fractions/fractionAndIntegerProduct.d.ts +6 -2
- package/lib/exercises/math/calcul/fractions/fractionAndIntegerProduct.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionAndIntegerProduct.js +88 -40
- package/lib/exercises/math/calcul/fractions/fractionAndIntegerSum.d.ts +4 -1
- package/lib/exercises/math/calcul/fractions/fractionAndIntegerSum.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionAndIntegerSum.js +23 -5
- package/lib/exercises/math/calcul/fractions/fractionsDivision.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsDivision.js +24 -6
- package/lib/exercises/math/calcul/fractions/fractionsProduct.d.ts +4 -1
- package/lib/exercises/math/calcul/fractions/fractionsProduct.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsProduct.js +24 -6
- package/lib/exercises/math/calcul/fractions/fractionsSum.d.ts +2 -2
- package/lib/exercises/math/calcul/fractions/fractionsSum.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSum.js +20 -11
- package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.js +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.js +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSumsSameDenominators.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSumsSameDenominators.js +2 -2
- package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.d.ts +7 -2
- package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.d.ts.map +1 -1
- package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.js +52 -44
- package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.d.ts +7 -2
- package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.d.ts.map +1 -1
- package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.js +55 -40
- package/lib/exercises/math/calculLitteral/systems/basicSystemResolution.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/systems/basicSystemResolution.js +5 -2
- package/lib/exercises/math/functions/affines/signFunction.js +1 -1
- package/lib/exercises/math/functions/trinoms/factorizedFormFromRoots.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/factorizedFormFromRoots.js +1 -0
- package/lib/exercises/math/geometry/thales/thalesCalcul.d.ts.map +1 -1
- package/lib/exercises/math/geometry/thales/thalesCalcul.js +6 -0
- package/lib/exercises/math/powers/powersDivision.d.ts.map +1 -1
- package/lib/exercises/math/powers/powersDivision.js +19 -11
- package/lib/exercises/math/powers/powersPower.d.ts.map +1 -1
- package/lib/exercises/math/powers/powersPower.js +19 -11
- package/lib/exercises/math/powers/powersProduct.d.ts +4 -1
- package/lib/exercises/math/powers/powersProduct.d.ts.map +1 -1
- package/lib/exercises/math/powers/powersProduct.js +84 -35
- package/lib/exercises/math/probaStat/binomial/binomialInequation.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/binomial/binomialInequation.js +6 -0
- package/lib/exercises/math/probaStat/probaFromTableNoContext.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probaFromTableNoContext.js +5 -1
- package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probaFromTableWithContext.js +19 -3
- package/lib/exercises/math/spaceGeometry/lineAndPlaneRelativePosition.d.ts +1 -0
- package/lib/exercises/math/spaceGeometry/lineAndPlaneRelativePosition.d.ts.map +1 -0
- package/lib/exercises/math/spaceGeometry/lineAndPlaneRelativePosition.js +84 -0
- package/lib/exercises/math/squareRoots/index.d.ts +2 -0
- package/lib/exercises/math/squareRoots/index.d.ts.map +1 -1
- package/lib/exercises/math/squareRoots/index.js +2 -0
- package/lib/exercises/math/squareRoots/squareRootsFractions.d.ts +10 -0
- package/lib/exercises/math/squareRoots/squareRootsFractions.d.ts.map +1 -0
- package/lib/exercises/math/squareRoots/squareRootsFractions.js +93 -0
- package/lib/exercises/math/squareRoots/squareRootsToSquare.d.ts +10 -0
- package/lib/exercises/math/squareRoots/squareRootsToSquare.d.ts.map +1 -0
- package/lib/exercises/math/squareRoots/squareRootsToSquare.js +116 -0
- package/lib/exercises/math/trigonometry/mainAngleMeasure.js +13 -13
- package/lib/index.d.ts +41 -11
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/line.d.ts.map +1 -1
- package/lib/math/geometry/line.js +3 -1
- package/lib/math/geometry/vector.d.ts.map +1 -1
- package/lib/math/geometry/vector.js +1 -7
- package/lib/math/numbers/rationals/rational.d.ts +1 -1
- package/lib/math/numbers/rationals/rational.d.ts.map +1 -1
- package/lib/math/numbers/rationals/rational.js +18 -6
- package/lib/math/numbers/reals/extendedRingElement.d.ts +1 -1
- package/lib/playground.d.ts.map +1 -1
- package/lib/playground.js +6 -1
- package/lib/tree/nodes/functions/absNode.d.ts +1 -1
- package/lib/tree/nodes/functions/absNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/absNode.js +9 -1
- package/lib/tree/nodes/functions/sqrtNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/sqrtNode.js +9 -0
- package/lib/tree/nodes/operators/operatorNode.d.ts +2 -1
- package/lib/tree/nodes/operators/operatorNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/operatorNode.js +1 -0
- package/lib/tree/nodes/operators/powerNode.d.ts +2 -0
- package/lib/tree/nodes/operators/powerNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/powerNode.js +21 -83
- package/lib/tree/parsers/powerParser.d.ts +2 -0
- package/lib/tree/parsers/powerParser.d.ts.map +1 -0
- package/lib/tree/parsers/powerParser.js +26 -0
- package/lib/tree/parsers/rationalParser.d.ts +1 -1
- package/lib/tree/parsers/rationalParser.d.ts.map +1 -1
- package/lib/tree/parsers/rationalParser.js +14 -9
- package/lib/tree/parsers/spacePointParser.d.ts.map +1 -1
- package/lib/tree/parsers/spaceVectorParser.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.squareRootsToSquare = void 0;
|
|
4
|
+
const exercise_1 = require("../../../exercises/exercise");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const rational_1 = require("../../../math/numbers/rationals/rational");
|
|
7
|
+
const randint_1 = require("../../../math/utils/random/randint");
|
|
8
|
+
const oppositeNode_1 = require("../../../tree/nodes/functions/oppositeNode");
|
|
9
|
+
const sqrtNode_1 = require("../../../tree/nodes/functions/sqrtNode");
|
|
10
|
+
const nodeConstructor_1 = require("../../../tree/nodes/nodeConstructor");
|
|
11
|
+
const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
|
|
12
|
+
const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
|
|
13
|
+
const powerNode_1 = require("../../../tree/nodes/operators/powerNode");
|
|
14
|
+
const rationalParser_1 = require("../../../tree/parsers/rationalParser");
|
|
15
|
+
const coinFlip_1 = require("../../../utils/alea/coinFlip");
|
|
16
|
+
const getPropositions = (n, { answer, a, isSquareInside, k }) => {
|
|
17
|
+
const propositions = [];
|
|
18
|
+
(0, exercise_1.addValidProp)(propositions, answer);
|
|
19
|
+
const kNode = nodeConstructor_1.NodeConstructor.fromIdentifiers(k);
|
|
20
|
+
if (kNode.evaluate() < 0) {
|
|
21
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, (0, oppositeNode_1.opposite)(getAnswerNode({ a, k, isSquareInside })).toTex());
|
|
22
|
+
}
|
|
23
|
+
if (isSquareInside) {
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, (0, multiplyNode_1.multiply)(a ** 2, (0, sqrtNode_1.sqrt)(kNode))
|
|
27
|
+
.simplify()
|
|
28
|
+
.toTex());
|
|
29
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, (0, multiplyNode_1.multiply)(a, kNode).simplify().toTex());
|
|
30
|
+
}
|
|
31
|
+
while (propositions.length < n) {
|
|
32
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, (0, numberNode_1.isNumberNode)(kNode)
|
|
33
|
+
? (0, randint_1.randint)(2, 100).frenchify()
|
|
34
|
+
: rational_1.RationalConstructor.randomIrreductible().toTree().toTex());
|
|
35
|
+
}
|
|
36
|
+
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
37
|
+
};
|
|
38
|
+
const getAnswerNode = (identifiers) => {
|
|
39
|
+
const { a, k, isSquareInside } = identifiers;
|
|
40
|
+
const kNode = nodeConstructor_1.NodeConstructor.fromIdentifiers(k);
|
|
41
|
+
const ansNode = (isSquareInside
|
|
42
|
+
? (0, multiplyNode_1.multiply)(a, (0, sqrtNode_1.sqrt)((0, powerNode_1.square)(kNode)))
|
|
43
|
+
: (0, powerNode_1.square)((0, multiplyNode_1.multiply)(a, (0, sqrtNode_1.sqrt)(kNode)))).simplify();
|
|
44
|
+
return ansNode;
|
|
45
|
+
};
|
|
46
|
+
const getAnswer = (identifiers) => {
|
|
47
|
+
return `${getAnswerNode(identifiers).toTex()}`;
|
|
48
|
+
};
|
|
49
|
+
const getInstruction = (identifiers) => {
|
|
50
|
+
const { a, k, isSquareInside } = identifiers;
|
|
51
|
+
const kNode = nodeConstructor_1.NodeConstructor.fromIdentifiers(k);
|
|
52
|
+
return `Simplifier au maximum :
|
|
53
|
+
|
|
54
|
+
$$
|
|
55
|
+
${(isSquareInside
|
|
56
|
+
? (0, multiplyNode_1.multiply)(a, (0, sqrtNode_1.sqrt)((0, powerNode_1.square)(kNode)))
|
|
57
|
+
: (0, powerNode_1.square)((0, multiplyNode_1.multiply)(a, (0, sqrtNode_1.sqrt)(kNode)))).toTex()}
|
|
58
|
+
$$`;
|
|
59
|
+
};
|
|
60
|
+
// const getHint: GetHint<Identifiers> = (identifiers) => {};
|
|
61
|
+
// const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
|
|
62
|
+
const getKeys = (identifiers) => {
|
|
63
|
+
return [];
|
|
64
|
+
};
|
|
65
|
+
const isAnswerValid = (ans, { answer, a, isSquareInside, k }) => {
|
|
66
|
+
const answerNode = getAnswerNode({ a, isSquareInside, k });
|
|
67
|
+
const parsed = (0, rationalParser_1.rationalParser)(ans);
|
|
68
|
+
if (!parsed)
|
|
69
|
+
return false;
|
|
70
|
+
const simpTex = parsed.simplify().toTex();
|
|
71
|
+
return (simpTex === answerNode.toTex() ||
|
|
72
|
+
simpTex === answerNode.evaluate().frenchify());
|
|
73
|
+
};
|
|
74
|
+
//a √(k^2) ou (a√k)^2
|
|
75
|
+
//avec k=b ou b/c
|
|
76
|
+
const getSquareRootsToSquareQuestion = () => {
|
|
77
|
+
const a = (0, randint_1.randint)(2, 10);
|
|
78
|
+
const isSquareInside = (0, coinFlip_1.coinFlip)();
|
|
79
|
+
const isInt = (0, coinFlip_1.coinFlip)();
|
|
80
|
+
const k = isInt
|
|
81
|
+
? (0, randint_1.randint)(isSquareInside ? -10 : 2, 11, [0, 1]).toTree()
|
|
82
|
+
: isSquareInside
|
|
83
|
+
? rational_1.RationalConstructor.randomIrreductibleWithSign().toTree()
|
|
84
|
+
: rational_1.RationalConstructor.randomIrreductible().toTree();
|
|
85
|
+
const identifiers = {
|
|
86
|
+
a,
|
|
87
|
+
k: k.toIdentifiers(),
|
|
88
|
+
isSquareInside,
|
|
89
|
+
};
|
|
90
|
+
const question = {
|
|
91
|
+
answer: getAnswer(identifiers),
|
|
92
|
+
instruction: getInstruction(identifiers),
|
|
93
|
+
keys: getKeys(identifiers),
|
|
94
|
+
answerFormat: "tex",
|
|
95
|
+
identifiers,
|
|
96
|
+
// hint: getHint(identifiers),
|
|
97
|
+
// correction: getCorrection(identifiers),
|
|
98
|
+
};
|
|
99
|
+
return question;
|
|
100
|
+
};
|
|
101
|
+
exports.squareRootsToSquare = {
|
|
102
|
+
id: "squareRootsToSquare",
|
|
103
|
+
connector: "=",
|
|
104
|
+
label: "Passer une racine carrée au carré",
|
|
105
|
+
isSingleStep: true,
|
|
106
|
+
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getSquareRootsToSquareQuestion, nb),
|
|
107
|
+
qcmTimer: 60,
|
|
108
|
+
freeTimer: 60,
|
|
109
|
+
getPropositions,
|
|
110
|
+
isAnswerValid,
|
|
111
|
+
subject: "Mathématiques",
|
|
112
|
+
// getHint,
|
|
113
|
+
// getCorrection,
|
|
114
|
+
getAnswer,
|
|
115
|
+
getInstruction,
|
|
116
|
+
};
|
|
@@ -43,13 +43,13 @@ ${angle.toTex()}
|
|
|
43
43
|
$$
|
|
44
44
|
`;
|
|
45
45
|
};
|
|
46
|
-
const getHint = (identifiers) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
};
|
|
50
|
-
const getCorrection = (identifiers) => {
|
|
51
|
-
|
|
52
|
-
};
|
|
46
|
+
// const getHint: GetHint<Identifiers> = (identifiers) => {
|
|
47
|
+
// const angle = NodeConstructor.fromIdentifiers(identifiers.nodeIds);
|
|
48
|
+
// return `La mesure principale d'un angle en radian est sa valeur appartenant à l'intervalle $]-\\pi; \\pi]$. Il faut donc ajouter (ou retirer) $2\\pi$ à $${angle.toTex()}$ jusqu'à ce que le résultat soit dans cet intervalle.`;
|
|
49
|
+
// };
|
|
50
|
+
// const getCorrection: GetCorrection<Identifiers> = (identifiers) => {
|
|
51
|
+
// return `a`;
|
|
52
|
+
// };
|
|
53
53
|
const getKeys = (identifiers) => {
|
|
54
54
|
return ["pi"];
|
|
55
55
|
};
|
|
@@ -67,7 +67,7 @@ const isAnswerValid = (ans, { answer, degree }) => {
|
|
|
67
67
|
};
|
|
68
68
|
const getMainAngleMeasureQuestion = () => {
|
|
69
69
|
const value = (0, random_1.random)(remarkableValues_1.mainTrigoValues);
|
|
70
|
-
const multipleOf2PiToAdd = (0, randint_1.randint)(-
|
|
70
|
+
const multipleOf2PiToAdd = (0, randint_1.randint)(-100, 100, [0]);
|
|
71
71
|
const node = new addNode_1.AddNode(value.angle, new multiplyNode_1.MultiplyNode((2 * multipleOf2PiToAdd).toTree(), piNode_1.PiNode)).simplify();
|
|
72
72
|
const identifiers = {
|
|
73
73
|
degree: value.degree,
|
|
@@ -80,8 +80,8 @@ const getMainAngleMeasureQuestion = () => {
|
|
|
80
80
|
keys: getKeys(identifiers),
|
|
81
81
|
answerFormat: "tex",
|
|
82
82
|
identifiers,
|
|
83
|
-
hint: getHint(identifiers),
|
|
84
|
-
correction: getCorrection(identifiers),
|
|
83
|
+
// hint: getHint(identifiers),
|
|
84
|
+
// correction: getCorrection(identifiers),
|
|
85
85
|
};
|
|
86
86
|
return question;
|
|
87
87
|
};
|
|
@@ -97,8 +97,8 @@ exports.mainAngleMeasure = {
|
|
|
97
97
|
getPropositions,
|
|
98
98
|
isAnswerValid,
|
|
99
99
|
subject: "Mathématiques",
|
|
100
|
-
getHint,
|
|
101
|
-
getCorrection,
|
|
100
|
+
// getHint,
|
|
101
|
+
// getCorrection,
|
|
102
102
|
getAnswer,
|
|
103
|
-
hasHintAndCorrection:
|
|
103
|
+
// hasHintAndCorrection: false,
|
|
104
104
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -26,14 +26,19 @@ declare const mathExercises: (import("./exercises/exercise").Exercise<{
|
|
|
26
26
|
}, {}> | import("./exercises/exercise").Exercise<{
|
|
27
27
|
integerFirst: boolean;
|
|
28
28
|
integer: number;
|
|
29
|
-
rational: [
|
|
29
|
+
rational: number[];
|
|
30
30
|
}, {}> | import("./exercises/exercise").Exercise<{
|
|
31
31
|
integer: number;
|
|
32
|
-
rational: [
|
|
33
|
-
|
|
32
|
+
rational: number[];
|
|
33
|
+
integerFirst: boolean;
|
|
34
|
+
}, {
|
|
35
|
+
allowNonIrreductible?: boolean | undefined;
|
|
36
|
+
}> | import("./exercises/exercise").Exercise<{
|
|
34
37
|
integer: number;
|
|
35
38
|
rational: [number, number];
|
|
36
|
-
}, {
|
|
39
|
+
}, {
|
|
40
|
+
allowNonIrreductible?: boolean | undefined;
|
|
41
|
+
}> | import("./exercises/exercise").Exercise<{
|
|
37
42
|
rand: number;
|
|
38
43
|
numerator: number;
|
|
39
44
|
denominator: number;
|
|
@@ -43,9 +48,11 @@ declare const mathExercises: (import("./exercises/exercise").Exercise<{
|
|
|
43
48
|
}, {}> | import("./exercises/exercise").Exercise<{
|
|
44
49
|
rationalNum: [number, number];
|
|
45
50
|
rationalDenum: [number, number];
|
|
46
|
-
}, {
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
}, {
|
|
52
|
+
allowNonIrreductible?: boolean | undefined;
|
|
53
|
+
}> | import("./exercises/exercise").Exercise<{
|
|
54
|
+
rational: number[];
|
|
55
|
+
rational2: number[];
|
|
49
56
|
}, {
|
|
50
57
|
allowNonIrreductible?: boolean | undefined;
|
|
51
58
|
}> | import("./exercises/exercise").Exercise<{
|
|
@@ -131,13 +138,21 @@ declare const mathExercises: (import("./exercises/exercise").Exercise<{
|
|
|
131
138
|
xValues: any[];
|
|
132
139
|
yValues: any[];
|
|
133
140
|
isProportionnal: boolean;
|
|
134
|
-
|
|
135
|
-
|
|
141
|
+
coeffType: string;
|
|
142
|
+
valuesType: string;
|
|
143
|
+
}, {
|
|
144
|
+
coeffNumberTypes: string[];
|
|
145
|
+
valuesNumberTypes: string[];
|
|
146
|
+
}> | import("./exercises/exercise").Exercise<{
|
|
136
147
|
coeffIds: any;
|
|
137
148
|
xValues: any[];
|
|
138
149
|
yValues: any[];
|
|
139
|
-
|
|
140
|
-
|
|
150
|
+
coeffType: string;
|
|
151
|
+
valuesType: string;
|
|
152
|
+
}, {
|
|
153
|
+
coeffNumberTypes: string[];
|
|
154
|
+
valuesNumberTypes: string[];
|
|
155
|
+
}> | import("./exercises/exercise").Exercise<{
|
|
141
156
|
xValues: number[];
|
|
142
157
|
yValues: number[];
|
|
143
158
|
}, {}> | import("./exercises/exercise").Exercise<{
|
|
@@ -1242,6 +1257,12 @@ declare const mathExercises: (import("./exercises/exercise").Exercise<{
|
|
|
1242
1257
|
b: number;
|
|
1243
1258
|
c: number;
|
|
1244
1259
|
}, {}> | import("./exercises/exercise").Exercise<{
|
|
1260
|
+
a: number;
|
|
1261
|
+
b: number;
|
|
1262
|
+
c: number;
|
|
1263
|
+
}, {
|
|
1264
|
+
useOnlyPowersOfTen: boolean;
|
|
1265
|
+
}> | import("./exercises/exercise").Exercise<{
|
|
1245
1266
|
tenPower: number;
|
|
1246
1267
|
decimal: number;
|
|
1247
1268
|
}, {}> | import("./exercises/exercise").Exercise<{
|
|
@@ -1553,6 +1574,15 @@ declare const mathExercises: (import("./exercises/exercise").Exercise<{
|
|
|
1553
1574
|
b: number;
|
|
1554
1575
|
c: number;
|
|
1555
1576
|
d: number;
|
|
1577
|
+
}, {}> | import("./exercises/exercise").Exercise<{
|
|
1578
|
+
a: number;
|
|
1579
|
+
b: number;
|
|
1580
|
+
c: number;
|
|
1581
|
+
d: number;
|
|
1582
|
+
}, {}> | import("./exercises/exercise").Exercise<{
|
|
1583
|
+
a: number;
|
|
1584
|
+
k: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
|
|
1585
|
+
isSquareInside: boolean;
|
|
1556
1586
|
}, {}> | import("./exercises/exercise").Exercise<{
|
|
1557
1587
|
valueIndex: number;
|
|
1558
1588
|
isCos: boolean;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":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S,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;gBACJ,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM;IAsBvD,aAAa;;;;;IAOb,WAAW,CAAC,IAAI,EAAE,IAAI;IAYtB,YAAY,CAAC,KAAK,EAAE,KAAK;IAWzB,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,WAAW,GAAE,OAAe;IAenD,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM;IAa5B,WAAW,MAAO,MAAM,KAAK,KAAK,KAAG,SAAS,CAmB5C;IAEF,oBAAoB,IAAI,SAAS;IAuBjC,WAAW;IAMX,iBAAiB;;;;;IAcjB,KAAK;IAGL,gBAAgB;IAIhB,aAAa,CACX,iBAAiB,EAAE,OAAO,EAC1B,EACE,OAAc,EACd,SAAiB,EACjB,yBAAgC,GACjC,GAAE,kBAAuB;IAqB5B,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,EAAE,MAAM;CAW7C"}
|
|
@@ -69,7 +69,9 @@ class Line {
|
|
|
69
69
|
if (line.isVertical) {
|
|
70
70
|
return this.isVertical;
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
const vec = vector_1.VectorConstructor.fromPoints(this.pointA, this.pointB);
|
|
73
|
+
const lineVec = vector_1.VectorConstructor.fromPoints(line.pointA, line.pointB);
|
|
74
|
+
return vec.isColinear(lineVec);
|
|
73
75
|
}
|
|
74
76
|
getParallele(point) {
|
|
75
77
|
if (this.isVertical) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/vector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,OAAO,EAAE,IAAI,EAAY,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/vector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,OAAO,EAAE,IAAI,EAAY,MAAM,uBAAuB,CAAC;AAavD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,8BAAsB,iBAAiB;IACrC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,MAAM;IAOpD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,UAAO,GAAG,MAAM;CAOtD;AAED,qBAAa,MAAM;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;gBACL,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa;IAO5D,KAAK,IAAI,MAAM;IAIf,eAAe,IAAI,MAAM;IAMzB,iBAAiB,IAAI,MAAM;IAM3B,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO;IAI9B,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,aAAa;IAIrC,KAAK,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM;IAOrC,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAc9B,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAYtB,OAAO,IAAI,aAAa;IAUxB,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM;IAO5C,MAAM,CAAC,CAAC,EAAE,MAAM;IAIhB,YAAY;IAMZ,YAAY;CAMb"}
|
|
@@ -44,13 +44,7 @@ class Vector {
|
|
|
44
44
|
return det.evaluate({}) === 0;
|
|
45
45
|
}
|
|
46
46
|
determinant(v) {
|
|
47
|
-
|
|
48
|
-
throw Error("general determinant not implemented");
|
|
49
|
-
const xValue = this.x.value;
|
|
50
|
-
const yValue = this.y.value;
|
|
51
|
-
const vxValue = v.x.value;
|
|
52
|
-
const vyValue = v.y.value;
|
|
53
|
-
return new numberNode_1.NumberNode(xValue * vyValue - yValue * vxValue);
|
|
47
|
+
return (0, substractNode_1.substract)((0, multiplyNode_1.multiply)(this.x, v.y), (0, multiplyNode_1.multiply)(this.y, v.x)).simplify();
|
|
54
48
|
}
|
|
55
49
|
times(k, name) {
|
|
56
50
|
return new Vector(name ?? "v", new multiplyNode_1.MultiplyNode(this.x, k).simplify(), new multiplyNode_1.MultiplyNode(this.y, k).simplify());
|
|
@@ -11,7 +11,7 @@ export declare abstract class RationalConstructor {
|
|
|
11
11
|
static randomIrreductible(max?: number): Rational;
|
|
12
12
|
static randomIrreductibleProba(maxDenum?: number): Rational | Integer;
|
|
13
13
|
static randomIrreductibleWithSign(max?: number): Rational;
|
|
14
|
-
static randomPureRational(): Rational;
|
|
14
|
+
static randomPureRational(max?: number): Rational;
|
|
15
15
|
}
|
|
16
16
|
export declare class Rational implements Nombre {
|
|
17
17
|
num: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rational.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/rationals/rational.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EAAQ,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"rational.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/rationals/rational.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EAAQ,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAMvE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE/C,8BAAsB,mBAAmB;IACvC;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,MAAM,GAAE,MAAW;IAW7C,MAAM,CAAC,kBAAkB,CAAC,GAAG,GAAE,MAAW;IAO1C,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,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;IAgBzB,cAAc;IAId,QAAQ,IAAI,OAAO,GAAG,QAAQ;CAqB/B"}
|
|
@@ -13,6 +13,7 @@ const coinFlip_1 = require("../../../utils/alea/coinFlip");
|
|
|
13
13
|
const random_1 = require("../../../utils/alea/random");
|
|
14
14
|
const shuffle_1 = require("../../../utils/alea/shuffle");
|
|
15
15
|
const doWhile_1 = require("../../../utils/doWhile");
|
|
16
|
+
const decimal_1 = require("../decimals/decimal");
|
|
16
17
|
const integer_1 = require("../integer/integer");
|
|
17
18
|
const nombre_1 = require("../nombre");
|
|
18
19
|
class RationalConstructor {
|
|
@@ -52,8 +53,8 @@ class RationalConstructor {
|
|
|
52
53
|
const [num, denum] = (0, shuffle_1.shuffle)([a, b]);
|
|
53
54
|
return new Rational(sign * num, denum);
|
|
54
55
|
}
|
|
55
|
-
static randomPureRational() {
|
|
56
|
-
const frac = (0, doWhile_1.doWhile)(() => RationalConstructor.randomIrreductible(
|
|
56
|
+
static randomPureRational(max = 20) {
|
|
57
|
+
const frac = (0, doWhile_1.doWhile)(() => RationalConstructor.randomIrreductible(max), (x) => (0, round_1.round)(x.value, 10) === x.value);
|
|
57
58
|
return frac;
|
|
58
59
|
}
|
|
59
60
|
}
|
|
@@ -139,10 +140,21 @@ class Rational {
|
|
|
139
140
|
}
|
|
140
141
|
simplify() {
|
|
141
142
|
const sign = this.num * this.denum > 0 ? 1 : -1;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
let intNum = this.num;
|
|
144
|
+
let intDenum = this.denum;
|
|
145
|
+
if (Math.floor(intNum) !== intNum || Math.floor(intDenum) !== intDenum) {
|
|
146
|
+
const numDec = new decimal_1.Decimal(intNum);
|
|
147
|
+
const denumDec = new decimal_1.Decimal(intDenum);
|
|
148
|
+
const numPrec = numDec.precision;
|
|
149
|
+
const denumPrec = denumDec.precision;
|
|
150
|
+
const totalPrec = Math.max(numPrec, denumPrec);
|
|
151
|
+
intNum = numDec.multiplyByPowerOfTen(totalPrec).value;
|
|
152
|
+
intDenum = denumDec.multiplyByPowerOfTen(totalPrec).value;
|
|
153
|
+
}
|
|
154
|
+
const div = Math.abs((0, gcd_1.gcd)(intNum, intDenum));
|
|
155
|
+
if (Math.abs(intDenum) === div)
|
|
156
|
+
return new integer_1.Integer(intNum / intDenum);
|
|
157
|
+
return new Rational((sign * Math.abs(intNum)) / div, Math.abs(intDenum) / div);
|
|
146
158
|
}
|
|
147
159
|
}
|
|
148
160
|
exports.Rational = Rational;
|
|
@@ -13,6 +13,6 @@ export declare class ExtendedRingElement {
|
|
|
13
13
|
b: number;
|
|
14
14
|
algebraicElement: Nombre;
|
|
15
15
|
constructor(a: number, b: number, algebraicElement: Nombre);
|
|
16
|
-
toTree(): import("../../../tree/nodes/algebraicNode").AlgebraicNode | NumberNode |
|
|
16
|
+
toTree(): import("../../../tree/nodes/algebraicNode").AlgebraicNode | NumberNode | OppositeNode | MultiplyNode | AddNode | SubstractNode;
|
|
17
17
|
}
|
|
18
18
|
//# sourceMappingURL=extendedRingElement.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":"
|
|
1
|
+
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAsCA,eAAO,MAAM,UAAU,YAItB,CAAC"}
|
package/lib/playground.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.playground = void 0;
|
|
4
|
-
const
|
|
4
|
+
const rational_1 = require("./math/numbers/rationals/rational");
|
|
5
|
+
const playground = () => {
|
|
6
|
+
// console.log(multiply(1.8, frac(3, 7)).simplify().toTex());
|
|
7
|
+
const ratio = new rational_1.Rational(5.4, 7).simplify();
|
|
8
|
+
console.log(ratio.toTree().toTex());
|
|
9
|
+
};
|
|
5
10
|
exports.playground = playground;
|
|
@@ -18,7 +18,7 @@ export declare class AbsNode implements FunctionNode {
|
|
|
18
18
|
toTex(): string;
|
|
19
19
|
toEquivalentNodes(): AlgebraicNode[];
|
|
20
20
|
toAllValidTexs(): string[];
|
|
21
|
-
simplify(): AbsNode;
|
|
21
|
+
simplify(): AlgebraicNode | AbsNode;
|
|
22
22
|
evaluate(vars?: Record<string, number>): number;
|
|
23
23
|
equals(node: AlgebraicNode): boolean;
|
|
24
24
|
toDetailedEvaluation(vars: Record<string, AlgebraicNode>): AbsNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"absNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/absNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
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,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,OAAO,CAE/C;AACD,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;IAItB,KAAK,IAAI,MAAM;IAOf,iBAAiB,IAAI,aAAa,EAAE;IASpC,cAAc,IAAI,MAAM,EAAE;IAG1B,QAAQ;IAUR,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAGtC,MAAM,CAAC,IAAI,EAAE,aAAa;IAI1B,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;CAGzD"}
|
|
@@ -4,6 +4,8 @@ exports.AbsNode = exports.isAbsNode = void 0;
|
|
|
4
4
|
// import { abs } from "mathjs";
|
|
5
5
|
const node_1 = require("../node");
|
|
6
6
|
const functionNode_1 = require("./functionNode");
|
|
7
|
+
const numberNode_1 = require("../numbers/numberNode");
|
|
8
|
+
const oppositeNode_1 = require("./oppositeNode");
|
|
7
9
|
function isAbsNode(a) {
|
|
8
10
|
return (0, functionNode_1.isFunctionNode)(a) && a.id === functionNode_1.FunctionsIds.abs;
|
|
9
11
|
}
|
|
@@ -42,7 +44,13 @@ class AbsNode {
|
|
|
42
44
|
return this.toEquivalentNodes().map((node) => node.toTex());
|
|
43
45
|
}
|
|
44
46
|
simplify() {
|
|
45
|
-
|
|
47
|
+
const childSimplified = this.child.simplify();
|
|
48
|
+
if ((0, numberNode_1.isNumberNode)(childSimplified))
|
|
49
|
+
return Math.abs(childSimplified.value).toTree();
|
|
50
|
+
if ((0, oppositeNode_1.isOppositeNode)(childSimplified)) {
|
|
51
|
+
return childSimplified.child;
|
|
52
|
+
}
|
|
53
|
+
return new AbsNode(childSimplified);
|
|
46
54
|
}
|
|
47
55
|
evaluate(vars) {
|
|
48
56
|
return Math.abs(this.child.evaluate(vars));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqrtNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/sqrtNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAK5E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,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,SAAS,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAK5E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAMlE,wBAAgB,UAAU,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,QAAQ,CAEjD;AAED,eAAO,MAAM,IAAI,MAAO,aAAa,GAAG,MAAM,GAAG,MAAM,aAItD,CAAC;AAEF,qBAAa,QAAS,YAAW,YAAY;IAC3C,EAAE,EAAE,YAAY,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;gBACP,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;IAOpD,aAAa;;;;;;IAMb,YAAY,IAAI,MAAM;IAMtB,KAAK,IAAI,MAAM;IAIf,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,aAAa,EAAE;IAwBtD,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAG5C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAGtC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe;IAyC/B,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAGpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;CAGzD"}
|
|
@@ -9,6 +9,9 @@ const numberNode_1 = require("../numbers/numberNode");
|
|
|
9
9
|
const multiplyNode_1 = require("../operators/multiplyNode");
|
|
10
10
|
const isInt_1 = require("../../../utils/isInt");
|
|
11
11
|
const operatorComposition_1 = require("../../../tree/utilities/operatorComposition");
|
|
12
|
+
const fractionNode_1 = require("../operators/fractionNode");
|
|
13
|
+
const powerNode_1 = require("../operators/powerNode");
|
|
14
|
+
const absNode_1 = require("./absNode");
|
|
12
15
|
function isSqrtNode(a) {
|
|
13
16
|
return (0, functionNode_1.isFunctionNode)(a) && a.id === functionNode_1.FunctionsIds.sqrt;
|
|
14
17
|
}
|
|
@@ -88,6 +91,12 @@ class SqrtNode {
|
|
|
88
91
|
return sqrt.simplify().toTree();
|
|
89
92
|
}
|
|
90
93
|
//TODO diviser par 2 les puissances (dont exp)
|
|
94
|
+
if ((0, powerNode_1.isSquareNode)(a)) {
|
|
95
|
+
return new absNode_1.AbsNode(a.leftChild).simplify();
|
|
96
|
+
}
|
|
97
|
+
if ((0, fractionNode_1.isFractionNode)(a)) {
|
|
98
|
+
return (0, fractionNode_1.frac)((0, exports.sqrt)(a.leftChild), (0, exports.sqrt)(a.rightChild)).simplify(opts);
|
|
99
|
+
}
|
|
91
100
|
return new SqrtNode(a);
|
|
92
101
|
};
|
|
93
102
|
const simplifyIteration = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operatorNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/operatorNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAY,MAAM,SAAS,CAAC;AAEzC,oBAAY,WAAW;IACrB,GAAG,IAAA;IACH,SAAS,IAAA;IACT,QAAQ,IAAA;IACR,QAAQ,IAAA;IACR,MAAM,IAAA;IACN,KAAK,IAAA;IACL,KAAK,IAAA;IACL,QAAQ,IAAA;IACR,mBAAmB,IAAA;
|
|
1
|
+
{"version":3,"file":"operatorNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/operatorNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAY,MAAM,SAAS,CAAC;AAEzC,oBAAY,WAAW;IACrB,GAAG,IAAA;IACH,SAAS,IAAA;IACT,QAAQ,IAAA;IACR,QAAQ,IAAA;IACR,MAAM,IAAA;IACN,KAAK,IAAA;IACL,KAAK,IAAA;IACL,QAAQ,IAAA;IACR,mBAAmB,IAAA;IACnB,MAAM,IAAA;CACP;AAED,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;CAC3B;AACD,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AAED,MAAM,WAAW,uBAAwB,SAAQ,YAAY;IAC3D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,MAAM,EAAE,CAAC;CAC3B"}
|
|
@@ -13,6 +13,7 @@ var OperatorIds;
|
|
|
13
13
|
OperatorIds[OperatorIds["limit"] = 6] = "limit";
|
|
14
14
|
OperatorIds[OperatorIds["integral"] = 7] = "integral";
|
|
15
15
|
OperatorIds[OperatorIds["binomialCoefficient"] = 8] = "binomialCoefficient";
|
|
16
|
+
OperatorIds[OperatorIds["square"] = 9] = "square";
|
|
16
17
|
})(OperatorIds || (exports.OperatorIds = OperatorIds = {}));
|
|
17
18
|
function isOperatorNode(a) {
|
|
18
19
|
return a.type === node_1.NodeType.operator;
|
|
@@ -2,7 +2,9 @@ import { Node, NodeIds, NodeOptions, NodeType } from "../node";
|
|
|
2
2
|
import { OperatorIds, OperatorNode } from "./operatorNode";
|
|
3
3
|
import { AlgebraicNode, SimplifyOptions } from "../algebraicNode";
|
|
4
4
|
export declare function isPowerNode(a: Node): a is PowerNode;
|
|
5
|
+
export declare function isSquareNode(a: Node): a is SquareNode;
|
|
5
6
|
export declare const square: (a: AlgebraicNode | number | string) => SquareNode;
|
|
7
|
+
export declare const power: (a: AlgebraicNode | number | string, b: AlgebraicNode | number | string, opts?: NodeOptions) => PowerNode;
|
|
6
8
|
export declare class PowerNode implements OperatorNode {
|
|
7
9
|
opts?: NodeOptions;
|
|
8
10
|
id: OperatorIds;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"powerNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/powerNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAG3E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"powerNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/powerNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAG3E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGlE,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,SAAS,CAEnD;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,UAAU,CAErD;AACD,eAAO,MAAM,MAAM,MAAO,aAAa,GAAG,MAAM,GAAG,MAAM,eAKxD,CAAC;AAEF,eAAO,MAAM,KAAK,MACb,aAAa,GAAG,MAAM,GAAG,MAAM,KAC/B,aAAa,GAAG,MAAM,GAAG,MAAM,SAC3B,WAAW,cAOnB,CAAC;AAEF,qBAAa,SAAU,YAAW,YAAY;IAC5C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,EAAE,EA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