math-exercises 3.0.202 → 3.0.204

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 (133) hide show
  1. package/lib/exercises/exercise.d.ts +4 -0
  2. package/lib/exercises/exercise.d.ts.map +1 -1
  3. package/lib/exercises/math/derivation/derivative/trigo/productOfSinAXPlusBCosCXPlusDDerivative.js +1 -1
  4. package/lib/exercises/math/derivation/derivative/trigo/sinAndCosMixedWithSquareDerivative.js +1 -1
  5. package/lib/exercises/math/derivation/derivative/trigo/sinCosDerivativeRewriteUsingCos2PlusSin2Equals1.d.ts.map +1 -1
  6. package/lib/exercises/math/derivation/derivative/trigo/sinCosDerivativeRewriteUsingCos2PlusSin2Equals1.js +1 -1
  7. package/lib/exercises/math/derivation/variations/index.d.ts.map +1 -1
  8. package/lib/exercises/math/derivation/variations/index.js +1 -0
  9. package/lib/exercises/math/derivation/variations/signVarTableWithExtremumTestExercise.d.ts +9 -0
  10. package/lib/exercises/math/derivation/variations/signVarTableWithExtremumTestExercise.d.ts.map +1 -0
  11. package/lib/exercises/math/derivation/variations/signVarTableWithExtremumTestExercise.js +191 -0
  12. package/lib/exercises/math/functions/continuity/equationNumberOfSolutionsFromVarTable.d.ts +9 -0
  13. package/lib/exercises/math/functions/continuity/equationNumberOfSolutionsFromVarTable.d.ts.map +1 -0
  14. package/lib/exercises/math/functions/continuity/equationNumberOfSolutionsFromVarTable.js +176 -0
  15. package/lib/exercises/math/functions/continuity/index.d.ts +6 -0
  16. package/lib/exercises/math/functions/continuity/index.d.ts.map +1 -0
  17. package/lib/exercises/math/functions/continuity/index.js +5 -0
  18. package/lib/exercises/math/functions/continuity/isFunctionContinuousFromGraph.d.ts +9 -0
  19. package/lib/exercises/math/functions/continuity/isFunctionContinuousFromGraph.d.ts.map +1 -0
  20. package/lib/exercises/math/functions/continuity/isFunctionContinuousFromGraph.js +193 -0
  21. package/lib/exercises/math/functions/continuity/piecewiseFunctionContinuity.d.ts +10 -0
  22. package/lib/exercises/math/functions/continuity/piecewiseFunctionContinuity.d.ts.map +1 -0
  23. package/lib/exercises/math/functions/continuity/piecewiseFunctionContinuity.js +150 -0
  24. package/lib/exercises/math/functions/continuity/signTableFromVarTableWithZeroes.d.ts +9 -0
  25. package/lib/exercises/math/functions/continuity/signTableFromVarTableWithZeroes.d.ts.map +1 -0
  26. package/lib/exercises/math/functions/continuity/signTableFromVarTableWithZeroes.js +162 -0
  27. package/lib/exercises/math/functions/continuity/thirdDegreeZeroesFramingWithCalculator.d.ts +8 -0
  28. package/lib/exercises/math/functions/continuity/thirdDegreeZeroesFramingWithCalculator.d.ts.map +1 -0
  29. package/lib/exercises/math/functions/continuity/thirdDegreeZeroesFramingWithCalculator.js +194 -0
  30. package/lib/exercises/math/functions/index.d.ts +1 -0
  31. package/lib/exercises/math/functions/index.d.ts.map +1 -1
  32. package/lib/exercises/math/functions/index.js +1 -0
  33. package/lib/exercises/math/functions/variations/index.d.ts.map +1 -1
  34. package/lib/exercises/math/functions/variations/index.js +1 -0
  35. package/lib/exercises/math/functions/variations/varTableWithExtremumTestExercise.d.ts +9 -0
  36. package/lib/exercises/math/functions/variations/varTableWithExtremumTestExercise.d.ts.map +1 -0
  37. package/lib/exercises/math/functions/variations/varTableWithExtremumTestExercise.js +183 -0
  38. package/lib/exercises/math/geometry/angles/anglesUsingIsParallel.d.ts.map +1 -1
  39. package/lib/exercises/math/geometry/angles/anglesUsingIsParallel.js +172 -51
  40. package/lib/exercises/math/geometry/angles/index.d.ts +1 -0
  41. package/lib/exercises/math/geometry/angles/index.d.ts.map +1 -1
  42. package/lib/exercises/math/geometry/angles/index.js +1 -1
  43. package/lib/exercises/math/limits/index.d.ts +1 -5
  44. package/lib/exercises/math/limits/index.d.ts.map +1 -1
  45. package/lib/exercises/math/limits/index.js +1 -5
  46. package/lib/exercises/math/limits/limitReading.d.ts.map +1 -1
  47. package/lib/exercises/math/limits/limitReading.js +70 -0
  48. package/lib/exercises/math/limits/polynomLimit.d.ts.map +1 -1
  49. package/lib/exercises/math/limits/polynomLimit.js +55 -4
  50. package/lib/exercises/math/limits/polynomLimitNoFI.d.ts.map +1 -1
  51. package/lib/exercises/math/limits/polynomLimitNoFI.js +35 -2
  52. package/lib/exercises/math/limits/sequenceGeometricLimit.d.ts.map +1 -1
  53. package/lib/exercises/math/limits/sequenceGeometricLimit.js +45 -9
  54. package/lib/exercises/math/limits/sequencePolynomLimit.d.ts.map +1 -1
  55. package/lib/exercises/math/limits/sequencePolynomLimit.js +56 -3
  56. package/lib/exercises/math/limits/sequencePolynomNoFILimit.d.ts.map +1 -1
  57. package/lib/exercises/math/limits/sequencePolynomNoFILimit.js +32 -0
  58. package/lib/exercises/math/limits/sequencePolynomProductLimit.d.ts.map +1 -1
  59. package/lib/exercises/math/limits/sequencePolynomProductLimit.js +33 -3
  60. package/lib/exercises/math/limits/sequenceRationalFracLimit.d.ts.map +1 -1
  61. package/lib/exercises/math/limits/sequenceRationalFracLimit.js +2 -2
  62. package/lib/exercises/math/limits/sequences/index.d.ts +6 -0
  63. package/lib/exercises/math/limits/sequences/index.d.ts.map +1 -0
  64. package/lib/exercises/math/limits/sequences/index.js +5 -0
  65. package/lib/exercises/math/limits/sequences/sequenceGeometricLimit.d.ts +9 -0
  66. package/lib/exercises/math/limits/sequences/sequenceGeometricLimit.d.ts.map +1 -0
  67. package/lib/exercises/math/limits/sequences/sequenceGeometricLimit.js +110 -0
  68. package/lib/exercises/math/limits/sequences/sequencePolynomLimit.d.ts +7 -0
  69. package/lib/exercises/math/limits/sequences/sequencePolynomLimit.d.ts.map +1 -0
  70. package/lib/exercises/math/limits/sequences/sequencePolynomLimit.js +116 -0
  71. package/lib/exercises/math/limits/sequences/sequencePolynomNoFILimit.d.ts +7 -0
  72. package/lib/exercises/math/limits/sequences/sequencePolynomNoFILimit.d.ts.map +1 -0
  73. package/lib/exercises/math/limits/sequences/sequencePolynomNoFILimit.js +95 -0
  74. package/lib/exercises/math/limits/sequences/sequencePolynomProductLimit.d.ts +8 -0
  75. package/lib/exercises/math/limits/sequences/sequencePolynomProductLimit.d.ts.map +1 -0
  76. package/lib/exercises/math/limits/sequences/sequencePolynomProductLimit.js +111 -0
  77. package/lib/exercises/math/limits/sequences/sequenceRationalFracLimit.d.ts +8 -0
  78. package/lib/exercises/math/limits/sequences/sequenceRationalFracLimit.d.ts.map +1 -0
  79. package/lib/exercises/math/limits/sequences/sequenceRationalFracLimit.js +114 -0
  80. package/lib/exercises/math/sequences/index.d.ts +1 -0
  81. package/lib/exercises/math/sequences/index.d.ts.map +1 -1
  82. package/lib/exercises/math/sequences/index.js +1 -0
  83. package/lib/exercises/math/sequences/proofByInduction/index.d.ts +5 -0
  84. package/lib/exercises/math/sequences/proofByInduction/index.d.ts.map +1 -0
  85. package/lib/exercises/math/sequences/proofByInduction/index.js +4 -0
  86. package/lib/exercises/math/sequences/proofByInduction/proofByInductionCheckInitialization.d.ts +10 -0
  87. package/lib/exercises/math/sequences/proofByInduction/proofByInductionCheckInitialization.d.ts.map +1 -0
  88. package/lib/exercises/math/sequences/proofByInduction/proofByInductionCheckInitialization.js +236 -0
  89. package/lib/exercises/math/sequences/proofByInduction/proofByInductionReorderProof.d.ts +13 -0
  90. package/lib/exercises/math/sequences/proofByInduction/proofByInductionReorderProof.d.ts.map +1 -0
  91. package/lib/exercises/math/sequences/proofByInduction/proofByInductionReorderProof.js +244 -0
  92. package/lib/exercises/math/sequences/proofByInduction/proofByInductionSituations.d.ts +98 -0
  93. package/lib/exercises/math/sequences/proofByInduction/proofByInductionSituations.d.ts.map +1 -0
  94. package/lib/exercises/math/sequences/proofByInduction/proofByInductionSituations.js +175 -0
  95. package/lib/exercises/math/sequences/proofByInduction/proofByInductionWriteMissingStep.d.ts +13 -0
  96. package/lib/exercises/math/sequences/proofByInduction/proofByInductionWriteMissingStep.d.ts.map +1 -0
  97. package/lib/exercises/math/sequences/proofByInduction/proofByInductionWriteMissingStep.js +317 -0
  98. package/lib/exercises/math/sequences/proofByInduction/proofByInductionWritePropAtRankKPlus1.d.ts +13 -0
  99. package/lib/exercises/math/sequences/proofByInduction/proofByInductionWritePropAtRankKPlus1.d.ts.map +1 -0
  100. package/lib/exercises/math/sequences/proofByInduction/proofByInductionWritePropAtRankKPlus1.js +265 -0
  101. package/lib/exercises/vea/polynomialVEA.d.ts.map +1 -1
  102. package/lib/exercises/vea/polynomialVEA.js +4 -0
  103. package/lib/index.d.ts +68 -13
  104. package/lib/index.d.ts.map +1 -1
  105. package/lib/math/geometry/point.d.ts.map +1 -1
  106. package/lib/math/geometry/point.js +1 -1
  107. package/lib/math/utils/functions/functionDecomposition.d.ts +2 -2
  108. package/lib/math/utils/functions/functionDecomposition.d.ts.map +1 -1
  109. package/lib/tests/exoTest.d.ts.map +1 -1
  110. package/lib/tests/exoTest.js +7 -11
  111. package/lib/tests/questionTest.d.ts.map +1 -1
  112. package/lib/tests/questionTest.js +7 -3
  113. package/lib/tests/singleExo.test.d.ts.map +1 -1
  114. package/lib/tests/singleExo.test.js +2 -2
  115. package/lib/tree/nodes/node.d.ts +2 -1
  116. package/lib/tree/nodes/node.d.ts.map +1 -1
  117. package/lib/tree/nodes/node.js +1 -0
  118. package/lib/tree/nodes/student/iDontKnowNode.d.ts +26 -0
  119. package/lib/tree/nodes/student/iDontKnowNode.d.ts.map +1 -0
  120. package/lib/tree/nodes/student/iDontKnowNode.js +63 -0
  121. package/lib/tree/parsers/latexParser.d.ts +3 -2
  122. package/lib/tree/parsers/latexParser.d.ts.map +1 -1
  123. package/lib/tree/parsers/latexParser.js +7 -0
  124. package/lib/tree/parsers/monomParser.d.ts +1 -1
  125. package/lib/tree/parsers/monomParser.d.ts.map +1 -1
  126. package/lib/tree/parsers/polynomialParser.d.ts +1 -1
  127. package/lib/tree/parsers/polynomialParser.d.ts.map +1 -1
  128. package/lib/tree/parsers/trinomParser.d.ts +1 -1
  129. package/lib/tree/parsers/trinomParser.d.ts.map +1 -1
  130. package/lib/tree/utilities/nodeComparator.d.ts +3 -1
  131. package/lib/tree/utilities/nodeComparator.d.ts.map +1 -1
  132. package/lib/tree/utilities/nodeComparator.js +63 -5
  133. package/package.json +1 -1
@@ -1,11 +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";
8
10
  import { round } from "../../math/utils/round.js";
11
+ import { isIDontKnowNode } from "../nodes/student/iDontKnowNode.js";
9
12
  export class NodeComparator {
10
13
  //via sub
11
14
  static compareViaSub = (node1, node2) => {
@@ -71,10 +74,16 @@ export class NodeComparator {
71
74
  }
72
75
  };
73
76
  static isEqualViaSub = (node1, node2) => {
77
+ if (isIDontKnowNode(node1) || isIDontKnowNode(node2)) {
78
+ return false;
79
+ }
74
80
  return this.compareViaSub(node1, node2) === 0;
75
81
  };
76
82
  //via frac
77
83
  static isEqualViaFrac = (node1, node2) => {
84
+ if (isIDontKnowNode(node1) || isIDontKnowNode(node2)) {
85
+ return false;
86
+ }
78
87
  const [arrNode1, arrNode2] = [node1, node2].map((node) => NodeRewriter.getArrNodeEquivalent(node));
79
88
  return arrNode1.some((node1Equivalent) => {
80
89
  return arrNode2.some((node2Equivalent) => {
@@ -90,27 +99,37 @@ export class NodeComparator {
90
99
  });
91
100
  };
92
101
  //via random evaluations
93
- static isEqualViaRandomEvaluations(node1, node2, nbRandomEvaluations, precision = 8) {
94
- const getSafeEvaluationDictForEqualityCheck = (node1, node2, nbSafeX = 4) => {
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) => {
95
111
  const dict = {};
96
112
  let counter = -1;
97
113
  while (Object.keys(dict).length < nbSafeX && counter < 1000) {
98
114
  counter++;
99
- const x = randfloat(-20, 100, 3);
115
+ const x = randFunc();
100
116
  let value1;
101
117
  let value2;
102
118
  try {
103
- value1 = node1.evaluate({ x });
119
+ value1 = node1.evaluate({ [nodeVar.name]: x });
104
120
  }
105
121
  catch (_) {
106
122
  continue;
107
123
  }
108
124
  try {
109
- value2 = node2.evaluate({ x });
125
+ value2 = node2.evaluate({ [nodeVar.name]: x });
110
126
  }
111
127
  catch (_) {
112
128
  continue;
113
129
  }
130
+ // console.log("x", x);
131
+ // console.log("value1", value1);
132
+ // console.log("value2", value2);
114
133
  const [isValidValue1, isValidValue2] = [value1, value2].map((value) => value !== undefined &&
115
134
  !isNaN(value) &&
116
135
  !isInfiniteNode(value.toTree()));
@@ -128,10 +147,49 @@ export class NodeComparator {
128
147
  return Object.values(getSafeEvaluationDictForEqualityCheck(node1, node2, nbRandomEvaluations)).every((arrSafeEval) => {
129
148
  return arrSafeEval.slice(1).every((safeEval) => {
130
149
  const valueSubRounded = round(substract(arrSafeEval[0].value, safeEval.value).evaluate(), precision);
150
+ // console.log("valueSubRounded", valueSubRounded);
131
151
  return valueSubRounded === 0;
132
152
  });
133
153
  });
134
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
+ });
191
+ });
192
+ }
135
193
  //discreteSets, etc.
136
194
  static isNodeInDiscreteSet = (node, nodeDiscreteSet) => nodeDiscreteSet.elements.some((nodeInSet) => NodeComparator.isEqualViaSub(node, nodeInSet));
137
195
  static isTupleInCartesianProductOfDiscreteSets = (tuple, arrDiscreteSet) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "math-exercises",
3
3
  "type": "module",
4
- "version": "3.0.202",
4
+ "version": "3.0.204",
5
5
  "description": "Math exercises generator for middle school and high school",
6
6
  "main": "lib/index.js",
7
7
  "files": [