math-exercises 2.0.22 → 2.0.23
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/equaDiff/equaDiffCheckSolutionFirstOrderTrinom.d.ts +1 -0
- package/lib/exercises/equaDiff/equaDiffCheckSolutionFirstOrderTrinom.d.ts.map +1 -0
- package/lib/exercises/equaDiff/equaDiffCheckSolutionFirstOrderTrinom.js +53 -0
- package/lib/exercises/functions/logarithm/log10Simplifying.d.ts.map +1 -1
- package/lib/exercises/functions/logarithm/log10Simplifying.js +2 -1
- package/lib/exercises/functions/logarithm/logSimplifiying.js +1 -1
- package/lib/geogebra/geogebraConstructor.d.ts +7 -0
- package/lib/geogebra/geogebraConstructor.d.ts.map +1 -0
- package/lib/geogebra/geogebraConstructor.js +15 -0
- package/lib/math/utils/arithmetic/maxPowerDecomposition.d.ts +11 -0
- package/lib/math/utils/arithmetic/maxPowerDecomposition.d.ts.map +1 -0
- package/lib/math/utils/arithmetic/maxPowerDecomposition.js +26 -0
- package/lib/math/utils/arithmetic/primeDecomposition.d.ts +5 -0
- package/lib/math/utils/arithmetic/primeDecomposition.d.ts.map +1 -0
- package/lib/math/utils/arithmetic/primeDecomposition.js +22 -0
- package/lib/tree/nodes/functions/log10Node.d.ts.map +1 -1
- package/lib/tree/nodes/functions/log10Node.js +13 -6
- package/lib/tree/nodes/functions/logNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/logNode.js +16 -9
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=equaDiffCheckSolutionFirstOrderTrinom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"equaDiffCheckSolutionFirstOrderTrinom.d.ts","sourceRoot":"","sources":["../../../src/exercises/equaDiff/equaDiffCheckSolutionFirstOrderTrinom.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import {
|
|
3
|
+
// MathExercise,
|
|
4
|
+
// Proposition,
|
|
5
|
+
// QCMGenerator,
|
|
6
|
+
// Question,
|
|
7
|
+
// QuestionGenerator,
|
|
8
|
+
// VEA,
|
|
9
|
+
// addValidProp,
|
|
10
|
+
// shuffleProps,
|
|
11
|
+
// tryToAddWrongProp,
|
|
12
|
+
// } from "../../exercises/exercise";
|
|
13
|
+
// import { getDistinctQuestions } from "../../exercises/utils/getDistinctQuestions";
|
|
14
|
+
// import { TrinomConstructor } from "../../math/polynomials/trinom";
|
|
15
|
+
// type Identifiers = {};
|
|
16
|
+
// /**y = y' + dx^2+ex+f, alors y = ax^2+bx+c */
|
|
17
|
+
// const getEquaDiffCheckSolutionFirstOrderQuestion: QuestionGenerator<
|
|
18
|
+
// Identifiers
|
|
19
|
+
// > = () => {
|
|
20
|
+
// const trinom = TrinomConstructor.random();
|
|
21
|
+
// const d = trinom.a;
|
|
22
|
+
// const e = trinom.b - 2 * trinom.a;
|
|
23
|
+
// const f = trinom.c - trinom.b;
|
|
24
|
+
// const question: Question<Identifiers> = {
|
|
25
|
+
// answer,
|
|
26
|
+
// instruction: ``,
|
|
27
|
+
// keys: [],
|
|
28
|
+
// answerFormat: "tex",
|
|
29
|
+
// identifiers: {},
|
|
30
|
+
// };
|
|
31
|
+
// return question;
|
|
32
|
+
// };
|
|
33
|
+
// const getPropositions: QCMGenerator<Identifiers> = (n, { answer }) => {
|
|
34
|
+
// const propositions: Proposition[] = [];
|
|
35
|
+
// addValidProp(propositions, answer);
|
|
36
|
+
// while (propositions.length < n) {}
|
|
37
|
+
// return shuffleProps(propositions, n);
|
|
38
|
+
// };
|
|
39
|
+
// const isAnswerValid: VEA<Identifiers> = (ans, { answer }) => {};
|
|
40
|
+
// export const equaDiffCheckSolutionFirstOrder: MathExercise<Identifiers> = {
|
|
41
|
+
// id: "equaDiffCheckSolutionFirstOrder",
|
|
42
|
+
// connector: "",
|
|
43
|
+
// label: "",
|
|
44
|
+
// levels: [],
|
|
45
|
+
// isSingleStep: true,
|
|
46
|
+
// sections: [],
|
|
47
|
+
// generator: (nb: number) =>
|
|
48
|
+
// getDistinctQuestions(getEquaDiffCheckSolutionFirstOrderQuestion, nb),
|
|
49
|
+
// qcmTimer: 60,
|
|
50
|
+
// freeTimer: 60,
|
|
51
|
+
// getPropositions,
|
|
52
|
+
// isAnswerValid,
|
|
53
|
+
// };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log10Simplifying.d.ts","sourceRoot":"","sources":["../../../../src/exercises/functions/logarithm/log10Simplifying.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EASb,MAAM,0BAA0B,CAAC;AAalC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;
|
|
1
|
+
{"version":3,"file":"log10Simplifying.d.ts","sourceRoot":"","sources":["../../../../src/exercises/functions/logarithm/log10Simplifying.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EASb,MAAM,0BAA0B,CAAC;AAalC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AA0FF,eAAO,MAAM,mBAAmB,EAAE,YAAY,CAAC,WAAW,CAgBzD,CAAC;AACF,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,WAAW,CAgBvD,CAAC"}
|
|
@@ -15,6 +15,7 @@ const operatorComposition_1 = require("../../../tree/utilities/operatorCompositi
|
|
|
15
15
|
const random_1 = require("../../../utils/random");
|
|
16
16
|
const getLog10SumSimplifyingQuestion = (opts) => {
|
|
17
17
|
const nb = (0, randint_1.randint)(2, 10);
|
|
18
|
+
const trueNb = [2, 4, 8].includes(nb) ? 2 : [3, 9].includes(nb) ? 3 : nb;
|
|
18
19
|
const nbTerms = (0, randint_1.randint)(2, 4);
|
|
19
20
|
const powers = [];
|
|
20
21
|
const signs = [];
|
|
@@ -36,7 +37,7 @@ const getLog10SumSimplifyingQuestion = (opts) => {
|
|
|
36
37
|
const answer = statement.simplify();
|
|
37
38
|
const question = {
|
|
38
39
|
answer: answer.toTex(),
|
|
39
|
-
instruction: `
|
|
40
|
+
instruction: `Exprimer le nombre suivant sous la forme $a${opts?.isLog10 ? "\\log" : "\\ln"}\\left(${trueNb}\\right)$ : $\\newline ${statement.toTex()}$`,
|
|
40
41
|
keys: [opts?.isLog10 ? "log" : "ln"],
|
|
41
42
|
answerFormat: "tex",
|
|
42
43
|
identifiers: { nb, powers, signs, isLog10: opts?.isLog10 ?? false },
|
|
@@ -31,7 +31,7 @@ const getExpSimplifiying = () => {
|
|
|
31
31
|
}
|
|
32
32
|
const answer = simplifiedExpression.toTex();
|
|
33
33
|
const question = {
|
|
34
|
-
instruction: `
|
|
34
|
+
instruction: `Ecrire le nombre suivant sous la forme $\\ln\\left(a\\right)$ : $\\newline ${expression.toTex()}$.`,
|
|
35
35
|
answer,
|
|
36
36
|
keys: ["ln"],
|
|
37
37
|
answerFormat: "tex",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geogebraConstructor.d.ts","sourceRoot":"","sources":["../../src/geogebra/geogebraConstructor.ts"],"names":[],"mappings":"AAAA,qBAAa,mBAAmB;IAC9B,QAAQ,EAAE,MAAM,EAAE,CAAM;;IAIxB,UAAU,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE;IAGzB,WAAW;CAGZ"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GeogebraConstructor = void 0;
|
|
4
|
+
class GeogebraConstructor {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.commands = [];
|
|
7
|
+
}
|
|
8
|
+
addCommand(...s) {
|
|
9
|
+
this.commands.push(...s);
|
|
10
|
+
}
|
|
11
|
+
getCommands() {
|
|
12
|
+
return this.commands;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.GeogebraConstructor = GeogebraConstructor;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maxPowerDecomposition.d.ts","sourceRoot":"","sources":["../../../../src/math/utils/arithmetic/maxPowerDecomposition.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,MAAO,MAAM;WAEzB,MAAM;WAAS,MAAM;GAW1C,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.maxPowerDecomposition = void 0;
|
|
4
|
+
const primeDecomposition_1 = require("./primeDecomposition");
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param n
|
|
8
|
+
* eg for n = 36 will return 6^2
|
|
9
|
+
* for n = 12 will return 2^2*3
|
|
10
|
+
*/
|
|
11
|
+
const maxPowerDecomposition = (n) => {
|
|
12
|
+
const decomposition = (0, primeDecomposition_1.primeDecomposition)(n);
|
|
13
|
+
const res = [];
|
|
14
|
+
for (const item of decomposition) {
|
|
15
|
+
const { value, power } = item;
|
|
16
|
+
const matchingPower = res.find((el) => el.power === power);
|
|
17
|
+
if (matchingPower) {
|
|
18
|
+
matchingPower.value *= value;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
res.push(item);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return res;
|
|
25
|
+
};
|
|
26
|
+
exports.maxPowerDecomposition = maxPowerDecomposition;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primeDecomposition.d.ts","sourceRoot":"","sources":["../../../../src/math/utils/arithmetic/primeDecomposition.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,MAAO,MAAM;WAEtB,MAAM;WAAS,MAAM;GAa1C,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.primeDecomposition = void 0;
|
|
4
|
+
const primeFactors_1 = require("./primeFactors");
|
|
5
|
+
const primeDecomposition = (n) => {
|
|
6
|
+
const factors = (0, primeFactors_1.primeFactors)(n);
|
|
7
|
+
const res = [];
|
|
8
|
+
for (const factor of factors) {
|
|
9
|
+
const data = res.find((el) => el.value === factor);
|
|
10
|
+
if (data) {
|
|
11
|
+
data.power++;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
res.push({
|
|
15
|
+
value: factor,
|
|
16
|
+
power: 1,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return res;
|
|
21
|
+
};
|
|
22
|
+
exports.primeDecomposition = primeDecomposition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log10Node.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/log10Node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"log10Node.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/log10Node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAQjD,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,SAAS,CAEnD;AACD,qBAAa,SAAU,YAAW,YAAY;IAC5C,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;IAQpD,YAAY,IAAI,MAAM;IAItB,KAAK,IAAI,MAAM;IAaf,iBAAiB,IAAI,aAAa,EAAE;IASpC,cAAc,IAAI,MAAM,EAAE;IAG1B,QAAQ,IAAI,aAAa;IAgCzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAGrC,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;CAGrC"}
|
|
@@ -9,7 +9,7 @@ const numberNode_1 = require("../numbers/numberNode");
|
|
|
9
9
|
const isInt_1 = require("../../../utils/isInt");
|
|
10
10
|
const powerNode_1 = require("../operators/powerNode");
|
|
11
11
|
const multiplyNode_1 = require("../operators/multiplyNode");
|
|
12
|
-
const
|
|
12
|
+
const maxPowerDecomposition_1 = require("../../../math/utils/arithmetic/maxPowerDecomposition");
|
|
13
13
|
function isLog10Node(a) {
|
|
14
14
|
return (0, functionNode_1.isFunctionNode)(a) && a.id === functionNode_1.FunctionsIds.log10;
|
|
15
15
|
}
|
|
@@ -58,11 +58,18 @@ class Log10Node {
|
|
|
58
58
|
if ((0, isInt_1.isInt)(log10))
|
|
59
59
|
return new numberNode_1.NumberNode(log10);
|
|
60
60
|
if ((0, isInt_1.isInt)(value)) {
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
const decomposition = (0, maxPowerDecomposition_1.maxPowerDecomposition)(value);
|
|
62
|
+
if (decomposition.length === 1) {
|
|
63
|
+
const el = decomposition[0];
|
|
64
|
+
if (el.power === 1)
|
|
65
|
+
return this; //isPrime
|
|
66
|
+
else
|
|
67
|
+
return new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(el.power), new Log10Node(new numberNode_1.NumberNode(el.value)));
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
//! things like log(6) will return themselves
|
|
71
|
+
//! even true for log(12). Should they be simplified into 2ln(2)+ln(3) ?
|
|
72
|
+
return new Log10Node(simplifiedChild);
|
|
66
73
|
}
|
|
67
74
|
}
|
|
68
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/logNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"logNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/logNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAQjD,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,OAAO,CAE/C;AACD,qBAAa,OAAQ,YAAW,YAAY;IAC1C,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;IAQpD,YAAY,IAAI,MAAM;IAItB,KAAK,IAAI,MAAM;IAaf,iBAAiB,IAAI,aAAa,EAAE;IASpC,cAAc,IAAI,MAAM,EAAE;IAG1B,QAAQ,IAAI,aAAa;IAmCzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAGrC,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;CAGrC"}
|
|
@@ -9,8 +9,8 @@ const multiplyNode_1 = require("../operators/multiplyNode");
|
|
|
9
9
|
const powerNode_1 = require("../operators/powerNode");
|
|
10
10
|
const numberNode_1 = require("../numbers/numberNode");
|
|
11
11
|
const isInt_1 = require("../../../utils/isInt");
|
|
12
|
-
const primeFactors_1 = require("../../../math/utils/arithmetic/primeFactors");
|
|
13
12
|
const expNode_1 = require("./expNode");
|
|
13
|
+
const maxPowerDecomposition_1 = require("../../../math/utils/arithmetic/maxPowerDecomposition");
|
|
14
14
|
function isLogNode(a) {
|
|
15
15
|
return (0, functionNode_1.isFunctionNode)(a) && a.id === functionNode_1.FunctionsIds.log;
|
|
16
16
|
}
|
|
@@ -55,15 +55,22 @@ class LogNode {
|
|
|
55
55
|
const simplifiedChild = this.child.simplify();
|
|
56
56
|
if ((0, numberNode_1.isNumberNode)(simplifiedChild)) {
|
|
57
57
|
const value = simplifiedChild.value;
|
|
58
|
-
const
|
|
59
|
-
if ((0, isInt_1.isInt)(
|
|
60
|
-
return new numberNode_1.NumberNode(
|
|
58
|
+
const log10 = Math.log10(value);
|
|
59
|
+
if ((0, isInt_1.isInt)(log10))
|
|
60
|
+
return new numberNode_1.NumberNode(log10);
|
|
61
61
|
if ((0, isInt_1.isInt)(value)) {
|
|
62
|
-
const
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
const decomposition = (0, maxPowerDecomposition_1.maxPowerDecomposition)(value);
|
|
63
|
+
if (decomposition.length === 1) {
|
|
64
|
+
const el = decomposition[0];
|
|
65
|
+
if (el.power === 1)
|
|
66
|
+
return this; //isPrime
|
|
67
|
+
else
|
|
68
|
+
return new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(el.power), new LogNode(new numberNode_1.NumberNode(el.value)));
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
//! things like log(6) will return themselves
|
|
72
|
+
//! even true for log(12). Should they be simplified into 2ln(2)+ln(3) ?
|
|
73
|
+
return new LogNode(simplifiedChild);
|
|
67
74
|
}
|
|
68
75
|
}
|
|
69
76
|
}
|