math-exercises 3.0.37 → 3.0.39
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/fractions/fractionsSumsMultiplesDenominators.d.ts +4 -1
- package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.js +71 -16
- package/lib/exercises/math/calcul/fractions/simplifyFraction.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/simplifyFraction.js +37 -0
- package/lib/exercises/math/calcul/rounding/rounding.d.ts +8 -5
- package/lib/exercises/math/calcul/rounding/rounding.d.ts.map +1 -1
- package/lib/exercises/math/calcul/rounding/rounding.js +63 -31
- package/lib/exercises/math/calculLitteral/simplifying/reduceExpression.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/simplifying/reduceExpression.js +64 -57
- package/lib/exercises/math/functions/affines/algebricExpressionOfAffine.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/algebricExpressionOfAffine.js +48 -5
- package/lib/exercises/math/functions/affines/leadingCoefficient.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/leadingCoefficient.js +42 -4
- package/lib/exercises/math/functions/integral/integralAffines.d.ts.map +1 -1
- package/lib/exercises/math/functions/integral/integralAffines.js +31 -15
- package/lib/exercises/math/functions/integral/integralTrinomials.d.ts.map +1 -1
- package/lib/exercises/math/functions/integral/integralTrinomials.js +31 -16
- package/lib/exercises/math/functions/trinoms/factoForm/factorizedFormFromRoots.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/factoForm/factorizedFormFromRoots.js +49 -0
- package/lib/exercises/math/functions/trinoms/parabole/trinomSymetryAxisFromFacto.js +1 -1
- package/lib/exercises/math/functions/trinoms/roots/findSecondRoot.js +1 -1
- package/lib/exercises/math/functions/trinoms/roots/rootsProduct.js +1 -1
- package/lib/exercises/math/functions/trinoms/roots/rootsSum.js +1 -1
- package/lib/exercises/math/geometry/cartesian/distanceBetweenTwoPoints.d.ts.map +1 -1
- package/lib/exercises/math/geometry/cartesian/distanceBetweenTwoPoints.js +66 -18
- package/lib/exercises/math/geometry/cartesian/midpoint.d.ts.map +1 -1
- package/lib/exercises/math/geometry/cartesian/midpoint.js +45 -3
- package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLine.d.ts.map +1 -1
- package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLine.js +1 -2
- package/lib/exercises/math/geometry/perimeters/rectanglePerimeter.d.ts.map +1 -1
- package/lib/exercises/math/geometry/perimeters/rectanglePerimeter.js +0 -2
- package/lib/exercises/math/geometry/pythagore/pythagoreCalcul.js +1 -1
- package/lib/exercises/math/geometry/thales/thalesCalcul.js +1 -1
- package/lib/exercises/math/geometry/vectors/chasles.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/chasles.js +0 -2
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductViaCoords.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductViaCoords.js +68 -15
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductViaCos.d.ts +1 -0
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductViaCos.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductViaCos.js +32 -14
- package/lib/exercises/math/probaStat/diceBasicProbas.js +1 -1
- package/lib/exercises/math/sequences/arithmetic/arithmeticFindReason.d.ts.map +1 -1
- package/lib/exercises/math/sequences/arithmetic/arithmeticFindReason.js +43 -8
- package/lib/exercises/math/sequences/arithmetic/arithmeticFindReasonRandomRange.d.ts.map +1 -1
- package/lib/exercises/math/sequences/arithmetic/arithmeticFindReasonRandomRange.js +0 -2
- package/lib/exercises/math/sequences/arithmetic/arithmeticReasonUsage.d.ts.map +1 -1
- package/lib/exercises/math/sequences/arithmetic/arithmeticReasonUsage.js +51 -8
- package/lib/exercises/math/sequences/arithmetic/recognizeReasonFromFirstTerms.d.ts.map +1 -1
- package/lib/exercises/math/sequences/arithmetic/recognizeReasonFromFirstTerms.js +36 -5
- package/lib/exercises/math/sequences/geometric/geometricRecognizeReasonFromFirstTerms.d.ts.map +1 -1
- package/lib/exercises/math/sequences/geometric/geometricRecognizeReasonFromFirstTerms.js +36 -5
- package/lib/exercises/math/trigonometry/associatePoint.d.ts.map +1 -1
- package/lib/exercises/math/trigonometry/associatePoint.js +5 -2
- package/lib/exercises/math/trigonometry/mainRemarkableValues.js +1 -1
- package/lib/exercises/math/trigonometry/remarkableValues.js +2 -2
- package/lib/geogebra/geogebraConstructor.d.ts +3 -1
- package/lib/geogebra/geogebraConstructor.d.ts.map +1 -1
- package/lib/geogebra/geogebraConstructor.js +5 -2
- package/lib/index.d.ts +8 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/latexTester.js +1 -0
- package/lib/math/geometry/point.d.ts +2 -0
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/point.js +10 -0
- package/lib/math/numbers/integer/integer.d.ts +1 -1
- package/lib/math/numbers/rationals/rational.d.ts +1 -0
- package/lib/math/numbers/rationals/rational.d.ts.map +1 -1
- package/lib/math/numbers/rationals/rational.js +3 -0
- package/lib/math/trigonometry/remarkableValue.d.ts +1 -4
- package/lib/math/trigonometry/remarkableValue.d.ts.map +1 -1
- package/lib/math/trigonometry/remarkableValue.js +5 -6
- package/lib/math/utils/stats/generateAffineCloud.js +1 -1
- package/lib/playground.d.ts.map +1 -1
- package/lib/playground.js +5 -0
- package/lib/tests/pdfExo.test.d.ts.map +1 -1
- package/lib/tests/pdfExo.test.js +2 -2
- package/lib/tree/nodes/functions/oppositeNode.d.ts +1 -2
- package/lib/tree/nodes/functions/oppositeNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/sqrtNode.d.ts +2 -1
- package/lib/tree/nodes/functions/sqrtNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/sqrtNode.js +47 -2
- package/lib/tree/nodes/node.d.ts +1 -0
- package/lib/tree/nodes/node.d.ts.map +1 -1
- package/lib/tree/nodes/numbers/numberNode.d.ts +1 -1
- package/lib/tree/nodes/numbers/numberNode.d.ts.map +1 -1
- package/lib/tree/nodes/numbers/numberNode.js +1 -1
- package/lib/tree/nodes/operators/addNode.d.ts +1 -0
- package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.js +6 -0
- package/lib/tree/nodes/operators/fractionNode.d.ts +1 -1
- package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/fractionNode.js +1 -1
- package/lib/tree/nodes/operators/multiplyNode.d.ts +1 -0
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +7 -0
- package/lib/utils/iterators/dualReturn.d.ts +2 -0
- package/lib/utils/iterators/dualReturn.d.ts.map +1 -0
- package/lib/utils/iterators/dualReturn.js +19 -0
- package/package.json +1 -1
|
@@ -2,18 +2,46 @@ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exer
|
|
|
2
2
|
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
3
|
import { randint } from "../../../../math/utils/random/randint.js";
|
|
4
4
|
import { numberParser } from "../../../../tree/parsers/numberParser.js";
|
|
5
|
+
const getInstruction = (identifiers) => {
|
|
6
|
+
const { sequence, reason } = identifiers;
|
|
7
|
+
return `Voici les premiers termes d'une suite arithmétique $u$ :
|
|
8
|
+
|
|
9
|
+
$$
|
|
10
|
+
${sequence.join("\\ ; \\ ")}
|
|
11
|
+
$$
|
|
12
|
+
|
|
13
|
+
Quelle est la raison de $u$ ?`;
|
|
14
|
+
};
|
|
15
|
+
const getAnswer = (identifiers) => {
|
|
16
|
+
const { sequence, reason } = identifiers;
|
|
17
|
+
return reason + "";
|
|
18
|
+
};
|
|
19
|
+
const getHint = (identifiers) => {
|
|
20
|
+
return `La raison d'une suite arithmétique est le nombre par lequel on additionne un terme pour obtenir le suivant.`;
|
|
21
|
+
};
|
|
22
|
+
const getCorrection = (identifiers) => {
|
|
23
|
+
return `La raison d'une suite arithmétique est le nombre par lequel on additionne un terme pour obtenir le suivant.
|
|
24
|
+
|
|
25
|
+
Ici, on remarque que pour passer d'un terme au suivant, on additionne toujours par $${identifiers.reason}$.
|
|
26
|
+
|
|
27
|
+
La raison de $u$ est donc $${identifiers.reason}$.
|
|
28
|
+
`;
|
|
29
|
+
};
|
|
5
30
|
const getRecognizeReasonFromFirstTermsQuestion = () => {
|
|
6
31
|
const firstTerm = randint(1, 20);
|
|
7
32
|
const reason = randint(-5, 6, [0]);
|
|
8
33
|
const sequence = new Array(5)
|
|
9
34
|
.fill(0)
|
|
10
35
|
.map((el, index) => firstTerm + index * reason);
|
|
36
|
+
const identifiers = { sequence, reason };
|
|
11
37
|
const question = {
|
|
12
|
-
answer:
|
|
13
|
-
instruction:
|
|
38
|
+
answer: getAnswer(identifiers),
|
|
39
|
+
instruction: getInstruction(identifiers),
|
|
14
40
|
keys: [],
|
|
15
41
|
answerFormat: "tex",
|
|
16
|
-
identifiers
|
|
42
|
+
identifiers,
|
|
43
|
+
hint: getHint(identifiers),
|
|
44
|
+
correction: getCorrection(identifiers),
|
|
17
45
|
};
|
|
18
46
|
return question;
|
|
19
47
|
};
|
|
@@ -32,13 +60,16 @@ const isAnswerValid = (ans, { answer }) => {
|
|
|
32
60
|
export const recognizeReasonFromFirstTerms = {
|
|
33
61
|
id: "recognizeReasonFromFirstTerms",
|
|
34
62
|
label: "Reconnaître la raison d'une suite arithmétique via ses premiers termes",
|
|
35
|
-
levels: ["1reESM", "1rePro", "1reSpé", "1reTech"],
|
|
36
63
|
isSingleStep: true,
|
|
37
|
-
sections: ["Suites"],
|
|
38
64
|
generator: (nb) => getDistinctQuestions(getRecognizeReasonFromFirstTermsQuestion, nb),
|
|
39
65
|
qcmTimer: 60,
|
|
40
66
|
freeTimer: 60,
|
|
41
67
|
getPropositions,
|
|
42
68
|
isAnswerValid,
|
|
43
69
|
subject: "Mathématiques",
|
|
70
|
+
getAnswer,
|
|
71
|
+
getInstruction,
|
|
72
|
+
getHint,
|
|
73
|
+
getCorrection,
|
|
74
|
+
hasHintAndCorrection: true,
|
|
44
75
|
};
|
package/lib/exercises/math/sequences/geometric/geometricRecognizeReasonFromFirstTerms.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometricRecognizeReasonFromFirstTerms.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricRecognizeReasonFromFirstTerms.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"geometricRecognizeReasonFromFirstTerms.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricRecognizeReasonFromFirstTerms.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAIrC,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAiEF,eAAO,MAAM,sCAAsC,EAAE,QAAQ,CAAC,WAAW,CAkBxE,CAAC"}
|
|
@@ -1,18 +1,46 @@
|
|
|
1
1
|
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
2
|
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
3
|
import { randint } from "../../../../math/utils/random/randint.js";
|
|
4
|
+
const getInstruction = (identifiers) => {
|
|
5
|
+
const { sequence, reason } = identifiers;
|
|
6
|
+
return `Voici les premiers termes d'une suite géométrique $u$ :
|
|
7
|
+
|
|
8
|
+
$$
|
|
9
|
+
${sequence.join("\\ ; \\ ")}
|
|
10
|
+
$$
|
|
11
|
+
|
|
12
|
+
Quelle est la raison de $u$ ?`;
|
|
13
|
+
};
|
|
14
|
+
const getAnswer = (identifiers) => {
|
|
15
|
+
const { sequence, reason } = identifiers;
|
|
16
|
+
return reason + "";
|
|
17
|
+
};
|
|
18
|
+
const getHint = (identifiers) => {
|
|
19
|
+
return `La raison d'une suite géométrique est le nombre par lequel on multiplie un terme pour obtenir le suivant.`;
|
|
20
|
+
};
|
|
21
|
+
const getCorrection = (identifiers) => {
|
|
22
|
+
return `La raison d'une suite géométrique est le nombre par lequel on multiplie un terme pour obtenir le suivant.
|
|
23
|
+
|
|
24
|
+
Ici, on remarque que pour passer d'un terme au suivant, on multiplie toujours par $${identifiers.reason}$.
|
|
25
|
+
|
|
26
|
+
La raison de $u$ est donc $${identifiers.reason}$.
|
|
27
|
+
`;
|
|
28
|
+
};
|
|
4
29
|
const getGeometricRecognizeReasonFromFirstTermsQuestion = () => {
|
|
5
30
|
const firstTerm = randint(1, 20);
|
|
6
31
|
const reason = randint(-5, 6, [0, 1]);
|
|
7
32
|
const sequence = new Array(5)
|
|
8
33
|
.fill(0)
|
|
9
34
|
.map((el, index) => firstTerm * Math.pow(reason, index));
|
|
35
|
+
const identifiers = { sequence, reason };
|
|
10
36
|
const question = {
|
|
11
|
-
answer:
|
|
12
|
-
instruction:
|
|
37
|
+
answer: getAnswer(identifiers),
|
|
38
|
+
instruction: getInstruction(identifiers),
|
|
13
39
|
keys: [],
|
|
14
40
|
answerFormat: "tex",
|
|
15
|
-
identifiers
|
|
41
|
+
identifiers,
|
|
42
|
+
hint: getHint(identifiers),
|
|
43
|
+
correction: getCorrection(identifiers),
|
|
16
44
|
};
|
|
17
45
|
return question;
|
|
18
46
|
};
|
|
@@ -31,13 +59,16 @@ export const geometricRecognizeReasonFromFirstTerms = {
|
|
|
31
59
|
id: "geometricRecognizeReasonFromFirstTerms",
|
|
32
60
|
connector: "=",
|
|
33
61
|
label: "Reconnaître la raison d'une suite géométrique via ses premiers termes",
|
|
34
|
-
levels: [],
|
|
35
62
|
isSingleStep: true,
|
|
36
|
-
sections: [],
|
|
37
63
|
generator: (nb) => getDistinctQuestions(getGeometricRecognizeReasonFromFirstTermsQuestion, nb),
|
|
38
64
|
qcmTimer: 60,
|
|
39
65
|
freeTimer: 60,
|
|
40
66
|
getPropositions,
|
|
41
67
|
isAnswerValid,
|
|
42
68
|
subject: "Mathématiques",
|
|
69
|
+
getAnswer,
|
|
70
|
+
getInstruction,
|
|
71
|
+
getHint,
|
|
72
|
+
getCorrection,
|
|
73
|
+
hasHintAndCorrection: true,
|
|
43
74
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"associatePoint.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/trigonometry/associatePoint.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"associatePoint.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/trigonometry/associatePoint.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAKtE,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,eAAe,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AA4DF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAchD,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
|
|
2
2
|
import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
|
|
3
3
|
import { RemarkableValueConstructor } from "../../../math/trigonometry/remarkableValue.js";
|
|
4
|
+
import { coinFlip } from "../../../utils/alea/coinFlip.js";
|
|
4
5
|
import { random } from "../../../utils/alea/random.js";
|
|
5
6
|
const points = [
|
|
6
7
|
"I",
|
|
@@ -21,7 +22,9 @@ const points = [
|
|
|
21
22
|
"Q",
|
|
22
23
|
];
|
|
23
24
|
const getAssociatePointQuestion = () => {
|
|
24
|
-
const remarkableValue =
|
|
25
|
+
const remarkableValue = coinFlip()
|
|
26
|
+
? RemarkableValueConstructor.simplifiable()
|
|
27
|
+
: RemarkableValueConstructor.mainInterval();
|
|
25
28
|
const answer = remarkableValue.point;
|
|
26
29
|
const question = {
|
|
27
30
|
answer,
|
|
@@ -31,7 +34,7 @@ const getAssociatePointQuestion = () => {
|
|
|
31
34
|
keys: points,
|
|
32
35
|
answerFormat: "tex",
|
|
33
36
|
identifiers: {
|
|
34
|
-
angleValue: remarkableValue.
|
|
37
|
+
angleValue: remarkableValue.angle.evaluate({}),
|
|
35
38
|
point: answer,
|
|
36
39
|
angleIdentifiers: remarkableValue.angle.toIdentifiers(),
|
|
37
40
|
},
|
|
@@ -88,7 +88,7 @@ const isAnswerValid = (ans, { answer, valueIndex, isCos }) => {
|
|
|
88
88
|
export const mainRemarkableValuesExercise = {
|
|
89
89
|
id: "mainRemarkableValues",
|
|
90
90
|
connector: "=",
|
|
91
|
-
label: "Valeurs remarquables de $\\cos$ et $\\sin$ sur $]-\\pi
|
|
91
|
+
label: "Valeurs remarquables de $\\cos$ et $\\sin$ sur $]-\\pi; \\pi]$",
|
|
92
92
|
isSingleStep: true,
|
|
93
93
|
generator: (nb) => getDistinctQuestions(getMainRemarkableValues, nb, 18),
|
|
94
94
|
qcmTimer: 60,
|
|
@@ -45,7 +45,7 @@ const getAnswer = (identifiers) => {
|
|
|
45
45
|
const getRemarkableValues = () => {
|
|
46
46
|
const isCos = coinFlip();
|
|
47
47
|
const remarkableValue = RemarkableValueConstructor.simplifiable();
|
|
48
|
-
const mainValue = remarkableValue.
|
|
48
|
+
const mainValue = remarkableValue.angle.evaluate({});
|
|
49
49
|
// const valueIndex = remarkableValue.index;
|
|
50
50
|
const identifiers = {
|
|
51
51
|
isCos,
|
|
@@ -87,7 +87,7 @@ const isAnswerValid = (ans, { answer, mainValue, isCos }) => {
|
|
|
87
87
|
export const remarkableValuesExercise = {
|
|
88
88
|
id: "remarkableValues",
|
|
89
89
|
connector: "=",
|
|
90
|
-
label: "Valeurs remarquables de $\\cos$ et $\\sin$",
|
|
90
|
+
label: "Valeurs remarquables de $\\cos$ et $\\sin$ (hors de $]-\\pi; \\pi]$)",
|
|
91
91
|
levels: ["1reSpé", "TermSpé", "MathComp"],
|
|
92
92
|
isSingleStep: true,
|
|
93
93
|
sections: ["Trigonométrie"],
|
|
@@ -8,6 +8,8 @@ type GetAdaptedCoords = {
|
|
|
8
8
|
zMin?: number;
|
|
9
9
|
zMax?: number;
|
|
10
10
|
forceShowAxes?: boolean;
|
|
11
|
+
minCoords?: number[];
|
|
12
|
+
ratio?: number;
|
|
11
13
|
};
|
|
12
14
|
type GetOptionsProps = {
|
|
13
15
|
coords: number[];
|
|
@@ -33,7 +35,7 @@ export declare class GeogebraConstructor {
|
|
|
33
35
|
hideFullScreenButton?: boolean;
|
|
34
36
|
constructor(options: Omit<GeogebraOptions, "coords">);
|
|
35
37
|
getCoordsForPoints(points: Point[]): number[];
|
|
36
|
-
getAdaptedCoords({ xMin, xMax, yMin, yMax, zMin, zMax, forceShowAxes, }: GetAdaptedCoords): number[];
|
|
38
|
+
getAdaptedCoords({ xMin, xMax, yMin, yMax, zMin, zMax, forceShowAxes, minCoords, ratio, }: GetAdaptedCoords): number[];
|
|
37
39
|
getOptions({ coords }: GetOptionsProps): GeogebraOptions;
|
|
38
40
|
}
|
|
39
41
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geogebraConstructor.d.ts","sourceRoot":"","sources":["../../src/geogebra/geogebraConstructor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,eAAe,EAChB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAErD,KAAK,gBAAgB,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AAO,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACjC,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;gBACnB,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC;IAoBpD,kBAAkB,CAAC,MAAM,EAAE,KAAK,EAAE;IAOlC,gBAAgB,CAAC,EACf,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,aAAa,EACb,SAAS,EACT,KAAK,GACN,EAAE,gBAAgB;IAsDnB,UAAU,CAAC,EAAE,MAAM,EAAE,EAAE,eAAe,GAAG,eAAe;CAuBzD"}
|
|
@@ -45,11 +45,11 @@ export class GeogebraConstructor {
|
|
|
45
45
|
const yMax = Math.max(...points.map((p) => p.y.evaluate()));
|
|
46
46
|
return this.getAdaptedCoords({ xMin, xMax, yMin, yMax });
|
|
47
47
|
}
|
|
48
|
-
getAdaptedCoords({ xMin, xMax, yMin, yMax, zMin, zMax, forceShowAxes, }) {
|
|
48
|
+
getAdaptedCoords({ xMin, xMax, yMin, yMax, zMin, zMax, forceShowAxes, minCoords, ratio, }) {
|
|
49
49
|
const showAxes = forceShowAxes ?? (this.hideAxes ? false : true);
|
|
50
50
|
const xDelta = xMax - xMin;
|
|
51
51
|
const yDelta = yMax - yMin;
|
|
52
|
-
const coeff = 0.1;
|
|
52
|
+
const coeff = ratio ?? 0.1;
|
|
53
53
|
if (this.is3D && zMin !== undefined && zMax !== undefined) {
|
|
54
54
|
const zDelta = zMax - zMin;
|
|
55
55
|
const coords = [
|
|
@@ -91,6 +91,9 @@ export class GeogebraConstructor {
|
|
|
91
91
|
coords[2] = Math.min(-1, coords[2]);
|
|
92
92
|
coords[3] = Math.max(1, coords[3]);
|
|
93
93
|
}
|
|
94
|
+
if (minCoords) {
|
|
95
|
+
return coords.map((coord, index) => (index % 2 === 0 ? Math.min : Math.max)(minCoords[index], coord));
|
|
96
|
+
}
|
|
94
97
|
return coords;
|
|
95
98
|
}
|
|
96
99
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -76,7 +76,9 @@ declare const mathExercises: (Exercise<{
|
|
|
76
76
|
num2: number;
|
|
77
77
|
denom1: number;
|
|
78
78
|
denom2: number;
|
|
79
|
-
}, {
|
|
79
|
+
}, {
|
|
80
|
+
allowNonIrreductible?: boolean;
|
|
81
|
+
}> | Exercise<{
|
|
80
82
|
num1: number;
|
|
81
83
|
num2: number;
|
|
82
84
|
denom1: number;
|
|
@@ -176,7 +178,9 @@ declare const mathExercises: (Exercise<{
|
|
|
176
178
|
precisionAsked: number;
|
|
177
179
|
decimal: number;
|
|
178
180
|
precision: number;
|
|
179
|
-
}, {
|
|
181
|
+
}, {
|
|
182
|
+
precisionAsked: number;
|
|
183
|
+
}> | Exercise<{
|
|
180
184
|
nb: number;
|
|
181
185
|
rankAsked: number;
|
|
182
186
|
}, {}> | Exercise<{
|
|
@@ -1190,6 +1194,7 @@ declare const mathExercises: (Exercise<{
|
|
|
1190
1194
|
AB: number;
|
|
1191
1195
|
AC: number;
|
|
1192
1196
|
trigoPoint: string;
|
|
1197
|
+
letters: string[];
|
|
1193
1198
|
}, {}> | Exercise<{
|
|
1194
1199
|
c: number;
|
|
1195
1200
|
vec1Name: string;
|
|
@@ -2021,6 +2026,7 @@ declare const pcExercises: (Exercise<{
|
|
|
2021
2026
|
AB: number;
|
|
2022
2027
|
AC: number;
|
|
2023
2028
|
trigoPoint: string;
|
|
2029
|
+
letters: string[];
|
|
2024
2030
|
}, {}> | Exercise<{
|
|
2025
2031
|
total: number;
|
|
2026
2032
|
lefties: number;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -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;AAG7D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,QAAA,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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
+
midpointNode(B: Point, name?: string): Point;
|
|
40
41
|
midpoint(B: Point, name?: string): Point;
|
|
41
42
|
distanceTo(B: Point): number;
|
|
43
|
+
distanceToNode(B: Point): AlgebraicNode;
|
|
42
44
|
equals(B: Point): boolean;
|
|
43
45
|
isAligned(B: Point, C: Point): boolean;
|
|
44
46
|
toMathString(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/point.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAGlE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sDAAsD,CAAC;AAC1F,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAM7C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/point.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAGlE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sDAAsD,CAAC;AAC1F,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAM7C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAIvC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;CACpB,CAAC;AACF,8BAAsB,gBAAgB;IACpC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE;IAGrC,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM;IAKhC,MAAM,CAAC,M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a;IAMvC,MAAM,CAAC,CAAC,EAAE,KAAK,GAAG,OAAO;IAGzB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK;IAK5B,YAAY;IAGZ,YAAY,CAAC,EACX,OAAc,EACd,SAAgB,EAChB,KAAK,EACL,IAAI,EACJ,KAAK,GACN,GAAE,kBAAuB;IAiB1B,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK;IAiBnC,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,SAAkB;IAIrD,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,SAAkB;IAI1C,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,SAAkB;CAIjD"}
|
|
@@ -8,6 +8,8 @@ import { multiply } from "../../tree/nodes/operators/multiplyNode.js";
|
|
|
8
8
|
import { add } from "../../tree/nodes/operators/addNode.js";
|
|
9
9
|
import { randomLetter } from "../../utils/strings/randomLetter.js";
|
|
10
10
|
import { frac } from "../../tree/nodes/operators/fractionNode.js";
|
|
11
|
+
import { sqrt } from "../../tree/nodes/functions/sqrtNode.js";
|
|
12
|
+
import { square } from "../../tree/nodes/operators/powerNode.js";
|
|
11
13
|
export class PointConstructor {
|
|
12
14
|
static randomName(excludes) {
|
|
13
15
|
return randomLetter(true, ["O", ...(excludes ?? [])]);
|
|
@@ -94,6 +96,9 @@ export class Point {
|
|
|
94
96
|
getYnumber() {
|
|
95
97
|
return this.y.evaluate();
|
|
96
98
|
}
|
|
99
|
+
midpointNode(B, name = "I") {
|
|
100
|
+
return new Point(name, frac(add(this.x, B.x), 2), frac(add(this.y, B.y), 2));
|
|
101
|
+
}
|
|
97
102
|
midpoint(B, name = "I") {
|
|
98
103
|
return new Point(name, frac(add(this.x, B.x), 2).simplify(), frac(add(this.y, B.y), 2).simplify());
|
|
99
104
|
}
|
|
@@ -102,6 +107,11 @@ export class Point {
|
|
|
102
107
|
const dy = this.getYnumber() - B.getYnumber();
|
|
103
108
|
return Math.sqrt(dx ** 2 + dy ** 2);
|
|
104
109
|
}
|
|
110
|
+
distanceToNode(B) {
|
|
111
|
+
const dx = substract(this.x, B.x);
|
|
112
|
+
const dy = substract(this.y, B.y);
|
|
113
|
+
return sqrt(add(square(dx), square(dy)));
|
|
114
|
+
}
|
|
105
115
|
equals(B) {
|
|
106
116
|
return this.x.equals(B.x) && this.y.equals(B.y);
|
|
107
117
|
}
|
|
@@ -15,7 +15,7 @@ export declare class Integer implements Nombre {
|
|
|
15
15
|
constructor(value: number, tex?: string);
|
|
16
16
|
equals(n: Nombre): boolean;
|
|
17
17
|
toTree(): NumberNode;
|
|
18
|
-
times(n: number | Nombre):
|
|
18
|
+
times(n: number | Nombre): Integer | Decimal;
|
|
19
19
|
round(precision: number): Integer;
|
|
20
20
|
divide(nb: Nombre): Nombre;
|
|
21
21
|
multiply(nb: Nombre): Rational | Integer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rational.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/rationals/rational.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE,OAAO,EAAQ,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAQ7D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAElD,8BAAsB,mBAAmB;IACvC;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,MAAM,GAAE,MAAW;IAW7C,MAAM,CAAC,kBAAkB,CACvB,GAAG,GAAE,MAAW,EAChB,EAAE,UAAkB,EAAE,GAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAO;IASvD,MAAM,CAAC,uBAAuB,CAAC,QAAQ,GAAE,MAAW;IAKpD,MAAM,CAAC,0BAA0B,CAAC,GAAG,GAAE,MAAW;IAQlD,MAAM,CAAC,kBAAk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AC,uBAAuB,CAAC,QAAQ,GAAE,MAAW;IAKpD,MAAM,CAAC,0BAA0B,CAAC,GAAG,GAAE,MAAW;IAQlD,MAAM,CAAC,kBAAkB,CAAC,GAAG,GAAE,MAAW;CAO3C;AAED,qBAAa,QAAS,YAAW,MAAM;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,OAAO,CAAC;IACtB,IAAI,EAAE,UAAU,CAAC;gBAEL,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IAYlD,OAAO;IAGP,MAAM,CAAC,CAAC,EAAE,MAAM;IAGhB,KAAK;IAML,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAkBvB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO;IAgBxC,OAAO,CAAC,cAAc,EAAE,OAAO,GAAG,MAAM;IAIxC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAgB1B,QAAQ,IAAI,QAAQ;IAIpB,MAAM,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,aAAa;IAgBzC,cAAc;IAId,QAAQ,IAAI,OAAO,GAAG,QAAQ;CAqB/B"}
|
|
@@ -74,6 +74,9 @@ export class Rational {
|
|
|
74
74
|
this.tex = `${this.num < 0 ? "-" : ""}\\frac{${this.num < 0 ? -this.num : this.num}}{${this.denum}}`;
|
|
75
75
|
this.type = NumberType.Rational;
|
|
76
76
|
}
|
|
77
|
+
toArray() {
|
|
78
|
+
return [this.num, this.denum];
|
|
79
|
+
}
|
|
77
80
|
equals(n) {
|
|
78
81
|
return this.value === n.value;
|
|
79
82
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { AlgebraicNode } from "../../tree/nodes/algebraicNode.js";
|
|
2
1
|
import { RemarkableValue } from "./remarkableValues.js";
|
|
3
2
|
export declare abstract class RemarkableValueConstructor {
|
|
4
3
|
static mainInterval: () => RemarkableValue;
|
|
5
|
-
static simplifiable: () => RemarkableValue
|
|
6
|
-
mainAngle: AlgebraicNode;
|
|
7
|
-
};
|
|
4
|
+
static simplifiable: () => RemarkableValue;
|
|
8
5
|
}
|
|
9
6
|
//# sourceMappingURL=remarkableValue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remarkableValue.d.ts","sourceRoot":"","sources":["../../../src/math/trigonometry/remarkableValue.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"remarkableValue.d.ts","sourceRoot":"","sources":["../../../src/math/trigonometry/remarkableValue.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,eAAe,EAGhB,MAAM,uBAAuB,CAAC;AAE/B,8BAAsB,0BAA0B;IAC9C,MAAM,CAAC,YAAY,QAAO,eAAe,CAGvC;IACF,MAAM,CAAC,YAAY,QAAO,eAAe,CAgBvC;CACH"}
|
|
@@ -4,19 +4,18 @@ import { AddNode } from "../../tree/nodes/operators/addNode.js";
|
|
|
4
4
|
import { MultiplyNode } from "../../tree/nodes/operators/multiplyNode.js";
|
|
5
5
|
import { random } from "../../utils/alea/random.js";
|
|
6
6
|
import { randint } from "../utils/random/randint.js";
|
|
7
|
-
import {
|
|
7
|
+
import { mainTrigoValues, } from "./remarkableValues.js";
|
|
8
8
|
export class RemarkableValueConstructor {
|
|
9
9
|
static mainInterval = () => {
|
|
10
|
-
const randValue = random(
|
|
10
|
+
const randValue = random(mainTrigoValues);
|
|
11
11
|
return randValue;
|
|
12
12
|
};
|
|
13
13
|
static simplifiable = () => {
|
|
14
|
-
const index = randint(0,
|
|
15
|
-
const randValue =
|
|
16
|
-
const toAdd = randint(-3, 4) * 2;
|
|
14
|
+
const index = randint(0, mainTrigoValues.length);
|
|
15
|
+
const randValue = mainTrigoValues[index];
|
|
16
|
+
const toAdd = randint(-3, 4, [0]) * 2;
|
|
17
17
|
const newRadian = new AddNode(randValue.angle, new MultiplyNode(new NumberNode(toAdd), PiNode)).simplify();
|
|
18
18
|
return {
|
|
19
|
-
mainAngle: randValue.angle,
|
|
20
19
|
angle: newRadian,
|
|
21
20
|
cos: randValue.cos,
|
|
22
21
|
sin: randValue.sin,
|
package/lib/playground.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAuBA,eAAO,MAAM,UAAU,YAMtB,CAAC"}
|
package/lib/playground.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
import { multiply } from "./tree/nodes/operators/multiplyNode.js";
|
|
2
|
+
import { substract } from "./tree/nodes/operators/substractNode.js";
|
|
1
3
|
export const playground = () => {
|
|
2
4
|
// const tex = "3\\%";
|
|
3
5
|
// console.log(parseAlgebraic(tex).simplify({}).toTex());
|
|
6
|
+
const x = multiply(3, substract("x", 9));
|
|
7
|
+
console.log(x.simplify().toTex());
|
|
8
|
+
console.log(x.equals(x.simplify()));
|
|
4
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdfExo.test.d.ts","sourceRoot":"","sources":["../../src/tests/pdfExo.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pdfExo.test.d.ts","sourceRoot":"","sources":["../../src/tests/pdfExo.test.ts"],"names":[],"mappings":"AAgBA,OAAO,6BAA6B,CAAC"}
|
package/lib/tests/pdfExo.test.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { factorizedFormFromRoots, } from "../exercises/math/index.js";
|
|
2
2
|
import { buildPdfForExercise } from "./pdfs/buildPDFForExercise.js";
|
|
3
3
|
import "../prototypesEnhancement.js";
|
|
4
4
|
try {
|
|
5
|
-
buildPdfForExercise(
|
|
5
|
+
buildPdfForExercise(factorizedFormFromRoots);
|
|
6
6
|
}
|
|
7
7
|
catch (err) {
|
|
8
8
|
console.log(err);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Node, NodeIds, NodeOptions, NodeType } from "../node.js";
|
|
2
2
|
import { FunctionNode, FunctionsIds } from "./functionNode.js";
|
|
3
|
-
import { NumberNode } from "../numbers/numberNode.js";
|
|
4
3
|
import { AlgebraicNode, SimplifyOptions } from "../algebraicNode.js";
|
|
5
4
|
export declare function isOppositeNode(a: Node): a is OppositeNode;
|
|
6
5
|
export declare const opposite: <T extends AlgebraicNode = AlgebraicNode>(a: T | number | string) => OppositeNode<T>;
|
|
@@ -27,7 +26,7 @@ export declare class OppositeNode<T extends AlgebraicNode = AlgebraicNode> imple
|
|
|
27
26
|
*/
|
|
28
27
|
toAllValidTexs(opts?: NodeOptions): string[];
|
|
29
28
|
evaluate(vars?: Record<string, number>): number;
|
|
30
|
-
simplify(opts?: SimplifyOptions): AlgebraicNode
|
|
29
|
+
simplify(opts?: SimplifyOptions): AlgebraicNode;
|
|
31
30
|
equals(node: AlgebraicNode): boolean;
|
|
32
31
|
toDetailedEvaluation(vars: Record<string, AlgebraicNode>): OppositeNode<AlgebraicNode>;
|
|
33
32
|
derivative(varName?: string | undefined): AlgebraicNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oppositeNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/oppositeNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAMlE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"oppositeNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/oppositeNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAA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
|
toEquivalentNodes(opts?: NodeOptions): AlgebraicNode[];
|
|
22
22
|
toAllValidTexs(opts?: NodeOptions): string[];
|
|
23
23
|
evaluate(vars?: Record<string, number>): number;
|
|
24
|
-
simplify(opts?: SimplifyOptions): AlgebraicNode;
|
|
24
|
+
simplify(opts?: SimplifyOptions, steps?: AlgebraicNode[]): AlgebraicNode;
|
|
25
25
|
equals(node: AlgebraicNode): boolean;
|
|
26
26
|
toDetailedEvaluation(vars: Record<string, AlgebraicNode>): SqrtNode;
|
|
27
27
|
derivative(varName?: string | undefined): AlgebraicNode;
|
|
28
|
+
toSimplificationTex(opts?: SimplifyOptions): void;
|
|
28
29
|
}
|
|
29
30
|
//# sourceMappingURL=sqrtNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqrtNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/sqrtNode.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;AAK/E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"sqrtNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/sqrtNode.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;AAK/E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAMrE,wBAAgB,UAAU,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,QAAQ,CAEjD;AAED,eAAO,MAAM,IAAI,MAAO,aAAa,GAAG,MAAM,GAAG,MAAM,aAItD,CAAC;AAEF,qBAAa,QAAS,YAAW,YAAY;IAC3C,EAAE,EAAE,YAAY,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;gBACP,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;IAOpD,aAAa;;;;;;IAMb,YAAY,IAAI,MAAM;IAMtB,KAAK,IAAI,MAAM;IAIf,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,aAAa,EAAE;IAwBtD,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAG5C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAGtC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,EAAE,KAAK,CAAC,EAAE,aAAa,EAAE;IA2CxD,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAGpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAGxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;IAGvD,mBAAmB,CAAC,IAAI,CAAC,EAAE,eAAe;CAI3C"}
|
|
@@ -69,12 +69,13 @@ export class SqrtNode {
|
|
|
69
69
|
evaluate(vars) {
|
|
70
70
|
return Math.sqrt(this.child.evaluate(vars));
|
|
71
71
|
}
|
|
72
|
-
simplify(opts) {
|
|
72
|
+
simplify(opts, steps) {
|
|
73
73
|
const simplifiedChild = this.child.simplify(opts);
|
|
74
74
|
const copy = new SqrtNode(simplifiedChild, this.opts);
|
|
75
|
+
if (steps && !this.child.equals(simplifiedChild))
|
|
76
|
+
steps.push(copy);
|
|
75
77
|
const externals = [];
|
|
76
78
|
//ex [3, x^2] pour sqrt(3x^2)
|
|
77
|
-
//TODO fractions
|
|
78
79
|
const recursive = (node) => {
|
|
79
80
|
if (isMultiplyNode(node)) {
|
|
80
81
|
recursive(node.leftChild);
|
|
@@ -120,4 +121,48 @@ export class SqrtNode {
|
|
|
120
121
|
derivative(varName) {
|
|
121
122
|
throw new Error("unimplemented derivative");
|
|
122
123
|
}
|
|
124
|
+
toSimplificationTex(opts) {
|
|
125
|
+
const nodes = [this];
|
|
126
|
+
const simp = this.simplify(opts, nodes);
|
|
127
|
+
}
|
|
123
128
|
}
|
|
129
|
+
// const simplifyInteger = (a: number)=>{
|
|
130
|
+
// if (a === 0) return 0..toTree()
|
|
131
|
+
// if (a === 1) return 1..toTree();
|
|
132
|
+
// const [outsideSqrt, insideSqrt] = this.getSimplifiedCoeffs();
|
|
133
|
+
// const simplified =
|
|
134
|
+
// insideSqrt !== 1
|
|
135
|
+
// ? new Real(
|
|
136
|
+
// outsideSqrt * Math.sqrt(insideSqrt),
|
|
137
|
+
// `${outsideSqrt === 1 ? "" : `${outsideSqrt}`}\\sqrt{${insideSqrt}}`,
|
|
138
|
+
// )
|
|
139
|
+
// : new Real(outsideSqrt, outsideSqrt + "");
|
|
140
|
+
// simplified.toTree = (): AlgebraicNode => {
|
|
141
|
+
// return insideSqrt !== 1
|
|
142
|
+
// ? outsideSqrt === 1
|
|
143
|
+
// ? new SqrtNode(new NumberNode(insideSqrt))
|
|
144
|
+
// : new MultiplyNode(
|
|
145
|
+
// new NumberNode(outsideSqrt),
|
|
146
|
+
// new SqrtNode(new NumberNode(insideSqrt)),
|
|
147
|
+
// )
|
|
148
|
+
// : new NumberNode(outsideSqrt);
|
|
149
|
+
// };
|
|
150
|
+
// return simplified;
|
|
151
|
+
// }
|
|
152
|
+
// const getMaxSquareAndRest = (a: number)=> {
|
|
153
|
+
// if (a === 0) return [1, 0];
|
|
154
|
+
// const factors = primeFactors( a);
|
|
155
|
+
// // finds primes with even exponents
|
|
156
|
+
// const multiples = [1];
|
|
157
|
+
// for (let i = 0; i < factors.length - 1; i++) {
|
|
158
|
+
// if (factors[i] === factors[i + 1]) {
|
|
159
|
+
// multiples.push(factors[i]);
|
|
160
|
+
// factors.splice(i, 2);
|
|
161
|
+
// i--;
|
|
162
|
+
// }
|
|
163
|
+
// }
|
|
164
|
+
// const maxSquare = multiples.reduce((x, y) => x * y);
|
|
165
|
+
// const insideSqrt =
|
|
166
|
+
// factors.length === 0 ? 1 : factors.reduce((x, y) => x * y);
|
|
167
|
+
// return [maxSquare, insideSqrt];
|
|
168
|
+
// }
|