math-exercises 2.0.9 → 2.0.11
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/calcul/fractions/index.d.ts +1 -0
- package/lib/exercises/calcul/fractions/index.d.ts.map +1 -1
- package/lib/exercises/calcul/fractions/index.js +1 -0
- package/lib/exercises/calcul/fractions/periodicWritingToFraction.d.ts +9 -0
- package/lib/exercises/calcul/fractions/periodicWritingToFraction.d.ts.map +1 -0
- package/lib/exercises/calcul/fractions/periodicWritingToFraction.js +80 -0
- package/lib/exercises/calculLitteral/factorisation/factoIdRmq3.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/factorisation/factoIdRmq3.js +2 -1
- package/lib/exercises/exercise.d.ts +1 -1
- package/lib/exercises/exercise.d.ts.map +1 -1
- package/lib/exercises/functions/affines/leadingCoefficient.d.ts.map +1 -1
- package/lib/exercises/functions/affines/leadingCoefficient.js +5 -1
- package/lib/exercises/functions/logarithm/index.d.ts +1 -0
- package/lib/exercises/functions/logarithm/index.d.ts.map +1 -1
- package/lib/exercises/functions/logarithm/index.js +1 -0
- package/lib/exercises/functions/logarithm/log10Simplifying.d.ts +11 -0
- package/lib/exercises/functions/logarithm/log10Simplifying.d.ts.map +1 -0
- package/lib/exercises/functions/logarithm/log10Simplifying.js +97 -0
- package/lib/exercises/functions/logarithm/logEquation.d.ts.map +1 -1
- package/lib/exercises/functions/logarithm/logEquation.js +0 -1
- package/lib/exercises/geometry/vectors/index.d.ts +1 -0
- package/lib/exercises/geometry/vectors/index.d.ts.map +1 -1
- package/lib/exercises/geometry/vectors/index.js +1 -0
- package/lib/exercises/geometry/vectors/scalarProductViaCoords.js +1 -1
- package/lib/exercises/geometry/vectors/scalarProductViaCos.d.ts +9 -0
- package/lib/exercises/geometry/vectors/scalarProductViaCos.d.ts.map +1 -0
- package/lib/exercises/geometry/vectors/scalarProductViaCos.js +66 -0
- package/lib/exercises/limits/index.d.ts +1 -0
- package/lib/exercises/limits/index.d.ts.map +1 -1
- package/lib/exercises/limits/index.js +1 -0
- package/lib/exercises/limits/limitReading.d.ts +10 -0
- package/lib/exercises/limits/limitReading.d.ts.map +1 -0
- package/lib/exercises/limits/limitReading.js +111 -0
- package/lib/exercises/squareRoots/index.d.ts +3 -0
- package/lib/exercises/squareRoots/index.d.ts.map +1 -1
- package/lib/exercises/squareRoots/index.js +3 -0
- package/lib/exercises/squareRoots/squareRootIdentities.d.ts +11 -0
- package/lib/exercises/squareRoots/squareRootIdentities.d.ts.map +1 -0
- package/lib/exercises/squareRoots/squareRootIdentities.js +124 -0
- package/lib/exercises/squareRoots/squareRootsDistributivity.d.ts +10 -0
- package/lib/exercises/squareRoots/squareRootsDistributivity.d.ts.map +1 -0
- package/lib/exercises/squareRoots/squareRootsDistributivity.js +67 -0
- package/lib/exercises/squareRoots/squareRootsSum.d.ts +13 -0
- package/lib/exercises/squareRoots/squareRootsSum.d.ts.map +1 -0
- package/lib/exercises/squareRoots/squareRootsSum.js +79 -0
- package/lib/index.d.ts +37 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/math/numbers/decimals/decimal.d.ts +3 -0
- package/lib/math/numbers/decimals/decimal.d.ts.map +1 -1
- package/lib/math/numbers/decimals/decimal.js +8 -0
- package/lib/math/numbers/integer/integer.d.ts +1 -1
- package/lib/math/numbers/nombre.d.ts +1 -1
- package/lib/math/polynomials/rationalFrac.d.ts +1 -1
- package/lib/server.js +11 -0
- package/lib/tree/nodes/algebraicNode.d.ts +4 -1
- package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/oppositeNode.d.ts +2 -2
- package/lib/tree/nodes/functions/oppositeNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/oppositeNode.js +2 -2
- package/lib/tree/nodes/functions/sqrtNode.d.ts +2 -2
- package/lib/tree/nodes/functions/sqrtNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/sqrtNode.js +3 -3
- package/lib/tree/nodes/node.d.ts +4 -1
- package/lib/tree/nodes/node.d.ts.map +1 -1
- package/lib/tree/nodes/numbers/numberNode.d.ts +3 -0
- package/lib/tree/nodes/numbers/numberNode.d.ts.map +1 -1
- package/lib/tree/nodes/numbers/numberNode.js +8 -1
- package/lib/tree/nodes/operators/addNode.d.ts +2 -2
- package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.js +7 -5
- package/lib/tree/nodes/operators/fractionNode.d.ts +2 -2
- package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/fractionNode.js +4 -6
- package/lib/tree/nodes/operators/limitNode.d.ts +29 -0
- package/lib/tree/nodes/operators/limitNode.d.ts.map +1 -0
- package/lib/tree/nodes/operators/limitNode.js +56 -0
- package/lib/tree/nodes/operators/multiplyNode.d.ts +2 -2
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +5 -6
- 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 -2
- package/lib/tree/nodes/operators/powerNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/powerNode.js +51 -2
- package/lib/tree/nodes/operators/substractNode.d.ts +2 -2
- package/lib/tree/nodes/operators/substractNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/substractNode.js +2 -2
- package/lib/utils/randomLetter.d.ts +1 -1
- package/lib/utils/randomLetter.d.ts.map +1 -1
- package/lib/utils/randomLetter.js +6 -4
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numberNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/numbers/numberNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"numberNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/numbers/numberNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,wBAAgB,YAAY,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,UAAU,CAErD;AAED,8BAAsB,qBAAqB;IACzC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAM,EAAO;CAGhE;AACD,qBAAa,UAAW,YAAW,aAAa;IAC9C,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,CAAmB;IACjC,SAAS,EAAE,OAAO,CAAC;gBACP,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;IAO5D,YAAY,IAAI,MAAM;IAGtB,KAAK,IAAI,MAAM;IAGf,QAAQ;IAGR,cAAc;IAOd,iBAAiB;IAGjB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAGrC,QAAQ;IAGR,MAAM,CAAC,IAAI,EAAE,aAAa;CAG3B"}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NumberNode = exports.isNumberNode = void 0;
|
|
3
|
+
exports.NumberNode = exports.NumberNodeConstructor = exports.isNumberNode = void 0;
|
|
4
4
|
const node_1 = require("../node");
|
|
5
|
+
const randint_1 = require("../../../math/utils/random/randint");
|
|
5
6
|
function isNumberNode(a) {
|
|
6
7
|
return a.type === node_1.NodeType.number;
|
|
7
8
|
}
|
|
8
9
|
exports.isNumberNode = isNumberNode;
|
|
10
|
+
class NumberNodeConstructor {
|
|
11
|
+
static random(min, max, excludes = []) {
|
|
12
|
+
return new NumberNode((0, randint_1.randint)(min, max, excludes));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.NumberNodeConstructor = NumberNodeConstructor;
|
|
9
16
|
class NumberNode {
|
|
10
17
|
constructor(value, tex, mathString) {
|
|
11
18
|
this.type = node_1.NodeType.number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Node, NodeOptions, NodeType } from "../node";
|
|
2
2
|
import { CommutativeOperatorNode, OperatorIds } from "./operatorNode";
|
|
3
|
-
import { AlgebraicNode } from "../algebraicNode";
|
|
3
|
+
import { AlgebraicNode, SimplifyOptions } from "../algebraicNode";
|
|
4
4
|
export declare function isAddNode(a: Node): a is AddNode;
|
|
5
5
|
export declare class AddNode implements CommutativeOperatorNode {
|
|
6
6
|
id: OperatorIds;
|
|
@@ -17,7 +17,7 @@ export declare class AddNode implements CommutativeOperatorNode {
|
|
|
17
17
|
toAllValidTexs(opts?: NodeOptions): string[];
|
|
18
18
|
toTex(): string;
|
|
19
19
|
evaluate(vars: Record<string, number>): number;
|
|
20
|
-
simplify(): AlgebraicNode;
|
|
20
|
+
simplify(opts?: SimplifyOptions): AlgebraicNode;
|
|
21
21
|
equals(node: AlgebraicNode): boolean;
|
|
22
22
|
}
|
|
23
23
|
//# sourceMappingURL=addNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/addNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EACL,uBAAuB,EACvB,WAAW,EAGZ,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"addNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/addNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EACL,uBAAuB,EACvB,WAAW,EAGZ,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAOlE,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,OAAO,CAE/C;AAMD,qBAAa,OAAQ,YAAW,uBAAuB;IACrD,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IASpB,OAAO,aAGL;IAEF,YAAY,IAAI,MAAM;IAItB,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,aAAa,EAAE;IAoCtD,SAAS,IAAI,MAAM,EAAE;IAIrB,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAK5C,KAAK,IAAI,MAAM;IAIf,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMrC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IA2K/C,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;CAUrC"}
|
|
@@ -87,7 +87,7 @@ class AddNode {
|
|
|
87
87
|
// toMathjs() {
|
|
88
88
|
// return add(this.leftChild.toMathjs(), this.rightChild.toMathjs());
|
|
89
89
|
// }
|
|
90
|
-
simplify() {
|
|
90
|
+
simplify(opts) {
|
|
91
91
|
const leftSimplified = this.leftChild.simplify();
|
|
92
92
|
const rightSimplified = this.rightChild.simplify();
|
|
93
93
|
const copy = new AddNode(leftSimplified, rightSimplified, this.opts);
|
|
@@ -150,6 +150,8 @@ class AddNode {
|
|
|
150
150
|
return new numberNode_1.NumberNode(a.child.value + b.child.value);
|
|
151
151
|
}
|
|
152
152
|
//gérer opposites, fractions
|
|
153
|
+
if (opts?.forbidFactorize)
|
|
154
|
+
return null;
|
|
153
155
|
const aSubExternals = [];
|
|
154
156
|
const bSubExternals = [];
|
|
155
157
|
const getAMultiplyExternals = (a) => {
|
|
@@ -196,9 +198,9 @@ class AddNode {
|
|
|
196
198
|
}
|
|
197
199
|
}
|
|
198
200
|
}
|
|
199
|
-
//si aucun facteur on return
|
|
201
|
+
//si aucun facteur on return
|
|
200
202
|
if (!factors.length)
|
|
201
|
-
return
|
|
203
|
+
return null;
|
|
202
204
|
const factorsNode = factors.length === 1
|
|
203
205
|
? factors[0]
|
|
204
206
|
: (0, operatorComposition_1.operatorComposition)(multiplyNode_1.MultiplyNode, factors);
|
|
@@ -207,12 +209,12 @@ class AddNode {
|
|
|
207
209
|
? new numberNode_1.NumberNode(1)
|
|
208
210
|
: aSubExternals.length === 1
|
|
209
211
|
? aSubExternals[0]
|
|
210
|
-
: (0, operatorComposition_1.operatorComposition)(
|
|
212
|
+
: (0, operatorComposition_1.operatorComposition)(multiplyNode_1.MultiplyNode, aSubExternals);
|
|
211
213
|
const bNode = bSubExternals.length === 0
|
|
212
214
|
? new numberNode_1.NumberNode(1)
|
|
213
215
|
: bSubExternals.length === 1
|
|
214
216
|
? bSubExternals[0]
|
|
215
|
-
: (0, operatorComposition_1.operatorComposition)(
|
|
217
|
+
: (0, operatorComposition_1.operatorComposition)(multiplyNode_1.MultiplyNode, bSubExternals);
|
|
216
218
|
const addNode = new AddNode(aNode, bNode);
|
|
217
219
|
return new multiplyNode_1.MultiplyNode(addNode, factorsNode).simplify();
|
|
218
220
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Node, NodeOptions, NodeType } from "../node";
|
|
2
2
|
import { OperatorIds, OperatorNode } from "./operatorNode";
|
|
3
|
-
import { AlgebraicNode } from "../algebraicNode";
|
|
3
|
+
import { AlgebraicNode, SimplifyOptions } from "../algebraicNode";
|
|
4
4
|
export declare function isFractionNode(a: Node): a is FractionNode;
|
|
5
5
|
export declare class FractionNode implements OperatorNode {
|
|
6
6
|
opts?: NodeOptions;
|
|
@@ -20,7 +20,7 @@ export declare class FractionNode implements OperatorNode {
|
|
|
20
20
|
toAllValidTexs(opts?: NodeOptions): string[];
|
|
21
21
|
toTex(): string;
|
|
22
22
|
evaluate(vars: Record<string, number>): number;
|
|
23
|
-
simplify(): AlgebraicNode;
|
|
23
|
+
simplify(opts?: SimplifyOptions): AlgebraicNode;
|
|
24
24
|
equals(node: AlgebraicNode): boolean;
|
|
25
25
|
}
|
|
26
26
|
//# sourceMappingURL=fractionNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fractionNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/fractionNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAK3E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"fractionNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/fractionNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAK3E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAIlE,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AACD,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;IAUpB,YAAY,IAAI,MAAM;IAItB,UAAU;IAGV,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IA2BpC,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAI5C,KAAK,IAAI,MAAM;IAaf,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMrC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IA2E/C,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;CAOrC"}
|
|
@@ -73,9 +73,9 @@ class FractionNode {
|
|
|
73
73
|
// toMathjs() {
|
|
74
74
|
// return fraction(this.leftChild.toMathjs(), this.rightChild.toMathjs());
|
|
75
75
|
// }
|
|
76
|
-
simplify() {
|
|
77
|
-
const simplifiedNum = this.leftChild.simplify();
|
|
78
|
-
const simplifiedDenum = this.rightChild.simplify();
|
|
76
|
+
simplify(opts) {
|
|
77
|
+
const simplifiedNum = this.leftChild.simplify(opts);
|
|
78
|
+
const simplifiedDenum = this.rightChild.simplify(opts);
|
|
79
79
|
const copy = new FractionNode(simplifiedNum, simplifiedDenum, this.opts);
|
|
80
80
|
const externalsNums = [];
|
|
81
81
|
const externalsDenums = [];
|
|
@@ -102,7 +102,6 @@ class FractionNode {
|
|
|
102
102
|
const simplifyExternalNodes = (num, denum) => {
|
|
103
103
|
if ((0, numberNode_1.isNumberNode)(num) && (0, numberNode_1.isNumberNode)(denum)) {
|
|
104
104
|
const frac = new rational_1.Rational(num.value, denum.value);
|
|
105
|
-
console.log(frac.isIrreductible());
|
|
106
105
|
if (frac.isIrreductible())
|
|
107
106
|
return null;
|
|
108
107
|
return frac.simplify().toTree();
|
|
@@ -113,7 +112,6 @@ class FractionNode {
|
|
|
113
112
|
return new numberNode_1.NumberNode(1);
|
|
114
113
|
return null;
|
|
115
114
|
};
|
|
116
|
-
console.log(externalsNums, externalsDenums);
|
|
117
115
|
const simplifyIteration = () => {
|
|
118
116
|
for (let i = 0; i < externalsNums.length; i++) {
|
|
119
117
|
const num = externalsNums[i];
|
|
@@ -138,7 +136,7 @@ class FractionNode {
|
|
|
138
136
|
simplifyIteration();
|
|
139
137
|
const nums = externalsNums.length === 1
|
|
140
138
|
? externalsNums[0]
|
|
141
|
-
: (0, operatorComposition_1.operatorComposition)(multiplyNode_1.MultiplyNode, externalsNums).simplify();
|
|
139
|
+
: (0, operatorComposition_1.operatorComposition)(multiplyNode_1.MultiplyNode, externalsNums).simplify(opts);
|
|
142
140
|
if (externalsDenums.length === 0) {
|
|
143
141
|
return nums;
|
|
144
142
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Node, NodeOptions, NodeType, ToTexOptions } from "../node";
|
|
2
|
+
import { OperatorIds, OperatorNode } from "./operatorNode";
|
|
3
|
+
import { AlgebraicNode, SimplifyOptions } from "../algebraicNode";
|
|
4
|
+
export declare function isLimitNode(a: Node): a is LimitNode;
|
|
5
|
+
export declare class LimitNode implements OperatorNode {
|
|
6
|
+
opts?: NodeOptions;
|
|
7
|
+
id: OperatorIds;
|
|
8
|
+
leftChild: AlgebraicNode;
|
|
9
|
+
rightChild: AlgebraicNode;
|
|
10
|
+
type: NodeType;
|
|
11
|
+
isNumeric: boolean;
|
|
12
|
+
from: "+" | "-" | undefined;
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param leftChild x to ..
|
|
16
|
+
* @param rightChild f(x)
|
|
17
|
+
* @param from + ou - pour les VI
|
|
18
|
+
* @param opts
|
|
19
|
+
*/
|
|
20
|
+
constructor(leftChild: AlgebraicNode, rightChild: AlgebraicNode, from?: "+" | "-", opts?: NodeOptions);
|
|
21
|
+
toMathString(): string;
|
|
22
|
+
toEquivalentNodes(opts?: NodeOptions | undefined): this[];
|
|
23
|
+
toAllValidTexs(): string[];
|
|
24
|
+
toTex(opts?: ToTexOptions): string;
|
|
25
|
+
evaluate(vars: Record<string, number>): number;
|
|
26
|
+
simplify(opts?: SimplifyOptions): AlgebraicNode;
|
|
27
|
+
equals(node: AlgebraicNode): boolean;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=limitNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limitNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/limitNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAG3E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAElE,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,SAAS,CAEnD;AAED,qBAAa,SAAU,YAAW,YAAY;IAC5C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,GAAG,GAAG,GAAG,GAAG,SAAS,CAAC;IAE5B;;;;;;OAMG;gBAED,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,EAChB,IAAI,CAAC,EAAE,WAAW;IAWpB,YAAY,IAAI,MAAM;IAItB,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,SAAS;IAIhD,cAAc,IAAI,MAAM,EAAE;IAI1B,KAAK,CAAC,IAAI,CAAC,EAAE,YAAY,GAAG,MAAM;IAWlC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM;IAI9C,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAG/C,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;CAOrC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LimitNode = exports.isLimitNode = void 0;
|
|
4
|
+
// import { pow } from "mathjs";
|
|
5
|
+
const node_1 = require("../node");
|
|
6
|
+
const operatorNode_1 = require("./operatorNode");
|
|
7
|
+
function isLimitNode(a) {
|
|
8
|
+
return (0, operatorNode_1.isOperatorNode)(a) && a.id === operatorNode_1.OperatorIds.limit;
|
|
9
|
+
}
|
|
10
|
+
exports.isLimitNode = isLimitNode;
|
|
11
|
+
class LimitNode {
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param leftChild x to ..
|
|
15
|
+
* @param rightChild f(x)
|
|
16
|
+
* @param from + ou - pour les VI
|
|
17
|
+
* @param opts
|
|
18
|
+
*/
|
|
19
|
+
constructor(leftChild, rightChild, from, opts) {
|
|
20
|
+
this.id = operatorNode_1.OperatorIds.limit;
|
|
21
|
+
this.leftChild = leftChild;
|
|
22
|
+
this.rightChild = rightChild;
|
|
23
|
+
this.type = node_1.NodeType.operator;
|
|
24
|
+
this.opts = opts;
|
|
25
|
+
this.isNumeric = leftChild.isNumeric && rightChild.isNumeric;
|
|
26
|
+
this.from = from;
|
|
27
|
+
}
|
|
28
|
+
toMathString() {
|
|
29
|
+
return `limit_(${this.leftChild.toMathString()})(${this.rightChild.toMathString()})`;
|
|
30
|
+
}
|
|
31
|
+
toEquivalentNodes(opts) {
|
|
32
|
+
return [this];
|
|
33
|
+
}
|
|
34
|
+
toAllValidTexs() {
|
|
35
|
+
return this.toEquivalentNodes().map((node) => node.toTex());
|
|
36
|
+
}
|
|
37
|
+
toTex(opts) {
|
|
38
|
+
const displayStyle = opts?.displayStyle ?? true;
|
|
39
|
+
let rightTex = this.rightChild.toTex();
|
|
40
|
+
let leftTex = this.leftChild.toTex();
|
|
41
|
+
let fromDisplay = this.from === "+" ? "^+" : this.from === "-" ? "^-" : "";
|
|
42
|
+
return `${displayStyle ? "\\displaystyle" : ""}\\lim_{x \\to ${leftTex}${fromDisplay}} ${rightTex}`;
|
|
43
|
+
}
|
|
44
|
+
evaluate(vars) {
|
|
45
|
+
throw Error("unimplemented limit evaluation");
|
|
46
|
+
}
|
|
47
|
+
simplify(opts) {
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
equals(node) {
|
|
51
|
+
return (isLimitNode(node) &&
|
|
52
|
+
node.leftChild.equals(this.leftChild) &&
|
|
53
|
+
node.rightChild.equals(this.rightChild));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.LimitNode = LimitNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Node, NodeOptions, NodeType } from "../node";
|
|
2
2
|
import { CommutativeOperatorNode, OperatorIds } from "./operatorNode";
|
|
3
|
-
import { AlgebraicNode } from "../algebraicNode";
|
|
3
|
+
import { AlgebraicNode, SimplifyOptions } from "../algebraicNode";
|
|
4
4
|
export declare function isMultiplyNode(a: Node): a is MultiplyNode;
|
|
5
5
|
export declare const sortMultiplyNodes: (arr: AlgebraicNode[]) => void;
|
|
6
6
|
export declare class MultiplyNode implements CommutativeOperatorNode {
|
|
@@ -19,7 +19,7 @@ export declare class MultiplyNode implements CommutativeOperatorNode {
|
|
|
19
19
|
toAllValidTexs(opts?: NodeOptions): string[];
|
|
20
20
|
evaluate(vars: Record<string, number>): number;
|
|
21
21
|
copy(): MultiplyNode;
|
|
22
|
-
simplify(): AlgebraicNode;
|
|
22
|
+
simplify(opts?: SimplifyOptions): AlgebraicNode;
|
|
23
23
|
equals(node: AlgebraicNode): boolean;
|
|
24
24
|
}
|
|
25
25
|
//# sourceMappingURL=multiplyNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiplyNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/multiplyNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EACL,uBAAuB,EACvB,WAAW,EAEZ,MAAM,gBAAgB,CAAC;AAYxB,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"multiplyNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/multiplyNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EACL,uBAAuB,EACvB,WAAW,EAEZ,MAAM,gBAAgB,CAAC;AAYxB,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKlE,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AAED,eAAO,MAAM,iBAAiB,QAAS,aAAa,EAAE,SAWrD,CAAC;AACF,qBAAa,YAAa,YAAW,uBAAuB;IAC1D,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,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;IAUpB,OAAO,aAGL;IAEF,YAAY,IAAI,MAAM;IAItB,KAAK,IAAI,MAAM;IAkDf,SAAS;IAkDT,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,YAAY,EAAE;IAwFrD,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAQ5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIrC,IAAI;IAGJ,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAoG/C,MAAM,CAAC,IAAI,EAAE,aAAa;CAU3B"}
|
|
@@ -201,9 +201,9 @@ class MultiplyNode {
|
|
|
201
201
|
copy() {
|
|
202
202
|
return new MultiplyNode(this.leftChild, this.rightChild, this.opts);
|
|
203
203
|
}
|
|
204
|
-
simplify() {
|
|
205
|
-
const leftSimplified = this.leftChild.simplify();
|
|
206
|
-
const rightSimplified = this.rightChild.simplify();
|
|
204
|
+
simplify(opts) {
|
|
205
|
+
const leftSimplified = this.leftChild.simplify(opts);
|
|
206
|
+
const rightSimplified = this.rightChild.simplify(opts);
|
|
207
207
|
const copy = new MultiplyNode(leftSimplified, rightSimplified, this.opts);
|
|
208
208
|
/**get externals nodes
|
|
209
209
|
* les opposites sont supprimés et on ajoute *-1 à la fin si leur nb est impair
|
|
@@ -259,16 +259,15 @@ class MultiplyNode {
|
|
|
259
259
|
const denumNode = denums.length === 1
|
|
260
260
|
? denums[0]
|
|
261
261
|
: (0, operatorComposition_1.operatorComposition)(MultiplyNode, denums);
|
|
262
|
-
return new fractionNode_1.FractionNode(numNode, denumNode).simplify();
|
|
262
|
+
return new fractionNode_1.FractionNode(numNode, denumNode).simplify(opts);
|
|
263
263
|
}
|
|
264
264
|
(0, exports.sortMultiplyNodes)(externals);
|
|
265
|
-
console.log(externals.map((n) => n.toTex()));
|
|
266
265
|
const simplifyExternalNodes = (a, b) => {
|
|
267
266
|
if ((0, numberNode_1.isNumberNode)(a) && (0, numberNode_1.isNumberNode)(b)) {
|
|
268
267
|
return new numberNode_1.NumberNode(a.value * b.value);
|
|
269
268
|
}
|
|
270
269
|
if ((0, sqrtNode_1.isSqrtNode)(a) && (0, sqrtNode_1.isSqrtNode)(b)) {
|
|
271
|
-
return new sqrtNode_1.SqrtNode(new MultiplyNode(a.child, b.child)).simplify();
|
|
270
|
+
return new sqrtNode_1.SqrtNode(new MultiplyNode(a.child, b.child)).simplify(opts);
|
|
272
271
|
}
|
|
273
272
|
//TODo continue
|
|
274
273
|
return null;
|
|
@@ -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;CACN;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"}
|
|
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;CACN;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"}
|
|
@@ -10,6 +10,7 @@ var OperatorIds;
|
|
|
10
10
|
OperatorIds[OperatorIds["fraction"] = 3] = "fraction";
|
|
11
11
|
OperatorIds[OperatorIds["divide"] = 4] = "divide";
|
|
12
12
|
OperatorIds[OperatorIds["power"] = 5] = "power";
|
|
13
|
+
OperatorIds[OperatorIds["limit"] = 6] = "limit";
|
|
13
14
|
})(OperatorIds || (exports.OperatorIds = OperatorIds = {}));
|
|
14
15
|
function isOperatorNode(a) {
|
|
15
16
|
return a.type === node_1.NodeType.operator;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Node, NodeOptions, NodeType } from "../node";
|
|
2
2
|
import { OperatorIds, OperatorNode } from "./operatorNode";
|
|
3
|
-
import { AlgebraicNode } from "../algebraicNode";
|
|
3
|
+
import { AlgebraicNode, SimplifyOptions } from "../algebraicNode";
|
|
4
4
|
export declare function isPowerNode(a: Node): a is PowerNode;
|
|
5
5
|
export declare class PowerNode implements OperatorNode {
|
|
6
6
|
opts?: NodeOptions;
|
|
@@ -15,7 +15,7 @@ export declare class PowerNode implements OperatorNode {
|
|
|
15
15
|
toAllValidTexs(): string[];
|
|
16
16
|
toTex(): string;
|
|
17
17
|
evaluate(vars: Record<string, number>): number;
|
|
18
|
-
simplify():
|
|
18
|
+
simplify(opts?: SimplifyOptions): AlgebraicNode;
|
|
19
19
|
equals(node: AlgebraicNode): boolean;
|
|
20
20
|
}
|
|
21
21
|
export declare class SquareNode extends PowerNode {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"powerNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/powerNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAG3E,OAAO,EAAE,aAAa,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,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAG3E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAOlE,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,SAAS,CAEnD;AAED,qBAAa,SAAU,YAAW,YAAY;IAC5C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,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;IAUpB,YAAY,IAAI,MAAM;IAItB,iBAAiB;IAqBjB,cAAc,IAAI,MAAM,EAAE;IAI1B,KAAK,IAAI,MAAM;IAuBf,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IA+FrC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAO/C,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;CAOrC;AAED,qBAAa,UAAW,SAAQ,SAAS;gBAC3B,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;CAGrD"}
|
|
@@ -77,6 +77,7 @@ class PowerNode {
|
|
|
77
77
|
// simplify(): AlgebraicNode {
|
|
78
78
|
// const leftSimplified = this.leftChild.simplify();
|
|
79
79
|
// const rightSimplified = this.rightChild.simplify();
|
|
80
|
+
// const copy = new PowerNode(leftSimplified, rightSimplified, this.opts);
|
|
80
81
|
// if (isNumberNode(rightSimplified)) {
|
|
81
82
|
// const value = rightSimplified.value;
|
|
82
83
|
// if (value === 0) return new NumberNode(1);
|
|
@@ -87,6 +88,36 @@ class PowerNode {
|
|
|
87
88
|
// if (value === 0) return leftSimplified;
|
|
88
89
|
// if (value === 1) return leftSimplified;
|
|
89
90
|
// }
|
|
91
|
+
// let externals: AlgebraicNode[] = [];
|
|
92
|
+
// //TODO Fractions
|
|
93
|
+
// const recursive = (node: AlgebraicNode) => {
|
|
94
|
+
// if (isMultiplyNode(node)) {
|
|
95
|
+
// recursive(node.leftChild);
|
|
96
|
+
// recursive(node.rightChild);
|
|
97
|
+
// } else {
|
|
98
|
+
// externals.push(node);
|
|
99
|
+
// }
|
|
100
|
+
// };
|
|
101
|
+
// recursive(copy.leftChild)
|
|
102
|
+
// const simplifyIteration = () => {
|
|
103
|
+
// for (let i = 0; i < externals.length - 1; i++) {
|
|
104
|
+
// const left = externals[i];
|
|
105
|
+
// for (let j = i + 1; j < externals.length; j++) {
|
|
106
|
+
// const right = externals[j];
|
|
107
|
+
// const simplified = simplifyExternalNodes(left, right);
|
|
108
|
+
// if (simplified) {
|
|
109
|
+
// externals[i] = simplified;
|
|
110
|
+
// externals.splice(j, 1);
|
|
111
|
+
// if (isNumberNode(simplified) && simplified.value === 1) {
|
|
112
|
+
// externals.splice(i, 1);
|
|
113
|
+
// }
|
|
114
|
+
// simplifyIteration();
|
|
115
|
+
// return;
|
|
116
|
+
// }
|
|
117
|
+
// }
|
|
118
|
+
// }
|
|
119
|
+
// };
|
|
120
|
+
// simplifyIteration();
|
|
90
121
|
// if (isNumberNode(rightSimplified) && isNumberNode(leftSimplified)) {
|
|
91
122
|
// const value = this.evaluate({});
|
|
92
123
|
// // à partir de ^21 et de ^-7, javascript returns des écritures scientifiques
|
|
@@ -107,11 +138,29 @@ class PowerNode {
|
|
|
107
138
|
// ).simplify();
|
|
108
139
|
// }
|
|
109
140
|
// if (isSqrtNode(leftSimplified) && isNumberNode(rightSimplified)) {
|
|
141
|
+
// const powerValue = rightSimplified.value;
|
|
142
|
+
// const powerIsEven = powerValue % 2 === 0;
|
|
143
|
+
// if (powerIsEven) {
|
|
144
|
+
// return new PowerNode(
|
|
145
|
+
// leftSimplified.child,
|
|
146
|
+
// new NumberNode(powerValue / 2),
|
|
147
|
+
// ).simplify();
|
|
148
|
+
// } else {
|
|
149
|
+
// const parityPower = Math.floor(powerValue / 2);
|
|
150
|
+
// return new MultiplyNode(
|
|
151
|
+
// new PowerNode(leftSimplified.child, new NumberNode(parityPower)),
|
|
152
|
+
// leftSimplified,
|
|
153
|
+
// ).simplify();
|
|
154
|
+
// }
|
|
110
155
|
// }
|
|
111
|
-
//
|
|
156
|
+
// return this;
|
|
112
157
|
// // puissances négatives ?
|
|
113
158
|
// }
|
|
114
|
-
simplify() {
|
|
159
|
+
simplify(opts) {
|
|
160
|
+
//! temporaire
|
|
161
|
+
if ((0, numberNode_1.isNumberNode)(this.rightChild) && this.rightChild.value === 2) {
|
|
162
|
+
return new multiplyNode_1.MultiplyNode(this.leftChild, this.leftChild).simplify(opts);
|
|
163
|
+
}
|
|
115
164
|
return this;
|
|
116
165
|
}
|
|
117
166
|
equals(node) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Node, NodeType } from "../node";
|
|
2
2
|
import { OperatorIds, OperatorNode } from "./operatorNode";
|
|
3
|
-
import { AlgebraicNode } from "../algebraicNode";
|
|
3
|
+
import { AlgebraicNode, SimplifyOptions } from "../algebraicNode";
|
|
4
4
|
export declare function isSubstractNode(a: Node): a is SubstractNode;
|
|
5
5
|
export declare class SubstractNode implements OperatorNode {
|
|
6
6
|
id: OperatorIds;
|
|
@@ -14,7 +14,7 @@ export declare class SubstractNode implements OperatorNode {
|
|
|
14
14
|
toAllValidTexs(): string[];
|
|
15
15
|
toTex(): string;
|
|
16
16
|
evaluate(vars: Record<string, number>): number;
|
|
17
|
-
simplify():
|
|
17
|
+
simplify(opts?: SimplifyOptions): AlgebraicNode;
|
|
18
18
|
equals(node: AlgebraicNode): boolean;
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=substractNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"substractNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/substractNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAG3E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"substractNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/substractNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAG3E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAClE,wBAAgB,eAAe,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,aAAa,CAE3D;AACD,qBAAa,aAAc,YAAW,YAAY;IAChD,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBACP,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa;IAQ/D,YAAY,IAAI,MAAM;IAItB,iBAAiB,IAAI,aAAa,EAAE;IAapC,cAAc,IAAI,MAAM,EAAE;IAG1B,KAAK,IAAI,MAAM;IAef,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMrC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe;IAM/B,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;CAOrC"}
|
|
@@ -52,8 +52,8 @@ class SubstractNode {
|
|
|
52
52
|
// toMathjs() {
|
|
53
53
|
// return subtract(this.leftChild.toMathjs(), this.rightChild.toMathjs());
|
|
54
54
|
// }
|
|
55
|
-
simplify() {
|
|
56
|
-
return this;
|
|
55
|
+
simplify(opts) {
|
|
56
|
+
return new addNode_1.AddNode(this.leftChild, new oppositeNode_1.OppositeNode(this.rightChild)).simplify(opts);
|
|
57
57
|
}
|
|
58
58
|
equals(node) {
|
|
59
59
|
return (isSubstractNode(node) &&
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const randomLetter: (isMaj?: boolean) => string;
|
|
1
|
+
export declare const randomLetter: (isMaj?: boolean, excludes?: string[]) => string;
|
|
2
2
|
//# sourceMappingURL=randomLetter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"randomLetter.d.ts","sourceRoot":"","sources":["../../src/utils/randomLetter.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"randomLetter.d.ts","sourceRoot":"","sources":["../../src/utils/randomLetter.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,WAChB,OAAO,aACJ,MAAM,EAAE,WASnB,CAAC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.randomLetter = void 0;
|
|
4
|
-
const randomLetter = (isMaj = false) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const randomLetter = (isMaj = false, excludes = []) => {
|
|
5
|
+
let letter = "";
|
|
6
|
+
do {
|
|
7
|
+
letter = String.fromCharCode((isMaj ? 65 : 97) + Math.floor(Math.random() * 26));
|
|
8
|
+
} while (excludes.includes(letter));
|
|
9
|
+
return letter;
|
|
8
10
|
};
|
|
9
11
|
exports.randomLetter = randomLetter;
|