math-exercises 3.0.94 → 3.0.95
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/calcul/arithmetics/index.d.ts +0 -9
- package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/index.js +0 -9
- package/lib/exercises/math/calcul/decimals/decimalBoundingOnLine.d.ts +9 -0
- package/lib/exercises/math/calcul/decimals/decimalBoundingOnLine.d.ts.map +1 -0
- package/lib/exercises/math/calcul/decimals/decimalBoundingOnLine.js +171 -0
- package/lib/exercises/math/calcul/decimals/index.d.ts +1 -0
- package/lib/exercises/math/calcul/decimals/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/decimals/index.js +1 -0
- package/lib/exercises/math/calcul/fractions/index.d.ts +0 -1
- package/lib/exercises/math/calcul/fractions/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/index.js +0 -1
- package/lib/exercises/math/functions/basics/countFunctionZeroes.d.ts +11 -0
- package/lib/exercises/math/functions/basics/countFunctionZeroes.d.ts.map +1 -0
- package/lib/exercises/math/functions/basics/countFunctionZeroes.js +197 -0
- package/lib/exercises/math/functions/basics/findZeroesProductQuotient.d.ts +11 -0
- package/lib/exercises/math/functions/basics/findZeroesProductQuotient.d.ts.map +1 -0
- package/lib/exercises/math/functions/basics/findZeroesProductQuotient.js +213 -0
- package/lib/exercises/math/functions/basics/index.d.ts +3 -0
- package/lib/exercises/math/functions/basics/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/index.js +3 -1
- package/lib/exercises/math/functions/basics/isPointOnFunction.d.ts +10 -0
- package/lib/exercises/math/functions/basics/isPointOnFunction.d.ts.map +1 -0
- package/lib/exercises/math/functions/basics/isPointOnFunction.js +133 -0
- package/lib/exercises/math/functions/cube/index.d.ts +1 -0
- package/lib/exercises/math/functions/cube/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/cube/index.js +1 -0
- package/lib/exercises/math/functions/cube/isPointOnCubicFunction.d.ts +9 -0
- package/lib/exercises/math/functions/cube/isPointOnCubicFunction.d.ts.map +1 -0
- package/lib/exercises/math/functions/cube/isPointOnCubicFunction.js +111 -0
- package/lib/exercises/math/functions/inverse/compareInverseValues.d.ts +10 -0
- package/lib/exercises/math/functions/inverse/compareInverseValues.d.ts.map +1 -0
- package/lib/exercises/math/functions/inverse/compareInverseValues.js +136 -0
- package/lib/exercises/math/functions/inverse/index.d.ts +3 -0
- package/lib/exercises/math/functions/inverse/index.d.ts.map +1 -0
- package/lib/exercises/math/functions/inverse/index.js +2 -0
- package/lib/exercises/math/functions/inverse/isPointOnReciprocalFunction.d.ts +9 -0
- package/lib/exercises/math/functions/inverse/isPointOnReciprocalFunction.d.ts.map +1 -0
- package/lib/exercises/math/functions/inverse/isPointOnReciprocalFunction.js +117 -0
- package/lib/exercises/math/functions/sign/equationFromSignTable.d.ts +4 -1
- package/lib/exercises/math/functions/sign/equationFromSignTable.d.ts.map +1 -1
- package/lib/exercises/math/functions/sign/equationFromSignTable.js +25 -10
- package/lib/exercises/math/functions/sqrt/getImageOfSquareRootFunction.d.ts +8 -0
- package/lib/exercises/math/functions/sqrt/getImageOfSquareRootFunction.d.ts.map +1 -0
- package/lib/exercises/math/functions/sqrt/getImageOfSquareRootFunction.js +128 -0
- package/lib/exercises/math/functions/sqrt/index.d.ts +1 -0
- package/lib/exercises/math/functions/sqrt/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/sqrt/index.js +1 -0
- package/lib/exercises/math/functions/square/compareSquaredValues.d.ts +9 -0
- package/lib/exercises/math/functions/square/compareSquaredValues.d.ts.map +1 -0
- package/lib/exercises/math/functions/square/compareSquaredValues.js +143 -0
- package/lib/exercises/math/functions/square/imageOfSquareFunction.d.ts +8 -0
- package/lib/exercises/math/functions/square/imageOfSquareFunction.d.ts.map +1 -0
- package/lib/exercises/math/functions/square/imageOfSquareFunction.js +152 -0
- package/lib/exercises/math/functions/square/index.d.ts +2 -1
- package/lib/exercises/math/functions/square/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/square/index.js +3 -1
- package/lib/exercises/math/functions/square/squareImageIntervalWithGraph.d.ts +11 -0
- package/lib/exercises/math/functions/square/squareImageIntervalWithGraph.d.ts.map +1 -0
- package/lib/exercises/math/functions/square/squareImageIntervalWithGraph.js +174 -0
- package/lib/exercises/math/functions/variations/varTableFromSentences.d.ts +2 -0
- package/lib/exercises/math/functions/variations/varTableFromSentences.d.ts.map +1 -0
- package/lib/exercises/math/functions/variations/varTableFromSentences.js +137 -0
- package/lib/exercises/math/powers/index.d.ts +1 -0
- package/lib/exercises/math/powers/index.d.ts.map +1 -1
- package/lib/exercises/math/powers/index.js +1 -0
- package/lib/exercises/math/powers/powerNotation.d.ts +9 -0
- package/lib/exercises/math/powers/powerNotation.d.ts.map +1 -0
- package/lib/exercises/math/powers/powerNotation.js +126 -0
- package/lib/exercises/math/sets/index.d.ts +1 -0
- package/lib/exercises/math/sets/index.d.ts.map +1 -1
- package/lib/exercises/math/sets/index.js +1 -0
- package/lib/exercises/math/sets/isNumberDecimal.d.ts +11 -0
- package/lib/exercises/math/sets/isNumberDecimal.d.ts.map +1 -0
- package/lib/exercises/math/sets/isNumberDecimal.js +144 -0
- package/lib/index.d.ts +43 -42
- package/lib/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { Affine } from "../../../../math/polynomials/affine.js";
|
|
4
|
+
import { Polynomial } from "../../../../math/polynomials/polynomial.js";
|
|
5
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
6
|
+
import { EquationSolutionNode } from "../../../../tree/nodes/equations/equationSolutionNode.js";
|
|
7
|
+
import { opposite } from "../../../../tree/nodes/functions/oppositeNode.js";
|
|
8
|
+
import { sqrt } from "../../../../tree/nodes/functions/sqrtNode.js";
|
|
9
|
+
import { frac, isFractionNode, } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
10
|
+
import { multiply, } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
11
|
+
import { square } from "../../../../tree/nodes/operators/powerNode.js";
|
|
12
|
+
import { substract } from "../../../../tree/nodes/operators/substractNode.js";
|
|
13
|
+
import { DiscreteSetNode } from "../../../../tree/nodes/sets/discreteSetNode.js";
|
|
14
|
+
import { discreteSetParser } from "../../../../tree/parsers/discreteSetParser.js";
|
|
15
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
16
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
17
|
+
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
18
|
+
const getPropositions = (n, { answer }) => {
|
|
19
|
+
const propositions = [];
|
|
20
|
+
addValidProp(propositions, answer);
|
|
21
|
+
while (propositions.length < n) {
|
|
22
|
+
const oneSol = coinFlip();
|
|
23
|
+
const a = randint(-10, 10);
|
|
24
|
+
const b = randint(-10, 10, [a]);
|
|
25
|
+
const roots = oneSol
|
|
26
|
+
? [a.toTree()]
|
|
27
|
+
: [a, b].sort((a, b) => a - b).map((e) => e.toTree());
|
|
28
|
+
tryToAddWrongProp(propositions, new EquationSolutionNode(new DiscreteSetNode(roots)).toTex());
|
|
29
|
+
}
|
|
30
|
+
return shuffleProps(propositions, n);
|
|
31
|
+
};
|
|
32
|
+
const getRoots = (identifiers) => {
|
|
33
|
+
const { a, b, c, d } = identifiers;
|
|
34
|
+
switch (identifiers.type) {
|
|
35
|
+
case 0:
|
|
36
|
+
return [frac(-b, a), frac(-d, c)].sort((r1, r2) => r1.evaluate() - r2.evaluate());
|
|
37
|
+
case 1:
|
|
38
|
+
return [frac(-b, a)];
|
|
39
|
+
case 2:
|
|
40
|
+
default:
|
|
41
|
+
return [opposite(sqrt(a)), sqrt(a)];
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const getAnswer = (identifiers) => {
|
|
45
|
+
const roots = getRoots(identifiers).map((r) => r.simplify());
|
|
46
|
+
return new EquationSolutionNode(new DiscreteSetNode(roots)).toTex();
|
|
47
|
+
};
|
|
48
|
+
const buildFunc = (identifiers) => {
|
|
49
|
+
const { type, a, b, c, d } = identifiers;
|
|
50
|
+
switch (type) {
|
|
51
|
+
case 0: //product
|
|
52
|
+
return multiply(new Affine(a, b).toTree(), new Affine(c, d).toTree());
|
|
53
|
+
break;
|
|
54
|
+
case 1: //quotient
|
|
55
|
+
return frac(new Affine(a, b).toTree(), new Affine(c, d).toTree());
|
|
56
|
+
break;
|
|
57
|
+
case 2: //x^2 -k
|
|
58
|
+
default:
|
|
59
|
+
return substract(square("x"), a);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const getInstruction = (identifiers) => {
|
|
64
|
+
const { type, a, b, c, d } = identifiers;
|
|
65
|
+
const myFuncNode = buildFunc(identifiers);
|
|
66
|
+
return `Déterminer la ou les valeurs d'annulation de la fonction suivante :
|
|
67
|
+
|
|
68
|
+
$$
|
|
69
|
+
f(x)=${myFuncNode.toTex()}
|
|
70
|
+
$$`;
|
|
71
|
+
};
|
|
72
|
+
const getHint = (identifiers) => {
|
|
73
|
+
const type = identifiers.type;
|
|
74
|
+
if (type === 0) {
|
|
75
|
+
return `Un produit est nul si et seulement si au moins un des deux facteurs est nul. Cherche les valeurs de $x$ qui annulent chaque facteur.`;
|
|
76
|
+
}
|
|
77
|
+
if (type === 1) {
|
|
78
|
+
return `Un quotient est nul lorsque son numérateur est nul, et son dénominateur non nul. Cherche donc les valeurs de $x$ qui rendent le numérateur nul, mais pas le dénominateur.`;
|
|
79
|
+
}
|
|
80
|
+
return `Cherche les solutions de l'équation $x^2 = k$.`;
|
|
81
|
+
};
|
|
82
|
+
const getCorrection = (identifiers) => {
|
|
83
|
+
const myFunc = buildFunc(identifiers);
|
|
84
|
+
const tex = myFunc.toTex();
|
|
85
|
+
const answer = getAnswer(identifiers);
|
|
86
|
+
const { type, a, b, c, d } = identifiers;
|
|
87
|
+
if (type === 0) {
|
|
88
|
+
const polynome1 = new Polynomial([b, a]);
|
|
89
|
+
const polynome2 = new Polynomial([d, c]);
|
|
90
|
+
const sol1 = frac(-b, a).simplify();
|
|
91
|
+
const sol2 = frac(-d, c).simplify();
|
|
92
|
+
return `Un produit est nul si et seulement si un des deux facteurs est nul. On résout donc deux équations :
|
|
93
|
+
|
|
94
|
+
${alignTex([
|
|
95
|
+
["", buildFunc(identifiers).toTex() + "=0"],
|
|
96
|
+
[
|
|
97
|
+
"\\iff",
|
|
98
|
+
`${polynome1.toTree().toTex()} = 0 \\text{ ou } ${polynome2
|
|
99
|
+
.toTree()
|
|
100
|
+
.toTex()} = 0`,
|
|
101
|
+
],
|
|
102
|
+
["\\iff", `x=${sol1.toTex()} \\text{ ou } x=${sol2.toTex()}`],
|
|
103
|
+
])}
|
|
104
|
+
|
|
105
|
+
Ainsi, $${getAnswer(identifiers)}$`;
|
|
106
|
+
}
|
|
107
|
+
if (isFractionNode(myFunc)) {
|
|
108
|
+
const polynome1 = new Polynomial([b, a]);
|
|
109
|
+
const polynome2 = new Polynomial([d, c]);
|
|
110
|
+
const root1 = frac(-b, a).simplify().toTex();
|
|
111
|
+
const root2 = frac(-d, c).simplify().toTex();
|
|
112
|
+
const answer = getAnswer(identifiers);
|
|
113
|
+
return `Un quotient est nul si est seulement si le numérateur est nul et le dénominateur est non nul. Ainsi :
|
|
114
|
+
|
|
115
|
+
${alignTex([
|
|
116
|
+
["", buildFunc(identifiers).toTex() + "=0"],
|
|
117
|
+
["\\iff", `${polynome1.toTex()}=0 \\text{ et } ${polynome2.toTex()}\\neq 0`],
|
|
118
|
+
["\\iff", `x=${root1} \\text{ et } x\\neq ${root2}`],
|
|
119
|
+
])}
|
|
120
|
+
|
|
121
|
+
Il y a donc bien une solution pour cette équation :
|
|
122
|
+
|
|
123
|
+
$$
|
|
124
|
+
${answer}
|
|
125
|
+
$$`;
|
|
126
|
+
}
|
|
127
|
+
return `On résout l'équation :
|
|
128
|
+
|
|
129
|
+
${alignTex([
|
|
130
|
+
["", buildFunc(identifiers).toTex() + "=0"],
|
|
131
|
+
["\\iff", `x^2=${a}`],
|
|
132
|
+
])}
|
|
133
|
+
|
|
134
|
+
Il y a donc deux solutions à cette équaton :
|
|
135
|
+
|
|
136
|
+
$$
|
|
137
|
+
${getAnswer(identifiers)}
|
|
138
|
+
$$
|
|
139
|
+
`;
|
|
140
|
+
};
|
|
141
|
+
const getKeys = (identifiers) => {
|
|
142
|
+
return ["S", "equal", "lbrace", "semicolon", "rbrace"];
|
|
143
|
+
};
|
|
144
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
145
|
+
try {
|
|
146
|
+
const parsed = discreteSetParser(ans);
|
|
147
|
+
if (!parsed)
|
|
148
|
+
return false;
|
|
149
|
+
return "S=" + parsed.simplify().toTex() === answer;
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
return handleVEAError(err);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
const getFindZeroesProductQuotientQuestion = () => {
|
|
156
|
+
const type = randint(0, 3);
|
|
157
|
+
let a = 0;
|
|
158
|
+
let b = undefined;
|
|
159
|
+
let c = undefined;
|
|
160
|
+
let d = undefined;
|
|
161
|
+
switch (type) {
|
|
162
|
+
case 0: //product
|
|
163
|
+
a = randint(-10, 10, [0]);
|
|
164
|
+
b = randint(-10, 10);
|
|
165
|
+
do {
|
|
166
|
+
c = randint(-10, 10, [0]);
|
|
167
|
+
d = randint(-10, 10, [0]);
|
|
168
|
+
} while (a / c === b / d);
|
|
169
|
+
break;
|
|
170
|
+
case 1: //quotient
|
|
171
|
+
a = randint(-10, 10, [0]);
|
|
172
|
+
b = randint(-10, 10);
|
|
173
|
+
do {
|
|
174
|
+
c = randint(-10, 10, [0]);
|
|
175
|
+
d = randint(-10, 10, [0]);
|
|
176
|
+
} while (a / c === b / d);
|
|
177
|
+
break;
|
|
178
|
+
case 2: //x^2 -k
|
|
179
|
+
default:
|
|
180
|
+
a = randint(1, 11) ** 2;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
const identifiers = { type, a, b, c, d };
|
|
184
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
185
|
+
};
|
|
186
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
187
|
+
return {
|
|
188
|
+
answer: getAnswer(identifiers),
|
|
189
|
+
instruction: getInstruction(identifiers),
|
|
190
|
+
keys: getKeys(identifiers),
|
|
191
|
+
answerFormat: "tex",
|
|
192
|
+
identifiers,
|
|
193
|
+
hint: getHint(identifiers),
|
|
194
|
+
correction: getCorrection(identifiers),
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
export const findZeroesProductQuotient = {
|
|
198
|
+
id: "findZeroesProductQuotient",
|
|
199
|
+
label: "Déterminer la ou les valeur d'annulation d'une fonction par le calcul",
|
|
200
|
+
isSingleStep: true,
|
|
201
|
+
generator: (nb, opts) => getDistinctQuestions(() => getFindZeroesProductQuotientQuestion(opts), nb),
|
|
202
|
+
qcmTimer: 60,
|
|
203
|
+
freeTimer: 60,
|
|
204
|
+
getPropositions,
|
|
205
|
+
isAnswerValid,
|
|
206
|
+
subject: "Mathématiques",
|
|
207
|
+
getInstruction,
|
|
208
|
+
getHint,
|
|
209
|
+
getCorrection,
|
|
210
|
+
getAnswer,
|
|
211
|
+
getQuestionFromIdentifiers,
|
|
212
|
+
hasHintAndCorrection: true,
|
|
213
|
+
};
|
|
@@ -12,4 +12,7 @@ export * from "./graphicInequationAffine.js";
|
|
|
12
12
|
export * from "./signOfFunction.js";
|
|
13
13
|
export * from "./valueTableCompletion.js";
|
|
14
14
|
export * from "./valueTableFromGraph.js";
|
|
15
|
+
export * from "./isPointOnFunction.js";
|
|
16
|
+
export * from "./countFunctionZeroes.js";
|
|
17
|
+
export * from "./findZeroesProductQuotient.js";
|
|
15
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC"}
|
|
@@ -9,7 +9,9 @@ export * from "./twoFunctionsInequation.js";
|
|
|
9
9
|
export * from "./inverseImageFunctionTable.js";
|
|
10
10
|
export * from "./imageAntecedentFromSentence.js";
|
|
11
11
|
export * from "./graphicInequationAffine.js";
|
|
12
|
-
// export * from "./valueTableCompletion.js";
|
|
13
12
|
export * from "./signOfFunction.js";
|
|
14
13
|
export * from "./valueTableCompletion.js";
|
|
15
14
|
export * from "./valueTableFromGraph.js";
|
|
15
|
+
export * from "./isPointOnFunction.js";
|
|
16
|
+
export * from "./countFunctionZeroes.js";
|
|
17
|
+
export * from "./findZeroesProductQuotient.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { PointIdentifiers } from "../../../../math/geometry/point.js";
|
|
3
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
4
|
+
type Identifiers = {
|
|
5
|
+
point: PointIdentifiers;
|
|
6
|
+
func: NodeIdentifiers;
|
|
7
|
+
};
|
|
8
|
+
export declare const isPointOnFunction: Exercise<Identifiers>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=isPointOnFunction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPointOnFunction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/isPointOnFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAItC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAI7C,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,gBAAgB,CAAC;IACxB,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AA2HF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAkBnD,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { Point, PointConstructor, } from "../../../../math/geometry/point.js";
|
|
4
|
+
import { AffineConstructor } from "../../../../math/polynomials/affine.js";
|
|
5
|
+
import { TrinomConstructor } from "../../../../math/polynomials/trinom.js";
|
|
6
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
7
|
+
import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
8
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
9
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
10
|
+
const getPropositions = (n, { answer }) => {
|
|
11
|
+
const propositions = [];
|
|
12
|
+
addValidProp(propositions, answer, "raw");
|
|
13
|
+
tryToAddWrongProp(propositions, "Non", "raw");
|
|
14
|
+
tryToAddWrongProp(propositions, "On ne peut pas savoir", "raw");
|
|
15
|
+
tryToAddWrongProp(propositions, "Oui", "raw");
|
|
16
|
+
return shuffleProps(propositions, n);
|
|
17
|
+
};
|
|
18
|
+
const getAnswer = (identifiers) => {
|
|
19
|
+
const { point, func } = identifiers;
|
|
20
|
+
const pointObj = PointConstructor.fromIdentifiers(point);
|
|
21
|
+
const funcNode = reifyAlgebraic(func);
|
|
22
|
+
const resolvedValue = funcNode
|
|
23
|
+
.toDetailedEvaluation({ x: pointObj.x })
|
|
24
|
+
.simplify();
|
|
25
|
+
const answer = resolvedValue.equals(pointObj.y) ? "Oui" : "Non";
|
|
26
|
+
return answer;
|
|
27
|
+
};
|
|
28
|
+
const getInstruction = (identifiers) => {
|
|
29
|
+
const { point, func } = identifiers;
|
|
30
|
+
const pointTex = PointConstructor.fromIdentifiers(point).toTexWithCoords();
|
|
31
|
+
const funcTex = reifyAlgebraic(func).toTex();
|
|
32
|
+
return `On considère la fonction $f$ définie par :
|
|
33
|
+
|
|
34
|
+
$$
|
|
35
|
+
f(x) = ${funcTex}
|
|
36
|
+
$$
|
|
37
|
+
|
|
38
|
+
Le point $${pointTex}$ appartient-il à la courbe représentant la fonction $f$ ?`;
|
|
39
|
+
};
|
|
40
|
+
const getHint = (identifiers) => {
|
|
41
|
+
const { point, func } = identifiers;
|
|
42
|
+
const pointTex = PointConstructor.fromIdentifiers(point).toTexWithCoords();
|
|
43
|
+
const funcTex = reifyAlgebraic(func).toTex();
|
|
44
|
+
return `Pour vérifier si le point $${pointTex}$ appartient à la courbe de la fonction $f(x) = ${funcTex}$, remplace $x$ par l'abscisse du point dans l'expression de $f(x)$ et compare le résultat avec l'ordonnée du point.`;
|
|
45
|
+
};
|
|
46
|
+
const getCorrection = (identifiers) => {
|
|
47
|
+
const { point, func } = identifiers;
|
|
48
|
+
const pointObj = PointConstructor.fromIdentifiers(point);
|
|
49
|
+
const funcNode = reifyAlgebraic(func);
|
|
50
|
+
const detailedEval = funcNode.toDetailedEvaluation({ x: pointObj.x });
|
|
51
|
+
const simplifiedEval = detailedEval.simplify();
|
|
52
|
+
const pointTex = pointObj.toTexWithCoords();
|
|
53
|
+
const detailedTex = detailedEval.toTex();
|
|
54
|
+
const simplifiedTex = simplifiedEval.toTex();
|
|
55
|
+
const xTex = pointObj.x.toTex();
|
|
56
|
+
const yTex = pointObj.y.toTex();
|
|
57
|
+
if (getAnswer(identifiers) === "Oui") {
|
|
58
|
+
return `Pour vérifier si le point $${pointTex}$ appartient à la courbe de la fonction, on remplace $x$ par $${xTex}$ dans l'expression de $f(x)$ :
|
|
59
|
+
|
|
60
|
+
$$
|
|
61
|
+
${detailedTex} = ${simplifiedTex}
|
|
62
|
+
$$
|
|
63
|
+
|
|
64
|
+
On a donc bien $f(${xTex})=${yTex}$, donc le point appartient à la courbe.`;
|
|
65
|
+
}
|
|
66
|
+
return `Pour vérifier si le point $${pointTex}$ appartient à la courbe de la fonction, on remplace $x$ par $${xTex}$ dans l'expression de $f(x)$ :
|
|
67
|
+
|
|
68
|
+
$$
|
|
69
|
+
${detailedTex} = ${simplifiedTex}
|
|
70
|
+
$$
|
|
71
|
+
|
|
72
|
+
Comme $${simplifiedTex} \\neq ${yTex}$, le point n'appartient pas à la courbe.`;
|
|
73
|
+
};
|
|
74
|
+
const getKeys = (identifiers) => {
|
|
75
|
+
return [];
|
|
76
|
+
};
|
|
77
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
78
|
+
try {
|
|
79
|
+
throw Error("VEA not implemented");
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
return handleVEAError(err);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const getIsPointOnFunctionQuestion = (ops) => {
|
|
86
|
+
const useTrinom = coinFlip();
|
|
87
|
+
const func = useTrinom
|
|
88
|
+
? TrinomConstructor.random()
|
|
89
|
+
: AffineConstructor.random();
|
|
90
|
+
const x = randint(1, 6);
|
|
91
|
+
const isSolution = coinFlip();
|
|
92
|
+
let y;
|
|
93
|
+
const correctY = func
|
|
94
|
+
.toTree()
|
|
95
|
+
.toDetailedEvaluation({ x: x.toTree() })
|
|
96
|
+
.evaluate();
|
|
97
|
+
const wrongY = correctY + randint(-5, 5, [0]);
|
|
98
|
+
isSolution ? (y = correctY) : (y = wrongY);
|
|
99
|
+
const point = new Point("A", x, y);
|
|
100
|
+
return getQuestionFromIdentifiers({
|
|
101
|
+
point: point.toIdentifiers(),
|
|
102
|
+
func: func.toTree().toIdentifiers(),
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
106
|
+
return {
|
|
107
|
+
answer: getAnswer(identifiers),
|
|
108
|
+
instruction: getInstruction(identifiers),
|
|
109
|
+
keys: getKeys(identifiers),
|
|
110
|
+
answerFormat: "tex",
|
|
111
|
+
identifiers,
|
|
112
|
+
hint: getHint(identifiers),
|
|
113
|
+
correction: getCorrection(identifiers),
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
export const isPointOnFunction = {
|
|
117
|
+
id: "isPointOnFunction",
|
|
118
|
+
label: "Déterminer si un point appartient à la courbe d’une fonction",
|
|
119
|
+
answerType: "QCU",
|
|
120
|
+
isSingleStep: true,
|
|
121
|
+
generator: (nb, opts) => getDistinctQuestions(() => getIsPointOnFunctionQuestion(opts), nb),
|
|
122
|
+
qcmTimer: 60,
|
|
123
|
+
freeTimer: 60,
|
|
124
|
+
getPropositions,
|
|
125
|
+
isAnswerValid,
|
|
126
|
+
subject: "Mathématiques",
|
|
127
|
+
getInstruction,
|
|
128
|
+
getHint,
|
|
129
|
+
getCorrection,
|
|
130
|
+
getAnswer,
|
|
131
|
+
getQuestionFromIdentifiers,
|
|
132
|
+
hasHintAndCorrection: true,
|
|
133
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/cube/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/cube/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
x: NodeIdentifiers;
|
|
5
|
+
y: NodeIdentifiers;
|
|
6
|
+
};
|
|
7
|
+
export declare const isPointOnCubicFunction: Exercise<Identifiers>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=isPointOnCubicFunction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPointOnCubicFunction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/cube/isPointOnCubicFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAM7C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;CACpB,CAAC;AAiGF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAkBxD,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { Point } from "../../../../math/geometry/point.js";
|
|
4
|
+
import { RationalConstructor } from "../../../../math/numbers/rationals/rational.js";
|
|
5
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
6
|
+
import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
7
|
+
import { power } from "../../../../tree/nodes/operators/powerNode.js";
|
|
8
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
9
|
+
import { random } from "../../../../utils/alea/random.js";
|
|
10
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
11
|
+
const getPropositions = (n, { answer }) => {
|
|
12
|
+
const propositions = [];
|
|
13
|
+
addValidProp(propositions, answer, "raw");
|
|
14
|
+
tryToAddWrongProp(propositions, "Non", "raw");
|
|
15
|
+
tryToAddWrongProp(propositions, "On ne peut pas savoir", "raw");
|
|
16
|
+
tryToAddWrongProp(propositions, "Oui", "raw");
|
|
17
|
+
return shuffleProps(propositions, n);
|
|
18
|
+
};
|
|
19
|
+
const getAnswer = (identifiers) => {
|
|
20
|
+
const { x, y } = identifiers;
|
|
21
|
+
const cubicNode = power("x", 3);
|
|
22
|
+
const xNode = reifyAlgebraic(x);
|
|
23
|
+
const yNode = reifyAlgebraic(y);
|
|
24
|
+
const cubicValue = cubicNode
|
|
25
|
+
.toDetailedEvaluation({ x: xNode })
|
|
26
|
+
.simplify({ calculatePowers: true, distributePowersOnFrac: true });
|
|
27
|
+
const answer = cubicValue.toTex() === yNode.toTex() ? "Oui" : "Non";
|
|
28
|
+
return answer;
|
|
29
|
+
};
|
|
30
|
+
const getInstruction = (identifiers) => {
|
|
31
|
+
const { x, y } = identifiers;
|
|
32
|
+
const xNode = reifyAlgebraic(x);
|
|
33
|
+
const yNode = reifyAlgebraic(y);
|
|
34
|
+
const point = new Point("A", xNode, yNode);
|
|
35
|
+
return `Le point $${point.toTexWithCoords()}$ appartient-il à la courbe de la fonction cube ?`;
|
|
36
|
+
};
|
|
37
|
+
const getHint = (identifiers) => {
|
|
38
|
+
return `Un point de coordonnées $(x;y)$ appartient à la courbe d'une fonction $f$ si et seulement $y = f(x)$.`;
|
|
39
|
+
};
|
|
40
|
+
const getCorrection = (identifiers) => {
|
|
41
|
+
const { x, y } = identifiers;
|
|
42
|
+
const cubicNode = power("x", 3);
|
|
43
|
+
const xNode = reifyAlgebraic(x);
|
|
44
|
+
const yNode = reifyAlgebraic(y);
|
|
45
|
+
const cubicValue = cubicNode.toDetailedEvaluation({ x: xNode });
|
|
46
|
+
if (getAnswer(identifiers) == "Oui") {
|
|
47
|
+
return `On a bien $${cubicValue.toTex()} = ${yNode.toTex()}$, donc le point appartient à la courbe de la fonction cube.`;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return `Le cube de $${xNode
|
|
51
|
+
.simplify()
|
|
52
|
+
.toTex()}$ est $${cubicValue.toTex()} = ${cubicValue
|
|
53
|
+
.simplify({ calculatePowers: true, distributePowersOnFrac: true })
|
|
54
|
+
.toTex()} \\neq ${yNode.toTex()}$.
|
|
55
|
+
|
|
56
|
+
Le point n'appartient donc pas à la courbe de la fonction cube.`;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const getKeys = (identifiers) => {
|
|
60
|
+
return [];
|
|
61
|
+
};
|
|
62
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
63
|
+
try {
|
|
64
|
+
return ans == answer;
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
return handleVEAError(err);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const getIsPointOnCubicFunctionQuestion = (ops) => {
|
|
71
|
+
const xNumber = randint(0, 10);
|
|
72
|
+
const xFrac = RationalConstructor.randomIrreductible().toTree();
|
|
73
|
+
const xChoices = [xNumber.toTree(), xFrac];
|
|
74
|
+
const chosenX = random(xChoices);
|
|
75
|
+
const yNumber = coinFlip()
|
|
76
|
+
? power(chosenX, 3)
|
|
77
|
+
.simplify({ calculatePowers: true, distributePowersOnFrac: true })
|
|
78
|
+
.toIdentifiers()
|
|
79
|
+
: randint(0, 10).toTree().toIdentifiers();
|
|
80
|
+
const identifiers = { x: chosenX.toIdentifiers(), y: yNumber };
|
|
81
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
82
|
+
};
|
|
83
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
84
|
+
return {
|
|
85
|
+
answer: getAnswer(identifiers),
|
|
86
|
+
instruction: getInstruction(identifiers),
|
|
87
|
+
keys: getKeys(identifiers),
|
|
88
|
+
answerFormat: "tex",
|
|
89
|
+
identifiers,
|
|
90
|
+
hint: getHint(identifiers),
|
|
91
|
+
correction: getCorrection(identifiers),
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
export const isPointOnCubicFunction = {
|
|
95
|
+
id: "isPointOnCubicFunction",
|
|
96
|
+
label: "Déterminer si un point appartient à la courbe de la fonction cube",
|
|
97
|
+
isSingleStep: true,
|
|
98
|
+
generator: (nb, opts) => getDistinctQuestions(() => getIsPointOnCubicFunctionQuestion(opts), nb),
|
|
99
|
+
qcmTimer: 60,
|
|
100
|
+
freeTimer: 60,
|
|
101
|
+
isAnswerValid,
|
|
102
|
+
subject: "Mathématiques",
|
|
103
|
+
getPropositions,
|
|
104
|
+
getInstruction,
|
|
105
|
+
getHint,
|
|
106
|
+
getCorrection,
|
|
107
|
+
getAnswer,
|
|
108
|
+
getQuestionFromIdentifiers,
|
|
109
|
+
hasHintAndCorrection: true,
|
|
110
|
+
answerType: "QCU",
|
|
111
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
a: NodeIdentifiers;
|
|
5
|
+
b: NodeIdentifiers;
|
|
6
|
+
isMinusInside: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const compareInverseValues: Exercise<Identifiers>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=compareInverseValues.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compareInverseValues.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/inverse/compareInverseValues.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAM7C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AAuIF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAkBtD,CAAC"}
|