math-exercises 1.3.20 → 1.3.21
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/calculLitteral/equation/equationSimpleSquare.js +1 -1
- package/lib/exercises/calculLitteral/equation/equationType1Exercise.js +1 -1
- package/lib/exercises/calculLitteral/equation/equationType2Exercise.js +1 -1
- package/lib/exercises/calculLitteral/equation/equationType3Exercise.js +1 -1
- package/lib/exercises/calculLitteral/equation/equationType4Exercise.js +1 -1
- package/lib/exercises/calculLitteral/equation/firstDegreeEquation.d.ts +1 -1
- package/lib/exercises/calculLitteral/equation/firstDegreeEquation.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/equation/firstDegreeEquation.js +2 -1
- package/lib/exercises/derivation/derivative/thirdDegreeDerivative.d.ts +1 -1
- package/lib/exercises/derivation/derivative/thirdDegreeDerivative.d.ts.map +1 -1
- package/lib/exercises/derivation/derivative/thirdDegreeDerivative.js +2 -2
- package/lib/exercises/derivation/derivative/usualderivative.d.ts +1 -1
- package/lib/exercises/derivation/derivative/usualderivative.d.ts.map +1 -1
- package/lib/exercises/derivation/derivative/usualderivative.js +2 -2
- package/lib/exercises/exercises.d.ts.map +1 -1
- package/lib/exercises/exercises.js +18 -14
- package/lib/exercises/geometry/cartesian/derivativeNumberReading.d.ts +4 -0
- package/lib/exercises/geometry/cartesian/derivativeNumberReading.d.ts.map +1 -0
- package/lib/exercises/geometry/cartesian/derivativeNumberReading.js +60 -0
- package/lib/exercises/geometry/cartesian/derivativeNumberReading2.d.ts +1 -0
- package/lib/exercises/geometry/cartesian/derivativeNumberReading2.d.ts.map +1 -0
- package/lib/exercises/geometry/cartesian/derivativeNumberReading2.js +91 -0
- package/lib/exercises/geometry/cartesian/leadingCoefficient.d.ts +4 -0
- package/lib/exercises/geometry/cartesian/leadingCoefficient.d.ts.map +1 -0
- package/lib/exercises/geometry/cartesian/leadingCoefficient.js +38 -0
- package/lib/math/geometry/droite.d.ts +20 -0
- package/lib/math/geometry/droite.d.ts.map +1 -0
- package/lib/math/geometry/droite.js +61 -0
- package/lib/server.js +20 -0
- package/package.json +2 -1
|
@@ -9,7 +9,7 @@ exports.equationSimpleSquare = {
|
|
|
9
9
|
instruction: '',
|
|
10
10
|
label: 'Résoudre une équation du second degré du type x² = a',
|
|
11
11
|
levels: ['2', '1'],
|
|
12
|
-
section: '
|
|
12
|
+
section: 'Équations',
|
|
13
13
|
isSingleStep: false,
|
|
14
14
|
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getEquationSimpleSquare, nb),
|
|
15
15
|
};
|
|
@@ -16,7 +16,7 @@ exports.equationType1Exercise = {
|
|
|
16
16
|
instruction: 'Résoudre : ',
|
|
17
17
|
label: 'Equations $x+a = b$',
|
|
18
18
|
levels: ['4', '3', '2'],
|
|
19
|
-
section: '
|
|
19
|
+
section: 'Équations',
|
|
20
20
|
isSingleStep: true,
|
|
21
21
|
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getEquationType1ExerciseQuestion, nb),
|
|
22
22
|
};
|
|
@@ -18,7 +18,7 @@ exports.equationType2Exercise = {
|
|
|
18
18
|
instruction: 'Résoudre : ',
|
|
19
19
|
label: 'Equations $ax=b$',
|
|
20
20
|
levels: ['4', '3', '2'],
|
|
21
|
-
section: '
|
|
21
|
+
section: 'Équations',
|
|
22
22
|
isSingleStep: true,
|
|
23
23
|
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getEquationType2ExerciseQuestion, nb),
|
|
24
24
|
};
|
|
@@ -18,7 +18,7 @@ exports.equationType3Exercise = {
|
|
|
18
18
|
instruction: 'Résoudre : ',
|
|
19
19
|
label: 'Equations $ax+b=c$',
|
|
20
20
|
levels: ['4', '3', '2'],
|
|
21
|
-
section: '
|
|
21
|
+
section: 'Équations',
|
|
22
22
|
isSingleStep: false,
|
|
23
23
|
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getEquationType3ExerciseQuestion, nb),
|
|
24
24
|
};
|
|
@@ -18,7 +18,7 @@ exports.equationType4Exercise = {
|
|
|
18
18
|
instruction: 'Résoudre : ',
|
|
19
19
|
label: 'Equations $ax+b=cx+d$',
|
|
20
20
|
levels: ['4', '3', '2'],
|
|
21
|
-
section: '
|
|
21
|
+
section: 'Équations',
|
|
22
22
|
isSingleStep: false,
|
|
23
23
|
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getEquationType4ExerciseQuestion, nb),
|
|
24
24
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Exercise, Question } from
|
|
1
|
+
import { Exercise, Question } from '../../../exercises/exercise';
|
|
2
2
|
export declare const firstDegreeEquation: Exercise;
|
|
3
3
|
export declare function getFirstDegreeEquation(): Question;
|
|
4
4
|
//# sourceMappingURL=firstDegreeEquation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firstDegreeEquation.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/equation/firstDegreeEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAK9D,eAAO,MAAM,mBAAmB,EAAE,QASjC,CAAC;
|
|
1
|
+
{"version":3,"file":"firstDegreeEquation.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/equation/firstDegreeEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAK9D,eAAO,MAAM,mBAAmB,EAAE,QASjC,CAAC;AAOF,wBAAgB,sBAAsB,IAAI,QAAQ,CAiBjD"}
|
|
@@ -10,10 +10,11 @@ exports.firstDegreeEquation = {
|
|
|
10
10
|
instruction: '',
|
|
11
11
|
label: 'Résoudre une équation du premier degré du type $\\frac{a}{x} = b$',
|
|
12
12
|
levels: ['2', '1'],
|
|
13
|
-
section: '
|
|
13
|
+
section: 'Équations',
|
|
14
14
|
isSingleStep: false,
|
|
15
15
|
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getFirstDegreeEquation, nb),
|
|
16
16
|
};
|
|
17
|
+
2;
|
|
17
18
|
const pgcd = (a, b) => {
|
|
18
19
|
if (b === 0)
|
|
19
20
|
return a;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Exercise, Question } from
|
|
1
|
+
import { Exercise, Question } from '../../../exercises/exercise';
|
|
2
2
|
export declare const thirdDegreeDerivative: Exercise;
|
|
3
3
|
export declare function getThirdDegreeDerivative(): Question;
|
|
4
4
|
//# sourceMappingURL=thirdDegreeDerivative.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thirdDegreeDerivative.d.ts","sourceRoot":"","sources":["../../../../src/exercises/derivation/derivative/thirdDegreeDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAK9D,eAAO,MAAM,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"thirdDegreeDerivative.d.ts","sourceRoot":"","sources":["../../../../src/exercises/derivation/derivative/thirdDegreeDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAK9D,eAAO,MAAM,qBAAqB,EAAE,QASnC,CAAC;AAEF,wBAAgB,wBAAwB,IAAI,QAAQ,CAgBnD"}
|
|
@@ -9,8 +9,8 @@ exports.thirdDegreeDerivative = {
|
|
|
9
9
|
connector: '=',
|
|
10
10
|
instruction: '',
|
|
11
11
|
label: "Dérivée d'un polynôme de degré 3",
|
|
12
|
-
levels: ['
|
|
13
|
-
section: '
|
|
12
|
+
levels: ['1', '0'],
|
|
13
|
+
section: 'Dérivation',
|
|
14
14
|
isSingleStep: false,
|
|
15
15
|
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getThirdDegreeDerivative, nb),
|
|
16
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usualderivative.d.ts","sourceRoot":"","sources":["../../../../src/exercises/derivation/derivative/usualderivative.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAGpD,eAAO,MAAM,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"usualderivative.d.ts","sourceRoot":"","sources":["../../../../src/exercises/derivation/derivative/usualderivative.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAGpD,eAAO,MAAM,eAAe,EAAE,QAS7B,CAAC;AAEF,wBAAgB,kBAAkB,IAAI,QAAQ,CAgD7C"}
|
|
@@ -10,8 +10,8 @@ exports.usualDerivative = {
|
|
|
10
10
|
connector: '=',
|
|
11
11
|
instruction: '',
|
|
12
12
|
label: 'Dérivées usuelles',
|
|
13
|
-
levels: ['
|
|
14
|
-
section: '
|
|
13
|
+
levels: ['1', '0'],
|
|
14
|
+
section: 'Dérivation',
|
|
15
15
|
isSingleStep: false,
|
|
16
16
|
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getUsualDerivative, nb),
|
|
17
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exercises.d.ts","sourceRoot":"","sources":["../../src/exercises/exercises.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"exercises.d.ts","sourceRoot":"","sources":["../../src/exercises/exercises.ts"],"names":[],"mappings":"AAkEA,eAAO,MAAM,SAAS,iCA6GrB,CAAC"}
|
|
@@ -25,7 +25,6 @@ const equationType2Exercise_1 = require("./calculLitteral/equation/equationType2
|
|
|
25
25
|
const equationType3Exercise_1 = require("./calculLitteral/equation/equationType3Exercise");
|
|
26
26
|
const equationType4Exercise_1 = require("./calculLitteral/equation/equationType4Exercise");
|
|
27
27
|
const firstDegreeEquation_1 = require("./calculLitteral/equation/firstDegreeEquation");
|
|
28
|
-
const firstDegreeGeneralEquation_1 = require("./calculLitteral/equation/firstDegreeGeneralEquation");
|
|
29
28
|
const factoIdRmq1_1 = require("./calculLitteral/factorisation/factoIdRmq1");
|
|
30
29
|
const factoIdRmq2_1 = require("./calculLitteral/factorisation/factoIdRmq2");
|
|
31
30
|
const factoIdRmq3_1 = require("./calculLitteral/factorisation/factoIdRmq3");
|
|
@@ -70,10 +69,15 @@ exports.exercises = [
|
|
|
70
69
|
secondIdentity_1.secondIdentity,
|
|
71
70
|
thirdIdentity_1.thirdIdentity,
|
|
72
71
|
allIdentities_1.allIdentities,
|
|
72
|
+
/**
|
|
73
|
+
* equations
|
|
74
|
+
*/
|
|
73
75
|
equationType1Exercise_1.equationType1Exercise,
|
|
74
76
|
equationType2Exercise_1.equationType2Exercise,
|
|
75
77
|
equationType3Exercise_1.equationType3Exercise,
|
|
76
78
|
equationType4Exercise_1.equationType4Exercise,
|
|
79
|
+
firstDegreeEquation_1.firstDegreeEquation,
|
|
80
|
+
equationSimpleSquare_1.equationSimpleSquare,
|
|
77
81
|
/**
|
|
78
82
|
* square roots
|
|
79
83
|
*/
|
|
@@ -91,8 +95,10 @@ exports.exercises = [
|
|
|
91
95
|
/**
|
|
92
96
|
* calcul
|
|
93
97
|
*/
|
|
94
|
-
operationsPriorities_1.operationsPriorities,
|
|
95
98
|
addAndSub_1.addAndSubExercise,
|
|
99
|
+
addAndSubWithoutRelatives_1.addAndSubWithoutRelatives,
|
|
100
|
+
operationsPriorities_1.operationsPriorities,
|
|
101
|
+
operationsPrioritiesWithoutRelative_1.operationsPrioritiesWithoutRelative,
|
|
96
102
|
/**
|
|
97
103
|
* rounding
|
|
98
104
|
*/
|
|
@@ -128,25 +134,23 @@ exports.exercises = [
|
|
|
128
134
|
geometricFindExplicitFormula_1.geometricFindExplicitFormula,
|
|
129
135
|
geometricReasonUsage_1.geometricReasonUsage,
|
|
130
136
|
geometricRecurrenceFormulaUsage_1.geometricRecurrenceFormulaUsage,
|
|
137
|
+
arithmeticExplicitFormulaUsage_1.arithmeticExplicitFormulaUsage,
|
|
138
|
+
arithmeticFindExplicitFormula_1.arithmeticFindExplicitFormula,
|
|
139
|
+
arithmeticFindReason_1.arithmeticFindReason,
|
|
140
|
+
arithmeticReasonUsage_1.arithmeticReasonUsage,
|
|
141
|
+
arithmeticRecurrenceFormulaUsage_1.arithmeticRecurrenceFormulaUsage,
|
|
142
|
+
arithmeticThresholdFind_1.arithmeticThresholdFind,
|
|
131
143
|
/**
|
|
132
144
|
* islam
|
|
133
145
|
*/
|
|
134
146
|
applyPercent_1.applyPercent,
|
|
135
147
|
globalPercent_1.globalPercent,
|
|
136
148
|
reciprocalPercentage_1.reciprocalPercentage,
|
|
137
|
-
|
|
149
|
+
averageEvolutionRate_1.averageEvolutionRate,
|
|
138
150
|
usualderivative_1.usualDerivative,
|
|
139
151
|
thirdDegreeDerivative_1.thirdDegreeDerivative,
|
|
140
|
-
averageEvolutionRate_1.averageEvolutionRate,
|
|
141
|
-
firstDegreeEquation_1.firstDegreeEquation,
|
|
142
|
-
firstDegreeGeneralEquation_1.firstDegreeGeneralEquation,
|
|
143
152
|
conditionalProbability_1.conditionalProbability,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
arithmeticReasonUsage_1.arithmeticReasonUsage,
|
|
148
|
-
arithmeticRecurrenceFormulaUsage_1.arithmeticRecurrenceFormulaUsage,
|
|
149
|
-
arithmeticThresholdFind_1.arithmeticThresholdFind,
|
|
150
|
-
addAndSubWithoutRelatives_1.addAndSubWithoutRelatives,
|
|
151
|
-
operationsPrioritiesWithoutRelative_1.operationsPrioritiesWithoutRelative,
|
|
153
|
+
// leadingCoefficient,
|
|
154
|
+
// derivativeNumberReading,
|
|
155
|
+
//derivativeNumberReading2,
|
|
152
156
|
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derivativeNumberReading.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/cartesian/derivativeNumberReading.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAS9D,eAAO,MAAM,uBAAuB,EAAE,QASrC,CAAC;AAEF,wBAAgB,0BAA0B,IAAI,QAAQ,CA8CrD"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDerivativeNumberReading = exports.derivativeNumberReading = void 0;
|
|
4
|
+
const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
|
|
5
|
+
const droite_1 = require("../../../math/geometry/droite");
|
|
6
|
+
const point_1 = require("../../../math/geometry/point");
|
|
7
|
+
const polynomial_1 = require("../../../math/polynomials/polynomial");
|
|
8
|
+
const randint_1 = require("../../../math/utils/random/randint");
|
|
9
|
+
const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
|
|
10
|
+
const mathjs_1 = require("mathjs");
|
|
11
|
+
exports.derivativeNumberReading = {
|
|
12
|
+
id: 'derivativeNumberReading',
|
|
13
|
+
connector: '=',
|
|
14
|
+
instruction: '',
|
|
15
|
+
label: 'Lecture de nombre dérivé',
|
|
16
|
+
levels: ['3', '2', '1'],
|
|
17
|
+
isSingleStep: false,
|
|
18
|
+
section: 'Géométrie cartésienne',
|
|
19
|
+
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getDerivativeNumberReading, nb),
|
|
20
|
+
};
|
|
21
|
+
function getDerivativeNumberReading() {
|
|
22
|
+
/*let xA = randint(-4, 5);
|
|
23
|
+
let polynome: Polynomial;
|
|
24
|
+
let yA: number;
|
|
25
|
+
|
|
26
|
+
do {
|
|
27
|
+
polynome = new Polynomial([randint(-4, 5), randint(-4, 5), randint(-4, 5), randint(-4, 5, [0])]);
|
|
28
|
+
yA = polynome.coefficients[0];
|
|
29
|
+
for (let index = 1; index < 4; index++) yA += polynome.coefficients[index] * Math.pow(xA, index);
|
|
30
|
+
} while (yA < -5 || yA > 5);
|
|
31
|
+
|
|
32
|
+
const pointA = new Point('A', new NumberNode(xA), new NumberNode(yA));
|
|
33
|
+
const slope = polynome.derivate().coefficients[2] * xA;
|
|
34
|
+
const droite = DroiteConstructor.fromPointAndSlope(pointA, new NumberNode(slope));
|
|
35
|
+
|
|
36
|
+
let instruction = `$f(x) = ${polynome}$, $${pointA.toTexWithCoords()}$, $f'(${xA}) = ${slope}$`;
|
|
37
|
+
*/
|
|
38
|
+
let xA, yA, xB, yB;
|
|
39
|
+
let pointA, pointB;
|
|
40
|
+
do {
|
|
41
|
+
[xA, yA] = [1, 2].map((el) => (0, randint_1.randint)(-5, 6));
|
|
42
|
+
xB = xA > 0 ? (0, randint_1.randint)(xA - 4, 6) : (0, randint_1.randint)(-4, xA + 5); // l'écart entre les deux points ne soit pas grand
|
|
43
|
+
yB = yA > 0 ? (0, randint_1.randint)(yA - 4, 6) : (0, randint_1.randint)(-4, yA + 5);
|
|
44
|
+
pointA = new point_1.Point('A', new numberNode_1.NumberNode(xA), new numberNode_1.NumberNode(yA));
|
|
45
|
+
pointB = new point_1.Point('B', new numberNode_1.NumberNode(xB), new numberNode_1.NumberNode(yB));
|
|
46
|
+
} while (xB - xA === 0);
|
|
47
|
+
const droite = droite_1.DroiteConstructor.fromTwoPoints(pointA, pointB, 'D');
|
|
48
|
+
const [a, b] = [(3 * (0, randint_1.randint)(-100, 100, [0])) / 100, (2 * (0, randint_1.randint)(-4, 5)) / 100];
|
|
49
|
+
const c = (0, mathjs_1.evaluate)(droite.a.toMathString()) - a * Math.pow(xA, 2) - b * xA;
|
|
50
|
+
const d = yA - (a / 3) * Math.pow(xA, 3) - (b / 2) * Math.pow(xA, 2) - xA * c;
|
|
51
|
+
const polynome = new polynomial_1.Polynomial([d, c, b / 2, a / 3]);
|
|
52
|
+
let instruction = `$f(x) = ${polynome.toTex()}$, $${pointA.toTexWithCoords()}$, $${pointB.toTexWithCoords()}$, $f'(${xA}) = ${droite.getLeadingCoefficient()}$`;
|
|
53
|
+
const question = {
|
|
54
|
+
instruction,
|
|
55
|
+
//startStatement: 'a',
|
|
56
|
+
answer: droite.getLeadingCoefficient(),
|
|
57
|
+
};
|
|
58
|
+
return question;
|
|
59
|
+
}
|
|
60
|
+
exports.getDerivativeNumberReading = getDerivativeNumberReading;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=derivativeNumberReading2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derivativeNumberReading2.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/cartesian/derivativeNumberReading2.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*import { Exercise, Question } from '../../../exercises/exercise';
|
|
3
|
+
import { getDistinctQuestions } from '../../../exercises/utils/getDistinctQuestions';
|
|
4
|
+
import { DroiteConstructor } from '../../../math/geometry/droite';
|
|
5
|
+
import { Point } from '../../../math/geometry/point';
|
|
6
|
+
import { Polynomial } from '../../../math/polynomials/polynomial';
|
|
7
|
+
import { randint } from '../../../math/utils/random/randint';
|
|
8
|
+
import { NumberNode } from '../../../tree/nodes/numbers/numberNode';
|
|
9
|
+
import { evaluate } from 'mathjs';
|
|
10
|
+
|
|
11
|
+
export const derivativeNumberReading2: Exercise = {
|
|
12
|
+
id: 'derivativeNumberReading2',
|
|
13
|
+
connector: '=',
|
|
14
|
+
instruction: '',
|
|
15
|
+
label: 'Lecture de nombre dérivé 2',
|
|
16
|
+
levels: ['3', '2', '1'],
|
|
17
|
+
isSingleStep: false,
|
|
18
|
+
section: 'Géométrie cartésienne',
|
|
19
|
+
generator: (nb: number) => getDistinctQuestions(getDerivativeNumberReading, nb),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export function getDerivativeNumberReading(): Question {
|
|
23
|
+
function computePolynomial(
|
|
24
|
+
x0: number,
|
|
25
|
+
y0: number,
|
|
26
|
+
m: number,
|
|
27
|
+
x1: number,
|
|
28
|
+
y1: number,
|
|
29
|
+
x2: number,
|
|
30
|
+
y2: number,
|
|
31
|
+
x3: number,
|
|
32
|
+
y3: number,
|
|
33
|
+
): [number, number, number, number] {
|
|
34
|
+
const a = (-2 * x0 * x1 * x2 + x0 * x1 * x3 + x0 * x2 * x3 + x1 * x2 * x3) / ((x0 - x1) * (x0 - x2) * (x0 - x3));
|
|
35
|
+
const b =
|
|
36
|
+
((y0 - y1) / ((x0 - x1) * (x0 - x1)) -
|
|
37
|
+
(y0 - y2) / ((x0 - x2) * (x0 - x2)) +
|
|
38
|
+
(y0 - y3) / ((x0 - x3) * (x0 - x3))) /
|
|
39
|
+
(x0 - x1);
|
|
40
|
+
const c =
|
|
41
|
+
((m - 2 * a * x0 - b) * (x0 - x1) * (x0 - x2) * (x0 - x3) -
|
|
42
|
+
(y0 - y1) / ((x0 - x1) * (x0 - x1)) +
|
|
43
|
+
a * (x1 * x1 * (x0 - x2) + x2 * x2 * (x0 - x1) - 2 * x1 * x2 * x0) +
|
|
44
|
+
b * (x1 + x2 - 2 * x0)) /
|
|
45
|
+
((x0 - x2) * (x0 - x3));
|
|
46
|
+
const d = y0 - a * x0 * x0 * x0 - b * x0 * x0 - c * x0;
|
|
47
|
+
return [a, b, c, d];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function generatePolynomial(
|
|
51
|
+
x0: number,
|
|
52
|
+
y0: number,
|
|
53
|
+
m: number,
|
|
54
|
+
x1: number,
|
|
55
|
+
y1: number,
|
|
56
|
+
x2: number,
|
|
57
|
+
y2: number,
|
|
58
|
+
x3: number,
|
|
59
|
+
y3: number,
|
|
60
|
+
): Polynomial {
|
|
61
|
+
const [a, b, c, d] = computePolynomial(x0, y0, m, x1, y1, x2, y2, x3, y3);
|
|
62
|
+
return new Polynomial([d, c, b, a]);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const [x1, y1, x2, y2, x3, y3] = [1, 2, 3, 4, 5, 6].map((el) => randint(-5, 6));
|
|
66
|
+
|
|
67
|
+
let xA: number, yA, xB, yB: number;
|
|
68
|
+
let pointA, pointB: Point;
|
|
69
|
+
do {
|
|
70
|
+
[xA, yA] = [1, 2].map((el) => randint(-5, 6));
|
|
71
|
+
xB = xA > 0 ? randint(xA - 4, 6) : randint(-4, xA + 5); // l'écart entre les deux points ne soit pas grand
|
|
72
|
+
yB = yA > 0 ? randint(yA - 4, 6) : randint(-4, yA + 5);
|
|
73
|
+
pointA = new Point('A', new NumberNode(xA), new NumberNode(yA));
|
|
74
|
+
pointB = new Point('B', new NumberNode(xB), new NumberNode(yB));
|
|
75
|
+
} while (xB - xA === 0);
|
|
76
|
+
|
|
77
|
+
const droite = DroiteConstructor.fromTwoPoints(pointA, pointB, 'D');
|
|
78
|
+
|
|
79
|
+
const polynome = generatePolynomial(xA, yA, evaluate(droite.a.toMathString()), x1, y1, x2, y2, x3, y3);
|
|
80
|
+
|
|
81
|
+
let instruction = `$f(x) = ${polynome.toTex()}$, $${pointA.toTexWithCoords()}$, $${pointB.toTexWithCoords()}$, $f'(${xA}) = ${droite.getLeadingCoefficient()}$`;
|
|
82
|
+
|
|
83
|
+
const question: Question = {
|
|
84
|
+
instruction,
|
|
85
|
+
//startStatement: pointA.toTexWithCoords() + ' ' + pointB.toTexWithCoords(),
|
|
86
|
+
answer: droite.a.toTex(),
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
return question;
|
|
90
|
+
}
|
|
91
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leadingCoefficient.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/cartesian/leadingCoefficient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAO9D,eAAO,MAAM,kBAAkB,EAAE,QAShC,CAAC;AAEF,wBAAgB,6BAA6B,IAAI,QAAQ,CAuBxD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLeadingCoefficientQuestion = exports.leadingCoefficient = void 0;
|
|
4
|
+
const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
|
|
5
|
+
const droite_1 = require("../../../math/geometry/droite");
|
|
6
|
+
const point_1 = require("../../../math/geometry/point");
|
|
7
|
+
const randint_1 = require("../../../math/utils/random/randint");
|
|
8
|
+
const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
|
|
9
|
+
exports.leadingCoefficient = {
|
|
10
|
+
id: 'leadingCoefficient',
|
|
11
|
+
connector: '=',
|
|
12
|
+
instruction: '',
|
|
13
|
+
label: 'Déterminer le coefficient directeur',
|
|
14
|
+
levels: ['3', '2', '1'],
|
|
15
|
+
isSingleStep: false,
|
|
16
|
+
section: 'Géométrie cartésienne',
|
|
17
|
+
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getLeadingCoefficientQuestion, nb),
|
|
18
|
+
};
|
|
19
|
+
function getLeadingCoefficientQuestion() {
|
|
20
|
+
let xA, yA, xB, yB;
|
|
21
|
+
let pointA, pointB;
|
|
22
|
+
do {
|
|
23
|
+
[xA, yA] = [1, 2].map((el) => (0, randint_1.randint)(-5, 6));
|
|
24
|
+
xB = xA > 0 ? (0, randint_1.randint)(xA - 4, 6) : (0, randint_1.randint)(-4, xA + 5); // l'écart entre les deux points ne soit pas grand
|
|
25
|
+
yB = yA > 0 ? (0, randint_1.randint)(yA - 4, 6) : (0, randint_1.randint)(-4, yA + 5);
|
|
26
|
+
pointA = new point_1.Point('A', new numberNode_1.NumberNode(xA), new numberNode_1.NumberNode(yA));
|
|
27
|
+
pointB = new point_1.Point('B', new numberNode_1.NumberNode(xB), new numberNode_1.NumberNode(yB));
|
|
28
|
+
} while (xB - xA === 0);
|
|
29
|
+
const droite = droite_1.DroiteConstructor.fromTwoPoints(pointA, pointB, 'D');
|
|
30
|
+
let instruction = `Quel est le coefficient directeur de la droite $${droite.toEquationExpression()}$`;
|
|
31
|
+
const question = {
|
|
32
|
+
instruction,
|
|
33
|
+
//startStatement: pointA.toTexWithCoords() + ' ' + pointB.toTexWithCoords(),
|
|
34
|
+
answer: droite.getLeadingCoefficient(),
|
|
35
|
+
};
|
|
36
|
+
return question;
|
|
37
|
+
}
|
|
38
|
+
exports.getLeadingCoefficientQuestion = getLeadingCoefficientQuestion;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Node } from '../../tree/nodes/node';
|
|
2
|
+
import { Point } from './point';
|
|
3
|
+
export declare abstract class DroiteConstructor {
|
|
4
|
+
static fromTwoPoints(A: Point, B: Point, name?: string): Droite;
|
|
5
|
+
static fromPointAndSlope(A: Point, m: Node, name?: string): Droite;
|
|
6
|
+
static fromPointAndAngle(A: Point, theta: Node, name?: string): Droite;
|
|
7
|
+
}
|
|
8
|
+
export declare class Droite {
|
|
9
|
+
name: string;
|
|
10
|
+
a: Node;
|
|
11
|
+
b: Node;
|
|
12
|
+
constructor(name: string | undefined, a: Node, b: Node);
|
|
13
|
+
toTex(): string;
|
|
14
|
+
toEquationForm(): string;
|
|
15
|
+
toEquationExpression(): string;
|
|
16
|
+
toPolynome(): string;
|
|
17
|
+
getLeadingCoefficient(): string;
|
|
18
|
+
intersection(D: Droite, name?: string): Point | void;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=droite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"droite.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/droite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAQ7C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,8BAAsB,iBAAiB;IACrC,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,SAAM,GAAG,MAAM;IAM5D,MAAM,CAAC,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,SAAM,GAAG,MAAM;IAI/D,MAAM,CAAC,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,SAAM,GAAG,MAAM;CAKpE;AAED,qBAAa,MAAM;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,IAAI,CAAC;IACR,CAAC,EAAE,IAAI,CAAC;gBAEI,IAAI,oBAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI;IAOxC,KAAK,IAAI,MAAM;IAIf,cAAc,IAAI,MAAM;IAIxB,oBAAoB,IAAI,MAAM;IAI9B,UAAU,IAAI,MAAM;IAKpB,qBAAqB,IAAI,MAAM;IAI/B,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,SAAM,GAAG,KAAK,GAAG,IAAI;CAMlD"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Droite = exports.DroiteConstructor = void 0;
|
|
4
|
+
const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
|
|
5
|
+
const addNode_1 = require("../../tree/nodes/operators/addNode");
|
|
6
|
+
const fractionNode_1 = require("../../tree/nodes/operators/fractionNode");
|
|
7
|
+
const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
|
|
8
|
+
const substractNode_1 = require("../../tree/nodes/operators/substractNode");
|
|
9
|
+
const simplify_1 = require("../../tree/parsers/simplify");
|
|
10
|
+
const mathjs_1 = require("mathjs");
|
|
11
|
+
const point_1 = require("./point");
|
|
12
|
+
const polynomial_1 = require("../polynomials/polynomial");
|
|
13
|
+
class DroiteConstructor {
|
|
14
|
+
static fromTwoPoints(A, B, name = 'd') {
|
|
15
|
+
const a = new fractionNode_1.FractionNode(new substractNode_1.SubstractNode(B.y, A.y), new substractNode_1.SubstractNode(B.x, A.x));
|
|
16
|
+
const b = new substractNode_1.SubstractNode(A.y, new multiplyNode_1.MultiplyNode(a, A.x));
|
|
17
|
+
return new Droite(name, (0, simplify_1.simplifyNode)(a), (0, simplify_1.simplifyNode)(b));
|
|
18
|
+
}
|
|
19
|
+
static fromPointAndSlope(A, m, name = 'd') {
|
|
20
|
+
return new Droite(name, (0, simplify_1.simplifyNode)(m), (0, simplify_1.simplifyNode)(new substractNode_1.SubstractNode(A.y, new multiplyNode_1.MultiplyNode(m, A.x))));
|
|
21
|
+
}
|
|
22
|
+
static fromPointAndAngle(A, theta, name = 'd') {
|
|
23
|
+
const m = new numberNode_1.NumberNode((0, mathjs_1.round)(Math.tan(parseFloat(theta.toMathString())), 2));
|
|
24
|
+
const b = new substractNode_1.SubstractNode(A.y, new multiplyNode_1.MultiplyNode(m, A.x));
|
|
25
|
+
return new Droite(name, (0, simplify_1.simplifyNode)(m), (0, simplify_1.simplifyNode)(b));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.DroiteConstructor = DroiteConstructor;
|
|
29
|
+
class Droite {
|
|
30
|
+
constructor(name = 'D', a, b) {
|
|
31
|
+
// ax + b
|
|
32
|
+
this.name = name;
|
|
33
|
+
this.a = a;
|
|
34
|
+
this.b = b;
|
|
35
|
+
}
|
|
36
|
+
toTex() {
|
|
37
|
+
return `${this.name}`;
|
|
38
|
+
}
|
|
39
|
+
toEquationForm() {
|
|
40
|
+
return `${this.a.toTex()}x + ${this.b.toTex()}`;
|
|
41
|
+
}
|
|
42
|
+
toEquationExpression() {
|
|
43
|
+
return `(${this.name}) : y = ${this.toEquationForm()}`; // (D) : y = ax + b
|
|
44
|
+
}
|
|
45
|
+
toPolynome() {
|
|
46
|
+
const polynome = new polynomial_1.Polynomial([parseFloat(this.b.toMathString()), parseFloat(this.a.toMathString())], 'x');
|
|
47
|
+
return polynome.toTex();
|
|
48
|
+
}
|
|
49
|
+
getLeadingCoefficient() {
|
|
50
|
+
return `${(0, simplify_1.simplifyNode)(this.a).toTex()}`;
|
|
51
|
+
}
|
|
52
|
+
// TODO : ajouter des conditions ou cas ou les deux droites sont Parallèles
|
|
53
|
+
intersection(D, name = 'P') {
|
|
54
|
+
if ((0, mathjs_1.evaluate)(D.a.toMathString()) === (0, mathjs_1.evaluate)(this.a.toMathString()))
|
|
55
|
+
return;
|
|
56
|
+
const x = new fractionNode_1.FractionNode(new substractNode_1.SubstractNode(D.b, this.b), new substractNode_1.SubstractNode(this.a, D.a));
|
|
57
|
+
const y = new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(this.a, x), this.b);
|
|
58
|
+
return new point_1.Point(name, (0, simplify_1.simplifyNode)(x), (0, simplify_1.simplifyNode)(y));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.Droite = Droite;
|
package/lib/server.js
CHANGED
|
@@ -26,6 +26,26 @@ const runServer = () => {
|
|
|
26
26
|
questions,
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
|
+
/*console.log(new Droite('D', new NumberNode(2), new NumberNode(-1)).toEquationExpression());
|
|
30
|
+
console.log(
|
|
31
|
+
PointConstructor.fromTwoPoints(
|
|
32
|
+
new Point('A', new NumberNode(0), new NumberNode(-1)),
|
|
33
|
+
new Point('B', new NumberNode(1), new NumberNode(1)),
|
|
34
|
+
).toEquationExpression(),
|
|
35
|
+
);
|
|
36
|
+
console.log(
|
|
37
|
+
PointConstructor.fromPointAndSlope(
|
|
38
|
+
new Point('A', new NumberNode(0), new NumberNode(-1)),
|
|
39
|
+
new NumberNode(2),
|
|
40
|
+
).toEquationExpression(),
|
|
41
|
+
);
|
|
42
|
+
console.log(
|
|
43
|
+
PointConstructor.fromPointAndAngle(
|
|
44
|
+
new Point('A', new NumberNode(0), new NumberNode(-1)),
|
|
45
|
+
new NumberNode(1.107),
|
|
46
|
+
).toEquationExpression(),
|
|
47
|
+
);*/
|
|
48
|
+
//console.log(leadingCoefficient.generator(2));
|
|
29
49
|
app.listen('5000', () => {
|
|
30
50
|
console.log(`[server]: Server is running at http://localhost:5000`);
|
|
31
51
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "math-exercises",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.21",
|
|
4
4
|
"description": "Math exercises generator for middle school and high school",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"dev": "nodemon",
|
|
11
11
|
"start": "ts-node -r tsconfig-paths/register src/index.ts",
|
|
12
12
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
13
|
+
"prepublish": "npm run build",
|
|
13
14
|
"build": "tsc && tsc-alias"
|
|
14
15
|
},
|
|
15
16
|
"keywords": [],
|