math-exercises 3.0.182 → 3.0.184

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.
Files changed (85) hide show
  1. package/lib/exercises/math/functions/composition/functionComposition.d.ts.map +1 -1
  2. package/lib/exercises/math/functions/composition/functionComposition.js +11 -22
  3. package/lib/exercises/math/functions/exponential/algebraic/index.d.ts +1 -0
  4. package/lib/exercises/math/functions/exponential/algebraic/index.d.ts.map +1 -1
  5. package/lib/exercises/math/functions/exponential/algebraic/index.js +1 -1
  6. package/lib/exercises/math/functions/exponential/algebraic/rewriteExpUsingExpA.d.ts.map +1 -1
  7. package/lib/exercises/math/functions/exponential/algebraic/rewriteExpUsingExpA.js +18 -3
  8. package/lib/exercises/math/functions/exponential/expKT/derivativeOfAExpKT.d.ts +8 -0
  9. package/lib/exercises/math/functions/exponential/expKT/derivativeOfAExpKT.d.ts.map +1 -0
  10. package/lib/exercises/math/functions/exponential/expKT/derivativeOfAExpKT.js +108 -0
  11. package/lib/exercises/math/functions/exponential/expKT/drugConcentrationMaximum.d.ts +8 -0
  12. package/lib/exercises/math/functions/exponential/expKT/drugConcentrationMaximum.d.ts.map +1 -0
  13. package/lib/exercises/math/functions/exponential/expKT/drugConcentrationMaximum.js +144 -0
  14. package/lib/exercises/math/functions/exponential/expKT/index.d.ts +3 -0
  15. package/lib/exercises/math/functions/exponential/expKT/index.d.ts.map +1 -0
  16. package/lib/exercises/math/functions/exponential/expKT/index.js +2 -0
  17. package/lib/exercises/math/functions/exponential/expSimplifiying.d.ts.map +1 -1
  18. package/lib/exercises/math/functions/exponential/expSimplifiying.js +94 -4
  19. package/lib/exercises/math/functions/exponential/index.d.ts +3 -0
  20. package/lib/exercises/math/functions/exponential/index.d.ts.map +1 -1
  21. package/lib/exercises/math/functions/exponential/index.js +3 -0
  22. package/lib/exercises/math/functions/exponential/sign/expFunctionBasicSign.d.ts +9 -0
  23. package/lib/exercises/math/functions/exponential/sign/expFunctionBasicSign.d.ts.map +1 -0
  24. package/lib/exercises/math/functions/exponential/sign/expFunctionBasicSign.js +101 -0
  25. package/lib/exercises/math/functions/exponential/sign/index.d.ts +2 -0
  26. package/lib/exercises/math/functions/exponential/sign/index.d.ts.map +1 -0
  27. package/lib/exercises/math/functions/exponential/sign/index.js +1 -0
  28. package/lib/exercises/math/functions/exponential/variations/index.d.ts +3 -0
  29. package/lib/exercises/math/functions/exponential/variations/index.d.ts.map +1 -0
  30. package/lib/exercises/math/functions/exponential/variations/index.js +2 -0
  31. package/lib/exercises/math/functions/exponential/variations/varSignTableOfAffineTimesExp.d.ts +7 -0
  32. package/lib/exercises/math/functions/exponential/variations/varSignTableOfAffineTimesExp.d.ts.map +1 -0
  33. package/lib/exercises/math/functions/exponential/variations/varSignTableOfAffineTimesExp.js +144 -0
  34. package/lib/exercises/math/functions/exponential/variations/varSignTableOfExpMinusX.d.ts +7 -0
  35. package/lib/exercises/math/functions/exponential/variations/varSignTableOfExpMinusX.d.ts.map +1 -0
  36. package/lib/exercises/math/functions/exponential/variations/varSignTableOfExpMinusX.js +139 -0
  37. package/lib/exercises/math/probaStat/independancy/independantSuccessiveEventsComputeTwoSuccess.d.ts +7 -0
  38. package/lib/exercises/math/probaStat/independancy/independantSuccessiveEventsComputeTwoSuccess.d.ts.map +1 -0
  39. package/lib/exercises/math/probaStat/independancy/independantSuccessiveEventsComputeTwoSuccess.js +100 -0
  40. package/lib/exercises/math/probaStat/independancy/index.d.ts +1 -0
  41. package/lib/exercises/math/probaStat/independancy/index.d.ts.map +1 -1
  42. package/lib/exercises/math/probaStat/independancy/index.js +1 -0
  43. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoConsecutiveTerms.d.ts.map +1 -1
  44. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoConsecutiveTerms.js +37 -39
  45. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.d.ts.map +1 -1
  46. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.js +14 -4
  47. package/lib/exercises/math/sequences/geometric/index.d.ts +3 -0
  48. package/lib/exercises/math/sequences/geometric/index.d.ts.map +1 -1
  49. package/lib/exercises/math/sequences/geometric/index.js +3 -3
  50. package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.d.ts.map +1 -1
  51. package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.js +12 -3
  52. package/lib/exercises/math/sequences/geometric/situations/index.d.ts +1 -0
  53. package/lib/exercises/math/sequences/geometric/situations/index.d.ts.map +1 -1
  54. package/lib/exercises/math/sequences/geometric/situations/index.js +1 -1
  55. package/lib/exercises/vea/treeTableVEA.d.ts.map +1 -1
  56. package/lib/exercises/vea/treeTableVEA.js +3 -0
  57. package/lib/index.d.ts +50 -0
  58. package/lib/index.d.ts.map +1 -1
  59. package/lib/latexTester.js +1 -1
  60. package/lib/tests/singleExo.test.js +2 -2
  61. package/lib/tree/nodes/functions/expNode.d.ts +1 -1
  62. package/lib/tree/nodes/functions/expNode.d.ts.map +1 -1
  63. package/lib/tree/nodes/functions/expNode.js +3 -6
  64. package/lib/tree/nodes/operators/addNode.d.ts +1 -1
  65. package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
  66. package/lib/tree/nodes/operators/addNode.js +2 -2
  67. package/lib/tree/nodes/operators/substractNode.d.ts +1 -1
  68. package/lib/tree/nodes/operators/substractNode.d.ts.map +1 -1
  69. package/lib/tree/nodes/operators/substractNode.js +2 -2
  70. package/lib/tree/utilities/nodeComparator.d.ts +7 -0
  71. package/lib/tree/utilities/nodeComparator.d.ts.map +1 -0
  72. package/lib/tree/utilities/nodeComparator.js +88 -0
  73. package/lib/tree/utilities/nodeInspector.d.ts +5 -0
  74. package/lib/tree/utilities/nodeInspector.d.ts.map +1 -0
  75. package/lib/tree/utilities/nodeInspector.js +15 -0
  76. package/lib/tree/utilities/nodeRewriter.d.ts +9 -0
  77. package/lib/tree/utilities/nodeRewriter.d.ts.map +1 -0
  78. package/lib/tree/utilities/nodeRewriter.js +172 -0
  79. package/lib/tree/utilities/nodeShuffler.d.ts +2 -4
  80. package/lib/tree/utilities/nodeShuffler.d.ts.map +1 -1
  81. package/lib/tree/utilities/nodeShuffler.js +13 -104
  82. package/lib/tree/utilities/nodeSimplifier.d.ts +1 -2
  83. package/lib/tree/utilities/nodeSimplifier.d.ts.map +1 -1
  84. package/lib/tree/utilities/nodeSimplifier.js +14 -88
  85. package/package.json +1 -1
@@ -4,12 +4,14 @@ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQue
4
4
  import { randfloat } from "../../../../math/utils/random/randfloat.js";
5
5
  import { randint } from "../../../../math/utils/random/randint.js";
6
6
  import { round } from "../../../../math/utils/round.js";
7
- import { EqualNode } from "../../../../tree/nodes/equations/equalNode.js";
7
+ import { EqualNode, isEqualNode, } from "../../../../tree/nodes/equations/equalNode.js";
8
8
  import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
9
9
  import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
10
10
  import { power } from "../../../../tree/nodes/operators/powerNode.js";
11
11
  import { substract } from "../../../../tree/nodes/operators/substractNode.js";
12
12
  import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
13
+ import { NodeComparator } from "../../../../tree/utilities/nodeComparator.js";
14
+ import { NodeRewriter } from "../../../../tree/utilities/nodeRewriter.js";
13
15
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
14
16
  import { random } from "../../../../utils/alea/random.js";
15
17
  import { shuffle } from "../../../../utils/alea/shuffle.js";
@@ -122,46 +124,41 @@ const getPropositions = (n, { answer, ..._identifiers }, optsIn) => {
122
124
  });
123
125
  return shuffle(propositions);
124
126
  };
125
- const isAnswerValid = (ans, { answer }) => {
127
+ const isAnswerValid = (ans, { answer, ...identifiers }, optsIn) => {
128
+ const opts = optsIn ?? optsDefault;
126
129
  try {
127
130
  //TODO faire fonctionner parseAlgebraic("u_n=3+2n") (token _ not implemented)
128
- const splitted = ans.split("=");
129
- const studentAns = splitted[1] ?? ans;
130
- const parsed = parseAlgebraic(studentAns);
131
- if (!parsed)
131
+ const nodeAnswer = getAnswerStuff(identifiers, opts).answerNode;
132
+ if (!ans.includes("=")) {
133
+ // return false;
134
+ ans = nodeAnswer.leftChild.toTex() + "=" + ans;
135
+ }
136
+ // const nodeAns = parseAlgebraic(ans);
137
+ const nodeAns = (() => {
138
+ const [lhs, rhs] = ans.split("=");
139
+ const nodeLhs = lhs.toTree();
140
+ const nodeRhs = parseAlgebraic(rhs);
141
+ return new EqualNode(nodeLhs, nodeRhs);
142
+ })();
143
+ if (!isEqualNode(nodeAns)) {
132
144
  return false;
133
- return parsed.simplify().toTex() === answer.split("=")[1];
134
- //!ROBIN : tout commenté car ne passent pas les tests
135
- // const nodeAnswer = getAnswerStuff(identifiers, opts).answerNode;
136
- // if (!ans.includes("=")) {
137
- // // return false;
138
- // ans = nodeAnswer.leftChild.toTex() + "=" + ans;
139
- // }
140
- // // const nodeAns = parseAlgebraic(ans);
141
- // const nodeAns = (() => {
142
- // const [lhs, rhs] = ans.split("=");
143
- // const nodeLhs = lhs.toTree();
144
- // const nodeRhs = parseAlgebraic(rhs);
145
- // return new EqualNode(nodeLhs, nodeRhs);
146
- // })();
147
- // if (!isEqualNode(nodeAns)) {
148
- // return false;
149
- // }
150
- // const isValidLhs = () =>
151
- // nodeAns.leftChild.toTex() === nodeAnswer.leftChild.toTex();
152
- // const isValidRhs = () => {
153
- // const nodeAnsRhs = nodeAns.rightChild;
154
- // const nodeAnswerRhs = nodeAnswer.rightChild;
155
- // return [0, 1, 2].every((n) => {
156
- // return (
157
- // substract(
158
- // nodeAnsRhs.evaluate({ n }),
159
- // nodeAnswerRhs.evaluate({ n }),
160
- // ).evaluate() === 0
161
- // );
162
- // });
163
- // };
164
- // return isValidLhs() && isValidRhs();
145
+ }
146
+ const isValidLhs = () => nodeAns.leftChild.toTex() === nodeAnswer.leftChild.toTex();
147
+ const isValidRhs = () => {
148
+ const nodeAnsRhs = nodeAns.rightChild;
149
+ const nodeAnswerRhs = nodeAnswer.rightChild;
150
+ const isEquivalentFound = () => {
151
+ const nodeAns = nodeAnsRhs;
152
+ const nodeAnswer = nodeAnswerRhs;
153
+ const arrNodeAnswerEquivalent = NodeRewriter.getArrNodeEquivalent(nodeAnswer);
154
+ return arrNodeAnswerEquivalent.some((nodeAnswerRefined) => {
155
+ const isEqual = NodeComparator.isEqualViaFrac(nodeAns, nodeAnswerRefined);
156
+ return isEqual;
157
+ });
158
+ };
159
+ return isEquivalentFound();
160
+ };
161
+ return isValidLhs() && isValidRhs();
165
162
  }
166
163
  catch (e) {
167
164
  handleVEAError(e);
@@ -246,7 +243,8 @@ const createRandomIdentifiersCurated = (opts) => {
246
243
  counter++;
247
244
  const identifiersCandidate = createRandomIdentifiersRaw(opts);
248
245
  const answer = getAnswer(identifiersCandidate, opts);
249
- isValid = !answer.includes("NaN");
246
+ const isVEAOk = () => isAnswerValid(answer, { answer, ...identifiersCandidate }, opts);
247
+ isValid = !answer.includes("NaN") && isVEAOk();
250
248
  if (isValid) {
251
249
  identifiers = identifiersCandidate;
252
250
  }
@@ -1 +1 @@
1
- {"version":3,"file":"geometricFindExplicitFormulaFromTwoTerms.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,sBAAsB,EACvB,MAAM,mDAAmD,CAAC;AAoB3D,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAsWF,KAAK,OAAO,GAAG,sBAAsB,CAAC;AAMtC,eAAO,MAAM,wCAAwC,EAAE,QAAQ,CAC7D,WAAW,EACX,OAAO,CAoBR,CAAC"}
1
+ {"version":3,"file":"geometricFindExplicitFormulaFromTwoTerms.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,sBAAsB,EACvB,MAAM,mDAAmD,CAAC;AAsB3D,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAiXF,KAAK,OAAO,GAAG,sBAAsB,CAAC;AAMtC,eAAO,MAAM,wCAAwC,EAAE,QAAQ,CAC7D,WAAW,EACX,OAAO,CAoBR,CAAC"}
@@ -10,6 +10,8 @@ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
10
10
  import { power } from "../../../../tree/nodes/operators/powerNode.js";
11
11
  import { substract } from "../../../../tree/nodes/operators/substractNode.js";
12
12
  import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
13
+ import { NodeComparator } from "../../../../tree/utilities/nodeComparator.js";
14
+ import { NodeRewriter } from "../../../../tree/utilities/nodeRewriter.js";
13
15
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
14
16
  import { random } from "../../../../utils/alea/random.js";
15
17
  import { shuffle } from "../../../../utils/alea/shuffle.js";
@@ -156,9 +158,16 @@ const isAnswerValid = (ans, { answer, ...identifiers }, optsIn) => {
156
158
  const isValidRhs = () => {
157
159
  const nodeAnsRhs = nodeAns.rightChild;
158
160
  const nodeAnswerRhs = nodeAnswer.rightChild;
159
- return [0, 1, 2, 10].every((n) => {
160
- return (substract(nodeAnsRhs.evaluate({ n }), nodeAnswerRhs.evaluate({ n })).evaluate() === 0);
161
- });
161
+ const isEquivalentFound = () => {
162
+ const nodeAns = nodeAnsRhs;
163
+ const nodeAnswer = nodeAnswerRhs;
164
+ const arrNodeAnswerEquivalent = NodeRewriter.getArrNodeEquivalent(nodeAnswer);
165
+ return arrNodeAnswerEquivalent.some((nodeAnswerRefined) => {
166
+ const isEqual = NodeComparator.isEqualViaFrac(nodeAns, nodeAnswerRefined);
167
+ return isEqual;
168
+ });
169
+ };
170
+ return isEquivalentFound();
162
171
  };
163
172
  return isValidLhs() && isValidRhs();
164
173
  }
@@ -245,7 +254,8 @@ const createRandomIdentifiersCurated = (opts) => {
245
254
  counter++;
246
255
  const identifiersCandidate = createRandomIdentifiersRaw(opts);
247
256
  const answer = getAnswer(identifiersCandidate, opts);
248
- isValid = !answer.includes("NaN");
257
+ const isVEAOk = () => isAnswerValid(answer, { answer, ...identifiersCandidate }, opts);
258
+ isValid = !answer.includes("NaN") && isVEAOk();
249
259
  if (isValid) {
250
260
  identifiers = identifiersCandidate;
251
261
  }
@@ -12,4 +12,7 @@ export * from "./geometricVariations.js";
12
12
  export * from "./geometricFindRandomTermFromTwoTerms.js";
13
13
  export * from "./sum/index.js";
14
14
  export * from "./situations/index.js";
15
+ export * from "./geometricFindExplicitFormulaFromTwoTerms.js";
16
+ export * from "./geometricFindExplicitFormulaFromTwoConsecutiveTerms.js";
17
+ export * from "./geometricFindRandomTermFromTwoConsecutiveTerms.js";
15
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,+CAA+C,CAAC;AAE9D,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,cAAc,kDAAkD,CAAC;AACjE,cAAc,wBAAwB,CAAC;AACvC,cAAc,oCAAoC,CAAC;AAEnD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,0BAA0B,CAAC;AAEzC,cAAc,0CAA0C,CAAC;AAEzD,cAAc,gBAAgB,CAAC;AAE/B,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,+CAA+C,CAAC;AAE9D,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,cAAc,kDAAkD,CAAC;AACjE,cAAc,wBAAwB,CAAC;AACvC,cAAc,oCAAoC,CAAC;AAEnD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,0BAA0B,CAAC;AAEzC,cAAc,0CAA0C,CAAC;AAEzD,cAAc,gBAAgB,CAAC;AAE/B,cAAc,uBAAuB,CAAC;AAEtC,cAAc,+CAA+C,CAAC;AAC9D,cAAc,0DAA0D,CAAC;AACzE,cAAc,qDAAqD,CAAC"}
@@ -12,6 +12,6 @@ export * from "./geometricVariations.js";
12
12
  export * from "./geometricFindRandomTermFromTwoTerms.js";
13
13
  export * from "./sum/index.js";
14
14
  export * from "./situations/index.js";
15
- // export * from "./geometricFindExplicitFormulaFromTwoTerms.js";
16
- // export * from "./geometricFindExplicitFormulaFromTwoConsecutiveTerms.js";
17
- // export * from "./geometricFindRandomTermFromTwoConsecutiveTerms.js";
15
+ export * from "./geometricFindExplicitFormulaFromTwoTerms.js";
16
+ export * from "./geometricFindExplicitFormulaFromTwoConsecutiveTerms.js";
17
+ export * from "./geometricFindRandomTermFromTwoConsecutiveTerms.js";
@@ -1 +1 @@
1
- {"version":3,"file":"geometricFindExplicitFormulaFromSituation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,sBAAsB,EACvB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAEL,2BAA2B,EAC5B,MAAM,wDAAwD,CAAC;AAIhE,OAAO,EAEL,iCAAiC,EAElC,MAAM,iEAAiE,CAAC;AAiBzE,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,iCAAiC,CAAC;CACrD,CAAC;AAiPF,KAAK,OAAO,GAAG,sBAAsB,GAAG,2BAA2B,CAAC;AAcpE,eAAO,MAAM,yCAAyC,EAAE,QAAQ,CAC9D,WAAW,EACX,OAAO,CAoBR,CAAC"}
1
+ {"version":3,"file":"geometricFindExplicitFormulaFromSituation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,sBAAsB,EACvB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAEL,2BAA2B,EAC5B,MAAM,wDAAwD,CAAC;AAIhE,OAAO,EAEL,iCAAiC,EAElC,MAAM,iEAAiE,CAAC;AAmBzE,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,iCAAiC,CAAC;CACrD,CAAC;AA0PF,KAAK,OAAO,GAAG,sBAAsB,GAAG,2BAA2B,CAAC;AAcpE,eAAO,MAAM,yCAAyC,EAAE,QAAQ,CAC9D,WAAW,EACX,OAAO,CAoBR,CAAC"}
@@ -11,6 +11,8 @@ import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
11
11
  import { power } from "../../../../../tree/nodes/operators/powerNode.js";
12
12
  import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
13
13
  import { parseAlgebraic } from "../../../../../tree/parsers/latexParser.js";
14
+ import { NodeComparator } from "../../../../../tree/utilities/nodeComparator.js";
15
+ import { NodeRewriter } from "../../../../../tree/utilities/nodeRewriter.js";
14
16
  import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
15
17
  const getNodeFactor = (firstRank, varName = "n") => {
16
18
  const nodeN = varName.toTree();
@@ -121,9 +123,16 @@ const isAnswerValid = (ans, { answer, ...identifiers }, optsIn) => {
121
123
  const isValidRhs = () => {
122
124
  const nodeAnsRhs = nodeAns.rightChild;
123
125
  const nodeAnswerRhs = nodeAnswer.rightChild;
124
- return [0, 1, 2, 3].every((n) => {
125
- return (substract(nodeAnsRhs.evaluate({ n }), nodeAnswerRhs.evaluate({ n })).evaluate() === 0);
126
- });
126
+ const isEquivalentFound = () => {
127
+ const nodeAns = nodeAnsRhs;
128
+ const nodeAnswer = nodeAnswerRhs;
129
+ const arrNodeAnswerEquivalent = NodeRewriter.getArrNodeEquivalent(nodeAnswer);
130
+ return arrNodeAnswerEquivalent.some((nodeAnswerRefined) => {
131
+ const isEqual = NodeComparator.isEqualViaFrac(nodeAns, nodeAnswerRefined);
132
+ return isEqual;
133
+ });
134
+ };
135
+ return isEquivalentFound();
127
136
  };
128
137
  return isValidLhs() && isValidRhs();
129
138
  }
@@ -1,3 +1,4 @@
1
1
  export * from "./geometricFindRecurrenceFormulaFromSituation.js";
2
2
  export * from "./geometricFindTermFromSituation.js";
3
+ export * from "./geometricFindExplicitFormulaFromSituation.js";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/geometric/situations/index.ts"],"names":[],"mappings":"AAAA,cAAc,kDAAkD,CAAC;AACjE,cAAc,qCAAqC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/geometric/situations/index.ts"],"names":[],"mappings":"AAAA,cAAc,kDAAkD,CAAC;AACjE,cAAc,qCAAqC,CAAC;AAGpD,cAAc,gDAAgD,CAAC"}
@@ -2,4 +2,4 @@ export * from "./geometricFindRecurrenceFormulaFromSituation.js";
2
2
  export * from "./geometricFindTermFromSituation.js";
3
3
  // export * from "./geometricFindRankFromSituation.js";
4
4
  // export * from "./geometricFindThresholdFromSituation.js";
5
- // export * from "./geometricFindExplicitFormulaFromSituation.js";
5
+ export * from "./geometricFindExplicitFormulaFromSituation.js";
@@ -1 +1 @@
1
- {"version":3,"file":"treeTableVEA.d.ts","sourceRoot":"","sources":["../../../src/exercises/vea/treeTableVEA.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,YAAY,GACvB,KAAK,MAAM,EAAE,EAAE,EAAE,EAAE,EACnB,aAAa,MAAM,EAAE,EAAE,EAAE,EAAE,YAa5B,CAAC"}
1
+ {"version":3,"file":"treeTableVEA.d.ts","sourceRoot":"","sources":["../../../src/exercises/vea/treeTableVEA.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,YAAY,GACvB,KAAK,MAAM,EAAE,EAAE,EAAE,EAAE,EACnB,aAAa,MAAM,EAAE,EAAE,EAAE,EAAE,YAgB5B,CAAC"}
@@ -2,6 +2,9 @@ import { rationalVEA } from "./rationalVEA.js";
2
2
  // type Options = {
3
3
  // }
4
4
  export const treeTableVEA = (ans, answerTable) => {
5
+ //TODO
6
+ //les branches peuvent commuter au sein d'un block
7
+ //les blocks peuvent commuter au sein d'un step
5
8
  return ans.every((step, i) => step.every((block, j) => block.every((branch, k) => branch.every((value, l) => value === answerTable[i][j][k][l] ||
6
9
  rationalVEA(value, answerTable[i][j][k][l])))));
7
10
  };
package/lib/index.d.ts CHANGED
@@ -1607,6 +1607,13 @@ declare const mathExercises: (Exercise<{
1607
1607
  expBRounded: number;
1608
1608
  precision: number;
1609
1609
  }, Record<string, string | boolean | string[]>> | Exercise<{
1610
+ nodeIdsA: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
1611
+ nodeIdsB: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
1612
+ nodeIdsAOpB: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
1613
+ rand: number;
1614
+ }, {
1615
+ isUseExpNotation: boolean;
1616
+ }> | Exercise<{
1610
1617
  nodeIdsF: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
1611
1618
  nodeIdsT: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
1612
1619
  x: number;
@@ -1629,6 +1636,20 @@ declare const mathExercises: (Exercise<{
1629
1636
  }, Record<string, string | boolean | string[]>> | Exercise<{
1630
1637
  a: number;
1631
1638
  k: number;
1639
+ }, Record<string, string | boolean | string[]>> | Exercise<{
1640
+ a: number;
1641
+ k: number;
1642
+ }, Record<string, string | boolean | string[]>> | Exercise<{
1643
+ coeffs: number[];
1644
+ }, Record<string, string | boolean | string[]>> | Exercise<{
1645
+ a: number;
1646
+ }, Record<string, string | boolean | string[]>> | Exercise<{
1647
+ a: number;
1648
+ k: number;
1649
+ type: number;
1650
+ }, Record<string, string | boolean | string[]>> | Exercise<{
1651
+ a: number;
1652
+ k: number;
1632
1653
  }, Record<string, string | boolean | string[]>> | Exercise<{
1633
1654
  pm: number;
1634
1655
  a: number;
@@ -2989,6 +3010,8 @@ declare const mathExercises: (Exercise<{
2989
3010
  pAIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
2990
3011
  p_ABIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
2991
3012
  p_ABarreBIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
3013
+ }, Record<string, string | boolean | string[]>> | Exercise<{
3014
+ percent: number;
2992
3015
  }, Record<string, string | boolean | string[]>> | Exercise<{
2993
3016
  questionType: string;
2994
3017
  value?: string;
@@ -3465,6 +3488,33 @@ declare const mathExercises: (Exercise<{
3465
3488
  superfluousData?: import("./math/utils/sequences/situations/seqGeometricSituations.js").SituationGeometricSuperfluousData;
3466
3489
  rankAsked: number;
3467
3490
  }, import("./exercises/options/optionFirstTermRankOne.js").OptionFirstTermRankOne & import("./exercises/options/optionIsWithSuperfluousData.js").OptionIsWithSuperfluousData> | Exercise<{
3491
+ situationIndex: number;
3492
+ initial: number;
3493
+ reason: number;
3494
+ superfluousData?: import("./math/utils/sequences/situations/seqGeometricSituations.js").SituationGeometricSuperfluousData;
3495
+ }, import("./exercises/options/optionFirstTermRankOne.js").OptionFirstTermRankOne & import("./exercises/options/optionIsWithSuperfluousData.js").OptionIsWithSuperfluousData> | Exercise<{
3496
+ rank1: number;
3497
+ value1: number;
3498
+ rank2: number;
3499
+ value2: number;
3500
+ precisionInitial: number;
3501
+ precisionReason: number;
3502
+ }, import("./exercises/options/optionFirstTermRankOne.js").OptionFirstTermRankOne> | Exercise<{
3503
+ rank1: number;
3504
+ value1: number;
3505
+ rank2: number;
3506
+ value2: number;
3507
+ precisionInitial: number;
3508
+ precisionReason: number;
3509
+ }, import("./exercises/options/optionFirstTermRankOne.js").OptionFirstTermRankOne> | Exercise<{
3510
+ rank1: number;
3511
+ value1: number;
3512
+ rank2: number;
3513
+ value2: number;
3514
+ precisionInitial: number;
3515
+ precisionReason: number;
3516
+ rankAsked: number;
3517
+ }, import("./exercises/options/optionFirstTermRankOne.js").OptionFirstTermRankOne> | Exercise<{
3468
3518
  rank: number;
3469
3519
  coeffs: number[];
3470
3520
  }, {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,aAAa,MAAM,2BAA2B,CAAC;AAE3D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kDAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
@@ -153,7 +153,7 @@ export const latexTester = (latex, isDefaultInMathMode = false) => {
153
153
  }
154
154
  }
155
155
  if (!isDefaultInMathMode && (inDollarMode || inDoubleDollarMode))
156
- throw new Error(`Math mode not finished`);
156
+ throw new Error(`Math mode not finished ${formated}`);
157
157
  if (leftRightCount !== 0)
158
158
  throw new Error("Left right not balanced");
159
159
  if (commandModeCount !== 0)
@@ -1,9 +1,9 @@
1
1
  import "../prototypesEnhancement.js";
2
2
  import { exoTest } from "./exoTest.js";
3
- import { arithmeticFindExplicitFormulaFromTwoTerms, } from "../exercises/math/index.js";
3
+ import { geometricFindExplicitFormulaFromSituation, } from "../exercises/math/index.js";
4
4
  try {
5
5
  for (let i = 0; i < 1000; i++)
6
- exoTest(arithmeticFindExplicitFormulaFromTwoTerms);
6
+ exoTest(geometricFindExplicitFormulaFromSituation);
7
7
  }
8
8
  catch (err) {
9
9
  throw err;
@@ -1,7 +1,7 @@
1
1
  import { Node, NodeIds, NodeOptions, NodeType } from "../node.js";
2
2
  import { FunctionNode, FunctionsIds } from "./functionNode.js";
3
3
  import { AlgebraicNode, SimplifyOptions } from "../algebraicNode.js";
4
- export declare const exp: (a: AlgebraicNode | number | string) => ExpNode;
4
+ export declare const exp: (a: AlgebraicNode | number | string, opts?: NodeOptions) => ExpNode;
5
5
  export declare function isExpNode(a: Node): a is ExpNode;
6
6
  export declare class ExpNode implements FunctionNode {
7
7
  opts?: NodeOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"expNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/expNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAKrE,eAAO,MAAM,GAAG,GAAI,GAAG,aAAa,GAAG,MAAM,GAAG,MAAM,YAIrD,CAAC;AAEF,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;IACf,SAAS,EAAE,OAAO,CAAC;gBACP,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;IAOpD,aAAa;;;;;;IAMb,mBAAmB;IAOnB,YAAY,IAAI,MAAM;IAGtB,mBAAmB,IAAI,MAAM;IAG7B,KAAK,IAAI,MAAM;IAmBf,iBAAiB,IAAI,aAAa,EAAE;IAUpC,cAAc,IAAI,MAAM,EAAE;IAI1B,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,EAAE,IAAI,UAAQ,GAAG,aAAa;IAO7D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAGtC,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAGp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;IAGpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAGxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;CAGxD"}
@@ -4,9 +4,9 @@ import { FunctionsIds, isFunctionNode } from "./functionNode.js";
4
4
  import { isNumberNode } from "../numbers/numberNode.js";
5
5
  import { isLogNode } from "./logNode.js";
6
6
  import { multiply } from "../operators/multiplyNode.js";
7
- export const exp = (a) => {
7
+ export const exp = (a, opts) => {
8
8
  const nodeA = typeof a === "number" ? a.toTree() : typeof a === "string" ? a.toTree() : a;
9
- return new ExpNode(nodeA);
9
+ return new ExpNode(nodeA, opts);
10
10
  };
11
11
  export function isExpNode(a) {
12
12
  return isFunctionNode(a) && a.id === FunctionsIds.exp;
@@ -54,10 +54,7 @@ export class ExpNode {
54
54
  if (this.opts?.useExpNotation) {
55
55
  return `\\exp\\left(${tex}\\right)`;
56
56
  }
57
- const needBraces = tex.length > 1;
58
- if (needBraces)
59
- return `e^{${tex}}`;
60
- return `e^${tex}`;
57
+ return `e^{${tex}}`;
61
58
  }
62
59
  // toMathjs() {
63
60
  // return exp(this.child.toMathjs());
@@ -2,7 +2,7 @@ import { Node, NodeIds, NodeOptions, NodeType, ToTexOptions } from "../node.js";
2
2
  import { CommutativeOperatorNode, OperatorIds } from "./operatorNode.js";
3
3
  import { AlgebraicNode, SimplifyOptions } from "../algebraicNode.js";
4
4
  export declare function isAddNode(a: Node): a is AddNode;
5
- export declare const add: (a: AlgebraicNode | number | string, b: AlgebraicNode | number | string) => AddNode;
5
+ export declare const add: (a: AlgebraicNode | number | string, b: AlgebraicNode | number | string, opts?: NodeOptions) => AddNode;
6
6
  export declare class AddNode implements CommutativeOperatorNode {
7
7
  id: OperatorIds;
8
8
  leftChild: AlgebraicNode;
@@ -1 +1 @@
1
- {"version":3,"file":"addNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/addNode.ts"],"names":[],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AAE;IAK5C,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM;IAerC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAGtC,mBAAmB;IAUnB,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,EAAE,IAAI,UAAQ,GAAG,aAAa;IAyJ7D,aAAa;;;;;;;;;IAOb,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAUpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAMxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;IAMvD,mBAAmB,CAAC,IAAI,CAAC,EAAE,eAAe;CAK3C"}
@@ -16,10 +16,10 @@ import { shuffle } from "../../../utils/alea/shuffle.js";
16
16
  export function isAddNode(a) {
17
17
  return isOperatorNode(a) && a.id === OperatorIds.add;
18
18
  }
19
- export const add = (a, b) => {
19
+ export const add = (a, b, opts) => {
20
20
  const nodeA = typeof a === "number" ? a.toTree() : typeof a === "string" ? a.toTree() : a;
21
21
  const nodeB = typeof b === "number" ? b.toTree() : typeof b === "string" ? b.toTree() : b;
22
- return new AddNode(nodeA, nodeB);
22
+ return new AddNode(nodeA, nodeB, opts);
23
23
  };
24
24
  export class AddNode {
25
25
  id;
@@ -3,7 +3,7 @@ import { OperatorIds, OperatorNode } from "./operatorNode.js";
3
3
  import { AddNode } from "./addNode.js";
4
4
  import { AlgebraicNode, SimplifyOptions } from "../algebraicNode.js";
5
5
  export declare function isSubstractNode(a: Node): a is SubstractNode;
6
- export declare const substract: (a: AlgebraicNode | number | string, b: AlgebraicNode | number | string) => SubstractNode;
6
+ export declare const substract: (a: AlgebraicNode | number | string, b: AlgebraicNode | number | string, opts?: NodeOptions) => SubstractNode;
7
7
  export declare class SubstractNode implements OperatorNode {
8
8
  id: OperatorIds;
9
9
  leftChild: AlgebraicNode;
@@ -1 +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KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM;IAoBrC,mBAAmB,CAAC,IAAI,CAAC,EAAE,eAAe;IAK1C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAStC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe;IAM/B,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAOpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAMxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;IAMvD,OAAO,uBAGL;CACH"}
@@ -9,10 +9,10 @@ import { round } from "../../../math/utils/round.js";
9
9
  export function isSubstractNode(a) {
10
10
  return isOperatorNode(a) && a.id === OperatorIds.substract;
11
11
  }
12
- export const substract = (a, b) => {
12
+ export const substract = (a, b, opts) => {
13
13
  const nodeA = typeof a === "number" ? a.toTree() : typeof a === "string" ? a.toTree() : a;
14
14
  const nodeB = typeof b === "number" ? b.toTree() : typeof b === "string" ? b.toTree() : b;
15
- return new SubstractNode(nodeA, nodeB);
15
+ return new SubstractNode(nodeA, nodeB, opts);
16
16
  };
17
17
  export class SubstractNode {
18
18
  id;
@@ -0,0 +1,7 @@
1
+ import { AlgebraicNode } from "../nodes/algebraicNode.js";
2
+ export declare abstract class NodeComparator {
3
+ static compareViaSub: <T extends AlgebraicNode>(node1: T, node2: T) => -1 | 0 | 1;
4
+ static isEqualViaSub: (node1: AlgebraicNode, node2: AlgebraicNode) => boolean;
5
+ static isEqualViaFrac: (node1: AlgebraicNode, node2: AlgebraicNode) => boolean;
6
+ }
7
+ //# sourceMappingURL=nodeComparator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodeComparator.d.ts","sourceRoot":"","sources":["../../../src/tree/utilities/nodeComparator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAM1D,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,CAER;IAIF,MAAM,CAAC,cAAc,GACnB,OAAO,aAAa,EACpB,OAAO,aAAa,KACnB,OAAO,CAgBR;CACH"}
@@ -0,0 +1,88 @@
1
+ import { frac } from "../nodes/operators/fractionNode.js";
2
+ import { substract } from "../nodes/operators/substractNode.js";
3
+ import { NodeRewriter } from "./nodeRewriter.js";
4
+ import { NodeSimplifier } from "./nodeSimplifier.js";
5
+ export class NodeComparator {
6
+ //via sub
7
+ static compareViaSub = (node1, node2) => {
8
+ const isSameTex = () => {
9
+ return node1.toTex() === node2.toTex();
10
+ };
11
+ function compareValueSub(valueSub) {
12
+ if (isNaN(valueSub)) {
13
+ throw new Error("valueSub is NaN");
14
+ }
15
+ else {
16
+ if (valueSub === 0) {
17
+ return 0;
18
+ }
19
+ else if (valueSub > 0) {
20
+ return 1;
21
+ }
22
+ else {
23
+ return -1;
24
+ }
25
+ }
26
+ }
27
+ const compareUsingEvaluate = () => {
28
+ const valueSub = substract(node1, node2).evaluate();
29
+ return compareValueSub(valueSub);
30
+ };
31
+ const isEquivalent = () => {
32
+ const [arrNode1, arrNode2] = [node1, node2].map((node) => NodeRewriter.getArrNodeEquivalent(node));
33
+ return arrNode1.some((node1Equivalent) => {
34
+ return arrNode2.some((node2Equivalent) => {
35
+ try {
36
+ const nodeSub = substract(node1Equivalent, node2Equivalent);
37
+ const nodeSubSimplified = NodeSimplifier.simplifyByVibrating(nodeSub);
38
+ const valueSub = nodeSubSimplified.evaluate();
39
+ return compareValueSub(valueSub);
40
+ }
41
+ catch (_) {
42
+ return false;
43
+ }
44
+ });
45
+ });
46
+ };
47
+ try {
48
+ if (isSameTex()) {
49
+ return 0;
50
+ }
51
+ else {
52
+ return compareUsingEvaluate();
53
+ }
54
+ }
55
+ catch (_) {
56
+ try {
57
+ if (isEquivalent()) {
58
+ return 0;
59
+ }
60
+ else {
61
+ return 1;
62
+ }
63
+ }
64
+ catch (_) {
65
+ return 1;
66
+ }
67
+ }
68
+ };
69
+ static isEqualViaSub = (node1, node2) => {
70
+ return this.compareViaSub(node1, node2) === 0;
71
+ };
72
+ //via frac
73
+ static isEqualViaFrac = (node1, node2) => {
74
+ const [arrNode1, arrNode2] = [node1, node2].map((node) => NodeRewriter.getArrNodeEquivalent(node));
75
+ return arrNode1.some((node1Equivalent) => {
76
+ return arrNode2.some((node2Equivalent) => {
77
+ try {
78
+ const nodeFrac = frac(node1Equivalent, node2Equivalent);
79
+ const nodeFracSimplified = NodeSimplifier.simplifyByVibrating(nodeFrac);
80
+ return this.isEqualViaSub(nodeFracSimplified, (1).toTree());
81
+ }
82
+ catch (_) {
83
+ return false;
84
+ }
85
+ });
86
+ });
87
+ };
88
+ }
@@ -0,0 +1,5 @@
1
+ import { AlgebraicNode } from "../nodes/algebraicNode.js";
2
+ export declare abstract class NodeInspector {
3
+ static getChildren(algebraicNode: AlgebraicNode): AlgebraicNode[];
4
+ }
5
+ //# sourceMappingURL=nodeInspector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodeInspector.d.ts","sourceRoot":"","sources":["../../../src/tree/utilities/nodeInspector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAI1D,8BAAsB,aAAa;IACjC,MAAM,CAAC,WAAW,CAAC,aAAa,EAAE,aAAa;CAShD"}
@@ -0,0 +1,15 @@
1
+ import { isFunctionNode } from "../nodes/functions/functionNode.js";
2
+ import { isOperatorNode } from "../nodes/operators/operatorNode.js";
3
+ export class NodeInspector {
4
+ static getChildren(algebraicNode) {
5
+ if (isOperatorNode(algebraicNode)) {
6
+ return [algebraicNode.leftChild, algebraicNode.rightChild];
7
+ }
8
+ else if (isFunctionNode(algebraicNode)) {
9
+ return [algebraicNode.child];
10
+ }
11
+ else {
12
+ return [];
13
+ }
14
+ }
15
+ }