math-exercises 3.0.173 → 3.0.174

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.
Files changed (63) hide show
  1. package/lib/exercises/math/functions/trinoms/parabole/parabolaVarTable.js +2 -2
  2. package/lib/exercises/math/functions/trinoms/parabole/paraboleSolveGraphEquation.js +1 -1
  3. package/lib/exercises/math/functions/trinoms/roots/rootsFromDevForm.d.ts.map +1 -1
  4. package/lib/exercises/math/functions/trinoms/roots/rootsFromDevForm.js +0 -1
  5. package/lib/exercises/math/probaStat/trees/buildTreeFromSituation.d.ts +2 -0
  6. package/lib/exercises/math/probaStat/trees/buildTreeFromSituation.d.ts.map +1 -0
  7. package/lib/exercises/math/probaStat/trees/buildTreeFromSituation.js +68 -0
  8. package/lib/exercises/math/probaStat/trees/fillProbaTreeWithComplementaryProbabilities.d.ts +15 -0
  9. package/lib/exercises/math/probaStat/trees/fillProbaTreeWithComplementaryProbabilities.d.ts.map +1 -0
  10. package/lib/exercises/math/probaStat/trees/fillProbaTreeWithComplementaryProbabilities.js +206 -0
  11. package/lib/exercises/math/probaStat/trees/probaTreeSituations.d.ts +2 -0
  12. package/lib/exercises/math/probaStat/trees/probaTreeSituations.d.ts.map +1 -0
  13. package/lib/exercises/math/probaStat/trees/probaTreeSituations.js +108 -0
  14. package/lib/exercises/math/probaStat/trees/probabilityTree.d.ts +25 -0
  15. package/lib/exercises/math/probaStat/trees/probabilityTree.d.ts.map +1 -0
  16. package/lib/exercises/math/probaStat/trees/probabilityTree.js +625 -0
  17. package/lib/exercises/math/probaStat/trees/treeInAnswer.d.ts +9 -0
  18. package/lib/exercises/math/probaStat/trees/treeInAnswer.d.ts.map +1 -0
  19. package/lib/exercises/math/probaStat/trees/treeInAnswer.js +107 -0
  20. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormula.js +1 -1
  21. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFirstRankOne.js +1 -1
  22. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFirstTermRandom.d.ts +4 -1
  23. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFirstTermRandom.d.ts.map +1 -1
  24. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFirstTermRandom.js +66 -24
  25. package/lib/exercises/math/trigonometry/circle/index.d.ts +1 -0
  26. package/lib/exercises/math/trigonometry/circle/index.d.ts.map +1 -1
  27. package/lib/exercises/math/trigonometry/circle/index.js +1 -0
  28. package/lib/exercises/math/trigonometry/circle/selectQuadrantOnTrigoCircle.d.ts +2 -0
  29. package/lib/exercises/math/trigonometry/circle/selectQuadrantOnTrigoCircle.d.ts.map +1 -0
  30. package/lib/exercises/math/trigonometry/circle/selectQuadrantOnTrigoCircle.js +94 -0
  31. package/lib/exercises/math/trigonometry/circle/trigoFunctionsFundamentalEquation.d.ts +10 -0
  32. package/lib/exercises/math/trigonometry/circle/trigoFunctionsFundamentalEquation.d.ts.map +1 -0
  33. package/lib/exercises/math/trigonometry/circle/trigoFunctionsFundamentalEquation.js +223 -0
  34. package/lib/exercises/math/trigonometry/functions/basicEquationCos.d.ts.map +1 -1
  35. package/lib/exercises/math/trigonometry/functions/basicEquationCos.js +2 -1
  36. package/lib/exercises/math/trigonometry/functions/cosInequationMainInterval.d.ts +10 -0
  37. package/lib/exercises/math/trigonometry/functions/cosInequationMainInterval.d.ts.map +1 -0
  38. package/lib/exercises/math/trigonometry/functions/cosInequationMainInterval.js +208 -0
  39. package/lib/exercises/math/trigonometry/functions/equationSinOnRandomInterval.d.ts +0 -6
  40. package/lib/exercises/math/trigonometry/functions/equationSinOnRandomInterval.d.ts.map +1 -1
  41. package/lib/exercises/math/trigonometry/functions/equationSinOnRandomInterval.js +162 -99
  42. package/lib/exercises/math/trigonometry/functions/index.d.ts +3 -0
  43. package/lib/exercises/math/trigonometry/functions/index.d.ts.map +1 -1
  44. package/lib/exercises/math/trigonometry/functions/index.js +3 -0
  45. package/lib/exercises/math/trigonometry/functions/readPeriodicityOnFunctionGraph.d.ts +12 -0
  46. package/lib/exercises/math/trigonometry/functions/readPeriodicityOnFunctionGraph.d.ts.map +1 -0
  47. package/lib/exercises/math/trigonometry/functions/readPeriodicityOnFunctionGraph.js +159 -0
  48. package/lib/exercises/math/trigonometry/functions/sinInequationMainInterval.d.ts +10 -0
  49. package/lib/exercises/math/trigonometry/functions/sinInequationMainInterval.d.ts.map +1 -0
  50. package/lib/exercises/math/trigonometry/functions/sinInequationMainInterval.js +224 -0
  51. package/lib/exercises/math/trigonometry/trigoFundamentalEquation.js +1 -1
  52. package/lib/exercises/vea/treeTableVEA.d.ts +2 -0
  53. package/lib/exercises/vea/treeTableVEA.d.ts.map +1 -0
  54. package/lib/exercises/vea/treeTableVEA.js +7 -0
  55. package/lib/index.d.ts +19 -1
  56. package/lib/index.d.ts.map +1 -1
  57. package/lib/tree/nodes/inequations/inequationNode.d.ts +1 -0
  58. package/lib/tree/nodes/inequations/inequationNode.d.ts.map +1 -1
  59. package/lib/tree/nodes/inequations/inequationNode.js +16 -0
  60. package/lib/utils/latex/poundify.d.ts +2 -0
  61. package/lib/utils/latex/poundify.d.ts.map +1 -0
  62. package/lib/utils/latex/poundify.js +3 -0
  63. package/package.json +1 -1
@@ -0,0 +1,107 @@
1
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
2
+ import { RationalConstructor } from "../../../../math/numbers/rationals/rational.js";
3
+ import { randfloat } from "../../../../math/utils/random/randfloat.js";
4
+ import { randint } from "../../../../math/utils/random/randint.js";
5
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
6
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
7
+ const getTreeDiagramAnswer = (identifiers) => {
8
+ return identifiers.answerTree;
9
+ };
10
+ const getInstruction = () => {
11
+ return `Compléter l'arbre suivant blabla`;
12
+ };
13
+ const getHint = () => {
14
+ return `indice`;
15
+ };
16
+ const getCorrection = () => {
17
+ return `correction`;
18
+ };
19
+ const getKeys = () => {
20
+ return ["A", "B", "C"];
21
+ };
22
+ const isAnswerTreeTableValid = (ans, { answerTreeTable }) => {
23
+ try {
24
+ return ans.every((step, i) => step.every((block, j) => block.every((branch, k) => branch.every((value, l) => value === answerTreeTable[i][j][k][l]))));
25
+ }
26
+ catch (err) {
27
+ return handleVEAError(err);
28
+ }
29
+ };
30
+ const getTreeInAnswerQuestion = () => {
31
+ // const steps = randint(2, 3);
32
+ const randomBlock = () => {
33
+ const branches = randint(2, 4);
34
+ const isDecimal = coinFlip();
35
+ const value = () => {
36
+ return isDecimal
37
+ ? randfloat(0.1, 1, 2)
38
+ : RationalConstructor.randomIrreductibleProba().toTree().toTex();
39
+ };
40
+ const res = [
41
+ [`${value()}`, "A"],
42
+ [`${value()}`, "B"],
43
+ ];
44
+ if (branches === 3)
45
+ res.push([`${value()}`, "C"]);
46
+ return res;
47
+ };
48
+ const firstBlock = randomBlock();
49
+ const firstBlockLength = firstBlock.length;
50
+ const tree = [[firstBlock], []];
51
+ for (let i = 0; i < firstBlockLength; i++) {
52
+ tree[1].push(randomBlock());
53
+ }
54
+ // if (steps === 3) {
55
+ // tree.push([]);
56
+ // tree[1].forEach((block) => {
57
+ // const length = block.length;
58
+ // for (let i = 0; i < length; i++) {
59
+ // tree[2].push(randomBlock());
60
+ // }
61
+ // });
62
+ // }
63
+ const initTree = structuredClone(tree);
64
+ const voidifyCell = () => {
65
+ const x = randint(0, tree.length);
66
+ const y = randint(0, tree[x].length);
67
+ const z = randint(0, tree[x][y].length);
68
+ const w = randint(0, tree[x][y][z].length);
69
+ initTree[x][y][z][w] = "";
70
+ };
71
+ const nbVoid = randint(1, 3);
72
+ for (let i = 0; i < nbVoid; i++) {
73
+ voidifyCell();
74
+ }
75
+ const identifiers = {
76
+ initTree,
77
+ answerTree: tree,
78
+ };
79
+ return getQuestionFromIdentifiers(identifiers);
80
+ };
81
+ const getQuestionFromIdentifiers = (identifiers) => {
82
+ return {
83
+ initTreeTable: identifiers.initTree,
84
+ answerTreeTable: getTreeDiagramAnswer(identifiers),
85
+ instruction: getInstruction(identifiers),
86
+ keys: getKeys(identifiers),
87
+ identifiers,
88
+ hint: getHint(identifiers),
89
+ correction: getCorrection(identifiers),
90
+ };
91
+ };
92
+ export const treeInAnswer = {
93
+ id: "treeInAnswer",
94
+ label: "Tree in answer",
95
+ isSingleStep: true,
96
+ generator: (nb, opts) => getDistinctQuestions(() => getTreeInAnswerQuestion(opts), nb),
97
+ qcmTimer: 60,
98
+ freeTimer: 60,
99
+ subject: "Mathématiques",
100
+ getInstruction,
101
+ getHint,
102
+ getCorrection,
103
+ getQuestionFromIdentifiers,
104
+ hasHintAndCorrection: true,
105
+ answerType: "treeDiagram",
106
+ isAnswerTreeTableValid,
107
+ };
@@ -99,7 +99,7 @@ const isAnswerValid = (ans, { reason, firstValue }) => {
99
99
  export const geometricFindExplicitFormula = {
100
100
  id: "geometricFindExplicitFormula",
101
101
  connector: "=",
102
- label: "Déterminer la formule générale d'une suite géométrique (premier rang $u_0$)",
102
+ label: "Déterminer la formule générale d'une suite géométrique à partir de la raison et de $u_0$",
103
103
  isSingleStep: false,
104
104
  generator: (nb) => getDistinctQuestions(getGeometricFindExplicitFormula, nb),
105
105
  qcmTimer: 60,
@@ -99,7 +99,7 @@ const isAnswerValid = (ans, { reason, firstValue }) => {
99
99
  export const geometricFindExplicitFormulaFirstRankOne = {
100
100
  id: "geometricFindExplicitFormulaFirstRankOne",
101
101
  connector: "=",
102
- label: "Déterminer la formule générale d'une suite géométrique (premier rang $u_1$)",
102
+ label: "Déterminer la formule générale d'une suite géométrique à partir de la raison et de $u_1$",
103
103
  isSingleStep: false,
104
104
  generator: (nb) => getDistinctQuestions(getGeometricFindExplicitFormula, nb),
105
105
  qcmTimer: 60,
@@ -4,6 +4,9 @@ type Identifiers = {
4
4
  firstValue: number;
5
5
  firstRank: number;
6
6
  };
7
- export declare const geometricFindExplicitFormulaFirstTermRandom: Exercise<Identifiers>;
7
+ type Options = {
8
+ firstTermRankOne: boolean;
9
+ };
10
+ export declare const geometricFindExplicitFormulaFirstTermRandom: Exercise<Identifiers, Options>;
8
11
  export {};
9
12
  //# sourceMappingURL=geometricFindExplicitFormulaFirstTermRandom.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"geometricFindExplicitFormulaFirstTermRandom.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricFindExplicitFormulaFirstTermRandom.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAgGF,eAAO,MAAM,2CAA2C,EAAE,QAAQ,CAAC,WAAW,CAe3E,CAAC"}
1
+ {"version":3,"file":"geometricFindExplicitFormulaFirstTermRandom.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricFindExplicitFormulaFirstTermRandom.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA6HF,KAAK,OAAO,GAAG;IACb,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AASF,eAAO,MAAM,2CAA2C,EAAE,QAAQ,CAChE,WAAW,EACX,OAAO,CAoBR,CAAC"}
@@ -1,13 +1,13 @@
1
- import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
1
+ import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { randint } from "../../../../math/utils/random/randint.js";
4
4
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
5
- import { EqualNode } from "../../../../tree/nodes/equations/equalNode.js";
6
- import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
7
- import { PowerNode } from "../../../../tree/nodes/operators/powerNode.js";
5
+ import { multiply, MultiplyNode, } from "../../../../tree/nodes/operators/multiplyNode.js";
6
+ import { power, PowerNode } from "../../../../tree/nodes/operators/powerNode.js";
8
7
  import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
9
8
  import { shuffle } from "../../../../utils/alea/shuffle.js";
10
- import { SubstractNode } from "../../../../tree/nodes/operators/substractNode.js";
9
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
10
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
11
11
  const getInstruction = (identifiers) => {
12
12
  const { firstRank, firstValue, reason } = identifiers;
13
13
  return `$(u_n)$ est une suite géométrique de premier terme $u_{${firstRank}} = ${firstValue}$ et de raison $q = ${reason}$.
@@ -16,26 +16,58 @@ Donner l'expression de $u_n$ en fonction de $n$.`;
16
16
  };
17
17
  const getAnswer = (identifiers) => {
18
18
  const { firstRank, firstValue, reason } = identifiers;
19
- const formula = new MultiplyNode(new NumberNode(firstValue), new PowerNode(new NumberNode(reason), new SubstractNode(new VariableNode("n"), firstRank.toTree())));
20
- const answer = "u_n=" + formula.toTex();
19
+ const formula = multiply(firstValue, power(reason, substract("n", firstRank)));
20
+ const answer = "u_n=" + formula.simplify().toTex();
21
21
  return answer;
22
22
  };
23
- const getQuestionFromIdentifiers = (identifiers) => {
24
- const question = {
25
- instruction: getInstruction(identifiers),
26
- answer: getAnswer(identifiers),
23
+ const getHint = () => {
24
+ return `La formule générale d'une suite géométrique $u$ de raison $q$ est, pour tous entiers $n$ et $k$ positifs :
25
+
26
+ $$
27
+ u_n = u_k\\times q^{n-k}
28
+ $$`;
29
+ };
30
+ const getCorrection = (identifiers) => {
31
+ const { firstRank, firstValue, reason } = identifiers;
32
+ const formula = multiply(firstValue, power(reason, substract("n", firstRank)));
33
+ const formulaSimp = formula.simplify();
34
+ return `La formule générale d'une suite géométrique $u$ de raison $q$ est, pour tous entiers $n$ et $k$ positifs :
35
+
36
+ $$
37
+ u_n = u_k\\times q^{n-k}
38
+ $$
39
+
40
+ Ici, on a donc :
41
+
42
+ $$
43
+ u_n = ${formula.toTex()}
44
+ $$
45
+
46
+ ${formula.toTex() !== formulaSimp.toTex()
47
+ ? `On peut simplifier :
48
+
49
+ $$
50
+ u_n = ${formulaSimp.toTex()}
51
+ $$`
52
+ : ""}`;
53
+ };
54
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
55
+ return {
56
+ instruction: getInstruction(identifiers, opts),
57
+ answer: getAnswer(identifiers, opts),
27
58
  keys: ["un", "equal", "n"],
28
59
  answerFormat: "tex",
29
60
  identifiers,
61
+ hint: getHint(identifiers, opts),
62
+ correction: getCorrection(identifiers, opts),
30
63
  };
31
- return question;
32
64
  };
33
- const getGeometricFindExplicitFormulaFirstTermRandom = () => {
34
- const firstRank = randint(0, 9);
65
+ const getGeometricFindExplicitFormulaFirstTermRandom = (opts) => {
66
+ const firstRank = randint(opts?.firstTermRankOne ? 1 : 0, 9);
35
67
  const firstValue = randint(1, 10);
36
68
  const reason = randint(2, 10);
37
69
  const identifiers = { reason, firstValue, firstRank };
38
- return getQuestionFromIdentifiers(identifiers);
70
+ return getQuestionFromIdentifiers(identifiers, opts);
39
71
  };
40
72
  const getPropositions = (n, { answer, reason, firstValue }) => {
41
73
  const propositions = [];
@@ -48,24 +80,34 @@ const getPropositions = (n, { answer, reason, firstValue }) => {
48
80
  });
49
81
  return shuffle(propositions);
50
82
  };
51
- const isAnswerValid = (ans, { reason, firstValue, firstRank }) => {
52
- const formula = new MultiplyNode(new NumberNode(firstValue), new PowerNode(new NumberNode(reason), new SubstractNode(new VariableNode("n"), firstRank.toTree())));
53
- const equal = new EqualNode(new VariableNode("u_n"), formula, {
54
- allowRawRightChildAsSolution: true,
55
- });
56
- const texs = equal.toAllValidTexs();
57
- return texs.includes(ans);
83
+ const isAnswerValid = (ans, { answer }) => {
84
+ const parsed = ans.includes("=")
85
+ ? parseAlgebraic(ans.split("=")[1])
86
+ : parseAlgebraic(ans);
87
+ if (!parsed)
88
+ return false;
89
+ return parsed.simplify().toTex() === answer.split("=")[1];
58
90
  };
91
+ const options = [
92
+ {
93
+ id: "firstTermRankOne",
94
+ label: "Utiliser $u_1$ comme premier terme",
95
+ target: GeneratorOptionTarget.generation,
96
+ type: GeneratorOptionType.checkbox,
97
+ },
98
+ ];
59
99
  export const geometricFindExplicitFormulaFirstTermRandom = {
60
100
  id: "geometricFindExplicitFormulaFirstTermRandom",
61
101
  connector: "=",
62
- label: "Déterminer la formule générale d'une suite géométrique (premier rang aléatoire)",
102
+ label: "Déterminer la formule générale d'une suite géométrique à partir de la raison et d'un terme donné",
63
103
  isSingleStep: false,
64
- generator: (nb) => getDistinctQuestions(getGeometricFindExplicitFormulaFirstTermRandom, nb),
104
+ generator: (nb, opts) => getDistinctQuestions(() => getGeometricFindExplicitFormulaFirstTermRandom(opts), nb),
65
105
  qcmTimer: 60,
66
106
  freeTimer: 60,
67
107
  getPropositions,
68
108
  isAnswerValid,
69
109
  subject: "Mathématiques",
70
110
  getQuestionFromIdentifiers,
111
+ hasHintAndCorrection: true,
112
+ options,
71
113
  };
@@ -6,4 +6,5 @@ export * from "./areReelsOnTheSameTrigoCirclePoint.js";
6
6
  export * from "./associateReelToTrigoCirclePoint.js";
7
7
  export * from "./placeAssociateAngleOnCircle.js";
8
8
  export * from "./findAssociateAnglePointOnTrigoCircle.js";
9
+ export * from "./trigoFunctionsFundamentalEquation.js";
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/trigonometry/circle/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,wCAAwC,CAAC;AACvD,cAAc,sCAAsC,CAAC;AAErD,cAAc,kCAAkC,CAAC;AACjD,cAAc,2CAA2C,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/trigonometry/circle/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,wCAAwC,CAAC;AACvD,cAAc,sCAAsC,CAAC;AAErD,cAAc,kCAAkC,CAAC;AACjD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,wCAAwC,CAAC"}
@@ -7,3 +7,4 @@ export * from "./associateReelToTrigoCirclePoint.js";
7
7
  // export * from "./findAngleFromCosAndSin.js";
8
8
  export * from "./placeAssociateAngleOnCircle.js";
9
9
  export * from "./findAssociateAnglePointOnTrigoCircle.js";
10
+ export * from "./trigoFunctionsFundamentalEquation.js";
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=selectQuadrantOnTrigoCircle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectQuadrantOnTrigoCircle.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/trigonometry/circle/selectQuadrantOnTrigoCircle.ts"],"names":[],"mappings":""}
@@ -0,0 +1,94 @@
1
+ // import {
2
+ // Exercise,
3
+ // Proposition,
4
+ // QCMGenerator,
5
+ // Question,
6
+ // QuestionGenerator,
7
+ // VEA,
8
+ // addValidProp,
9
+ // shuffleProps,
10
+ // GetAnswer,
11
+ // GetHint,
12
+ // GetCorrection,
13
+ // GetInstruction,
14
+ // GetKeys,
15
+ // GetQuestionFromIdentifiers,
16
+ // propWhile,
17
+ // } from "../../../../exercises/exercise.js";
18
+ // import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
19
+ // import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
20
+ // import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
21
+ export {};
22
+ // //angle donné genre Pi/6, donner la couleur
23
+ // //donner couleur pour signe cos et sin
24
+ // //une couleur est donnée, donner signe sin&cos
25
+ // type Identifiers = {
26
+ // angle?: NodeIdentifiers;
27
+ // };
28
+ // const getPropositions: QCMGenerator<Identifiers> = (n, { answer }) => {
29
+ // const propositions: Proposition[] = [];
30
+ // addValidProp(propositions, answer);
31
+ // propWhile(propositions, n, () => {
32
+ // throw Error("QCM not implemented");
33
+ // });
34
+ // return shuffleProps(propositions, n);
35
+ // };
36
+ // const getAnswer: GetAnswer<Identifiers> = (identifiers) => {};
37
+ // const getInstruction: GetInstruction<Identifiers> = (identifiers) => {
38
+ // return `On considère le cercle trigonométrique ci-dessous.
39
+ // https://heureuxhasarddocsbucket.s3.eu-west-3.amazonaws.com/mathliveV2/activities/quizzes/generator/piCercle_couleur.jpg`;
40
+ // };
41
+ // const getHint: GetHint<Identifiers> = (identifiers) => {};
42
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
43
+ // const getKeys: GetKeys<Identifiers> = (identifiers) => {
44
+ // return [];
45
+ // };
46
+ // const isAnswerValid: VEA<Identifiers> = (ans, { answer }) => {
47
+ // try {
48
+ // throw Error("VEA not implemented");
49
+ // } catch (err) {
50
+ // return handleVEAError(err);
51
+ // }
52
+ // };
53
+ // const getSelectQuadrantOnTrigoCircleQuestion: QuestionGenerator<Identifiers> = (
54
+ // ops,
55
+ // ) => {
56
+ // const identifiers: Identifiers = {};
57
+ // return getQuestionFromIdentifiers(identifiers);
58
+ // };
59
+ // const getQuestionFromIdentifiers: GetQuestionFromIdentifiers<Identifiers> = (
60
+ // identifiers,
61
+ // ) => {
62
+ // return {
63
+ // answer: getAnswer(identifiers),
64
+ // instruction: getInstruction(identifiers),
65
+ // keys: getKeys(identifiers),
66
+ // answerFormat: "tex",
67
+ // identifiers,
68
+ // hint: getHint(identifiers),
69
+ // correction: getCorrection(identifiers),
70
+ // };
71
+ // };
72
+ // export const selectQuadrantOnTrigoCircle: Exercise<Identifiers> = {
73
+ // id: "selectQuadrantOnTrigoCircle",
74
+ // label:
75
+ // "Donner le quadrant du cercle trigonométrique auquel un angle appartient",
76
+ // isSingleStep: true,
77
+ // generator: (nb, opts) =>
78
+ // getDistinctQuestions(
79
+ // () => getSelectQuadrantOnTrigoCircleQuestion(opts),
80
+ // nb,
81
+ // ),
82
+ // qcmTimer: 60,
83
+ // freeTimer: 60,
84
+ // getPropositions,
85
+ // isAnswerValid,
86
+ // subject: "Mathématiques",
87
+ // getInstruction,
88
+ // getHint,
89
+ // getCorrection,
90
+ // getAnswer,
91
+ // getQuestionFromIdentifiers,
92
+ // hasHintAndCorrection: true,
93
+ // answerType: "QCU",
94
+ // };
@@ -0,0 +1,10 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ isCos: boolean;
5
+ valueIds: NodeIdentifiers;
6
+ quadrant: number;
7
+ };
8
+ export declare const trigoFunctionsFundamentalEquation: Exercise<Identifiers>;
9
+ export {};
10
+ //# sourceMappingURL=trigoFunctionsFundamentalEquation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trigoFunctionsFundamentalEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/trigonometry/circle/trigoFunctionsFundamentalEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAY7C,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAsNF,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,WAAW,CAsBnE,CAAC"}
@@ -0,0 +1,223 @@
1
+ import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { RationalConstructor } from "../../../../math/numbers/rationals/rational.js";
4
+ import { randfloat } from "../../../../math/utils/random/randfloat.js";
5
+ import { opposite } from "../../../../tree/nodes/functions/oppositeNode.js";
6
+ import { sqrt } from "../../../../tree/nodes/functions/sqrtNode.js";
7
+ import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
8
+ import { PiNode } from "../../../../tree/nodes/numbers/piNode.js";
9
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
10
+ import { square } from "../../../../tree/nodes/operators/powerNode.js";
11
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
12
+ import { ClosureType } from "../../../../tree/nodes/sets/closure.js";
13
+ import { IntervalNode } from "../../../../tree/nodes/sets/intervalNode.js";
14
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
15
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
16
+ import { random } from "../../../../utils/alea/random.js";
17
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
18
+ const getPropositions = (n, { answer, ...identifiers }) => {
19
+ const propositions = [];
20
+ addValidProp(propositions, answer);
21
+ tryToAddWrongProp(propositions, opposite(getAnswerNode(identifiers)).toTex());
22
+ tryToAddWrongProp(propositions, getAnswerNode({
23
+ isCos: !identifiers.isCos,
24
+ quadrant: identifiers.quadrant,
25
+ valueIds: identifiers.valueIds,
26
+ }).toTex());
27
+ propWhile(propositions, n, () => {
28
+ let value = coinFlip()
29
+ ? randfloat(0.1, 1, 1).toTree()
30
+ : RationalConstructor.randomIrreductibleProba().toTree();
31
+ value = coinFlip() ? opposite(value).simplify() : value;
32
+ tryToAddWrongProp(propositions, getAnswer({
33
+ isCos: identifiers.isCos,
34
+ quadrant: identifiers.quadrant,
35
+ valueIds: value.toIdentifiers(),
36
+ }));
37
+ });
38
+ return shuffleProps(propositions, n);
39
+ };
40
+ const getAnswerNode = (identifiers) => {
41
+ const { isCos, valueIds, quadrant } = identifiers;
42
+ const value = reifyAlgebraic(valueIds);
43
+ const isPos = value.evaluate() >= 0;
44
+ const absValue = sqrt(substract(1, square(value))).simplify();
45
+ if (isCos) {
46
+ if (isPos) {
47
+ if (quadrant === 0)
48
+ return absValue;
49
+ return opposite(absValue);
50
+ }
51
+ else {
52
+ if (quadrant === 1)
53
+ return absValue;
54
+ return opposite(absValue);
55
+ }
56
+ }
57
+ else {
58
+ if (isPos) {
59
+ if (quadrant === 0)
60
+ return absValue;
61
+ return opposite(absValue);
62
+ }
63
+ else {
64
+ if (quadrant === 3)
65
+ return absValue;
66
+ return opposite(absValue);
67
+ }
68
+ }
69
+ };
70
+ const getAnswer = (identifiers) => {
71
+ return getAnswerNode(identifiers).toTex();
72
+ };
73
+ const getInterval = (identifiers) => {
74
+ const { quadrant } = identifiers;
75
+ switch (quadrant) {
76
+ case 0:
77
+ return new IntervalNode((0).toTree(), frac(PiNode, 2), ClosureType.FF);
78
+ case 1:
79
+ return new IntervalNode(frac(PiNode, 2), PiNode, ClosureType.FF);
80
+ case 2:
81
+ return new IntervalNode(opposite(PiNode), opposite(frac(PiNode, 2)), ClosureType.FF);
82
+ case 3:
83
+ default:
84
+ return new IntervalNode(opposite(frac(PiNode, 2)), (0).toTree(), ClosureType.FF);
85
+ }
86
+ };
87
+ const getInstruction = (identifiers) => {
88
+ const { isCos, valueIds } = identifiers;
89
+ const value = reifyAlgebraic(valueIds);
90
+ const interval = getInterval(identifiers);
91
+ return `On donne :
92
+
93
+ $$
94
+ ${isCos ? "\\cos" : "\\sin"}(x) = ${value.toTex()}
95
+ $$
96
+
97
+ avec
98
+
99
+ $$
100
+ ${interval.toInequality().toTex()}
101
+ $$
102
+
103
+ Déterminer $${isCos ? "\\sin" : "\\cos"}(x)$.`;
104
+ };
105
+ const getHint = (identifiers) => {
106
+ const { isCos } = identifiers;
107
+ const fct = isCos ? "\\sin(x)" : "\\cos(x)";
108
+ return `Utilise la propriété suivante : pour tout réel $x$,
109
+
110
+ $$
111
+ \\cos(x)^2 + \\sin(x)^2 = 1
112
+ $$
113
+
114
+ Grâce à cela, tu peux obtenir la valeur de $(${fct})^2$. Cela te donne donc deux valeurs possibles pour $${fct}$.
115
+
116
+ Pour déterminer laquelle est la bonne, utilise le quart de cercle auquel appartient $x$.
117
+ `;
118
+ };
119
+ const getCorrection = (identifiers) => {
120
+ const { isCos, valueIds, quadrant } = identifiers;
121
+ const fct = isCos ? "\\sin(x)" : "\\cos(x)";
122
+ const value = reifyAlgebraic(valueIds);
123
+ const squared = substract(1, square(value)).simplify();
124
+ const interval = getInterval(identifiers);
125
+ const answerNode = getAnswerNode(identifiers);
126
+ const answerIsPos = answerNode.evaluate() >= 0;
127
+ const direction = quadrant === 0
128
+ ? "nord-est"
129
+ : quadrant === 1
130
+ ? "nord-ouest"
131
+ : quadrant === 2
132
+ ? "sud-ouest"
133
+ : "sud-est";
134
+ return `On sait que :
135
+
136
+ $$
137
+ \\cos(x)^2 + \\sin(x)^2 = 1
138
+ $$
139
+
140
+ On a donc :
141
+
142
+ $$
143
+ ${fct}^2 = 1 - \\${isCos ? "cos" : "sin"}(x)^2 = ${squared.toTex()}
144
+ $$
145
+
146
+ On en déduit que $${fct}$ peut valoir $${sqrt(squared)
147
+ .simplify()
148
+ .toTex()}$ ou $${opposite(sqrt(squared)).simplify().toTex()}$.
149
+
150
+ Or, puique $${interval.toInequality().toTex()}$, $${fct}$ est ${answerIsPos ? "positif" : "négatif"} (car on est sur le quart "${direction}" du cercle trigonométrique).
151
+
152
+ Ainsi :
153
+
154
+ $$
155
+ ${fct}=${answerNode.toTex()}
156
+ $$
157
+ `;
158
+ };
159
+ const getKeys = () => {
160
+ return [];
161
+ };
162
+ const isAnswerValid = (ans, { answer, ...identifiers }) => {
163
+ try {
164
+ const parsed = parseAlgebraic(ans);
165
+ if (!parsed)
166
+ return false;
167
+ const value = getAnswerNode(identifiers).evaluate();
168
+ return Math.abs(parsed.evaluate() - value) < 0.01;
169
+ }
170
+ catch (err) {
171
+ return handleVEAError(err);
172
+ }
173
+ };
174
+ const getTrigoFunctionsFundamentalEquationQuestion = () => {
175
+ const isCos = coinFlip();
176
+ let value = coinFlip()
177
+ ? randfloat(0.1, 1, 1).toTree()
178
+ : RationalConstructor.randomIrreductibleProba().toTree();
179
+ value = coinFlip() ? opposite(value).simplify() : value;
180
+ const isPos = value.evaluate() >= 0;
181
+ const quadrant = isCos
182
+ ? isPos
183
+ ? random([0, 3])
184
+ : random([1, 2])
185
+ : isPos
186
+ ? random([0, 1])
187
+ : random([2, 3]);
188
+ const identifiers = {
189
+ isCos,
190
+ valueIds: value.toIdentifiers(),
191
+ quadrant,
192
+ };
193
+ return getQuestionFromIdentifiers(identifiers);
194
+ };
195
+ const getQuestionFromIdentifiers = (identifiers) => {
196
+ return {
197
+ answer: getAnswer(identifiers),
198
+ instruction: getInstruction(identifiers),
199
+ keys: getKeys(identifiers),
200
+ answerFormat: "tex",
201
+ identifiers,
202
+ hint: getHint(identifiers),
203
+ correction: getCorrection(identifiers),
204
+ };
205
+ };
206
+ export const trigoFunctionsFundamentalEquation = {
207
+ id: "trigoFunctionsFundamentalEquation",
208
+ connector: "=",
209
+ label: "Connaissant $\\cos(x)$ et le quart de cercle auquel appartient $x$, déterminer $\\sin(x)$.",
210
+ isSingleStep: true,
211
+ generator: (nb, opts) => getDistinctQuestions(() => getTrigoFunctionsFundamentalEquationQuestion(opts), nb),
212
+ qcmTimer: 60,
213
+ freeTimer: 60,
214
+ getPropositions,
215
+ isAnswerValid,
216
+ subject: "Mathématiques",
217
+ getInstruction,
218
+ getHint,
219
+ getCorrection,
220
+ getAnswer,
221
+ getQuestionFromIdentifiers,
222
+ hasHintAndCorrection: true,
223
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"basicEquationCos.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/trigonometry/functions/basicEquationCos.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAmFF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAelD,CAAC"}
1
+ {"version":3,"file":"basicEquationCos.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/trigonometry/functions/basicEquationCos.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAmFF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAiBlD,CAAC"}
@@ -78,7 +78,7 @@ const getQuestionFromIdentifiers = (identifiers) => {
78
78
  export const basicEquationCos = {
79
79
  id: "basicEquationCos",
80
80
  connector: "\\iff",
81
- label: "Résoudre une équation du type $\\cos\\left(x\\right)=k$",
81
+ label: "Résoudre une équation du type $\\cos\\left(x\\right)=k$ sur l'intervalle $]-\\pi; \\pi]$",
82
82
  isSingleStep: true,
83
83
  generator: (nb) => getDistinctQuestions(getBasicEquationCosQuestion, nb, 9),
84
84
  qcmTimer: 60,
@@ -89,4 +89,5 @@ export const basicEquationCos = {
89
89
  subject: "Mathématiques",
90
90
  getQuestionFromIdentifiers,
91
91
  maxAllowedQuestions: 9,
92
+ // hasHintAndCorrection: true,
92
93
  };