math-exercises 3.0.178 → 3.0.179

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 (173) hide show
  1. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving1.d.ts +14 -0
  2. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving1.d.ts.map +1 -0
  3. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving1.js +283 -0
  4. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving3.d.ts +15 -0
  5. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving3.d.ts.map +1 -0
  6. package/lib/exercises/math/derivation/derivative/derivativeEquationSolving3.js +296 -0
  7. package/lib/exercises/math/derivation/derivative/exp/expDerivativeOne.js +3 -3
  8. package/lib/exercises/math/derivation/derivative/exp/expDerivativeProductFExp.d.ts +14 -0
  9. package/lib/exercises/math/derivation/derivative/exp/expDerivativeProductFExp.d.ts.map +1 -0
  10. package/lib/exercises/math/derivation/derivative/exp/expDerivativeProductFExp.js +346 -0
  11. package/lib/exercises/math/derivation/derivative/exp/expDerivativeQuotientFExp.d.ts +15 -0
  12. package/lib/exercises/math/derivation/derivative/exp/expDerivativeQuotientFExp.d.ts.map +1 -0
  13. package/lib/exercises/math/derivation/derivative/exp/expDerivativeQuotientFExp.js +435 -0
  14. package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.d.ts +13 -0
  15. package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.d.ts.map +1 -0
  16. package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.js +326 -0
  17. package/lib/exercises/math/derivation/derivativeNumber/signOfDerivativeNumberFromFunctionCurve.d.ts +14 -0
  18. package/lib/exercises/math/derivation/derivativeNumber/signOfDerivativeNumberFromFunctionCurve.d.ts.map +1 -0
  19. package/lib/exercises/math/derivation/derivativeNumber/signOfDerivativeNumberFromFunctionCurve.js +181 -0
  20. package/lib/exercises/math/derivation/derivativeNumber/valueTableImageAndDerivativeFromFunctionExpression.d.ts +10 -0
  21. package/lib/exercises/math/derivation/derivativeNumber/valueTableImageAndDerivativeFromFunctionExpression.d.ts.map +1 -0
  22. package/lib/exercises/math/derivation/derivativeNumber/valueTableImageAndDerivativeFromFunctionExpression.js +272 -0
  23. package/lib/exercises/math/derivation/problems/index.d.ts +5 -0
  24. package/lib/exercises/math/derivation/problems/index.d.ts.map +1 -0
  25. package/lib/exercises/math/derivation/problems/index.js +4 -0
  26. package/lib/exercises/math/derivation/problems/problemMaximizeBoxVolumeFindX.d.ts +8 -0
  27. package/lib/exercises/math/derivation/problems/problemMaximizeBoxVolumeFindX.d.ts.map +1 -0
  28. package/lib/exercises/math/derivation/problems/problemMaximizeBoxVolumeFindX.js +171 -0
  29. package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.d.ts +15 -0
  30. package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.d.ts.map +1 -0
  31. package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.js +328 -0
  32. package/lib/exercises/math/derivation/problems/problemMovementOnLineFindSpeedAtPoint.d.ts +13 -0
  33. package/lib/exercises/math/derivation/problems/problemMovementOnLineFindSpeedAtPoint.d.ts.map +1 -0
  34. package/lib/exercises/math/derivation/problems/problemMovementOnLineFindSpeedAtPoint.js +275 -0
  35. package/lib/exercises/math/derivation/problems/problemProjectileHeightFindAbscissa.d.ts +8 -0
  36. package/lib/exercises/math/derivation/problems/problemProjectileHeightFindAbscissa.d.ts.map +1 -0
  37. package/lib/exercises/math/derivation/problems/problemProjectileHeightFindAbscissa.js +137 -0
  38. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineY.d.ts +10 -0
  39. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineY.d.ts.map +1 -0
  40. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineY.js +478 -0
  41. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineYAndSlope.d.ts +10 -0
  42. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineYAndSlope.d.ts.map +1 -0
  43. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineYAndSlope.js +499 -0
  44. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingPoint.d.ts +10 -0
  45. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingPoint.d.ts.map +1 -0
  46. package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingPoint.js +240 -0
  47. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingBuildingTangent.d.ts +12 -0
  48. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingBuildingTangent.d.ts.map +1 -0
  49. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingBuildingTangent.js +436 -0
  50. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingPoint.d.ts +12 -0
  51. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingPoint.d.ts.map +1 -0
  52. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingPoint.js +219 -0
  53. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingSecant.d.ts +13 -0
  54. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingSecant.d.ts.map +1 -0
  55. package/lib/exercises/math/derivation/tangent/derivativeReadingByManipulatingSecant.js +273 -0
  56. package/lib/exercises/math/derivation/tangent/placePointsOfDerivativeFromGraph.d.ts +18 -0
  57. package/lib/exercises/math/derivation/tangent/placePointsOfDerivativeFromGraph.d.ts.map +1 -0
  58. package/lib/exercises/math/derivation/tangent/placePointsOfDerivativeFromGraph.js +295 -0
  59. package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.d.ts +13 -0
  60. package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.d.ts.map +1 -0
  61. package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.js +388 -0
  62. package/lib/exercises/math/derivation/tangent/tangentEquationFromGraph.d.ts +9 -0
  63. package/lib/exercises/math/derivation/tangent/tangentEquationFromGraph.d.ts.map +1 -0
  64. package/lib/exercises/math/derivation/tangent/tangentEquationFromGraph.js +308 -0
  65. package/lib/exercises/math/derivation/variations/findAbscissaOfExtremaFromFunctionExpression.d.ts +14 -0
  66. package/lib/exercises/math/derivation/variations/findAbscissaOfExtremaFromFunctionExpression.d.ts.map +1 -0
  67. package/lib/exercises/math/derivation/variations/findAbscissaOfExtremaFromFunctionExpression.js +439 -0
  68. package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.d.ts +14 -0
  69. package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.d.ts.map +1 -0
  70. package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.js +547 -0
  71. package/lib/exercises/math/derivation/variations/plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.d.ts +15 -0
  72. package/lib/exercises/math/derivation/variations/plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.d.ts.map +1 -0
  73. package/lib/exercises/math/derivation/variations/plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.js +537 -0
  74. package/lib/exercises/math/derivation/variations/plausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomial.d.ts +15 -0
  75. package/lib/exercises/math/derivation/variations/plausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomial.d.ts.map +1 -0
  76. package/lib/exercises/math/derivation/variations/plausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomial.js +639 -0
  77. package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.d.ts +14 -0
  78. package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.d.ts.map +1 -0
  79. package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.js +530 -0
  80. package/lib/exercises/math/derivation/variations/signVarTableProductFExp.d.ts +10 -0
  81. package/lib/exercises/math/derivation/variations/signVarTableProductFExp.d.ts.map +1 -0
  82. package/lib/exercises/math/derivation/variations/signVarTableProductFExp.js +451 -0
  83. package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.d.ts +11 -0
  84. package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.d.ts.map +1 -0
  85. package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.js +514 -0
  86. package/lib/exercises/math/functions/composition/index.d.ts +0 -1
  87. package/lib/exercises/math/functions/composition/index.d.ts.map +1 -1
  88. package/lib/exercises/math/functions/composition/index.js +1 -1
  89. package/lib/exercises/math/functions/exponential/algebraic/index.d.ts +0 -1
  90. package/lib/exercises/math/functions/exponential/algebraic/index.d.ts.map +1 -1
  91. package/lib/exercises/math/functions/exponential/algebraic/index.js +1 -1
  92. package/lib/exercises/math/functions/trinoms/sign/signOfProductOfAffineAndTrinom.d.ts.map +1 -1
  93. package/lib/exercises/math/functions/trinoms/sign/signOfProductOfAffineAndTrinom.js +4 -11
  94. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOrthoInSquare.d.ts.map +1 -1
  95. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOrthoInSquare.js +32 -17
  96. package/lib/exercises/math/probaStat/conditional/conditionalProbaFromTableWithContext.d.ts +13 -0
  97. package/lib/exercises/math/probaStat/conditional/conditionalProbaFromTableWithContext.d.ts.map +1 -0
  98. package/lib/exercises/math/probaStat/conditional/conditionalProbaFromTableWithContext.js +195 -0
  99. package/lib/exercises/math/probaStat/conditional/conditionalProbaWriteFromFrench.d.ts +9 -0
  100. package/lib/exercises/math/probaStat/conditional/conditionalProbaWriteFromFrench.d.ts.map +1 -0
  101. package/lib/exercises/math/probaStat/conditional/conditionalProbaWriteFromFrench.js +220 -0
  102. package/lib/exercises/math/probaStat/conditional/conditionalProbability.d.ts +15 -0
  103. package/lib/exercises/math/probaStat/conditional/conditionalProbability.d.ts.map +1 -0
  104. package/lib/exercises/math/probaStat/conditional/conditionalProbability.js +332 -0
  105. package/lib/exercises/math/probaStat/conditional/fillTableConditionalProbabilitySituation.d.ts +8 -0
  106. package/lib/exercises/math/probaStat/conditional/fillTableConditionalProbabilitySituation.d.ts.map +1 -0
  107. package/lib/exercises/math/probaStat/conditional/fillTableConditionalProbabilitySituation.js +222 -0
  108. package/lib/exercises/math/probaStat/conditional/index.d.ts +5 -0
  109. package/lib/exercises/math/probaStat/conditional/index.d.ts.map +1 -0
  110. package/lib/exercises/math/probaStat/conditional/index.js +4 -0
  111. package/lib/exercises/math/probaStat/index.d.ts +1 -2
  112. package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
  113. package/lib/exercises/math/probaStat/index.js +1 -2
  114. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts +1 -0
  115. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
  116. package/lib/exercises/math/probaStat/probaFromTableWithContext.js +26 -199
  117. package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationProbabilityLaw.d.ts.map +1 -1
  118. package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationProbabilityLaw.js +6 -2
  119. package/lib/exercises/math/probaStat/randomVariable/utils/randomVariableSituations.d.ts.map +1 -1
  120. package/lib/exercises/math/probaStat/randomVariable/utils/randomVariableSituations.js +6 -5
  121. package/lib/exercises/math/probaStat/trees/buildTreeFromSituation.d.ts.map +1 -1
  122. package/lib/exercises/math/probaStat/trees/buildTreeFromSituation.js +4 -27
  123. package/lib/exercises/math/probaStat/twoEventsSituations.d.ts +29 -0
  124. package/lib/exercises/math/probaStat/twoEventsSituations.d.ts.map +1 -0
  125. package/lib/exercises/math/probaStat/twoEventsSituations.js +145 -0
  126. package/lib/exercises/math/sequences/explicitFormulaUsage.d.ts +4 -1
  127. package/lib/exercises/math/sequences/explicitFormulaUsage.d.ts.map +1 -1
  128. package/lib/exercises/math/sequences/explicitFormulaUsage.js +47 -7
  129. package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoTerms.js +1 -1
  130. package/lib/exercises/math/sequences/geometric/index.d.ts +0 -3
  131. package/lib/exercises/math/sequences/geometric/index.d.ts.map +1 -1
  132. package/lib/exercises/math/sequences/geometric/index.js +3 -3
  133. package/lib/exercises/math/sequences/geometric/situations/index.d.ts +0 -1
  134. package/lib/exercises/math/sequences/geometric/situations/index.d.ts.map +1 -1
  135. package/lib/exercises/math/sequences/geometric/situations/index.js +1 -1
  136. package/lib/exercises/math/sequences/recurrenceFormulaUsage.d.ts +5 -1
  137. package/lib/exercises/math/sequences/recurrenceFormulaUsage.d.ts.map +1 -1
  138. package/lib/exercises/math/sequences/recurrenceFormulaUsage.js +89 -9
  139. package/lib/exercises/math/trigonometry/circle/associatePoint.d.ts.map +1 -1
  140. package/lib/exercises/math/trigonometry/circle/associatePoint.js +55 -6
  141. package/lib/exercises/math/trigonometry/circle/selectQuadrantOnTrigoCircle.d.ts.map +1 -1
  142. package/lib/exercises/math/trigonometry/circle/selectQuadrantOnTrigoCircle.js +5 -6
  143. package/lib/exercises/math/trigonometry/functions/associateAngleSimplification.d.ts.map +1 -1
  144. package/lib/exercises/math/trigonometry/functions/associateAngleSimplification.js +1 -3
  145. package/lib/exercises/vea/polynomialVEA.d.ts +2 -0
  146. package/lib/exercises/vea/polynomialVEA.d.ts.map +1 -0
  147. package/lib/exercises/vea/polynomialVEA.js +17 -0
  148. package/lib/exercises/vea/valueTableVEA.d.ts +8 -0
  149. package/lib/exercises/vea/valueTableVEA.d.ts.map +1 -0
  150. package/lib/exercises/vea/valueTableVEA.js +12 -0
  151. package/lib/index.d.ts +27 -47
  152. package/lib/index.d.ts.map +1 -1
  153. package/lib/latexTester.d.ts.map +1 -1
  154. package/lib/latexTester.js +1 -1
  155. package/lib/math/utils/polynomial/polynomialInterpolationUtils.d.ts +19 -0
  156. package/lib/math/utils/polynomial/polynomialInterpolationUtils.d.ts.map +1 -0
  157. package/lib/math/utils/polynomial/polynomialInterpolationUtils.js +53 -0
  158. package/lib/math/utils/polynomial/polynomialUtils.d.ts +37 -0
  159. package/lib/math/utils/polynomial/polynomialUtils.d.ts.map +1 -0
  160. package/lib/math/utils/polynomial/polynomialUtils.js +223 -0
  161. package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts.map +1 -1
  162. package/lib/math/utils/sequences/situations/seqArithmeticSituations.js +6 -6
  163. package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
  164. package/lib/tree/nodes/operators/multiplyNode.js +1 -1
  165. package/lib/tree/nodes/operators/substractNode.d.ts.map +1 -1
  166. package/lib/tree/nodes/operators/substractNode.js +2 -1
  167. package/lib/tree/utilities/nodeUtils.d.ts +6 -0
  168. package/lib/tree/utilities/nodeUtils.d.ts.map +1 -0
  169. package/lib/tree/utilities/nodeUtils.js +24 -0
  170. package/lib/utils/strings/prependArticle.d.ts +2 -0
  171. package/lib/utils/strings/prependArticle.d.ts.map +1 -0
  172. package/lib/utils/strings/prependArticle.js +1 -0
  173. package/package.json +1 -1
@@ -0,0 +1,295 @@
1
+ import { toolBarConstructor } from "../../../../exercises/utils/geogebra/toolBarConstructor.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { blueMain, greenMain, orange, pinkMain, } from "../../../../geogebra/colors.js";
4
+ import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
5
+ import { GeogebraParser } from "../../../../geogebra/parsers/geogebraParser.js";
6
+ import { Point } from "../../../../math/geometry/point.js";
7
+ import { createArrNodeCoeffCubic, PointOfFunction, PointOfFunctionConstructor, } from "../../../../math/utils/polynomial/polynomialInterpolationUtils.js";
8
+ import { randint } from "../../../../math/utils/random/randint.js";
9
+ import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.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 { power } from "../../../../tree/nodes/operators/powerNode.js";
14
+ import { zip } from "../../../../utils/arrays/arrayZip.js";
15
+ import { joinanded } from "../../../../utils/strings/joinanded.js";
16
+ //create spline: seam cubics together
17
+ function createNodeFCubic(arrNodesCoeff) {
18
+ const [d, c, b, a] = arrNodesCoeff.map((node) => node.evaluate());
19
+ const nodeX = "x".toTree();
20
+ const nodeCubic = [d, c, b, a].reduce((acc, coeff, i) => {
21
+ return add(acc, multiply(coeff, power(nodeX, i)));
22
+ }, (0).toTree());
23
+ return nodeCubic;
24
+ }
25
+ function createCubicSpline(arrArrPOF) {
26
+ const arrChunk = arrArrPOF.map(([pof1, pof2]) => {
27
+ const nodeXStart = pof1.nodeAbscissa;
28
+ const nodeXEnd = pof2.nodeAbscissa;
29
+ const nodeFCubic = createNodeFCubic(createArrNodeCoeffCubic(pof1, pof2));
30
+ const chunk = {
31
+ nodeFCubic,
32
+ nodeXStart,
33
+ nodeXEnd,
34
+ };
35
+ return chunk;
36
+ });
37
+ const cubicSpline = new CubicSpline(arrChunk);
38
+ return cubicSpline;
39
+ }
40
+ class CubicSpline {
41
+ chunks;
42
+ constructor(chunks) {
43
+ this.chunks = chunks;
44
+ }
45
+ toIdentifiers() {
46
+ const arrChunkIds = this.chunks.map((chunk) => {
47
+ const chunkIds = {
48
+ nodeIdsFCubic: chunk.nodeFCubic.toIdentifiers(),
49
+ nodeIdsXStart: chunk.nodeXStart.toIdentifiers(),
50
+ nodeIdsXEnd: chunk.nodeXEnd.toIdentifiers(),
51
+ };
52
+ return chunkIds;
53
+ });
54
+ return {
55
+ chunkIds: arrChunkIds,
56
+ };
57
+ }
58
+ }
59
+ class CubicSplineConstructor {
60
+ static fromIdentifiers(cubicSplineIds) {
61
+ const arrChunk = cubicSplineIds.chunkIds.map((chunkIds) => {
62
+ const chunk = {
63
+ nodeFCubic: NodeConstructor.fromIdentifiers(chunkIds.nodeIdsFCubic),
64
+ nodeXStart: NodeConstructor.fromIdentifiers(chunkIds.nodeIdsXStart),
65
+ nodeXEnd: NodeConstructor.fromIdentifiers(chunkIds.nodeIdsXEnd),
66
+ };
67
+ return chunk;
68
+ });
69
+ return new CubicSpline(arrChunk);
70
+ }
71
+ }
72
+ const getSolutionPoints = (identifiers) => {
73
+ const { pofIds } = identifiers;
74
+ const arrPOF = pofIds.map((pofIds) => PointOfFunctionConstructor.fromIdentifiers(pofIds));
75
+ return arrPOF.map((pof, i) => {
76
+ const { nodeAbscissa, nodeDerivative } = pof;
77
+ return new Point(`S${i}`, nodeAbscissa, nodeDerivative);
78
+ });
79
+ };
80
+ const getInstruction = () => {
81
+ return `La courbe représentative d'une fonction $f$ (notée $C_f$) est tracée ci-dessous.
82
+
83
+ Les tangentes à $C_f$ en différents points sont également tracées.
84
+
85
+ Pour chaque tangente tracée, placer sur le même graphique, le point appartenant à la courbe représentative de $f'$.
86
+ `;
87
+ };
88
+ const getGGBAnswer = (identifiers) => {
89
+ const solutionPoints = getSolutionPoints(identifiers);
90
+ return [
91
+ ...solutionPoints.flatMap((point) => point.toGGBCommand({ color: `${greenMain}`, showLabel: false })),
92
+ ];
93
+ };
94
+ const getHint = () => {
95
+ return `Place chaque point de coordonnées $(x;f'(x))$.`;
96
+ };
97
+ const getCorrection = (identifiers) => {
98
+ const solutionPoints = getSolutionPoints(identifiers);
99
+ return `On place chaque point de coordonnées $(x;f'(x))$.
100
+
101
+ On place donc les points de coordonnées ${joinanded(solutionPoints.map((p) => `$(${p.x.toTex()};${p.y.simplify().toTex()})$`), ", ", " et ")} (ci-dessous en vert).
102
+
103
+ On a également représenté ci-dessous la courbe représentative de la fonction dérivée (en rose foncé) pour avoir une vue globale.`;
104
+ };
105
+ const getCorrectionGGBOptions = (identifiers) => {
106
+ const { cubicSplineIds, pofIds } = identifiers;
107
+ const cubicSpline = CubicSplineConstructor.fromIdentifiers(cubicSplineIds);
108
+ const arrPOF = pofIds.map((pofIds) => PointOfFunctionConstructor.fromIdentifiers(pofIds));
109
+ const ggb = new GeogebraConstructor({
110
+ commands: [
111
+ //function (chunks)
112
+ ...cubicSpline.chunks.flatMap((chunk, i, arr) => {
113
+ const isFirst = i === 0;
114
+ const isLast = i === arr.length - 1;
115
+ const xStart = isFirst ? -20 : chunk.nodeXStart.evaluate();
116
+ const xEnd = isLast ? +20 : chunk.nodeXEnd.evaluate();
117
+ return [
118
+ `f${i}(x) = Function(${chunk.nodeFCubic.toMathString()}, ${xStart}, ${xEnd})`,
119
+ `SetColor(f${i}, "${blueMain}")`,
120
+ ];
121
+ }),
122
+ //points with tangents
123
+ ...arrPOF.flatMap((pof, i) => {
124
+ const a = pof.nodeAbscissa.evaluate();
125
+ const u = pof.nodeValue.evaluate();
126
+ const v = pof.nodeDerivative.evaluate();
127
+ return [
128
+ `t${i}(x) = Function(${u} + ${v}(x-${a}), ${a} - 2, ${a} + 2)`,
129
+ `SetColor(t${i}, "${orange}")`,
130
+ `P${i} = Point({${a}, ${u}})`,
131
+ `SetFixed(P${i}, false, false)`,
132
+ `SetColor(P${i}, "${orange}")`,
133
+ ];
134
+ }),
135
+ //derivative (chunks)
136
+ ...cubicSpline.chunks.flatMap((chunk, i, arr) => {
137
+ const isFirst = i === 0;
138
+ const isLast = i === arr.length - 1;
139
+ const xStart = isFirst ? -20 : chunk.nodeXStart.evaluate();
140
+ const xEnd = isLast ? +20 : chunk.nodeXEnd.evaluate();
141
+ return [
142
+ `d${i}(x) = Function(${chunk.nodeFCubic
143
+ .derivative()
144
+ .toMathString()}, ${xStart}, ${xEnd})`,
145
+ `SetColor(d${i}, "${pinkMain}")`,
146
+ ];
147
+ }),
148
+ //derivative (points)
149
+ ...arrPOF.flatMap((pof, i) => {
150
+ const a = pof.nodeAbscissa.evaluate();
151
+ const v = pof.nodeDerivative.evaluate();
152
+ return [
153
+ `D${i} = Point({${a}, ${v}})`,
154
+ `SetFixed(D${i}, true, false)`,
155
+ `SetColor(D${i}, "${greenMain}")`,
156
+ ];
157
+ }),
158
+ ],
159
+ });
160
+ return ggb.getOptions({
161
+ coords: ggb.getCoordsForPoints([
162
+ ...arrPOF.map((pof, i) => new Point(`P${i}`, pof.nodeAbscissa, pof.nodeValue)),
163
+ ...getSolutionPoints(identifiers),
164
+ ]),
165
+ });
166
+ };
167
+ const getStudentGGBOptions = (identifiers) => {
168
+ const { cubicSplineIds, pofIds } = identifiers;
169
+ const cubicSpline = CubicSplineConstructor.fromIdentifiers(cubicSplineIds);
170
+ const arrPOF = pofIds.map((pofIds) => PointOfFunctionConstructor.fromIdentifiers(pofIds));
171
+ const ggb = new GeogebraConstructor({
172
+ commands: [
173
+ //function (chunks)
174
+ ...cubicSpline.chunks.flatMap((chunk, i, arr) => {
175
+ const isFirst = i === 0;
176
+ const isLast = i === arr.length - 1;
177
+ const xStart = isFirst ? -20 : chunk.nodeXStart.evaluate();
178
+ const xEnd = isLast ? +20 : chunk.nodeXEnd.evaluate();
179
+ return [
180
+ `f${i}(x) = Function(${chunk.nodeFCubic.toMathString()}, ${xStart}, ${xEnd})`,
181
+ `SetColor(f${i}, "${blueMain}")`,
182
+ ];
183
+ }),
184
+ //points with tangents
185
+ ...arrPOF.flatMap((pof, i) => {
186
+ const a = pof.nodeAbscissa.evaluate();
187
+ const u = pof.nodeValue.evaluate();
188
+ const v = pof.nodeDerivative.evaluate();
189
+ return [
190
+ `t${i}(x) = Function(${u} + ${v}(x-${a}), ${a} - 2, ${a} + 2)`,
191
+ `SetColor(t${i}, "${orange}")`,
192
+ `P${i} = Point({${a}, ${u}})`,
193
+ `SetFixed(P${i}, true, false)`,
194
+ `SetColor(P${i}, "${orange}")`,
195
+ ];
196
+ }),
197
+ ],
198
+ customToolBar: toolBarConstructor({
199
+ point: true,
200
+ }),
201
+ });
202
+ return ggb.getOptions({
203
+ coords: ggb.getCoordsForPoints([
204
+ ...arrPOF.map((pof, i) => new Point(`P${i}`, pof.nodeAbscissa, pof.nodeValue)),
205
+ ...getSolutionPoints(identifiers),
206
+ ]),
207
+ });
208
+ };
209
+ const isGGBAnswerValid = (ans, { ggbAnswer, ...identifiers }) => {
210
+ const commands = ans;
211
+ const ggbParser = new GeogebraParser(commands);
212
+ const objectDict = ggbParser.objectDict();
213
+ const pointsCoords = Object.keys(objectDict).map((name) => ggbParser.pointCoords(name));
214
+ const pointsCoordsSortedByAscX = pointsCoords.toSorted(([x1], [x2]) => {
215
+ return x1 - x2;
216
+ });
217
+ const solutionPointsSortedByAscX = getSolutionPoints(identifiers).toSorted((p1, p2) => {
218
+ return p1.x.evaluate() - p2.x.evaluate();
219
+ });
220
+ return (pointsCoordsSortedByAscX.length === solutionPointsSortedByAscX.length &&
221
+ pointsCoordsSortedByAscX.every(([x, y], i) => {
222
+ const studentPoint = new Point("StudentPoint", x, y);
223
+ const solutionPoint = solutionPointsSortedByAscX[i];
224
+ const distance = studentPoint.distanceTo(solutionPoint);
225
+ return distance < 1;
226
+ }));
227
+ };
228
+ const getPlacePointsOfDerivativeFromGraphQuestion = () => {
229
+ const arrNodeAbscissa = [
230
+ randint(-10, -5),
231
+ randint(-5, 0),
232
+ randint(0, 5),
233
+ randint(6, 10),
234
+ ].map((x) => x.toTree());
235
+ const arrNodeImage = arrNodeAbscissa
236
+ .slice(1)
237
+ .reduce((acc, _, i) => {
238
+ const yPrev = acc[i];
239
+ const yNew = yPrev + randint(-5, 6);
240
+ acc.push(yNew);
241
+ return acc;
242
+ }, [randint(-9, 10)])
243
+ .map((x) => x.toTree());
244
+ const arrNodeDerivative = arrNodeAbscissa.map(() => {
245
+ const num = randint(-3, 3);
246
+ const den = randint(-3, 3, [0]);
247
+ return frac(num, den);
248
+ });
249
+ const arrPOF = zip(arrNodeAbscissa, zip(arrNodeImage, arrNodeDerivative)).map(([nodeAbscissa, [nodeValue, nodeDerivative]]) => {
250
+ const pof = new PointOfFunction(nodeAbscissa, nodeValue, nodeDerivative);
251
+ return pof;
252
+ });
253
+ const arrArrPOF = zip(arrPOF.slice(0, -1), arrPOF.slice(1));
254
+ const cubicSpline = createCubicSpline(arrArrPOF);
255
+ const identifiers = {
256
+ cubicSplineIds: cubicSpline.toIdentifiers(),
257
+ pofIds: arrPOF.map((pof) => pof.toIdentifiers()),
258
+ };
259
+ return getQuestionFromIdentifiers(identifiers);
260
+ };
261
+ const getQuestionFromIdentifiers = (identifiers) => {
262
+ return {
263
+ ggbAnswer: getGGBAnswer(identifiers),
264
+ instruction: getInstruction(identifiers),
265
+ studentGgbOptions: getStudentGGBOptions(identifiers),
266
+ correctionGgbOptions: getCorrectionGGBOptions(identifiers),
267
+ identifiers,
268
+ hint: getHint(identifiers),
269
+ correction: getCorrection(identifiers),
270
+ style: {
271
+ tableOptions: {
272
+ firstCellIsDivided: false,
273
+ firstColumnIsHeader: true,
274
+ firstRowIsHeader: false,
275
+ },
276
+ },
277
+ };
278
+ };
279
+ export const placePointsOfDerivativeFromGraph = {
280
+ id: "placePointsOfDerivativeFromGraph",
281
+ label: "Placer des points de la dérivée à partir des tangentes à la courbe représentative d'une fonction",
282
+ isSingleStep: true,
283
+ generator: (nb, opts) => getDistinctQuestions(() => getPlacePointsOfDerivativeFromGraphQuestion(opts), nb),
284
+ ggbTimer: 60,
285
+ isGGBAnswerValid,
286
+ subject: "Mathématiques",
287
+ getHint,
288
+ getInstruction,
289
+ getCorrection,
290
+ getGGBAnswer,
291
+ getStudentGGBOptions,
292
+ answerType: "GGB",
293
+ getQuestionFromIdentifiers,
294
+ hasHintAndCorrection: true,
295
+ };
@@ -0,0 +1,13 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ nodeIdsXAsked: NodeIdentifiers;
5
+ nodeIdsF: NodeIdentifiers;
6
+ typeF: string;
7
+ };
8
+ type Options = {
9
+ typeF: string;
10
+ };
11
+ export declare const tangentEquationFromFunctionExpression: Exercise<Identifiers, Options>;
12
+ export {};
13
+ //# sourceMappingURL=tangentEquationFromFunctionExpression.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tangentEquationFromFunctionExpression.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAUrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAgF7C,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,eAAe,CAAC;IAC/B,QAAQ,EAAE,eAAe,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAsWF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAgDF,eAAO,MAAM,qCAAqC,EAAE,QAAQ,CAC1D,WAAW,EACX,OAAO,CAqBR,CAAC"}