math-exercises 2.2.68 → 2.2.69
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/functions/absolute/absolueValueAffineEquation.d.ts +9 -0
- package/lib/exercises/math/functions/absolute/absolueValueAffineEquation.d.ts.map +1 -0
- package/lib/exercises/math/functions/absolute/absolueValueAffineEquation.js +178 -0
- package/lib/exercises/math/functions/absolute/index.d.ts +1 -0
- package/lib/exercises/math/functions/absolute/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/absolute/index.js +1 -0
- package/lib/exercises/math/functions/trinoms/rootsProduct.js +1 -1
- package/lib/exercises/math/functions/trinoms/rootsSum.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/rootsSum.js +2 -3
- package/lib/exercises/math/geometry/euclidianConstructions/pointImageFromTranslation.d.ts.map +1 -1
- package/lib/exercises/math/geometry/euclidianConstructions/pointImageFromTranslation.js +4 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/math/numbers/nombre.d.ts +5 -0
- package/lib/math/numbers/nombre.d.ts.map +1 -1
- package/lib/math/numbers/nombre.js +12 -0
- package/lib/math/polynomials/generalAffine.d.ts +13 -0
- package/lib/math/polynomials/generalAffine.d.ts.map +1 -1
- package/lib/math/polynomials/generalAffine.js +25 -1
- package/lib/playground.d.ts.map +1 -1
- package/lib/playground.js +8 -1
- package/lib/tree/nodes/functions/absNode.d.ts +1 -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/nodeConstructor.d.ts +3 -0
- package/lib/tree/nodes/nodeConstructor.d.ts.map +1 -1
- package/lib/tree/nodes/nodeConstructor.js +5 -1
- package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/fractionNode.js +6 -1
- 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 +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise";
|
|
2
|
+
import { GeneralAffineIdentifiers } from "../../../../math/polynomials/generalAffine";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
firstAffine: GeneralAffineIdentifiers;
|
|
5
|
+
secondAffine: GeneralAffineIdentifiers;
|
|
6
|
+
};
|
|
7
|
+
export declare const absolueValueAffineEquation: Exercise<Identifiers>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=absolueValueAffineEquation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"absolueValueAffineEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/absolute/absolueValueAffineEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AAKlC,OAAO,EAGL,wBAAwB,EACzB,MAAM,sCAAsC,CAAC;AAM9C,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,wBAAwB,CAAC;IACtC,YAAY,EAAE,wBAAwB,CAAC;CACxC,CAAC;AA4KF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAiB5D,CAAC"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.absolueValueAffineEquation = void 0;
|
|
4
|
+
const exercise_1 = require("../../../../exercises/exercise");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const integer_1 = require("../../../../math/numbers/integer/integer");
|
|
7
|
+
const nombre_1 = require("../../../../math/numbers/nombre");
|
|
8
|
+
const rational_1 = require("../../../../math/numbers/rationals/rational");
|
|
9
|
+
const generalAffine_1 = require("../../../../math/polynomials/generalAffine");
|
|
10
|
+
const equalNode_1 = require("../../../../tree/nodes/equations/equalNode");
|
|
11
|
+
const absNode_1 = require("../../../../tree/nodes/functions/absNode");
|
|
12
|
+
const rationalParser_1 = require("../../../../tree/parsers/rationalParser");
|
|
13
|
+
const getPropositions = (n, { answer }) => {
|
|
14
|
+
const propositions = [];
|
|
15
|
+
(0, exercise_1.addValidProp)(propositions, answer);
|
|
16
|
+
while (propositions.length < n) {
|
|
17
|
+
const fracs = [
|
|
18
|
+
rational_1.RationalConstructor.randomIrreductibleWithSign().toTree(),
|
|
19
|
+
rational_1.RationalConstructor.randomIrreductibleWithSign().toTree(),
|
|
20
|
+
].sort((a, b) => a.evaluate() - b.evaluate());
|
|
21
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, `x=${fracs[0].toTex()}\\text{ ou }${fracs[1].toTex()}`);
|
|
22
|
+
}
|
|
23
|
+
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
24
|
+
};
|
|
25
|
+
const getAnswerNode = (identifiers) => {
|
|
26
|
+
const affines = [
|
|
27
|
+
generalAffine_1.GeneralAffineConstructor.fromIdentifiers(identifiers.firstAffine),
|
|
28
|
+
generalAffine_1.GeneralAffineConstructor.fromIdentifiers(identifiers.secondAffine),
|
|
29
|
+
];
|
|
30
|
+
const firstIntersec = affines[0].xIntersect(affines[1]);
|
|
31
|
+
const oppositeAffine = affines[1].opposite();
|
|
32
|
+
const secondIntersec = oppositeAffine.xIntersect(affines[0]);
|
|
33
|
+
const res = [firstIntersec, secondIntersec]
|
|
34
|
+
.filter(Boolean)
|
|
35
|
+
.sort((a, b) => a.evaluate() - b.evaluate());
|
|
36
|
+
return res;
|
|
37
|
+
};
|
|
38
|
+
const getAnswer = (identifiers) => {
|
|
39
|
+
const nodes = getAnswerNode(identifiers);
|
|
40
|
+
if (nodes.length > 1)
|
|
41
|
+
return `x=${nodes[0].toTex()}\\text{ ou }x=${nodes[1].toTex()}`;
|
|
42
|
+
return `x=${nodes[0]?.toTex() || nodes[1]?.toTex()}`;
|
|
43
|
+
};
|
|
44
|
+
const getInstruction = (identifiers) => {
|
|
45
|
+
const affines = [
|
|
46
|
+
generalAffine_1.GeneralAffineConstructor.fromIdentifiers(identifiers.firstAffine),
|
|
47
|
+
generalAffine_1.GeneralAffineConstructor.fromIdentifiers(identifiers.secondAffine),
|
|
48
|
+
];
|
|
49
|
+
const node = (0, equalNode_1.equal)((0, absNode_1.abs)(affines[0].toTree()), (0, absNode_1.abs)(affines[1].toTree()));
|
|
50
|
+
return `Résoudre :
|
|
51
|
+
|
|
52
|
+
$$
|
|
53
|
+
${node.toTex()}
|
|
54
|
+
$$`;
|
|
55
|
+
};
|
|
56
|
+
const getHint = (identifiers) => {
|
|
57
|
+
return `L'égalité $|a|=|b|$ est vraie si et seulement si $a = b$ ou $a = -b$.`;
|
|
58
|
+
};
|
|
59
|
+
const getCorrection = (identifiers) => {
|
|
60
|
+
const affines = [
|
|
61
|
+
generalAffine_1.GeneralAffineConstructor.fromIdentifiers(identifiers.firstAffine),
|
|
62
|
+
generalAffine_1.GeneralAffineConstructor.fromIdentifiers(identifiers.secondAffine),
|
|
63
|
+
];
|
|
64
|
+
const firstIntersec = affines[0].xIntersect(affines[1]);
|
|
65
|
+
const oppositeAffine = affines[1].opposite();
|
|
66
|
+
const secondIntersec = oppositeAffine.xIntersect(affines[0]);
|
|
67
|
+
const res = [firstIntersec, secondIntersec]
|
|
68
|
+
.filter(Boolean)
|
|
69
|
+
.sort((a, b) => a.evaluate() - b.evaluate());
|
|
70
|
+
return `L'égalité $|a|=|b|$ est vraie si et seulement si $a = b$ ou $a=-b$.
|
|
71
|
+
|
|
72
|
+
On doit donc résoudre deux équations: d'une part,
|
|
73
|
+
|
|
74
|
+
$$
|
|
75
|
+
${affines[0].toTree().toTex()} = ${affines[1].toTree().toTex()}
|
|
76
|
+
$$
|
|
77
|
+
|
|
78
|
+
${firstIntersec
|
|
79
|
+
? `ce qui donne :
|
|
80
|
+
|
|
81
|
+
$$
|
|
82
|
+
x=${firstIntersec?.toTex()}
|
|
83
|
+
$$`
|
|
84
|
+
: "qui n'a pas de solution, "}
|
|
85
|
+
|
|
86
|
+
et d'autre part :
|
|
87
|
+
|
|
88
|
+
$$
|
|
89
|
+
${affines[0].toTree().toTex()} = ${oppositeAffine.toTree().toTex()}
|
|
90
|
+
$$
|
|
91
|
+
|
|
92
|
+
${secondIntersec
|
|
93
|
+
? `ce qui donne :
|
|
94
|
+
|
|
95
|
+
$$
|
|
96
|
+
x=${secondIntersec?.toTex()}
|
|
97
|
+
$$`
|
|
98
|
+
: "qui n'a pas de solution."}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
Ainsi, la solution de cette équation est :
|
|
102
|
+
|
|
103
|
+
$$
|
|
104
|
+
${res.length > 1
|
|
105
|
+
? `x=${res[0].toTex()} \\text{ ou } x=${res[1].toTex()}`
|
|
106
|
+
: `x=${res[0]?.toTex() || res[1]?.toTex()}`}
|
|
107
|
+
`;
|
|
108
|
+
};
|
|
109
|
+
const getKeys = (identifiers) => {
|
|
110
|
+
return ["x", "equal", "ou"];
|
|
111
|
+
};
|
|
112
|
+
const isAnswerValid = (ans, { answer, ...identifiers }) => {
|
|
113
|
+
const parsedOu = ans.split("\\text{ ou }");
|
|
114
|
+
console.log(parsedOu);
|
|
115
|
+
try {
|
|
116
|
+
const nodes = [];
|
|
117
|
+
parsedOu.forEach((item) => {
|
|
118
|
+
let formated = item
|
|
119
|
+
.replaceAll("\\text{", "")
|
|
120
|
+
.replaceAll("}", "")
|
|
121
|
+
.replaceAll(" ", "");
|
|
122
|
+
const equalForm = formated.split("=");
|
|
123
|
+
if (equalForm.length > 1 && equalForm[0] !== "x")
|
|
124
|
+
throw Error("wrong answer");
|
|
125
|
+
const nbStr = equalForm.length > 1 ? equalForm[1] : formated;
|
|
126
|
+
const node = (0, rationalParser_1.rationalParser)(nbStr);
|
|
127
|
+
if (!node)
|
|
128
|
+
throw Error("wrong answer");
|
|
129
|
+
nodes.push(node);
|
|
130
|
+
});
|
|
131
|
+
const answerNodes = getAnswerNode(identifiers);
|
|
132
|
+
return answerNodes.every((e) => nodes.some((n) => n.evaluate() === e.evaluate()));
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const getAbsolueValueAffineEquationQuestion = (ops) => {
|
|
139
|
+
const types = [nombre_1.NumberType.Integer];
|
|
140
|
+
const [a, c] = nombre_1.NombreConstructor.manyRandom(4, {
|
|
141
|
+
types,
|
|
142
|
+
excludes: [new integer_1.Integer(0)],
|
|
143
|
+
}).map((e) => e.toTree());
|
|
144
|
+
const [b, d] = nombre_1.NombreConstructor.manyRandom(4, {
|
|
145
|
+
types,
|
|
146
|
+
}).map((e) => e.toTree());
|
|
147
|
+
const identifiers = {
|
|
148
|
+
firstAffine: new generalAffine_1.GeneralAffine(a, b).toIdentifiers(),
|
|
149
|
+
secondAffine: new generalAffine_1.GeneralAffine(c, d).toIdentifiers(),
|
|
150
|
+
};
|
|
151
|
+
const question = {
|
|
152
|
+
answer: getAnswer(identifiers),
|
|
153
|
+
instruction: getInstruction(identifiers),
|
|
154
|
+
keys: getKeys(identifiers),
|
|
155
|
+
answerFormat: "tex",
|
|
156
|
+
identifiers,
|
|
157
|
+
hint: getHint(identifiers),
|
|
158
|
+
correction: getCorrection(identifiers),
|
|
159
|
+
};
|
|
160
|
+
return question;
|
|
161
|
+
};
|
|
162
|
+
exports.absolueValueAffineEquation = {
|
|
163
|
+
id: "absolueValueAffineEquation",
|
|
164
|
+
connector: "\\iff",
|
|
165
|
+
label: "Résoudre une équation avec valeur absolue du type $|ax+b|=|cx+d|$",
|
|
166
|
+
isSingleStep: false,
|
|
167
|
+
generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getAbsolueValueAffineEquationQuestion(opts), nb),
|
|
168
|
+
qcmTimer: 60,
|
|
169
|
+
freeTimer: 60,
|
|
170
|
+
getPropositions,
|
|
171
|
+
isAnswerValid,
|
|
172
|
+
subject: "Mathématiques",
|
|
173
|
+
getInstruction,
|
|
174
|
+
getHint,
|
|
175
|
+
getCorrection,
|
|
176
|
+
getAnswer,
|
|
177
|
+
hasHintAndCorrection: true,
|
|
178
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/absolute/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/absolute/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC"}
|
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./absoluteValueEquations"), exports);
|
|
18
18
|
__exportStar(require("./absoluteValueInequations"), exports);
|
|
19
|
+
__exportStar(require("./absolueValueAffineEquation"), exports);
|
|
@@ -77,7 +77,7 @@ const getRootsProductQuestion = (ops) => {
|
|
|
77
77
|
//ac <= 0
|
|
78
78
|
const a = (0, randint_1.randint)(-10, 10, [0]);
|
|
79
79
|
const b = (0, randint_1.randint)(-10, 10);
|
|
80
|
-
const c = (a / Math.abs(a)) * (0, randint_1.randint)(-10,
|
|
80
|
+
const c = (a / Math.abs(a)) * (0, randint_1.randint)(-10, 0, !b ? [0] : []);
|
|
81
81
|
const trinom = new generalTrinom_1.GeneralTrinom(a, b, c);
|
|
82
82
|
const identifiers = {
|
|
83
83
|
trinomIdentifiers: trinom.toIdentifiers(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rootsSum.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/trinoms/rootsSum.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAGL,wBAAwB,EACzB,MAAM,sCAAsC,CAAC;AAO9C,KAAK,WAAW,GAAG;IACjB,iBAAiB,EAAE,wBAAwB,CAAC;CAC7C,CAAC;
|
|
1
|
+
{"version":3,"file":"rootsSum.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/trinoms/rootsSum.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAGL,wBAAwB,EACzB,MAAM,sCAAsC,CAAC;AAO9C,KAAK,WAAW,GAAG;IACjB,iBAAiB,EAAE,wBAAwB,CAAC;CAC7C,CAAC;AAoGF,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,WAAW,CAiB1C,CAAC"}
|
|
@@ -56,7 +56,7 @@ const getCorrection = (identifiers) => {
|
|
|
56
56
|
return `Si $f(x) = ax^2 + bx + c$ admet deux racines, alors leur somme $S$ vaut :
|
|
57
57
|
|
|
58
58
|
$$
|
|
59
|
-
S = \\frac{
|
|
59
|
+
S = \\frac{-b}{a}
|
|
60
60
|
$$
|
|
61
61
|
|
|
62
62
|
Ici, on a $a = ${aTex}$ et $b = ${bTex}$, donc :
|
|
@@ -73,11 +73,10 @@ const isAnswerValid = (ans, { answer }) => {
|
|
|
73
73
|
return (0, rationalVEA_1.rationalVEA)(ans, answer);
|
|
74
74
|
};
|
|
75
75
|
const getRootsSumQuestion = (ops) => {
|
|
76
|
-
//(b,c) != 0
|
|
77
76
|
//ac <= 0
|
|
78
77
|
const a = (0, randint_1.randint)(-10, 10, [0]);
|
|
79
78
|
const b = (0, randint_1.randint)(-10, 10);
|
|
80
|
-
const c = (a / Math.abs(a)) * (0, randint_1.randint)(-10,
|
|
79
|
+
const c = (a / Math.abs(a)) * (0, randint_1.randint)(-10, 0, !b ? [0] : []);
|
|
81
80
|
// const trinom = GeneralTrinomConstructor.randomNiceRoots(2);
|
|
82
81
|
const trinom = new generalTrinom_1.GeneralTrinom(a, b, c);
|
|
83
82
|
const identifiers = {
|
package/lib/exercises/math/geometry/euclidianConstructions/pointImageFromTranslation.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pointImageFromTranslation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/euclidianConstructions/pointImageFromTranslation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAGL,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAMnC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;
|
|
1
|
+
{"version":3,"file":"pointImageFromTranslation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/euclidianConstructions/pointImageFromTranslation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAGL,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAMnC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAmIF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAepE,CAAC"}
|
|
@@ -57,7 +57,10 @@ const isGGBAnswerValid = (ans, { ggbAnswer }) => {
|
|
|
57
57
|
const studentAns = ans.filter((c) => !["A", "B", "C", "D"].includes(c[0]));
|
|
58
58
|
if (studentAns.length !== 1)
|
|
59
59
|
return false;
|
|
60
|
-
const
|
|
60
|
+
const studentPoint = studentAns[0].split("=")[1];
|
|
61
|
+
if (studentPoint === undefined)
|
|
62
|
+
return false;
|
|
63
|
+
const coords = (0, ggbPointToCoords_1.ggbPointToCoords)(studentPoint);
|
|
61
64
|
const coordsAns = (0, ggbPointToCoords_1.ggbPointToCoords)(ggbAnswer[0].split("=")[1]);
|
|
62
65
|
return ((0, approxEqual_1.approxEqual)(coords.x, coordsAns.x, 0.2) &&
|
|
63
66
|
(0, approxEqual_1.approxEqual)(coords.y, coordsAns.y, 0.2));
|
package/lib/index.d.ts
CHANGED
|
@@ -578,6 +578,9 @@ declare const mathExercises: (Exercise<{
|
|
|
578
578
|
a: number;
|
|
579
579
|
b: number;
|
|
580
580
|
isStrict: boolean;
|
|
581
|
+
}, {}> | Exercise<{
|
|
582
|
+
firstAffine: import("./math/polynomials/generalAffine").GeneralAffineIdentifiers;
|
|
583
|
+
secondAffine: import("./math/polynomials/generalAffine").GeneralAffineIdentifiers;
|
|
581
584
|
}, {}> | Exercise<{
|
|
582
585
|
xA: number;
|
|
583
586
|
yA: 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,sBAAsB,CAAC;AAG1D,OAAO,yBAAyB,CAAC;AAEjC,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,sBAAsB,CAAC;AAG1D,OAAO,yBAAyB,CAAC;AAEjC,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -18,5 +18,10 @@ export declare abstract class NombreConstructor {
|
|
|
18
18
|
types?: NumberType[];
|
|
19
19
|
excludes?: Nombre[];
|
|
20
20
|
}): Nombre;
|
|
21
|
+
static manyRandom(n: number, { types, excludes, allDifferent, }?: {
|
|
22
|
+
types?: NumberType[];
|
|
23
|
+
excludes?: Nombre[];
|
|
24
|
+
allDifferent?: boolean;
|
|
25
|
+
}): Nombre[];
|
|
21
26
|
}
|
|
22
27
|
//# sourceMappingURL=nombre.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nombre.d.ts","sourceRoot":"","sources":["../../../src/math/numbers/nombre.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAQ,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAQ1D,oBAAY,UAAU;IACpB,OAAO,IAAA;IACP,OAAO,IAAA;IACP,QAAQ,IAAA;IACR,IAAI,IAAA;CACL;AAED,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,WAAW,KAAK,aAAa,CAAC;IAC9C,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;CAChC;AAED,8BAAsB,iBAAiB;IACrC,MAAM,CAAC,MAAM,CAAC,EACZ,KAAK,EACL,QAAQ,GACT,GAAE;QACD,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KAChB;
|
|
1
|
+
{"version":3,"file":"nombre.d.ts","sourceRoot":"","sources":["../../../src/math/numbers/nombre.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAQ,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAQ1D,oBAAY,UAAU;IACpB,OAAO,IAAA;IACP,OAAO,IAAA;IACP,QAAQ,IAAA;IACR,IAAI,IAAA;CACL;AAED,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,WAAW,KAAK,aAAa,CAAC;IAC9C,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;CAChC;AAED,8BAAsB,iBAAiB;IACrC,MAAM,CAAC,MAAM,CAAC,EACZ,KAAK,EACL,QAAQ,GACT,GAAE;QACD,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KAChB;IAiCN,MAAM,CAAC,UAAU,CACf,CAAC,EAAE,MAAM,EACT,EACE,KAAK,EACL,QAAQ,EACR,YAAoB,GACrB,GAAE;QACD,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,YAAY,CAAC,EAAE,OAAO,CAAC;KACnB;CAaT"}
|
|
@@ -48,5 +48,17 @@ class NombreConstructor {
|
|
|
48
48
|
}
|
|
49
49
|
return res;
|
|
50
50
|
}
|
|
51
|
+
static manyRandom(n, { types, excludes, allDifferent = false, } = {}) {
|
|
52
|
+
const res = [];
|
|
53
|
+
res.push(NombreConstructor.random({ types, excludes }));
|
|
54
|
+
for (let i = 0; i < n - 1; i++) {
|
|
55
|
+
let b;
|
|
56
|
+
do {
|
|
57
|
+
b = NombreConstructor.random({ types, excludes });
|
|
58
|
+
} while (allDifferent && res.some((el) => el.equals(b)));
|
|
59
|
+
res.push(b);
|
|
60
|
+
}
|
|
61
|
+
return res;
|
|
62
|
+
}
|
|
51
63
|
}
|
|
52
64
|
exports.NombreConstructor = NombreConstructor;
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import { AlgebraicNode } from "../../tree/nodes/algebraicNode";
|
|
2
|
+
import { NodeIdentifiers } from "../../tree/nodes/nodeConstructor";
|
|
3
|
+
export declare abstract class GeneralAffineConstructor {
|
|
4
|
+
static fromIdentifiers(identifiers: GeneralAffineIdentifiers): GeneralAffine;
|
|
5
|
+
}
|
|
6
|
+
export type GeneralAffineIdentifiers = {
|
|
7
|
+
id: "affine";
|
|
8
|
+
a: NodeIdentifiers;
|
|
9
|
+
b: NodeIdentifiers;
|
|
10
|
+
variable?: string;
|
|
11
|
+
};
|
|
2
12
|
export declare class GeneralAffine {
|
|
3
13
|
a: AlgebraicNode;
|
|
4
14
|
b: AlgebraicNode;
|
|
5
15
|
variable: string;
|
|
6
16
|
constructor(a: number | AlgebraicNode, b: number | AlgebraicNode, variable?: string);
|
|
17
|
+
toIdentifiers(): GeneralAffineIdentifiers;
|
|
7
18
|
getRoot(): AlgebraicNode;
|
|
8
19
|
toTree(): import("../../tree/nodes/operators/addNode").AddNode | import("../../tree/nodes/operators/multiplyNode").MultiplyNode;
|
|
20
|
+
xIntersect(aff: GeneralAffine): AlgebraicNode | undefined;
|
|
21
|
+
opposite(): GeneralAffine;
|
|
9
22
|
}
|
|
10
23
|
//# sourceMappingURL=generalAffine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generalAffine.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/generalAffine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"generalAffine.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/generalAffine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAG/D,OAAO,EAEL,eAAe,EAEhB,MAAM,kCAAkC,CAAC;AAQ1C,8BAAsB,wBAAwB;IAC5C,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,wBAAwB;CAM7D;AACD,MAAM,MAAM,wBAAwB,GAAG;IACrC,EAAE,EAAE,QAAQ,CAAC;IACb,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AACF,qBAAa,aAAa;IACxB,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;gBAGf,CAAC,EAAE,MAAM,GAAG,aAAa,EACzB,CAAC,EAAE,MAAM,GAAG,aAAa,EACzB,QAAQ,GAAE,MAAY;IAUxB,aAAa,IAAI,wBAAwB;IAQzC,OAAO,IAAI,aAAa;IAIxB,MAAM;IAMN,UAAU,CAAC,GAAG,EAAE,aAAa;IAI7B,QAAQ;CAGT"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GeneralAffine = void 0;
|
|
3
|
+
exports.GeneralAffine = exports.GeneralAffineConstructor = void 0;
|
|
4
4
|
const oppositeNode_1 = require("../../tree/nodes/functions/oppositeNode");
|
|
5
|
+
const nodeConstructor_1 = require("../../tree/nodes/nodeConstructor");
|
|
5
6
|
const addNode_1 = require("../../tree/nodes/operators/addNode");
|
|
6
7
|
const fractionNode_1 = require("../../tree/nodes/operators/fractionNode");
|
|
7
8
|
const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
|
|
9
|
+
const substractNode_1 = require("../../tree/nodes/operators/substractNode");
|
|
10
|
+
class GeneralAffineConstructor {
|
|
11
|
+
static fromIdentifiers(identifiers) {
|
|
12
|
+
return new GeneralAffine((0, nodeConstructor_1.reifyAlgebraic)(identifiers.a), (0, nodeConstructor_1.reifyAlgebraic)(identifiers.b));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.GeneralAffineConstructor = GeneralAffineConstructor;
|
|
8
16
|
class GeneralAffine {
|
|
9
17
|
constructor(a, b, variable = "x") {
|
|
10
18
|
if (typeof a === "number")
|
|
@@ -19,6 +27,14 @@ class GeneralAffine {
|
|
|
19
27
|
this.b = b;
|
|
20
28
|
this.variable = variable;
|
|
21
29
|
}
|
|
30
|
+
toIdentifiers() {
|
|
31
|
+
return {
|
|
32
|
+
id: "affine",
|
|
33
|
+
a: this.a.toIdentifiers(),
|
|
34
|
+
b: this.b.toIdentifiers(),
|
|
35
|
+
variable: this.variable !== "x" ? this.variable : undefined,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
22
38
|
getRoot() {
|
|
23
39
|
return (0, fractionNode_1.frac)((0, oppositeNode_1.opposite)(this.b), this.a).simplify();
|
|
24
40
|
}
|
|
@@ -28,5 +44,13 @@ class GeneralAffine {
|
|
|
28
44
|
return monom;
|
|
29
45
|
return (0, addNode_1.add)(monom, this.b);
|
|
30
46
|
}
|
|
47
|
+
xIntersect(aff) {
|
|
48
|
+
if (aff.a.evaluate() === this.a.evaluate())
|
|
49
|
+
return undefined;
|
|
50
|
+
return (0, fractionNode_1.frac)((0, substractNode_1.substract)(aff.b, this.b), (0, substractNode_1.substract)(this.a, aff.a)).simplify();
|
|
51
|
+
}
|
|
52
|
+
opposite() {
|
|
53
|
+
return new GeneralAffine((0, oppositeNode_1.opposite)(this.a), (0, oppositeNode_1.opposite)(this.b));
|
|
54
|
+
}
|
|
31
55
|
}
|
|
32
56
|
exports.GeneralAffine = GeneralAffine;
|
package/lib/playground.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AA8CA,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AA8CA,eAAO,MAAM,UAAU,YAMtB,CAAC"}
|
package/lib/playground.js
CHANGED
|
@@ -2,7 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.playground = void 0;
|
|
4
4
|
const nodeConstructor_1 = require("./tree/nodes/nodeConstructor");
|
|
5
|
-
const
|
|
5
|
+
const fractionNode_1 = require("./tree/nodes/operators/fractionNode");
|
|
6
|
+
const oppositeNode_1 = require("./tree/nodes/functions/oppositeNode");
|
|
7
|
+
const playground = () => {
|
|
8
|
+
const fraction = (0, fractionNode_1.frac)((0, oppositeNode_1.opposite)(-6), (0, oppositeNode_1.opposite)(4)).toSimplificationString();
|
|
9
|
+
console.log(fraction);
|
|
10
|
+
console.log((0, fractionNode_1.frac)((0, oppositeNode_1.opposite)(-6), 4).toTex());
|
|
11
|
+
console.log((0, oppositeNode_1.opposite)(-6).toTex());
|
|
12
|
+
};
|
|
6
13
|
exports.playground = playground;
|
|
7
14
|
const logIdentifiers = () => {
|
|
8
15
|
const ids = '{"xA":-3,"yA":-2,"yPrimeA":{"id":31,"child":{"id":3,"leftChild":{"id":7,"value":3},"rightChild":{"id":7,"value":2}}},"trinomCoeffs":[0.3888888888888889,0.833333333333333,-3]}';
|
|
@@ -2,6 +2,7 @@ import { Node, NodeIds, NodeType } from "../node";
|
|
|
2
2
|
import { FunctionNode, FunctionsIds } from "./functionNode";
|
|
3
3
|
import { AlgebraicNode } from "../algebraicNode";
|
|
4
4
|
export declare function isAbsNode(a: Node): a is AbsNode;
|
|
5
|
+
export declare const abs: (a: AlgebraicNode | number | string) => AbsNode;
|
|
5
6
|
export declare class AbsNode implements FunctionNode {
|
|
6
7
|
id: FunctionsIds;
|
|
7
8
|
child: AlgebraicNode;
|
|
@@ -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;AAKjD,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;IAKxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS;CAIxC"}
|
|
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;AAKjD,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,OAAO,CAE/C;AACD,eAAO,MAAM,GAAG,MAAO,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;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;IAKxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS;CAIxC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AbsNode = exports.isAbsNode = void 0;
|
|
3
|
+
exports.AbsNode = exports.abs = exports.isAbsNode = void 0;
|
|
4
4
|
// import { abs } from "mathjs";
|
|
5
5
|
const node_1 = require("../node");
|
|
6
6
|
const functionNode_1 = require("./functionNode");
|
|
@@ -12,6 +12,11 @@ function isAbsNode(a) {
|
|
|
12
12
|
return (0, functionNode_1.isFunctionNode)(a) && a.id === functionNode_1.FunctionsIds.abs;
|
|
13
13
|
}
|
|
14
14
|
exports.isAbsNode = isAbsNode;
|
|
15
|
+
const abs = (a) => {
|
|
16
|
+
const nodeA = typeof a === "number" ? a.toTree() : typeof a === "string" ? a.toTree() : a;
|
|
17
|
+
return new AbsNode(nodeA);
|
|
18
|
+
};
|
|
19
|
+
exports.abs = abs;
|
|
15
20
|
class AbsNode {
|
|
16
21
|
constructor(child) {
|
|
17
22
|
this.id = functionNode_1.FunctionsIds.abs;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { AlgebraicNode } from "./algebraicNode";
|
|
1
2
|
import { Node, NodeIds } from "./node";
|
|
3
|
+
export declare const reifyAlgebraic: (identifiers: NodeIdentifiers) => AlgebraicNode;
|
|
4
|
+
export declare const reifyNode: (identifiers: NodeIdentifiers) => Node;
|
|
2
5
|
export type NodeIdentifiers = {
|
|
3
6
|
id: NodeIds;
|
|
4
7
|
} & Record<string, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeConstructor.d.ts","sourceRoot":"","sources":["../../../src/tree/nodes/nodeConstructor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nodeConstructor.d.ts","sourceRoot":"","sources":["../../../src/tree/nodes/nodeConstructor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAwBhD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAmBvC,eAAO,MAAM,cAAc,gBAAiB,eAAe,kBACI,CAAC;AAChE,eAAO,MAAM,SAAS,gBAAiB,eAAe,SACR,CAAC;AAC/C,MAAM,MAAM,eAAe,GAAG;IAAE,EAAE,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACpE,8BAAsB,eAAe;IACnC,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,eAAe,GAAG,IAAI;CAsR3D"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NodeConstructor = void 0;
|
|
3
|
+
exports.NodeConstructor = exports.reifyNode = exports.reifyAlgebraic = void 0;
|
|
4
4
|
const point_1 = require("../../math/geometry/point");
|
|
5
5
|
const complexNode_1 = require("./complex/complexNode");
|
|
6
6
|
const equalNode_1 = require("./equations/equalNode");
|
|
@@ -42,6 +42,10 @@ const discreteSetNode_1 = require("./sets/discreteSetNode");
|
|
|
42
42
|
const intervalNode_1 = require("./sets/intervalNode");
|
|
43
43
|
const unionIntervalNode_1 = require("./sets/unionIntervalNode");
|
|
44
44
|
const variableNode_1 = require("./variables/variableNode");
|
|
45
|
+
const reifyAlgebraic = (identifiers) => NodeConstructor.fromIdentifiers(identifiers);
|
|
46
|
+
exports.reifyAlgebraic = reifyAlgebraic;
|
|
47
|
+
const reifyNode = (identifiers) => NodeConstructor.fromIdentifiers(identifiers);
|
|
48
|
+
exports.reifyNode = reifyNode;
|
|
45
49
|
class NodeConstructor {
|
|
46
50
|
static fromIdentifiers(identifiers) {
|
|
47
51
|
switch (identifiers.id) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fractionNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/fractionNode.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;AAK3E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKlE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AAED,eAAO,MAAM,IAAI,MACZ,aAAa,GAAG,MAAM,GAAG,MAAM,KAC/B,aAAa,GAAG,MAAM,GAAG,MAAM,SAC3B,WAAW,iBAOnB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,EAAE,EAAE,OAAO,CAAC,QAAQ,CAAC;IACrB,SAAS,EAAE,eAAe,CAAC;IAC3B,UAAU,EAAE,eAAe,CAAC;CAC7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CAC7B,CAAC;AACF,qBAAa,YAAa,YAAW,YAAY;IAC/C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;;OAGG;IACH,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IAiBpB,YAAY,IAAI,MAAM;IAItB,aAAa,IAAI,uBAAuB;IAQxC,UAAU;IAGV,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IA+BpC,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAG5C,SAAS;IAUT,KAAK,IAAI,MAAM;IA2Bf,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMtC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAyJ/C,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAOpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAOxD,sBAAsB;IAQtB,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;CAGxD"}
|
|
@@ -93,8 +93,13 @@ class FractionNode {
|
|
|
93
93
|
return denum === 1;
|
|
94
94
|
}
|
|
95
95
|
toTex() {
|
|
96
|
+
//! this stinks
|
|
97
|
+
//! to tex shouldn't be doing all of this
|
|
98
|
+
//! we need a "canonicalToTex" or a "purifyTex" in order to print correct latex without simplifying mathematically
|
|
96
99
|
if (!this.opts?.allowMinusAnywhereInFraction &&
|
|
97
|
-
((0, oppositeNode_1.isOppositeNode)(this.leftChild)
|
|
100
|
+
(((0, oppositeNode_1.isOppositeNode)(this.leftChild) &&
|
|
101
|
+
(0, numberNode_1.isNumberNode)(this.leftChild.child) &&
|
|
102
|
+
this.leftChild.child.value > 0) ||
|
|
98
103
|
((0, numberNode_1.isNumberNode)(this.leftChild) && this.leftChild.value < 0))) {
|
|
99
104
|
return `-\\frac{${this.leftChild
|
|
100
105
|
.toTex()
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { FractionNode } from "../nodes/operators/fractionNode";
|
|
2
|
-
export declare const rationalParser: (ans: string) => false | import("../nodes/numbers/numberNode").NumberNode | import("../nodes/numbers/constantNode").ConstantNode | import("../nodes/functions/oppositeNode").OppositeNode | FractionNode
|
|
2
|
+
export declare const rationalParser: (ans: string) => false | import("../nodes/numbers/numberNode").NumberNode | import("../nodes/numbers/constantNode").ConstantNode | import("../nodes/functions/oppositeNode").OppositeNode | FractionNode;
|
|
3
3
|
//# sourceMappingURL=rationalParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rationalParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/rationalParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAQ,MAAM,iCAAiC,CAAC;AAGrE,eAAO,MAAM,cAAc,QAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"rationalParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/rationalParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAQ,MAAM,iCAAiC,CAAC;AAGrE,eAAO,MAAM,cAAc,QAAS,MAAM,4LA2BzC,CAAC"}
|