math-exercises 1.3.64 → 1.3.66

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.
@@ -1 +1 @@
1
- {"version":3,"file":"exercises.d.ts","sourceRoot":"","sources":["../../src/exercises/exercises.ts"],"names":[],"mappings":"AA+KA,eAAO,MAAM,SAAS,iCA8PrB,CAAC"}
1
+ {"version":3,"file":"exercises.d.ts","sourceRoot":"","sources":["../../src/exercises/exercises.ts"],"names":[],"mappings":"AAiLA,eAAO,MAAM,SAAS,iCAmQrB,CAAC"}
@@ -165,6 +165,8 @@ const inequalityToInterval_1 = require("./sets/intervals/inequalityToInterval");
165
165
  const setBelonging_1 = require("./sets/setBelonging");
166
166
  const intervalsUnion_1 = require("./sets/intervals/intervalsUnion");
167
167
  const intervalsIntersection_1 = require("./sets/intervals/intervalsIntersection");
168
+ const sequencePolynomLimit_1 = require("./limits/sequencePolynomLimit");
169
+ const sequenceRationalFracLimit_1 = require("./limits/sequenceRationalFracLimit");
168
170
  exports.exercises = [
169
171
  /**
170
172
  * calcul litteral
@@ -363,7 +365,6 @@ exports.exercises = [
363
365
  euclideanDivision_1.euclideanDivision,
364
366
  signFunction_1.signFunction,
365
367
  thirdDegreeFunctionVariation_1.thirdDegreeFunctionVariation,
366
- polynomeLimit_1.polynomeLimit,
367
368
  equaDiffGeneralForme_1.exponentialDifferentialEquation,
368
369
  equaDiffGeneralFormeWithIC_1.exponentialDifferentialEquationWithIC,
369
370
  /**Stats */
@@ -396,4 +397,8 @@ exports.exercises = [
396
397
  setBelonging_1.setBelonging,
397
398
  intervalsUnion_1.intervalsUnion,
398
399
  intervalsIntersection_1.intervalsIntersection,
400
+ /**limites */
401
+ polynomeLimit_1.polynomeLimit,
402
+ sequencePolynomLimit_1.sequencePolynomLimit,
403
+ sequenceRationalFracLimit_1.sequenceRationalFracLimit,
399
404
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"inverseImageFunctionGeogebra.d.ts","sourceRoot":"","sources":["../../../../src/exercises/functions/basics/inverseImageFunctionGeogebra.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAS3E,eAAO,MAAM,4BAA4B,EAAE,QAY1C,CAAC;AAEF,wBAAgB,+BAA+B,IAAI,QAAQ,CAsJ1D"}
1
+ {"version":3,"file":"inverseImageFunctionGeogebra.d.ts","sourceRoot":"","sources":["../../../../src/exercises/functions/basics/inverseImageFunctionGeogebra.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAS3E,eAAO,MAAM,4BAA4B,EAAE,QAY1C,CAAC;AAEF,wBAAgB,+BAA+B,IAAI,QAAQ,CA4J1D"}
@@ -141,7 +141,13 @@ function getInverseImageFunctionGeogebra() {
141
141
  }
142
142
  return (0, shuffle_1.shuffle)(res);
143
143
  };
144
- const commands = [rand ? polynome1.toString() : polynome2.add(new polynomial_1.Polynomial([yValue])).toString()];
144
+ const commands = [
145
+ rand
146
+ ? polynome1.toString()
147
+ : yValue !== 0
148
+ ? polynome2.add(new polynomial_1.Polynomial([yValue])).toString()
149
+ : polynome2.toString(),
150
+ ];
145
151
  const question = {
146
152
  instruction: statement,
147
153
  answer: answer + '',
@@ -0,0 +1,4 @@
1
+ import { Exercise, Question } from '../../exercises/exercise';
2
+ export declare const sequencePolynomLimit: Exercise;
3
+ export declare function getSequencePolynomLimitQuestion(): Question;
4
+ //# sourceMappingURL=sequencePolynomLimit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sequencePolynomLimit.d.ts","sourceRoot":"","sources":["../../../src/exercises/limits/sequencePolynomLimit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAO3E,eAAO,MAAM,oBAAoB,EAAE,QAWlC,CAAC;AAEF,wBAAgB,+BAA+B,IAAI,QAAQ,CAiD1D"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSequencePolynomLimitQuestion = exports.sequencePolynomLimit = void 0;
4
+ const getDistinctQuestions_1 = require("../../exercises/utils/getDistinctQuestions");
5
+ const polynomial_1 = require("../../math/polynomials/polynomial");
6
+ const coinFlip_1 = require("../../utils/coinFlip");
7
+ const shuffle_1 = require("../../utils/shuffle");
8
+ const uuid_1 = require("uuid");
9
+ exports.sequencePolynomLimit = {
10
+ id: 'sequencePolynomLimit',
11
+ connector: '=',
12
+ instruction: '',
13
+ label: "Limite d'une suite polynomiale",
14
+ levels: ['TermSpé', 'MathComp'],
15
+ isSingleStep: true,
16
+ sections: ['Limites'],
17
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getSequencePolynomLimitQuestion, nb),
18
+ qcmTimer: 60,
19
+ freeTimer: 60,
20
+ };
21
+ function getSequencePolynomLimitQuestion() {
22
+ const poly = polynomial_1.PolynomialConstructor.random(4, 'n');
23
+ const isPositiveInfinite = (0, coinFlip_1.coinFlip)();
24
+ const to = isPositiveInfinite ? '+\\infty' : '-\\infty';
25
+ const answer = poly.getLimit(to);
26
+ const getPropositions = (n) => {
27
+ const res = [];
28
+ res.push({
29
+ id: (0, uuid_1.v4)(),
30
+ statement: answer,
31
+ isRightAnswer: true,
32
+ format: 'tex',
33
+ });
34
+ const missing = n - res.length;
35
+ for (let i = 0; i < missing; i++) {
36
+ let isDuplicate;
37
+ let proposition;
38
+ do {
39
+ const wrongAnswer = '';
40
+ proposition = {
41
+ id: (0, uuid_1.v4)() + ``,
42
+ statement: wrongAnswer,
43
+ isRightAnswer: false,
44
+ format: 'tex',
45
+ };
46
+ isDuplicate = res.some((p) => p.statement === proposition.statement);
47
+ } while (isDuplicate);
48
+ res.push(proposition);
49
+ }
50
+ return (0, shuffle_1.shuffle)(res);
51
+ };
52
+ const question = {
53
+ answer: answer,
54
+ instruction: `Soit $u$ la suite définie par $u_n = ${poly
55
+ .toTree()
56
+ .toTex()}$. Déterminer $$\\lim_{n\\to ${to}}u_n$$.`,
57
+ keys: ['infty'],
58
+ getPropositions,
59
+ answerFormat: 'tex',
60
+ };
61
+ return question;
62
+ }
63
+ exports.getSequencePolynomLimitQuestion = getSequencePolynomLimitQuestion;
@@ -0,0 +1,4 @@
1
+ import { Exercise, Question } from '../../exercises/exercise';
2
+ export declare const sequenceRationalFracLimit: Exercise;
3
+ export declare function getSequenceRationalFracLimitQuestion(): Question;
4
+ //# sourceMappingURL=sequenceRationalFracLimit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sequenceRationalFracLimit.d.ts","sourceRoot":"","sources":["../../../src/exercises/limits/sequenceRationalFracLimit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAS3E,eAAO,MAAM,yBAAyB,EAAE,QAWvC,CAAC;AAEF,wBAAgB,oCAAoC,IAAI,QAAQ,CAmE/D"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSequenceRationalFracLimitQuestion = exports.sequenceRationalFracLimit = void 0;
4
+ const getDistinctQuestions_1 = require("../../exercises/utils/getDistinctQuestions");
5
+ const rational_1 = require("../../math/numbers/rationals/rational");
6
+ const monom_1 = require("../../math/polynomials/monom");
7
+ const polynomial_1 = require("../../math/polynomials/polynomial");
8
+ const coinFlip_1 = require("../../utils/coinFlip");
9
+ const shuffle_1 = require("../../utils/shuffle");
10
+ const uuid_1 = require("uuid");
11
+ exports.sequenceRationalFracLimit = {
12
+ id: 'sequenceRationalFracLimit',
13
+ connector: '=',
14
+ instruction: '',
15
+ label: "Limite d'une suite rationnelle",
16
+ levels: ['TermSpé', 'MathComp'],
17
+ isSingleStep: true,
18
+ sections: ['Limites'],
19
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getSequenceRationalFracLimitQuestion, nb),
20
+ qcmTimer: 60,
21
+ freeTimer: 60,
22
+ };
23
+ function getSequenceRationalFracLimitQuestion() {
24
+ const polyNum = polynomial_1.PolynomialConstructor.random(4, 'n');
25
+ const polyDenum = polynomial_1.PolynomialConstructor.random(4, 'n');
26
+ const numLeadingCoeff = polyNum.coefficients[polyNum.degree];
27
+ const denumLeadingCoeff = polyDenum.coefficients[polyDenum.degree];
28
+ const isPositiveInfinite = (0, coinFlip_1.coinFlip)();
29
+ const to = isPositiveInfinite ? '+\\infty' : '-\\infty';
30
+ let answer;
31
+ if (polyDenum.degree === polyNum.degree) {
32
+ answer = new rational_1.Rational(numLeadingCoeff, denumLeadingCoeff).simplify().toTree().toTex();
33
+ }
34
+ else if (polyDenum.degree > polyNum.degree) {
35
+ answer = '0';
36
+ }
37
+ else {
38
+ const tempPoly = new monom_1.Monom(polyNum.degree - polyDenum.degree, numLeadingCoeff * denumLeadingCoeff > 0 ? 1 : -1, 'n');
39
+ answer = tempPoly.getLimit(to);
40
+ }
41
+ // sinon créer un polynome de coeff = leading coeff et degré = division des degrés
42
+ const getPropositions = (n) => {
43
+ const res = [];
44
+ res.push({
45
+ id: (0, uuid_1.v4)(),
46
+ statement: answer,
47
+ isRightAnswer: true,
48
+ format: 'tex',
49
+ });
50
+ const missing = n - res.length;
51
+ for (let i = 0; i < missing; i++) {
52
+ let isDuplicate;
53
+ let proposition;
54
+ do {
55
+ const wrongAnswer = '';
56
+ proposition = {
57
+ id: (0, uuid_1.v4)() + ``,
58
+ statement: wrongAnswer,
59
+ isRightAnswer: false,
60
+ format: 'tex',
61
+ };
62
+ isDuplicate = res.some((p) => p.statement === proposition.statement);
63
+ } while (isDuplicate);
64
+ res.push(proposition);
65
+ }
66
+ return (0, shuffle_1.shuffle)(res);
67
+ };
68
+ const question = {
69
+ answer,
70
+ instruction: `Soit $u$ la suite définie par $u_n = \\dfrac{${polyNum.toTree().toTex()}}{${polyDenum
71
+ .toTree()
72
+ .toTex()}}$. Déterminer $$\\lim_{n\\to ${to}}u_n$$.`,
73
+ keys: ['infty'],
74
+ getPropositions,
75
+ answerFormat: 'tex',
76
+ };
77
+ return question;
78
+ }
79
+ exports.getSequenceRationalFracLimitQuestion = getSequenceRationalFracLimitQuestion;
@@ -127,7 +127,7 @@ function getInequalityToIntervalQuestion() {
127
127
  const question = {
128
128
  answer,
129
129
  instruction: instruction,
130
- keys: ['x', 'belongs', 'inf', 'sup', 'geq', 'leq', 'lbracket', 'rbracket', 'semicolon'],
130
+ keys: ['x', 'belongs', 'inf', 'sup', 'geq', 'leq', 'lbracket', 'rbracket', 'semicolon', 'infty'],
131
131
  getPropositions,
132
132
  answerFormat: 'tex',
133
133
  };
@@ -0,0 +1,5 @@
1
+ import { Polynomial } from './polynomial';
2
+ export declare class Monom extends Polynomial {
3
+ constructor(degree: number, coeff: number, variable?: string);
4
+ }
5
+ //# sourceMappingURL=monom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monom.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/monom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,qBAAa,KAAM,SAAQ,UAAU;gBACvB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;CAMlE"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Monom = void 0;
4
+ const polynomial_1 = require("./polynomial");
5
+ class Monom extends polynomial_1.Polynomial {
6
+ constructor(degree, coeff, variable = 'x') {
7
+ const coeffs = [];
8
+ for (let i = 0; i < degree; i++)
9
+ coeffs.push(0);
10
+ coeffs.push(coeff);
11
+ super(coeffs, variable);
12
+ }
13
+ }
14
+ exports.Monom = Monom;
@@ -1,5 +1,9 @@
1
1
  import { Node } from '../../tree/nodes/node';
2
2
  export declare function createRandomPolynomialWithOrder(order: number, variable?: string): Polynomial;
3
+ export declare abstract class PolynomialConstructor {
4
+ static randomWithOrder(order: number, variable?: string): Polynomial;
5
+ static random(maxOrder: number, variable?: string): Polynomial;
6
+ }
3
7
  export declare class Polynomial {
4
8
  degree: number;
5
9
  variable: string;
@@ -22,6 +26,7 @@ export declare class Polynomial {
22
26
  derivate(): Polynomial;
23
27
  integrate(): Polynomial;
24
28
  calculate(x: number): number;
29
+ getLimit(to: '+\\infty' | '-\\infty'): string;
25
30
  toTree(): Node;
26
31
  toTex(): string;
27
32
  toString(): string;
@@ -1 +1 @@
1
- {"version":3,"file":"polynomial.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/polynomial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAU7C,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY,GAAG,UAAU,CAYjG;AAED,qBAAa,UAAU;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IAEvB;;;;OAIG;gBACS,YAAY,EAAE,MAAM,EAAE,EAAE,QAAQ,GAAE,MAAY;IAS1D,MAAM,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO;IAG9B,QAAQ,IAAI,MAAM,EAAE;IA8BpB,GAAG,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU;IAc9B,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU;IAM7B,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU;IAkBnC,QAAQ,IAAI,UAAU;IAOtB,QAAQ,IAAI,UAAU;IAQtB,SAAS,IAAI,UAAU;IAMvB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAM5B,MAAM,IAAI,IAAI;IAmCd,KAAK,IAAI,MAAM;IAkBf,QAAQ,IAAI,MAAM;CAGnB"}
1
+ {"version":3,"file":"polynomial.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/polynomial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAU7C,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY,GAAG,UAAU,CAYjG;AAED,8BAAsB,qBAAqB;IACzC,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IAa5D,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;CAavD;AAED,qBAAa,UAAU;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IAEvB;;;;OAIG;gBACS,YAAY,EAAE,MAAM,EAAE,EAAE,QAAQ,GAAE,MAAY;IAS1D,MAAM,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO;IAG9B,QAAQ,IAAI,MAAM,EAAE;IA8BpB,GAAG,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU;IAc9B,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU;IAM7B,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU;IAkBnC,QAAQ,IAAI,UAAU;IAOtB,QAAQ,IAAI,UAAU;IAQtB,SAAS,IAAI,UAAU;IAMvB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAM5B,QAAQ,CAAC,EAAE,EAAE,UAAU,GAAG,UAAU,GAAG,MAAM;IAiB7C,MAAM,IAAI,IAAI;IAmCd,KAAK,IAAI,MAAM;IAkBf,QAAQ,IAAI,MAAM;CAGnB"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Polynomial = exports.createRandomPolynomialWithOrder = void 0;
3
+ exports.Polynomial = exports.PolynomialConstructor = exports.createRandomPolynomialWithOrder = void 0;
4
4
  const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
5
5
  const addNode_1 = require("../../tree/nodes/operators/addNode");
6
6
  const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
@@ -20,6 +20,32 @@ function createRandomPolynomialWithOrder(order, variable = 'x') {
20
20
  return new Polynomial(coefficients, variable);
21
21
  }
22
22
  exports.createRandomPolynomialWithOrder = createRandomPolynomialWithOrder;
23
+ class PolynomialConstructor {
24
+ static randomWithOrder(order, variable = 'x') {
25
+ if (order < 0) {
26
+ throw Error('Order must be a non-negative integer');
27
+ }
28
+ const coefficients = [];
29
+ for (let i = 0; i <= order - 1; i++) {
30
+ coefficients.push((0, randint_1.randint)(-9, 10));
31
+ }
32
+ coefficients.push((0, randint_1.randint)(-9, 10, [0]));
33
+ return new Polynomial(coefficients, variable);
34
+ }
35
+ static random(maxOrder, variable = 'x') {
36
+ if (maxOrder < 0) {
37
+ throw Error('Order must be a non-negative integer');
38
+ }
39
+ const order = (0, randint_1.randint)(1, maxOrder + 1);
40
+ const coefficients = [];
41
+ for (let i = 0; i <= order - 1; i++) {
42
+ coefficients.push((0, randint_1.randint)(-9, 10));
43
+ }
44
+ coefficients.push((0, randint_1.randint)(-9, 10, [0]));
45
+ return new Polynomial(coefficients, variable);
46
+ }
47
+ }
48
+ exports.PolynomialConstructor = PolynomialConstructor;
23
49
  class Polynomial {
24
50
  /**
25
51
  *
@@ -118,6 +144,28 @@ class Polynomial {
118
144
  res += x ** i * this.coefficients[i];
119
145
  return res;
120
146
  }
147
+ getLimit(to) {
148
+ const leadingCoeff = this.coefficients[this.coefficients.length - 1];
149
+ if (this.degree === 0)
150
+ return leadingCoeff + '';
151
+ if (to === '+\\infty') {
152
+ if (leadingCoeff > 0)
153
+ return '+\\infty';
154
+ return '-\\infty';
155
+ }
156
+ else {
157
+ if (leadingCoeff > 0) {
158
+ if (this.degree % 2 === 0)
159
+ return '+\\infty';
160
+ return '-\\infty';
161
+ }
162
+ else {
163
+ if (this.degree % 2 === 0)
164
+ return '-\\infty';
165
+ return '+\\infty';
166
+ }
167
+ }
168
+ }
121
169
  toTree() {
122
170
  const recursive = (cursor) => {
123
171
  const coeff = this.coefficients[cursor];
@@ -216,19 +216,19 @@ class Interval {
216
216
  const isRightClosed = this.boundType === BoundType.FF || this.boundType === BoundType.OF;
217
217
  if (this.max === Infinity) {
218
218
  if (isLeftClosed) {
219
- return `x \\ge ${this.min}`;
219
+ return `x\\ge${this.min}`;
220
220
  }
221
221
  else
222
- return `x > ${this.min}`;
222
+ return `x>${this.min}`;
223
223
  }
224
224
  else if (this.min === -Infinity) {
225
225
  if (this.boundType === BoundType.OF) {
226
- return `x \\le ${this.max}`;
226
+ return `x\\le${this.max}`;
227
227
  }
228
228
  else
229
- return `x < ${this.max}`;
229
+ return `x<${this.max}`;
230
230
  }
231
- return `${this.min} ${isLeftClosed ? '\\le' : '<'} x ${isRightClosed ? '\\le' : '<'} ${this.max}`;
231
+ return `${this.min}${isLeftClosed ? '\\le x' : '<x'}${isRightClosed ? '\\le' : '<'}${this.max}`;
232
232
  }
233
233
  getRandomElement(precision = this.type === nombre_1.NumberType.Integer ? 0 : 2) {
234
234
  if (this.min === -Infinity || this.max === Infinity)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "math-exercises",
3
- "version": "1.3.64",
3
+ "version": "1.3.66",
4
4
  "description": "Math exercises generator for middle school and high school",
5
5
  "main": "lib/index.js",
6
6
  "files": [