math-exercises 3.0.73 → 3.0.75
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/calcul/arithmetics/divisorsList.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/divisorsList.js +37 -2
- package/lib/exercises/math/calcul/arithmetics/index.d.ts +2 -0
- package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/index.js +2 -0
- package/lib/exercises/math/calcul/arithmetics/isInequalityTrue.js +2 -2
- package/lib/exercises/math/calcul/arithmetics/isMultipleOrDivisor.d.ts +9 -0
- package/lib/exercises/math/calcul/arithmetics/isMultipleOrDivisor.d.ts.map +1 -0
- package/lib/exercises/math/calcul/arithmetics/isMultipleOrDivisor.js +123 -0
- package/lib/exercises/math/calcul/arithmetics/paritySumsAndProducts.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/paritySumsAndProducts.js +114 -0
- package/lib/exercises/math/calcul/arithmetics/pgcdCalcul.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/pgcdCalcul.js +28 -1
- package/lib/exercises/math/calcul/arithmetics/ppcmCalcul.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/ppcmCalcul.js +1 -0
- package/lib/exercises/math/calcul/arithmetics/primeNumbers.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/primeNumbers.js +37 -2
- package/lib/exercises/math/calcul/arithmetics/whichMultipleAmI.d.ts +9 -0
- package/lib/exercises/math/calcul/arithmetics/whichMultipleAmI.d.ts.map +1 -0
- package/lib/exercises/math/calcul/arithmetics/whichMultipleAmI.js +131 -0
- package/lib/exercises/math/calcul/operations/operationsPrioritiesParenthesis.js +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivitySubstract.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivitySubstract.js +52 -4
- package/lib/exercises/math/calculLitteral/distributivity/identitiesWithNonIntegers.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/identitiesWithNonIntegers.js +109 -4
- package/lib/exercises/math/calculLitteral/inequations/squareFunctionInequation.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/inequations/squareFunctionInequation.js +15 -0
- package/lib/exercises/math/functions/affines/leadingCoefficientCalculV1.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/leadingCoefficientCalculV1.js +52 -0
- package/lib/exercises/math/functions/basics/index.d.ts +0 -1
- package/lib/exercises/math/functions/basics/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/index.js +1 -1
- package/lib/exercises/math/functions/basics/inverseImageFunctionGeogebra.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/inverseImageFunctionGeogebra.js +24 -0
- package/lib/exercises/math/functions/basics/inverseImageFunctionTable.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/inverseImageFunctionTable.js +19 -0
- package/lib/exercises/math/functions/cube/cubicEquation.d.ts.map +1 -1
- package/lib/exercises/math/functions/cube/cubicEquation.js +16 -8
- package/lib/exercises/math/functions/parity/parityFromAlgebra.d.ts.map +1 -1
- package/lib/exercises/math/functions/parity/parityFromAlgebra.js +57 -2
- package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.js +34 -31
- package/lib/exercises/math/geometry/thales/thalesCalcul.d.ts.map +1 -1
- package/lib/exercises/math/geometry/thales/thalesCalcul.js +79 -8
- package/lib/exercises/math/geometry/vectors/paralellismViaColinearity.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/paralellismViaColinearity.js +39 -1
- package/lib/exercises/math/geometry/vectors/parallelogramViaEqualVectors.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/parallelogramViaEqualVectors.js +32 -1
- package/lib/exercises/math/geometry/vectors/vectorLinearCombination.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/vectorLinearCombination.js +40 -2
- package/lib/exercises/math/percent/evolutions/findRightCalculForPriceEvolution.d.ts.map +1 -1
- package/lib/exercises/math/percent/evolutions/findRightCalculForPriceEvolution.js +39 -8
- package/lib/exercises/math/probaStat/cardBasicProbas.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/cardBasicProbas.js +37 -0
- package/lib/exercises/math/probaStat/issuesCountingForCards.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/issuesCountingForCards.js +27 -0
- package/lib/exercises/math/probaStat/probaFromTableNoContext.d.ts +3 -1
- package/lib/exercises/math/probaStat/probaFromTableNoContext.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probaFromTableNoContext.js +126 -7
- package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probaFromTableWithContext.js +131 -3
- package/lib/exercises/math/probaStat/stats1var/choseReasoningForIndicator.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/choseReasoningForIndicator.js +17 -10
- package/lib/exercises/math/probaStat/stats1var/median.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/median.js +35 -0
- package/lib/exercises/math/probaStat/stats1var/medianList.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/medianList.js +18 -0
- package/lib/exercises/math/probaStat/stats1var/quartiles.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/quartiles.js +37 -0
- package/lib/exercises/math/probaStat/stats1var/quartilesList.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/quartilesList.js +23 -0
- package/lib/exercises/math/python/index.d.ts +1 -0
- package/lib/exercises/math/python/index.d.ts.map +1 -1
- package/lib/exercises/math/python/index.js +1 -0
- package/lib/exercises/math/python/whileLoopCount.d.ts +8 -0
- package/lib/exercises/math/python/whileLoopCount.d.ts.map +1 -0
- package/lib/exercises/math/python/whileLoopCount.js +94 -0
- package/lib/exercises/math/squareRoots/simpifySquareRoot.d.ts.map +1 -1
- package/lib/exercises/math/squareRoots/simpifySquareRoot.js +41 -0
- package/lib/exercises/math/squareRoots/squareRootEquation.d.ts.map +1 -1
- package/lib/exercises/math/squareRoots/squareRootEquation.js +25 -0
- package/lib/exercises/math/squareRoots/squareRootIdentities.d.ts.map +1 -1
- package/lib/exercises/math/squareRoots/squareRootIdentities.js +106 -5
- package/lib/exercises/math/squareRoots/squareRootsDistributivity.d.ts.map +1 -1
- package/lib/exercises/math/squareRoots/squareRootsDistributivity.js +29 -2
- package/lib/exercises/math/squareRoots/squareRootsFractions.d.ts.map +1 -1
- package/lib/exercises/math/squareRoots/squareRootsFractions.js +33 -4
- package/lib/exercises/math/squareRoots/squareRootsProducts.d.ts.map +1 -1
- package/lib/exercises/math/squareRoots/squareRootsProducts.js +27 -4
- package/lib/exercises/math/squareRoots/squareRootsSum.d.ts.map +1 -1
- package/lib/exercises/math/squareRoots/squareRootsSum.js +33 -1
- package/lib/exercises/math/squareRoots/squareRootsToSquare.d.ts.map +1 -1
- package/lib/exercises/math/squareRoots/squareRootsToSquare.js +46 -4
- package/lib/index.d.ts +13 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/playground.d.ts.map +1 -1
- package/lib/playground.js +9 -5
- package/lib/tree/nodes/functions/absNode.d.ts +2 -2
- package/lib/tree/nodes/functions/absNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/absNode.js +5 -2
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +15 -6
- package/package.json +1 -1
|
@@ -6,7 +6,8 @@ import { randint } from "../../../math/utils/random/randint.js";
|
|
|
6
6
|
import { SqrtNode } from "../../../tree/nodes/functions/sqrtNode.js";
|
|
7
7
|
import { NumberNode } from "../../../tree/nodes/numbers/numberNode.js";
|
|
8
8
|
import { AddNode } from "../../../tree/nodes/operators/addNode.js";
|
|
9
|
-
import { MultiplyNode } from "../../../tree/nodes/operators/multiplyNode.js";
|
|
9
|
+
import { multiply, MultiplyNode, } from "../../../tree/nodes/operators/multiplyNode.js";
|
|
10
|
+
import { operatorComposition } from "../../../tree/utilities/operatorComposition.js";
|
|
10
11
|
import { coinFlip } from "../../../utils/alea/coinFlip.js";
|
|
11
12
|
import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
|
|
12
13
|
//a sqrt(x*b) + c sqrt(y*b) (+ d sqrt(z*b))
|
|
@@ -54,6 +55,34 @@ const getSquareRootsSumQuestion = () => {
|
|
|
54
55
|
const identifiers = { a, b, c, d, x, y, z };
|
|
55
56
|
return getQuestionFromIdentifiers(identifiers);
|
|
56
57
|
};
|
|
58
|
+
const getHint = (identifiers) => {
|
|
59
|
+
return `Simplifie d'abord chacune des racines carrés, puis additionne les résultats. `;
|
|
60
|
+
};
|
|
61
|
+
const getCorrection = (identifiers) => {
|
|
62
|
+
const { a, b, c, d, x, y, z } = identifiers;
|
|
63
|
+
const aNode = new NumberNode(a);
|
|
64
|
+
const cNode = new NumberNode(c);
|
|
65
|
+
const xbNode = new NumberNode(b * x);
|
|
66
|
+
const ybNode = new NumberNode(b * y);
|
|
67
|
+
const coeffs = [x, y, z];
|
|
68
|
+
const sqrts = coeffs
|
|
69
|
+
.filter((e) => e !== undefined)
|
|
70
|
+
.map((x) => new SqrtNode(new NumberNode(x * b)));
|
|
71
|
+
const sqrtsSimps = Array.from(new Set(coeffs.filter((e) => e !== undefined))).map((x) => new SqrtNode(new NumberNode(x * b)));
|
|
72
|
+
return `On simplifie d'abord chacune des racines carrés :
|
|
73
|
+
|
|
74
|
+
${sqrtsSimps
|
|
75
|
+
.map((s, i) => `- ${coeffs[i] === 1
|
|
76
|
+
? `$${s.toTex()}$ n'est pas simplifiable `
|
|
77
|
+
: `$${s.toTex()} = ${s.simplify().toTex()}$ `}`)
|
|
78
|
+
.join("\n")}
|
|
79
|
+
|
|
80
|
+
On a alors :
|
|
81
|
+
|
|
82
|
+
$$
|
|
83
|
+
${operatorComposition(AddNode, sqrts.map((s, i) => multiply([a, c, d][i], s.simplify()))).toTex()}= ${getAnswer(identifiers)}
|
|
84
|
+
$$`;
|
|
85
|
+
};
|
|
57
86
|
const getQuestionFromIdentifiers = (identifiers) => {
|
|
58
87
|
const question = {
|
|
59
88
|
answer: getAnswer(identifiers),
|
|
@@ -61,6 +90,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
|
|
|
61
90
|
keys: [],
|
|
62
91
|
answerFormat: "tex",
|
|
63
92
|
identifiers,
|
|
93
|
+
hint: getHint(identifiers),
|
|
94
|
+
correction: getCorrection(identifiers),
|
|
64
95
|
};
|
|
65
96
|
return question;
|
|
66
97
|
};
|
|
@@ -92,4 +123,5 @@ export const squareRootsSum = {
|
|
|
92
123
|
isAnswerValid,
|
|
93
124
|
subject: "Mathématiques",
|
|
94
125
|
getQuestionFromIdentifiers,
|
|
126
|
+
hasHintAndCorrection: true,
|
|
95
127
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"squareRootsToSquare.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/squareRoots/squareRootsToSquare.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"squareRootsToSquare.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/squareRoots/squareRootsToSquare.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAQ7C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,eAAe,CAAC;IACnB,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAqKF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAgBrD,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercis
|
|
|
2
2
|
import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
|
|
3
3
|
import { RationalConstructor } from "../../../math/numbers/rationals/rational.js";
|
|
4
4
|
import { randint } from "../../../math/utils/random/randint.js";
|
|
5
|
+
import { abs } from "../../../tree/nodes/functions/absNode.js";
|
|
5
6
|
import { opposite } from "../../../tree/nodes/functions/oppositeNode.js";
|
|
6
7
|
import { sqrt } from "../../../tree/nodes/functions/sqrtNode.js";
|
|
7
8
|
import { NodeConstructor, } from "../../../tree/nodes/nodeConstructor.js";
|
|
@@ -10,6 +11,7 @@ import { multiply } from "../../../tree/nodes/operators/multiplyNode.js";
|
|
|
10
11
|
import { square } from "../../../tree/nodes/operators/powerNode.js";
|
|
11
12
|
import { rationalParser } from "../../../tree/parsers/rationalParser.js";
|
|
12
13
|
import { coinFlip } from "../../../utils/alea/coinFlip.js";
|
|
14
|
+
import { alignTex } from "../../../utils/latex/alignTex.js";
|
|
13
15
|
const getPropositions = (n, { answer, a, isSquareInside, k }) => {
|
|
14
16
|
const propositions = [];
|
|
15
17
|
addValidProp(propositions, answer);
|
|
@@ -54,8 +56,47 @@ ${(isSquareInside
|
|
|
54
56
|
: square(multiply(a, sqrt(kNode)))).toTex()}
|
|
55
57
|
$$`;
|
|
56
58
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
const getHint = (identifiers) => {
|
|
60
|
+
const { a, k, isSquareInside } = identifiers;
|
|
61
|
+
if (isSquareInside)
|
|
62
|
+
return `Utilise la propriété suivante : $\\sqrt{x^2} = |x|$.`;
|
|
63
|
+
return `Utilise les propriétés suivantes :
|
|
64
|
+
|
|
65
|
+
- $(ab)^2 = a^2\\times b^2$
|
|
66
|
+
- $\\sqrt{x}^2 = x$`;
|
|
67
|
+
};
|
|
68
|
+
const getCorrection = (identifiers) => {
|
|
69
|
+
const { a, k, isSquareInside } = identifiers;
|
|
70
|
+
const kNode = NodeConstructor.fromIdentifiers(k);
|
|
71
|
+
const statement = isSquareInside
|
|
72
|
+
? multiply(a, sqrt(square(kNode)))
|
|
73
|
+
: square(multiply(a, sqrt(kNode)));
|
|
74
|
+
if (isSquareInside)
|
|
75
|
+
return `On a :
|
|
76
|
+
|
|
77
|
+
$$
|
|
78
|
+
${sqrt(square(kNode)).toTex()} = ${abs(kNode).toTex()} = ${abs(kNode)
|
|
79
|
+
.simplify()
|
|
80
|
+
.toTex()}
|
|
81
|
+
$$
|
|
82
|
+
|
|
83
|
+
donc
|
|
84
|
+
|
|
85
|
+
$$
|
|
86
|
+
${statement.toTex()} = ${multiply(a, abs(kNode).simplify()).toTex()} = ${getAnswer(identifiers)}
|
|
87
|
+
$$`;
|
|
88
|
+
return `
|
|
89
|
+
|
|
90
|
+
${alignTex([
|
|
91
|
+
[statement.toTex(), "=", multiply(square(a), square(sqrt(kNode))).toTex()],
|
|
92
|
+
[
|
|
93
|
+
"",
|
|
94
|
+
"=",
|
|
95
|
+
multiply(square(a).simplify(), square(sqrt(kNode)).simplify()).toTex(),
|
|
96
|
+
],
|
|
97
|
+
["", "=", getAnswer(identifiers)],
|
|
98
|
+
])}`;
|
|
99
|
+
};
|
|
59
100
|
const getKeys = (identifiers) => {
|
|
60
101
|
return [];
|
|
61
102
|
};
|
|
@@ -93,8 +134,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
|
|
|
93
134
|
keys: getKeys(identifiers),
|
|
94
135
|
answerFormat: "tex",
|
|
95
136
|
identifiers,
|
|
96
|
-
|
|
97
|
-
|
|
137
|
+
hint: getHint(identifiers),
|
|
138
|
+
correction: getCorrection(identifiers),
|
|
98
139
|
};
|
|
99
140
|
return question;
|
|
100
141
|
};
|
|
@@ -112,4 +153,5 @@ export const squareRootsToSquare = {
|
|
|
112
153
|
// getHint,
|
|
113
154
|
// getCorrection,
|
|
114
155
|
getQuestionFromIdentifiers,
|
|
156
|
+
hasHintAndCorrection: true,
|
|
115
157
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -67,6 +67,13 @@ declare const mathExercises: (Exercise<{
|
|
|
67
67
|
}, {}> | Exercise<{
|
|
68
68
|
point: import("./math/geometry/point.js").PointIdentifiers;
|
|
69
69
|
func: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
70
|
+
}, {}> | Exercise<{
|
|
71
|
+
n: number;
|
|
72
|
+
threshold: number;
|
|
73
|
+
mode: "sup\u00E9rieur" | "inf\u00E9rieur";
|
|
74
|
+
}, {}> | Exercise<{
|
|
75
|
+
a: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
76
|
+
b: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
70
77
|
}, {}> | Exercise<{
|
|
71
78
|
integerFirst: boolean;
|
|
72
79
|
integer: number;
|
|
@@ -845,8 +852,6 @@ declare const mathExercises: (Exercise<{
|
|
|
845
852
|
inegalitySymbol: import("./math/inequations/inequation.js").InegalitySymbols;
|
|
846
853
|
a: number;
|
|
847
854
|
b: number;
|
|
848
|
-
}, {}> | Exercise<{
|
|
849
|
-
test: number;
|
|
850
855
|
}, {}> | Exercise<{
|
|
851
856
|
k: number;
|
|
852
857
|
}, {}> | Exercise<{
|
|
@@ -1796,7 +1801,9 @@ declare const mathExercises: (Exercise<{
|
|
|
1796
1801
|
event: string;
|
|
1797
1802
|
type: string;
|
|
1798
1803
|
probaFrac: number[];
|
|
1799
|
-
}, {
|
|
1804
|
+
}, {
|
|
1805
|
+
forbidConditionnal?: boolean;
|
|
1806
|
+
}> | Exercise<{
|
|
1800
1807
|
aCapB: number;
|
|
1801
1808
|
aCapBBarre: number;
|
|
1802
1809
|
aBarreCapB: number;
|
|
@@ -2148,6 +2155,9 @@ declare const mathExercises: (Exercise<{
|
|
|
2148
2155
|
}, {}> | Exercise<{
|
|
2149
2156
|
v: string | number;
|
|
2150
2157
|
vType: string;
|
|
2158
|
+
}, {}> | Exercise<{
|
|
2159
|
+
inputValue: number;
|
|
2160
|
+
threshold: number;
|
|
2151
2161
|
}, {}> | Exercise<{
|
|
2152
2162
|
p: number;
|
|
2153
2163
|
n: number;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @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;;;;;;;;;;;;;;SAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
|
package/lib/playground.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAmCA,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAmCA,eAAO,MAAM,UAAU,YAUtB,CAAC"}
|
package/lib/playground.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { frac } from "./tree/nodes/operators/fractionNode.js";
|
|
2
|
+
import { multiply } from "./tree/nodes/operators/multiplyNode.js";
|
|
1
3
|
export const playground = () => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
console.log(multiply(frac(1, 3), frac(-1, 3))
|
|
5
|
+
.simplify({
|
|
6
|
+
towardsDistribute: true,
|
|
7
|
+
forbidFactorize: true,
|
|
8
|
+
forceDistributeFractions: true,
|
|
9
|
+
})
|
|
10
|
+
.toTex());
|
|
7
11
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Node, NodeIds, NodeType } from "../node.js";
|
|
2
2
|
import { FunctionNode, FunctionsIds } from "./functionNode.js";
|
|
3
|
-
import { AlgebraicNode } from "../algebraicNode.js";
|
|
3
|
+
import { AlgebraicNode, SimplifyOptions } from "../algebraicNode.js";
|
|
4
4
|
export declare function isAbsNode(a: Node): a is AbsNode;
|
|
5
5
|
export declare const abs: (a: AlgebraicNode | number | string) => AbsNode;
|
|
6
6
|
export declare class AbsNode implements FunctionNode {
|
|
@@ -19,7 +19,7 @@ export declare class AbsNode implements FunctionNode {
|
|
|
19
19
|
toTex(): string;
|
|
20
20
|
toEquivalentNodes(): AlgebraicNode[];
|
|
21
21
|
toAllValidTexs(): string[];
|
|
22
|
-
simplify(): AlgebraicNode | import("../numbers/constantNode.js").ConstantNode | import("../numbers/numberNode.js").NumberNode | AbsNode;
|
|
22
|
+
simplify(opts?: SimplifyOptions): AlgebraicNode | import("../numbers/constantNode.js").ConstantNode | import("../numbers/numberNode.js").NumberNode | AbsNode;
|
|
23
23
|
evaluate(vars?: Record<string, number>): number;
|
|
24
24
|
equals(node: AlgebraicNode): boolean;
|
|
25
25
|
toDetailedEvaluation(vars: Record<string, AlgebraicNode>): AbsNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"absNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/absNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"absNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/absNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAKrE,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,OAAO,CAE/C;AACD,eAAO,MAAM,GAAG,MAAO,aAAa,GAAG,MAAM,GAAG,MAAM,YAIrD,CAAC;AACF,qBAAa,OAAQ,YAAW,YAAY;IAC1C,EAAE,EAAE,YAAY,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBACP,KAAK,EAAE,aAAa;IAMhC,aAAa;;;;;;IAMb,YAAY,IAAI,MAAM;IAItB,KAAK,IAAI,MAAM;IAOf,iBAAiB,IAAI,aAAa,EAAE;IASpC,cAAc,IAAI,MAAM,EAAE;IAG1B,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe;IAgB/B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAGtC,MAAM,CAAC,IAAI,EAAE,aAAa;IAI1B,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAKxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS;CAIxC"}
|
|
@@ -3,7 +3,7 @@ import { NodeIds, NodeType } from "../node.js";
|
|
|
3
3
|
import { FunctionsIds, isFunctionNode } from "./functionNode.js";
|
|
4
4
|
import { isNumberNode } from "../numbers/numberNode.js";
|
|
5
5
|
import { isOppositeNode } from "./oppositeNode.js";
|
|
6
|
-
import { frac } from "../operators/fractionNode.js";
|
|
6
|
+
import { frac, isFractionNode } from "../operators/fractionNode.js";
|
|
7
7
|
import { multiply } from "../operators/multiplyNode.js";
|
|
8
8
|
export function isAbsNode(a) {
|
|
9
9
|
return isFunctionNode(a) && a.id === FunctionsIds.abs;
|
|
@@ -49,13 +49,16 @@ export class AbsNode {
|
|
|
49
49
|
toAllValidTexs() {
|
|
50
50
|
return this.toEquivalentNodes().map((node) => node.toTex());
|
|
51
51
|
}
|
|
52
|
-
simplify() {
|
|
52
|
+
simplify(opts) {
|
|
53
53
|
const childSimplified = this.child.simplify();
|
|
54
54
|
if (isNumberNode(childSimplified))
|
|
55
55
|
return Math.abs(childSimplified.value).toTree();
|
|
56
56
|
if (isOppositeNode(childSimplified)) {
|
|
57
57
|
return childSimplified.child;
|
|
58
58
|
}
|
|
59
|
+
if (isFractionNode(childSimplified)) {
|
|
60
|
+
return frac(abs(childSimplified.leftChild), abs(childSimplified.rightChild)).simplify(opts);
|
|
61
|
+
}
|
|
59
62
|
return new AbsNode(childSimplified);
|
|
60
63
|
}
|
|
61
64
|
evaluate(vars) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiplyNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/multiplyNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,WAAW,EAGZ,MAAM,mBAAmB,CAAC;AAY3B,OAAO,EACL,aAAa,EACb,eAAe,EAEhB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"multiplyNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/multiplyNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,WAAW,EAGZ,MAAM,mBAAmB,CAAC;AAY3B,OAAO,EACL,aAAa,EACb,eAAe,EAEhB,MAAM,qBAAqB,CAAC;AAe7B,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AAED,eAAO,MAAM,QAAQ,MAChB,aAAa,GAAG,MAAM,GAAG,MAAM,KAC/B,aAAa,GAAG,MAAM,GAAG,MAAM,SAC3B,WAAW,iBAOnB,CAAC;AACF,eAAO,MAAM,iBAAiB,QAAS,aAAa,EAAE,SAYrD,CAAC;AACF,qBAAa,YAAa,YAAW,uBAAuB;IAC1D,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IAUpB,OAAO,qBAGL;IAEF,WAAW,UAAW,eAAe,kBAUnC;IAEF,UAAU,qBAER;IACF,YAAY,IAAI,MAAM;IAItB,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM;IAgFrC,SAAS;IAkDT,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,YAAY,EAAE;IAyFrD,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAG5C,aAAa;;;;;;;;;IAYb,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAItC,IAAI;IAGJ,cAAc;IACd,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IA2L/C,mBAAmB,CAAC,IAAI,CAAC,EAAE,eAAe;IAM1C,MAAM,CAAC,IAAI,EAAE,aAAa;IAU1B,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAQxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;CAMxD"}
|
|
@@ -10,7 +10,7 @@ import { NumberNode, isNumberNode } from "../numbers/numberNode.js";
|
|
|
10
10
|
import { isInt } from "../../../utils/isInt.js";
|
|
11
11
|
import { isVariableNode } from "../variables/variableNode.js";
|
|
12
12
|
import { SqrtNode, isSqrtNode } from "../functions/sqrtNode.js";
|
|
13
|
-
import { isOppositeNode } from "../functions/oppositeNode.js";
|
|
13
|
+
import { isOppositeNode, } from "../functions/oppositeNode.js";
|
|
14
14
|
import { FractionNode, isFractionNode } from "./fractionNode.js";
|
|
15
15
|
import { isFunctionNode } from "../functions/functionNode.js";
|
|
16
16
|
import { AddNode, add, isAddNode } from "./addNode.js";
|
|
@@ -358,11 +358,20 @@ export class MultiplyNode {
|
|
|
358
358
|
if (isNumberNode(b) && isFractionNode(a) && a.isNumeric) {
|
|
359
359
|
return new FractionNode(multiply(a.leftChild, b), a.rightChild).simplify(opts);
|
|
360
360
|
}
|
|
361
|
-
|
|
362
|
-
a
|
|
363
|
-
isFractionNode(
|
|
364
|
-
|
|
365
|
-
|
|
361
|
+
const aFractionNode = isFractionNode(a) && a.isNumeric
|
|
362
|
+
? a
|
|
363
|
+
: isOppositeNode(a) && isFractionNode(a.child) && a.child.isNumeric
|
|
364
|
+
? a.child
|
|
365
|
+
: null;
|
|
366
|
+
const bFractionNode = isFractionNode(b) && b.isNumeric
|
|
367
|
+
? b
|
|
368
|
+
: isOppositeNode(b) && isFractionNode(b.child) && b.child.isNumeric
|
|
369
|
+
? b.child
|
|
370
|
+
: null;
|
|
371
|
+
if (aFractionNode && bFractionNode) {
|
|
372
|
+
if (isFractionNode(b) && b.isNumeric) {
|
|
373
|
+
return new FractionNode(multiply(aFractionNode.leftChild, bFractionNode.leftChild), multiply(aFractionNode.rightChild, bFractionNode.rightChild)).simplify(opts);
|
|
374
|
+
}
|
|
366
375
|
}
|
|
367
376
|
let powerSimplified = powerSimplify(a, b, opts);
|
|
368
377
|
if (powerSimplified)
|