math-exercises 1.3.58 → 1.3.59

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.
@@ -28,6 +28,7 @@ export interface Exercise {
28
28
  connector?: '=' | '\\iff' | '\\approx';
29
29
  keys?: string[];
30
30
  generator(nb: number, options?: GeneratorOptions): Question[];
31
+ answerType?: 'QCM' | 'free';
31
32
  }
32
33
  export type MathLevel = '6ème' | '5ème' | '4ème' | '3ème' | '2nde' | '1reTech' | '1reESM' | '1reSpé' | 'TermSpé' | 'TermTech' | 'MathExp' | 'MathComp' | 'CAP' | '2ndPro' | '1rePro' | 'TermPro';
33
34
  export type MathSection = 'Arithmétique' | 'Calcul littéral' | 'Calculs' | 'Conversions' | 'Dérivation' | 'Droites' | 'Équations' | 'Équations différentielles' | 'Exponentielle' | 'Fonction cube' | 'Fonction inverse' | 'Fonctions' | 'Fonctions affines' | 'Fonctions de référence' | 'Fractions' | 'Géométrie cartésienne' | 'Géométrie euclidienne' | 'Inéquations' | 'Intégration' | 'Intervalles' | 'Limites' | 'Logarithme népérien' | 'Nombres complexes' | 'Pourcentages' | 'Primitives' | 'Probabilités' | 'Proportionnalité' | 'Puissances' | 'Racines carrées' | 'Second degré' | 'Statistiques' | 'Suites' | 'Trigonométrie' | 'Vecteurs';
@@ -1 +1 @@
1
- {"version":3,"file":"exercise.d.ts","sourceRoot":"","sources":["../../src/exercises/exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,MAAM,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAElC,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,OAAO,CAAC;IACvB,MAAM,EAAE,KAAK,GAAG,KAAK,CAAC;CACvB,CAAC;AACF,MAAM,WAAW,QAAQ;IACvB,WAAW,CAAC,EAAE,MAAM,CA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,SAAS,EAAE,CAAC;IACpB,SAAS,CAAC,EAAE,GAAG,GAAG,OAAO,GAAG,UAAU,CAAC;IACvC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,QAAQ,EAAE,CAAC;IAC9D,UAAU,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CAC7B;AAED,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,UAAU,GACV,SAAS,GACT,UAAU,GACV,KAAK,GACL,QAAQ,GACR,QAAQ,GACR,SAAS,CAAC;AAEd,MAAM,MAAM,WAAW,GACnB,cAAc,GACd,iBAAiB,GACjB,SAAS,GACT,aAAa,GACb,YAAY,GACZ,SAAS,GACT,WAAW,GACX,2BAA2B,GAC3B,eAAe,GACf,eAAe,GACf,kBAAkB,GAClB,WAAW,GACX,mBAAmB,GACnB,wBAAwB,GACxB,WAAW,GACX,uBAAuB,GACvB,uBAAuB,GACvB,aAAa,GACb,aAAa,GACb,aAAa,GACb,SAAS,GACT,qBAAqB,GACrB,mBAAmB,GACnB,cAAc,GACd,YAAY,GACZ,cAAc,GACd,kBAAkB,GAClB,YAAY,GACZ,iBAAiB,GACjB,cAAc,GACd,cAAc,GACd,QAAQ,GACR,eAAe,GACf,UAAU,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"exercises.d.ts","sourceRoot":"","sources":["../../src/exercises/exercises.ts"],"names":[],"mappings":"AAwKA,eAAO,MAAM,SAAS,iCAqPrB,CAAC"}
1
+ {"version":3,"file":"exercises.d.ts","sourceRoot":"","sources":["../../src/exercises/exercises.ts"],"names":[],"mappings":"AA2KA,eAAO,MAAM,SAAS,iCAwPrB,CAAC"}
@@ -159,6 +159,8 @@ const firstDegreeInequationsType2_1 = require("./calculLitteral/inequations/firs
159
159
  const firstDegreeInequationsType3_1 = require("./calculLitteral/inequations/firstDegreeInequationsType3");
160
160
  const firstDegreeInequationsType0_1 = require("./calculLitteral/inequations/firstDegreeInequationsType0");
161
161
  const chasles_1 = require("./geometry/vectors/chasles");
162
+ const rootsFromFactorizedForm_1 = require("./functions/trinoms/rootsFromFactorizedForm");
163
+ const rootsFromDevForm_1 = require("./functions/trinoms/rootsFromDevForm");
162
164
  exports.exercises = [
163
165
  /**
164
166
  * calcul litteral
@@ -373,6 +375,9 @@ exports.exercises = [
373
375
  extremumFromCanonicalForm_1.extremumFromCanonicalForm,
374
376
  extremumTypeFromAlgebricForm_1.extremumTypeFromAlgebricForm,
375
377
  variationsFromAlgebricForm_1.variationsFromAlgebricForm,
378
+ // deltaTrinom,
379
+ rootsFromFactorizedForm_1.rootsFromFactorizedForm,
380
+ rootsFromDevForm_1.rootsFromDevForm,
376
381
  /**Complexes */
377
382
  mutiplyComplex_1.mutiplyComplex,
378
383
  reAndIm_1.reAndIm,
@@ -0,0 +1,4 @@
1
+ import { Exercise, Question } from '../../../exercises/exercise';
2
+ export declare const deltaTrinom: Exercise;
3
+ export declare function getDeltaTrinomQuestion(): Question;
4
+ //# sourceMappingURL=deltaTrinom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deltaTrinom.d.ts","sourceRoot":"","sources":["../../../../src/exercises/functions/trinoms/deltaTrinom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAO3E,eAAO,MAAM,WAAW,EAAE,QASzB,CAAC;AAEF,wBAAgB,sBAAsB,IAAI,QAAQ,CA4DjD"}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDeltaTrinomQuestion = exports.deltaTrinom = void 0;
4
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
5
+ const trinom_1 = require("../../../math/polynomials/trinom");
6
+ const randint_1 = require("../../../math/utils/random/randint");
7
+ const shuffle_1 = require("../../../utils/shuffle");
8
+ const uuid_1 = require("uuid");
9
+ exports.deltaTrinom = {
10
+ id: 'deltaTrinom',
11
+ connector: '=',
12
+ instruction: '',
13
+ label: "Calculer le discriminant d'un trinôme",
14
+ levels: ['1reSpé', 'TermSpé', 'MathComp'],
15
+ isSingleStep: true,
16
+ sections: ['Second degré'],
17
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getDeltaTrinomQuestion, nb),
18
+ };
19
+ function getDeltaTrinomQuestion() {
20
+ const trinom = trinom_1.TrinomConstructor.random();
21
+ const answer = trinom.getDelta();
22
+ const getPropositions = (n) => {
23
+ const res = [];
24
+ res.push({
25
+ id: (0, uuid_1.v4)(),
26
+ statement: answer + '',
27
+ isRightAnswer: true,
28
+ format: 'tex',
29
+ });
30
+ const bMinus4ac = trinom.b - 4 * trinom.a * trinom.c;
31
+ if (bMinus4ac !== answer)
32
+ res.push({
33
+ id: (0, uuid_1.v4)(),
34
+ statement: bMinus4ac + '',
35
+ isRightAnswer: false,
36
+ format: 'tex',
37
+ });
38
+ const bSquarePlus4ac = trinom.b ** 2 + trinom.a * trinom.c;
39
+ if (bSquarePlus4ac !== answer && bSquarePlus4ac !== bMinus4ac)
40
+ res.push({
41
+ id: (0, uuid_1.v4)(),
42
+ statement: bSquarePlus4ac + '',
43
+ isRightAnswer: false,
44
+ format: 'tex',
45
+ });
46
+ const missing = n - res.length;
47
+ for (let i = 0; i < missing; i++) {
48
+ let isDuplicate;
49
+ let proposition;
50
+ do {
51
+ const wrongAnswer = (0, randint_1.randint)(-100, 100) + '';
52
+ proposition = {
53
+ id: (0, uuid_1.v4)() + ``,
54
+ statement: wrongAnswer,
55
+ isRightAnswer: false,
56
+ format: 'tex',
57
+ };
58
+ isDuplicate = res.some((p) => p.statement === proposition.statement);
59
+ } while (isDuplicate);
60
+ res.push(proposition);
61
+ }
62
+ return (0, shuffle_1.shuffle)(res);
63
+ };
64
+ const question = {
65
+ answer: answer + '',
66
+ instruction: `Soit $f(x) = ${trinom.toTree().toTex()}$. Calculer le discriminant $\\Delta$.`,
67
+ keys: [],
68
+ getPropositions,
69
+ answerFormat: 'tex',
70
+ };
71
+ return question;
72
+ }
73
+ exports.getDeltaTrinomQuestion = getDeltaTrinomQuestion;
@@ -1 +1 @@
1
- {"version":3,"file":"extremumTypeFromAlgebricForm.d.ts","sourceRoot":"","sources":["../../../../src/exercises/functions/trinoms/extremumTypeFromAlgebricForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAO3E,eAAO,MAAM,4BAA4B,EAAE,QAQ1C,CAAC;AAEF,wBAAgB,uCAAuC,IAAI,QAAQ,CA6ClE"}
1
+ {"version":3,"file":"extremumTypeFromAlgebricForm.d.ts","sourceRoot":"","sources":["../../../../src/exercises/functions/trinoms/extremumTypeFromAlgebricForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAO3E,eAAO,MAAM,4BAA4B,EAAE,QAS1C,CAAC;AAEF,wBAAgB,uCAAuC,IAAI,QAAQ,CA6ClE"}
@@ -14,6 +14,7 @@ exports.extremumTypeFromAlgebricForm = {
14
14
  isSingleStep: true,
15
15
  sections: ['Second degré'],
16
16
  generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getExtremumTypeFromAlgebricFormQuestion, nb),
17
+ answerType: 'QCM',
17
18
  };
18
19
  function getExtremumTypeFromAlgebricFormQuestion() {
19
20
  const isDevForm = (0, coinFlip_1.coinFlip)();
@@ -0,0 +1,4 @@
1
+ import { Exercise, Question } from '../../../exercises/exercise';
2
+ export declare const rootsFromDevForm: Exercise;
3
+ export declare function getRootsFromDevFormQuestion(): Question;
4
+ //# sourceMappingURL=rootsFromDevForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rootsFromDevForm.d.ts","sourceRoot":"","sources":["../../../../src/exercises/functions/trinoms/rootsFromDevForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAM3E,eAAO,MAAM,gBAAgB,EAAE,QAS9B,CAAC;AAEF,wBAAgB,2BAA2B,IAAI,QAAQ,CA6CtD"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRootsFromDevFormQuestion = exports.rootsFromDevForm = void 0;
4
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
5
+ const trinom_1 = require("../../../math/polynomials/trinom");
6
+ const shuffle_1 = require("../../../utils/shuffle");
7
+ const uuid_1 = require("uuid");
8
+ exports.rootsFromDevForm = {
9
+ id: 'rootsFromDevForm',
10
+ connector: '\\iff',
11
+ instruction: '',
12
+ label: 'Résoudre une équation du second degré',
13
+ levels: ['1reSpé', 'TermSpé', 'MathComp'],
14
+ isSingleStep: true,
15
+ sections: [],
16
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getRootsFromDevFormQuestion, nb),
17
+ };
18
+ function getRootsFromDevFormQuestion() {
19
+ const trinom = trinom_1.TrinomConstructor.random();
20
+ const answer = trinom.getRootsEquationSolutionTex();
21
+ const getPropositions = (n) => {
22
+ const res = [];
23
+ res.push({
24
+ id: (0, uuid_1.v4)(),
25
+ statement: answer,
26
+ isRightAnswer: true,
27
+ format: 'tex',
28
+ });
29
+ const missing = n - res.length;
30
+ for (let i = 0; i < missing; i++) {
31
+ let isDuplicate;
32
+ let proposition;
33
+ do {
34
+ const wrongAnswer = '';
35
+ proposition = {
36
+ id: (0, uuid_1.v4)() + ``,
37
+ statement: wrongAnswer,
38
+ isRightAnswer: false,
39
+ format: 'tex',
40
+ };
41
+ isDuplicate = res.some((p) => p.statement === proposition.statement);
42
+ } while (isDuplicate);
43
+ res.push(proposition);
44
+ }
45
+ return (0, shuffle_1.shuffle)(res);
46
+ };
47
+ const question = {
48
+ answer: answer,
49
+ instruction: `Soit $f(x) = ${trinom.toTree().toTex()}$. Résoudre l'équation $f(x) = 0$.`,
50
+ keys: [],
51
+ getPropositions,
52
+ answerFormat: 'tex',
53
+ };
54
+ return question;
55
+ }
56
+ exports.getRootsFromDevFormQuestion = getRootsFromDevFormQuestion;
@@ -0,0 +1,4 @@
1
+ import { Exercise, Question } from '../../../exercises/exercise';
2
+ export declare const rootsFromFactorizedForm: Exercise;
3
+ export declare function getRootsFromFactorizedFormQuestion(): Question;
4
+ //# sourceMappingURL=rootsFromFactorizedForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rootsFromFactorizedForm.d.ts","sourceRoot":"","sources":["../../../../src/exercises/functions/trinoms/rootsFromFactorizedForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAS3E,eAAO,MAAM,uBAAuB,EAAE,QASrC,CAAC;AAEF,wBAAgB,kCAAkC,IAAI,QAAQ,CAiF7D"}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRootsFromFactorizedFormQuestion = exports.rootsFromFactorizedForm = void 0;
4
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
5
+ const trinom_1 = require("../../../math/polynomials/trinom");
6
+ const randint_1 = require("../../../math/utils/random/randint");
7
+ const oppositeNode_1 = require("../../../tree/nodes/functions/oppositeNode");
8
+ const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
9
+ const shuffle_1 = require("../../../utils/shuffle");
10
+ const uuid_1 = require("uuid");
11
+ exports.rootsFromFactorizedForm = {
12
+ id: 'rootsFromFactorizedForm',
13
+ connector: '=',
14
+ instruction: '',
15
+ label: "Déterminer les racines d'un trinôme à partir de sa forme factorisée",
16
+ levels: ['1reSpé', 'TermSpé', 'MathComp'],
17
+ isSingleStep: true,
18
+ sections: ['Second degré'],
19
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getRootsFromFactorizedFormQuestion, nb),
20
+ };
21
+ function getRootsFromFactorizedFormQuestion() {
22
+ const trinom = trinom_1.TrinomConstructor.randomFactorized();
23
+ const answer = trinom.getRootsEquationSolutionTex();
24
+ const roots = trinom.getRoots();
25
+ const getPropositions = (n) => {
26
+ const res = [];
27
+ res.push({
28
+ id: (0, uuid_1.v4)(),
29
+ statement: answer,
30
+ isRightAnswer: true,
31
+ format: 'tex',
32
+ });
33
+ if (roots.length === 1 && roots[0] !== 0) {
34
+ res.push({
35
+ id: (0, uuid_1.v4)(),
36
+ statement: `S = \\lbrace ${new oppositeNode_1.OppositeNode(new numberNode_1.NumberNode(roots[0]))} \\rbrace`,
37
+ isRightAnswer: false,
38
+ format: 'tex',
39
+ });
40
+ }
41
+ if (roots.length === 2 && roots[0] !== 0) {
42
+ res.push({
43
+ id: (0, uuid_1.v4)(),
44
+ statement: `S = \\lbrace ${new oppositeNode_1.OppositeNode(new numberNode_1.NumberNode(roots[0])).toTex()} ; ${roots[1]} \\rbrace`,
45
+ isRightAnswer: false,
46
+ format: 'tex',
47
+ });
48
+ }
49
+ if (roots.length === 2 && roots[1] !== 0) {
50
+ res.push({
51
+ id: (0, uuid_1.v4)(),
52
+ statement: `S = \\lbrace ${roots[0]} ; ${new oppositeNode_1.OppositeNode(new numberNode_1.NumberNode(roots[1])).toTex()} \\rbrace`,
53
+ isRightAnswer: false,
54
+ format: 'tex',
55
+ });
56
+ }
57
+ if (roots.length === 2 && roots[0] !== 0 && roots[1] !== 0) {
58
+ res.push({
59
+ id: (0, uuid_1.v4)(),
60
+ statement: `S = \\lbrace ${new oppositeNode_1.OppositeNode(new numberNode_1.NumberNode(roots[0])).toTex()} ; ${new oppositeNode_1.OppositeNode(new numberNode_1.NumberNode(roots[1])).toTex()} \\rbrace`,
61
+ isRightAnswer: false,
62
+ format: 'tex',
63
+ });
64
+ }
65
+ const missing = n - res.length;
66
+ for (let i = 0; i < missing; i++) {
67
+ let isDuplicate;
68
+ let proposition;
69
+ do {
70
+ const wrongAnswer = `S = \\lbrace ${(0, randint_1.randint)(-10, 11)}; ${(0, randint_1.randint)(-10, 11)} \\rbrace`;
71
+ proposition = {
72
+ id: (0, uuid_1.v4)() + ``,
73
+ statement: wrongAnswer,
74
+ isRightAnswer: false,
75
+ format: 'tex',
76
+ };
77
+ isDuplicate = res.some((p) => p.statement === proposition.statement);
78
+ } while (isDuplicate);
79
+ res.push(proposition);
80
+ }
81
+ return (0, shuffle_1.shuffle)(res);
82
+ };
83
+ const question = {
84
+ answer: answer,
85
+ instruction: `Soit $f(x) = ${trinom.getFactorizedForm().toTex()}$. Résoudre l'équation $f(x) = 0$.`,
86
+ keys: ['S', 'equal', 'lbrace', 'semicolon', 'rbrace', 'emptyset'],
87
+ getPropositions,
88
+ answerFormat: 'tex',
89
+ };
90
+ return question;
91
+ }
92
+ exports.getRootsFromFactorizedFormQuestion = getRootsFromFactorizedFormQuestion;
@@ -5,6 +5,7 @@ import { Polynomial } from './polynomial';
5
5
  export declare abstract class TrinomConstructor {
6
6
  static random(domainA?: MathSet, domainB?: MathSet, domainC?: MathSet): Trinom;
7
7
  static randomCanonical(domainA?: MathSet, domainAlpha?: MathSet, domainBeta?: MathSet): Trinom;
8
+ static randomFactorized(domainA?: MathSet, domainX1?: MathSet, domainX2?: MathSet): Trinom;
8
9
  }
9
10
  export declare class Trinom extends Polynomial {
10
11
  a: number;
@@ -14,10 +15,14 @@ export declare class Trinom extends Polynomial {
14
15
  constructor(a: number, b: number, c: number, variable?: string);
15
16
  getDelta(): number;
16
17
  getDeltaNode(): NumberNode;
18
+ getRoots(): number[];
19
+ getRootsNode(): Node[];
20
+ getRootsEquationSolutionTex(): string;
17
21
  getAlpha(): number;
18
22
  getAlphaNode(): Node;
19
23
  getBeta(): number;
20
24
  getBetaNode(): Node;
25
+ getFactorizedForm(): Node;
21
26
  getCanonicalForm(): Node;
22
27
  getSommet(): string;
23
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"trinom.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/trinom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAajE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,8BAAsB,iBAAiB;IACrC,MAAM,CAAC,MAAM,CACX,OAAO,GAAE,OAAmF,EAC5F,OAAO,GAAE,OAAqC,EAC9C,OAAO,GAAE,OAAqC,GAC7C,MAAM;IAOT,MAAM,CAAC,eAAe,CACpB,OAAO,GAAE,OAAmF,EAC5F,WAAW,GAAE,OAAqC,EAClD,UAAU,GAAE,OAAqC,GAChD,MAAM;CAQV;AAED,qBAAa,MAAO,SAAQ,UAAU;IACpC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;gBACL,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IAQnE,QAAQ;IAGR,YAAY,IAAI,UAAU;IAI1B,QAAQ;IAGR,YAAY,IAAI,IAAI;IAIpB,OAAO;IAIP,WAAW,IAAI,IAAI;IAInB,gBAAgB,IAAI,IAAI;IAYxB,SAAS;CAGV"}
1
+ {"version":3,"file":"trinom.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/trinom.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAejE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,8BAAsB,iBAAiB;IACrC,MAAM,CAAC,MAAM,CACX,OAAO,GAAE,OAAmF,EAC5F,OAAO,GAAE,OAAqC,EAC9C,OAAO,GAAE,OAAqC,GAC7C,MAAM;IAOT,MAAM,CAAC,eAAe,CACpB,OAAO,GAAE,OAAmF,EAC5F,WAAW,GAAE,OAAqC,EAClD,UAAU,GAAE,OAAqC,GAChD,MAAM;IAQT,MAAM,CAAC,gBAAgB,CACrB,OAAO,GAAE,OAAmF,EAC5F,QAAQ,GAAE,OAAqC,EAC/C,QAAQ,GAAE,OAAqC,GAC9C,MAAM;CAOV;AAED,qBAAa,MAAO,SAAQ,UAAU;IACpC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;gBACL,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IAQnE,QAAQ;IAGR,YAAY,IAAI,UAAU;IAI1B,QAAQ;IAQR,YAAY,IAAI,IAAI,EAAE;IAoBtB,2BAA2B;IAO3B,QAAQ;IAGR,YAAY,IAAI,IAAI;IAIpB,OAAO;IAIP,WAAW,IAAI,IAAI;IAInB,iBAAiB,IAAI,IAAI;IAqBzB,gBAAgB,IAAI,IAAI;IAYxB,SAAS;CAGV"}
@@ -11,6 +11,8 @@ const variableNode_1 = require("../../tree/nodes/variables/variableNode");
11
11
  const simplify_1 = require("../../tree/parsers/simplify");
12
12
  const point_1 = require("../geometry/point");
13
13
  const integer_1 = require("../numbers/integer/integer");
14
+ const rational_1 = require("../numbers/rationals/rational");
15
+ const squareRoot_1 = require("../numbers/reals/squareRoot");
14
16
  const discreteSet_1 = require("../sets/discreteSet");
15
17
  const intervals_1 = require("../sets/intervals/intervals");
16
18
  const polynomial_1 = require("./polynomial");
@@ -29,6 +31,13 @@ class TrinomConstructor {
29
31
  const c = a.value * alpha.value ** 2 + beta.value;
30
32
  return new Trinom(a.value, b, c);
31
33
  }
34
+ static randomFactorized(domainA = new intervals_1.Interval('[[-10; 10]]').difference(new discreteSet_1.DiscreteSet([new integer_1.Integer(0)])), domainX1 = new intervals_1.Interval('[[-10; 10]]'), domainX2 = new intervals_1.Interval('[[-10; 10]]')) {
35
+ const a = domainA.getRandomElement();
36
+ const x1 = domainX1.getRandomElement();
37
+ const x2 = domainX2.getRandomElement();
38
+ //a*x^2 + ax*-x2 + a*-x1*x + a*-x1*-x2
39
+ return new Trinom(a.value, -a.value * (x1.value + x2.value), a.value * x1.value * x2.value);
40
+ }
32
41
  }
33
42
  exports.TrinomConstructor = TrinomConstructor;
34
43
  class Trinom extends polynomial_1.Polynomial {
@@ -45,6 +54,34 @@ class Trinom extends polynomial_1.Polynomial {
45
54
  getDeltaNode() {
46
55
  return new numberNode_1.NumberNode(this.getDelta());
47
56
  }
57
+ getRoots() {
58
+ const delta = this.getDelta();
59
+ if (delta < 0)
60
+ return [];
61
+ if (delta === 0)
62
+ return [-this.b / (2 * this.a)];
63
+ return [(-this.b - Math.sqrt(delta)) / (2 * this.a), (-this.b + Math.sqrt(delta)) / (2 * this.a)];
64
+ }
65
+ //! la simplification de mathjs est foireuse, exemple (4+4sqrt(3))/16 est simplifiée mais pas (4-4sqrt(3))/16 ??
66
+ getRootsNode() {
67
+ const delta = this.getDelta();
68
+ if (delta < 0)
69
+ return [];
70
+ if (delta === 0)
71
+ return [new rational_1.Rational(-this.b, 2 * this.a).simplify().toTree()];
72
+ return [
73
+ (0, simplify_1.simplifyNode)(new fractionNode_1.FractionNode(new substractNode_1.SubstractNode(new numberNode_1.NumberNode(-this.b), new squareRoot_1.SquareRoot(delta).simplify().toTree()), new numberNode_1.NumberNode(2 * this.a))),
74
+ (0, simplify_1.simplifyNode)(new fractionNode_1.FractionNode(new addNode_1.AddNode(new numberNode_1.NumberNode(-this.b), new squareRoot_1.SquareRoot(delta).simplify().toTree()), new numberNode_1.NumberNode(2 * this.a))),
75
+ ];
76
+ }
77
+ getRootsEquationSolutionTex() {
78
+ const roots = this.getRootsNode();
79
+ if (!roots.length)
80
+ return `S = \\emptyset`;
81
+ if (roots.length === 1)
82
+ return `S = \\left\\lbrace ${roots[0].toTex()} \\right\\rbrace`;
83
+ return `S = \\left\\lbrace ${roots[0].toTex()} ; ${roots[1].toTex()} \\right\\rbrace`;
84
+ }
48
85
  getAlpha() {
49
86
  return -this.b / (2 * this.a);
50
87
  }
@@ -57,6 +94,14 @@ class Trinom extends polynomial_1.Polynomial {
57
94
  getBetaNode() {
58
95
  return (0, simplify_1.simplifyNode)(new fractionNode_1.FractionNode(new numberNode_1.NumberNode(-this.getDelta()), new numberNode_1.NumberNode(4 * this.a)));
59
96
  }
97
+ getFactorizedForm() {
98
+ const roots = this.getRootsNode();
99
+ if (!roots.length)
100
+ return this.toTree();
101
+ if (roots.length === 1)
102
+ return (0, simplify_1.simplifyNode)(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(this.a), new powerNode_1.PowerNode(new substractNode_1.SubstractNode(new variableNode_1.VariableNode('x'), roots[0]), new numberNode_1.NumberNode(2))));
103
+ return (0, simplify_1.simplifyNode)(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(this.a), new multiplyNode_1.MultiplyNode(new substractNode_1.SubstractNode(new variableNode_1.VariableNode('x'), roots[0]), new substractNode_1.SubstractNode(new variableNode_1.VariableNode('x'), roots[1]))));
104
+ }
60
105
  getCanonicalForm() {
61
106
  return (0, simplify_1.simplifyNode)(new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(this.a), new powerNode_1.PowerNode(new substractNode_1.SubstractNode(new variableNode_1.VariableNode(this.variable), this.getAlphaNode()), new numberNode_1.NumberNode(2))), new numberNode_1.NumberNode(this.getBeta())));
62
107
  }
@@ -1 +1 @@
1
- {"version":3,"file":"oppositeNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/oppositeNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAY,MAAM,SAAS,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAgB,MAAM,gBAAgB,CAAC;AAE5D,qBAAa,YAAa,SAAQ,YAAa,YAAW,IAAI;gBAChD,KAAK,EAAE,IAAI;IAGvB,YAAY,IAAI,MAAM;IAGtB,KAAK,IAAI,MAAM;IAWf,QAAQ;CAGT"}
1
+ {"version":3,"file":"oppositeNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/oppositeNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAY,MAAM,SAAS,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAgB,MAAM,gBAAgB,CAAC;AAG5D,qBAAa,YAAa,SAAQ,YAAa,YAAW,IAAI;gBAChD,KAAK,EAAE,IAAI;IAGvB,YAAY,IAAI,MAAM;IAGtB,KAAK,IAAI,MAAM;IAcf,QAAQ;CAGT"}
@@ -19,6 +19,9 @@ class OppositeNode extends functionNode_1.FunctionNode {
19
19
  const operatorChild = this.child;
20
20
  needBrackets || (needBrackets = [operatorNode_1.OperatorIds.add, operatorNode_1.OperatorIds.substract].includes(operatorChild.id));
21
21
  }
22
+ if (this.child.type === node_1.NodeType.number && childTex[0] === '-') {
23
+ return childTex.substring(1);
24
+ }
22
25
  if (needBrackets)
23
26
  childTex = `(${childTex})`;
24
27
  return `-${childTex}`;
@@ -10,7 +10,7 @@ class SqrtNode extends functionNode_1.FunctionNode {
10
10
  this.type = node_1.NodeType.function;
11
11
  }
12
12
  toMathString() {
13
- return `sqrt(${this.child.toMathString()})`;
13
+ return `sqr(${this.child.toMathString()})`;
14
14
  }
15
15
  toMathjs() {
16
16
  return (0, mathjs_1.sqrt)(this.child.toMathjs());
@@ -56,6 +56,9 @@ const mathjsNodeToNode = (mathjsNode) => {
56
56
  else if (mathjsNode.isFunctionNode) {
57
57
  const fn = mathjsNode.fn;
58
58
  switch (fn.name) {
59
+ //mathjs arrondit les racines carrées, on truc avec sqr pour bypass
60
+ case 'sqr':
61
+ return new sqrtNode_1.SqrtNode(mathjsNodeToNode(mathjsNode.args[0]));
59
62
  case 'sqrt':
60
63
  return new sqrtNode_1.SqrtNode(mathjsNodeToNode(mathjsNode.args[0]));
61
64
  case 'log':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "math-exercises",
3
- "version": "1.3.58",
3
+ "version": "1.3.59",
4
4
  "description": "Math exercises generator for middle school and high school",
5
5
  "main": "lib/index.js",
6
6
  "files": [