math-exercises 3.0.212 → 3.0.214
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/arithmetic/hasDiophantianEquationSolution.js +4 -4
- package/lib/exercises/math/arithmetic/pgcdFromPrimeDecomposition.d.ts.map +1 -1
- package/lib/exercises/math/arithmetic/pgcdFromPrimeDecomposition.js +11 -9
- package/lib/exercises/math/complex/argumentFromAlgebraicComplex.d.ts +3 -0
- package/lib/exercises/math/complex/argumentFromAlgebraicComplex.d.ts.map +1 -1
- package/lib/exercises/math/complex/argumentFromAlgebraicComplex.js +92 -3
- package/lib/exercises/math/complex/conjugateDivideComplex.d.ts.map +1 -1
- package/lib/exercises/math/complex/conjugateDivideComplex.js +67 -6
- package/lib/exercises/math/complex/conjugateMultiplyComplex.d.ts.map +1 -1
- package/lib/exercises/math/complex/conjugateMultiplyComplex.js +54 -15
- package/lib/exercises/math/complex/divideComplex.d.ts.map +1 -1
- package/lib/exercises/math/complex/divideComplex.js +60 -6
- package/lib/exercises/math/complex/exp/complexAlgebraicFromExpForm.d.ts +9 -0
- package/lib/exercises/math/complex/exp/complexAlgebraicFromExpForm.d.ts.map +1 -0
- package/lib/exercises/math/complex/exp/complexAlgebraicFromExpForm.js +178 -0
- package/lib/exercises/math/complex/exp/complexExpFormPowerSimplify.d.ts +10 -0
- package/lib/exercises/math/complex/exp/complexExpFormPowerSimplify.d.ts.map +1 -0
- package/lib/exercises/math/complex/exp/complexExpFormPowerSimplify.js +152 -0
- package/lib/exercises/math/complex/exp/complexExpFormProductSimplify.d.ts +11 -0
- package/lib/exercises/math/complex/exp/complexExpFormProductSimplify.d.ts.map +1 -0
- package/lib/exercises/math/complex/exp/complexExpFormProductSimplify.js +165 -0
- package/lib/exercises/math/complex/exp/complexExpFormQuotientSimplify.d.ts +11 -0
- package/lib/exercises/math/complex/exp/complexExpFormQuotientSimplify.d.ts.map +1 -0
- package/lib/exercises/math/complex/exp/complexExpFormQuotientSimplify.js +164 -0
- package/lib/exercises/math/complex/exp/complexExpFromAlgebraicForm.d.ts +9 -0
- package/lib/exercises/math/complex/exp/complexExpFromAlgebraicForm.d.ts.map +1 -0
- package/lib/exercises/math/complex/exp/complexExpFromAlgebraicForm.js +175 -0
- package/lib/exercises/math/complex/exp/index.d.ts +5 -0
- package/lib/exercises/math/complex/exp/index.d.ts.map +1 -0
- package/lib/exercises/math/complex/exp/index.js +5 -0
- package/lib/exercises/math/complex/index.d.ts +1 -0
- package/lib/exercises/math/complex/index.d.ts.map +1 -1
- package/lib/exercises/math/complex/index.js +1 -0
- package/lib/exercises/math/complex/inverseComplex.d.ts.map +1 -1
- package/lib/exercises/math/complex/inverseComplex.js +35 -2
- package/lib/exercises/math/complex/linearCombinaisonComplex.d.ts.map +1 -1
- package/lib/exercises/math/complex/linearCombinaisonComplex.js +36 -5
- package/lib/exercises/math/complex/moduloFromAlgebraicComplex.d.ts.map +1 -1
- package/lib/exercises/math/complex/moduloFromAlgebraicComplex.js +38 -9
- package/lib/exercises/math/derivation/problems/index.d.ts +0 -1
- package/lib/exercises/math/derivation/problems/index.d.ts.map +1 -1
- package/lib/exercises/math/derivation/problems/index.js +1 -1
- package/lib/exercises/math/trigonometry/formulas/index.d.ts +2 -0
- package/lib/exercises/math/trigonometry/formulas/index.d.ts.map +1 -0
- package/lib/exercises/math/trigonometry/formulas/index.js +1 -0
- package/lib/exercises/math/trigonometry/formulas/trigoAdditionFormulaUsage.d.ts +8 -0
- package/lib/exercises/math/trigonometry/formulas/trigoAdditionFormulaUsage.d.ts.map +1 -0
- package/lib/exercises/math/trigonometry/formulas/trigoAdditionFormulaUsage.js +217 -0
- package/lib/exercises/math/trigonometry/index.d.ts +1 -0
- package/lib/exercises/math/trigonometry/index.d.ts.map +1 -1
- package/lib/exercises/math/trigonometry/index.js +1 -0
- package/lib/index.d.ts +21 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/playground.d.ts +0 -5
- package/lib/playground.d.ts.map +1 -1
- package/lib/playground.js +3 -9
- package/lib/tree/nodes/algebraicNode.d.ts +2 -0
- package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
- package/lib/tree/nodes/complex/complexNode.d.ts +3 -0
- package/lib/tree/nodes/complex/complexNode.d.ts.map +1 -1
- package/lib/tree/nodes/complex/complexNode.js +8 -0
- package/lib/tree/nodes/functions/absNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/absNode.js +6 -1
- package/lib/tree/nodes/functions/expNode.d.ts +2 -2
- package/lib/tree/nodes/functions/expNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/expNode.js +2 -2
- package/lib/tree/nodes/node.d.ts +1 -0
- package/lib/tree/nodes/node.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.js +6 -0
- package/lib/tree/nodes/operators/multiplyNode.d.ts +1 -1
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +11 -6
- package/package.json +1 -1
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { mainTrigoValues } from "../../../../math/trigonometry/remarkableValues.js";
|
|
4
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
5
|
+
import { abs } from "../../../../tree/nodes/functions/absNode.js";
|
|
6
|
+
import { cos } from "../../../../tree/nodes/functions/cosNode.js";
|
|
7
|
+
import { sin } from "../../../../tree/nodes/functions/sinNode.js";
|
|
8
|
+
import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
9
|
+
import { add } from "../../../../tree/nodes/operators/addNode.js";
|
|
10
|
+
import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
11
|
+
import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
|
|
12
|
+
import { random } from "../../../../utils/alea/random.js";
|
|
13
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
14
|
+
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
15
|
+
const getPropositions = (n, { answer, rIds, thetaIds }) => {
|
|
16
|
+
const propositions = [];
|
|
17
|
+
addValidProp(propositions, answer);
|
|
18
|
+
tryToAddWrongProp(propositions, getAnswer({
|
|
19
|
+
rIds: (1).toTree().toIdentifiers(),
|
|
20
|
+
thetaIds: thetaIds,
|
|
21
|
+
}));
|
|
22
|
+
propWhile(propositions, n, () => {
|
|
23
|
+
const fakeTheta = random(mainTrigoValues).angle;
|
|
24
|
+
tryToAddWrongProp(propositions, getAnswer({
|
|
25
|
+
rIds,
|
|
26
|
+
thetaIds: fakeTheta.toIdentifiers(),
|
|
27
|
+
}));
|
|
28
|
+
});
|
|
29
|
+
return shuffleProps(propositions, n);
|
|
30
|
+
};
|
|
31
|
+
const getRawAnswerNode = (identifiers) => {
|
|
32
|
+
const { rIds, thetaIds } = identifiers;
|
|
33
|
+
const r = reifyAlgebraic(rIds);
|
|
34
|
+
const theta = reifyAlgebraic(thetaIds);
|
|
35
|
+
const re = multiply(r, cos(theta)).simplify();
|
|
36
|
+
const im = multiply(r, sin(theta)).simplify();
|
|
37
|
+
return add(re, multiply(im, "i"));
|
|
38
|
+
};
|
|
39
|
+
const getAnswer = (identifiers) => {
|
|
40
|
+
return getRawAnswerNode(identifiers)
|
|
41
|
+
.simplify({
|
|
42
|
+
noAddOrder: true,
|
|
43
|
+
forceDistributeFractions: true,
|
|
44
|
+
towardsDistribute: true,
|
|
45
|
+
forbidFactorize: true,
|
|
46
|
+
})
|
|
47
|
+
.toTex();
|
|
48
|
+
};
|
|
49
|
+
const getInstruction = (identifiers) => {
|
|
50
|
+
const { rIds, thetaIds } = identifiers;
|
|
51
|
+
const r = reifyAlgebraic(rIds);
|
|
52
|
+
const theta = reifyAlgebraic(thetaIds);
|
|
53
|
+
const rawTheta = abs(theta).simplify();
|
|
54
|
+
return `Soit le nombre complexe :
|
|
55
|
+
|
|
56
|
+
$$
|
|
57
|
+
z = ${r.toTex()}e^{${theta.evaluate() < 0 ? "-" : ""}${multiply("i", rawTheta).toTex({
|
|
58
|
+
forceNoTimesSign: true,
|
|
59
|
+
})}}
|
|
60
|
+
$$
|
|
61
|
+
|
|
62
|
+
Écrire $z$ sous forme algébrique.`;
|
|
63
|
+
};
|
|
64
|
+
const getHint = () => {
|
|
65
|
+
return `Pour tout réel $\\theta$, on a :
|
|
66
|
+
|
|
67
|
+
$$
|
|
68
|
+
e^{i\\theta} = \\cos(\\theta)+i\\sin(\\theta)
|
|
69
|
+
$$`;
|
|
70
|
+
};
|
|
71
|
+
const getCorrection = (identifiers) => {
|
|
72
|
+
const { rIds, thetaIds } = identifiers;
|
|
73
|
+
const r = reifyAlgebraic(rIds);
|
|
74
|
+
const theta = reifyAlgebraic(thetaIds);
|
|
75
|
+
const rawTheta = abs(theta).simplify();
|
|
76
|
+
const rawRe = cos(theta).simplify().toTex();
|
|
77
|
+
const rawIm = multiply("i", sin(theta))
|
|
78
|
+
.simplify({
|
|
79
|
+
forceDistributeFractions: true,
|
|
80
|
+
})
|
|
81
|
+
.toTex();
|
|
82
|
+
return `Pour tout réel $\\theta$, on a :
|
|
83
|
+
|
|
84
|
+
$$
|
|
85
|
+
e^{i\\theta} = \\cos(\\theta)+i\\sin(\\theta)
|
|
86
|
+
$$
|
|
87
|
+
|
|
88
|
+
Ici, on a donc :
|
|
89
|
+
|
|
90
|
+
${alignTex([
|
|
91
|
+
[
|
|
92
|
+
`e^{${theta.evaluate() < 0 ? "-" : ""}${multiply("i", rawTheta).toTex({
|
|
93
|
+
forceNoTimesSign: true,
|
|
94
|
+
})}}`,
|
|
95
|
+
"=",
|
|
96
|
+
cos(theta).toTex() + "+" + multiply("i", sin(theta)).toTex(),
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
"",
|
|
100
|
+
"=",
|
|
101
|
+
add(rawRe, rawIm)
|
|
102
|
+
.simplify({
|
|
103
|
+
noAddOrder: true,
|
|
104
|
+
})
|
|
105
|
+
.toTex(),
|
|
106
|
+
],
|
|
107
|
+
])}
|
|
108
|
+
|
|
109
|
+
On multiplie alors par $${r.toTex()}$ :
|
|
110
|
+
|
|
111
|
+
$$
|
|
112
|
+
z = ${getAnswer(identifiers)}
|
|
113
|
+
$$
|
|
114
|
+
`;
|
|
115
|
+
};
|
|
116
|
+
const getKeys = () => {
|
|
117
|
+
return ["i"];
|
|
118
|
+
};
|
|
119
|
+
const isAnswerValid = (ans, { answer, ...identifiers }) => {
|
|
120
|
+
try {
|
|
121
|
+
const parsed = parseAlgebraic(ans);
|
|
122
|
+
return (parsed
|
|
123
|
+
.simplify({
|
|
124
|
+
towardsDistribute: true,
|
|
125
|
+
forbidFactorize: true,
|
|
126
|
+
forceDistributeFractions: true,
|
|
127
|
+
})
|
|
128
|
+
.toTex() ===
|
|
129
|
+
getRawAnswerNode(identifiers)
|
|
130
|
+
.simplify({
|
|
131
|
+
towardsDistribute: true,
|
|
132
|
+
forbidFactorize: true,
|
|
133
|
+
forceDistributeFractions: true,
|
|
134
|
+
})
|
|
135
|
+
.toTex());
|
|
136
|
+
}
|
|
137
|
+
catch (err) {
|
|
138
|
+
return handleVEAError(err);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const getComplexAlgebraicFromExpFormQuestion = () => {
|
|
142
|
+
const angle = random(mainTrigoValues).angle;
|
|
143
|
+
const r = randint(1, 10);
|
|
144
|
+
const identifiers = {
|
|
145
|
+
rIds: r.toTree().toIdentifiers(),
|
|
146
|
+
thetaIds: angle.toIdentifiers(),
|
|
147
|
+
};
|
|
148
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
149
|
+
};
|
|
150
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
151
|
+
return {
|
|
152
|
+
answer: getAnswer(identifiers),
|
|
153
|
+
instruction: getInstruction(identifiers),
|
|
154
|
+
keys: getKeys(identifiers),
|
|
155
|
+
answerFormat: "tex",
|
|
156
|
+
identifiers,
|
|
157
|
+
hint: getHint(identifiers),
|
|
158
|
+
correction: getCorrection(identifiers),
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
export const complexAlgebraicFromExpForm = {
|
|
162
|
+
id: "complexAlgebraicFromExpForm",
|
|
163
|
+
connector: "=",
|
|
164
|
+
label: "Donner la forme algébrique d'un complexe écrit sous forme exponentielle",
|
|
165
|
+
isSingleStep: true,
|
|
166
|
+
generator: (nb, opts) => getDistinctQuestions(() => getComplexAlgebraicFromExpFormQuestion(opts), nb),
|
|
167
|
+
qcmTimer: 60,
|
|
168
|
+
freeTimer: 60,
|
|
169
|
+
getPropositions,
|
|
170
|
+
isAnswerValid,
|
|
171
|
+
subject: "Mathématiques",
|
|
172
|
+
getInstruction,
|
|
173
|
+
getHint,
|
|
174
|
+
getCorrection,
|
|
175
|
+
getAnswer,
|
|
176
|
+
getQuestionFromIdentifiers,
|
|
177
|
+
hasHintAndCorrection: true,
|
|
178
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
z1ModuleIds: NodeIdentifiers;
|
|
5
|
+
z1ArgIds: NodeIdentifiers;
|
|
6
|
+
pow: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const complexExpFormPowerSimplify: Exercise<Identifiers>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=complexExpFormPowerSimplify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complexExpFormPowerSimplify.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/complex/exp/complexExpFormPowerSimplify.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAY7C,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,eAAe,CAAC;IAC7B,QAAQ,EAAE,eAAe,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AA4JF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAsB7D,CAAC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { mainTrigoValues } from "../../../../math/trigonometry/remarkableValues.js";
|
|
4
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
5
|
+
import { abs } from "../../../../tree/nodes/functions/absNode.js";
|
|
6
|
+
import { exp } from "../../../../tree/nodes/functions/expNode.js";
|
|
7
|
+
import { logn } from "../../../../tree/nodes/functions/logNode.js";
|
|
8
|
+
import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
9
|
+
import { PiNode } from "../../../../tree/nodes/numbers/piNode.js";
|
|
10
|
+
import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
11
|
+
import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
12
|
+
import { power } from "../../../../tree/nodes/operators/powerNode.js";
|
|
13
|
+
import { substract } from "../../../../tree/nodes/operators/substractNode.js";
|
|
14
|
+
import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
|
|
15
|
+
import { random } from "../../../../utils/alea/random.js";
|
|
16
|
+
import { doWhile } from "../../../../utils/doWhile.js";
|
|
17
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
18
|
+
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
19
|
+
const getPropositions = (n, { answer, ...identifiers }) => {
|
|
20
|
+
const propositions = [];
|
|
21
|
+
addValidProp(propositions, answer);
|
|
22
|
+
const { z1ArgIds, z1ModuleIds, pow } = identifiers;
|
|
23
|
+
const z1Arg = reifyAlgebraic(z1ArgIds);
|
|
24
|
+
const z1Module = reifyAlgebraic(z1ModuleIds);
|
|
25
|
+
const module = power(z1Module, pow).simplify();
|
|
26
|
+
const arg = multiply(z1Arg, pow).simplify();
|
|
27
|
+
propWhile(propositions, n, () => {
|
|
28
|
+
const z1ModuleFake = randint(2, 10);
|
|
29
|
+
const z1ArgFake = random(mainTrigoValues.filter((a) => a.angle.evaluate({}) !== 0));
|
|
30
|
+
const moduleFake = power(z1ModuleFake, pow).simplify();
|
|
31
|
+
const argFake = multiply(z1ArgFake.angle, pow).simplify();
|
|
32
|
+
if (module.toTex() === moduleFake.toTex() &&
|
|
33
|
+
frac(substract(argFake, arg), PiNode).simplify().evaluate() % 2 === 0)
|
|
34
|
+
return;
|
|
35
|
+
tryToAddWrongProp(propositions, `${moduleFake.toTex()}${getExpTex(argFake)}`);
|
|
36
|
+
});
|
|
37
|
+
return shuffleProps(propositions, n);
|
|
38
|
+
};
|
|
39
|
+
const getExpTex = (theta) => {
|
|
40
|
+
const rawTheta = abs(theta).simplify();
|
|
41
|
+
return `e^{${theta.evaluate() < 0 ? "-" : ""}${multiply("i", rawTheta).toTex({
|
|
42
|
+
forceNoTimesSign: true,
|
|
43
|
+
})}}`;
|
|
44
|
+
};
|
|
45
|
+
const getAnswer = (identifiers) => {
|
|
46
|
+
const { z1ArgIds, z1ModuleIds, pow } = identifiers;
|
|
47
|
+
const z1Arg = reifyAlgebraic(z1ArgIds);
|
|
48
|
+
const z1Module = reifyAlgebraic(z1ModuleIds);
|
|
49
|
+
const module = power(z1Module, pow).simplify();
|
|
50
|
+
const arg = multiply(z1Arg, pow).simplify();
|
|
51
|
+
return `${module.toTex()}${getExpTex(arg)}`;
|
|
52
|
+
};
|
|
53
|
+
const getInstruction = (identifiers) => {
|
|
54
|
+
throw new Error("wtf, 9^3e^3 plante, le parsage des puissances doit être tout pété. Aussi 9^3\\cos^3 donne un truc trop chelou. Après investigation : a^bc est mal parsé, que a soit nb ou e : il faut cut à a^b*c mais c'est parsé en a^{bc}...");
|
|
55
|
+
const { z1ArgIds, z1ModuleIds, pow } = identifiers;
|
|
56
|
+
const z1Arg = reifyAlgebraic(z1ArgIds);
|
|
57
|
+
const z1Module = reifyAlgebraic(z1ModuleIds);
|
|
58
|
+
return `Écrire sous forme exponentielle :
|
|
59
|
+
|
|
60
|
+
$$
|
|
61
|
+
\\left(${z1Module.toTex()}${getExpTex(z1Arg)}\\right)^{${pow}}
|
|
62
|
+
$$`;
|
|
63
|
+
};
|
|
64
|
+
const getHint = () => {
|
|
65
|
+
return `Pour tous nombres réels $\\theta$ et $\\theta'$ et tout entier relatif $n$, on a :
|
|
66
|
+
|
|
67
|
+
$$
|
|
68
|
+
\\left(e^{i\\theta}\\right)^n = e^{in\\theta}
|
|
69
|
+
$$`;
|
|
70
|
+
};
|
|
71
|
+
const getCorrection = (identifiers) => {
|
|
72
|
+
const { z1ArgIds, z1ModuleIds, pow } = identifiers;
|
|
73
|
+
const z1Arg = reifyAlgebraic(z1ArgIds);
|
|
74
|
+
const z1Module = reifyAlgebraic(z1ModuleIds);
|
|
75
|
+
return `On utilise la relation fonctionnelle : pour tous nombres réels $\\theta$ et $\\theta'$ et tout entier relatif $n$, on a
|
|
76
|
+
|
|
77
|
+
$$
|
|
78
|
+
\\left(e^{i\\theta}\\right)^n = e^{in\\theta}
|
|
79
|
+
$$
|
|
80
|
+
|
|
81
|
+
Ici, on a donc :
|
|
82
|
+
|
|
83
|
+
${alignTex([
|
|
84
|
+
["", `\\left(${z1Module.toTex()}${getExpTex(z1Arg)}\\right)^{${pow}}`],
|
|
85
|
+
[
|
|
86
|
+
"=",
|
|
87
|
+
multiply(power(z1Module, pow), exp(multiply("i", multiply(z1Arg, pow)))).toTex(),
|
|
88
|
+
],
|
|
89
|
+
["=", getAnswer(identifiers)],
|
|
90
|
+
])}`;
|
|
91
|
+
};
|
|
92
|
+
const getKeys = () => {
|
|
93
|
+
return ["epower", "i", "pi"];
|
|
94
|
+
};
|
|
95
|
+
const isAnswerValid = (ans, { z1ArgIds, z1ModuleIds, pow }) => {
|
|
96
|
+
try {
|
|
97
|
+
const z1Arg = reifyAlgebraic(z1ArgIds);
|
|
98
|
+
const z1Module = reifyAlgebraic(z1ModuleIds);
|
|
99
|
+
const module = power(z1Module, pow).simplify();
|
|
100
|
+
const angle = multiply(z1Arg, pow).simplify();
|
|
101
|
+
const parsed = parseAlgebraic(ans);
|
|
102
|
+
const expForm = multiply(module, exp(multiply("i", angle))).simplify();
|
|
103
|
+
console.log(expForm.toTex());
|
|
104
|
+
console.log(parsed.simplify().toTex());
|
|
105
|
+
const divided = frac(expForm, parsed).simplify();
|
|
106
|
+
return (parsed.simplify().toTex() === expForm.toTex() ||
|
|
107
|
+
frac(logn(divided), multiply(PiNode, "i")).simplify().evaluate() % 2 === 0);
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
return handleVEAError(err);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const getComplexExpFormPowerSimplifyQuestion = () => {
|
|
114
|
+
const z1Module = randint(2, 10);
|
|
115
|
+
const z1Arg = random(mainTrigoValues.filter((a) => a.angle.evaluate({}) !== 0));
|
|
116
|
+
const pow = doWhile(() => randint(2, 10), (x) => frac(multiply(z1Arg.angle, x), PiNode).simplify().evaluate({}) % 2 === 0);
|
|
117
|
+
const identifiers = {
|
|
118
|
+
z1ArgIds: z1Arg.angle.toIdentifiers(),
|
|
119
|
+
z1ModuleIds: z1Module.toTree().toIdentifiers(),
|
|
120
|
+
pow,
|
|
121
|
+
};
|
|
122
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
123
|
+
};
|
|
124
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
125
|
+
return {
|
|
126
|
+
answer: getAnswer(identifiers),
|
|
127
|
+
instruction: getInstruction(identifiers),
|
|
128
|
+
keys: getKeys(identifiers),
|
|
129
|
+
answerFormat: "tex",
|
|
130
|
+
identifiers,
|
|
131
|
+
hint: getHint(identifiers),
|
|
132
|
+
correction: getCorrection(identifiers),
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
export const complexExpFormPowerSimplify = {
|
|
136
|
+
id: "complexExpFormPowerSimplify",
|
|
137
|
+
connector: "=",
|
|
138
|
+
label: "Simplifier une puissance de formes exponentielles de nombres complexes",
|
|
139
|
+
isSingleStep: true,
|
|
140
|
+
generator: (nb, opts) => getDistinctQuestions(() => getComplexExpFormPowerSimplifyQuestion(opts), nb),
|
|
141
|
+
qcmTimer: 60,
|
|
142
|
+
freeTimer: 60,
|
|
143
|
+
getPropositions,
|
|
144
|
+
isAnswerValid,
|
|
145
|
+
subject: "Mathématiques",
|
|
146
|
+
getInstruction,
|
|
147
|
+
getHint,
|
|
148
|
+
getCorrection,
|
|
149
|
+
getAnswer,
|
|
150
|
+
getQuestionFromIdentifiers,
|
|
151
|
+
hasHintAndCorrection: true,
|
|
152
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
z1ModuleIds: NodeIdentifiers;
|
|
5
|
+
z1ArgIds: NodeIdentifiers;
|
|
6
|
+
z2ModuleIds: NodeIdentifiers;
|
|
7
|
+
z2ArgIds: NodeIdentifiers;
|
|
8
|
+
};
|
|
9
|
+
export declare const complexExpFormProductSimplify: Exercise<Identifiers>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=complexExpFormProductSimplify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complexExpFormProductSimplify.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/complex/exp/complexExpFormProductSimplify.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAW7C,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,eAAe,CAAC;IAC7B,QAAQ,EAAE,eAAe,CAAC;IAC1B,WAAW,EAAE,eAAe,CAAC;IAC7B,QAAQ,EAAE,eAAe,CAAC;CAC3B,CAAC;AAiLF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAqB/D,CAAC"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { mainTrigoValues } from "../../../../math/trigonometry/remarkableValues.js";
|
|
4
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
5
|
+
import { abs } from "../../../../tree/nodes/functions/absNode.js";
|
|
6
|
+
import { exp } from "../../../../tree/nodes/functions/expNode.js";
|
|
7
|
+
import { logn } from "../../../../tree/nodes/functions/logNode.js";
|
|
8
|
+
import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
9
|
+
import { PiNode } from "../../../../tree/nodes/numbers/piNode.js";
|
|
10
|
+
import { add } from "../../../../tree/nodes/operators/addNode.js";
|
|
11
|
+
import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
12
|
+
import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
13
|
+
import { substract } from "../../../../tree/nodes/operators/substractNode.js";
|
|
14
|
+
import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
|
|
15
|
+
import { random } from "../../../../utils/alea/random.js";
|
|
16
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
17
|
+
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
18
|
+
const getPropositions = (n, { answer, ...identifiers }) => {
|
|
19
|
+
const propositions = [];
|
|
20
|
+
addValidProp(propositions, answer);
|
|
21
|
+
const { z1ArgIds, z1ModuleIds, z2ArgIds, z2ModuleIds } = identifiers;
|
|
22
|
+
const z1Arg = reifyAlgebraic(z1ArgIds);
|
|
23
|
+
const z1Module = reifyAlgebraic(z1ModuleIds);
|
|
24
|
+
const z2Arg = reifyAlgebraic(z2ArgIds);
|
|
25
|
+
const z2Module = reifyAlgebraic(z2ModuleIds);
|
|
26
|
+
const module = multiply(z1Module, z2Module).simplify();
|
|
27
|
+
const arg = add(z1Arg, z2Arg).simplify();
|
|
28
|
+
propWhile(propositions, n, () => {
|
|
29
|
+
const z1ModuleFake = randint(2, 10);
|
|
30
|
+
const z2ModuleFake = randint(2, 10);
|
|
31
|
+
const z1ArgFake = random(mainTrigoValues.filter((a) => a.angle.evaluate({}) !== 0));
|
|
32
|
+
const z2ArgFake = random(mainTrigoValues.filter((a) => a.angle.evaluate({}) !== 0 &&
|
|
33
|
+
Math.abs(a.angle.evaluate()) !== Math.abs(z1ArgFake.angle.evaluate())));
|
|
34
|
+
const moduleFake = multiply(z1ModuleFake, z2ModuleFake).simplify();
|
|
35
|
+
const argFake = add(z1ArgFake.angle, z2ArgFake.angle).simplify();
|
|
36
|
+
if (module.toTex() === moduleFake.toTex() &&
|
|
37
|
+
frac(substract(argFake, arg), PiNode).simplify().evaluate() % 2 === 0)
|
|
38
|
+
return;
|
|
39
|
+
tryToAddWrongProp(propositions, `${moduleFake.toTex()}${getExpTex(argFake)}`);
|
|
40
|
+
});
|
|
41
|
+
return shuffleProps(propositions, n);
|
|
42
|
+
};
|
|
43
|
+
const getExpTex = (theta) => {
|
|
44
|
+
const rawTheta = abs(theta).simplify();
|
|
45
|
+
return `e^{${theta.evaluate() < 0 ? "-" : ""}${multiply("i", rawTheta).toTex({
|
|
46
|
+
forceNoTimesSign: true,
|
|
47
|
+
})}}`;
|
|
48
|
+
};
|
|
49
|
+
const getAnswer = (identifiers) => {
|
|
50
|
+
const { z1ArgIds, z1ModuleIds, z2ArgIds, z2ModuleIds } = identifiers;
|
|
51
|
+
const z1Arg = reifyAlgebraic(z1ArgIds);
|
|
52
|
+
const z1Module = reifyAlgebraic(z1ModuleIds);
|
|
53
|
+
const z2Arg = reifyAlgebraic(z2ArgIds);
|
|
54
|
+
const z2Module = reifyAlgebraic(z2ModuleIds);
|
|
55
|
+
const module = multiply(z1Module, z2Module).simplify();
|
|
56
|
+
const arg = add(z1Arg, z2Arg).simplify();
|
|
57
|
+
return `${module.toTex()}${getExpTex(arg)}`;
|
|
58
|
+
};
|
|
59
|
+
const getInstruction = (identifiers) => {
|
|
60
|
+
const { z1ArgIds, z1ModuleIds, z2ArgIds, z2ModuleIds } = identifiers;
|
|
61
|
+
const z1Arg = reifyAlgebraic(z1ArgIds);
|
|
62
|
+
const z1Module = reifyAlgebraic(z1ModuleIds);
|
|
63
|
+
const z2Arg = reifyAlgebraic(z2ArgIds);
|
|
64
|
+
const z2Module = reifyAlgebraic(z2ModuleIds);
|
|
65
|
+
return `Écrire sous forme exponentielle :
|
|
66
|
+
|
|
67
|
+
$$
|
|
68
|
+
\\left(${z1Module.toTex()}${getExpTex(z1Arg)}\\right)\\left(${z2Module.toTex()}${getExpTex(z2Arg)}\\right)
|
|
69
|
+
$$`;
|
|
70
|
+
};
|
|
71
|
+
const getHint = () => {
|
|
72
|
+
return `Pour tous nombres réels $\\theta$ et $\\theta'$, on a :
|
|
73
|
+
|
|
74
|
+
$$
|
|
75
|
+
e^{i\\theta} \\times e^{i\\theta'} = e^{i\\left(\\theta+\\theta'\\right)}
|
|
76
|
+
$$`;
|
|
77
|
+
};
|
|
78
|
+
const getCorrection = (identifiers) => {
|
|
79
|
+
const { z1ArgIds, z1ModuleIds, z2ArgIds, z2ModuleIds } = identifiers;
|
|
80
|
+
const z1Arg = reifyAlgebraic(z1ArgIds);
|
|
81
|
+
const z1Module = reifyAlgebraic(z1ModuleIds);
|
|
82
|
+
const z2Arg = reifyAlgebraic(z2ArgIds);
|
|
83
|
+
const z2Module = reifyAlgebraic(z2ModuleIds);
|
|
84
|
+
const module = multiply(z1Module, z2Module).simplify();
|
|
85
|
+
return `On utilise la relation fonctionnelle : pour tous nombres réels $\\theta$ et $\\theta'$, on a
|
|
86
|
+
|
|
87
|
+
$$
|
|
88
|
+
e^{i\\theta} \\times e^{i\\theta'} = e^{i\\left(\\theta+\\theta'\\right)}
|
|
89
|
+
$$
|
|
90
|
+
|
|
91
|
+
Ici, on a donc :
|
|
92
|
+
|
|
93
|
+
${alignTex([
|
|
94
|
+
[
|
|
95
|
+
"",
|
|
96
|
+
`\\left(${z1Module.toTex()}${getExpTex(z1Arg)}\\right)\\left(${z2Module.toTex()}${getExpTex(z2Arg)}\\right)`,
|
|
97
|
+
],
|
|
98
|
+
["=", multiply(module, exp(multiply("i", add(z1Arg, z2Arg)))).toTex()],
|
|
99
|
+
["=", getAnswer(identifiers)],
|
|
100
|
+
])}`;
|
|
101
|
+
};
|
|
102
|
+
const getKeys = () => {
|
|
103
|
+
return ["epower", "i", "pi"];
|
|
104
|
+
};
|
|
105
|
+
const isAnswerValid = (ans, { z1ArgIds, z1ModuleIds, z2ArgIds, z2ModuleIds }) => {
|
|
106
|
+
try {
|
|
107
|
+
const z1Arg = reifyAlgebraic(z1ArgIds);
|
|
108
|
+
const z1Module = reifyAlgebraic(z1ModuleIds);
|
|
109
|
+
const z2Arg = reifyAlgebraic(z2ArgIds);
|
|
110
|
+
const z2Module = reifyAlgebraic(z2ModuleIds);
|
|
111
|
+
const module = multiply(z1Module, z2Module).simplify();
|
|
112
|
+
const angle = add(z1Arg, z2Arg).simplify();
|
|
113
|
+
const parsed = parseAlgebraic(ans);
|
|
114
|
+
const expForm = multiply(module, exp(multiply("i", angle))).simplify();
|
|
115
|
+
const divided = frac(expForm, parsed).simplify();
|
|
116
|
+
return (parsed.simplify().toTex() === expForm.toTex() ||
|
|
117
|
+
frac(logn(divided), multiply(PiNode, "i")).simplify().evaluate() % 2 === 0);
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
return handleVEAError(err);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const getComplexExpFormProductSimplifyQuestion = () => {
|
|
124
|
+
const z1Module = randint(2, 10);
|
|
125
|
+
const z2Module = randint(2, 10);
|
|
126
|
+
const z1Arg = random(mainTrigoValues.filter((a) => a.angle.evaluate({}) !== 0));
|
|
127
|
+
const z2Arg = random(mainTrigoValues.filter((a) => a.angle.evaluate({}) !== 0 &&
|
|
128
|
+
Math.abs(a.angle.evaluate()) !== Math.abs(z1Arg.angle.evaluate())));
|
|
129
|
+
const identifiers = {
|
|
130
|
+
z1ArgIds: z1Arg.angle.toIdentifiers(),
|
|
131
|
+
z1ModuleIds: z1Module.toTree().toIdentifiers(),
|
|
132
|
+
z2ArgIds: z2Arg.angle.toIdentifiers(),
|
|
133
|
+
z2ModuleIds: z2Module.toTree().toIdentifiers(),
|
|
134
|
+
};
|
|
135
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
136
|
+
};
|
|
137
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
138
|
+
return {
|
|
139
|
+
answer: getAnswer(identifiers),
|
|
140
|
+
instruction: getInstruction(identifiers),
|
|
141
|
+
keys: getKeys(identifiers),
|
|
142
|
+
answerFormat: "tex",
|
|
143
|
+
identifiers,
|
|
144
|
+
hint: getHint(identifiers),
|
|
145
|
+
correction: getCorrection(identifiers),
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
export const complexExpFormProductSimplify = {
|
|
149
|
+
id: "complexExpFormProductSimplify",
|
|
150
|
+
connector: "=",
|
|
151
|
+
label: "Simplifier un produit de formes exponentielles de nombres complexes",
|
|
152
|
+
isSingleStep: true,
|
|
153
|
+
generator: (nb, opts) => getDistinctQuestions(() => getComplexExpFormProductSimplifyQuestion(opts), nb),
|
|
154
|
+
qcmTimer: 60,
|
|
155
|
+
freeTimer: 60,
|
|
156
|
+
getPropositions,
|
|
157
|
+
isAnswerValid,
|
|
158
|
+
subject: "Mathématiques",
|
|
159
|
+
getInstruction,
|
|
160
|
+
getHint,
|
|
161
|
+
getCorrection,
|
|
162
|
+
getAnswer,
|
|
163
|
+
getQuestionFromIdentifiers,
|
|
164
|
+
hasHintAndCorrection: true,
|
|
165
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
z1ModuleIds: NodeIdentifiers;
|
|
5
|
+
z1ArgIds: NodeIdentifiers;
|
|
6
|
+
z2ModuleIds: NodeIdentifiers;
|
|
7
|
+
z2ArgIds: NodeIdentifiers;
|
|
8
|
+
};
|
|
9
|
+
export declare const complexExpFormQuotientSimplify: Exercise<Identifiers>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=complexExpFormQuotientSimplify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complexExpFormQuotientSimplify.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/complex/exp/complexExpFormQuotientSimplify.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAU7C,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,eAAe,CAAC;IAC7B,QAAQ,EAAE,eAAe,CAAC;IAC1B,WAAW,EAAE,eAAe,CAAC;IAC7B,QAAQ,EAAE,eAAe,CAAC;CAC3B,CAAC;AAiLF,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,WAAW,CAqBhE,CAAC"}
|