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.
- package/lib/exercises/exercise.d.ts +4 -0
- package/lib/exercises/exercise.d.ts.map +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.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/trigo/sinCosDerivativeRewriteUsingCos2PlusSin2Equals1.js +1 -1
- package/lib/exercises/math/derivation/variations/index.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/index.js +1 -0
- package/lib/exercises/math/derivation/variations/signVarTableWithExtremumTestExercise.d.ts +9 -0
- package/lib/exercises/math/derivation/variations/signVarTableWithExtremumTestExercise.d.ts.map +1 -0
- package/lib/exercises/math/derivation/variations/signVarTableWithExtremumTestExercise.js +191 -0
- package/lib/exercises/math/functions/continuity/equationNumberOfSolutionsFromVarTable.d.ts +9 -0
- package/lib/exercises/math/functions/continuity/equationNumberOfSolutionsFromVarTable.d.ts.map +1 -0
- package/lib/exercises/math/functions/continuity/equationNumberOfSolutionsFromVarTable.js +176 -0
- package/lib/exercises/math/functions/continuity/index.d.ts +6 -0
- package/lib/exercises/math/functions/continuity/index.d.ts.map +1 -0
- package/lib/exercises/math/functions/continuity/index.js +5 -0
- package/lib/exercises/math/functions/continuity/isFunctionContinuousFromGraph.d.ts +9 -0
- package/lib/exercises/math/functions/continuity/isFunctionContinuousFromGraph.d.ts.map +1 -0
- package/lib/exercises/math/functions/continuity/isFunctionContinuousFromGraph.js +193 -0
- package/lib/exercises/math/functions/continuity/piecewiseFunctionContinuity.d.ts +10 -0
- package/lib/exercises/math/functions/continuity/piecewiseFunctionContinuity.d.ts.map +1 -0
- package/lib/exercises/math/functions/continuity/piecewiseFunctionContinuity.js +150 -0
- package/lib/exercises/math/functions/continuity/signTableFromVarTableWithZeroes.d.ts +9 -0
- package/lib/exercises/math/functions/continuity/signTableFromVarTableWithZeroes.d.ts.map +1 -0
- package/lib/exercises/math/functions/continuity/signTableFromVarTableWithZeroes.js +162 -0
- package/lib/exercises/math/functions/continuity/thirdDegreeZeroesFramingWithCalculator.d.ts +8 -0
- package/lib/exercises/math/functions/continuity/thirdDegreeZeroesFramingWithCalculator.d.ts.map +1 -0
- package/lib/exercises/math/functions/continuity/thirdDegreeZeroesFramingWithCalculator.js +194 -0
- package/lib/exercises/math/functions/index.d.ts +1 -0
- package/lib/exercises/math/functions/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/index.js +1 -0
- package/lib/exercises/math/functions/variations/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/variations/index.js +1 -0
- package/lib/exercises/math/functions/variations/varTableWithExtremumTestExercise.d.ts +9 -0
- package/lib/exercises/math/functions/variations/varTableWithExtremumTestExercise.d.ts.map +1 -0
- package/lib/exercises/math/functions/variations/varTableWithExtremumTestExercise.js +183 -0
- 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/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/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/vea/polynomialVEA.d.ts.map +1 -1
- package/lib/exercises/vea/polynomialVEA.js +4 -0
- package/lib/index.d.ts +68 -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/utils/functions/functionDecomposition.d.ts +2 -2
- package/lib/math/utils/functions/functionDecomposition.d.ts.map +1 -1
- package/lib/tests/exoTest.d.ts.map +1 -1
- package/lib/tests/exoTest.js +7 -11
- package/lib/tests/questionTest.d.ts.map +1 -1
- package/lib/tests/questionTest.js +7 -3
- package/lib/tests/singleExo.test.d.ts.map +1 -1
- 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 +63 -5
- 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
|
-
|
|
94
|
-
|
|
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 =
|
|
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) => {
|