math-exercises 3.0.201 → 3.0.203
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/dataRepresentations/scatterPlot/index.d.ts +2 -0
- package/lib/exercises/math/dataRepresentations/scatterPlot/index.d.ts.map +1 -1
- package/lib/exercises/math/dataRepresentations/scatterPlot/index.js +2 -2
- package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableFromScatterPlotData.js +2 -2
- package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableWithDataClassesFromScatterPlotData.d.ts.map +1 -1
- package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableWithDataClassesFromScatterPlotData.js +9 -2
- package/lib/exercises/math/derivation/derivative/exp/secondDerivativeOfExpoFunction.js +1 -1
- package/lib/exercises/math/derivation/derivative/trigo/index.d.ts +1 -0
- package/lib/exercises/math/derivation/derivative/trigo/index.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/trigo/index.js +1 -1
- package/lib/exercises/math/derivation/derivative/trigo/productOfSinAXPlusBCosCXPlusDDerivative.js +1 -1
- package/lib/exercises/math/derivation/derivative/trigo/sinAndCosMixedWithSquareDerivative.js +1 -1
- package/lib/exercises/math/derivation/derivative/trigo/sinCosDerivativeRewriteUsingCos2PlusSin2Equals1.js +1 -1
- package/lib/exercises/math/derivation/problems/index.d.ts +1 -0
- package/lib/exercises/math/derivation/problems/index.d.ts.map +1 -1
- package/lib/exercises/math/derivation/problems/index.js +1 -1
- package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.d.ts.map +1 -1
- package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.js +31 -21
- package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineY.d.ts.map +1 -1
- package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineY.js +8 -128
- package/lib/exercises/math/derivation/tangent/index.d.ts +1 -0
- package/lib/exercises/math/derivation/tangent/index.d.ts.map +1 -1
- package/lib/exercises/math/derivation/tangent/index.js +1 -1
- package/lib/exercises/math/derivation/variations/index.d.ts +1 -0
- package/lib/exercises/math/derivation/variations/index.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/index.js +1 -1
- package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.js +47 -20
- package/lib/exercises/math/equaDiff/equaDiffAyPlusB.d.ts.map +1 -1
- package/lib/exercises/math/equaDiff/equaDiffAyPlusB.js +29 -6
- package/lib/exercises/math/equaDiff/equaDiffCheckSolutionFirstOrder.d.ts.map +1 -1
- package/lib/exercises/math/equaDiff/equaDiffCheckSolutionFirstOrder.js +33 -0
- package/lib/exercises/math/equaDiff/exponentialDifferentialEquation.d.ts +7 -0
- package/lib/exercises/math/equaDiff/exponentialDifferentialEquation.d.ts.map +1 -0
- package/lib/exercises/math/equaDiff/exponentialDifferentialEquation.js +86 -0
- package/lib/exercises/math/equaDiff/exponentialDifferentialEquationWithIC.d.ts.map +1 -1
- package/lib/exercises/math/equaDiff/exponentialDifferentialEquationWithIC.js +35 -7
- package/lib/exercises/math/equaDiff/index.d.ts +1 -1
- package/lib/exercises/math/equaDiff/index.d.ts.map +1 -1
- package/lib/exercises/math/equaDiff/index.js +1 -1
- package/lib/exercises/math/functions/integral/integralExpU.d.ts.map +1 -1
- package/lib/exercises/math/functions/integral/integralExpU.js +48 -0
- package/lib/exercises/math/functions/integral/integralFractions.d.ts.map +1 -1
- package/lib/exercises/math/functions/integral/integralFractions.js +52 -0
- package/lib/exercises/math/functions/integral/integralTrinomials.d.ts.map +1 -1
- package/lib/exercises/math/functions/integral/integralTrinomials.js +40 -0
- package/lib/exercises/math/functions/logarithm/log10Simplifying.js +2 -2
- package/lib/exercises/math/functions/logarithm/powerEquation.js +1 -1
- package/lib/exercises/math/geometry/angles/anglesUsingIsParallel.d.ts.map +1 -1
- package/lib/exercises/math/geometry/angles/anglesUsingIsParallel.js +172 -51
- package/lib/exercises/math/geometry/angles/index.d.ts +1 -0
- package/lib/exercises/math/geometry/angles/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/angles/index.js +1 -1
- package/lib/exercises/math/geometry/parametric/extractVectorFromParametricLine.d.ts.map +1 -1
- package/lib/exercises/math/geometry/parametric/extractVectorFromParametricLine.js +30 -25
- package/lib/exercises/math/geometry/parametric/pointFromParametricLine.d.ts.map +1 -1
- package/lib/exercises/math/geometry/parametric/pointFromParametricLine.js +52 -5
- package/lib/exercises/math/integration/fromExpr/areaBetweenCrossingCurvesFixedPosFromExpr.d.ts.map +1 -1
- package/lib/exercises/math/integration/fromExpr/areaBetweenCrossingCurvesFixedPosFromExpr.js +26 -35
- package/lib/exercises/math/integration/fromExpr/index.d.ts +1 -0
- package/lib/exercises/math/integration/fromExpr/index.d.ts.map +1 -1
- package/lib/exercises/math/integration/fromExpr/index.js +1 -1
- package/lib/exercises/math/limits/index.d.ts +1 -5
- package/lib/exercises/math/limits/index.d.ts.map +1 -1
- package/lib/exercises/math/limits/index.js +1 -5
- package/lib/exercises/math/limits/limitReading.d.ts.map +1 -1
- package/lib/exercises/math/limits/limitReading.js +70 -0
- package/lib/exercises/math/limits/polynomLimit.d.ts.map +1 -1
- package/lib/exercises/math/limits/polynomLimit.js +55 -4
- package/lib/exercises/math/limits/polynomLimitNoFI.d.ts.map +1 -1
- package/lib/exercises/math/limits/polynomLimitNoFI.js +35 -2
- package/lib/exercises/math/limits/sequenceGeometricLimit.d.ts.map +1 -1
- package/lib/exercises/math/limits/sequenceGeometricLimit.js +45 -9
- package/lib/exercises/math/limits/sequencePolynomLimit.d.ts.map +1 -1
- package/lib/exercises/math/limits/sequencePolynomLimit.js +56 -3
- package/lib/exercises/math/limits/sequencePolynomNoFILimit.d.ts.map +1 -1
- package/lib/exercises/math/limits/sequencePolynomNoFILimit.js +32 -0
- package/lib/exercises/math/limits/sequencePolynomProductLimit.d.ts.map +1 -1
- package/lib/exercises/math/limits/sequencePolynomProductLimit.js +33 -3
- package/lib/exercises/math/limits/sequenceRationalFracLimit.d.ts.map +1 -1
- package/lib/exercises/math/limits/sequenceRationalFracLimit.js +2 -2
- package/lib/exercises/math/limits/sequences/index.d.ts +6 -0
- package/lib/exercises/math/limits/sequences/index.d.ts.map +1 -0
- package/lib/exercises/math/limits/sequences/index.js +5 -0
- package/lib/exercises/math/limits/sequences/sequenceGeometricLimit.d.ts +9 -0
- package/lib/exercises/math/limits/sequences/sequenceGeometricLimit.d.ts.map +1 -0
- package/lib/exercises/math/limits/sequences/sequenceGeometricLimit.js +110 -0
- package/lib/exercises/math/limits/sequences/sequencePolynomLimit.d.ts +7 -0
- package/lib/exercises/math/limits/sequences/sequencePolynomLimit.d.ts.map +1 -0
- package/lib/exercises/math/limits/sequences/sequencePolynomLimit.js +116 -0
- package/lib/exercises/math/limits/sequences/sequencePolynomNoFILimit.d.ts +7 -0
- package/lib/exercises/math/limits/sequences/sequencePolynomNoFILimit.d.ts.map +1 -0
- package/lib/exercises/math/limits/sequences/sequencePolynomNoFILimit.js +95 -0
- package/lib/exercises/math/limits/sequences/sequencePolynomProductLimit.d.ts +8 -0
- package/lib/exercises/math/limits/sequences/sequencePolynomProductLimit.d.ts.map +1 -0
- package/lib/exercises/math/limits/sequences/sequencePolynomProductLimit.js +111 -0
- package/lib/exercises/math/limits/sequences/sequenceRationalFracLimit.d.ts +8 -0
- package/lib/exercises/math/limits/sequences/sequenceRationalFracLimit.d.ts.map +1 -0
- package/lib/exercises/math/limits/sequences/sequenceRationalFracLimit.js +114 -0
- package/lib/exercises/math/primitive/constantPrimitive.d.ts.map +1 -1
- package/lib/exercises/math/primitive/constantPrimitive.js +25 -1
- package/lib/exercises/math/primitive/exponentialPrimitive.d.ts.map +1 -1
- package/lib/exercises/math/primitive/exponentialPrimitive.js +17 -0
- package/lib/exercises/math/primitive/polynomialPrimitive.d.ts.map +1 -1
- package/lib/exercises/math/primitive/polynomialPrimitive.js +17 -1
- package/lib/exercises/math/primitive/sinCosPrimitive.d.ts.map +1 -1
- package/lib/exercises/math/primitive/sinCosPrimitive.js +20 -1
- package/lib/exercises/math/primitive/usualPrimitives.d.ts.map +1 -1
- package/lib/exercises/math/primitive/usualPrimitives.js +1 -0
- package/lib/exercises/math/sequences/index.d.ts +1 -0
- package/lib/exercises/math/sequences/index.d.ts.map +1 -1
- package/lib/exercises/math/sequences/index.js +1 -0
- package/lib/exercises/math/sequences/proofByInduction/index.d.ts +5 -0
- package/lib/exercises/math/sequences/proofByInduction/index.d.ts.map +1 -0
- package/lib/exercises/math/sequences/proofByInduction/index.js +4 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionCheckInitialization.d.ts +10 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionCheckInitialization.d.ts.map +1 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionCheckInitialization.js +236 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionReorderProof.d.ts +13 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionReorderProof.d.ts.map +1 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionReorderProof.js +244 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionSituations.d.ts +98 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionSituations.d.ts.map +1 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionSituations.js +175 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionWriteMissingStep.d.ts +13 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionWriteMissingStep.d.ts.map +1 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionWriteMissingStep.js +317 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionWritePropAtRankKPlus1.d.ts +13 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionWritePropAtRankKPlus1.d.ts.map +1 -0
- package/lib/exercises/math/sequences/proofByInduction/proofByInductionWritePropAtRankKPlus1.js +265 -0
- package/lib/exercises/math/sets/cartesianProduct/findCardinalOfCartesianProductOfFiniteSets.js +4 -4
- package/lib/exercises/math/sets/cartesianProduct/findCardinalOfCartesianProductOfFiniteSetsFromSituation.js +3 -3
- package/lib/exercises/math/sets/cartesianProduct/proposeElementInCartesianProductOfFiniteSets.js +4 -4
- package/lib/exercises/math/spaceGeometry/basis/spaceCoordinatesOfPointInCubeCoordSystemFromVecPath.js +1 -1
- package/lib/exercises/math/spaceGeometry/orthogonalProjection/findOrthogonalProjectionOfPointOnPlane.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/orthogonalProjection/findOrthogonalProjectionOfPointOnPlane.js +12 -25
- package/lib/exercises/math/spaceGeometry/orthogonalProjection/index.d.ts +1 -1
- package/lib/exercises/math/spaceGeometry/orthogonalProjection/index.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/orthogonalProjection/index.js +1 -2
- package/lib/exercises/math/spaceGeometry/planes/findNormalVectorFromPlanePointsCoords.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/planes/findNormalVectorFromPlanePointsCoords.js +11 -26
- package/lib/exercises/math/spaceGeometry/planes/index.d.ts +1 -0
- package/lib/exercises/math/spaceGeometry/planes/index.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/planes/index.js +1 -1
- package/lib/exercises/math/spaceGeometry/planes/planePlaneRelativePositions.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/planes/planePlaneRelativePositions.js +11 -25
- package/lib/exercises/math/spaceGeometry/scalarProduct/angleFromScalarProductFromSpacePointCoords.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/scalarProduct/angleFromScalarProductFromSpacePointCoords.js +25 -5
- package/lib/exercises/math/spaceGeometry/scalarProduct/index.d.ts +1 -0
- package/lib/exercises/math/spaceGeometry/scalarProduct/index.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/scalarProduct/index.js +1 -1
- package/lib/exercises/math/spaceGeometry/vectors/findLinearDecompositionWrtCoplanarUVFromCoords.js +2 -2
- package/lib/exercises/math/trigonometry/functions/equationCosOnRandomInterval.d.ts.map +1 -1
- package/lib/exercises/math/trigonometry/functions/equationCosOnRandomInterval.js +87 -24
- package/lib/exercises/pc/mathExosInPC.d.ts +1 -1
- package/lib/exercises/pc/mathExosInPC.d.ts.map +1 -1
- package/lib/exercises/pc/mathExosInPC.js +1 -1
- package/lib/exercises/vea/polynomialVEA.d.ts.map +1 -1
- package/lib/exercises/vea/polynomialVEA.js +4 -0
- package/lib/index.d.ts +104 -13
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/point.js +1 -1
- package/lib/math/geometry/spaceVector.d.ts +2 -0
- package/lib/math/geometry/spaceVector.d.ts.map +1 -1
- package/lib/math/geometry/spaceVector.js +40 -0
- package/lib/math/utils/functions/functionDecomposition.d.ts +2 -2
- package/lib/math/utils/functions/functionDecomposition.d.ts.map +1 -1
- package/lib/math/utils/polynomial/polynomialUtils.d.ts +2 -2
- package/lib/math/utils/polynomial/polynomialUtils.d.ts.map +1 -1
- package/lib/math/utils/polynomial/polynomialUtils.js +5 -2
- package/lib/tests/exoTest.d.ts.map +1 -1
- package/lib/tests/exoTest.js +8 -12
- package/lib/tests/questionTest.d.ts.map +1 -1
- package/lib/tests/questionTest.js +14 -6
- package/lib/tests/singleExo.test.js +2 -2
- package/lib/tree/nodes/node.d.ts +2 -1
- package/lib/tree/nodes/node.d.ts.map +1 -1
- package/lib/tree/nodes/node.js +1 -0
- package/lib/tree/nodes/student/iDontKnowNode.d.ts +26 -0
- package/lib/tree/nodes/student/iDontKnowNode.d.ts.map +1 -0
- package/lib/tree/nodes/student/iDontKnowNode.js +63 -0
- package/lib/tree/parsers/latexParser.d.ts +3 -2
- package/lib/tree/parsers/latexParser.d.ts.map +1 -1
- package/lib/tree/parsers/latexParser.js +7 -0
- package/lib/tree/parsers/monomParser.d.ts +1 -1
- package/lib/tree/parsers/monomParser.d.ts.map +1 -1
- package/lib/tree/parsers/polynomialParser.d.ts +1 -1
- package/lib/tree/parsers/polynomialParser.d.ts.map +1 -1
- package/lib/tree/parsers/trinomParser.d.ts +1 -1
- package/lib/tree/parsers/trinomParser.d.ts.map +1 -1
- package/lib/tree/utilities/nodeComparator.d.ts +3 -1
- package/lib/tree/utilities/nodeComparator.d.ts.map +1 -1
- package/lib/tree/utilities/nodeComparator.js +68 -8
- package/lib/tree/utilities/nodeSimplifier.d.ts +1 -0
- package/lib/tree/utilities/nodeSimplifier.d.ts.map +1 -1
- package/lib/tree/utilities/nodeSimplifier.js +40 -0
- package/package.json +1 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { NodeIds, NodeType } from "../node.js";
|
|
2
|
+
export function isIDontKnowNode(a) {
|
|
3
|
+
return a.type === NodeType.iDontKnow;
|
|
4
|
+
}
|
|
5
|
+
export class IDontKnowNode {
|
|
6
|
+
tex;
|
|
7
|
+
type;
|
|
8
|
+
isNumeric;
|
|
9
|
+
constructor(tex) {
|
|
10
|
+
this.tex = tex;
|
|
11
|
+
this.isNumeric = false;
|
|
12
|
+
this.type = NodeType.iDontKnow;
|
|
13
|
+
}
|
|
14
|
+
static keyword() {
|
|
15
|
+
return "N.S.P";
|
|
16
|
+
}
|
|
17
|
+
toMathString() {
|
|
18
|
+
throw new Error("can't create mathString from IDontKnowNode");
|
|
19
|
+
}
|
|
20
|
+
toTex() {
|
|
21
|
+
return `${this.tex}`;
|
|
22
|
+
}
|
|
23
|
+
// toMathjs() {
|
|
24
|
+
// return parse(this.mathString);
|
|
25
|
+
// }
|
|
26
|
+
toAllValidTexs() {
|
|
27
|
+
return this.toEquivalentNodes().map((node) => node.toTex());
|
|
28
|
+
}
|
|
29
|
+
toIdentifiers() {
|
|
30
|
+
return {
|
|
31
|
+
id: NodeIds.constant,
|
|
32
|
+
tex: this.tex,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
toEquivalentNodes() {
|
|
36
|
+
return [this];
|
|
37
|
+
}
|
|
38
|
+
evaluate() {
|
|
39
|
+
return NaN;
|
|
40
|
+
}
|
|
41
|
+
simplify(_opts) {
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
toSimplificationTex(opts) {
|
|
45
|
+
const simp = this.simplify(opts);
|
|
46
|
+
if (simp.toTex() !== this.toTex())
|
|
47
|
+
return this.toTex() + "=" + simp.toTex();
|
|
48
|
+
return this.toTex();
|
|
49
|
+
}
|
|
50
|
+
equals(node) {
|
|
51
|
+
return isIDontKnowNode(node) && node.tex === this.tex;
|
|
52
|
+
}
|
|
53
|
+
toDetailedEvaluation(vars) {
|
|
54
|
+
//?utile pour des trucs genre 3Pi+4 --> 3*3.14+4
|
|
55
|
+
return vars[this.tex] ?? this;
|
|
56
|
+
}
|
|
57
|
+
derivative() {
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
toSignInequationTex() {
|
|
61
|
+
return "";
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { AlgebraicNode } from "../nodes/algebraicNode.js";
|
|
2
2
|
import { EqualNode } from "../nodes/equations/equalNode.js";
|
|
3
3
|
import { InequationNode } from "../nodes/inequations/inequationNode.js";
|
|
4
|
+
import { IDontKnowNode } from "../nodes/student/iDontKnowNode.js";
|
|
4
5
|
export declare const tokenize: (latex: string) => string[];
|
|
5
6
|
type ParserOptions = {
|
|
6
7
|
allowStartingPower?: boolean;
|
|
7
8
|
};
|
|
8
|
-
export declare const parseAlgebraic: (latex: string, opts?: ParserOptions) => AlgebraicNode;
|
|
9
|
-
export declare const parseLatex: (latex: string) => AlgebraicNode | EqualNode | InequationNode;
|
|
9
|
+
export declare const parseAlgebraic: (latex: string, opts?: ParserOptions) => AlgebraicNode | IDontKnowNode;
|
|
10
|
+
export declare const parseLatex: (latex: string) => AlgebraicNode | EqualNode | InequationNode | IDontKnowNode;
|
|
10
11
|
export {};
|
|
11
12
|
//# sourceMappingURL=latexParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latexParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/latexParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAQ5D,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"latexParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/latexParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAQ5D,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAgBxE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AA2DlE,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,aAwDrC,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AACF,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,EAAE,OAAO,aAAa,kCA4BjE,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,+DA6CvC,CAAC"}
|
|
@@ -16,6 +16,7 @@ import { FractionNode } from "../nodes/operators/fractionNode.js";
|
|
|
16
16
|
import { MultiplyNode, isMultiplyNode, } from "../nodes/operators/multiplyNode.js";
|
|
17
17
|
import { PowerNode } from "../nodes/operators/powerNode.js";
|
|
18
18
|
import { SubstractNode } from "../nodes/operators/substractNode.js";
|
|
19
|
+
import { IDontKnowNode } from "../nodes/student/iDontKnowNode.js";
|
|
19
20
|
import { VariableNode } from "../nodes/variables/variableNode.js";
|
|
20
21
|
//cmds that needs a child, like \exp{3}
|
|
21
22
|
const functions = [
|
|
@@ -125,6 +126,9 @@ export const tokenize = (latex) => {
|
|
|
125
126
|
};
|
|
126
127
|
export const parseAlgebraic = (latex, opts) => {
|
|
127
128
|
// console.log("parsingAlg ", latex);
|
|
129
|
+
if (latex.includes(IDontKnowNode.keyword())) {
|
|
130
|
+
return new IDontKnowNode(latex);
|
|
131
|
+
}
|
|
128
132
|
let formatedLatex = latex;
|
|
129
133
|
if (!opts?.allowStartingPower && latex.startsWith("^")) {
|
|
130
134
|
if (latex[1] === "{") {
|
|
@@ -151,6 +155,9 @@ export const parseAlgebraic = (latex, opts) => {
|
|
|
151
155
|
};
|
|
152
156
|
export const parseLatex = (latex) => {
|
|
153
157
|
// console.log("parsingLatex ", latex);
|
|
158
|
+
if (latex.includes(IDontKnowNode.keyword())) {
|
|
159
|
+
return new IDontKnowNode(latex);
|
|
160
|
+
}
|
|
154
161
|
const formattedLatex = latex
|
|
155
162
|
.replaceAll("\\left", "")
|
|
156
163
|
.replaceAll("\\right", "");
|
|
@@ -3,6 +3,6 @@ type Opts = {
|
|
|
3
3
|
maxDegree?: number;
|
|
4
4
|
minDegree?: number;
|
|
5
5
|
};
|
|
6
|
-
export declare const monomParser: (str: string, { variable, maxDegree, minDegree }?: Opts) => false | import("../nodes/algebraicNode.js").AlgebraicNode;
|
|
6
|
+
export declare const monomParser: (str: string, { variable, maxDegree, minDegree }?: Opts) => false | import("../nodes/algebraicNode.js").AlgebraicNode | import("../nodes/student/iDontKnowNode.js").IDontKnowNode;
|
|
7
7
|
export {};
|
|
8
8
|
//# sourceMappingURL=monomParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monomParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/monomParser.ts"],"names":[],"mappings":"AAIA,KAAK,IAAI,GAAG;IACV,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AACF,eAAO,MAAM,WAAW,GACtB,KAAK,MAAM,EACX,qCAAoC,IAInC,
|
|
1
|
+
{"version":3,"file":"monomParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/monomParser.ts"],"names":[],"mappings":"AAIA,KAAK,IAAI,GAAG;IACV,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AACF,eAAO,MAAM,WAAW,GACtB,KAAK,MAAM,EACX,qCAAoC,IAInC,0HAaF,CAAC"}
|
|
@@ -2,6 +2,6 @@ import { AlgebraicNode } from "../nodes/algebraicNode.js";
|
|
|
2
2
|
type Opts = {
|
|
3
3
|
variable?: string;
|
|
4
4
|
};
|
|
5
|
-
export declare const polynomialParser: (ans: string, opts?: Opts) => false | AlgebraicNode | import("../nodes/numbers/constantNode.js").ConstantNode | import("../nodes/numbers/numberNode.js").NumberNode | import("../nodes/operators/substractNode.js").SubstractNode | import("../nodes/operators/addNode.js").AddNode;
|
|
5
|
+
export declare const polynomialParser: (ans: string, opts?: Opts) => false | AlgebraicNode | import("../nodes/numbers/constantNode.js").ConstantNode | import("../nodes/numbers/numberNode.js").NumberNode | import("../nodes/operators/substractNode.js").SubstractNode | import("../nodes/operators/addNode.js").AddNode | import("../nodes/student/iDontKnowNode.js").IDontKnowNode;
|
|
6
6
|
export {};
|
|
7
7
|
//# sourceMappingURL=polynomialParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polynomialParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/polynomialParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAS1D,KAAK,IAAI,GAAG;IACV,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAIF,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,EAAE,OAAO,IAAI,
|
|
1
|
+
{"version":3,"file":"polynomialParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/polynomialParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAS1D,KAAK,IAAI,GAAG;IACV,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAIF,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,EAAE,OAAO,IAAI,sTAkCxD,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const trinomParser: (ans: string, variable?: string) => false | import("../nodes/algebraicNode.js").AlgebraicNode | undefined;
|
|
1
|
+
export declare const trinomParser: (ans: string, variable?: string) => false | import("../nodes/algebraicNode.js").AlgebraicNode | import("../nodes/student/iDontKnowNode.js").IDontKnowNode | undefined;
|
|
2
2
|
//# sourceMappingURL=trinomParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trinomParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/trinomParser.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,EAAE,WAAU,MAAY,
|
|
1
|
+
{"version":3,"file":"trinomParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/trinomParser.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,EAAE,WAAU,MAAY,sIAgC/D,CAAC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Tuple } from "../../math/sets/tuple.js";
|
|
2
2
|
import { AlgebraicNode } from "../nodes/algebraicNode.js";
|
|
3
3
|
import { DiscreteSetNode } from "../nodes/sets/discreteSetNode.js";
|
|
4
|
+
import { VariableNode } from "../nodes/variables/variableNode.js";
|
|
4
5
|
export declare abstract class NodeComparator {
|
|
5
6
|
static compareViaSub: <T extends AlgebraicNode>(node1: T, node2: T) => -1 | 0 | 1;
|
|
6
7
|
static isEqualViaSub: (node1: AlgebraicNode, node2: AlgebraicNode) => boolean;
|
|
7
8
|
static isEqualViaFrac: (node1: AlgebraicNode, node2: AlgebraicNode) => boolean;
|
|
8
|
-
static isEqualViaRandomEvaluations(node1: AlgebraicNode, node2: AlgebraicNode, nbRandomEvaluations: number): boolean;
|
|
9
|
+
static isEqualViaRandomEvaluations(node1: AlgebraicNode, node2: AlgebraicNode, nbRandomEvaluations: number, precision?: number, nodeVar?: VariableNode, randFunc?: () => number): boolean;
|
|
10
|
+
static isEqualViaRandomSubstitutions(node1: AlgebraicNode, node2: AlgebraicNode, nbRandomEvaluations: number, nodeVar?: VariableNode): boolean;
|
|
9
11
|
static isNodeInDiscreteSet: (node: AlgebraicNode, nodeDiscreteSet: DiscreteSetNode) => boolean;
|
|
10
12
|
static isTupleInCartesianProductOfDiscreteSets: (tuple: Tuple, arrDiscreteSet: DiscreteSetNode[]) => boolean;
|
|
11
13
|
static isEqualTuple: (tuple1: Tuple, tuple2: Tuple) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeComparator.d.ts","sourceRoot":"","sources":["../../../src/tree/utilities/nodeComparator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"nodeComparator.d.ts","sourceRoot":"","sources":["../../../src/tree/utilities/nodeComparator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAIjD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAI1D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAMlE,8BAAsB,cAAc;IAGlC,MAAM,CAAC,aAAa,GAAI,CAAC,SAAS,aAAa,EAC7C,OAAO,CAAC,EACR,OAAO,CAAC,KACP,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CA4DX;IAEF,MAAM,CAAC,aAAa,GAClB,OAAO,aAAa,EACpB,OAAO,aAAa,KACnB,OAAO,CAMR;IAIF,MAAM,CAAC,cAAc,GACnB,OAAO,aAAa,EACpB,OAAO,aAAa,KACnB,OAAO,CAoBR;IASF,MAAM,CAAC,2BAA2B,CAChC,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,aAAa,EACpB,mBAAmB,EAAE,MAAM,EAC3B,SAAS,GAAE,MAAU,EACrB,OAAO,GAAE,YAAoC,EAC7C,QAAQ,GAAE,MAAM,MAAqC;IA2EvD,MAAM,CAAC,6BAA6B,CAClC,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,aAAa,EACpB,mBAAmB,EAAE,MAAM,EAC3B,OAAO,GAAE,YAAoC;IAmE/C,MAAM,CAAC,mBAAmB,GACxB,MAAM,aAAa,EACnB,iBAAiB,eAAe,aAI9B;IAEJ,MAAM,CAAC,uCAAuC,GAC5C,OAAO,KAAK,EACZ,gBAAgB,eAAe,EAAE,aAQjC;IAIF,MAAM,CAAC,YAAY,GAAI,QAAQ,KAAK,EAAE,QAAQ,KAAK,aAIjD;IAEF,MAAM,CAAC,iBAAiB,GAAI,OAAO,KAAK,EAAE,UAAU,KAAK,EAAE,aAMzD;CACH"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { nodeBySubstitutingVar } from "../../math/utils/functions/functionComposition.js";
|
|
1
2
|
import { randfloat } from "../../math/utils/random/randfloat.js";
|
|
2
3
|
import { zip } from "../../utils/arrays/arrayZip.js";
|
|
3
4
|
import { isInfiniteNode } from "../nodes/numbers/constantNode.js";
|
|
4
5
|
import { frac } from "../nodes/operators/fractionNode.js";
|
|
5
6
|
import { substract } from "../nodes/operators/substractNode.js";
|
|
7
|
+
import { VariableNode } from "../nodes/variables/variableNode.js";
|
|
6
8
|
import { NodeRewriter } from "./nodeRewriter.js";
|
|
7
9
|
import { NodeSimplifier } from "./nodeSimplifier.js";
|
|
10
|
+
import { round } from "../../math/utils/round.js";
|
|
11
|
+
import { isIDontKnowNode } from "../nodes/student/iDontKnowNode.js";
|
|
8
12
|
export class NodeComparator {
|
|
9
13
|
//via sub
|
|
10
14
|
static compareViaSub = (node1, node2) => {
|
|
@@ -70,10 +74,16 @@ export class NodeComparator {
|
|
|
70
74
|
}
|
|
71
75
|
};
|
|
72
76
|
static isEqualViaSub = (node1, node2) => {
|
|
77
|
+
if (isIDontKnowNode(node1) || isIDontKnowNode(node2)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
73
80
|
return this.compareViaSub(node1, node2) === 0;
|
|
74
81
|
};
|
|
75
82
|
//via frac
|
|
76
83
|
static isEqualViaFrac = (node1, node2) => {
|
|
84
|
+
if (isIDontKnowNode(node1) || isIDontKnowNode(node2)) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
77
87
|
const [arrNode1, arrNode2] = [node1, node2].map((node) => NodeRewriter.getArrNodeEquivalent(node));
|
|
78
88
|
return arrNode1.some((node1Equivalent) => {
|
|
79
89
|
return arrNode2.some((node2Equivalent) => {
|
|
@@ -89,27 +99,37 @@ export class NodeComparator {
|
|
|
89
99
|
});
|
|
90
100
|
};
|
|
91
101
|
//via random evaluations
|
|
92
|
-
|
|
93
|
-
|
|
102
|
+
/*
|
|
103
|
+
Spoiler alert: (-2)^1.96 = NaN
|
|
104
|
+
Be sure to always use positive integer exponents when dealing with negative numbers
|
|
105
|
+
*/
|
|
106
|
+
static isEqualViaRandomEvaluations(node1, node2, nbRandomEvaluations, precision = 8, nodeVar = new VariableNode("x"), randFunc = () => randfloat(-20, 100, 3)) {
|
|
107
|
+
if (isIDontKnowNode(node1) || isIDontKnowNode(node2)) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
const getSafeEvaluationDictForEqualityCheck = (node1, node2, nbSafeX = nbRandomEvaluations) => {
|
|
94
111
|
const dict = {};
|
|
95
112
|
let counter = -1;
|
|
96
113
|
while (Object.keys(dict).length < nbSafeX && counter < 1000) {
|
|
97
114
|
counter++;
|
|
98
|
-
const x =
|
|
115
|
+
const x = randFunc();
|
|
99
116
|
let value1;
|
|
100
117
|
let value2;
|
|
101
118
|
try {
|
|
102
|
-
value1 = node1.evaluate({ x });
|
|
119
|
+
value1 = node1.evaluate({ [nodeVar.name]: x });
|
|
103
120
|
}
|
|
104
121
|
catch (_) {
|
|
105
122
|
continue;
|
|
106
123
|
}
|
|
107
124
|
try {
|
|
108
|
-
value2 = node2.evaluate({ x });
|
|
125
|
+
value2 = node2.evaluate({ [nodeVar.name]: x });
|
|
109
126
|
}
|
|
110
127
|
catch (_) {
|
|
111
128
|
continue;
|
|
112
129
|
}
|
|
130
|
+
// console.log("x", x);
|
|
131
|
+
// console.log("value1", value1);
|
|
132
|
+
// console.log("value2", value2);
|
|
113
133
|
const [isValidValue1, isValidValue2] = [value1, value2].map((value) => value !== undefined &&
|
|
114
134
|
!isNaN(value) &&
|
|
115
135
|
!isInfiniteNode(value.toTree()));
|
|
@@ -125,9 +145,49 @@ export class NodeComparator {
|
|
|
125
145
|
return dict;
|
|
126
146
|
};
|
|
127
147
|
return Object.values(getSafeEvaluationDictForEqualityCheck(node1, node2, nbRandomEvaluations)).every((arrSafeEval) => {
|
|
128
|
-
return arrSafeEval
|
|
129
|
-
.
|
|
130
|
-
.
|
|
148
|
+
return arrSafeEval.slice(1).every((safeEval) => {
|
|
149
|
+
const valueSubRounded = round(substract(arrSafeEval[0].value, safeEval.value).evaluate(), precision);
|
|
150
|
+
// console.log("valueSubRounded", valueSubRounded);
|
|
151
|
+
return valueSubRounded === 0;
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
//via random substitutions
|
|
156
|
+
static isEqualViaRandomSubstitutions(node1, node2, nbRandomEvaluations, nodeVar = new VariableNode("x")) {
|
|
157
|
+
if (isIDontKnowNode(node1) || isIDontKnowNode(node2)) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
const getSafeEvaluationDictForEqualityCheck = (node1, node2, nbSafeX = nbRandomEvaluations) => {
|
|
161
|
+
const dict = {};
|
|
162
|
+
let counter = -1;
|
|
163
|
+
while (Object.keys(dict).length < nbSafeX && counter < 1000) {
|
|
164
|
+
counter++;
|
|
165
|
+
const x = randfloat(-20, 100, 3);
|
|
166
|
+
const [nodeSubstituted1, nodeSubstituted2] = [node1, node2].map((node) => nodeBySubstitutingVar(node, x.toTree(), nodeVar));
|
|
167
|
+
const [isValidValue1, isValidValue2] = [
|
|
168
|
+
nodeSubstituted1,
|
|
169
|
+
nodeSubstituted2,
|
|
170
|
+
].map((nodeSubstituted) => {
|
|
171
|
+
const value = nodeSubstituted.evaluate();
|
|
172
|
+
return value !== undefined && !isInfiniteNode(value.toTree());
|
|
173
|
+
});
|
|
174
|
+
const isValidEvaluation = isValidValue1 && isValidValue2;
|
|
175
|
+
if (isValidEvaluation) {
|
|
176
|
+
dict[x] = [nodeSubstituted1, nodeSubstituted2].map((nodeSubstituted) => {
|
|
177
|
+
return {
|
|
178
|
+
x,
|
|
179
|
+
nodeSubstituted,
|
|
180
|
+
};
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return dict;
|
|
185
|
+
};
|
|
186
|
+
return Object.values(getSafeEvaluationDictForEqualityCheck(node1, node2, nbRandomEvaluations)).every((arrSafeEval) => {
|
|
187
|
+
return arrSafeEval.slice(1).every((safeEval) => {
|
|
188
|
+
const isEqualNodes = NodeComparator.isEqualViaSub(arrSafeEval[0].nodeSubstituted, safeEval.nodeSubstituted);
|
|
189
|
+
return isEqualNodes;
|
|
190
|
+
});
|
|
131
191
|
});
|
|
132
192
|
}
|
|
133
193
|
//discreteSets, etc.
|
|
@@ -11,5 +11,6 @@ export declare abstract class NodeSimplifier {
|
|
|
11
11
|
isMultiTopLevel: boolean;
|
|
12
12
|
}, toTexOpts?: ToTexOptions) => string[];
|
|
13
13
|
static simplifyByVibrating(algebraicNode: AlgebraicNode, nbVibrations?: number, isTowardsDistribute?: boolean): AlgebraicNode;
|
|
14
|
+
static simplifyByInfiltrating(algebraicNode: AlgebraicNode, simplifyOpts: SimplifyOptions): AlgebraicNode;
|
|
14
15
|
}
|
|
15
16
|
//# sourceMappingURL=nodeSimplifier.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeSimplifier.d.ts","sourceRoot":"","sources":["../../../src/tree/utilities/nodeSimplifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAiB3E,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAKhD,8BAAsB,cAAc;IAClC,MAAM,CAAC,QAAQ,GAAI,CAAC,SAAS,aAAa,EACxC,eAAe,CAAC,EAChB,cAAc,eAAe,EAC7B,eAAc,YAIb,KACA,MAAM,CAsBP;IAEF,MAAM,CAAC,iBAAiB,GAAI,eAAe,aAAa,sCAmCtD;IAEF,MAAM,CAAC,8BAA8B,GAAI,OAAO,aAAa,EAAE,qBAK7D;IAEF,MAAM,CAAC,eAAe,GAAI,CAAC,SAAS,aAAa,EAC/C,eAAe,CAAC,EAChB,cAAc,eAAe,EAC7B,iBAAgB;QACd,eAAe,EAAE,OAAO,CAAC;KAG1B,EACD,YAAW,YAIV,KACA,aAAa,EAAE,CA4JhB;IAEF,MAAM,CAAC,gBAAgB,GACrB,MAAM,aAAa,EACnB,eAAc,eAAoB,EAClC,iBAAgB;QACd,eAAe,EAAE,OAAO,CAAC;KAG1B,EACD,YAAW,YAIV,cAQD;IAEF,MAAM,CAAC,mBAAmB,CACxB,aAAa,EAAE,aAAa,EAC5B,YAAY,GAAE,MAAU,EACxB,mBAAmB,GAAE,OAAc,GAClC,aAAa;
|
|
1
|
+
{"version":3,"file":"nodeSimplifier.d.ts","sourceRoot":"","sources":["../../../src/tree/utilities/nodeSimplifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAiB3E,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAKhD,8BAAsB,cAAc;IAClC,MAAM,CAAC,QAAQ,GAAI,CAAC,SAAS,aAAa,EACxC,eAAe,CAAC,EAChB,cAAc,eAAe,EAC7B,eAAc,YAIb,KACA,MAAM,CAsBP;IAEF,MAAM,CAAC,iBAAiB,GAAI,eAAe,aAAa,sCAmCtD;IAEF,MAAM,CAAC,8BAA8B,GAAI,OAAO,aAAa,EAAE,qBAK7D;IAEF,MAAM,CAAC,eAAe,GAAI,CAAC,SAAS,aAAa,EAC/C,eAAe,CAAC,EAChB,cAAc,eAAe,EAC7B,iBAAgB;QACd,eAAe,EAAE,OAAO,CAAC;KAG1B,EACD,YAAW,YAIV,KACA,aAAa,EAAE,CA4JhB;IAEF,MAAM,CAAC,gBAAgB,GACrB,MAAM,aAAa,EACnB,eAAc,eAAoB,EAClC,iBAAgB;QACd,eAAe,EAAE,OAAO,CAAC;KAG1B,EACD,YAAW,YAIV,cAQD;IAEF,MAAM,CAAC,mBAAmB,CACxB,aAAa,EAAE,aAAa,EAC5B,YAAY,GAAE,MAAU,EACxB,mBAAmB,GAAE,OAAc,GAClC,aAAa;IAehB,MAAM,CAAC,sBAAsB,CAC3B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,eAAe,GAC5B,aAAa;CAyDjB"}
|
|
@@ -209,4 +209,44 @@ export class NodeSimplifier {
|
|
|
209
209
|
return this.simplifyByVibrating(nodeSimplified, nbVibrations - 1, !isTowardsDistribute);
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
|
+
static simplifyByInfiltrating(algebraicNode, simplifyOpts) {
|
|
213
|
+
const outNode = (() => {
|
|
214
|
+
if (isOperatorNode(algebraicNode)) {
|
|
215
|
+
const [nodeLeft, nodeRight] = [
|
|
216
|
+
algebraicNode.leftChild,
|
|
217
|
+
algebraicNode.rightChild,
|
|
218
|
+
];
|
|
219
|
+
const isCanDiveDeeper = [nodeLeft, nodeRight].every((nodeChild) => isOperatorNode(nodeChild) || isFunctionNode(nodeChild));
|
|
220
|
+
if (isCanDiveDeeper) {
|
|
221
|
+
const [nodeLeftSimplified, nodeRightSimplified] = [
|
|
222
|
+
nodeLeft,
|
|
223
|
+
nodeRight,
|
|
224
|
+
].map((nodeChild) => this.simplifyByInfiltrating(nodeChild, simplifyOpts));
|
|
225
|
+
const funcMother = NodeRewriter.getArrCreateNodeFromChildrenFunction(algebraicNode).find(() => true);
|
|
226
|
+
return funcMother([nodeLeftSimplified, nodeRightSimplified]).simplify(simplifyOpts);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
return algebraicNode.simplify(simplifyOpts);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
else if (isFunctionNode(algebraicNode)) {
|
|
233
|
+
const nodeChild = algebraicNode.child;
|
|
234
|
+
const isCanDiveDeeper = [nodeChild].every((nodeChild) => isOperatorNode(nodeChild) || isFunctionNode(nodeChild));
|
|
235
|
+
if (isCanDiveDeeper) {
|
|
236
|
+
const [nodeChildSimplified] = [nodeChild].map((nodeChild) => this.simplifyByInfiltrating(nodeChild, simplifyOpts));
|
|
237
|
+
const funcMother = NodeRewriter.getArrCreateNodeFromChildrenFunction(algebraicNode).find(() => true);
|
|
238
|
+
return funcMother([nodeChildSimplified]).simplify(simplifyOpts);
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
return algebraicNode.simplify(simplifyOpts);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
return algebraicNode.simplify(simplifyOpts);
|
|
246
|
+
}
|
|
247
|
+
})();
|
|
248
|
+
// console.log("simplifyByInfiltrating", "nodeIn:", algebraicNode.toTex());
|
|
249
|
+
// console.log("simplifyByInfiltrating", "nodeOut:", outNode.toTex());
|
|
250
|
+
return outNode;
|
|
251
|
+
}
|
|
212
252
|
}
|