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.
@@ -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;AAsFF,eAAO,MAAM,mBAAmB,EAAE,YAAY,CAAC,WAAW,CAgBzD,CAAC;AACF,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,WAAW,CAgBvD,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: `Simplifier le plus possible l'expression suivante : $${statement.toTex()}$`,
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: `Simplifier l'expression suivante : $${expression.toTex()}$.`,
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,7 @@
1
+ export declare class GeogebraConstructor {
2
+ commands: string[];
3
+ constructor();
4
+ addCommand(...s: string[]): void;
5
+ getCommands(): string[];
6
+ }
7
+ //# sourceMappingURL=geogebraConstructor.d.ts.map
@@ -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,11 @@
1
+ /**
2
+ *
3
+ * @param n
4
+ * eg for n = 36 will return 6^2
5
+ * for n = 12 will return 2^2*3
6
+ */
7
+ export declare const maxPowerDecomposition: (n: number) => {
8
+ value: number;
9
+ power: number;
10
+ }[];
11
+ //# sourceMappingURL=maxPowerDecomposition.d.ts.map
@@ -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,5 @@
1
+ export declare const primeDecomposition: (n: number) => {
2
+ value: number;
3
+ power: number;
4
+ }[];
5
+ //# sourceMappingURL=primeDecomposition.d.ts.map
@@ -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;AAMjD,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;IA0BzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAGrC,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;CAGrC"}
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 primeFactors_1 = require("../../../math/utils/arithmetic/primeFactors");
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 factors = (0, primeFactors_1.primeFactors)(value);
62
- if (factors.length === 1)
63
- return this; //isPrime
64
- if (factors.every((nb) => nb === factors[0])) {
65
- return new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(factors.length), new Log10Node(new numberNode_1.NumberNode(factors[0]))).simplify();
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;AAOjD,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,OAAO,CAE/C;AACD,qBAAa,OAAQ,YAAW,YAAY;IA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AI,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 log = Math.log(value);
59
- if ((0, isInt_1.isInt)(log))
60
- return new numberNode_1.NumberNode(log);
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 factors = (0, primeFactors_1.primeFactors)(value);
63
- if (factors.length === 1)
64
- return this; //isPrime
65
- if (factors.every((nb) => nb === factors[0])) {
66
- return new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(factors.length), new LogNode(new numberNode_1.NumberNode(factors[0]))).simplify();
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "math-exercises",
3
- "version": "2.0.22",
3
+ "version": "2.0.23",
4
4
  "description": "Math exercises generator for middle school and high school",
5
5
  "main": "lib/index.js",
6
6
  "files": [