math-exercises 2.0.3 → 2.0.5
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/derivation/derivative/lnDerivativeThree.d.ts.map +1 -1
- package/lib/exercises/functions/basics/inverseImageFunctionGeogebra.d.ts +2 -2
- package/lib/exercises/functions/basics/inverseImageFunctionGeogebra.d.ts.map +1 -1
- package/lib/exercises/functions/basics/inverseImageFunctionGeogebra.js +67 -74
- package/lib/exercises/primitive/index.d.ts +1 -0
- package/lib/exercises/primitive/index.d.ts.map +1 -1
- package/lib/exercises/primitive/index.js +3 -2
- package/lib/exercises/primitive/sinCosPrimitive.d.ts.map +1 -1
- package/lib/exercises/primitive/sinUCosUPrimitive.d.ts.map +1 -1
- package/lib/index.d.ts +5 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/math/complex/complex.d.ts +1 -1
- package/lib/math/geometry/point.d.ts +4 -4
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/triangles.d.ts +7 -7
- package/lib/math/geometry/triangles.d.ts.map +1 -1
- package/lib/math/geometry/triangles.js +21 -11
- package/lib/math/numbers/decimals/decimal.d.ts +5 -4
- package/lib/math/numbers/decimals/decimal.d.ts.map +1 -1
- package/lib/math/numbers/integer/integer.d.ts +3 -3
- package/lib/math/numbers/integer/integer.d.ts.map +1 -1
- package/lib/math/numbers/integer/power.d.ts +4 -3
- package/lib/math/numbers/integer/power.d.ts.map +1 -1
- package/lib/math/numbers/nombre.d.ts +3 -2
- package/lib/math/numbers/nombre.d.ts.map +1 -1
- package/lib/math/numbers/rationals/rational.d.ts +4 -2
- package/lib/math/numbers/rationals/rational.d.ts.map +1 -1
- package/lib/math/numbers/reals/extendedRingElement.d.ts +1 -1
- package/lib/math/numbers/reals/real.d.ts +4 -3
- package/lib/math/numbers/reals/real.d.ts.map +1 -1
- package/lib/math/polynomials/polynomial.d.ts +4 -3
- package/lib/math/polynomials/polynomial.d.ts.map +1 -1
- package/lib/math/polynomials/polynomial.js +8 -6
- package/lib/math/polynomials/rationalFrac.d.ts.map +1 -1
- package/lib/math/polynomials/rationalFrac.js +2 -2
- package/lib/math/polynomials/trinom.d.ts +10 -6
- package/lib/math/polynomials/trinom.d.ts.map +1 -1
- package/lib/math/polynomials/trinom.js +1 -1
- package/lib/math/utils/arithmetic/gcd.d.ts +1 -2
- package/lib/math/utils/arithmetic/gcd.d.ts.map +1 -1
- package/lib/math/utils/arithmetic/gcd.js +6 -7
- package/lib/server.js +4 -8
- package/lib/tree/nodes/algebraicNode.d.ts +3 -1
- package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
- package/lib/tree/nodes/complex/complexNode.d.ts +5 -4
- package/lib/tree/nodes/complex/complexNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/absNode.d.ts +2 -1
- package/lib/tree/nodes/functions/absNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/absNode.js +3 -0
- package/lib/tree/nodes/functions/cosNode.d.ts +2 -1
- package/lib/tree/nodes/functions/cosNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/cosNode.js +3 -0
- package/lib/tree/nodes/functions/expNode.d.ts +2 -1
- package/lib/tree/nodes/functions/expNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/expNode.js +3 -0
- package/lib/tree/nodes/functions/logNode.d.ts +2 -1
- package/lib/tree/nodes/functions/logNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/logNode.js +3 -0
- package/lib/tree/nodes/functions/oppositeNode.d.ts +1 -0
- package/lib/tree/nodes/functions/oppositeNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/oppositeNode.js +12 -22
- package/lib/tree/nodes/functions/sinNode.d.ts +2 -1
- package/lib/tree/nodes/functions/sinNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/sinNode.js +3 -0
- package/lib/tree/nodes/functions/sqrtNode.d.ts +2 -1
- package/lib/tree/nodes/functions/sqrtNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/sqrtNode.js +3 -0
- package/lib/tree/nodes/geometry/lengthNode.d.ts +1 -0
- package/lib/tree/nodes/geometry/lengthNode.d.ts.map +1 -1
- package/lib/tree/nodes/geometry/lengthNode.js +7 -0
- package/lib/tree/nodes/geometry/vectorNode.d.ts +2 -3
- package/lib/tree/nodes/geometry/vectorNode.d.ts.map +1 -1
- package/lib/tree/nodes/numbers/constantNode.d.ts +3 -1
- package/lib/tree/nodes/numbers/constantNode.d.ts.map +1 -1
- package/lib/tree/nodes/numbers/constantNode.js +5 -1
- package/lib/tree/nodes/numbers/infiniteNode.d.ts.map +1 -1
- package/lib/tree/nodes/numbers/infiniteNode.js +3 -3
- package/lib/tree/nodes/numbers/numberNode.d.ts +1 -0
- package/lib/tree/nodes/numbers/numberNode.d.ts.map +1 -1
- package/lib/tree/nodes/numbers/numberNode.js +3 -0
- package/lib/tree/nodes/numbers/piNode.d.ts +1 -1
- package/lib/tree/nodes/numbers/piNode.d.ts.map +1 -1
- package/lib/tree/nodes/numbers/piNode.js +1 -1
- package/lib/tree/nodes/operators/addNode.d.ts +2 -1
- package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.js +3 -0
- package/lib/tree/nodes/operators/divideNode.d.ts +2 -1
- package/lib/tree/nodes/operators/divideNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/divideNode.js +3 -0
- package/lib/tree/nodes/operators/fractionNode.d.ts +2 -1
- package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/fractionNode.js +3 -0
- package/lib/tree/nodes/operators/multiplyNode.d.ts +1 -1
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +6 -4
- package/lib/tree/nodes/operators/powerNode.d.ts +3 -2
- package/lib/tree/nodes/operators/powerNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/powerNode.js +6 -0
- package/lib/tree/nodes/operators/substractNode.d.ts +6 -4
- package/lib/tree/nodes/operators/substractNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/substractNode.js +3 -0
- package/lib/tree/nodes/variables/variableNode.d.ts +3 -1
- package/lib/tree/nodes/variables/variableNode.d.ts.map +1 -1
- package/lib/tree/nodes/variables/variableNode.js +6 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"real.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/reals/real.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"real.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/reals/real.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAS/D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,8BAAsB,eAAe;IACnC,MAAM,CAAC,MAAM;CAUd;AACD,qBAAa,IAAK,YAAW,MAAM;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;gBACL,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAKtC,MAAM,IAAI,aAAa;CAIxB;AAED,8BAAsB,qBAAqB;IACzC;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,EACxB,kBAA0B,EAC1B,SAAc,GACf;;;KAAA,GAAG,UAAU;IASd,MAAM,CAAC,kBAAkB,CAAC,GAAG,GAAE,MAAW,GAAG,UAAU;CAIxD;AAED,qBAAa,UAAW,SAAQ,IAAI;IAClC,OAAO,EAAE,MAAM,CAAC;gBACJ,OAAO,EAAE,MAAM;IAK3B,cAAc;IAMd,mBAAmB,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;IAiBvC,QAAQ,IAAI,MAAM;IAyBlB,KAAK,IAAI,MAAM;IAIf,MAAM;CAGP"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NodeOptions } from "../../tree/nodes/node";
|
|
2
2
|
import { NumberNode } from "../../tree/nodes/numbers/numberNode";
|
|
3
|
+
import { AlgebraicNode } from "../../tree/nodes/algebraicNode";
|
|
3
4
|
export declare abstract class PolynomialConstructor {
|
|
4
5
|
static randomWithOrder(order: number, variable?: string): Polynomial;
|
|
5
6
|
static random(maxOrder: number, variable?: string): Polynomial;
|
|
@@ -35,11 +36,11 @@ export declare class Polynomial {
|
|
|
35
36
|
scalarDivide(n: number): Polynomial;
|
|
36
37
|
opposite(): Polynomial;
|
|
37
38
|
derivate(): Polynomial;
|
|
38
|
-
integrateToNode(opts?: NodeOptions):
|
|
39
|
+
integrateToNode(opts?: NodeOptions): AlgebraicNode;
|
|
39
40
|
calculate(x: number): number;
|
|
40
41
|
getLimit(to: "+\\infty" | "-\\infty"): string;
|
|
41
42
|
getLimitNode(to: "+\\infty" | "-\\infty"): NumberNode | import("../../tree/nodes/numbers/constantNode").ConstantNode;
|
|
42
|
-
toTree(opts?: NodeOptions):
|
|
43
|
+
toTree(opts?: NodeOptions): AlgebraicNode;
|
|
43
44
|
toTex(): string;
|
|
44
45
|
toString(): string;
|
|
45
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polynomial.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/polynomial.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"polynomial.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/polynomial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAcjE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,8BAAsB,qBAAqB;IACzC,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IAa5D,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IActD;;;;;;OAMG;IACH,MAAM,CAAC,gBAAgB,CACrB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,QAAQ,GAAE,MAAY;IAoBxB,MAAM,CAAC,4BAA4B,CACjC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,QAAQ,GAAE,MAAY;IAqBxB,MAAM,CAAC,UAAU,CACf,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,UAAU,GAAG,UAAU,EAC3B,MAAM,CAAC,EAAE,MAAM,EACf,QAAQ,GAAE,MAAY;CAmCzB;AAED,qBAAa,UAAU;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IAEvB;;;;OAIG;gBACS,YAAY,EAAE,MAAM,EAAE,EAAE,QAAQ,GAAE,MAAY;IAY1D,MAAM,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO;IAM9B,QAAQ,IAAI,MAAM,EAAE;IAkCpB,GAAG,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,UAAU;IAyBvC,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU;IAQ7B,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU;IAuBnC,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU;IAMnC,QAAQ,IAAI,UAAU;IAOtB,QAAQ,IAAI,UAAU;IAmBtB,eAAe,CAAC,IAAI,CAAC,EAAE,WAAW;IA+BlC,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAO5B,QAAQ,CAAC,EAAE,EAAE,UAAU,GAAG,UAAU,GAAG,MAAM;IAiB7C,YAAY,CAAC,EAAE,EAAE,UAAU,GAAG,UAAU;IAiBxC,MAAM,CAAC,IAAI,CAAC,EAAE,WAAW;IAuCzB,KAAK,IAAI,MAAM;IAyBf,QAAQ,IAAI,MAAM;CAGnB"}
|
|
@@ -233,23 +233,25 @@ class Polynomial {
|
|
|
233
233
|
// }
|
|
234
234
|
integrateToNode(opts) {
|
|
235
235
|
let integralPolynomial = new variableNode_1.VariableNode("C");
|
|
236
|
+
const varNode = new variableNode_1.VariableNode(this.variable);
|
|
236
237
|
for (let i = 0; i < this.degree + 1; i++) {
|
|
237
238
|
const coeff = this.coefficients[i];
|
|
238
239
|
if (coeff === 0)
|
|
239
240
|
continue;
|
|
240
241
|
const nodeCoeff = new rational_1.Rational(coeff, i + 1).simplify().toTree();
|
|
241
242
|
const powerNode = i + 1 === 1
|
|
242
|
-
?
|
|
243
|
-
: new powerNode_1.PowerNode(
|
|
243
|
+
? varNode
|
|
244
|
+
: new powerNode_1.PowerNode(varNode, new numberNode_1.NumberNode(i + 1), opts);
|
|
244
245
|
let terme;
|
|
245
|
-
|
|
246
|
+
const coeffTex = nodeCoeff.toTex();
|
|
247
|
+
if (coeffTex === "1")
|
|
246
248
|
terme = powerNode;
|
|
247
|
-
else if (
|
|
249
|
+
else if (coeffTex === "-1")
|
|
248
250
|
terme = new oppositeNode_1.OppositeNode(powerNode, opts);
|
|
249
251
|
else {
|
|
250
252
|
terme = new multiplyNode_1.MultiplyNode(nodeCoeff, i + 1 === 1
|
|
251
|
-
?
|
|
252
|
-
: new powerNode_1.PowerNode(
|
|
253
|
+
? varNode
|
|
254
|
+
: new powerNode_1.PowerNode(varNode, new numberNode_1.NumberNode(i + 1), opts), opts);
|
|
253
255
|
}
|
|
254
256
|
integralPolynomial = new addNode_1.AddNode(terme, integralPolynomial, opts);
|
|
255
257
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rationalFrac.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/rationalFrac.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAEzD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAGrD,qBAAa,YAAY;IACvB,GAAG,EAAE,UAAU,CAAC;IAChB,KAAK,EAAE,UAAU,CAAC;gBACN,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU;IAI9C,MAAM;IAGN,QAAQ;
|
|
1
|
+
{"version":3,"file":"rationalFrac.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/rationalFrac.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAEzD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAGrD,qBAAa,YAAY;IACvB,GAAG,EAAE,UAAU,CAAC;IAChB,KAAK,EAAE,UAAU,CAAC;gBACN,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU;IAI9C,MAAM;IAGN,QAAQ;CAuCT"}
|
|
@@ -18,9 +18,9 @@ class RationalFrac {
|
|
|
18
18
|
if (this.num.coefficients.length === 1 && this.num.coefficients[0] === 0)
|
|
19
19
|
return new integer_1.Integer(0);
|
|
20
20
|
const numCoeffs = this.num.coefficients.filter((c) => c !== 0);
|
|
21
|
-
const numPGCD = numCoeffs.length > 1 ? (0, gcd_1.
|
|
21
|
+
const numPGCD = numCoeffs.length > 1 ? (0, gcd_1.gcd)(...numCoeffs) : numCoeffs[0];
|
|
22
22
|
const denumCoeffs = this.denum.coefficients.filter((c) => c !== 0);
|
|
23
|
-
const denumPGCD = denumCoeffs.length > 1 ? (0, gcd_1.
|
|
23
|
+
const denumPGCD = denumCoeffs.length > 1 ? (0, gcd_1.gcd)(...denumCoeffs) : denumCoeffs[0];
|
|
24
24
|
const rational = new rational_1.Rational(numPGCD, denumPGCD);
|
|
25
25
|
if (rational.isIrreductible()) {
|
|
26
26
|
return this;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { Node } from "../../tree/nodes/node";
|
|
2
1
|
import { NumberNode } from "../../tree/nodes/numbers/numberNode";
|
|
2
|
+
import { AddNode } from "../../tree/nodes/operators/addNode";
|
|
3
|
+
import { FractionNode } from "../../tree/nodes/operators/fractionNode";
|
|
4
|
+
import { MultiplyNode } from "../../tree/nodes/operators/multiplyNode";
|
|
3
5
|
import { Point } from "../geometry/point";
|
|
4
6
|
import { MathSet } from "../sets/mathSet";
|
|
5
7
|
import { Polynomial } from "./polynomial";
|
|
8
|
+
import { OppositeNode } from "../../tree/nodes/functions/oppositeNode";
|
|
9
|
+
import { AlgebraicNode } from "../../tree/nodes/algebraicNode";
|
|
6
10
|
export declare abstract class TrinomConstructor {
|
|
7
11
|
static random(domainA?: MathSet, domainB?: MathSet, domainC?: MathSet): Trinom;
|
|
8
12
|
static randomCanonical(domainA?: MathSet, domainAlpha?: MathSet, domainBeta?: MathSet): Trinom;
|
|
@@ -17,14 +21,14 @@ export declare class Trinom extends Polynomial {
|
|
|
17
21
|
getDelta(): number;
|
|
18
22
|
getDeltaNode(): NumberNode;
|
|
19
23
|
getRoots(): number[];
|
|
20
|
-
getRootsNode():
|
|
24
|
+
getRootsNode(): AlgebraicNode[];
|
|
21
25
|
getRootsEquationSolutionTex(): string;
|
|
22
26
|
getAlpha(): number;
|
|
23
|
-
getAlphaNode():
|
|
27
|
+
getAlphaNode(): NumberNode | FractionNode | OppositeNode;
|
|
24
28
|
getBeta(): number;
|
|
25
|
-
getBetaNode():
|
|
26
|
-
getFactorizedForm():
|
|
27
|
-
getCanonicalForm():
|
|
29
|
+
getBetaNode(): NumberNode | FractionNode | OppositeNode;
|
|
30
|
+
getFactorizedForm(): AlgebraicNode;
|
|
31
|
+
getCanonicalForm(): AddNode | MultiplyNode;
|
|
28
32
|
getSommet(): Point;
|
|
29
33
|
}
|
|
30
34
|
//# sourceMappingURL=trinom.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trinom.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/trinom.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"trinom.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/trinom.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAIvE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAO1C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAEvE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,8BAAsB,iBAAiB;IACrC,MAAM,CAAC,MAAM,CACX,OAAO,GAAE,OAER,EACD,OAAO,GAAE,OAAqC,EAC9C,OAAO,GAAE,OAAqC,GAC7C,MAAM;IAST,MAAM,CAAC,eAAe,CACpB,OAAO,GAAE,OAER,EACD,WAAW,GAAE,OAAqC,EAClD,UAAU,GAAE,OAAqC,GAChD,MAAM;IAUT,MAAM,CAAC,gBAAgB,CACrB,OAAO,GAAE,OAER,EACD,QAAQ,GAAE,OAAqC,EAC/C,QAAQ,GAAE,OAAqC,GAC9C,MAAM;CAcV;AAED,qBAAa,MAAO,SAAQ,UAAU;IACpC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;gBACL,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IAQnE,QAAQ;IAGR,YAAY,IAAI,UAAU;IAI1B,QAAQ;IAUR,YAAY,IAAI,aAAa,EAAE;IAoD/B,2BAA2B;IAO3B,QAAQ;IAGR,YAAY;IAIZ,OAAO;IAIP,WAAW;IAIX,iBAAiB;IA4CjB,gBAAgB;IAsBhB,SAAS;CAGV"}
|
|
@@ -92,7 +92,7 @@ class Trinom extends polynomial_1.Polynomial {
|
|
|
92
92
|
let [sqrtA, sqrtB] = new real_1.SquareRoot(delta).getSimplifiedCoeffs();
|
|
93
93
|
let denum = 2 * this.a;
|
|
94
94
|
let trueB = this.b;
|
|
95
|
-
const pgcd = (0, gcd_1.
|
|
95
|
+
const pgcd = (0, gcd_1.gcd)(sqrtA, trueB, denum);
|
|
96
96
|
[sqrtA, trueB, denum] = [sqrtA, trueB, denum].map((n) => n / pgcd);
|
|
97
97
|
const sqrtNode = sqrtA === 1
|
|
98
98
|
? new sqrtNode_1.SqrtNode(new numberNode_1.NumberNode(sqrtB))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gcd.d.ts","sourceRoot":"","sources":["../../../../src/math/utils/arithmetic/gcd.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gcd.d.ts","sourceRoot":"","sources":["../../../../src/math/utils/arithmetic/gcd.ts"],"names":[],"mappings":"AAIA,wBAAgB,GAAG,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAG7C"}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
function
|
|
3
|
+
exports.gcd = void 0;
|
|
4
|
+
function pgcd(a, b) {
|
|
5
5
|
return b ? gcd(b, a % b) : a;
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
function multigcd(...args) {
|
|
7
|
+
function gcd(...args) {
|
|
9
8
|
if (args.length === 2)
|
|
10
|
-
return
|
|
9
|
+
return pgcd(args[0], args[1]);
|
|
11
10
|
else
|
|
12
|
-
return gcd(args[0],
|
|
11
|
+
return gcd(args[0], gcd(...args.slice(1)));
|
|
13
12
|
}
|
|
14
|
-
exports.
|
|
13
|
+
exports.gcd = gcd;
|
package/lib/server.js
CHANGED
|
@@ -35,26 +35,22 @@ const express_1 = __importDefault(require("express"));
|
|
|
35
35
|
const body_parser_1 = __importDefault(require("body-parser"));
|
|
36
36
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
37
37
|
const cors_1 = __importDefault(require("cors"));
|
|
38
|
-
const rational_1 = require("./math/numbers/rationals/rational");
|
|
39
38
|
const multiplyNode_1 = require("./tree/nodes/operators/multiplyNode");
|
|
40
39
|
const numberNode_1 = require("./tree/nodes/numbers/numberNode");
|
|
41
|
-
const
|
|
42
|
-
const
|
|
40
|
+
const addNode_1 = require("./tree/nodes/operators/addNode");
|
|
41
|
+
const powerNode_1 = require("./tree/nodes/operators/powerNode");
|
|
43
42
|
const jsonParser = body_parser_1.default.json();
|
|
44
43
|
const allExercises = [...exercises];
|
|
45
44
|
const runServer = () => {
|
|
46
45
|
dotenv_1.default.config();
|
|
47
46
|
const app = (0, express_1.default)();
|
|
48
47
|
app.use((0, cors_1.default)());
|
|
49
|
-
console.log((0, gcd_1.multigcd)(5, 11, 15, 25, 55));
|
|
50
|
-
const frac = new rational_1.Rational(-2, 3).simplify().toTree();
|
|
51
|
-
console.log(frac.toAllValidTexs());
|
|
52
|
-
const prod = new oppositeNode_1.OppositeNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(2), new numberNode_1.NumberNode(3)));
|
|
53
|
-
console.log(prod.toAllValidTexs());
|
|
54
48
|
console.log(exercises.length);
|
|
55
49
|
app.get("/", (req, res) => {
|
|
56
50
|
res.json(allExercises);
|
|
57
51
|
});
|
|
52
|
+
const tree = new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(3), new addNode_1.AddNode(new powerNode_1.SquareNode(new numberNode_1.NumberNode(4)), new powerNode_1.PowerNode(new numberNode_1.NumberNode(2), new numberNode_1.NumberNode(3))));
|
|
53
|
+
console.log(tree.evaluate({}));
|
|
58
54
|
app.get("/exo", (req, res) => {
|
|
59
55
|
const exoId = req.query.exoId;
|
|
60
56
|
const exoIndex = allExercises.findIndex((exo) => exo.id == exoId);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { Node } from "./node";
|
|
1
|
+
import { Node, NodeOptions } from "./node";
|
|
2
2
|
export interface AlgebraicNode extends Node {
|
|
3
|
+
evaluate: (vars: Record<string, number>) => number;
|
|
4
|
+
toEquivalentNodes: (opts?: NodeOptions) => AlgebraicNode[];
|
|
3
5
|
}
|
|
4
6
|
//# sourceMappingURL=algebraicNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"algebraicNode.d.ts","sourceRoot":"","sources":["../../../src/tree/nodes/algebraicNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"algebraicNode.d.ts","sourceRoot":"","sources":["../../../src/tree/nodes/algebraicNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAE3C,MAAM,WAAW,aAAc,SAAQ,IAAI;IAEzC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC;IACnD,iBAAiB,EAAE,CAAC,IAAI,CAAC,EAAE,WAAW,KAAK,aAAa,EAAE,CAAC;CAC5D"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Node, NodeOptions, NodeType } from "../node";
|
|
2
|
+
import { AlgebraicNode } from "../algebraicNode";
|
|
2
3
|
export declare class ComplexNode implements Node {
|
|
3
|
-
re:
|
|
4
|
-
im:
|
|
4
|
+
re: AlgebraicNode;
|
|
5
|
+
im: AlgebraicNode;
|
|
5
6
|
opts?: NodeOptions;
|
|
6
7
|
type: NodeType;
|
|
7
|
-
constructor(re:
|
|
8
|
-
toEquivalentNodes(opts?: NodeOptions):
|
|
8
|
+
constructor(re: AlgebraicNode, im: AlgebraicNode, opts?: NodeOptions);
|
|
9
|
+
toEquivalentNodes(opts?: NodeOptions): AlgebraicNode[];
|
|
9
10
|
toAllValidTexs(opts?: NodeOptions): string[];
|
|
10
11
|
toMathString(): string;
|
|
11
12
|
toTex(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"complexNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/complex/complexNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"complexNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/complex/complexNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAOtD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,qBAAa,WAAY,YAAW,IAAI;IACtC,EAAE,EAAE,aAAa,CAAC;IAClB,EAAE,EAAE,aAAa,CAAC;IAClB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAmB;gBAErB,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;IAKpE,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,aAAa,EAAE;IAkBtD,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAI5C,YAAY,IAAI,MAAM;IAGtB,KAAK,IAAI,MAAM;CAiBhB"}
|
|
@@ -9,8 +9,9 @@ export declare class AbsNode implements FunctionNode {
|
|
|
9
9
|
constructor(child: AlgebraicNode);
|
|
10
10
|
toMathString(): string;
|
|
11
11
|
toTex(): string;
|
|
12
|
-
toEquivalentNodes():
|
|
12
|
+
toEquivalentNodes(): AlgebraicNode[];
|
|
13
13
|
toAllValidTexs(): string[];
|
|
14
14
|
simplify(): Node;
|
|
15
|
+
evaluate(vars: Record<string, number>): number;
|
|
15
16
|
}
|
|
16
17
|
//# sourceMappingURL=absNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"absNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/absNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,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;gBAEH,KAAK,EAAE,aAAa;IAMhC,YAAY,IAAI,MAAM;IAItB,KAAK,IAAI,MAAM;IAOf,iBAAiB,IAAI,
|
|
1
|
+
{"version":3,"file":"absNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/absNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,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;gBAEH,KAAK,EAAE,aAAa;IAMhC,YAAY,IAAI,MAAM;IAItB,KAAK,IAAI,MAAM;IAOf,iBAAiB,IAAI,aAAa,EAAE;IASpC,cAAc,IAAI,MAAM,EAAE;IAG1B,QAAQ,IAAI,IAAI;IAIhB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAGtC"}
|
|
@@ -8,9 +8,10 @@ export declare class CosNode implements FunctionNode {
|
|
|
8
8
|
type: NodeType;
|
|
9
9
|
constructor(child: AlgebraicNode);
|
|
10
10
|
toMathString(): string;
|
|
11
|
-
toEquivalentNodes():
|
|
11
|
+
toEquivalentNodes(): AlgebraicNode[];
|
|
12
12
|
toAllValidTexs(): string[];
|
|
13
13
|
toTex(): string;
|
|
14
14
|
simplify(): Node;
|
|
15
|
+
evaluate(vars: Record<string, number>): number;
|
|
15
16
|
}
|
|
16
17
|
//# sourceMappingURL=cosNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cosNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/cosNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,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;gBAEH,KAAK,EAAE,aAAa;IAMhC,YAAY,IAAI,MAAM;IAItB,iBAAiB,IAAI,
|
|
1
|
+
{"version":3,"file":"cosNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/cosNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,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;gBAEH,KAAK,EAAE,aAAa;IAMhC,YAAY,IAAI,MAAM;IAItB,iBAAiB,IAAI,aAAa,EAAE;IASpC,cAAc,IAAI,MAAM,EAAE;IAI1B,KAAK,IAAI,MAAM;IAQf,QAAQ,IAAI,IAAI;IAGhB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAGtC"}
|
|
@@ -10,8 +10,9 @@ export declare class ExpNode implements FunctionNode {
|
|
|
10
10
|
constructor(child: AlgebraicNode, opts?: NodeOptions);
|
|
11
11
|
toMathString(): string;
|
|
12
12
|
toTex(): string;
|
|
13
|
-
toEquivalentNodes():
|
|
13
|
+
toEquivalentNodes(): AlgebraicNode[];
|
|
14
14
|
toAllValidTexs(): string[];
|
|
15
15
|
simplify(): Node;
|
|
16
|
+
evaluate(vars: Record<string, number>): number;
|
|
16
17
|
}
|
|
17
18
|
//# sourceMappingURL=expNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/expNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,OAAO,CAE/C;AACD,qBAAa,OAAQ,YAAW,YAAY;IAC1C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,EAAE,EAAE,YAAY,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;gBACH,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;IAOpD,YAAY,IAAI,MAAM;IAItB,KAAK,IAAI,MAAM;IAgBf,iBAAiB,IAAI,
|
|
1
|
+
{"version":3,"file":"expNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/expNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,OAAO,CAE/C;AACD,qBAAa,OAAQ,YAAW,YAAY;IAC1C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,EAAE,EAAE,YAAY,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;gBACH,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;IAOpD,YAAY,IAAI,MAAM;IAItB,KAAK,IAAI,MAAM;IAgBf,iBAAiB,IAAI,aAAa,EAAE;IAUpC,cAAc,IAAI,MAAM,EAAE;IAI1B,QAAQ,IAAI,IAAI;IAGhB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAGtC"}
|
|
@@ -10,8 +10,9 @@ export declare class LogNode implements FunctionNode {
|
|
|
10
10
|
constructor(child: AlgebraicNode, opts?: NodeOptions);
|
|
11
11
|
toMathString(): string;
|
|
12
12
|
toTex(): string;
|
|
13
|
-
toEquivalentNodes():
|
|
13
|
+
toEquivalentNodes(): AlgebraicNode[];
|
|
14
14
|
toAllValidTexs(): string[];
|
|
15
15
|
simplify(): Node;
|
|
16
|
+
evaluate(vars: Record<string, number>): number;
|
|
16
17
|
}
|
|
17
18
|
//# sourceMappingURL=logNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/logNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,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,IAAI,CAAC,EAAE,WAAW,CAAC;gBAEP,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;IAOpD,YAAY,IAAI,MAAM;IAItB,KAAK,IAAI,MAAM;IAaf,iBAAiB,IAAI,
|
|
1
|
+
{"version":3,"file":"logNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/logNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,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,IAAI,CAAC,EAAE,WAAW,CAAC;gBAEP,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;IAOpD,YAAY,IAAI,MAAM;IAItB,KAAK,IAAI,MAAM;IAaf,iBAAiB,IAAI,aAAa,EAAE;IASpC,cAAc,IAAI,MAAM,EAAE;IAG1B,QAAQ,IAAI,IAAI;IAGhB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAGtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oppositeNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/oppositeNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAMtD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAMjD,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AAGD,qBAAa,YAAa,YAAW,YAAY;IAC/C,EAAE,EAAE,YAAY,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,CAAC;gBACP,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;IAMpD,YAAY,IAAI,MAAM;IAGtB,KAAK,IAAI,MAAM;IAef,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,aAAa,EAAE;
|
|
1
|
+
{"version":3,"file":"oppositeNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/oppositeNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAMtD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAMjD,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AAGD,qBAAa,YAAa,YAAW,YAAY;IAC/C,EAAE,EAAE,YAAY,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,CAAC;gBACP,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;IAMpD,YAAY,IAAI,MAAM;IAGtB,KAAK,IAAI,MAAM;IAef,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,aAAa,EAAE;IAgCtD;;;;OAIG;IACH,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAQ5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAGtC"}
|
|
@@ -6,6 +6,7 @@ const node_1 = require("../node");
|
|
|
6
6
|
const operatorNode_1 = require("../operators/operatorNode");
|
|
7
7
|
const functionNode_1 = require("./functionNode");
|
|
8
8
|
const numberNode_1 = require("../numbers/numberNode");
|
|
9
|
+
const fractionNode_1 = require("../operators/fractionNode");
|
|
9
10
|
function isOppositeNode(a) {
|
|
10
11
|
return (0, functionNode_1.isFunctionNode)(a) && a.id === functionNode_1.FunctionsIds.opposite;
|
|
11
12
|
}
|
|
@@ -40,31 +41,14 @@ class OppositeNode {
|
|
|
40
41
|
const externalNodes = [];
|
|
41
42
|
//! est ce qu'il faut faire ici des simplifications du type -ln(2) => 1/ln(2)
|
|
42
43
|
//! ou meme -(a+b) => -a - b
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// ...new MultiplyNode(
|
|
46
|
-
// new OppositeNode(this.child.leftChild),
|
|
47
|
-
// this.child.rightChild,
|
|
48
|
-
// ).toEquivalentNodes(options),
|
|
49
|
-
// );
|
|
50
|
-
// else if (isDivideNode(this.child))
|
|
51
|
-
// res.push(
|
|
52
|
-
// ...new DivideNode(
|
|
53
|
-
// new OppositeNode(this.child.leftChild),
|
|
54
|
-
// this.child.rightChild,
|
|
55
|
-
// ).toEquivalentNodes(options),
|
|
56
|
-
// );
|
|
57
|
-
// else if (isFractionNode(this.child))
|
|
58
|
-
// res.push(
|
|
59
|
-
// ...new FractionNode(
|
|
60
|
-
// new OppositeNode(this.child.leftChild),
|
|
61
|
-
// this.child.rightChild,
|
|
62
|
-
// ).toEquivalentNodes(options),
|
|
63
|
-
// );
|
|
64
|
-
// else {
|
|
44
|
+
//!version simplifiée pour juste gérer les fractions
|
|
45
|
+
//!la bonne solution serait de parse l'arbre et déplacer l'opposite sur chaque child d'un sous arbre multiplicatif
|
|
65
46
|
const childNodes = this.child.toEquivalentNodes(options);
|
|
66
47
|
childNodes.forEach((childNode) => {
|
|
67
48
|
res.push(new OppositeNode(childNode));
|
|
49
|
+
if ((0, fractionNode_1.isFractionNode)(childNode)) {
|
|
50
|
+
res.push(new fractionNode_1.FractionNode(new OppositeNode(childNode.leftChild), childNode.rightChild, { allowMinusAnywhereInFraction: true }), new fractionNode_1.FractionNode(childNode.leftChild, new OppositeNode(childNode.rightChild), { allowMinusAnywhereInFraction: true }));
|
|
51
|
+
}
|
|
68
52
|
});
|
|
69
53
|
// }
|
|
70
54
|
return res;
|
|
@@ -78,5 +62,11 @@ class OppositeNode {
|
|
|
78
62
|
const options = opts ?? this.opts;
|
|
79
63
|
return this.toEquivalentNodes(options).map((node) => node.toTex());
|
|
80
64
|
}
|
|
65
|
+
// toMathjs() {
|
|
66
|
+
// return unaryMinus(this.child.toMathjs());
|
|
67
|
+
// }
|
|
68
|
+
evaluate(vars) {
|
|
69
|
+
return -this.child.evaluate(vars);
|
|
70
|
+
}
|
|
81
71
|
}
|
|
82
72
|
exports.OppositeNode = OppositeNode;
|
|
@@ -9,8 +9,9 @@ export declare class SinNode implements FunctionNode {
|
|
|
9
9
|
constructor(child: AlgebraicNode);
|
|
10
10
|
toMathString(): string;
|
|
11
11
|
toTex(): string;
|
|
12
|
-
toEquivalentNodes():
|
|
12
|
+
toEquivalentNodes(): AlgebraicNode[];
|
|
13
13
|
toAllValidTexs(): string[];
|
|
14
14
|
simplify(): Node;
|
|
15
|
+
evaluate(vars: Record<string, number>): number;
|
|
15
16
|
}
|
|
16
17
|
//# sourceMappingURL=sinNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sinNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/sinNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,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;gBAEH,KAAK,EAAE,aAAa;IAMhC,YAAY,IAAI,MAAM;IAItB,KAAK,IAAI,MAAM;IAMf,iBAAiB,IAAI,
|
|
1
|
+
{"version":3,"file":"sinNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/sinNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,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;gBAEH,KAAK,EAAE,aAAa;IAMhC,YAAY,IAAI,MAAM;IAItB,KAAK,IAAI,MAAM;IAMf,iBAAiB,IAAI,aAAa,EAAE;IASpC,cAAc,IAAI,MAAM,EAAE;IAI1B,QAAQ,IAAI,IAAI;IAGhB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAGtC"}
|
|
@@ -10,7 +10,8 @@ export declare class SqrtNode implements FunctionNode {
|
|
|
10
10
|
constructor(child: AlgebraicNode, opts?: NodeOptions);
|
|
11
11
|
toMathString(): string;
|
|
12
12
|
toTex(): string;
|
|
13
|
-
toEquivalentNodes(opts?: NodeOptions):
|
|
13
|
+
toEquivalentNodes(opts?: NodeOptions): AlgebraicNode[];
|
|
14
14
|
toAllValidTexs(): string[];
|
|
15
|
+
evaluate(vars: Record<string, number>): number;
|
|
15
16
|
}
|
|
16
17
|
//# sourceMappingURL=sqrtNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqrtNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/sqrtNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAK5E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,wBAAgB,UAAU,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,QAAQ,CAEjD;AACD,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;gBAEP,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;IAMpD,YAAY,IAAI,MAAM;IAMtB,KAAK,IAAI,MAAM;IAIf,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"sqrtNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/sqrtNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAK5E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,wBAAgB,UAAU,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,QAAQ,CAEjD;AACD,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;gBAEP,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;IAMpD,YAAY,IAAI,MAAM;IAMtB,KAAK,IAAI,MAAM;IAIf,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,aAAa,EAAE;IAwBtD,cAAc,IAAI,MAAM,EAAE;IAG1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAGtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lengthNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/geometry/lengthNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEhD,qBAAa,UAAW,YAAW,aAAa;IAC9C,IAAI,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,QAAQ,CAAC;gBAEH,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW;IASnD,cAAc;IAId,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IAOpC,YAAY;IAGZ,QAAQ;IAIR,KAAK;
|
|
1
|
+
{"version":3,"file":"lengthNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/geometry/lengthNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEhD,qBAAa,UAAW,YAAW,aAAa;IAC9C,IAAI,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,QAAQ,CAAC;gBAEH,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW;IASnD,cAAc;IAId,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IAOpC,YAAY;IAGZ,QAAQ;IAIR,KAAK;IAIL,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAQtC"}
|
|
@@ -29,5 +29,12 @@ class LengthNode {
|
|
|
29
29
|
toTex() {
|
|
30
30
|
return this.segmentName;
|
|
31
31
|
}
|
|
32
|
+
evaluate(vars) {
|
|
33
|
+
const value = vars[this.segmentName] ??
|
|
34
|
+
vars[this.segmentName.split("").reverse().join("")];
|
|
35
|
+
if (value === undefined)
|
|
36
|
+
throw Error(`Can't evaluate length ${this.segmentName}`);
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
32
39
|
}
|
|
33
40
|
exports.LengthNode = LengthNode;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare class VectorNode implements AlgebraicNode {
|
|
1
|
+
import { Node, NodeOptions, NodeType } from "../node";
|
|
2
|
+
export declare class VectorNode implements Node {
|
|
4
3
|
opts?: NodeOptions | undefined;
|
|
5
4
|
name: string;
|
|
6
5
|
type: NodeType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vectorNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/geometry/vectorNode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vectorNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/geometry/vectorNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEtD,qBAAa,UAAW,YAAW,IAAI;IACrC,IAAI,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;gBAEH,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW;IAS5C,cAAc;IAId,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IAIpC,YAAY;IAGZ,QAAQ;IAIR,KAAK;CAGN"}
|
|
@@ -4,11 +4,13 @@ export declare function isConstantNode(a: Node): a is ConstantNode;
|
|
|
4
4
|
export declare class ConstantNode implements AlgebraicNode {
|
|
5
5
|
tex: string;
|
|
6
6
|
mathString: string;
|
|
7
|
+
value: number;
|
|
7
8
|
type: NodeType;
|
|
8
|
-
constructor(tex: string, mathString: string);
|
|
9
|
+
constructor(tex: string, mathString: string, value: number);
|
|
9
10
|
toMathString(): string;
|
|
10
11
|
toTex(): string;
|
|
11
12
|
toAllValidTexs(): string[];
|
|
12
13
|
toEquivalentNodes(): this[];
|
|
14
|
+
evaluate(vars: Record<string, number>): number;
|
|
13
15
|
}
|
|
14
16
|
//# sourceMappingURL=constantNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constantNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/numbers/constantNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AACD,qBAAa,YAAa,YAAW,aAAa;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAqB;gBAEvB,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"constantNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/numbers/constantNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AACD,qBAAa,YAAa,YAAW,aAAa;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,CAAqB;gBAEvB,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAM1D,YAAY,IAAI,MAAM;IAGtB,KAAK,IAAI,MAAM;IAMf,cAAc;IAGd,iBAAiB;IAGjB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAGtC"}
|
|
@@ -8,10 +8,11 @@ function isConstantNode(a) {
|
|
|
8
8
|
}
|
|
9
9
|
exports.isConstantNode = isConstantNode;
|
|
10
10
|
class ConstantNode {
|
|
11
|
-
constructor(tex, mathString) {
|
|
11
|
+
constructor(tex, mathString, value) {
|
|
12
12
|
this.type = node_1.NodeType.constant;
|
|
13
13
|
this.tex = tex;
|
|
14
14
|
this.mathString = mathString;
|
|
15
|
+
this.value = value;
|
|
15
16
|
}
|
|
16
17
|
toMathString() {
|
|
17
18
|
return `${this.mathString}`;
|
|
@@ -28,5 +29,8 @@ class ConstantNode {
|
|
|
28
29
|
toEquivalentNodes() {
|
|
29
30
|
return [this];
|
|
30
31
|
}
|
|
32
|
+
evaluate(vars) {
|
|
33
|
+
return this.value;
|
|
34
|
+
}
|
|
31
35
|
}
|
|
32
36
|
exports.ConstantNode = ConstantNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infiniteNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/numbers/infiniteNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"infiniteNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/numbers/infiniteNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,eAAO,MAAM,YAAY,cAAoD,CAAC;AAC9E,eAAO,MAAM,gBAAgB,cAI5B,CAAC;AACF,eAAO,MAAM,iBAAiB,cAI7B,CAAC"}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MinusInfinityNode = exports.PlusInfinityNode = exports.InfinityNode = void 0;
|
|
4
4
|
const constantNode_1 = require("./constantNode");
|
|
5
|
-
exports.InfinityNode = new constantNode_1.ConstantNode("\\infty", "infinity");
|
|
6
|
-
exports.PlusInfinityNode = new constantNode_1.ConstantNode("+\\infty", "infinity");
|
|
7
|
-
exports.MinusInfinityNode = new constantNode_1.ConstantNode("-\\infty", "-infinity");
|
|
5
|
+
exports.InfinityNode = new constantNode_1.ConstantNode("\\infty", "infinity", Infinity);
|
|
6
|
+
exports.PlusInfinityNode = new constantNode_1.ConstantNode("+\\infty", "infinity", Infinity);
|
|
7
|
+
exports.MinusInfinityNode = new constantNode_1.ConstantNode("-\\infty", "-infinity", -Infinity);
|