math-exercises 3.0.20 → 3.0.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/math/dataRepresentations/barChartReading.d.ts.map +1 -1
- package/lib/exercises/math/dataRepresentations/barChartReading.js +0 -1
- package/lib/exercises/math/dataRepresentations/functionGraphReading.d.ts +9 -0
- package/lib/exercises/math/dataRepresentations/functionGraphReading.d.ts.map +1 -0
- package/lib/exercises/math/dataRepresentations/functionGraphReading.js +174 -0
- package/lib/exercises/math/dataRepresentations/index.js +1 -0
- package/lib/exercises/math/derivation/derivative/inflexionPointQuadrinomials.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/inflexionPointQuadrinomials.js +68 -14
- package/lib/exercises/math/functions/exponential/expFactorization.d.ts +13 -0
- package/lib/exercises/math/functions/exponential/expFactorization.d.ts.map +1 -0
- package/lib/exercises/math/functions/exponential/expFactorization.js +147 -0
- package/lib/exercises/math/functions/exponential/index.d.ts +1 -0
- package/lib/exercises/math/functions/exponential/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/exponential/index.js +1 -0
- package/lib/exercises/math/geometry/euclidian/index.js +1 -0
- package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.d.ts +2 -0
- package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.d.ts.map +1 -0
- package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.js +187 -0
- package/lib/exercises/math/geometry/index.d.ts +1 -0
- package/lib/exercises/math/geometry/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/index.js +2 -1
- package/lib/exercises/math/geometry/lines/index.d.ts +2 -0
- package/lib/exercises/math/geometry/lines/index.d.ts.map +1 -0
- package/lib/exercises/math/geometry/lines/index.js +1 -0
- package/lib/exercises/math/geometry/lines/linesRelativePositions.d.ts +12 -0
- package/lib/exercises/math/geometry/lines/linesRelativePositions.d.ts.map +1 -0
- package/lib/exercises/math/geometry/lines/linesRelativePositions.js +140 -0
- package/lib/exercises/math/geometry/vectors/scalarProduct/index.d.ts +1 -0
- package/lib/exercises/math/geometry/vectors/scalarProduct/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/index.js +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOrthoInSquare.d.ts +6 -2
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOrthoInSquare.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOrthoInSquare.js +99 -67
- package/lib/geogebra/geogebraConstructor.d.ts.map +1 -1
- package/lib/geogebra/geogebraConstructor.js +12 -4
- package/lib/index.d.ts +23 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/point.d.ts +2 -1
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/point.js +3 -3
- package/lib/math/geometry/vector.d.ts +2 -0
- package/lib/math/geometry/vector.d.ts.map +1 -1
- package/lib/math/geometry/vector.js +3 -0
- package/lib/playground.d.ts.map +1 -1
- package/lib/playground.js +1 -3
- package/lib/tree/nodes/numbers/numberNode.d.ts +1 -0
- package/lib/tree/nodes/numbers/numberNode.d.ts.map +1 -1
- package/lib/tree/nodes/numbers/numberNode.js +3 -0
- package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/fractionNode.js +1 -1
- package/lib/tree/parsers/powerParser.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"barChartReading.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/dataRepresentations/barChartReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;
|
|
1
|
+
{"version":3,"file":"barChartReading.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/dataRepresentations/barChartReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAsIF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAejD,CAAC"}
|
|
@@ -72,7 +72,6 @@ const getInstruction = (identifiers) => {
|
|
|
72
72
|
.attr("width", xScale.bandwidth())
|
|
73
73
|
.attr("height", (d) => height - margin.bottom - yScale(d.sales))
|
|
74
74
|
.attr("fill", "steelblue");
|
|
75
|
-
console.log(d3n.svgString());
|
|
76
75
|
const svgString = d3n.svgString();
|
|
77
76
|
return `BBteeeezfst :
|
|
78
77
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Exercise } from "../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
yValue: number;
|
|
4
|
+
a: number;
|
|
5
|
+
b: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const functionGraphReading: Exercise<Identifiers>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=functionGraphReading.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functionGraphReading.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/dataRepresentations/functionGraphReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAoLF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAiBtD,CAAC"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, } from "../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { GeogebraConstructor } from "../../../geogebra/geogebraConstructor.js";
|
|
4
|
+
import { Affine } from "../../../math/polynomials/affine.js";
|
|
5
|
+
import { randint } from "../../../math/utils/random/randint.js";
|
|
6
|
+
import { round } from "../../../math/utils/round.js";
|
|
7
|
+
import { D3Node } from "d3-node";
|
|
8
|
+
import katex from "katex";
|
|
9
|
+
const getPropositions = (n, { answer }) => {
|
|
10
|
+
const propositions = [];
|
|
11
|
+
addValidProp(propositions, answer);
|
|
12
|
+
while (propositions.length < n) {
|
|
13
|
+
throw Error("QCM not implemented");
|
|
14
|
+
}
|
|
15
|
+
return shuffleProps(propositions, n);
|
|
16
|
+
};
|
|
17
|
+
const getAnswer = (identifiers) => {
|
|
18
|
+
const { a, b, yValue } = identifiers;
|
|
19
|
+
return round((yValue - b) / a, 0).frenchify();
|
|
20
|
+
};
|
|
21
|
+
const getInstruction = (identifiers) => {
|
|
22
|
+
const { yValue, a, b } = identifiers;
|
|
23
|
+
const width = 600;
|
|
24
|
+
const height = 300;
|
|
25
|
+
const margin = { top: 20, right: 20, bottom: 40, left: 50 };
|
|
26
|
+
const d3n = new D3Node();
|
|
27
|
+
const d3 = d3n.d3;
|
|
28
|
+
const svg = d3n.createSVG(width, height);
|
|
29
|
+
const xScale = d3
|
|
30
|
+
.scaleLinear()
|
|
31
|
+
.domain([0, 60])
|
|
32
|
+
.range([margin.left, width - margin.right]);
|
|
33
|
+
const yScale = d3
|
|
34
|
+
.scaleLinear()
|
|
35
|
+
.domain([0, 8000])
|
|
36
|
+
.range([height - margin.bottom, margin.top]);
|
|
37
|
+
const xAxis = d3.axisBottom(xScale).ticks(30).tickValues(d3.range(0, 61, 2));
|
|
38
|
+
const yAxis = d3
|
|
39
|
+
.axisLeft(yScale)
|
|
40
|
+
.ticks(16)
|
|
41
|
+
.tickValues(d3.range(0, 8500, 500));
|
|
42
|
+
svg
|
|
43
|
+
.append("g")
|
|
44
|
+
.attr("transform", `translate(0,${height - margin.bottom})`)
|
|
45
|
+
.call(xAxis);
|
|
46
|
+
svg.append("g").attr("transform", `translate(${margin.left},0)`).call(yAxis);
|
|
47
|
+
// Gridlines
|
|
48
|
+
const gridlinesX = d3
|
|
49
|
+
.axisBottom(xScale)
|
|
50
|
+
.tickSize(-height + margin.top + margin.bottom)
|
|
51
|
+
.tickFormat(() => "")
|
|
52
|
+
.tickValues(d3.range(0, 61, 2));
|
|
53
|
+
const gridlinesY = d3
|
|
54
|
+
.axisLeft(yScale)
|
|
55
|
+
.tickSize(-width + margin.left + margin.right)
|
|
56
|
+
.tickFormat(() => "")
|
|
57
|
+
.tickValues(d3.range(0, 8500, 500));
|
|
58
|
+
svg
|
|
59
|
+
.append("g")
|
|
60
|
+
.attr("class", "grid")
|
|
61
|
+
.attr("transform", `translate(0,${height - margin.bottom})`)
|
|
62
|
+
.call(gridlinesX);
|
|
63
|
+
svg
|
|
64
|
+
.append("g")
|
|
65
|
+
.attr("class", "grid")
|
|
66
|
+
.attr("transform", `translate(${margin.left},0)`)
|
|
67
|
+
.call(gridlinesY);
|
|
68
|
+
// Line
|
|
69
|
+
const line = d3
|
|
70
|
+
.line()
|
|
71
|
+
.x((d) => xScale(d))
|
|
72
|
+
.y((d) => yScale(d * a + b));
|
|
73
|
+
svg
|
|
74
|
+
.append("path")
|
|
75
|
+
.datum(d3.range(0, 61))
|
|
76
|
+
.attr("fill", "none")
|
|
77
|
+
.attr("stroke", "blue")
|
|
78
|
+
.attr("stroke-width", 1)
|
|
79
|
+
.attr("d", line);
|
|
80
|
+
// KaTeX math expression
|
|
81
|
+
const latexString = katex.renderToString("(d_1)", { throwOnError: false });
|
|
82
|
+
svg
|
|
83
|
+
.append("foreignObject")
|
|
84
|
+
.attr("x", xScale(18))
|
|
85
|
+
.attr("y", yScale(4500))
|
|
86
|
+
.attr("width", 50)
|
|
87
|
+
.attr("height", 30)
|
|
88
|
+
.html(`<div style='font-size: 16px; font-weight: bold'>${latexString}</div>`);
|
|
89
|
+
// Labels
|
|
90
|
+
svg
|
|
91
|
+
.append("text")
|
|
92
|
+
.attr("x", width / 2)
|
|
93
|
+
.attr("y", height - 5)
|
|
94
|
+
.attr("text-anchor", "middle")
|
|
95
|
+
.attr("font-weight", "bold")
|
|
96
|
+
.text("Nombre de participants");
|
|
97
|
+
svg
|
|
98
|
+
.append("text")
|
|
99
|
+
.attr("x", margin.left)
|
|
100
|
+
.attr("y", margin.top - 5)
|
|
101
|
+
.attr("text-anchor", "middle")
|
|
102
|
+
.attr("font-weight", "bold")
|
|
103
|
+
.text("Coût en €");
|
|
104
|
+
return `La droite $(d_1)$ modélise l'évolution du coût total d'un voyage scolaire en fonction du nombre de participants.
|
|
105
|
+
|
|
106
|
+
Si le coût total du voyage est de $${yValue}€$, quel est le nombre de participants ?
|
|
107
|
+
|
|
108
|
+
${d3n.svgString()}`;
|
|
109
|
+
};
|
|
110
|
+
// const getHint: GetHint<Identifiers> = (identifiers) => {};
|
|
111
|
+
// const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
|
|
112
|
+
const getGGBOptions = (identifiers) => {
|
|
113
|
+
const { a, b, yValue } = identifiers;
|
|
114
|
+
const affine = new Affine(a, b);
|
|
115
|
+
const ggb = new GeogebraConstructor({
|
|
116
|
+
commands: [`Function(${a}*x+${b}, 0, 10000)`],
|
|
117
|
+
forbidShiftDragZoom: true,
|
|
118
|
+
gridDistance: [2, 500],
|
|
119
|
+
lockedAxesRatio: 2 / 500,
|
|
120
|
+
xAxis: {
|
|
121
|
+
label: "Nombre de participants",
|
|
122
|
+
steps: 2,
|
|
123
|
+
showPositive: true,
|
|
124
|
+
},
|
|
125
|
+
yAxis: {
|
|
126
|
+
label: "Coût en €",
|
|
127
|
+
steps: 500,
|
|
128
|
+
showPositive: true,
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
return ggb.getOptions({
|
|
132
|
+
coords: [-5, 65, -5, 8500],
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
const getKeys = (identifiers) => {
|
|
136
|
+
return [];
|
|
137
|
+
};
|
|
138
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
139
|
+
throw Error("VEA not implemented");
|
|
140
|
+
};
|
|
141
|
+
const getFunctionGraphReadingQuestion = (opts) => {
|
|
142
|
+
const a = randint(50, 300);
|
|
143
|
+
const b = randint(0, 300);
|
|
144
|
+
const yValue = 500 * randint(1, 16);
|
|
145
|
+
const identifiers = { a, b, yValue };
|
|
146
|
+
const question = {
|
|
147
|
+
answer: getAnswer(identifiers),
|
|
148
|
+
instruction: getInstruction(identifiers),
|
|
149
|
+
keys: getKeys(identifiers),
|
|
150
|
+
answerFormat: "tex",
|
|
151
|
+
identifiers,
|
|
152
|
+
// hint: getHint(identifiers),
|
|
153
|
+
// correction: getCorrection(identifiers),
|
|
154
|
+
ggbOptions: getGGBOptions(identifiers),
|
|
155
|
+
};
|
|
156
|
+
return question;
|
|
157
|
+
};
|
|
158
|
+
export const functionGraphReading = {
|
|
159
|
+
id: "functionGraphReading",
|
|
160
|
+
label: "",
|
|
161
|
+
isSingleStep: true,
|
|
162
|
+
generator: (nb, opts) => getDistinctQuestions(() => getFunctionGraphReadingQuestion(opts), nb),
|
|
163
|
+
qcmTimer: 60,
|
|
164
|
+
freeTimer: 60,
|
|
165
|
+
getPropositions,
|
|
166
|
+
isAnswerValid,
|
|
167
|
+
subject: "Mathématiques",
|
|
168
|
+
// getHint,
|
|
169
|
+
// getCorrection,
|
|
170
|
+
getInstruction,
|
|
171
|
+
getAnswer,
|
|
172
|
+
getGGBOptions,
|
|
173
|
+
hasGeogebra: true,
|
|
174
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inflexionPointQuadrinomials.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/inflexionPointQuadrinomials.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"inflexionPointQuadrinomials.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/inflexionPointQuadrinomials.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAsJF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAkB7D,CAAC"}
|
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
2
|
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
|
|
3
4
|
import { Polynomial, PolynomialConstructor, } from "../../../../math/polynomials/polynomial.js";
|
|
4
5
|
import { Trinom } from "../../../../math/polynomials/trinom.js";
|
|
5
6
|
import { randint } from "../../../../math/utils/random/randint.js";
|
|
7
|
+
import { equationResolutionTex } from "../../../../tree/nodes/equations/equalNode.js";
|
|
6
8
|
import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
|
|
7
9
|
import { FractionNode } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
8
10
|
import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
11
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
12
|
+
const getInstruction = ({ quadcoeffs }) => {
|
|
13
|
+
const quadrinomial = new Polynomial(quadcoeffs);
|
|
14
|
+
return `Soit la fonction $f$ définie par :
|
|
15
|
+
|
|
16
|
+
$$
|
|
17
|
+
f(x) = ${quadrinomial.toTex()}
|
|
18
|
+
$$
|
|
19
|
+
|
|
20
|
+
Calculer l'abscisse de son point d'inflexion.`;
|
|
21
|
+
};
|
|
22
|
+
const getAnswer = ({ quadcoeffs }) => {
|
|
23
|
+
const quadrinomial = new Polynomial(quadcoeffs);
|
|
24
|
+
const secondderivative = quadrinomial.derivate().derivate();
|
|
25
|
+
const seconddcoeffs = secondderivative.coefficients;
|
|
26
|
+
return new FractionNode(new MultiplyNode(seconddcoeffs[0].toTree(), new NumberNode(-1)), seconddcoeffs[1].toTree())
|
|
27
|
+
.simplify()
|
|
28
|
+
.toTex();
|
|
29
|
+
};
|
|
9
30
|
const getInflexionPointQuadrinomialsQuestion = () => {
|
|
10
31
|
let quadrinomial;
|
|
11
32
|
let quadcoeffs;
|
|
@@ -13,17 +34,15 @@ const getInflexionPointQuadrinomialsQuestion = () => {
|
|
|
13
34
|
quadrinomial = PolynomialConstructor.randomWithOrder(3);
|
|
14
35
|
quadcoeffs = quadrinomial.coefficients;
|
|
15
36
|
} while (quadcoeffs[1] === 0 || quadcoeffs[2] === 0);
|
|
16
|
-
const
|
|
17
|
-
const seconddcoeffs = secondderivative.coefficients;
|
|
18
|
-
const inflexionPoint = new FractionNode(new MultiplyNode(seconddcoeffs[0].toTree(), new NumberNode(-1)), seconddcoeffs[1].toTree())
|
|
19
|
-
.simplify()
|
|
20
|
-
.toTex();
|
|
37
|
+
const identifiers = { quadcoeffs };
|
|
21
38
|
const question = {
|
|
22
|
-
answer:
|
|
23
|
-
instruction:
|
|
39
|
+
answer: getAnswer(identifiers),
|
|
40
|
+
instruction: getInstruction(identifiers),
|
|
24
41
|
keys: [],
|
|
25
42
|
answerFormat: "tex",
|
|
26
|
-
identifiers
|
|
43
|
+
identifiers,
|
|
44
|
+
hint: getHint(identifiers),
|
|
45
|
+
correction: getCorrection(identifiers),
|
|
27
46
|
};
|
|
28
47
|
return question;
|
|
29
48
|
};
|
|
@@ -56,14 +75,44 @@ const getPropositions = (n, { answer, quadcoeffs }) => {
|
|
|
56
75
|
return shuffleProps(propositions, n);
|
|
57
76
|
};
|
|
58
77
|
const isAnswerValid = (ans, { answer, quadcoeffs }) => {
|
|
78
|
+
try {
|
|
79
|
+
return rationalVEA(ans, answer);
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
return handleVEAError(err);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const getHint = ({ quadcoeffs }) => {
|
|
59
86
|
const quadrinomial = new Polynomial(quadcoeffs);
|
|
60
|
-
|
|
61
|
-
|
|
87
|
+
return `Pour trouver l'abscisse du point d'inflexion, on doit résoudre l'équation $f''(x) = 0$.`;
|
|
88
|
+
};
|
|
89
|
+
const getCorrection = ({ quadcoeffs }) => {
|
|
90
|
+
const quadrinomial = new Polynomial(quadcoeffs);
|
|
91
|
+
const firstDerivative = quadrinomial.derivate();
|
|
92
|
+
const secondDerivative = firstDerivative.derivate();
|
|
93
|
+
const seconddcoeffs = secondDerivative.coefficients;
|
|
62
94
|
const inflexionPoint = new FractionNode(new MultiplyNode(seconddcoeffs[0].toTree(), new NumberNode(-1)), seconddcoeffs[1].toTree()).simplify();
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
95
|
+
return `Le point d'inflexion est l'abscisse où la dérivée seconde s'annule.
|
|
96
|
+
|
|
97
|
+
- La dérivée première est :
|
|
98
|
+
|
|
99
|
+
$$
|
|
100
|
+
f'(x) = ${firstDerivative.toTex()}
|
|
101
|
+
$$
|
|
102
|
+
|
|
103
|
+
- La dérivée seconde est :
|
|
104
|
+
|
|
105
|
+
$$
|
|
106
|
+
f''(x) = ${secondDerivative.toTex()}
|
|
107
|
+
$$
|
|
108
|
+
|
|
109
|
+
- Résolvons $f''(x) = 0$ :
|
|
110
|
+
|
|
111
|
+
$$
|
|
112
|
+
${equationResolutionTex(seconddcoeffs[1].toTree(), seconddcoeffs[0].toTree(), (0).toTree(), (0).toTree())}
|
|
113
|
+
$$
|
|
114
|
+
|
|
115
|
+
L'abscisse du point d'inflexion est donc $${inflexionPoint.toTex()}$.`;
|
|
67
116
|
};
|
|
68
117
|
export const inflexionPointQuadrinomials = {
|
|
69
118
|
id: "inflexionPointQuadrinomials",
|
|
@@ -77,4 +126,9 @@ export const inflexionPointQuadrinomials = {
|
|
|
77
126
|
getPropositions,
|
|
78
127
|
isAnswerValid,
|
|
79
128
|
subject: "Mathématiques",
|
|
129
|
+
getInstruction,
|
|
130
|
+
getAnswer,
|
|
131
|
+
getHint,
|
|
132
|
+
getCorrection,
|
|
133
|
+
hasHintAndCorrection: true,
|
|
80
134
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
a: number;
|
|
4
|
+
b: number;
|
|
5
|
+
c: number;
|
|
6
|
+
d: number;
|
|
7
|
+
e: number;
|
|
8
|
+
f: number;
|
|
9
|
+
uA: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const expFactorization: Exercise<Identifiers>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=expFactorization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expFactorization.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/exponential/expFactorization.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IAEV,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAwJF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAiBlD,CAAC"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
// import { expressionVEA } from "#root/exercises/vea/expressionVEA.js";
|
|
4
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
5
|
+
import { add } from "../../../../tree/nodes/operators/addNode.js";
|
|
6
|
+
import { exp } from "../../../../tree/nodes/functions/expNode.js";
|
|
7
|
+
import { isMultiplyNode, multiply, } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
8
|
+
// import { variable } from "../../../../tree/nodes/variables/variableNode.js";
|
|
9
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
10
|
+
import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
|
|
11
|
+
import { AffineConstructor } from "../../../../math/polynomials/affine.js";
|
|
12
|
+
const getPropositions = (n, { answer, ...identifiers }) => {
|
|
13
|
+
const propositions = [];
|
|
14
|
+
const { uA } = identifiers;
|
|
15
|
+
addValidProp(propositions, answer);
|
|
16
|
+
const expNode = exp(multiply(uA, "x"));
|
|
17
|
+
while (propositions.length < n) {
|
|
18
|
+
const affine = AffineConstructor.random();
|
|
19
|
+
tryToAddWrongProp(propositions, multiply(affine.toTree(), expNode).toTex());
|
|
20
|
+
}
|
|
21
|
+
return shuffleProps(propositions, n);
|
|
22
|
+
};
|
|
23
|
+
const getAnswerNode = (identifiers) => {
|
|
24
|
+
const { a, b, c, d, e, f, uA } = identifiers;
|
|
25
|
+
const expNode = exp(multiply(uA, "x"));
|
|
26
|
+
const firstTerm = multiply(a, add(multiply(b, "x"), c)).simplify({
|
|
27
|
+
towardsDistribute: true,
|
|
28
|
+
forbidFactorize: true,
|
|
29
|
+
});
|
|
30
|
+
const secondTerm = multiply(d, add(multiply(e, "x"), f)).simplify({
|
|
31
|
+
towardsDistribute: true,
|
|
32
|
+
forbidFactorize: true,
|
|
33
|
+
});
|
|
34
|
+
const factor = add(firstTerm, secondTerm).simplify({
|
|
35
|
+
towardsDistribute: true,
|
|
36
|
+
forbidFactorize: true,
|
|
37
|
+
});
|
|
38
|
+
return multiply(factor, expNode);
|
|
39
|
+
};
|
|
40
|
+
const getAnswer = (identifiers) => {
|
|
41
|
+
return getAnswerNode(identifiers).toTex();
|
|
42
|
+
};
|
|
43
|
+
const getInstruction = (identifiers) => {
|
|
44
|
+
const { a, b, c, d, e, f, uA } = identifiers;
|
|
45
|
+
const expNode = exp(multiply(uA, "x"));
|
|
46
|
+
const node = add(multiply(a, multiply(add(multiply(b, "x"), c).simplify({
|
|
47
|
+
forbidFactorize: true,
|
|
48
|
+
}), expNode)), multiply(d, multiply(add(multiply(e, "x"), f).simplify({
|
|
49
|
+
forbidFactorize: true,
|
|
50
|
+
}), expNode)));
|
|
51
|
+
return `Factoriser l'expression suivante :
|
|
52
|
+
|
|
53
|
+
$$
|
|
54
|
+
${node.toTex()}
|
|
55
|
+
$$`;
|
|
56
|
+
};
|
|
57
|
+
// const getHint: GetHint<Identifiers> = () => {
|
|
58
|
+
// return `Pour factoriser une expression avec des exponentielles :
|
|
59
|
+
// 1) Repérer le facteur exponentiel commun
|
|
60
|
+
// 2) Mettre en facteur $e^{u(x)}$
|
|
61
|
+
// 3) Factoriser l'expression entre parenthèses`;
|
|
62
|
+
// };
|
|
63
|
+
// const getCorrection: GetCorrection<Identifiers> = (identifiers) => {
|
|
64
|
+
// const operator = isAdd ? "+" : "-";
|
|
65
|
+
// const step1 = `(${a}x${b >= 0 ? "+" : ""}${b})e^{${u}} ${operator} (${c}x${
|
|
66
|
+
// d >= 0 ? "+" : ""
|
|
67
|
+
// }${d})e^{${u}}`;
|
|
68
|
+
// const step2 = `e^{${u}}((${a}x${b >= 0 ? "+" : ""}${b}) ${operator} (${c}x${
|
|
69
|
+
// d >= 0 ? "+" : ""
|
|
70
|
+
// }${d}))`;
|
|
71
|
+
// return `${alignTex([
|
|
72
|
+
// ["", step1],
|
|
73
|
+
// ["=", step2],
|
|
74
|
+
// ])}
|
|
75
|
+
// On a mis en facteur $e^{${u}}$ qui est le terme exponentiel commun.`;
|
|
76
|
+
// };
|
|
77
|
+
const getKeys = () => {
|
|
78
|
+
return ["epower", "x"];
|
|
79
|
+
};
|
|
80
|
+
const isAnswerValid = (ans, { answer, ...identifiers }) => {
|
|
81
|
+
try {
|
|
82
|
+
const parsed = parseAlgebraic(ans);
|
|
83
|
+
if (!parsed)
|
|
84
|
+
return false;
|
|
85
|
+
if (!isMultiplyNode(parsed))
|
|
86
|
+
return false;
|
|
87
|
+
const simp = parsed.simplify({
|
|
88
|
+
forbidFactorize: true,
|
|
89
|
+
towardsDistribute: true,
|
|
90
|
+
});
|
|
91
|
+
const answerSimp = getAnswerNode(identifiers).simplify({
|
|
92
|
+
towardsDistribute: true,
|
|
93
|
+
forbidFactorize: true,
|
|
94
|
+
});
|
|
95
|
+
// const simp = parsed.simplify({});
|
|
96
|
+
return simp.toTex() === answerSimp.toTex();
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
return handleVEAError(err);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const getExpFactorizationQuestion = () => {
|
|
103
|
+
const a = randint(-5, 5, [0]);
|
|
104
|
+
const b = randint(-5, 5);
|
|
105
|
+
const c = b === 0 ? 1 : randint(-5, 5, [0]);
|
|
106
|
+
const d = randint(-5, 5, [0]);
|
|
107
|
+
const e = randint(-5, 5, b === 0 ? [0] : []);
|
|
108
|
+
const f = e === 0 ? 1 : randint(-5, 5);
|
|
109
|
+
// Generate random function for exponent
|
|
110
|
+
const uA = randint(-9, 10, [0]);
|
|
111
|
+
const identifiers = {
|
|
112
|
+
a,
|
|
113
|
+
b,
|
|
114
|
+
c,
|
|
115
|
+
d,
|
|
116
|
+
e,
|
|
117
|
+
f,
|
|
118
|
+
uA,
|
|
119
|
+
};
|
|
120
|
+
const question = {
|
|
121
|
+
answer: getAnswer(identifiers),
|
|
122
|
+
instruction: getInstruction(identifiers),
|
|
123
|
+
keys: getKeys(identifiers),
|
|
124
|
+
answerFormat: "tex",
|
|
125
|
+
identifiers,
|
|
126
|
+
// hint: getHint(identifiers),
|
|
127
|
+
// correction: getCorrection(identifiers),
|
|
128
|
+
};
|
|
129
|
+
return question;
|
|
130
|
+
};
|
|
131
|
+
export const expFactorization = {
|
|
132
|
+
id: "expFactorization",
|
|
133
|
+
connector: "=",
|
|
134
|
+
label: "Factoriser une expression avec des exponentielles",
|
|
135
|
+
isSingleStep: true,
|
|
136
|
+
generator: (nb, opts) => getDistinctQuestions(() => getExpFactorizationQuestion(opts), nb),
|
|
137
|
+
qcmTimer: 60,
|
|
138
|
+
freeTimer: 60,
|
|
139
|
+
getPropositions,
|
|
140
|
+
isAnswerValid,
|
|
141
|
+
subject: "Mathématiques",
|
|
142
|
+
getInstruction,
|
|
143
|
+
// getHint,
|
|
144
|
+
// getCorrection,
|
|
145
|
+
getAnswer,
|
|
146
|
+
// hasHintAndCorrection: true,
|
|
147
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/exponential/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/exponential/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pythagoreOrThales.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/euclidian/pythagoreOrThales.ts"],"names":[],"mappings":""}
|