math-exercises 3.0.183 → 3.0.185
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/exercises/math/functions/composition/functionComposition.d.ts.map +1 -1
- package/lib/exercises/math/functions/composition/functionComposition.js +11 -22
- package/lib/exercises/math/functions/exponential/algebraic/approxExpAPlusB.d.ts.map +1 -1
- package/lib/exercises/math/functions/exponential/algebraic/approxExpAPlusB.js +91 -38
- package/lib/exercises/math/functions/exponential/algebraic/rewriteExpUsingExpA.d.ts.map +1 -1
- package/lib/exercises/math/functions/exponential/algebraic/rewriteExpUsingExpA.js +18 -3
- package/lib/exercises/math/functions/exponential/expKT/derivativeOfAExpKT.d.ts +8 -0
- package/lib/exercises/math/functions/exponential/expKT/derivativeOfAExpKT.d.ts.map +1 -0
- package/lib/exercises/math/functions/exponential/expKT/derivativeOfAExpKT.js +108 -0
- package/lib/exercises/math/functions/exponential/expKT/drugConcentrationMaximum.d.ts +8 -0
- package/lib/exercises/math/functions/exponential/expKT/drugConcentrationMaximum.d.ts.map +1 -0
- package/lib/exercises/math/functions/exponential/expKT/drugConcentrationMaximum.js +144 -0
- package/lib/exercises/math/functions/exponential/expKT/index.d.ts +3 -0
- package/lib/exercises/math/functions/exponential/expKT/index.d.ts.map +1 -0
- package/lib/exercises/math/functions/exponential/expKT/index.js +2 -0
- package/lib/exercises/math/functions/exponential/expSimplifiying.d.ts.map +1 -1
- package/lib/exercises/math/functions/exponential/expSimplifiying.js +94 -4
- package/lib/exercises/math/functions/exponential/index.d.ts +3 -0
- package/lib/exercises/math/functions/exponential/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/exponential/index.js +3 -0
- package/lib/exercises/math/functions/exponential/sign/expFunctionBasicSign.d.ts +9 -0
- package/lib/exercises/math/functions/exponential/sign/expFunctionBasicSign.d.ts.map +1 -0
- package/lib/exercises/math/functions/exponential/sign/expFunctionBasicSign.js +101 -0
- package/lib/exercises/math/functions/exponential/sign/index.d.ts +2 -0
- package/lib/exercises/math/functions/exponential/sign/index.d.ts.map +1 -0
- package/lib/exercises/math/functions/exponential/sign/index.js +1 -0
- package/lib/exercises/math/functions/exponential/variations/index.d.ts +3 -0
- package/lib/exercises/math/functions/exponential/variations/index.d.ts.map +1 -0
- package/lib/exercises/math/functions/exponential/variations/index.js +2 -0
- package/lib/exercises/math/functions/exponential/variations/varSignTableOfAffineTimesExp.d.ts +7 -0
- package/lib/exercises/math/functions/exponential/variations/varSignTableOfAffineTimesExp.d.ts.map +1 -0
- package/lib/exercises/math/functions/exponential/variations/varSignTableOfAffineTimesExp.js +144 -0
- package/lib/exercises/math/functions/exponential/variations/varSignTableOfExpMinusX.d.ts +7 -0
- package/lib/exercises/math/functions/exponential/variations/varSignTableOfExpMinusX.d.ts.map +1 -0
- package/lib/exercises/math/functions/exponential/variations/varSignTableOfExpMinusX.js +139 -0
- package/lib/exercises/math/probaStat/independancy/independantSuccessiveEventsComputeTwoSuccess.d.ts +7 -0
- package/lib/exercises/math/probaStat/independancy/independantSuccessiveEventsComputeTwoSuccess.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/independancy/independantSuccessiveEventsComputeTwoSuccess.js +100 -0
- package/lib/exercises/math/probaStat/independancy/index.d.ts +1 -0
- package/lib/exercises/math/probaStat/independancy/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/independancy/index.js +1 -0
- package/lib/exercises/math/probaStat/trees/index.d.ts +4 -1
- package/lib/exercises/math/probaStat/trees/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/trees/index.js +4 -11
- package/lib/exercises/math/probaStat/trees/probabilityTree.d.ts +9 -3
- package/lib/exercises/math/probaStat/trees/probabilityTree.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/trees/probabilityTree.js +419 -45
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.d.ts.map +1 -1
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.js +3 -3
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.d.ts.map +1 -1
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.js +2 -2
- package/lib/exercises/math/sequences/arithmetic/situations/index.d.ts +2 -0
- package/lib/exercises/math/sequences/arithmetic/situations/index.d.ts.map +1 -1
- package/lib/exercises/math/sequences/arithmetic/situations/index.js +2 -2
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoConsecutiveTerms.d.ts.map +1 -1
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoConsecutiveTerms.js +37 -39
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.d.ts.map +1 -1
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.js +14 -4
- package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.d.ts.map +1 -1
- package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.js +12 -3
- package/lib/exercises/vea/treeTableVEA.d.ts.map +1 -1
- package/lib/exercises/vea/treeTableVEA.js +3 -0
- package/lib/index.d.ts +46 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/latexTester.js +1 -1
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts +2 -0
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts.map +1 -1
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.js +150 -128
- package/lib/math/utils/sequences/situations/seqArithmeticUtils.d.ts +1 -1
- package/lib/math/utils/sequences/situations/seqArithmeticUtils.d.ts.map +1 -1
- package/lib/math/utils/sequences/situations/seqArithmeticUtils.js +4 -1
- package/lib/tests/questionTest.d.ts.map +1 -1
- package/lib/tests/questionTest.js +1 -0
- package/lib/tests/singleExo.test.js +2 -2
- package/lib/tree/nodes/functions/expNode.d.ts +1 -1
- package/lib/tree/nodes/functions/expNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/expNode.js +3 -6
- package/lib/tree/nodes/operators/addNode.d.ts +1 -1
- package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.js +2 -2
- package/lib/tree/nodes/operators/substractNode.d.ts +1 -1
- package/lib/tree/nodes/operators/substractNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/substractNode.js +2 -2
- package/lib/tree/utilities/nodeComparator.d.ts +7 -0
- package/lib/tree/utilities/nodeComparator.d.ts.map +1 -0
- package/lib/tree/utilities/nodeComparator.js +88 -0
- package/lib/tree/utilities/nodeInspector.d.ts +5 -0
- package/lib/tree/utilities/nodeInspector.d.ts.map +1 -0
- package/lib/tree/utilities/nodeInspector.js +15 -0
- package/lib/tree/utilities/nodeRewriter.d.ts +9 -0
- package/lib/tree/utilities/nodeRewriter.d.ts.map +1 -0
- package/lib/tree/utilities/nodeRewriter.js +172 -0
- package/lib/tree/utilities/nodeShuffler.d.ts +2 -4
- package/lib/tree/utilities/nodeShuffler.d.ts.map +1 -1
- package/lib/tree/utilities/nodeShuffler.js +13 -104
- package/lib/tree/utilities/nodeSimplifier.d.ts +1 -2
- package/lib/tree/utilities/nodeSimplifier.d.ts.map +1 -1
- package/lib/tree/utilities/nodeSimplifier.js +14 -88
- package/package.json +1 -1
|
@@ -1,126 +1,35 @@
|
|
|
1
1
|
import { shuffle } from "../../utils/alea/shuffle.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { CosNode } from "../nodes/functions/cosNode.js";
|
|
5
|
-
import { FunctionsIds, isFunctionNode, } from "../nodes/functions/functionNode.js";
|
|
6
|
-
import { AddNode } from "../nodes/operators/addNode.js";
|
|
7
|
-
import { BinomialCoefficientNode } from "../nodes/operators/binomialCoefficientNode.js";
|
|
8
|
-
import { DivideNode } from "../nodes/operators/divideNode.js";
|
|
9
|
-
import { FractionNode } from "../nodes/operators/fractionNode.js";
|
|
10
|
-
import { MultiplyNode } from "../nodes/operators/multiplyNode.js";
|
|
11
|
-
import { PowerNode } from "../nodes/operators/powerNode.js";
|
|
12
|
-
import { SubstractNode } from "../nodes/operators/substractNode.js";
|
|
13
|
-
import { sin } from "../nodes/functions/sinNode.js";
|
|
14
|
-
import { sqrt } from "../nodes/functions/sqrtNode.js";
|
|
15
|
-
import { tan } from "../nodes/functions/tanNode.js";
|
|
16
|
-
import { ArcsinNode } from "../nodes/functions/arcSinNode.js";
|
|
17
|
-
import { ArctanNode } from "../nodes/functions/arctanNode.js";
|
|
18
|
-
import { ExpNode } from "../nodes/functions/expNode.js";
|
|
19
|
-
import { LogNode } from "../nodes/functions/logNode.js";
|
|
20
|
-
import { Log10Node } from "../nodes/functions/log10Node.js";
|
|
21
|
-
import { NodeConstructor } from "../nodes/nodeConstructor.js";
|
|
22
|
-
import { isOperatorNode, OperatorIds, } from "../nodes/operators/operatorNode.js";
|
|
23
|
-
import { opposite } from "../nodes/functions/oppositeNode.js";
|
|
24
|
-
import { facto } from "../nodes/functions/factorialNode.js";
|
|
2
|
+
import { NodeInspector } from "./nodeInspector.js";
|
|
3
|
+
import { NodeRewriter } from "./nodeRewriter.js";
|
|
25
4
|
export class NodeShuffler {
|
|
26
|
-
static shuffle = (algebraicNode, shuffleArrayIn) => {
|
|
27
|
-
const children =
|
|
5
|
+
static shuffle = (algebraicNode, shuffleArrayIn, indexIn) => {
|
|
6
|
+
const children = NodeInspector.getChildren(algebraicNode);
|
|
28
7
|
const shuffleArray = shuffleArrayIn ?? shuffle([...Array(children.length).keys()]);
|
|
29
8
|
const shuffledChildren = shuffleArray.map((iTo) => children[iTo]);
|
|
30
|
-
|
|
9
|
+
const funcCreateNodeFromChildren = NodeRewriter.getCreateNodeFromChildrenFunction(algebraicNode, indexIn);
|
|
10
|
+
return funcCreateNodeFromChildren(shuffledChildren);
|
|
31
11
|
};
|
|
32
12
|
//commutative by default
|
|
33
13
|
static deepShuffle = (algebraicNode, deepShuffleOpts = {
|
|
34
14
|
nodeTypesToShuffle: ["AddNode", "MultiplyNode"],
|
|
35
15
|
nodeTypesNoFurther: [],
|
|
36
|
-
}, shuffleArrayIn) => {
|
|
16
|
+
}, shuffleArrayIn, indexIn = 0) => {
|
|
37
17
|
const isCanBeTraversed = !deepShuffleOpts.nodeTypesNoFurther.includes(algebraicNode.constructor.name);
|
|
38
|
-
const children =
|
|
18
|
+
const children = NodeInspector.getChildren(algebraicNode).map((childNode) => isCanBeTraversed
|
|
39
19
|
? this.deepShuffle(childNode, deepShuffleOpts, shuffleArrayIn)
|
|
40
20
|
: childNode);
|
|
41
|
-
const
|
|
42
|
-
if (children.length >
|
|
21
|
+
const funcCreateNodeFromChildren = NodeRewriter.getCreateNodeFromChildrenFunction(algebraicNode, indexIn);
|
|
22
|
+
if (children.length > 1) {
|
|
43
23
|
const isCanBeShuffled = (deepShuffleOpts?.nodeTypesToShuffle ?? []).includes(algebraicNode.constructor.name);
|
|
44
24
|
if (isCanBeShuffled) {
|
|
45
25
|
const shuffleArray = shuffleArrayIn ?? shuffle([...Array(children.length).keys()]);
|
|
46
26
|
const shuffledChildren = shuffleArray.map((iTo) => children[iTo]);
|
|
47
|
-
return
|
|
27
|
+
return funcCreateNodeFromChildren(shuffledChildren);
|
|
48
28
|
}
|
|
49
29
|
else {
|
|
50
|
-
|
|
30
|
+
funcCreateNodeFromChildren(children);
|
|
51
31
|
}
|
|
52
32
|
}
|
|
53
|
-
return
|
|
33
|
+
return funcCreateNodeFromChildren(children);
|
|
54
34
|
};
|
|
55
|
-
static getCreateNodeFromChildrenFunction = (algebraicNode) => {
|
|
56
|
-
if (isOperatorNode(algebraicNode)) {
|
|
57
|
-
switch (algebraicNode.id) {
|
|
58
|
-
case OperatorIds.binomialCoefficient:
|
|
59
|
-
return (children) => new BinomialCoefficientNode(children[0], children[1], algebraicNode.opts);
|
|
60
|
-
case OperatorIds.divide:
|
|
61
|
-
return (children) => new DivideNode(children[0], children[1]);
|
|
62
|
-
case OperatorIds.fraction:
|
|
63
|
-
return (children) => new FractionNode(children[0], children[1], algebraicNode.opts);
|
|
64
|
-
case OperatorIds.integral:
|
|
65
|
-
// throw new Error("unsupported node type: integral"); //need to do intelligent shuffle here
|
|
66
|
-
return () => NodeConstructor.fromIdentifiers(algebraicNode.toIdentifiers());
|
|
67
|
-
case OperatorIds.limit:
|
|
68
|
-
// throw new Error("unsupported node type: limit"); //need to do intelligent shuffle here
|
|
69
|
-
return () => NodeConstructor.fromIdentifiers(algebraicNode.toIdentifiers());
|
|
70
|
-
case OperatorIds.multiply:
|
|
71
|
-
return (children) => new MultiplyNode(children[0], children[1], algebraicNode.opts);
|
|
72
|
-
case OperatorIds.power:
|
|
73
|
-
case OperatorIds.square: //this is so nice
|
|
74
|
-
return (children) => new PowerNode(children[0], children[1], algebraicNode.opts);
|
|
75
|
-
case OperatorIds.substract:
|
|
76
|
-
return (children) => new SubstractNode(children[0], children[1], algebraicNode.opts);
|
|
77
|
-
case OperatorIds.add:
|
|
78
|
-
return (children) => new AddNode(children[0], children[1], algebraicNode.opts);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
else if (isFunctionNode(algebraicNode)) {
|
|
82
|
-
switch (algebraicNode.id) {
|
|
83
|
-
case FunctionsIds.arccos:
|
|
84
|
-
return (children) => arccos(children[0]);
|
|
85
|
-
case FunctionsIds.arcsin:
|
|
86
|
-
return (children) => new ArcsinNode(children[0]);
|
|
87
|
-
case FunctionsIds.arctan:
|
|
88
|
-
return (children) => new ArctanNode(children[0]);
|
|
89
|
-
case FunctionsIds.cos:
|
|
90
|
-
return (children) => new CosNode(children[0]);
|
|
91
|
-
case FunctionsIds.exp:
|
|
92
|
-
return (children) => new ExpNode(children[0], algebraicNode.opts);
|
|
93
|
-
case FunctionsIds.log:
|
|
94
|
-
return (children) => new LogNode(children[0], algebraicNode.opts);
|
|
95
|
-
case FunctionsIds.log10:
|
|
96
|
-
return (children) => new Log10Node(children[0], algebraicNode.opts);
|
|
97
|
-
case FunctionsIds.opposite:
|
|
98
|
-
return (children) => opposite(children[0]);
|
|
99
|
-
case FunctionsIds.sin:
|
|
100
|
-
return (children) => sin(children[0]);
|
|
101
|
-
case FunctionsIds.sqrt:
|
|
102
|
-
return (children) => sqrt(children[0]);
|
|
103
|
-
case FunctionsIds.tan:
|
|
104
|
-
return (children) => tan(children[0]);
|
|
105
|
-
case FunctionsIds.abs:
|
|
106
|
-
return (children) => abs(children[0]);
|
|
107
|
-
case FunctionsIds.factorial:
|
|
108
|
-
return (children) => facto(children[0]);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
return () => NodeConstructor.fromIdentifiers(algebraicNode.toIdentifiers());
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
static getChildren(algebraicNode) {
|
|
116
|
-
if (isOperatorNode(algebraicNode)) {
|
|
117
|
-
return [algebraicNode.leftChild, algebraicNode.rightChild];
|
|
118
|
-
}
|
|
119
|
-
else if (isFunctionNode(algebraicNode)) {
|
|
120
|
-
return [algebraicNode.child];
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
return [];
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
35
|
}
|
|
@@ -10,7 +10,6 @@ export declare abstract class NodeSimplifier {
|
|
|
10
10
|
static arrTexStepByStep: (node: AlgebraicNode, simplifyOpts?: SimplifyOptions, simplifierOpts?: {
|
|
11
11
|
isMultiTopLevel: boolean;
|
|
12
12
|
}, toTexOpts?: ToTexOptions) => string[];
|
|
13
|
-
|
|
14
|
-
static getChildren(algebraicNode: AlgebraicNode): AlgebraicNode[];
|
|
13
|
+
static simplifyByVibrating(algebraicNode: AlgebraicNode, nbVibrations?: number, isTowardsDistribute?: boolean): AlgebraicNode;
|
|
15
14
|
}
|
|
16
15
|
//# 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;
|
|
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;CAcjB"}
|
|
@@ -1,34 +1,20 @@
|
|
|
1
1
|
import { abs } from "../nodes/functions/absNode.js";
|
|
2
|
-
import {
|
|
3
|
-
import { CosNode } from "../nodes/functions/cosNode.js";
|
|
4
|
-
import { FunctionsIds, isFunctionNode, } from "../nodes/functions/functionNode.js";
|
|
2
|
+
import { isFunctionNode } from "../nodes/functions/functionNode.js";
|
|
5
3
|
import { AddNode, isAddNode } from "../nodes/operators/addNode.js";
|
|
6
|
-
import { BinomialCoefficientNode } from "../nodes/operators/binomialCoefficientNode.js";
|
|
7
4
|
import { DivideNode, isDivideNode } from "../nodes/operators/divideNode.js";
|
|
8
|
-
import { FractionNode } from "../nodes/operators/fractionNode.js";
|
|
9
5
|
import { isMultiplyNode, MultiplyNode, } from "../nodes/operators/multiplyNode.js";
|
|
10
|
-
import { PowerNode } from "../nodes/operators/powerNode.js";
|
|
11
6
|
import { isSubstractNode, SubstractNode, } from "../nodes/operators/substractNode.js";
|
|
12
|
-
import { sin } from "../nodes/functions/sinNode.js";
|
|
13
|
-
import { sqrt } from "../nodes/functions/sqrtNode.js";
|
|
14
|
-
import { tan } from "../nodes/functions/tanNode.js";
|
|
15
|
-
import { ArcsinNode } from "../nodes/functions/arcSinNode.js";
|
|
16
|
-
import { ArctanNode } from "../nodes/functions/arctanNode.js";
|
|
17
|
-
import { ExpNode } from "../nodes/functions/expNode.js";
|
|
18
|
-
import { LogNode } from "../nodes/functions/logNode.js";
|
|
19
|
-
import { Log10Node } from "../nodes/functions/log10Node.js";
|
|
20
|
-
import { NodeConstructor } from "../nodes/nodeConstructor.js";
|
|
21
7
|
import { isOperatorNode, OperatorIds, } from "../nodes/operators/operatorNode.js";
|
|
22
|
-
import { opposite } from "../nodes/functions/oppositeNode.js";
|
|
23
8
|
import { isNumberNode } from "../nodes/numbers/numberNode.js";
|
|
24
|
-
import {
|
|
9
|
+
import { NodeInspector } from "./nodeInspector.js";
|
|
10
|
+
import { NodeRewriter } from "./nodeRewriter.js";
|
|
25
11
|
export class NodeSimplifier {
|
|
26
12
|
static getDepth = (algebraicNode, simplifyOpts, toTexOptions = {
|
|
27
13
|
forceTimesSign: true,
|
|
28
14
|
forceParenthesis: true,
|
|
29
15
|
forceNoSimplification: true,
|
|
30
16
|
}) => {
|
|
31
|
-
const children =
|
|
17
|
+
const children = NodeInspector.getChildren(algebraicNode);
|
|
32
18
|
if (children.length === 0) {
|
|
33
19
|
return 0;
|
|
34
20
|
}
|
|
@@ -98,7 +84,7 @@ export class NodeSimplifier {
|
|
|
98
84
|
default:
|
|
99
85
|
return [
|
|
100
86
|
...(() => {
|
|
101
|
-
const arrArrChild =
|
|
87
|
+
const arrArrChild = NodeInspector.getChildren(algebraicNode).map((nodeChild) => this.nodesStepByStep(nodeChild, simplifyOpts, simplifierOpts));
|
|
102
88
|
const maxLength = Math.max(...arrArrChild.map((nodesSByS) => nodesSByS.length));
|
|
103
89
|
//multi or single here
|
|
104
90
|
let arrChildren;
|
|
@@ -191,11 +177,11 @@ export class NodeSimplifier {
|
|
|
191
177
|
return new DivideNode(new MultiplyNode(childrenRefined[0], divNode.leftChild), divNode.rightChild);
|
|
192
178
|
}
|
|
193
179
|
else {
|
|
194
|
-
return
|
|
180
|
+
return NodeRewriter.getCreateNodeFromChildrenFunction(algebraicNode)(childrenRefined);
|
|
195
181
|
}
|
|
196
182
|
}
|
|
197
183
|
else {
|
|
198
|
-
return
|
|
184
|
+
return NodeRewriter.getCreateNodeFromChildrenFunction(algebraicNode)(childrenRefined);
|
|
199
185
|
}
|
|
200
186
|
});
|
|
201
187
|
})(),
|
|
@@ -212,75 +198,15 @@ export class NodeSimplifier {
|
|
|
212
198
|
}) => {
|
|
213
199
|
return this.nodesStepByStep(node, simplifyOpts, simplifierOpts, toTexOpts).map((node) => node.toTex(toTexOpts));
|
|
214
200
|
};
|
|
215
|
-
static
|
|
216
|
-
if (
|
|
217
|
-
|
|
218
|
-
case OperatorIds.binomialCoefficient:
|
|
219
|
-
return (children) => new BinomialCoefficientNode(children[0], children[1], algebraicNode.opts);
|
|
220
|
-
case OperatorIds.divide:
|
|
221
|
-
return (children) => new DivideNode(children[0], children[1]);
|
|
222
|
-
case OperatorIds.fraction:
|
|
223
|
-
return (children) => new FractionNode(children[0], children[1], algebraicNode.opts);
|
|
224
|
-
case OperatorIds.integral:
|
|
225
|
-
// throw new Error("unsupported node type: integral"); //need to do intelligent shuffle here
|
|
226
|
-
return () => NodeConstructor.fromIdentifiers(algebraicNode.toIdentifiers());
|
|
227
|
-
case OperatorIds.limit:
|
|
228
|
-
// throw new Error("unsupported node type: limit"); //need to do intelligent shuffle here
|
|
229
|
-
return () => NodeConstructor.fromIdentifiers(algebraicNode.toIdentifiers());
|
|
230
|
-
case OperatorIds.multiply:
|
|
231
|
-
return (children) => new MultiplyNode(children[0], children[1], algebraicNode.opts);
|
|
232
|
-
case OperatorIds.power:
|
|
233
|
-
case OperatorIds.square: //this is so nice
|
|
234
|
-
return (children) => new PowerNode(children[0], children[1], algebraicNode.opts);
|
|
235
|
-
case OperatorIds.substract:
|
|
236
|
-
return (children) => new SubstractNode(children[0], children[1], algebraicNode.opts);
|
|
237
|
-
case OperatorIds.add:
|
|
238
|
-
return (children) => new AddNode(children[0], children[1], algebraicNode.opts);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
else if (isFunctionNode(algebraicNode)) {
|
|
242
|
-
switch (algebraicNode.id) {
|
|
243
|
-
case FunctionsIds.arccos:
|
|
244
|
-
return (children) => arccos(children[0]);
|
|
245
|
-
case FunctionsIds.arcsin:
|
|
246
|
-
return (children) => new ArcsinNode(children[0]);
|
|
247
|
-
case FunctionsIds.arctan:
|
|
248
|
-
return (children) => new ArctanNode(children[0]);
|
|
249
|
-
case FunctionsIds.cos:
|
|
250
|
-
return (children) => new CosNode(children[0]);
|
|
251
|
-
case FunctionsIds.exp:
|
|
252
|
-
return (children) => new ExpNode(children[0], algebraicNode.opts);
|
|
253
|
-
case FunctionsIds.log:
|
|
254
|
-
return (children) => new LogNode(children[0], algebraicNode.opts);
|
|
255
|
-
case FunctionsIds.log10:
|
|
256
|
-
return (children) => new Log10Node(children[0], algebraicNode.opts);
|
|
257
|
-
case FunctionsIds.opposite:
|
|
258
|
-
return (children) => opposite(children[0]);
|
|
259
|
-
case FunctionsIds.sin:
|
|
260
|
-
return (children) => sin(children[0]);
|
|
261
|
-
case FunctionsIds.sqrt:
|
|
262
|
-
return (children) => sqrt(children[0]);
|
|
263
|
-
case FunctionsIds.tan:
|
|
264
|
-
return (children) => tan(children[0]);
|
|
265
|
-
case FunctionsIds.abs:
|
|
266
|
-
return (children) => abs(children[0]);
|
|
267
|
-
case FunctionsIds.factorial:
|
|
268
|
-
return (children) => facto(children[0]);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
else {
|
|
272
|
-
return () => NodeConstructor.fromIdentifiers(algebraicNode.toIdentifiers());
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
|
-
static getChildren(algebraicNode) {
|
|
276
|
-
if (isOperatorNode(algebraicNode)) {
|
|
277
|
-
return [algebraicNode.leftChild, algebraicNode.rightChild];
|
|
278
|
-
}
|
|
279
|
-
else if (isFunctionNode(algebraicNode)) {
|
|
280
|
-
return [algebraicNode.child];
|
|
201
|
+
static simplifyByVibrating(algebraicNode, nbVibrations = 5, isTowardsDistribute = true) {
|
|
202
|
+
if (nbVibrations === 0) {
|
|
203
|
+
return algebraicNode;
|
|
281
204
|
}
|
|
282
205
|
else {
|
|
283
|
-
|
|
206
|
+
const nodeSimplified = algebraicNode.simplify({
|
|
207
|
+
towardsDistribute: isTowardsDistribute,
|
|
208
|
+
});
|
|
209
|
+
return this.simplifyByVibrating(nodeSimplified, nbVibrations - 1, !isTowardsDistribute);
|
|
284
210
|
}
|
|
285
211
|
}
|
|
286
212
|
}
|